aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2005-07-18 10:32:59 +0000
committerEric Andersen <andersen@codepoet.org>2005-07-18 10:32:59 +0000
commit0ef24c672ab4901da22dffbfdb6301437309a0a3 (patch)
tree38dc628c67a667a966253a20712468275e0aef9a
parent2ada89b60f61019b3e1b80819257cc8af486e10c (diff)
downloadbusybox-w32-0ef24c672ab4901da22dffbfdb6301437309a0a3.tar.gz
busybox-w32-0ef24c672ab4901da22dffbfdb6301437309a0a3.tar.bz2
busybox-w32-0ef24c672ab4901da22dffbfdb6301437309a0a3.zip
Fix vi so that error messages, insert mode messages, etc are
all actually displayed in the status line as expected
-rw-r--r--editors/vi.c49
1 files changed, 37 insertions, 12 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 5a47f5a23..fc1deeb3c 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -344,6 +344,7 @@ extern int vi_main(int argc, char **argv)
344#endif /* CONFIG_FEATURE_VI_CRASHME */ 344#endif /* CONFIG_FEATURE_VI_CRASHME */
345 345
346 status_buffer = STATUS_BUFFER; 346 status_buffer = STATUS_BUFFER;
347 *status_buffer = '\0'; // clear status buffer
347 348
348#ifdef CONFIG_FEATURE_VI_READONLY 349#ifdef CONFIG_FEATURE_VI_READONLY
349 vi_readonly = readonly = FALSE; 350 vi_readonly = readonly = FALSE;
@@ -462,7 +463,6 @@ static void edit_file(Byte * fn)
462 last_forward_char = last_input_char = '\0'; 463 last_forward_char = last_input_char = '\0';
463 crow = 0; 464 crow = 0;
464 ccol = 0; 465 ccol = 0;
465 edit_status();
466 466
467#ifdef CONFIG_FEATURE_VI_USE_SIGNALS 467#ifdef CONFIG_FEATURE_VI_USE_SIGNALS
468 catch_sig(0); 468 catch_sig(0);
@@ -506,6 +506,7 @@ static void edit_file(Byte * fn)
506 adding2q = 0; 506 adding2q = 0;
507#endif /* CONFIG_FEATURE_VI_DOT_CMD */ 507#endif /* CONFIG_FEATURE_VI_DOT_CMD */
508 redraw(FALSE); // dont force every col re-draw 508 redraw(FALSE); // dont force every col re-draw
509 edit_status();
509 show_status_line(); 510 show_status_line();
510 511
511 //------This is the main Vi cmd handling loop ----------------------- 512 //------This is the main Vi cmd handling loop -----------------------
@@ -871,6 +872,7 @@ static void colon(Byte * buf)
871 } else { 872 } else {
872 // user wants file status info 873 // user wants file status info
873 edit_status(); 874 edit_status();
875 show_status_line();
874 } 876 }
875 } else if (strncasecmp((char *) cmd, "features", i) == 0) { // what features are available 877 } else if (strncasecmp((char *) cmd, "features", i) == 0) { // what features are available
876 // print out values of all features 878 // print out values of all features
@@ -1333,22 +1335,30 @@ static void dot_left(void)
1333{ 1335{
1334 if (dot > text && dot[-1] != '\n') 1336 if (dot > text && dot[-1] != '\n')
1335 dot--; 1337 dot--;
1338 edit_status(); // show current file status
1339 show_status_line();
1336} 1340}
1337 1341
1338static void dot_right(void) 1342static void dot_right(void)
1339{ 1343{
1340 if (dot < end - 1 && *dot != '\n') 1344 if (dot < end - 1 && *dot != '\n')
1341 dot++; 1345 dot++;
1346 edit_status(); // show current file status
1347 show_status_line();
1342} 1348}
1343 1349
1344static void dot_begin(void) 1350static void dot_begin(void)
1345{ 1351{
1346 dot = begin_line(dot); // return pointer to first char cur line 1352 dot = begin_line(dot); // return pointer to first char cur line
1353 edit_status(); // show current file status
1354 show_status_line();
1347} 1355}
1348 1356
1349static void dot_end(void) 1357static void dot_end(void)
1350{ 1358{
1351 dot = end_line(dot); // return pointer to last char cur line 1359 dot = end_line(dot); // return pointer to last char cur line
1360 edit_status(); // show current file status
1361 show_status_line();
1352} 1362}
1353 1363
1354static Byte *move_to_col(Byte * p, int l) 1364static Byte *move_to_col(Byte * p, int l)
@@ -1373,11 +1383,15 @@ static Byte *move_to_col(Byte * p, int l)
1373static void dot_next(void) 1383static void dot_next(void)
1374{ 1384{
1375 dot = next_line(dot); 1385 dot = next_line(dot);
1386 edit_status(); // show current file status
1387 show_status_line();
1376} 1388}
1377 1389
1378static void dot_prev(void) 1390static void dot_prev(void)
1379{ 1391{
1380 dot = prev_line(dot); 1392 dot = prev_line(dot);
1393 edit_status(); // show current file status
1394 show_status_line();
1381} 1395}
1382 1396
1383static void dot_scroll(int cnt, int dir) 1397static void dot_scroll(int cnt, int dir)
@@ -1402,6 +1416,8 @@ static void dot_scroll(int cnt, int dir)
1402 if (dot > q) 1416 if (dot > q)
1403 dot = begin_line(q); // is dot is below bottom line? 1417 dot = begin_line(q); // is dot is below bottom line?
1404 dot_skip_over_ws(); 1418 dot_skip_over_ws();
1419 edit_status(); // show current file status
1420 show_status_line();
1405} 1421}
1406 1422
1407static void dot_skip_over_ws(void) 1423static void dot_skip_over_ws(void)
@@ -1592,7 +1608,7 @@ static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p'
1592 cmd_mode = 0; 1608 cmd_mode = 0;
1593 cmdcnt = 0; 1609 cmdcnt = 0;
1594 end_cmd_q(); // stop adding to q 1610 end_cmd_q(); // stop adding to q
1595 strcpy((char *) status_buffer, " "); // clear the status buffer 1611 *status_buffer = '\0'; // clear the status buffer
1596 if ((p[-1] != '\n') && (dot>text)) { 1612 if ((p[-1] != '\n') && (dot>text)) {
1597 p--; 1613 p--;
1598 } 1614 }
@@ -2659,7 +2675,7 @@ static void show_status_line(void)
2659 static int last_cksum; 2675 static int last_cksum;
2660 int l, cnt, cksum; 2676 int l, cnt, cksum;
2661 2677
2662 edit_status(); 2678 //edit_status();
2663 cnt = strlen((char *) status_buffer); 2679 cnt = strlen((char *) status_buffer);
2664 for (cksum= l= 0; l < cnt; l++) { cksum += (int)(status_buffer[l]); } 2680 for (cksum= l= 0; l < cnt; l++) { cksum += (int)(status_buffer[l]); }
2665 // don't write the status line unless it changes 2681 // don't write the status line unless it changes
@@ -2681,10 +2697,10 @@ static void psbs(const char *format, ...)
2681 2697
2682 va_start(args, format); 2698 va_start(args, format);
2683 strcpy((char *) status_buffer, SOs); // Terminal standout mode on 2699 strcpy((char *) status_buffer, SOs); // Terminal standout mode on
2684 vsprintf((char *) status_buffer + strlen((char *) status_buffer), format, 2700 vsprintf((char *) status_buffer + strlen((char *) status_buffer), format, args);
2685 args);
2686 strcat((char *) status_buffer, SOn); // Terminal standout mode off 2701 strcat((char *) status_buffer, SOn); // Terminal standout mode off
2687 va_end(args); 2702 va_end(args);
2703 show_status_line();
2688 2704
2689 return; 2705 return;
2690} 2706}
@@ -2697,6 +2713,7 @@ static void psb(const char *format, ...)
2697 va_start(args, format); 2713 va_start(args, format);
2698 vsprintf((char *) status_buffer, format, args); 2714 vsprintf((char *) status_buffer, format, args);
2699 va_end(args); 2715 va_end(args);
2716 show_status_line();
2700 return; 2717 return;
2701} 2718}
2702 2719
@@ -2723,17 +2740,19 @@ static void edit_status(void) // show file status on status line
2723 cur = tot = 0; 2740 cur = tot = 0;
2724 percent = 100; 2741 percent = 100;
2725 } 2742 }
2726 psb("\"%s\"" 2743
2744 sprintf((char *) status_buffer,
2745 "\"%s\""
2727#ifdef CONFIG_FEATURE_VI_READONLY 2746#ifdef CONFIG_FEATURE_VI_READONLY
2728 "%s" 2747 "%s"
2729#endif /* CONFIG_FEATURE_VI_READONLY */ 2748#endif /* CONFIG_FEATURE_VI_READONLY */
2730 "%s line %d of %d --%d%%--", 2749 "%s line %d of %d --%d%%--",
2731 (cfn != 0 ? (char *) cfn : "No file"), 2750 (cfn != 0 ? (char *) cfn : "No file"),
2732#ifdef CONFIG_FEATURE_VI_READONLY 2751#ifdef CONFIG_FEATURE_VI_READONLY
2733 ((vi_readonly || readonly) ? " [Read only]" : ""), 2752 ((vi_readonly || readonly) ? " [Read only]" : ""),
2734#endif /* CONFIG_FEATURE_VI_READONLY */ 2753#endif /* CONFIG_FEATURE_VI_READONLY */
2735 (file_modified ? " [modified]" : ""), 2754 (file_modified ? " [modified]" : ""),
2736 cur, tot, percent); 2755 cur, tot, percent);
2737} 2756}
2738 2757
2739//----- Force refresh of all Lines ----------------------------- 2758//----- Force refresh of all Lines -----------------------------
@@ -2879,6 +2898,8 @@ static void refresh(int full_screen)
2879#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */ 2898#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
2880 } 2899 }
2881 2900
2901 edit_status(); // show current file status
2902 show_status_line();
2882 // write line out to terminal 2903 // write line out to terminal
2883 { 2904 {
2884 int nic = ce-cs+1; 2905 int nic = ce-cs+1;
@@ -3058,6 +3079,7 @@ key_cmd_mode:
3058 break; 3079 break;
3059 case 7: // ctrl-G show current status 3080 case 7: // ctrl-G show current status
3060 edit_status(); 3081 edit_status();
3082 show_status_line();
3061 break; 3083 break;
3062 case 'h': // h- move left 3084 case 'h': // h- move left
3063 case VI_K_LEFT: // cursor key Left 3085 case VI_K_LEFT: // cursor key Left
@@ -3067,6 +3089,8 @@ key_cmd_mode:
3067 do_cmd(c); 3089 do_cmd(c);
3068 } // repeat cnt 3090 } // repeat cnt
3069 dot_left(); 3091 dot_left();
3092 edit_status(); // show current file status
3093 show_status_line();
3070 break; 3094 break;
3071 case 10: // Newline ^J 3095 case 10: // Newline ^J
3072 case 'j': // j- goto next line, same col 3096 case 'j': // j- goto next line, same col
@@ -3383,6 +3407,7 @@ key_cmd_mode:
3383 } 3407 }
3384 } else if (strncasecmp((char *) p, "file", cnt) == 0 ) { 3408 } else if (strncasecmp((char *) p, "file", cnt) == 0 ) {
3385 edit_status(); // show current file status 3409 edit_status(); // show current file status
3410 show_status_line();
3386 } else if (sscanf((char *) p, "%d", &j) > 0) { 3411 } else if (sscanf((char *) p, "%d", &j) > 0) {
3387 dot = find_line(j); // go to line # j 3412 dot = find_line(j); // go to line # j
3388 dot_skip_over_ws(); 3413 dot_skip_over_ws();