Hi Arturo,

Pfff... this is deeply hidden!  One has to read very closely,
but then one can find it in here:
  http://invisible-island.net/ncurses/ncurses.faq.html#modified_keys

There where it says: "But xterm can also work for control-, alt-, and
meta-modifiers."  The given example is for the Delete key.  One has
to read a bit in 'man 5 terminfo' to find that the name for the shifted
Left key is kLFT.  And then, from the given example, the "automatic"
name for the Control+Left key is kLFT5.

Phew.  How complicated.  I've had to ask mister Thomas Dickey himself
to realize how this worked, and how to obtain the actual key code.
(Thanks, Thomas.)

Please try the attached patch.  (You have to undo the previous patch.)
It works here on a Pantheon terminal.

Benno

-- 
http://www.fastmail.com - Same, same, but different...

Index: src/proto.h
===================================================================
--- src/proto.h	(revision 5405)
+++ src/proto.h	(working copy)
@@ -35,6 +35,9 @@
 extern bool func_key;
 extern bool focusing;
 
+extern int controlleft;
+extern int controlright;
+
 #ifndef DISABLE_WRAPJUSTIFY
 extern ssize_t fill;
 extern ssize_t wrap_at;
Index: src/winio.c
===================================================================
--- src/winio.c	(revision 5405)
+++ src/winio.c	(working copy)
@@ -634,23 +634,20 @@
 		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;
 		break;
 #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)
Index: src/nano.c
===================================================================
--- src/nano.c	(revision 5405)
+++ src/nano.c	(working copy)
@@ -2707,6 +2707,13 @@
     interface_color_pair[FUNCTION_TAG].bright = FALSE;
 #endif
 
+#ifndef USE_SLANG
+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
Index: src/global.c
===================================================================
--- src/global.c	(revision 5405)
+++ src/global.c	(working copy)
@@ -41,6 +41,9 @@
 bool focusing = FALSE;
 	/* Whether an update of the edit window should center the cursor. */
 
+int controlleft = CONTROL_LEFT;
+int controlright = CONTROL_RIGHT;
+
 #ifndef DISABLE_WRAPJUSTIFY
 ssize_t fill = 0;
 	/* The column where we will wrap lines. */

Reply via email to