aboutsummaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-05-17 19:28:14 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-05-17 19:28:14 +0200
commitc396fe6306f9a769d3a91809eb03361640c2f2fc (patch)
tree2c2d41e06da55a79b1c7eb702f25de3c8ec16c7e /libbb/lineedit.c
parent020f40693a08b836abdea74f3823a0bce0378ec5 (diff)
downloadbusybox-w32-c396fe6306f9a769d3a91809eb03361640c2f2fc.tar.gz
busybox-w32-c396fe6306f9a769d3a91809eb03361640c2f2fc.tar.bz2
busybox-w32-c396fe6306f9a769d3a91809eb03361640c2f2fc.zip
lineedit: small fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r--libbb/lineedit.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index e1404fb68..a0b1bcf8e 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -299,17 +299,19 @@ static void input_backward(unsigned num)
299 299
300static void put_prompt(void) 300static void put_prompt(void)
301{ 301{
302#if ENABLE_FEATURE_EDITING_ASK_TERMINAL
303 /* Ask terminal where is cursor now.
304 * lineedit_read_key handles response and corrects
305 * our idea of current cursor position.
306 * Testcase: run "echo -n long_line_long_line_long_line",
307 * then type in a long, wrapping command and try to
308 * delete it using backspace key.
309 */
310 out1str("\033" "[6n");
311#endif
312 out1str(cmdedit_prompt); 302 out1str(cmdedit_prompt);
303 if (ENABLE_FEATURE_EDITING_ASK_TERMINAL) {
304 /* Ask terminal where is the cursor now.
305 * lineedit_read_key handles response and corrects
306 * our idea of current cursor position.
307 * Testcase: run "echo -n long_line_long_line_long_line",
308 * then type in a long, wrapping command and try to
309 * delete it using backspace key.
310 * Note: we print it _after_ prompt, because
311 * prompt may contain CR. Example: PS1='\[\r\n\]\w '
312 */
313 out1str("\033" "[6n");
314 }
313 cursor = 0; 315 cursor = 0;
314 { 316 {
315 unsigned w = cmdedit_termw; /* volatile var */ 317 unsigned w = cmdedit_termw; /* volatile var */
@@ -1458,8 +1460,8 @@ static int lineedit_read_key(char *read_key_buffer)
1458 && (int32_t)ic == KEYCODE_CURSOR_POS 1460 && (int32_t)ic == KEYCODE_CURSOR_POS
1459 ) { 1461 ) {
1460 int col = ((ic >> 32) & 0x7fff) - 1; 1462 int col = ((ic >> 32) & 0x7fff) - 1;
1461 if (col > 0) { 1463 if (col > cmdedit_prmt_len) {
1462 cmdedit_x += col; 1464 cmdedit_x += (col - cmdedit_prmt_len);
1463 while (cmdedit_x >= cmdedit_termw) { 1465 while (cmdedit_x >= cmdedit_termw) {
1464 cmdedit_x -= cmdedit_termw; 1466 cmdedit_x -= cmdedit_termw;
1465 cmdedit_y++; 1467 cmdedit_y++;
@@ -1583,6 +1585,7 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
1583 /* Print out the command prompt */ 1585 /* Print out the command prompt */
1584 parse_and_put_prompt(prompt); 1586 parse_and_put_prompt(prompt);
1585 1587
1588 read_key_buffer[0] = 0;
1586 while (1) { 1589 while (1) {
1587 fflush(NULL); 1590 fflush(NULL);
1588 ic = lineedit_read_key(read_key_buffer); 1591 ic = lineedit_read_key(read_key_buffer);