lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev [PATCH 2.8.4dev.10] keymap fixes


From: Ilya Zakharevich
Subject: lynx-dev [PATCH 2.8.4dev.10] keymap fixes
Date: Fri, 20 Oct 2000 02:01:33 -0400
User-agent: Mutt/1.2i

This patch fixes setting up key mappings in the keymap file.  The
problem with the current approach is that it probably never worked...

One could not set up key mapping for keys defined in the terminfo
database, neigher via their names, nor via the raw keysequences.  The
problem was that curses were informed about the mapping *before* the
request for keypad translations.  After this request the requested
actions were overwritten by curses loading the terminfo definition.

Additionally, this patch makes unrecognized keynames to emit
diagnostic when tracing (but ignores them the same way the older
code did).  The last chunk traces info about each keycode recieved.

Enjoy,
Ilya

--- ./src/LYCurses.c-pre        Sun Oct 15 17:02:56 2000
+++ ./src/LYCurses.c    Sun Oct 15 19:36:58 2000
@@ -689,6 +689,7 @@ static WINDOW *LYscreen = NULL;
 
 PUBLIC void start_curses NOARGS
 {
+    int keypad_on = 0;
 #ifdef USE_SLANG
     static int slinit;
 
@@ -845,7 +846,15 @@ PUBLIC void start_curses NOARGS
        size_change(0);
        recent_sizechange = FALSE; /* prevent mainloop drawing 1st doc twice */
 #endif /* SIGWINCH */
+
 #if defined(USE_KEYMAPS) && defined(NCURSES_VERSION)
+#  if HAVE_KEYPAD
+       /* Need to switch keypad on before initializing keymaps, otherwise
+          when the keypad is switched on, some keybindings may be overriden. */
+       keypad(stdscr,TRUE);
+       keypad_on = 1;
+#  endif /* HAVE_KEYPAD */
+
        if (-1 == lynx_initialize_keymaps ()) {
            endwin();
            exit (-1);
@@ -938,7 +947,8 @@ PUBLIC void start_curses NOARGS
     noecho();
 
 #if HAVE_KEYPAD
-    keypad(stdscr,TRUE);
+    if (!keypad_on)
+       keypad(stdscr,TRUE);
 #endif /* HAVE_KEYPAD */
 
     lynx_enable_mouse (1);
--- ./src/LYStrings.c-ini       Thu Sep 21 21:21:58 2000
+++ ./src/LYStrings.c   Sun Oct 15 20:56:24 2000
@@ -799,7 +799,7 @@ PUBLIC void ena_csi ARGS1(
 #define define_key(string, code) \
        SLkm_define_keysym (string, code, Keymap_List)
 #define expand_substring(dst, first, last, final) \
-       SLexpand_escaped_string(dst, (char *)first, (char *)last)
+       (SLexpand_escaped_string(dst, (char *)first, (char *)last),1)
 static SLKeyMap_List_Type *Keymap_List;
 /* This value should be larger than anything in LYStrings.h */
 #define MOUSE_KEYSYM 0x0400
@@ -937,9 +937,10 @@ PRIVATE CONST char *expand_tichar (CONST
     return first;
 }
 
-PRIVATE void expand_substring (char* dst, CONST char* first, CONST char* last, 
char *final)
+PRIVATE int expand_substring (char* dst, CONST char* first, CONST char* last, 
char *final)
 {
     int ch;
+
     while (first < last) {
        switch (ch = *first++) {
        case ESCAPE:
@@ -949,9 +950,12 @@ PRIVATE void expand_substring (char* dst
            ch = *first++;
            if (ch == LPAREN) {
                CONST char *s = strchr(first, RPAREN);
+               char *was = dst;
                if (s == 0)
                    s = first + strlen(first);
                first = expand_tiname(first, s-first, &dst, final);
+               if (dst == was)
+                   return 0;
                if (*first)
                    first++;
            } else if (ch == '?') {             /* ASCII delete? */
@@ -972,6 +976,7 @@ PRIVATE void expand_substring (char* dst
        }
     }
     *dst = '\0';
+    return 1;
 }
 #endif
 
@@ -999,10 +1004,8 @@ PRIVATE BOOLEAN unescape_string ARGS3(ch
            dst[1] = '\0';
            ok = TRUE;
        }
-    } else if (*src == DQUOTE) {
-       expand_substring(dst, src + 1, src + strlen(src) - 1, final);
-       ok = TRUE;
-    }
+    } else if (*src == DQUOTE)
+       ok = expand_substring(dst, src + 1, src + strlen(src) - 1, final);
     return ok;
 }
 
@@ -1137,8 +1140,11 @@ PRIVATE int setkey_cmd (char *parse)
            }
            if (t != s)
                *t = '\0';
-           if (map_string_to_keysym (s, &keysym) >= 0
-            && unescape_string(parse, buf, buf + sizeof(buf) - 1)) {
+           if (map_string_to_keysym (s, &keysym) >= 0) {
+               if (!unescape_string(parse, buf, buf + sizeof(buf) - 1)) {
+                   CTRACE((tfp, "KEYMAP(SKIP) could unescape key\n"));
+                   return 0;           /* Trace the failure and continue. */
+               }
                if (LYTraceLogFP == 0) {
                    CTRACE((tfp, "KEYMAP(DEF) keysym=%#x\n", keysym));
                } else {
@@ -1553,11 +1559,13 @@ re_read:
            if (sigint)
                sigint = FALSE;
 #endif /* IGNORE_CTRL_C */
+           CTRACE((tfp, "GETCH: Translate ^C to ^G.\n"));
            return(7); /* use ^G to cancel whatever called us. */
        }
     }
 #endif /* !USE_SLANG || VMS */
 
+    CTRACE((tfp, "GETCH: Got %#x.\n", c));
 #ifdef MISC_EXP
     if (LYNoZapKey > 1 && errno != EINTR &&
        (c == EOF

; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]