From: Chris Allegretta Date: Mon, 6 Nov 2000 02:57:22 +0000 (+0000) Subject: Add tab completion option to statusq and nanogetstr, beep when multiple/no matches... X-Git-Tag: v0.9.20~26 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=7da4e9f28ba69ab9cd01f4ddab4e2deba122468a;p=nano.git Add tab completion option to statusq and nanogetstr, beep when multiple/no matches found git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@271 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 1390d27d..5efd5c3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,7 +21,9 @@ CVS Code - last_replace back to nano.c (*shrug*). - New tab completion code. Used check_wildcard_match, input_tab, cwd_tab_completion, username_tab_completion from busybox, - hacked them a lot, changes to nanogetstr(). + hacked them a lot, changes to nanogetstr(). nanogetstr() and + statusq() now take an arg for whether or not to allow tab + completion. - files.c: do_writeout() - Change strcpy to answer to mallocstrcpy. diff --git a/files.c b/files.c index 85739e96..f12ce4fe 100644 --- a/files.c +++ b/files.c @@ -247,7 +247,7 @@ int do_insertfile(void) int i; wrap_reset(); - i = statusq(writefile_list, WRITEFILE_LIST_LEN, "", + i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, "", _("File to insert [from ./] ")); if (i != -1) { @@ -463,7 +463,7 @@ int do_writeout(int exiting) } while (1) { - i = statusq(writefile_list, WRITEFILE_LIST_LEN, answer, + i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, answer, _("File Name to write")); if (i != -1) { @@ -732,7 +732,8 @@ int input_tab(char *buf, int place, int lastWasTab) free(foo); wrefresh(edit); num_matches = 0; - } + } else + beep(); } diff --git a/po/nano.pot b/po/nano.pot index eea67e0f..b817fa21 100644 --- a/po/nano.pot +++ b/po/nano.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-11-05 17:48-0500\n" +"POT-Creation-Date: 2000-11-05 21:55-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -380,7 +380,7 @@ msgid "Case Sens" msgstr "" #: global.c:344 global.c:364 global.c:375 global.c:385 global.c:401 -#: global.c:405 global.c:411 winio.c:1009 +#: global.c:405 global.c:411 winio.c:1008 msgid "Cancel" msgstr "" @@ -817,67 +817,67 @@ msgstr "" msgid "actual_x_from_start for xplus=%d returned %d\n" msgstr "" -#: winio.c:424 +#: winio.c:421 #, c-format msgid "input '%c' (%d)\n" msgstr "" -#: winio.c:462 +#: winio.c:459 msgid "New Buffer" msgstr "" -#: winio.c:465 +#: winio.c:462 msgid " File: ..." msgstr "" -#: winio.c:473 +#: winio.c:470 msgid "Modified" msgstr "" -#: winio.c:925 +#: winio.c:922 #, c-format msgid "Moved to (%d, %d) in edit buffer\n" msgstr "" -#: winio.c:936 +#: winio.c:933 #, c-format msgid "current->data = \"%s\"\n" msgstr "" -#: winio.c:979 +#: winio.c:978 #, c-format msgid "I got \"%s\"\n" msgstr "" -#: winio.c:1004 +#: winio.c:1003 msgid "Yes" msgstr "" -#: winio.c:1006 +#: winio.c:1005 msgid "All" msgstr "" -#: winio.c:1008 +#: winio.c:1007 msgid "No" msgstr "" -#: winio.c:1145 +#: winio.c:1144 #, c-format msgid "do_cursorpos: linepct = %f, bytepct = %f\n" msgstr "" -#: winio.c:1149 +#: winio.c:1148 msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)" msgstr "" -#: winio.c:1277 +#: winio.c:1276 msgid "Dumping file buffer to stderr...\n" msgstr "" -#: winio.c:1279 +#: winio.c:1278 msgid "Dumping cutbuffer to stderr...\n" msgstr "" -#: winio.c:1281 +#: winio.c:1280 msgid "Dumping a buffer to stderr...\n" msgstr "" diff --git a/proto.h b/proto.h index cf7a5d8a..ced01509 100644 --- a/proto.h +++ b/proto.h @@ -71,7 +71,7 @@ int xplustabs(void); int do_yesno(int all, int leavecursor, char *msg, ...); int actual_x(filestruct * fileptr, int xplus); int strlenpt(char *buf); -int statusq(shortcut s[], int slen, char *def, char *msg, ...); +int statusq(int allowtabs, shortcut s[], int slen, char *def, char *msg, ...); int write_file(char *name, int tmpfile); int do_cut_text(void); int do_uncut_text(void); diff --git a/search.c b/search.c index 9f1ddb02..569e0637 100644 --- a/search.c +++ b/search.c @@ -108,11 +108,11 @@ int search_init(int replacing) reprompt = _(" (to replace)"); if (ISSET(PICO_MSGS)) - i = statusq(replacing ? replace_list : whereis_list, + i = statusq(0, replacing ? replace_list : whereis_list, replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, "", prompt, reprompt, buf); else - i = statusq(replacing ? replace_list : whereis_list, + i = statusq(0, replacing ? replace_list : whereis_list, replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, last_search, prompt, reprompt, ""); @@ -565,15 +565,15 @@ int do_replace(void) } else sprintf(buf, "%s", last_replace); - i = statusq(replace_list_2, REPLACE_LIST_2_LEN, "", + i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, "", _("Replace with [%s]"), buf); } else - i = statusq(replace_list_2, REPLACE_LIST_2_LEN, "", + i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, "", _("Replace with")); } else - i = statusq(replace_list_2, REPLACE_LIST_2_LEN, last_replace, + i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, last_replace, _("Replace with")); /* save where we are */ @@ -609,7 +609,7 @@ int do_gotoline(long defline) line = defline; else { /* Ask for it */ - j = statusq(goto_list, GOTO_LIST_LEN, "", _("Enter line number")); + j = statusq(0, goto_list, GOTO_LIST_LEN, "", _("Enter line number")); if (j == -1) { statusbar(_("Aborted")); goto_abort(); diff --git a/winio.c b/winio.c index 5a200502..db8902c4 100644 --- a/winio.c +++ b/winio.c @@ -244,7 +244,8 @@ void nanoget_repaint(char *buf, char *inputbuf, int x) } /* Get the input from the kb, this should only be called from statusq */ -int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x) +int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen, + int start_x) { int kbinput = 0, j = 0, x = 0, xend; int x_left = 0, inputlen, tabbed = 0; @@ -329,16 +330,12 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x) nanoget_repaint(buf, inputbuf, x); break; case NANO_CONTROL_I: - tabbed++; -#ifdef DEBUG - fprintf(stderr, "Before call, x = %d\n", x); -#endif - x += input_tab(inputbuf, (x - x_left), tabbed - 1); -#ifdef DEBUG - fprintf(stderr, "After call, x = %d\n", x); -#endif - nanoget_repaint(buf, inputbuf, x); - tabbed = 1; + if (allowtabs) { + tabbed++; + x += input_tab(inputbuf, (x - x_left), tabbed - 1); + nanoget_repaint(buf, inputbuf, x); + tabbed = 1; + } break; case KEY_LEFT: if (x > strlen(buf)) @@ -943,8 +940,10 @@ void update_cursor(void) * global. Returns -1 on aborted enter, -2 on a blank string, and 0 * otherwise, the valid shortcut key caught, Def is any editable text we * want to put up by default. + * + * New arg tabs tells whether or not to allow tab completion. */ -int statusq(shortcut s[], int slen, char *def, char *msg, ...) +int statusq(int tabs, shortcut s[], int slen, char *def, char *msg, ...) { va_list ap; char foo[133]; @@ -958,7 +957,7 @@ int statusq(shortcut s[], int slen, char *def, char *msg, ...) strncat(foo, ": ", 132); wattron(bottomwin, A_REVERSE); - ret = nanogetstr(foo, def, s, slen, (strlen(foo) + 3)); + ret = nanogetstr(tabs, foo, def, s, slen, (strlen(foo) + 3)); wattroff(bottomwin, A_REVERSE); switch (ret) {