From ce78c1eb88e28f1f958fa79d946a9bd7a0366ba4 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Sun, 23 Sep 2001 01:18:03 +0000 Subject: [PATCH] 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 --- ChangeLog | 6 +++++- files.c | 25 ++++++++++++++++++++----- nano.c | 39 +++++++++++++++++++++++---------------- winio.c | 31 ++++++++++++++++++------------- 4 files changed, 66 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f3c8ccd..f9f1bbae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,7 +9,7 @@ CVS code - - New flag -o, --operatingdir, similar to Pico's -o mode. New function check_operating_dir(), changes to load_file (arg), 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 new code in read_line and write_file. New cmdline flag (-D --dos) to automatically write the file in DOS format, @@ -26,6 +26,8 @@ CVS code - main() - Added vars oldcurrent and oldcurrent_x to check whether cursor 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() - Send 27 when the menu item clicked is an alt key seq... The lines aren't lined up since the menu width changed though, @@ -39,6 +41,8 @@ CVS code - - Add David Lawrence Ramsey to credits. bottombars() - Spread out the menu items, feedback definitely needed on this. + nanogetstr() + - More key fixes (David Lawrence Ramsey) - po/nl.po: - New Dutch translation, by Guus Sliepen . - po/es.po: diff --git a/files.c b/files.c index c210b240..c4b615b1 100644 --- a/files.c +++ b/files.c @@ -819,7 +819,7 @@ char *get_full_path(char *origpath) struct stat fileinfo; /* 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 d_here = getcwd(NULL, PATH_MAX + 1); @@ -830,8 +830,10 @@ char *get_full_path(char *origpath) if (d_here) { align(&d_here); - d_here = nrealloc(d_here, strlen(d_here) + 2); - strcat(d_here, "/"); + if (strcmp(d_here, "/")) { + d_here = nrealloc(d_here, strlen(d_here) + 2); + strcat(d_here, "/"); + } /* stat origpath; if stat() fails, assume that origpath refers to 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); 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 return NULL; @@ -987,6 +994,14 @@ int check_operating_dir(char *currpath, int allow_tabcomp) operating_dir = NULL; 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); diff --git a/nano.c b/nano.c index d3067688..5e1afa01 100644 --- a/nano.c +++ b/nano.c @@ -1512,7 +1512,7 @@ int do_int_speller(char *tempfile_name) /* External spell checking */ int do_alt_speller(char *file_name) { - int alt_spell_status; + int alt_spell_status, y_cur = current_y; pid_t pid_spell; char *ptr; 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 file as modified, and make sure that the titlebar is refreshed */ + current_y = y_cur; do_gotoline(lineno_cur, 1); set_modified(); clearok(topwin, FALSE); @@ -2742,10 +2743,11 @@ int main(int argc, char *argv[]) #ifdef DEBUG fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput); #endif + if (kbinput == 27) { /* Grab Alt-key stuff first */ switch (kbinput = wgetch(edit)) { /* Alt-O, suddenly very important ;) */ - case 79: + case 'O': kbinput = wgetch(edit); if ((kbinput <= 'D' && kbinput >= 'A') || (kbinput <= 'd' && kbinput >= 'a')) @@ -2768,7 +2770,7 @@ int main(int argc, char *argv[]) modify_control_seq = 1; keyhandled = 1; break; - case 91: + case '[': switch (kbinput = wgetch(edit)) { case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */ kbinput = wgetch(edit); @@ -2778,7 +2780,7 @@ int main(int argc, char *argv[]) } else if (kbinput >= '7' && kbinput <= '9') { kbinput = KEY_F(kbinput - 49); wgetch(edit); - } else if (kbinput == 126) + } else if (kbinput == '~') kbinput = KEY_HOME; #ifdef DEBUG @@ -2809,16 +2811,8 @@ int main(int argc, char *argv[]) kbinput = KEY_F(12); wgetch(edit); break; - case 126: /* Hack, make insert key do something - useful, like insert file */ -#ifdef ENABLE_MULTIBUFFER - do_insertfile(ISSET(MULTIBUFFER)); -#else - do_insertfile(0); -#endif - - keyhandled = 1; - break; + case '~': + goto do_insertkey; #ifdef DEBUG default: fprintf(stderr, _("I got Alt-[-2-%c! (%d)\n"), @@ -2953,6 +2947,20 @@ int main(int argc, char *argv[]) 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 */ if (!keyhandled) switch (kbinput) { @@ -2967,8 +2975,7 @@ int main(int argc, char *argv[]) do_next_word(); break; - case 331: /* Stuff that we don't want to do squat */ - case -1: + case -1: /* Stuff that we don't want to do squat */ case 410: /* Must ignore this, it gets sent when we resize */ #ifdef PDCURSES case 541: /* ???? */ diff --git a/winio.c b/winio.c index 17aeceda..3d793436 100644 --- a/winio.c +++ b/winio.c @@ -360,7 +360,6 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen, nanoget_repaint(buf, inputbuf, x); break; case KEY_BACKSPACE: - case KEY_DC: case 127: case NANO_CONTROL_H: if (strlen(inputbuf) > 0) { @@ -400,21 +399,24 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen, case KEY_DOWN: break; + case KEY_DC: + goto do_deletekey; + case 27: switch (kbinput = wgetch(edit)) { - case 79: + case 'O': switch (kbinput = wgetch(edit)) { - case 70: + case 'F': x = x_left + strlen(inputbuf); nanoget_repaint(buf, inputbuf, x); break; - case 72: + case 'H': x = x_left; nanoget_repaint(buf, inputbuf, x); break; } break; - case 91: + case '[': switch (kbinput = wgetch(edit)) { case 'C': if (x < xend) @@ -426,11 +428,13 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen, x--; wmove(bottomwin, 0, x); break; - case 49: + case '1': + case '7': x = x_left; nanoget_repaint(buf, inputbuf, x); - goto skip_126; - case 51: + goto skip_tilde; + case '3': + do_deletekey: if (strlen(inputbuf) > 0 && (x - x_left) != strlen(inputbuf)) { 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; } nanoget_repaint(buf, inputbuf, x); - goto skip_126; - case 52: + goto skip_tilde; + case '4': + case '8': x = x_left + strlen(inputbuf); nanoget_repaint(buf, inputbuf, x); - goto skip_126; - skip_126: + goto skip_tilde; + skip_tilde: nodelay(edit, TRUE); kbinput = wgetch(edit); - if (kbinput == 126 || kbinput == ERR) + if (kbinput == '~' || kbinput == ERR) kbinput = -1; nodelay(edit, FALSE); break;