On Mon, 2010-07-19 at 02:44 +0200, Harald Becker wrote: > > On 17.07.2010 19:12, Christopher Barry wrote: > > looking for an easy way to capture the current cursor position. found a > > reference to 'ESC [ 6 n', but not sure how that works. > > > This is indeed the only way to get the current cursor position from an > ANSI compatible terminal. As soon as the terminal receive this control > sequence, it answers with a response sequence, which has to be captured > and translated into what you are looking for ... but that doesn't seam > to be, what you want. > > The mistake in your assumption is, that terminal screens are not part of > a main unix computer, like it is on a DOS/Windoof PC. Terminals a > separate devices, which get connected to an computer. The computer send > text and special escape sequences to control the behavior of the > terminal. The Linux virtual consoles just mimic this traditional > behaviour of terminals. This way the running application (or shell) has > no access to the actual cursor position. > > A possible resolution to your problem is the following: > > - collect all your text data that should be written to the terminal in > an variable > - count the length of actual data in the output variable > - compare it to the maximum number of columns the terminal has (see > shell variable COLUMNS) > - react if the maximum number of columns would be exceeded > > If you need to display your data, before a complete line has been > collected, you may consider to display the partial row, adding a > carriage return (not a new line) at the end. This displays the data on > the terminal and returns the cursor to the beginning of the line. Next > time the terminal line is overwritten with possibly the same data, > adding just more at the end. As soon as your next data junk would exceed > the maximum terminal column, you just need to send a new line to the > terminal and start a new line capturing internally. > > This was just a brief description of a resolution. The details depend on > what exactly you want to do. Feel free to ask, if you want to know more > about terminal behavior, operation and usage (But this is not a busybox > topic, it's a general Unix console operation topic). > > Tschau > Harald
Thank you Harald for an such an informative response. I do appreciate it. Regards, -C _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox