DLR's latest fixes for the tabcomp code and keys

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@783 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2001-09-23 01:18:03 +00:00
parent beb5497530
commit ce78c1eb88
4 changed files with 66 additions and 35 deletions

View File

@ -9,7 +9,7 @@ CVS code -
- New flag -o, --operatingdir, similar to Pico's -o mode. New - New flag -o, --operatingdir, similar to Pico's -o mode. New
function check_operating_dir(), changes to load_file (arg), function check_operating_dir(), changes to load_file (arg),
open_file_dup_search (arg), new function do_gotopos for -F open_file_dup_search (arg), new function do_gotopos for -F
(Ravid Lawrence Ramsey). (David Lawrence Ramsey).
- Code to read/write dos formatted files. Massive amounts of - Code to read/write dos formatted files. Massive amounts of
new code in read_line and write_file. New cmdline flag new code in read_line and write_file. New cmdline flag
(-D --dos) to automatically write the file in DOS format, (-D --dos) to automatically write the file in DOS format,
@ -26,6 +26,8 @@ CVS code -
main() main()
- Added vars oldcurrent and oldcurrent_x to check whether cursor - Added vars oldcurrent and oldcurrent_x to check whether cursor
pos has changed and if so update the pos with -c. pos has changed and if so update the pos with -c.
- Many tweaks and changes from numerics to char equivs
(David Lawrence Ramsey).
do_mouse() do_mouse()
- Send 27 when the menu item clicked is an alt key seq... The - Send 27 when the menu item clicked is an alt key seq... The
lines aren't lined up since the menu width changed though, lines aren't lined up since the menu width changed though,
@ -39,6 +41,8 @@ CVS code -
- Add David Lawrence Ramsey to credits. - Add David Lawrence Ramsey to credits.
bottombars() bottombars()
- Spread out the menu items, feedback definitely needed on this. - Spread out the menu items, feedback definitely needed on this.
nanogetstr()
- More key fixes (David Lawrence Ramsey)
- po/nl.po: - po/nl.po:
- New Dutch translation, by Guus Sliepen <guus@nl.linux.org>. - New Dutch translation, by Guus Sliepen <guus@nl.linux.org>.
- po/es.po: - po/es.po:

25
files.c
View File

@ -819,7 +819,7 @@ char *get_full_path(char *origpath)
struct stat fileinfo; struct stat fileinfo;
/* first, get the current directory, and tack a slash onto the end of /* first, get the current directory, and tack a slash onto the end of
it */ it, unless it turns out to be "/", in which case leave it alone */
#ifdef PATH_MAX #ifdef PATH_MAX
d_here = getcwd(NULL, PATH_MAX + 1); d_here = getcwd(NULL, PATH_MAX + 1);
@ -830,8 +830,10 @@ char *get_full_path(char *origpath)
if (d_here) { if (d_here) {
align(&d_here); align(&d_here);
d_here = nrealloc(d_here, strlen(d_here) + 2); if (strcmp(d_here, "/")) {
strcat(d_here, "/"); d_here = nrealloc(d_here, strlen(d_here) + 2);
strcat(d_here, "/");
}
/* stat origpath; if stat() fails, assume that origpath refers to /* stat origpath; if stat() fails, assume that origpath refers to
a new file that hasn't been saved to disk yet (i. e. set a new file that hasn't been saved to disk yet (i. e. set
@ -910,8 +912,13 @@ char *get_full_path(char *origpath)
align(&d_there); align(&d_there);
if (d_there) { if (d_there) {
d_there = nrealloc(d_there, strlen(d_there) + 2);
strcat(d_there, "/"); /* add a slash to d_there, unless it's "/", in which
case we don't need it */
if (strcmp(d_there, "/")) {
d_there = nrealloc(d_there, strlen(d_there) + 2);
strcat(d_there, "/");
}
} }
else else
return NULL; return NULL;
@ -987,6 +994,14 @@ int check_operating_dir(char *currpath, int allow_tabcomp)
operating_dir = NULL; operating_dir = NULL;
return 0; return 0;
} }
/* if the full operating directory is "/", that's the same as
having no operating directory, so discard it and get out */
if (!strcmp(full_operating_dir, "/")) {
free(full_operating_dir);
operating_dir = NULL;
return 0;
}
} }
fullpath = get_full_path(currpath); fullpath = get_full_path(currpath);

39
nano.c
View File

@ -1512,7 +1512,7 @@ int do_int_speller(char *tempfile_name)
/* External spell checking */ /* External spell checking */
int do_alt_speller(char *file_name) int do_alt_speller(char *file_name)
{ {
int alt_spell_status; int alt_spell_status, y_cur = current_y;
pid_t pid_spell; pid_t pid_spell;
char *ptr; char *ptr;
long lineno_cur = current->lineno; long lineno_cur = current->lineno;
@ -1567,6 +1567,7 @@ int do_alt_speller(char *file_name)
/* go back to the old line while keeping the same position, mark the /* go back to the old line while keeping the same position, mark the
file as modified, and make sure that the titlebar is refreshed */ file as modified, and make sure that the titlebar is refreshed */
current_y = y_cur;
do_gotoline(lineno_cur, 1); do_gotoline(lineno_cur, 1);
set_modified(); set_modified();
clearok(topwin, FALSE); clearok(topwin, FALSE);
@ -2742,10 +2743,11 @@ int main(int argc, char *argv[])
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput); fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput);
#endif #endif
if (kbinput == 27) { /* Grab Alt-key stuff first */ if (kbinput == 27) { /* Grab Alt-key stuff first */
switch (kbinput = wgetch(edit)) { switch (kbinput = wgetch(edit)) {
/* Alt-O, suddenly very important ;) */ /* Alt-O, suddenly very important ;) */
case 79: case 'O':
kbinput = wgetch(edit); kbinput = wgetch(edit);
if ((kbinput <= 'D' && kbinput >= 'A') || if ((kbinput <= 'D' && kbinput >= 'A') ||
(kbinput <= 'd' && kbinput >= 'a')) (kbinput <= 'd' && kbinput >= 'a'))
@ -2768,7 +2770,7 @@ int main(int argc, char *argv[])
modify_control_seq = 1; modify_control_seq = 1;
keyhandled = 1; keyhandled = 1;
break; break;
case 91: case '[':
switch (kbinput = wgetch(edit)) { switch (kbinput = wgetch(edit)) {
case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */ case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */
kbinput = wgetch(edit); kbinput = wgetch(edit);
@ -2778,7 +2780,7 @@ int main(int argc, char *argv[])
} else if (kbinput >= '7' && kbinput <= '9') { } else if (kbinput >= '7' && kbinput <= '9') {
kbinput = KEY_F(kbinput - 49); kbinput = KEY_F(kbinput - 49);
wgetch(edit); wgetch(edit);
} else if (kbinput == 126) } else if (kbinput == '~')
kbinput = KEY_HOME; kbinput = KEY_HOME;
#ifdef DEBUG #ifdef DEBUG
@ -2809,16 +2811,8 @@ int main(int argc, char *argv[])
kbinput = KEY_F(12); kbinput = KEY_F(12);
wgetch(edit); wgetch(edit);
break; break;
case 126: /* Hack, make insert key do something case '~':
useful, like insert file */ goto do_insertkey;
#ifdef ENABLE_MULTIBUFFER
do_insertfile(ISSET(MULTIBUFFER));
#else
do_insertfile(0);
#endif
keyhandled = 1;
break;
#ifdef DEBUG #ifdef DEBUG
default: default:
fprintf(stderr, _("I got Alt-[-2-%c! (%d)\n"), fprintf(stderr, _("I got Alt-[-2-%c! (%d)\n"),
@ -2953,6 +2947,20 @@ int main(int argc, char *argv[])
keyhandled = 1; keyhandled = 1;
} }
/* Hack, make insert key do something useful, like insert file */
if (kbinput == KEY_IC) {
do_insertkey:
#ifdef ENABLE_MULTIBUFFER
do_insertfile(ISSET(MULTIBUFFER));
#else
do_insertfile(0);
#endif
keyhandled = 1;
}
/* Last gasp, stuff that's not in the main lists */ /* Last gasp, stuff that's not in the main lists */
if (!keyhandled) if (!keyhandled)
switch (kbinput) { switch (kbinput) {
@ -2967,8 +2975,7 @@ int main(int argc, char *argv[])
do_next_word(); do_next_word();
break; break;
case 331: /* Stuff that we don't want to do squat */ case -1: /* Stuff that we don't want to do squat */
case -1:
case 410: /* Must ignore this, it gets sent when we resize */ case 410: /* Must ignore this, it gets sent when we resize */
#ifdef PDCURSES #ifdef PDCURSES
case 541: /* ???? */ case 541: /* ???? */

31
winio.c
View File

@ -360,7 +360,6 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
nanoget_repaint(buf, inputbuf, x); nanoget_repaint(buf, inputbuf, x);
break; break;
case KEY_BACKSPACE: case KEY_BACKSPACE:
case KEY_DC:
case 127: case 127:
case NANO_CONTROL_H: case NANO_CONTROL_H:
if (strlen(inputbuf) > 0) { if (strlen(inputbuf) > 0) {
@ -400,21 +399,24 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
case KEY_DOWN: case KEY_DOWN:
break; break;
case KEY_DC:
goto do_deletekey;
case 27: case 27:
switch (kbinput = wgetch(edit)) { switch (kbinput = wgetch(edit)) {
case 79: case 'O':
switch (kbinput = wgetch(edit)) { switch (kbinput = wgetch(edit)) {
case 70: case 'F':
x = x_left + strlen(inputbuf); x = x_left + strlen(inputbuf);
nanoget_repaint(buf, inputbuf, x); nanoget_repaint(buf, inputbuf, x);
break; break;
case 72: case 'H':
x = x_left; x = x_left;
nanoget_repaint(buf, inputbuf, x); nanoget_repaint(buf, inputbuf, x);
break; break;
} }
break; break;
case 91: case '[':
switch (kbinput = wgetch(edit)) { switch (kbinput = wgetch(edit)) {
case 'C': case 'C':
if (x < xend) if (x < xend)
@ -426,11 +428,13 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
x--; x--;
wmove(bottomwin, 0, x); wmove(bottomwin, 0, x);
break; break;
case 49: case '1':
case '7':
x = x_left; x = x_left;
nanoget_repaint(buf, inputbuf, x); nanoget_repaint(buf, inputbuf, x);
goto skip_126; goto skip_tilde;
case 51: case '3':
do_deletekey:
if (strlen(inputbuf) > 0 if (strlen(inputbuf) > 0
&& (x - x_left) != strlen(inputbuf)) { && (x - x_left) != strlen(inputbuf)) {
memmove(inputbuf + (x - x_left), memmove(inputbuf + (x - x_left),
@ -439,15 +443,16 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
inputbuf[strlen(inputbuf) - 1] = 0; inputbuf[strlen(inputbuf) - 1] = 0;
} }
nanoget_repaint(buf, inputbuf, x); nanoget_repaint(buf, inputbuf, x);
goto skip_126; goto skip_tilde;
case 52: case '4':
case '8':
x = x_left + strlen(inputbuf); x = x_left + strlen(inputbuf);
nanoget_repaint(buf, inputbuf, x); nanoget_repaint(buf, inputbuf, x);
goto skip_126; goto skip_tilde;
skip_126: skip_tilde:
nodelay(edit, TRUE); nodelay(edit, TRUE);
kbinput = wgetch(edit); kbinput = wgetch(edit);
if (kbinput == 126 || kbinput == ERR) if (kbinput == '~' || kbinput == ERR)
kbinput = -1; kbinput = -1;
nodelay(edit, FALSE); nodelay(edit, FALSE);
break; break;