aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-05-17 04:05:53 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-05-17 04:05:53 +0200
commit9963fe36c2af2bf99fcbd2eae6e9e050c8cf779b (patch)
treedce2c33a8ac91b21db10aaa1a3a5c2a04e940c38
parent27ff681cfa573ce2a63b35c48047f1d7adcb1f02 (diff)
downloadbusybox-w32-9963fe36c2af2bf99fcbd2eae6e9e050c8cf779b.tar.gz
busybox-w32-9963fe36c2af2bf99fcbd2eae6e9e050c8cf779b.tar.bz2
busybox-w32-9963fe36c2af2bf99fcbd2eae6e9e050c8cf779b.zip
lineedit: trivial simplifications. -7 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/lineedit.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 836fc0089..36d057bbb 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -397,17 +397,10 @@ static void put_till_end_and_adv_cursor(void)
397static void goto_new_line(void) 397static void goto_new_line(void)
398{ 398{
399 put_till_end_and_adv_cursor(); 399 put_till_end_and_adv_cursor();
400 if (cmdedit_x) 400 if (cmdedit_x != 0)
401 bb_putchar('\n'); 401 bb_putchar('\n');
402} 402}
403 403
404
405static void out1str(const char *s)
406{
407 if (s)
408 fputs(s, stdout);
409}
410
411static void beep(void) 404static void beep(void)
412{ 405{
413 bb_putchar('\007'); 406 bb_putchar('\007');
@@ -417,7 +410,7 @@ static void put_prompt(void)
417{ 410{
418 unsigned w; 411 unsigned w;
419 412
420 out1str(cmdedit_prompt); 413 fputs(cmdedit_prompt, stdout);
421 fflush_all(); 414 fflush_all();
422 cursor = 0; 415 cursor = 0;
423 w = cmdedit_termw; /* read volatile var once */ 416 w = cmdedit_termw; /* read volatile var once */
@@ -485,9 +478,8 @@ static void input_backward(unsigned num)
485 * up to new cursor position (which is already known): 478 * up to new cursor position (which is already known):
486 */ 479 */
487 unsigned sv_cursor; 480 unsigned sv_cursor;
488 if (cmdedit_y > 0) /* up to start y */ 481 /* go to 1st column; go up to first line */
489 printf("\033[%uA", cmdedit_y); 482 printf("\r" "\033[%uA", cmdedit_y);
490 bb_putchar('\r');
491 cmdedit_y = 0; 483 cmdedit_y = 0;
492 sv_cursor = cursor; 484 sv_cursor = cursor;
493 put_prompt(); /* sets cursor to 0 */ 485 put_prompt(); /* sets cursor to 0 */
@@ -509,7 +501,7 @@ static void input_backward(unsigned num)
509/* draw prompt, editor line, and clear tail */ 501/* draw prompt, editor line, and clear tail */
510static void redraw(int y, int back_cursor) 502static void redraw(int y, int back_cursor)
511{ 503{
512 if (y > 0) /* up to start y */ 504 if (y > 0) /* up y lines */
513 printf("\033[%uA", y); 505 printf("\033[%uA", y);
514 bb_putchar('\r'); 506 bb_putchar('\r');
515 put_prompt(); 507 put_prompt();
@@ -1616,7 +1608,7 @@ static void ask_terminal(void)
1616 pfd.events = POLLIN; 1608 pfd.events = POLLIN;
1617 if (safe_poll(&pfd, 1, 0) == 0) { 1609 if (safe_poll(&pfd, 1, 0) == 0) {
1618 S.sent_ESC_br6n = 1; 1610 S.sent_ESC_br6n = 1;
1619 out1str("\033" "[6n"); 1611 fputs("\033" "[6n", stdout);
1620 fflush_all(); /* make terminal see it ASAP! */ 1612 fflush_all(); /* make terminal see it ASAP! */
1621 } 1613 }
1622} 1614}