vi: odd behaviour when editing files
Denys Vlasenko
vda.linux at googlemail.com
Fri Dec 21 18:43:48 UTC 2007
On Tuesday 18 December 2007 18:46, Cristian Ionescu-Idbohrn wrote:
> As I did not get any reaction on this post:
>
> http://busybox.net/lists/busybox/2007-December/029525.html
>
> I'll start a new thread. Please refer to the link above.
> Please find attached a minimal .config and a data file which can help
> reproduce the problem. Edit that file and place the cursor on lines with
> length beyond 255 characters. That will produce various artifacts,
> depending on the terminal (I tested xterm, aterm and pterm).
This can be "fixed" (read: glossed over) with the following:
memset(buf, ' ', MAX_SCR_COLS); // blank-out the buffer
- buf[MAX_SCR_COLS-1] = 0; // NULL terminate the buffer
// format current text line into buf
format_line(buf, tp, li);
+ buf[MAX_SCR_COLS-2] = ' ';
+ buf[MAX_SCR_COLS-1] = '\0'; // NUL terminate the buffer
Does it work for you?
At a deeper look it is actually not that hard to lift
line lenght limitation completely! Hint: text[] buffer
has entire file as a continuous stream of '\n' delimited lines!
There are NO SEPARATE LINES! You only need to tinker with screen
redraw to fix it, underlying data structure has no line len
limitation!
--
vda
More information about the busybox
mailing list