svn commit: trunk/busybox/libbb

vda at busybox.net vda at busybox.net
Fri Apr 25 18:44:35 UTC 2008


Author: vda
Date: 2008-04-25 11:44:35 -0700 (Fri, 25 Apr 2008)
New Revision: 21870

Log:
lineedit: hack for making it sort-of-work even if term width is wrong

function                                             old     new   delta
read_line_input                                     3158    3153      -5
input_end                                             29      24      -5
input_delete                                         115     110      -5
input_forward                                         27      20      -7
cmdedit_set_out_char                                  88      80      -8



Modified:
   trunk/busybox/libbb/lineedit.c


Changeset:
Modified: trunk/busybox/libbb/lineedit.c
===================================================================
--- trunk/busybox/libbb/lineedit.c	2008-04-25 17:30:17 UTC (rev 21869)
+++ trunk/busybox/libbb/lineedit.c	2008-04-25 18:44:35 UTC (rev 21870)
@@ -166,10 +166,17 @@
 }
 #define DEINIT_S() deinit_S()
 
+
 /* Put 'command_ps[cursor]', cursor++.
  * Advance cursor on screen. If we reached right margin, scroll text up
  * and remove terminal margin effect by printing 'next_char' */
+#define HACK_FOR_WRONG_WIDTH 1
+#if HACK_FOR_WRONG_WIDTH
+static void cmdedit_set_out_char(void)
+#define cmdedit_set_out_char(next_char) cmdedit_set_out_char()
+#else
 static void cmdedit_set_out_char(int next_char)
+#endif
 {
 	int c = (unsigned char)command_ps[cursor];
 
@@ -196,9 +203,21 @@
 		/* terminal is scrolled down */
 		cmdedit_y++;
 		cmdedit_x = 0;
+#if HACK_FOR_WRONG_WIDTH
+		/* This works better if our idea of term width is wrong
+		 * and it is actually wider (often happens on serial lines).
+		 * Printing CR,LF *forces* cursor to next line.
+		 * OTOH if terminal width is correct AND terminal does NOT
+		 * have automargin (IOW: it is moving cursor to next line
+		 * by itself (which is wrong for VT-10x terminals)),
+		 * this will break things: there will be one extra empty line */
+		puts("\r"); /* + implicit '\n' */
+#else
+		/* Works ok only if cmdedit_termw is correct */
 		/* destroy "(auto)margin" */
 		bb_putchar(next_char);
 		bb_putchar('\b');
+#endif
 	}
 // Huh? What if command_ps[cursor] == '\0' (we are at the end already?)
 	cursor++;




More information about the busybox-cvs mailing list