mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-22 21:01:24 +03:00
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
This commit is contained in:
parent
7586495813
commit
7da4e9f28b
@ -21,7 +21,9 @@ CVS Code -
|
|||||||
last_replace back to nano.c (*shrug*).
|
last_replace back to nano.c (*shrug*).
|
||||||
- New tab completion code. Used check_wildcard_match, input_tab,
|
- New tab completion code. Used check_wildcard_match, input_tab,
|
||||||
cwd_tab_completion, username_tab_completion from busybox,
|
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:
|
- files.c:
|
||||||
do_writeout()
|
do_writeout()
|
||||||
- Change strcpy to answer to mallocstrcpy.
|
- Change strcpy to answer to mallocstrcpy.
|
||||||
|
7
files.c
7
files.c
@ -247,7 +247,7 @@ int do_insertfile(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
wrap_reset();
|
wrap_reset();
|
||||||
i = statusq(writefile_list, WRITEFILE_LIST_LEN, "",
|
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, "",
|
||||||
_("File to insert [from ./] "));
|
_("File to insert [from ./] "));
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
|
|
||||||
@ -463,7 +463,7 @@ int do_writeout(int exiting)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
i = statusq(writefile_list, WRITEFILE_LIST_LEN, answer,
|
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, answer,
|
||||||
_("File Name to write"));
|
_("File Name to write"));
|
||||||
|
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
@ -732,7 +732,8 @@ int input_tab(char *buf, int place, int lastWasTab)
|
|||||||
free(foo);
|
free(foo);
|
||||||
wrefresh(edit);
|
wrefresh(edit);
|
||||||
num_matches = 0;
|
num_matches = 0;
|
||||||
}
|
} else
|
||||||
|
beep();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
po/nano.pot
34
po/nano.pot
@ -6,7 +6,7 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -380,7 +380,7 @@ msgid "Case Sens"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: global.c:344 global.c:364 global.c:375 global.c:385 global.c:401
|
#: 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"
|
msgid "Cancel"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -817,67 +817,67 @@ msgstr ""
|
|||||||
msgid "actual_x_from_start for xplus=%d returned %d\n"
|
msgid "actual_x_from_start for xplus=%d returned %d\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:424
|
#: winio.c:421
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "input '%c' (%d)\n"
|
msgid "input '%c' (%d)\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:462
|
#: winio.c:459
|
||||||
msgid "New Buffer"
|
msgid "New Buffer"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:465
|
#: winio.c:462
|
||||||
msgid " File: ..."
|
msgid " File: ..."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:473
|
#: winio.c:470
|
||||||
msgid "Modified"
|
msgid "Modified"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:925
|
#: winio.c:922
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "Moved to (%d, %d) in edit buffer\n"
|
msgid "Moved to (%d, %d) in edit buffer\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:936
|
#: winio.c:933
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "current->data = \"%s\"\n"
|
msgid "current->data = \"%s\"\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:979
|
#: winio.c:978
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "I got \"%s\"\n"
|
msgid "I got \"%s\"\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:1004
|
#: winio.c:1003
|
||||||
msgid "Yes"
|
msgid "Yes"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:1006
|
#: winio.c:1005
|
||||||
msgid "All"
|
msgid "All"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:1008
|
#: winio.c:1007
|
||||||
msgid "No"
|
msgid "No"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:1145
|
#: winio.c:1144
|
||||||
#, c-format
|
#, c-format
|
||||||
msgid "do_cursorpos: linepct = %f, bytepct = %f\n"
|
msgid "do_cursorpos: linepct = %f, bytepct = %f\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:1149
|
#: winio.c:1148
|
||||||
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
|
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:1277
|
#: winio.c:1276
|
||||||
msgid "Dumping file buffer to stderr...\n"
|
msgid "Dumping file buffer to stderr...\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:1279
|
#: winio.c:1278
|
||||||
msgid "Dumping cutbuffer to stderr...\n"
|
msgid "Dumping cutbuffer to stderr...\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: winio.c:1281
|
#: winio.c:1280
|
||||||
msgid "Dumping a buffer to stderr...\n"
|
msgid "Dumping a buffer to stderr...\n"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
2
proto.h
2
proto.h
@ -71,7 +71,7 @@ int xplustabs(void);
|
|||||||
int do_yesno(int all, int leavecursor, char *msg, ...);
|
int do_yesno(int all, int leavecursor, char *msg, ...);
|
||||||
int actual_x(filestruct * fileptr, int xplus);
|
int actual_x(filestruct * fileptr, int xplus);
|
||||||
int strlenpt(char *buf);
|
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 write_file(char *name, int tmpfile);
|
||||||
int do_cut_text(void);
|
int do_cut_text(void);
|
||||||
int do_uncut_text(void);
|
int do_uncut_text(void);
|
||||||
|
12
search.c
12
search.c
@ -108,11 +108,11 @@ int search_init(int replacing)
|
|||||||
reprompt = _(" (to replace)");
|
reprompt = _(" (to replace)");
|
||||||
|
|
||||||
if (ISSET(PICO_MSGS))
|
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, "",
|
replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, "",
|
||||||
prompt, reprompt, buf);
|
prompt, reprompt, buf);
|
||||||
else
|
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,
|
replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, last_search,
|
||||||
prompt, reprompt, "");
|
prompt, reprompt, "");
|
||||||
|
|
||||||
@ -565,15 +565,15 @@ int do_replace(void)
|
|||||||
} else
|
} else
|
||||||
sprintf(buf, "%s", last_replace);
|
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);
|
_("Replace with [%s]"), buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
i = statusq(replace_list_2, REPLACE_LIST_2_LEN, "",
|
i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, "",
|
||||||
_("Replace with"));
|
_("Replace with"));
|
||||||
}
|
}
|
||||||
else
|
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"));
|
_("Replace with"));
|
||||||
|
|
||||||
/* save where we are */
|
/* save where we are */
|
||||||
@ -609,7 +609,7 @@ int do_gotoline(long defline)
|
|||||||
line = defline;
|
line = defline;
|
||||||
else { /* Ask for it */
|
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) {
|
if (j == -1) {
|
||||||
statusbar(_("Aborted"));
|
statusbar(_("Aborted"));
|
||||||
goto_abort();
|
goto_abort();
|
||||||
|
17
winio.c
17
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 */
|
/* 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 kbinput = 0, j = 0, x = 0, xend;
|
||||||
int x_left = 0, inputlen, tabbed = 0;
|
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);
|
nanoget_repaint(buf, inputbuf, x);
|
||||||
break;
|
break;
|
||||||
case NANO_CONTROL_I:
|
case NANO_CONTROL_I:
|
||||||
|
if (allowtabs) {
|
||||||
tabbed++;
|
tabbed++;
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "Before call, x = %d\n", x);
|
|
||||||
#endif
|
|
||||||
x += input_tab(inputbuf, (x - x_left), tabbed - 1);
|
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);
|
nanoget_repaint(buf, inputbuf, x);
|
||||||
tabbed = 1;
|
tabbed = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_LEFT:
|
case KEY_LEFT:
|
||||||
if (x > strlen(buf))
|
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
|
* 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
|
* otherwise, the valid shortcut key caught, Def is any editable text we
|
||||||
* want to put up by default.
|
* 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;
|
va_list ap;
|
||||||
char foo[133];
|
char foo[133];
|
||||||
@ -958,7 +957,7 @@ int statusq(shortcut s[], int slen, char *def, char *msg, ...)
|
|||||||
strncat(foo, ": ", 132);
|
strncat(foo, ": ", 132);
|
||||||
|
|
||||||
wattron(bottomwin, A_REVERSE);
|
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);
|
wattroff(bottomwin, A_REVERSE);
|
||||||
|
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
|
Loading…
Reference in New Issue
Block a user