+2015-11-23 Benno Schulenberg <bensberg@justemail.net>
+ * src/nano.c (main), src/winio.c (parse_kbinput): Make Ctrl+Left and
+ Ctrl+Right work on more terminals by asking ncurses for the keycodes.
+ This addresses Debian bug #800681 reported by Arturo Borrero González.
+
2015-11-22 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (add_undo): Delete a condition that will never occur --
this function is only ever called with PASTE when cutbuffer != NULL.
bool focusing = FALSE;
/* Whether an update of the edit window should center the cursor. */
+#ifndef NANO_TINY
+int controlleft = CONTROL_LEFT;
+int controlright = CONTROL_RIGHT;
+#endif
+
#ifndef DISABLE_WRAPJUSTIFY
ssize_t fill = 0;
/* The column where we will wrap lines. */
interface_color_pair[FUNCTION_TAG].bright = FALSE;
#endif
+#if !defined(NANO_TINY) && !defined(USE_SLANG)
+ /* Ask ncurses for the key codes for Control+Left and Control+Right. */
+ if ((int)tigetstr("kLFT5") > 0)
+ controlleft = key_defined(tigetstr("kLFT5"));
+ if ((int)tigetstr("kRIT5") > 0)
+ controlright = key_defined(tigetstr("kRIT5"));
+#endif
+
#ifdef DEBUG
fprintf(stderr, "Main: open file\n");
#endif
#define NANO_CONTROL_7 31
#define NANO_CONTROL_8 127
-/* Codes for "modified" Arrow keys. Chosen like this because some
- * terminals produce them, and they are beyond KEY_MAX of ncurses. */
-#define CONTROL_LEFT 539
-#define CONTROL_RIGHT 554
+/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
+#define CONTROL_LEFT 0x401
+#define CONTROL_RIGHT 0x402
#ifndef NANO_TINY
/* An imaginary key for when we get a SIGWINCH (window resize). */
extern bool func_key;
extern bool focusing;
+#ifndef NANO_TINY
+extern int controlleft;
+extern int controlright;
+#endif
+
#ifndef DISABLE_WRAPJUSTIFY
extern ssize_t fill;
extern ssize_t wrap_at;
retval = ERR;
break;
#endif
- case CONTROL_LEFT:
-#ifndef NANO_TINY
- retval = sc_seq_or(do_prev_word_void, 0);
-#endif
- break;
- case CONTROL_RIGHT:
-#ifndef NANO_TINY
- retval = sc_seq_or(do_next_word_void, 0);
-#endif
- break;
#ifndef NANO_TINY
case KEY_WINCH:
retval = KEY_WINCH;
#endif
}
+#ifndef NANO_TINY
+ if (retval == controlleft)
+ retval = sc_seq_or(do_prev_word_void, 0);
+ else if (retval == controlright)
+ retval = sc_seq_or(do_next_word_void, 0);
+#endif
+
/* If our result is an extended keypad value (i.e. a value
* outside of byte range), set func_key to TRUE. */
if (retval != ERR)