aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Fox <pgf@brightstareng.com>2008-03-06 16:26:12 +0000
committerPaul Fox <pgf@brightstareng.com>2008-03-06 16:26:12 +0000
commit35e9c5d83ada1fea40798365a1b4c728f64ded98 (patch)
treebaf13f0fc18eafa19eb1f394310c3dd0be70e76b
parentc51fc7bed6d6555997fdfb3879f42c6b1191465c (diff)
downloadbusybox-w32-35e9c5d83ada1fea40798365a1b4c728f64ded98.tar.gz
busybox-w32-35e9c5d83ada1fea40798365a1b4c728f64ded98.tar.bz2
busybox-w32-35e9c5d83ada1fea40798365a1b4c728f64ded98.zip
fixups to vi usage, and move the initial redraw() past the
execution of commands supplied by -c or EXINIT, so their effect is displayed correctly.
-rw-r--r--editors/vi.c16
-rw-r--r--include/usage.h6
2 files changed, 14 insertions, 8 deletions
diff --git a/editors/vi.c b/editors/vi.c
index d9db94322..572e04972 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -23,6 +23,7 @@
23 23
24#include "libbb.h" 24#include "libbb.h"
25 25
26/* the CRASHME code is unmaintained, and doesn't currently build */
26#define ENABLE_FEATURE_VI_CRASHME 0 27#define ENABLE_FEATURE_VI_CRASHME 0
27 28
28 29
@@ -395,7 +396,7 @@ int vi_main(int argc, char **argv)
395 initial_cmds[0] = xstrndup(p, MAX_INPUT_LEN); 396 initial_cmds[0] = xstrndup(p, MAX_INPUT_LEN);
396 } 397 }
397#endif 398#endif
398 while ((c = getopt(argc, argv, "hCR" USE_FEATURE_VI_COLON("c:"))) != -1) { 399 while ((c = getopt(argc, argv, "hCRH" USE_FEATURE_VI_COLON("c:"))) != -1) {
399 switch (c) { 400 switch (c) {
400#if ENABLE_FEATURE_VI_CRASHME 401#if ENABLE_FEATURE_VI_CRASHME
401 case 'C': 402 case 'C':
@@ -407,18 +408,18 @@ int vi_main(int argc, char **argv)
407 SET_READONLY_MODE(readonly_mode); 408 SET_READONLY_MODE(readonly_mode);
408 break; 409 break;
409#endif 410#endif
410 //case 'r': // recover flag- ignore- we don't use tmp file
411 //case 'x': // encryption flag- ignore
412 //case 'c': // execute command first
413#if ENABLE_FEATURE_VI_COLON 411#if ENABLE_FEATURE_VI_COLON
414 case 'c': // cmd line vi command 412 case 'c': // cmd line vi command
415 if (*optarg) 413 if (*optarg)
416 initial_cmds[initial_cmds[0] != 0] = xstrndup(optarg, MAX_INPUT_LEN); 414 initial_cmds[initial_cmds[0] != 0] = xstrndup(optarg, MAX_INPUT_LEN);
417 break; 415 break;
418 //case 'h': // help -- just use default
419#endif 416#endif
420 default: 417 case 'H':
421 show_help(); 418 show_help();
419 /* fall through */
420
421 default:
422 bb_show_usage();
422 return 1; 423 return 1;
423 } 424 }
424 } 425 }
@@ -532,7 +533,6 @@ static void edit_file(char *fn)
532 lmc_len = 0; 533 lmc_len = 0;
533 adding2q = 0; 534 adding2q = 0;
534#endif 535#endif
535 redraw(FALSE); // dont force every col re-draw
536 536
537#if ENABLE_FEATURE_VI_COLON 537#if ENABLE_FEATURE_VI_COLON
538 { 538 {
@@ -555,6 +555,7 @@ static void edit_file(char *fn)
555 } 555 }
556 } 556 }
557#endif 557#endif
558 redraw(FALSE); // dont force every col re-draw
558 //------This is the main Vi cmd handling loop ----------------------- 559 //------This is the main Vi cmd handling loop -----------------------
559 while (editing > 0) { 560 while (editing > 0) {
560#if ENABLE_FEATURE_VI_CRASHME 561#if ENABLE_FEATURE_VI_CRASHME
@@ -3849,6 +3850,7 @@ static void do_cmd(char c)
3849 dot--; 3850 dot--;
3850} 3851}
3851 3852
3853/* NB! the CRASHME code is unmaintained, and doesn't currently build */
3852#if ENABLE_FEATURE_VI_CRASHME 3854#if ENABLE_FEATURE_VI_CRASHME
3853static int totalcmds = 0; 3855static int totalcmds = 0;
3854static int Mp = 85; // Movement command Probability 3856static int Mp = 85; // Movement command Probability
diff --git a/include/usage.h b/include/usage.h
index 4eac17401..f575f4676 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -4237,7 +4237,11 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
4237#define vi_full_usage \ 4237#define vi_full_usage \
4238 "Edit FILE" \ 4238 "Edit FILE" \
4239 "\n\nOptions:\n" \ 4239 "\n\nOptions:\n" \
4240 " -R Read-only - do not write to the file" 4240 USE_FEATURE_VI_COLON( \
4241 " -c Initial command to run ($EXINIT also available)\n") \
4242 USE_FEATURE_VI_READONLY( \
4243 " -R Read-only - do not write to the file\n") \
4244 " -H Short help regarding available features"
4241 4245
4242#define vlock_trivial_usage \ 4246#define vlock_trivial_usage \
4243 "[OPTIONS]" 4247 "[OPTIONS]"