patch: C-PGUP/DN will work in GNU screen in xterm



Hi all,

I wanted to get C-PGUP and C-PGDN working with screen in an xterm.

I'm no C coder (mostly bash and REXX) but below's a patch for key.h and
key.c in 4.6.0 which seems to do the trick....

I hope it's OK as it stands -- but something on these lines ought to be
in there, it seems to me.

best,

S.

=====patch below================

--- key.h.orig	Mon Dec 23 04:46:28 2002
+++ key.h	Sun Aug 31 20:03:27 2003
@@ -60,4 +60,9 @@
 int define_sequence (int code, char *seq, int action);

+/* xterm_key_defines for GNU screen running in xterm --
+defined in key.c, called by init_key() */
+
+int screen_under_xterm();
+
 /* internally used in key.c, defined in keyxtra.c */
 void load_xtra_key_defines (void);


--- key.c.orig	Mon Jan 27 17:37:56 2003
+++ key.c	Sun Aug 31 20:03:32 2003
@@ -252,4 +252,32 @@
 #endif /* HAVE_TEXTMODE_X11_SUPPORT */

+/* C-PGUP and C-PGDN will work fine in GNU screen running in */
+/* an xterm -- but xterm_key_defines are needed for that.    */
+/*                                                           */
+/* screen doesn't like TERM to be anything other than        */
+/* 'screen*' (or maybe 'vt100'), and init_key has been doing */
+/*                                                           */
+/*    define_sequences (xterm_key_defines);                  */
+/*                                                           */
+/* only for TERM=xterm* or TERM=iris-ansi*.... So we want to */
+/* say 'Yes, TERM=screen*, but I'm running in an xterm --    */
+/* define those sequences.'                                  */
+/*                                                           */
+/* So we create this function and add a test to init_key.    */
+/*                                                           */
+/* I don't think WINDOWID is infallible, but I don't know    */
+/* another way. (XGetCommand(), perhaps??)                   */
+
+int
+screen_under_xterm (void)
+{
+    static int s_xterm = -1;
+
+    if (s_xterm == -1)
+	s_xterm = !!getenv ("WINDOWID");
+
+    return s_xterm;
+}
+
 /* This has to be called before slang_init or whatever routine
    calls any define_sequence */
@@ -263,5 +291,5 @@

     /* Terminfo on irix does not have some keys */
-    if ((!strncmp (term, "iris-ansi", 9)) || (!strncmp (term, "xterm", 5)))
+    if ((!strncmp (term, "iris-ansi", 9)) || (!strncmp (term, "xterm", 5)) || (!strncmp (term, "screen", 6) && screen_under_xterm()))
 	define_sequences (xterm_key_defines);




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]