[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] Ctrl+Left / Ctrl+Right
From: |
David Lawrence Ramsey |
Subject: |
Re: [Nano-devel] Ctrl+Left / Ctrl+Right |
Date: |
Sun, 17 Dec 2006 14:39:17 -0500 |
User-agent: |
Thunderbird 1.5.0.8 (X11/20061025) |
Benno Schulenberg wrote:
> Hi,
>
> In many editors Ctrl+Left moves to the preceding word, Ctrl+Right to
> the next word -- even some browsers work like this in form fields, and
> Konqueror even does it in the Location bar. It would be nice if nano
> could be made to do this too, as the Alt+Space and Ctrl+Space are just
> too unmnemonic to remember. I understand that this cannot become a
> default part of nano, since on the standard Linux console Ctrl+Left
> and Ctrl+Right cannot be be distinguished from plain Left and Right,
> but if I wanted to make a local patch, to make it work in Konsole, how
> to go about it?
>
> I've tried the attached patch, but it's not working:
> get_escape_seq_kbinput() never even seems to get visited. What am I
> overlooking?
Not much. There are several different routines that correspond to
Ctrl-[arrow key], and NANO_PREVWORD_KEY's being a meta sequence screws
things up a bit. Does the attached (somewhat hackish) patch work for
you?
diff -ur nano/src/nano.h nano-fixed/src/nano.h
--- nano/src/nano.h 2006-11-21 12:17:50.000000000 -0500
+++ nano-fixed/src/nano.h 2006-12-17 14:28:27.000000000 -0500
@@ -467,6 +467,9 @@
/* No key at all. */
#define NANO_NO_KEY -2
+/* Placeholder for NANO_PREVWORD_KEY. */
+#define NANO_FAKE_PREVWORD_KEY -3
+
/* Normal keys. */
#define NANO_XON_KEY NANO_CONTROL_Q
#define NANO_XOFF_KEY NANO_CONTROL_S
diff -ur nano/src/winio.c nano-fixed/src/winio.c
--- nano/src/winio.c 2006-12-02 18:39:16.000000000 -0500
+++ nano-fixed/src/winio.c 2006-12-17 14:32:43.000000000 -0500
@@ -490,6 +490,10 @@
if (retval != ERR) {
switch (retval) {
+ case NANO_FAKE_PREVWORD_KEY:
+ *meta_key = TRUE;
+ retval = NANO_PREVWORD_KEY;
+ break;
case NANO_CONTROL_8:
retval = ISSET(REBIND_DELETE) ? NANO_DELETE_KEY :
NANO_BACKSPACE_KEY;
@@ -763,9 +767,13 @@
break;
case 'a': /* Esc O a == Ctrl-Up on rxvt. */
case 'b': /* Esc O b == Ctrl-Down on rxvt. */
+ retval = get_escape_seq_abcd(seq[1]);
+ break;
case 'c': /* Esc O c == Ctrl-Right on rxvt. */
+ retval = NANO_NEXTWORD_KEY;
+ break;
case 'd': /* Esc O d == Ctrl-Left on rxvt. */
- retval = get_escape_seq_abcd(seq[1]);
+ retval = NANO_FAKE_PREVWORD_KEY;
break;
case 'j': /* Esc O j == '*' on numeric keypad with
* NumLock off on VT100/VT220/VT320/xterm/
@@ -853,9 +861,13 @@
switch (seq[1]) {
case 'a': /* Esc o a == Ctrl-Up on Eterm. */
case 'b': /* Esc o b == Ctrl-Down on Eterm. */
+ retval = get_escape_seq_abcd(seq[1]);
+ break;
case 'c': /* Esc o c == Ctrl-Right on Eterm. */
+ retval = NANO_NEXTWORD_KEY;
+ break;
case 'd': /* Esc o d == Ctrl-Left on Eterm. */
- retval = get_escape_seq_abcd(seq[1]);
+ retval = NANO_FAKE_PREVWORD_KEY;
break;
}
break;
@@ -925,11 +937,15 @@
* xterm. */
case 'B': /* Esc [ 1 ; 5 B == Ctrl-Down on
* xterm. */
+ retval = get_escape_seq_abcd(seq[4]);
+ break;
case 'C': /* Esc [ 1 ; 5 C == Ctrl-Right on
* xterm. */
+ retval = NANO_NEXTWORD_KEY;
+ break;
case 'D': /* Esc [ 1 ; 5 D == Ctrl-Left on
* xterm. */
- retval = get_escape_seq_abcd(seq[4]);
+ retval = NANO_FAKE_PREVWORD_KEY;
break;
}
}