Aha, works even better now. Made input_tab much more grabby, it touches lastWasTab now also...

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@283 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Chris Allegretta 2000-11-14 18:25:26 +00:00
parent 022b96f941
commit b5b89aeb93
4 changed files with 72 additions and 80 deletions

84
files.c
View File

@ -550,7 +550,7 @@ char **cwd_tab_completion(char *buf, int *num_matches)
dirName = malloc(strlen(buf) + 1);
tmp = buf + strlen(buf);
while (*tmp != '/' && tmp != buf)
tmp--;
tmp--;
tmp++;
@ -608,7 +608,7 @@ char **cwd_tab_completion(char *buf, int *num_matches)
/* This function now has an arg which refers to how much the
* statusbar (place) should be advanced, i.e. the new cursor pos.
*/
char *input_tab(char *buf, int place, int lastWasTab, int *newplace)
char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
{
/* Do TAB completion */
static int num_matches = 0, match_matches = 0;
@ -618,9 +618,11 @@ char *input_tab(char *buf, int place, int lastWasTab, int *newplace)
char *foo;
struct stat fileinfo;
if (lastWasTab == FALSE) {
if (*lastWasTab == FALSE) {
char *tmp, *copyto, *matchBuf;
*lastWasTab = 1;
/* For now, we will not bother with trying to distinguish
* whether the cursor is in/at a command extression -- we
* will always try all possible matches. If you don't like
@ -651,8 +653,8 @@ char *input_tab(char *buf, int place, int lastWasTab, int *newplace)
* then try completing this word as a username. */
/* FIXME -- this check is broken!
if (*tmp == '~' && !strchr(tmp, '/'))
matches = username_tab_completion(tmp, &num_matches); */
if (*tmp == '~' && !strchr(tmp, '/'))
matches = username_tab_completion(tmp, &num_matches); */
/* Try to match everything in the current working directory that
* matches. */
@ -666,7 +668,7 @@ char *input_tab(char *buf, int place, int lastWasTab, int *newplace)
fprintf(stderr, "%d matches found...\n", num_matches);
#endif
/* Did we find exactly one match? */
switch(num_matches) {
switch (num_matches) {
case 0:
blank_edit();
break;
@ -675,65 +677,57 @@ char *input_tab(char *buf, int place, int lastWasTab, int *newplace)
buf = nrealloc(buf, strlen(buf) + strlen(matches[0]) + 1);
if (strcmp(buf, "") && strstr(buf, "/")) {
for (tmp = buf + strlen(buf); *tmp != '/' && tmp != buf; tmp--)
;
for (tmp = buf + strlen(buf); *tmp != '/' && tmp != buf;
tmp--);
tmp++;
}
else
} else
tmp = buf;
if (!strcmp(tmp, matches[0])) {
/* Is it a directory? */
if (stat(buf, &fileinfo) == -1)
break;
break;
else if (S_ISDIR(fileinfo.st_mode)) {
strncat(buf, "/", 1);
*newplace += 1;
strncat(buf, "/", 1);
*newplace += 1;
/* now we start over again with # of tabs so far */
*lastWasTab = 0;
}
break;
}
copyto = tmp;
for (pos = 0; *tmp == matches[0][pos] &&
pos <= strlen(matches[0]); pos++)
pos <= strlen(matches[0]); pos++)
tmp++;
#ifdef DEBUG
fprintf(stderr, "buf = \'%s\'\n", buf);
/* fprintf(stderr, "copyto = \'%s\'\n", copyto); */
fprintf(stderr, "matches[0] = \'%s\'\n", matches[0]);
fprintf(stderr, "pos = %d\n", pos);
fflush(stderr);
#endif
/* write out the matched command */
strncpy(copyto, matches[0], strlen(matches[0]) + 1);
strncpy(copyto, matches[0], strlen(matches[0]) + 1);
*newplace += strlen(matches[0]) - pos;
if (stat(buf, &fileinfo) == -1)
;
else if (S_ISDIR(fileinfo.st_mode)) {
strncat(buf, "/", 1);
*newplace += 1;
}
if (stat(buf, &fileinfo) == -1);
else if (S_ISDIR(fileinfo.st_mode)) {
strncat(buf, "/", 1);
*newplace += 1;
/* now we start over again with # of tabs so far */
*lastWasTab = 0;
}
break;
default:
/* Check to see if all matches share a beginning, and if so
tack it onto buf and then beep */
tack it onto buf and then beep */
if (strcmp(buf, "") && strstr(buf, "/")) {
for (tmp = buf + strlen(buf); *tmp != '/' && tmp != buf; tmp--)
;
for (tmp = buf + strlen(buf); *tmp != '/' && tmp != buf;
tmp--);
tmp++;
}
else
} else
tmp = buf;
for (pos = 0; *tmp == matches[0][pos] && *tmp != 0 &&
pos <= strlen(matches[0]); pos++)
pos <= strlen(matches[0]); pos++)
tmp++;
while (1) {
@ -746,12 +740,12 @@ char *input_tab(char *buf, int place, int lastWasTab, int *newplace)
match_matches++;
}
if (match_matches == num_matches &&
(i == num_matches || matches[i] != 0)) {
(i == num_matches || matches[i] != 0)) {
/* All the matches have the same character at pos+1,
so paste it into buf... */
so paste it into buf... */
buf = nrealloc(buf, strlen(buf) + 2);
strncat(buf, matches[0] + pos, 1);
*newplace += 1;
*newplace += 1;
pos++;
} else {
beep();
@ -785,7 +779,7 @@ char *input_tab(char *buf, int place, int lastWasTab, int *newplace)
for (i = 0, col = 0; i < num_matches; i++) {
/* make each filename shown be the same length as the longest
filename, with two spaces at the end */
filename, with two spaces at the end */
snprintf(foo, longestname + 1, matches[i]);
while (strlen(foo) < longestname)
strcat(foo, " ");
@ -800,13 +794,13 @@ char *input_tab(char *buf, int place, int lastWasTab, int *newplace)
/* And if the next match isn't going to fit on the
line, move to the next one */
if (col > (COLS - longestname) && matches[i + 1] != NULL) {
if (col > (COLS - longestname) && matches[i + 1] != NULL) {
editline++;
wmove(edit, editline, 0);
if (editline == editwinrows - 1) {
waddstr(edit, _("(more)"));
break;
}
if (editline == editwinrows - 1) {
waddstr(edit, _("(more)"));
break;
}
col = 0;
}
}

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-11-13 23:13-0500\n"
"POT-Creation-Date: 2000-11-14 13:25-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -107,7 +107,7 @@ msgstr ""
msgid "File exists, OVERWRITE ?"
msgstr ""
#: files.c:807
#: files.c:801
msgid "(more)"
msgstr ""
@ -384,7 +384,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:1011
#: global.c:405 global.c:411 winio.c:1012
msgid "Cancel"
msgstr ""
@ -773,41 +773,41 @@ msgstr ""
msgid "Replaced 1 occurence"
msgstr ""
#: search.c:443 search.c:538 search.c:554
#: search.c:443 search.c:536 search.c:552
msgid "Replace Cancelled"
msgstr ""
#: search.c:488
#: search.c:486
msgid "Replace this instance?"
msgstr ""
#: search.c:496
#: search.c:494
msgid "Replace failed: unknown subexpression!"
msgstr ""
#: search.c:571
#: search.c:569
#, c-format
msgid "Replace with [%s]"
msgstr ""
#: search.c:575 search.c:579
#: search.c:573 search.c:577
msgid "Replace with"
msgstr ""
#. Ask for it
#: search.c:614
#: search.c:612
msgid "Enter line number"
msgstr ""
#: search.c:616
#: search.c:614
msgid "Aborted"
msgstr ""
#: search.c:636
#: search.c:634
msgid "Come on, be reasonable"
msgstr ""
#: search.c:641
#: search.c:639
#, c-format
msgid "Only %d lines available, skipping to last line"
msgstr ""
@ -817,67 +817,67 @@ msgstr ""
msgid "actual_x_from_start for xplus=%d returned %d\n"
msgstr ""
#: winio.c:424
#: winio.c:425
#, c-format
msgid "input '%c' (%d)\n"
msgstr ""
#: winio.c:462
#: winio.c:463
msgid "New Buffer"
msgstr ""
#: winio.c:465
#: winio.c:466
msgid " File: ..."
msgstr ""
#: winio.c:473
#: winio.c:474
msgid "Modified"
msgstr ""
#: winio.c:925
#: winio.c:926
#, c-format
msgid "Moved to (%d, %d) in edit buffer\n"
msgstr ""
#: winio.c:936
#: winio.c:937
#, c-format
msgid "current->data = \"%s\"\n"
msgstr ""
#: winio.c:981
#: winio.c:982
#, c-format
msgid "I got \"%s\"\n"
msgstr ""
#: winio.c:1006
#: winio.c:1007
msgid "Yes"
msgstr ""
#: winio.c:1008
#: winio.c:1009
msgid "All"
msgstr ""
#: winio.c:1010
#: winio.c:1011
msgid "No"
msgstr ""
#: winio.c:1147
#: winio.c:1148
#, c-format
msgid "do_cursorpos: linepct = %f, bytepct = %f\n"
msgstr ""
#: winio.c:1151
#: winio.c:1152
msgid "line %d of %d (%.0f%%), character %d of %d (%.0f%%)"
msgstr ""
#: winio.c:1279
#: winio.c:1280
msgid "Dumping file buffer to stderr...\n"
msgstr ""
#: winio.c:1281
#: winio.c:1282
msgid "Dumping cutbuffer to stderr...\n"
msgstr ""
#: winio.c:1283
#: winio.c:1284
msgid "Dumping a buffer to stderr...\n"
msgstr ""

View File

@ -88,7 +88,7 @@ int do_down(void);
int do_left(void);
int do_right(void);
int check_wildcard_match(const char *text, const char *pattern);
char *input_tab(char *buf, int place, int lastWasTab, int *newplace);
char *input_tab(char *buf, int place, int *lastWasTab, int *newplace);
void shortcut_init(void);
void lowercase(char *src);

View File

@ -334,13 +334,11 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
break;
case NANO_CONTROL_I:
if (allowtabs) {
tabbed++;
shift = 0;
inputbuf = input_tab(inputbuf, (x - x_left),
tabbed - 1, &shift);
&tabbed, &shift);
x += shift;
nanoget_repaint(buf, inputbuf, x);
tabbed = 1;
}
break;
case KEY_LEFT: