From: David Lawrence Ramsey
4.5a. [version 1.1.12 and earlier] When I type in a search string, the string I last searched for is already in front of my cursor! What happened?!
4.5b. [version 1.2.2 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?
- 4.6. I get the message "NumLock glitch detected. Keypad will malfunction with NumLock off." What gives?
- 4.7. How do I make nano my default editor (in Pine, mutt, etc.)?
- 4.8. I've compiled nano with color support, but I don't see any color when I run it!
@@ -183,10 +182,7 @@5.1. There's no translation for my language!
5.2. I don't like the translation for <x> in my language. How can I fix it?
In nano version 0.9.20, the default is to have a completely consistent user interface across all user input functions. This means that regardless of whether you're being asked for a filename to insert or write, or a string to search for, the previous value is already inserted before the cursor. If you prefer the old behavior, use the Pico emulation mode (-p or --pico) or just hit Meta-P while in nano (see the ^G help text for more details).
-It was decided that consistency was nice, but people are used to Pico's inconsistent behavior. Also, in version 1.1.99pre1, search and replace history was introduced. If you wish to edit your previous search/replace entry (or any previous entry), you can do so by hitting the up arrow to cycle through your history. This method allows the best of both worlds: You don't need to erase the previous string if you want to enter a new one, but you can with one keystroke recall previous entries for editing. Therefore there is now no "Pico mode", nano is and has always been a Pico clone, and clones by default should be compatible.
-Nano (and actually almost all console editors) has issues when cycling the NumLock key in certain X terminals (rxvt, aterm, wterm, etc...). When you switch NumLock from on to off, you put the terminal into an "application mode" that changes what sequences are sent by the keypad. These sequences vary sufficiently from terminal to terminal that it is nearly impossible to work around them from within nano.
-In a nutshell, if you want to be able to use the keypad with the arrow and page up/down functionality, you have to exit nano and reset your terminal (presumably with "reset" or "stty sane" or similar) and then run nano again with NumLock off. If you know an easier way to restore "normal mode", please mail nano@nano-editor.org.
-You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your .bashrc if you use bash (or .zshrc if you believe in zsh):
export EDITOR=/usr/local/bin/nano
or if you use tcsh put this in your .cshrc file:
@@ -199,7 +195,7 @@Mutt users should see an effect immediately the next time you log in, no further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your .muttrc:
my_hdr X-Composer: nano x.y.z
Again, replace x.y.z with the version of nano you use.
If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Some example configurations are in the nanorc.sample that comes with the nano source or your nano package. See Section 3.9.
+2004/04/07 - Removed NumLock glitch question, as it's no longer needed. (DLR)
2004/01/30 - Fixed inaccuracy: multibuffer mode was first in nano 1.1.0, not 1.1.12. (DLR)
2003/12/31 - Added question about the new verbatim input function, and a few minor fixes. Removed reference to "set pico" (DLR).
2003/07/02 - Added question about nano's not showing color when it's compiled with color support (DLR; suggested by Jordi).
diff --git a/src/nano.c b/src/nano.c index 6ea3c359..2106953d 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2971,18 +2971,6 @@ void allow_pending_sigwinch(int allow) } #endif /* !NANO_SMALL */ -/* If the NumLock key has made the keypad go awry, print an error - * message; hopefully we can address it later. */ -void print_numlock_warning(void) -{ - static int didmsg = 0; - if (!didmsg) { - statusbar(_ - ("NumLock glitch detected. Keypad will malfunction with NumLock off")); - didmsg = 1; - } -} - #ifndef NANO_SMALL void do_toggle(const toggle *which) { diff --git a/src/nano.h b/src/nano.h index 0d259a52..ca2d3aa2 100644 --- a/src/nano.h +++ b/src/nano.h @@ -105,34 +105,6 @@ * all of the special sentinel values below, to different negative * values other than -1. */ -/* HP-UX 10 & 11 do not seem to support KEY_HOME and KEY_END. */ -#ifndef KEY_HOME -#define KEY_HOME -2 -#endif - -#ifndef KEY_END -#define KEY_END -3 -#endif - -/* Slang and SunOS 5.7-5.9 do not seem to support KEY_RESIZE. */ -#ifndef KEY_RESIZE -#define KEY_RESIZE -4 -#endif - -/* Slang does not seem to support KEY_SUSPEND, KEY_SLEFT, or - * KEY_SRIGHT. */ -#ifndef KEY_SUSPEND -#define KEY_SUSPEND -5 -#endif - -#ifndef KEY_SLEFT -#define KEY_SLEFT -6 -#endif - -#ifndef KEY_SRIGHT -#define KEY_SRIGHT -7 -#endif - #define VERMSG "GNU nano " VERSION /* If we aren't using ncurses, turn the mouse support off, as it's @@ -366,13 +338,13 @@ typedef struct historyheadtype { #define NANO_ALT_SPACE ' ' /* Some semi-changeable keybindings; don't play with these unless you're - * sure you know what you're doing. */ + * sure you know what you're doing. Assume ERR is defined as -1. */ /* No key at all. */ -#define NANO_NO_KEY -8 +#define NANO_NO_KEY -2 -/* Special sentinel key used for search string history. */ -#define NANO_HISTORY_KEY -9 +/* Special sentinel key used for search/replace history. */ +#define NANO_HISTORY_KEY -3 /* Normal keys. */ #define NANO_INSERTFILE_KEY NANO_CONTROL_R diff --git a/src/proto.h b/src/proto.h index 489ee7dc..3375eb82 100644 --- a/src/proto.h +++ b/src/proto.h @@ -341,7 +341,6 @@ RETSIGTYPE do_cont(int signal); void handle_sigwinch(int s); void allow_pending_sigwinch(int allow); #endif -void print_numlock_warning(void); #ifndef NANO_SMALL void do_toggle(const toggle *which); #endif diff --git a/src/winio.c b/src/winio.c index dd56cf4e..57f1efba 100644 --- a/src/winio.c +++ b/src/winio.c @@ -38,12 +38,22 @@ static int statblank = 0; /* Number of keystrokes left after we call statusbar(), before we actually blank the statusbar */ +/* Note on the following input routines: VT100s and derived terminals + * generate Ctrl-H for Backspace and Ctrl-? (Ctrl-8) for Delete, while + * VT220s/VT320s and derived terminals generate Ctrl-? (Ctrl-8) for + * Backspace (VT320 only) and Esc [ 3 ~ for Delete (VT220/VT320). The + * FreeBSD console is VT100-derived, but sometimes xterm wrongly assumes + * it's VT220/VT320-derived. The workarounds for the problems that this + * causes, in get_accepted_kbinput() and get_escape_seq_kbinput(), are + * indicated by the comments beginning with "Terminal breakage". */ + /* Read in a single input character. If it's ignored, swallow it and go * on. Otherwise, try to translate it from ASCII, extended keypad * values, and/or escape sequences. Supported extended keypad values * consist of [arrow key], Ctrl-[arrow key], Shift-[arrow key], Enter, - * Backspace, Insert, Delete, Home, End, PageUp, PageDown, and F1-F14. - * Assume nodelay(win) is FALSE. */ + * Backspace, the editing keypad (Insert, Delete, Home, End, PageUp, and + * PageDown), the function keypad (F1-F14), and the numeric keypad with + * NumLock off. Assume nodelay(win) is FALSE. */ int get_kbinput(WINDOW *win, int *meta_key) { int kbinput, retval; @@ -134,7 +144,10 @@ int get_ignored_kbinput(WINDOW *win) kbinput = wgetch(win); switch (kbinput) { case ERR: +#ifdef KEY_RESIZE + /* Slang and SunOS 5.7-5.9 don't support KEY_RESIZE. */ case KEY_RESIZE: +#endif #ifdef PDCURSES case KEY_SHIFT_L: case KEY_SHIFT_R: @@ -190,10 +203,12 @@ int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta_key) break; case 'O': case 'o': - /* Terminal breakage, part 1: We shouldn't get an escape - * sequence here for terminals that support Delete, but - * we do sometimes on FreeBSD. Thank you, Wouter van - * Hemel. */ + /* Terminal breakage, part 1: When Delete is pressed, + * xterm generates the VT220/VT320 sequence, Esc [ 3 ~, + * for it instead of the VT100 sequence, Ctrl-? + * (Ctrl-8). Work around this by always interpreting + * the VT220/VT320 sequence as Delete. Thank you, + * Wouter van Hemel. */ case '[': { int old_kbinput = kbinput, *escape_seq; @@ -222,8 +237,11 @@ int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta_key) } break; case NANO_CONTROL_8: - /* Terminal breakage, part 2: We shouldn't get Ctrl-8 - * (Ctrl-?) for Backspace or Delete, but we do sometimes. */ + /* Terminal breakage, part 2: When Backspace is pressed, + * xterm generates the VT320 sequence, Ctrl-? (Ctrl-8), for + * it instead of the VT100 sequence, Ctrl-H. Work around + * this by interpreting the VT320 sequence as Delete when + * REBIND_DELETE isn't set, and as Backspace when it is. */ kbinput = ISSET(REBIND_DELETE) ? NANO_DELETE_KEY : NANO_BACKSPACE_KEY; break; case KEY_DOWN: @@ -238,16 +256,23 @@ int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta_key) case KEY_RIGHT: kbinput = NANO_FORWARD_KEY; break; +#ifdef KEY_HOME + /* HP-UX 10 and 11 don't support KEY_HOME. */ case KEY_HOME: kbinput = NANO_HOME_KEY; break; +#endif case KEY_BACKSPACE: kbinput = NANO_BACKSPACE_KEY; break; case KEY_DC: - /* Terminal breakage, part 3: We should only get KEY_DC when - * hitting Delete, but we get it when hitting Backspace - * sometimes on FreeBSD. Thank you, Lee Nelson. */ + /* Terminal breakage, part 3: When Backspace is pressed, + * xterm generates the VT320 sequence, Ctrl-? (Ctrl-8), for + * it instead of the VT100 sequence, Ctrl-H. Ctrl-? + * (Ctrl-8) then gets translated into the keypad value + * KEY_DC. Work around this by interpreting KEY_DC as + * Delete when REBIND_DELETE isn't set, and as Backspace + * when it is. Thank you, Lee Nelson. */ kbinput = ISSET(REBIND_DELETE) ? NANO_BACKSPACE_KEY : NANO_DELETE_KEY; break; case KEY_IC: @@ -262,18 +287,39 @@ int get_accepted_kbinput(WINDOW *win, int kbinput, int *meta_key) case KEY_ENTER: kbinput = NANO_ENTER_KEY; break; + case KEY_B2: /* Center (5) on numeric keypad with NumLock off + * on xterm. */ +#ifdef KEY_BEG + /* Slang doesn't support KEY_BEG. */ + case KEY_BEG: /* Center (5) on numeric keypad with NumLock off + * on Eterm. */ +#endif + kbinput = '5'; + break; +#ifdef KEY_END + /* HP-UX 10 and 11 don't support KEY_END. */ case KEY_END: kbinput = NANO_END_KEY; break; +#endif +#ifdef KEY_SUSPEND + /* Slang doesn't support KEY_SUSPEND. */ case KEY_SUSPEND: kbinput = NANO_SUSPEND_KEY; break; +#endif +#ifdef KEY_SLEFT + /* Slang doesn't support KEY_SLEFT. */ case KEY_SLEFT: kbinput = NANO_BACK_KEY; break; +#endif +#ifdef KEY_SRIGHT + /* Slang doesn't support KEY_SRIGHT. */ case KEY_SRIGHT: kbinput = NANO_FORWARD_KEY; break; +#endif } #ifdef DEBUG fprintf(stderr, "get_accepted_kbinput(): kbinput = %d, meta_key = %d\n", kbinput, *meta_key); @@ -357,21 +403,27 @@ int get_ascii_kbinput(WINDOW *win, int kbinput) * There are several escape sequence conflicts and omissions, outlined * as follows: * + * - PageDown on FreeBSD console == Center (5) on numeric keypad with + * NumLock off on Linux console. (The editing keypad key is more + * important to have working than the numeric keypad key, because the + * latter actually has no value when NumLock is off.) * - F1 on FreeBSD console == kmous on xterm/rxvt/Eterm; the latter is * omitted. (Mouse input will only work properly if the extended * keypad value KEY_MOUSE is generated on mouse events instead of the * kmous escape sequence.) * - F9 on FreeBSD console == PageDown on Hurd console; the former is - * omitted. (The editing keypad, consisting of Insert, Delete, Home, - * End, PageUp, and PageDown, is more important to have working than - * the function keys, because the functions of the former are not + * omitted. (The editing keypad is more important to have working + * than the function keys, because the functions of the former are not * arbitrary and the functions of the latter are.) * - F10 on FreeBSD console == PageUp on Hurd console; the former is * omitted. (Same as above.) * - F13 on FreeBSD console == End on Hurd console; the former is * omitted. (Same as above.) - * - The Hurd console has no escape sequences for F11, F12, F13, or - * F14. */ + * - The Hurd console has no escape sequences for F11, F12, F13, F14, or + * Center (5) on the numeric keypad with NumLock off. + * + * Note that Center (5) on the numeric keypad with NumLock off can be + * either kb2 or kbeg, or both. */ int get_escape_seq_kbinput(WINDOW *win, int *escape_seq, size_t escape_seq_len) { @@ -401,12 +453,20 @@ int get_escape_seq_kbinput(WINDOW *win, int *escape_seq, size_t case 'D': /* Esc O D == Left on xterm. */ kbinput = get_escape_seq_abcd(escape_seq[1]); break; + case 'E': /* Esc O E == Center (5) on numeric keypad + * with NumLock off on xterm. */ + kbinput = '5'; + break; case 'F': /* Esc O F == End on xterm. */ kbinput = NANO_END_KEY; break; case 'H': /* Esc O H == Home on xterm. */ kbinput = NANO_HOME_KEY; break; + case 'M': /* Esc O M == Enter on numeric keypad with + * NumLock off on xterm/Eterm. */ + kbinput = NANO_ENTER_KEY; + break; case 'P': /* Esc O P == F1 on Hurd console. */ kbinput = KEY_F(1); break; @@ -443,6 +503,70 @@ int get_escape_seq_kbinput(WINDOW *win, int *escape_seq, size_t case 'd': /* Esc O d == Ctrl-Left on rxvt. */ kbinput = get_escape_seq_abcd(escape_seq[1]); break; + case 'j': /* Esc O j == '*' on numeric keypad with + * NumLock off on xterm/rxvt. */ + kbinput = '*'; + break; + case 'k': /* Esc O k == '+' on numeric keypad with + * NumLock off on xterm/rxvt. */ + kbinput = '+'; + break; + case 'l': /* Esc O l == ',' on numeric keypad with + * NumLock off on xterm/rxvt. */ + kbinput = '+'; + break; + case 'm': /* Esc O m == '-' on numeric keypad with + * NumLock off on xterm/rxvt. */ + kbinput = '-'; + break; + case 'n': /* Esc O n == Delete (.) on numeric keypad + * with NumLock off on rxvt. */ + kbinput = NANO_DELETE_KEY; + break; + case 'o': /* Esc O o == '/' on numeric keypad with + * NumLock off on xterm/rxvt. */ + kbinput = '/'; + break; + case 'p': /* Esc O p == Insert (0) on numeric keypad + * with NumLock off on rxvt. */ + kbinput = NANO_INSERTFILE_KEY; + break; + case 'q': /* Esc O q == End (1) on numeric keypad + * with NumLock off on rxvt. */ + kbinput = NANO_END_KEY; + break; + case 'r': /* Esc O r == Down (2) on numeric keypad + * with NumLock off on rxvt. */ + kbinput = NANO_NEXTLINE_KEY; + break; + case 's': /* Esc O s == PageDown (3) on numeric + * keypad with NumLock off on rxvt. */ + kbinput = NANO_NEXTPAGE_KEY; + break; + case 't': /* Esc O t == Left (4) on numeric keypad + * with NumLock off on rxvt. */ + kbinput = NANO_BACK_KEY; + break; + case 'u': /* Esc O u == Center (5) on numeric keypad + * with NumLock off on rxvt/Eterm. */ + kbinput = '5'; + break; + case 'v': /* Esc O v == Right (6) on numeric keypad + * with NumLock off on rxvt. */ + kbinput = NANO_FORWARD_KEY; + break; + case 'w': /* Esc O w == Home (7) on numeric keypad + * with NumLock off on rxvt. */ + kbinput = NANO_HOME_KEY; + break; + case 'x': /* Esc O x == Up (8) on numeric keypad + * with NumLock off on rxvt. */ + kbinput = NANO_PREVLINE_KEY; + break; + case 'y': /* Esc O y == PageUp (9) on numeric keypad + * with NumLock off on rxvt. */ + kbinput = NANO_PREVPAGE_KEY; + break; } break; case 'o': @@ -614,12 +738,16 @@ int get_escape_seq_kbinput(WINDOW *win, int *escape_seq, size_t * console/rxvt/Eterm. */ kbinput = get_escape_seq_abcd(escape_seq[1]); break; + case 'E': /* Esc [ E == Center (5) on numeric keypad + * with NumLock off on FreeBSD console. */ + kbinput = '5'; + break; case 'F': /* Esc [ F == End on FreeBSD * console/Eterm. */ kbinput = NANO_END_KEY; break; case 'G': /* Esc [ G == PageDown on FreeBSD - * console. */ + * console. */ kbinput = NANO_NEXTPAGE_KEY; break; case 'H': /* Esc [ H == Home on FreeBSD