diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-25 18:44:35 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-25 18:44:35 +0000 |
commit | 2c84495184c6d3de84f1b591ccb49c700273e0f5 (patch) | |
tree | 85e7ddcdbcfb25adc51f59837091c7ee10afd142 /libbb/lineedit.c | |
parent | 44f08212597f46caee40d2176feefcbb43653e16 (diff) | |
download | busybox-w32-2c84495184c6d3de84f1b591ccb49c700273e0f5.tar.gz busybox-w32-2c84495184c6d3de84f1b591ccb49c700273e0f5.tar.bz2 busybox-w32-2c84495184c6d3de84f1b591ccb49c700273e0f5.zip |
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
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r-- | libbb/lineedit.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 5a0d03eeb..d1a7a4bac 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -166,10 +166,17 @@ static void deinit_S(void) | |||
166 | } | 166 | } |
167 | #define DEINIT_S() deinit_S() | 167 | #define DEINIT_S() deinit_S() |
168 | 168 | ||
169 | |||
169 | /* Put 'command_ps[cursor]', cursor++. | 170 | /* Put 'command_ps[cursor]', cursor++. |
170 | * Advance cursor on screen. If we reached right margin, scroll text up | 171 | * Advance cursor on screen. If we reached right margin, scroll text up |
171 | * and remove terminal margin effect by printing 'next_char' */ | 172 | * and remove terminal margin effect by printing 'next_char' */ |
173 | #define HACK_FOR_WRONG_WIDTH 1 | ||
174 | #if HACK_FOR_WRONG_WIDTH | ||
175 | static void cmdedit_set_out_char(void) | ||
176 | #define cmdedit_set_out_char(next_char) cmdedit_set_out_char() | ||
177 | #else | ||
172 | static void cmdedit_set_out_char(int next_char) | 178 | static void cmdedit_set_out_char(int next_char) |
179 | #endif | ||
173 | { | 180 | { |
174 | int c = (unsigned char)command_ps[cursor]; | 181 | int c = (unsigned char)command_ps[cursor]; |
175 | 182 | ||
@@ -196,9 +203,21 @@ static void cmdedit_set_out_char(int next_char) | |||
196 | /* terminal is scrolled down */ | 203 | /* terminal is scrolled down */ |
197 | cmdedit_y++; | 204 | cmdedit_y++; |
198 | cmdedit_x = 0; | 205 | cmdedit_x = 0; |
206 | #if HACK_FOR_WRONG_WIDTH | ||
207 | /* This works better if our idea of term width is wrong | ||
208 | * and it is actually wider (often happens on serial lines). | ||
209 | * Printing CR,LF *forces* cursor to next line. | ||
210 | * OTOH if terminal width is correct AND terminal does NOT | ||
211 | * have automargin (IOW: it is moving cursor to next line | ||
212 | * by itself (which is wrong for VT-10x terminals)), | ||
213 | * this will break things: there will be one extra empty line */ | ||
214 | puts("\r"); /* + implicit '\n' */ | ||
215 | #else | ||
216 | /* Works ok only if cmdedit_termw is correct */ | ||
199 | /* destroy "(auto)margin" */ | 217 | /* destroy "(auto)margin" */ |
200 | bb_putchar(next_char); | 218 | bb_putchar(next_char); |
201 | bb_putchar('\b'); | 219 | bb_putchar('\b'); |
220 | #endif | ||
202 | } | 221 | } |
203 | // Huh? What if command_ps[cursor] == '\0' (we are at the end already?) | 222 | // Huh? What if command_ps[cursor] == '\0' (we are at the end already?) |
204 | cursor++; | 223 | cursor++; |