aboutsummaryrefslogtreecommitdiff
path: root/shell/cmdedit.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-22 09:03:07 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-22 09:03:07 +0000
commit38f6319421c1892ea5c9c0484cec0e190bdc5c69 (patch)
tree99a63bee4f133df98eb870308c4ca75e8dcbd8c1 /shell/cmdedit.c
parent253ce0029669919fbb7cf60b5c9eab2f791939d8 (diff)
downloadbusybox-w32-38f6319421c1892ea5c9c0484cec0e190bdc5c69.tar.gz
busybox-w32-38f6319421c1892ea5c9c0484cec0e190bdc5c69.tar.bz2
busybox-w32-38f6319421c1892ea5c9c0484cec0e190bdc5c69.zip
cmdedit is not a 'command' editing anymore, it's just editing (generic),
so rename stuff accordingly.
Diffstat (limited to 'shell/cmdedit.c')
-rw-r--r--shell/cmdedit.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/shell/cmdedit.c b/shell/cmdedit.c
index 7588922a6..e62975db3 100644
--- a/shell/cmdedit.c
+++ b/shell/cmdedit.c
@@ -38,9 +38,9 @@
38 38
39#ifdef TEST 39#ifdef TEST
40 40
41#define ENABLE_FEATURE_COMMAND_EDITING 0 41#define ENABLE_FEATURE_EDITING 0
42#define ENABLE_FEATURE_COMMAND_TAB_COMPLETION 0 42#define ENABLE_FEATURE_TAB_COMPLETION 0
43#define ENABLE_FEATURE_COMMAND_USERNAME_COMPLETION 0 43#define ENABLE_FEATURE_USERNAME_COMPLETION 0
44#define ENABLE_FEATURE_NONPRINTABLE_INVERSE_PUT 0 44#define ENABLE_FEATURE_NONPRINTABLE_INVERSE_PUT 0
45#define ENABLE_FEATURE_CLEAN_UP 0 45#define ENABLE_FEATURE_CLEAN_UP 0
46 46
@@ -48,7 +48,7 @@
48 48
49 49
50/* Entire file (except TESTing part) sits inside this #if */ 50/* Entire file (except TESTing part) sits inside this #if */
51#if ENABLE_FEATURE_COMMAND_EDITING 51#if ENABLE_FEATURE_EDITING
52 52
53#if ENABLE_LOCALE_SUPPORT 53#if ENABLE_LOCALE_SUPPORT
54#define Isprint(c) isprint(c) 54#define Isprint(c) isprint(c)
@@ -57,7 +57,7 @@
57#endif 57#endif
58 58
59#define ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR \ 59#define ENABLE_FEATURE_GETUSERNAME_AND_HOMEDIR \
60(ENABLE_FEATURE_COMMAND_USERNAME_COMPLETION || ENABLE_FEATURE_SH_FANCY_PROMPT) 60(ENABLE_FEATURE_USERNAME_COMPLETION || ENABLE_FEATURE_EDITING_FANCY_PROMPT)
61 61
62 62
63static line_input_t *state; 63static line_input_t *state;
@@ -75,7 +75,7 @@ static unsigned command_len;
75static char *command_ps; 75static char *command_ps;
76static const char *cmdedit_prompt; 76static const char *cmdedit_prompt;
77 77
78#if ENABLE_FEATURE_SH_FANCY_PROMPT 78#if ENABLE_FEATURE_EDITING_FANCY_PROMPT
79static char *hostname_buf; 79static char *hostname_buf;
80static int num_ok_lines = 1; 80static int num_ok_lines = 1;
81#endif 81#endif
@@ -85,7 +85,7 @@ static char *user_buf = "";
85static char *home_pwd_buf = ""; 85static char *home_pwd_buf = "";
86#endif 86#endif
87 87
88#if ENABLE_FEATURE_COMMAND_TAB_COMPLETION 88#if ENABLE_FEATURE_TAB_COMPLETION
89static int my_uid; 89static int my_uid;
90static int my_gid; 90static int my_gid;
91#endif 91#endif
@@ -208,7 +208,7 @@ static void redraw(int y, int back_cursor)
208 input_backward(back_cursor); 208 input_backward(back_cursor);
209} 209}
210 210
211#if ENABLE_FEATURE_COMMAND_EDITING_VI 211#if ENABLE_FEATURE_EDITING_VI
212#define DELBUFSIZ 128 212#define DELBUFSIZ 128
213static char *delbuf; /* a (malloced) place to store deleted characters */ 213static char *delbuf; /* a (malloced) place to store deleted characters */
214static char *delp; 214static char *delp;
@@ -224,7 +224,7 @@ static void input_delete(int save)
224 if (j == command_len) 224 if (j == command_len)
225 return; 225 return;
226 226
227#if ENABLE_FEATURE_COMMAND_EDITING_VI 227#if ENABLE_FEATURE_EDITING_VI
228 if (save) { 228 if (save) {
229 if (newdelflag) { 229 if (newdelflag) {
230 if (!delbuf) 230 if (!delbuf)
@@ -245,7 +245,7 @@ static void input_delete(int save)
245 input_backward(cursor - j); /* back to old pos cursor */ 245 input_backward(cursor - j); /* back to old pos cursor */
246} 246}
247 247
248#if ENABLE_FEATURE_COMMAND_EDITING_VI 248#if ENABLE_FEATURE_EDITING_VI
249static void put(void) 249static void put(void)
250{ 250{
251 int ocursor; 251 int ocursor;
@@ -280,7 +280,7 @@ static void input_forward(void)
280} 280}
281 281
282 282
283#if ENABLE_FEATURE_COMMAND_TAB_COMPLETION 283#if ENABLE_FEATURE_TAB_COMPLETION
284 284
285static char **matches; 285static char **matches;
286static unsigned num_matches; 286static unsigned num_matches;
@@ -305,7 +305,7 @@ static void add_match(char *matched)
305 num_matches++; 305 num_matches++;
306} 306}
307 307
308#if ENABLE_FEATURE_COMMAND_USERNAME_COMPLETION 308#if ENABLE_FEATURE_USERNAME_COMPLETION
309static void username_tab_completion(char *ud, char *with_shash_flg) 309static void username_tab_completion(char *ud, char *with_shash_flg)
310{ 310{
311 struct passwd *entry; 311 struct passwd *entry;
@@ -431,7 +431,7 @@ static void exe_n_cwd_tab_completion(char *command, int type)
431 } else { 431 } else {
432 /* dirbuf = ".../.../.../" */ 432 /* dirbuf = ".../.../.../" */
433 safe_strncpy(dirbuf, command, (pfind - command) + 2); 433 safe_strncpy(dirbuf, command, (pfind - command) + 2);
434#if ENABLE_FEATURE_COMMAND_USERNAME_COMPLETION 434#if ENABLE_FEATURE_USERNAME_COMPLETION
435 if (dirbuf[0] == '~') /* ~/... or ~user/... */ 435 if (dirbuf[0] == '~') /* ~/... or ~user/... */
436 username_tab_completion(dirbuf, dirbuf); 436 username_tab_completion(dirbuf, dirbuf);
437#endif 437#endif
@@ -749,7 +749,7 @@ static void input_tab(int *lastWasTab)
749 /* Free up any memory already allocated */ 749 /* Free up any memory already allocated */
750 free_tab_completion_data(); 750 free_tab_completion_data();
751 751
752#if ENABLE_FEATURE_COMMAND_USERNAME_COMPLETION 752#if ENABLE_FEATURE_USERNAME_COMPLETION
753 /* If the word starts with `~' and there is no slash in the word, 753 /* If the word starts with `~' and there is no slash in the word,
754 * then try completing this word as a username. */ 754 * then try completing this word as a username. */
755 if (state->flags & USERNAME_COMPLETION) 755 if (state->flags & USERNAME_COMPLETION)
@@ -874,7 +874,7 @@ static int get_next_history(void)
874 return 0; 874 return 0;
875} 875}
876 876
877#if ENABLE_FEATURE_COMMAND_SAVEHISTORY 877#if ENABLE_FEATURE_EDITING_SAVEHISTORY
878/* state->flags is already checked to be nonzero */ 878/* state->flags is already checked to be nonzero */
879void load_history(const char *fromfile) 879void load_history(const char *fromfile)
880{ 880{
@@ -952,7 +952,7 @@ static void remember_in_history(const char *str)
952 state->cnt_history = i; 952 state->cnt_history = i;
953 if (state->flags & SAVE_HISTORY) 953 if (state->flags & SAVE_HISTORY)
954 save_history(state->hist_file); 954 save_history(state->hist_file);
955 USE_FEATURE_SH_FANCY_PROMPT(num_ok_lines++;) 955 USE_FEATURE_EDITING_FANCY_PROMPT(num_ok_lines++;)
956} 956}
957 957
958#else /* MAX_HISTORY == 0 */ 958#else /* MAX_HISTORY == 0 */
@@ -977,7 +977,7 @@ static void remember_in_history(const char *str)
977 * vi mode implemented 2005 by Paul Fox <pgf@foxharp.boston.ma.us> 977 * vi mode implemented 2005 by Paul Fox <pgf@foxharp.boston.ma.us>
978 */ 978 */
979 979
980#if ENABLE_FEATURE_COMMAND_EDITING_VI 980#if ENABLE_FEATURE_EDITING_VI
981static void 981static void
982vi_Word_motion(char *command, int eat) 982vi_Word_motion(char *command, int eat)
983{ 983{
@@ -1076,7 +1076,7 @@ vi_back_motion(char *command)
1076 * read_line_input and its helpers 1076 * read_line_input and its helpers
1077 */ 1077 */
1078 1078
1079#if !ENABLE_FEATURE_SH_FANCY_PROMPT 1079#if !ENABLE_FEATURE_EDITING_FANCY_PROMPT
1080static void parse_prompt(const char *prmt_ptr) 1080static void parse_prompt(const char *prmt_ptr)
1081{ 1081{
1082 cmdedit_prompt = prmt_ptr; 1082 cmdedit_prompt = prmt_ptr;
@@ -1246,7 +1246,7 @@ static void win_changed(int nsig)
1246 1246
1247/* leave out the "vi-mode"-only case labels if vi editing isn't 1247/* leave out the "vi-mode"-only case labels if vi editing isn't
1248 * configured. */ 1248 * configured. */
1249#define vi_case(caselabel) USE_FEATURE_COMMAND_EDITING(case caselabel) 1249#define vi_case(caselabel) USE_FEATURE_EDITING(case caselabel)
1250 1250
1251/* convert uppercase ascii to equivalent control char, for readability */ 1251/* convert uppercase ascii to equivalent control char, for readability */
1252#undef CTRL 1252#undef CTRL
@@ -1260,7 +1260,7 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t
1260 unsigned int ic; 1260 unsigned int ic;
1261 unsigned char c; 1261 unsigned char c;
1262 smallint break_out = 0; 1262 smallint break_out = 0;
1263#if ENABLE_FEATURE_COMMAND_EDITING_VI 1263#if ENABLE_FEATURE_EDITING_VI
1264 smallint vi_cmdmode = 0; 1264 smallint vi_cmdmode = 0;
1265 smalluint prevc; 1265 smalluint prevc;
1266#endif 1266#endif
@@ -1309,7 +1309,7 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t
1309 } 1309 }
1310 } 1310 }
1311#endif 1311#endif
1312#if ENABLE_FEATURE_COMMAND_TAB_COMPLETION 1312#if ENABLE_FEATURE_TAB_COMPLETION
1313 my_uid = getuid(); 1313 my_uid = getuid();
1314 my_gid = getgid(); 1314 my_gid = getgid();
1315#endif 1315#endif
@@ -1326,7 +1326,7 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t
1326 1326
1327 ic = c; 1327 ic = c;
1328 1328
1329#if ENABLE_FEATURE_COMMAND_EDITING_VI 1329#if ENABLE_FEATURE_EDITING_VI
1330 newdelflag = 1; 1330 newdelflag = 1;
1331 if (vi_cmdmode) 1331 if (vi_cmdmode)
1332 ic |= vbit; 1332 ic |= vbit;
@@ -1453,7 +1453,7 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t
1453 input_backspace(); 1453 input_backspace();
1454 break; 1454 break;
1455 1455
1456#if ENABLE_FEATURE_COMMAND_EDITING_VI 1456#if ENABLE_FEATURE_EDITING_VI
1457 case 'i'|vbit: 1457 case 'i'|vbit:
1458 vi_cmdmode = 0; 1458 vi_cmdmode = 0;
1459 break; 1459 break;
@@ -1584,7 +1584,7 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t
1584 1584
1585 case '\x1b': /* ESC */ 1585 case '\x1b': /* ESC */
1586 1586
1587#if ENABLE_FEATURE_COMMAND_EDITING_VI 1587#if ENABLE_FEATURE_EDITING_VI
1588 if (state->flags & VI_MODE) { 1588 if (state->flags & VI_MODE) {
1589 /* ESC: insert mode --> command mode */ 1589 /* ESC: insert mode --> command mode */
1590 vi_cmdmode = 1; 1590 vi_cmdmode = 1;
@@ -1612,7 +1612,7 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t
1612 } 1612 }
1613 1613
1614 switch (c) { 1614 switch (c) {
1615#if ENABLE_FEATURE_COMMAND_TAB_COMPLETION 1615#if ENABLE_FEATURE_TAB_COMPLETION
1616 case '\t': /* Alt-Tab */ 1616 case '\t': /* Alt-Tab */
1617 input_tab(&lastWasTab); 1617 input_tab(&lastWasTab);
1618 break; 1618 break;
@@ -1679,7 +1679,7 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t
1679 } else 1679 } else
1680#endif 1680#endif
1681 1681
1682#if ENABLE_FEATURE_COMMAND_EDITING_VI 1682#if ENABLE_FEATURE_EDITING_VI
1683 if (vi_cmdmode) /* Don't self-insert */ 1683 if (vi_cmdmode) /* Don't self-insert */
1684 break; 1684 break;
1685#endif 1685#endif
@@ -1722,11 +1722,11 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t
1722 command[command_len] = '\0'; 1722 command[command_len] = '\0';
1723 } 1723 }
1724 1724
1725#if ENABLE_FEATURE_CLEAN_UP && ENABLE_FEATURE_COMMAND_TAB_COMPLETION 1725#if ENABLE_FEATURE_CLEAN_UP && ENABLE_FEATURE_TAB_COMPLETION
1726 free_tab_completion_data(); 1726 free_tab_completion_data();
1727#endif 1727#endif
1728 1728
1729#if ENABLE_FEATURE_SH_FANCY_PROMPT 1729#if ENABLE_FEATURE_EDITING_FANCY_PROMPT
1730 free((char*)cmdedit_prompt); 1730 free((char*)cmdedit_prompt);
1731#endif 1731#endif
1732 /* restore initial_settings */ 1732 /* restore initial_settings */
@@ -1772,7 +1772,7 @@ int main(int argc, char **argv)
1772{ 1772{
1773 char buff[BUFSIZ]; 1773 char buff[BUFSIZ];
1774 char *prompt = 1774 char *prompt =
1775#if ENABLE_FEATURE_SH_FANCY_PROMPT 1775#if ENABLE_FEATURE_EDITING_FANCY_PROMPT
1776 "\\[\\033[32;1m\\]\\u@\\[\\x1b[33;1m\\]\\h:" 1776 "\\[\\033[32;1m\\]\\u@\\[\\x1b[33;1m\\]\\h:"
1777 "\\[\\033[34;1m\\]\\w\\[\\033[35;1m\\] " 1777 "\\[\\033[34;1m\\]\\w\\[\\033[35;1m\\] "
1778 "\\!\\[\\e[36;1m\\]\\$ \\[\\E[0m\\]"; 1778 "\\!\\[\\e[36;1m\\]\\$ \\[\\E[0m\\]";