43 {
"Backspace", FL_BackSpace },
44 {
"Delete", FL_Delete },
61 {
"Insert", FL_Insert },
64 {
"PageDown", FL_Page_Down },
65 {
"PageUp", FL_Page_Up },
66 {
"Print", FL_Print },
67 {
"Return", FL_Enter },
68 {
"Right", FL_Right },
74 {
"Favorites", FL_Favorites },
75 {
"Forward", FL_Forward },
76 {
"HomePage", FL_Home_Page },
78 {
"MediaNext", FL_Media_Next },
79 {
"MediaPlay", FL_Media_Play },
80 {
"MediaPrev", FL_Media_Prev },
81 {
"MediaStop", FL_Media_Stop },
82 {
"Refresh", FL_Refresh },
83 {
"Search", FL_Search },
84 {
"Sleep", FL_Sleep },
86 {
"VolumeDown", FL_Volume_Down },
87 {
"VolumeMute", FL_Volume_Mute },
88 {
"VolumeUp", FL_Volume_Up },
92 {
"Shift", FL_SHIFT },
96 {
"Button1", FL_BUTTON1 },
97 {
"Button2", FL_BUTTON2 },
98 {
"Button3", FL_BUTTON3 }
121 {
"back" ,
KEYS_BACK , 0 , FL_BackSpace },
161 node =
dNew(KeyBinding_t, 1);
179 dFree((
char*)node->name);
191 KeyBinding_t *n = (KeyBinding_t*)node, *k = (KeyBinding_t*)key;
192 _MSG(
"Keys::nodeByKeyCmp modifier=%d\n", k->modifier);
193 return (n->key != k->key) ? (n->key - k->key) : (n->modifier - k->modifier);
203 KeyBinding_t keyNode;
205 keyNode.modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL |FL_ALT|FL_META);
206 if (iscntrl(Fl::event_text()[0])) {
207 keyNode.key = Fl::event_key();
209 const char *beyond = Fl::event_text() + Fl::event_length();
218 if (keyNode.key != Fl::event_key())
219 keyNode.modifier = 0;
221 _MSG(
"getKeyCmd: evkey=0x%x evtext=\'%s\' key=0x%x, mod=0x%x\n",
222 Fl::event_key(), Fl::event_text(), keyNode.key, keyNode.modifier);
225 ret = ((KeyBinding_t*)data)->cmd;
234 KeyBinding_t keyNode, *node;
236 keyNode.modifier = mod;
241 dFree((
char*)node->name);
271 for (i = 0; i <
sizeof(
default_keys) /
sizeof(KeyBinding_t); i++) {
302 for (
int i = 0; i < len; i++) {
304 if (cmd == node->cmd)
305 return node->modifier + node->key;
316 char *p, *modstr, *keystr;
318 int st, keymod = 0, keycode = 0;
320 _MSG(
"Keys::parseKey key='%s' commandName='%s'\n", key, commandName);
324 MSG(
"Keys::parseKey: Invalid command name: '%s'\n", commandName);
329 for ( ; isspace(*key); ++key) ;
331 while(*key ==
'<' && (p = strchr(key,
'>'))) {
335 MSG(
"Keys::parseKey unknown modifier: %s\n", modstr);
343 keystr = (*key && (p = strchr(key + 1,
' '))) ?
dStrndup(key, p - key - 1) :
349 const char *beyond = keystr + strlen(keystr);
351 }
else if (key[0] ==
'0' && key[1] ==
'x') {
353 keycode = strtol(key, NULL, 0x10);
355 MSG(
"Keys::parseKey unknown keyname: %s\n", keystr);
365 KeyBinding_t *node =
dNew(KeyBinding_t, 1);
366 node->name =
dStrdup(commandName);
368 node->modifier = keymod;
371 _MSG(
"parseKey: Adding key=%d, mod=%d\n", node->key, node->modifier);
381 char *line, *keycomb, *command;
385 while ((line =
dGetline(fp)) != NULL) {
389 _MSG(
"Keys::parse: keycomb=%s, command=%s\n", keycomb, command);
392 MSG(
"Keys::parse: Syntax error in keysrc line %d: "
393 "keycomb=\"%s\" command=\"%s\"\n", lineno, keycomb, command);
static void parse(FILE *fp)
Parse the keysrc.
static void init()
Initialize the bindings list.
static KeysCommand_t getKeyCmd(void)
Look if the just pressed key is bound to a command.
static KeysCommand_t getCmdCode(const char *symbolName)
Takes a command name and searches it in the mapping table.
static int getShortcut(KeysCommand_t cmd)
Given a keys command, return a shortcut for it, or 0 if there is none (e.g., for KEYS_NEW_WINDOW,...
static void free()
Free data.
static void delKeyCmd(int key, int mod)
Remove a key binding from the table.
static void parseKey(char *key, char *symbol)
Parse a key-combination/command-name pair, and insert it into the bindings list.
static int nodeByKeyCmp(const void *node, const void *key)
Compare function by {key,modifier} pairs.
static int getModifier(char *modifierName)
Takes a modifier name and looks it up in the mapping table.
static int getKeyCode(char *keyName)
Takes a key name and looks it up in the mapping table.
char * dGetline(FILE *stream)
Get a line from a FILE stream.
void dList_insert_sorted(Dlist *lp, void *data, dCompareFunc func)
Insert an element into a sorted list.
int dStrAsciiCasecmp(const char *s1, const char *s2)
char * dStrdup(const char *s)
Dlist * dList_new(int size)
Create a new empty list.
int dList_length(Dlist *lp)
For completing the ADT.
void * dList_nth_data(Dlist *lp, int n0)
Return the nth data item, NULL when not found or 'n0' is out of range.
void dList_remove_fast(Dlist *lp, const void *data)
Remove a data item without preserving order.
char * dStrndup(const char *s, size_t sz)
void * dList_find_sorted(Dlist *lp, const void *data, dCompareFunc func)
Search a sorted list.
void dList_free(Dlist *lp)
Free a list (not its elements)
int dParser_parse_rc_line(char **line, char **name, char **value)
Take a dillo rc line and return 'name' and 'value' pointers to it.
void dList_remove(Dlist *lp, const void *data)
#define dNew(type, count)
static const KeyBinding_t default_keys[]
static const Mapping_t modifierNames[]
static const Mapping_t keyNames[]
uint_t a_Utf8_decode(const char *str, const char *end, int *len)
Decode a single UTF-8-encoded character starting at p.
int a_Utf8_char_count(const char *str, int len)