[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev lynx keymaps
From: |
John E. Davis |
Subject: |
lynx-dev lynx keymaps |
Date: |
Thu, 23 Apr 1998 02:52:39 -0400 |
Tonight I managed to find a couple of hours to replace LYgetch with
something more reasonable in the hope of allowing one to easily define
new key sequences. Unfortunately, IMO lynx has a major design flaw in
the way it handles keymaps. From what I can tell, LYgetch simply
parses escape sequences and passes those back to the caller in the
form of a keysym, e.g., DNARROW. These keysyms appear to be an
intermediate representation that get mapped (via an array called
keymap) at various places in the code to a more abstract
representation, e.g., LYK_NEXT_LINK. The problem with this approach
is that the intermediate representation, e.g., DNARROW is fixed, that
is, once cannot dynamically new objects to this. About the only thing
that be done is to create key sequences that are equivalent. For
example, suppose that one wants to map the F23 key to go to the next
link. Then one can define the key sequence for F23 to produce a
DNARROW keysym. Of course the problem with this is that F23 will look
like a down arrow in all contexts.
I am far too tired to put the patches together tonight but what I have
is this: If compiled with SLANG, lynx will look for a file called
`.lynx-keymaps' in your home directory and use it for keymap
definitions. Here is a simple example of such a file:
# This is a comment
setkey "^[[21~" '/'
setkey "^K^[[A" HOME
setkey "^K^[[B" END
This file contains 3 keymappings: The first mapping is appropriate for
my F10 key on my terminal. This line will map it to the intermediate
representation of the '/' character. In otherwords, F10 will perform
the search function. Similarly, `Ctrl-K UP' maps to the HOME
(beginning of document) intermediate representation, and `Ctrl-K DOWN'
maps to END (end of document).
I will make the patches available tomorrow. For what it is worth,
LYgetch defined in LYStrings.c now looks like (when compiled with
slang):
int LYgetch (void)
{
SLang_Key_Type *key;
int keysym;
key = SLang_do_key (Keymap_List, (int (*)(void)) GetChar);
if ((key == NULL) || (key->type != SLKEY_F_KEYSYM))
return DO_NOTHING;
keysym = key->f.keysym;
#if defined (USE_SLANG_MOUSE)
if (keysym == MOUSE_KEYSYM)
return sl_read_mouse_event ();
#endif
if ((keysym > DO_NOTHING) || (keysym < 0))
return 0;
return keysym;
}
--John
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lynx-dev lynx keymaps,
John E. Davis <=