diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-10-14 10:34:41 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-10-14 10:34:41 +0000 |
commit | 267e16c74aa72d0e8fdd90b2a4301b89cdca0e42 (patch) | |
tree | 10b06a67651ae333ee01605d1c5e35cd50c9f671 | |
parent | 25497c1d92dadafa51ee1e7789f9b0c9c6171963 (diff) | |
download | busybox-w32-267e16c74aa72d0e8fdd90b2a4301b89cdca0e42.tar.gz busybox-w32-267e16c74aa72d0e8fdd90b2a4301b89cdca0e42.tar.bz2 busybox-w32-267e16c74aa72d0e8fdd90b2a4301b89cdca0e42.zip |
vi: trivial size optimization -65 bytes
-rw-r--r-- | editors/vi.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/editors/vi.c b/editors/vi.c index f7d3ef678..a01fa7c46 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -348,6 +348,7 @@ static void place_cursor(int, int, int); | |||
348 | static void screen_erase(void); | 348 | static void screen_erase(void); |
349 | static void clear_to_eol(void); | 349 | static void clear_to_eol(void); |
350 | static void clear_to_eos(void); | 350 | static void clear_to_eos(void); |
351 | static void go_bottom_and_clear_to_eol(void); | ||
351 | static void standout_start(void); // send "start reverse video" sequence | 352 | static void standout_start(void); // send "start reverse video" sequence |
352 | static void standout_end(void); // send "end reverse video" sequence | 353 | static void standout_end(void); // send "end reverse video" sequence |
353 | static void flash(int); // flash the terminal screen | 354 | static void flash(int); // flash the terminal screen |
@@ -645,8 +646,7 @@ static void edit_file(char *fn) | |||
645 | } | 646 | } |
646 | //------------------------------------------------------------------- | 647 | //------------------------------------------------------------------- |
647 | 648 | ||
648 | place_cursor(rows - 1, 0, FALSE); // go to bottom of screen | 649 | go_bottom_and_clear_to_eol(); |
649 | clear_to_eol(); // erase to end of line | ||
650 | cookmode(); | 650 | cookmode(); |
651 | #undef cur_line | 651 | #undef cur_line |
652 | } | 652 | } |
@@ -842,8 +842,7 @@ static void colon(char *buf) | |||
842 | else if (strncmp(cmd, "!", 1) == 0) { // run a cmd | 842 | else if (strncmp(cmd, "!", 1) == 0) { // run a cmd |
843 | int retcode; | 843 | int retcode; |
844 | // :!ls run the <cmd> | 844 | // :!ls run the <cmd> |
845 | place_cursor(rows - 1, 0, FALSE); // go to Status line | 845 | go_bottom_and_clear_to_eol(); |
846 | clear_to_eol(); // clear the line | ||
847 | cookmode(); | 846 | cookmode(); |
848 | retcode = system(orig_buf + 1); // run the cmd | 847 | retcode = system(orig_buf + 1); // run the cmd |
849 | if (retcode) | 848 | if (retcode) |
@@ -920,8 +919,7 @@ static void colon(char *buf) | |||
920 | } | 919 | } |
921 | } else if (strncasecmp(cmd, "features", i) == 0) { // what features are available | 920 | } else if (strncasecmp(cmd, "features", i) == 0) { // what features are available |
922 | // print out values of all features | 921 | // print out values of all features |
923 | place_cursor(rows - 1, 0, FALSE); // go to Status line, bottom of screen | 922 | go_bottom_and_clear_to_eol(); |
924 | clear_to_eol(); // clear the line | ||
925 | cookmode(); | 923 | cookmode(); |
926 | show_help(); | 924 | show_help(); |
927 | rawmode(); | 925 | rawmode(); |
@@ -931,8 +929,7 @@ static void colon(char *buf) | |||
931 | q = begin_line(dot); // assume .,. for the range | 929 | q = begin_line(dot); // assume .,. for the range |
932 | r = end_line(dot); | 930 | r = end_line(dot); |
933 | } | 931 | } |
934 | place_cursor(rows - 1, 0, FALSE); // go to Status line, bottom of screen | 932 | go_bottom_and_clear_to_eol(); |
935 | clear_to_eol(); // clear the line | ||
936 | puts("\r"); | 933 | puts("\r"); |
937 | for (; q <= r; q++) { | 934 | for (; q <= r; q++) { |
938 | int c_is_no_print; | 935 | int c_is_no_print; |
@@ -1032,8 +1029,7 @@ static void colon(char *buf) | |||
1032 | // only blank is regarded as args delmiter. What about tab '\t' ? | 1029 | // only blank is regarded as args delmiter. What about tab '\t' ? |
1033 | if (!args[0] || strcasecmp(args, "all") == 0) { | 1030 | if (!args[0] || strcasecmp(args, "all") == 0) { |
1034 | // print out values of all options | 1031 | // print out values of all options |
1035 | place_cursor(rows - 1, 0, FALSE); // go to Status line, bottom of screen | 1032 | go_bottom_and_clear_to_eol(); |
1036 | clear_to_eol(); // clear the line | ||
1037 | printf("----------------------------------------\r\n"); | 1033 | printf("----------------------------------------\r\n"); |
1038 | #if ENABLE_FEATURE_VI_SETOPTS | 1034 | #if ENABLE_FEATURE_VI_SETOPTS |
1039 | if (!autoindent) | 1035 | if (!autoindent) |
@@ -2169,8 +2165,7 @@ static void cont_sig(int sig UNUSED_PARAM) | |||
2169 | //----- Come here when we get a Suspend signal ------------------- | 2165 | //----- Come here when we get a Suspend signal ------------------- |
2170 | static void suspend_sig(int sig UNUSED_PARAM) | 2166 | static void suspend_sig(int sig UNUSED_PARAM) |
2171 | { | 2167 | { |
2172 | place_cursor(rows - 1, 0, FALSE); // go to bottom of screen | 2168 | go_bottom_and_clear_to_eol(); |
2173 | clear_to_eol(); // erase to end of line | ||
2174 | cookmode(); // terminal to "cooked" | 2169 | cookmode(); // terminal to "cooked" |
2175 | 2170 | ||
2176 | signal(SIGCONT, cont_sig); | 2171 | signal(SIGCONT, cont_sig); |
@@ -2253,8 +2248,7 @@ static char readit(void) // read (maybe cursor) key from stdin | |||
2253 | n = safe_read(0, readbuffer, 1); | 2248 | n = safe_read(0, readbuffer, 1); |
2254 | if (n <= 0) { | 2249 | if (n <= 0) { |
2255 | error: | 2250 | error: |
2256 | place_cursor(rows - 1, 0, FALSE); // go to bottom of screen | 2251 | go_bottom_and_clear_to_eol(); |
2257 | clear_to_eol(); // erase to end of line | ||
2258 | cookmode(); // terminal to "cooked" | 2252 | cookmode(); // terminal to "cooked" |
2259 | bb_error_msg_and_die("can't read user input"); | 2253 | bb_error_msg_and_die("can't read user input"); |
2260 | } | 2254 | } |
@@ -2367,8 +2361,7 @@ static char *get_input_line(const char *prompt) | |||
2367 | 2361 | ||
2368 | strcpy(buf, prompt); | 2362 | strcpy(buf, prompt); |
2369 | last_status_cksum = 0; // force status update | 2363 | last_status_cksum = 0; // force status update |
2370 | place_cursor(rows - 1, 0, FALSE); // go to Status line, bottom of screen | 2364 | go_bottom_and_clear_to_eol(); |
2371 | clear_to_eol(); // clear the line | ||
2372 | write1(prompt); // write out the :, /, or ? prompt | 2365 | write1(prompt); // write out the :, /, or ? prompt |
2373 | 2366 | ||
2374 | i = strlen(buf); | 2367 | i = strlen(buf); |
@@ -2572,6 +2565,12 @@ static void clear_to_eol(void) | |||
2572 | write1(Ceol); // Erase from cursor to end of line | 2565 | write1(Ceol); // Erase from cursor to end of line |
2573 | } | 2566 | } |
2574 | 2567 | ||
2568 | static void go_bottom_and_clear_to_eol(void) | ||
2569 | { | ||
2570 | place_cursor(rows - 1, 0, FALSE); // go to bottom of screen | ||
2571 | clear_to_eol(); // erase to end of line | ||
2572 | } | ||
2573 | |||
2575 | //----- Erase from cursor to end of screen ----------------------- | 2574 | //----- Erase from cursor to end of screen ----------------------- |
2576 | static void clear_to_eos(void) | 2575 | static void clear_to_eos(void) |
2577 | { | 2576 | { |
@@ -2643,9 +2642,8 @@ static void show_status_line(void) | |||
2643 | } | 2642 | } |
2644 | if (have_status_msg || ((cnt > 0 && last_status_cksum != cksum))) { | 2643 | if (have_status_msg || ((cnt > 0 && last_status_cksum != cksum))) { |
2645 | last_status_cksum = cksum; // remember if we have seen this line | 2644 | last_status_cksum = cksum; // remember if we have seen this line |
2646 | place_cursor(rows - 1, 0, FALSE); // put cursor on status line | 2645 | go_bottom_and_clear_to_eol(); |
2647 | write1(status_buffer); | 2646 | write1(status_buffer); |
2648 | clear_to_eol(); | ||
2649 | if (have_status_msg) { | 2647 | if (have_status_msg) { |
2650 | if (((int)strlen(status_buffer) - (have_status_msg - 1)) > | 2648 | if (((int)strlen(status_buffer) - (have_status_msg - 1)) > |
2651 | (columns - 1) ) { | 2649 | (columns - 1) ) { |