lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev Text editing keymap


From: aldomel
Subject: lynx-dev Text editing keymap
Date: Fri, 18 Sep 1998 04:26:34 +0000

I wanted to be able to press ^N in a text line and scroll down so
 I made this patch to extend the existing keymap.

 I added a lynx.cfg command to change the keymap used in text 
 editing. It's like the KEYMAP command, KEYEDITMAP:^N:LYE_PASS
 (added remapedit and revmapedit in LYEditmap.c and 
 keyeditmap_fun in LYReadCFG.c)
 And made a command called LYE_PASS to let a key be interpreted as
 not an editing key, so ^N will scroll down two instead of move right
 one word. (added lines in LYForms.c and LYStrings.h) 

 Relatve to ver 2.8.1dev28 
 

--- orig/src/LYEditmap.c        Thu Sep 17 21:57:47 1998
+++ new/src/LYEditmap.c Thu Sep 17 21:07:53 1998
@@ -147,3 +147,63 @@
     return status;
 }
 
+/*defined twice see LYKeymap.c*/
+struct rmap {
+       CONST char *name;
+       CONST char *doc;
+};
+
+/* contains names of text editing keys
+* used in forms
+* see LYStrings.h for those and LYEditMap.c
+*/
+PRIVATE struct rmap revmapedit[] = {
+{"LYE_NOP",    "Do Nothing"},
+{"LYE_CHAR",   "Insert printable char"},
+{"LYE_ENTER",  "Input complete, return char"},
+{"LYE_TAB",    "Input complete, return TAB "},
+{"LYE_ABORT",  "Input cancelled"},
+{"LYE_DELN",   "Delete next    char"},
+{"LYE_DELC",   "Delete current char"},
+{"LYE_DELP",   "Delete prev    char"},
+{"LYE_DELNW",  "Delete next word"},
+{"LYE_DELPW",  "Delete prev word"},
+{"LYE_ERASE",  "Erase the line"},
+{"LYE_BOL",    "Go to begin of line"},
+{"LYE_EOL",    "Go to end   of line"},
+{"LYE_FORW",   "Cursor forwards"},
+{"LYE_BACK",   "Cursor backwards"},
+{"LYE_FORWW",  "Word forward"},
+{"LYE_BACKW",  "Word back"},
+{"LYE_LOWER",  "Lower case the line"},
+{"LYE_UPPER",  "Upper case the line"},
+{"LYE_LKCMD",  "Invoke command prompt"},
+{"LYE_AIX",    "Hex 97"},
+{"LYE_PASS",   "Don't use key to edit, pass to main lynx"},
+{NULL, ""}
+};
+
+ /*Similar to remap but for EditBinding (text editing) */
+PUBLIC int remapedit ARGS2(char *,key, char *,func)
+ {
+       int i;
+       struct rmap *mp;
+       int c = 0;
+
+       if (func == NULL)
+              return 0;
+       if (strlen(key) == 1)
+               c = *key;
+       else if (strlen(key) == 2 && *key == '^')
+               c = key[1] & 037;
+       else if (strlen(key) >= 2 && isdigit(*key))
+               if (sscanf(key, "%i", &c) != 1)
+                       return 0;
+       for (i = 0, mp = revmapedit; (*mp).name != NULL; mp++, i++) {
+               if (strcmp((*mp).name, func) == 0) {
+                       EditBinding(c) = i;
+                       return c;
+               }
+       }
+       return 0;
+}
--- orig/src/LYForms.c  Thu Sep 17 21:57:48 1998
+++ new/src/LYForms.c   Thu Sep 17 23:42:34 1998
@@ -350,6 +350,8 @@
         *  to line editor, and LYK_REFRESH.
         */
        action = EditBinding(ch);
+       if (action == LYE_PASS) /*Don't treat as editing command*/
+           break;
        if (action == LYE_ENTER)
            break;
        if (action == LYE_LKCMD) {
--- orig/src/LYReadCFG.c        Thu Sep 17 21:57:48 1998
+++ new/src/LYReadCFG.c Thu Sep 17 20:09:32 1998
@@ -610,6 +610,24 @@
     return 0;
 }
 
+/*similar to keymap_fun, but for text editing mode*/
+static int keyeditmap_fun ARGS1(
+       char *,         key)
+{
+    char *func;
+
+    if ((func = strchr(key, ':')) != NULL)     {
+       *func++ = '\0';
+       /* Allow comments on the ends of key remapping lines. - DT */
+       if (!remapedit(key, strtok(func, " \t\n#")))
+           fprintf(stderr,
+                   "edit key remapping of %s to %s failed\n",key,func);
+       else if (!strcmp("TOGGLE_HELP", strtok(func, " \t\n#")))
+           LYUseNoviceLineTwo = FALSE;
+    }
+    return 0;
+}
+
 static int keymap_fun ARGS1(
        char *,         key)
 {
@@ -843,6 +861,7 @@
      PARSE_STR("jump_prompt", CONF_STR, jumpprompt),
      PARSE_SET("jumpbuffer", CONF_BOOL, jump_buffer),
      PARSE_FUN("jumpfile", CONF_FUN, jumpfile_fun),
+     PARSE_FUN("keyeditmap", CONF_FUN, keyeditmap_fun),
      PARSE_FUN("keymap", CONF_FUN, keymap_fun),
      PARSE_SET("list_news_numbers", CONF_BOOL, LYListNewsNumbers),
      PARSE_SET("list_news_dates", CONF_BOOL, LYListNewsDates),
--- orig/src/LYStrings.h        Thu Sep 17 21:57:49 1998
+++ new/src/LYStrings.h Thu Sep 17 22:11:28 1998
@@ -144,6 +144,9 @@
 
 #define LYE_AIX   (LYE_LKCMD +1)  /* Hex 97               */
 
+#define LYE_PASS  (LYE_AIX   +1)  /* Don't use key to edit, pass to
main lynx
+                                  * as command*/
+
 #if defined(USE_KEYMAPS)
 extern int lynx_initialize_keymaps NOPARAMS;
 #endif

reply via email to

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