45 {
"Backspace", FL_BackSpace },
46 {
"Delete", FL_Delete },
63 {
"Insert", FL_Insert },
66 {
"PageDown", FL_Page_Down },
67 {
"PageUp", FL_Page_Up },
68 {
"Print", FL_Print },
69 {
"Return", FL_Enter },
70 {
"Right", FL_Right },
76 {
"Favorites", FL_Favorites },
77 {
"Forward", FL_Forward },
78 {
"HomePage", FL_Home_Page },
80 {
"MediaNext", FL_Media_Next },
81 {
"MediaPlay", FL_Media_Play },
82 {
"MediaPrev", FL_Media_Prev },
83 {
"MediaStop", FL_Media_Stop },
84 {
"Refresh", FL_Refresh },
85 {
"Search", FL_Search },
86 {
"Sleep", FL_Sleep },
88 {
"VolumeDown", FL_Volume_Down },
89 {
"VolumeMute", FL_Volume_Mute },
90 {
"VolumeUp", FL_Volume_Up },
94 {
"Shift", FL_SHIFT },
98 {
"Button1", FL_BUTTON1 },
99 {
"Button2", FL_BUTTON2 },
100 {
"Button3", FL_BUTTON3 }
123 {
"back" ,
KEYS_BACK , 0 , FL_BackSpace },
174 node =
dNew(KeyBinding_t, 1);
192 dFree((
char*)node->name);
204 KeyBinding_t *n = (KeyBinding_t*)node, *k = (KeyBinding_t*)key;
205 _MSG(
"Keys::nodeByKeyCmp modifier=%d\n", k->modifier);
206 return (n->key != k->key) ? (n->key - k->key) : (n->modifier - k->modifier);
216 KeyBinding_t keyNode;
218 keyNode.modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL |FL_ALT|FL_META);
219 if (iscntrl(Fl::event_text()[0])) {
220 keyNode.key = Fl::event_key();
222 const char *beyond = Fl::event_text() + Fl::event_length();
231 if (keyNode.key != Fl::event_key())
232 keyNode.modifier = 0;
234 _MSG(
"getKeyCmd: evkey=0x%x evtext=\'%s\' key=0x%x, mod=0x%x\n",
235 Fl::event_key(), Fl::event_text(), keyNode.key, keyNode.modifier);
238 ret = ((KeyBinding_t*)data)->cmd;
247 KeyBinding_t keyNode, *node;
249 keyNode.modifier = mod;
254 dFree((
char*)node->name);
278 static char buf[128];
287 sprintf(buf,
"%c", key);
290 sprintf(buf,
"0x%x", key);
304 for (i = 0; i <
sizeof(
default_keys) /
sizeof(KeyBinding_t); i++) {
335 for (
int i = 0; i < len; i++) {
337 if (cmd == node->cmd)
338 return node->modifier + node->key;
349 char *p, *modstr, *keystr;
351 int st, keymod = 0, keycode = 0;
353 _MSG(
"Keys::parseKey key='%s' commandName='%s'\n", key, commandName);
357 MSG(
"Keys::parseKey: Invalid command name: '%s'\n", commandName);
362 for ( ; isspace(*key); ++key) ;
364 while(*key ==
'<' && (p = strchr(key,
'>'))) {
368 MSG(
"Keys::parseKey unknown modifier: %s\n", modstr);
376 keystr = (*key && (p = strchr(key + 1,
' '))) ?
dStrndup(key, p - key - 1) :
382 const char *beyond = keystr + strlen(keystr);
384 }
else if (key[0] ==
'0' && key[1] ==
'x') {
386 keycode = strtol(key, NULL, 0x10);
388 MSG(
"Keys::parseKey unknown keyname: %s\n", keystr);
398 KeyBinding_t *node =
dNew(KeyBinding_t, 1);
399 node->name =
dStrdup(commandName);
401 node->modifier = keymod;
404 _MSG(
"parseKey: Adding key=%d, mod=%d\n", node->key, node->modifier);
414 char *line, *keycomb, *command;
418 while ((line =
dGetline(fp)) != NULL) {
422 _MSG(
"Keys::parse: keycomb=%s, command=%s\n", keycomb, command);
425 MSG(
"Keys::parse: Syntax error in keysrc line %d: "
426 "keycomb=\"%s\" command=\"%s\"\n", lineno, keycomb, command);
444 " <title>Keyboard shortcuts</title>\n"
447 " background: white;\n"
449 " font-size: 16px;\n"
450 " font-family: sans-serif;\n"
451 " line-height: 1.4em;\n"
453 " .main { max-width: 40em; }\n"
454 " p { margin-top: 1em; }\n"
456 " border-collapse: collapse;\n"
459 " padding: 0.25em;\n"
460 " padding: 0.25em;\n"
461 " border-spacing: 0px;\n"
462 " border-top: solid 1px #ccc;\n"
463 " border-bottom: solid 1px #ccc;\n"
466 " min-width: 15em;\n"
469 " min-width: 10em;\n"
472 " background-color: #eee;\n"
475 " display: inline-block;\n"
476 " border: solid 1px #aaa;\n"
477 " padding: 1px 5px;\n"
480 " background: #f5f5f5;\n"
485 "<div class=\"main\">\n"
487 "<h1>Keyboard shortcuts</h1>\n"
489 "<p>The following table contains the current key bindings in Dillo.\n"
490 "To change them, edit the configuration file <code>~/.dillo/keysrc</code> \n"
491 "and restart the browser.</p>\n"
493 "<tr><th>Shortcut<th>Action</tr>\n");
495 for (
int i = 0; i < len; i++) {
508 dStr_sprintfa(table,
"<kbd class=key>%s</kbd></code></td>", key);
509 dStr_sprintfa(table,
"<td class=action><code>%s</code></td>", node->name);
void a_Cache_entry_inject(const DilloUrl *Url, Dstr *data_ds)
Inject full page content directly into the cache.
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 const char * getKeyName(int key)
static void parseKey(char *key, char *symbol)
Parse a key-combination/command-name pair, and insert it into the bindings list.
static void genAboutKeys(void)
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)
void dStr_sprintfa(Dstr *ds, const char *format,...)
Printf-like function that appends.
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.
void dStr_free(Dstr *ds, int all)
Free a dillo string.
char * dStrndup(const char *s, size_t sz)
Dstr * dStr_new(const char *s)
Create a new string.
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[]
void a_Url_free(DilloUrl *url)
Free a DilloUrl.
DilloUrl * a_Url_new(const char *url_str, const char *base_url)
Transform (and resolve) an URL string into the respective DilloURL.
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)