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 },
172 node =
dNew(KeyBinding_t, 1);
190 dFree((
char*)node->name);
202 KeyBinding_t *n = (KeyBinding_t*)node, *k = (KeyBinding_t*)key;
203 _MSG(
"Keys::nodeByKeyCmp modifier=%d\n", k->modifier);
204 return (n->key != k->key) ? (n->key - k->key) : (n->modifier - k->modifier);
214 KeyBinding_t keyNode;
216 keyNode.modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL |FL_ALT|FL_META);
217 if (
dIscntrl(Fl::event_text()[0])) {
218 keyNode.key = Fl::event_key();
220 const char *beyond = Fl::event_text() + Fl::event_length();
229 if (keyNode.key != Fl::event_key())
230 keyNode.modifier = 0;
232 _MSG(
"getKeyCmd: evkey=0x%x evtext=\'%s\' key=0x%x, mod=0x%x\n",
233 Fl::event_key(), Fl::event_text(), keyNode.key, keyNode.modifier);
236 ret = ((KeyBinding_t*)data)->cmd;
245 KeyBinding_t keyNode, *node;
247 keyNode.modifier = mod;
252 dFree((
char*)node->name);
276 static char buf[128];
285 sprintf(buf,
"%c", key);
288 sprintf(buf,
"0x%x", key);
302 for (i = 0; i <
sizeof(
default_keys) /
sizeof(KeyBinding_t); i++) {
333 for (
int i = 0; i < len; i++) {
335 if (cmd == node->cmd)
336 return node->modifier + node->key;
347 char *p, *modstr, *keystr;
349 int st, keymod = 0, keycode = 0;
351 _MSG(
"Keys::parseKey key='%s' commandName='%s'\n", key, commandName);
355 MSG(
"Keys::parseKey: Invalid command name: '%s'\n", commandName);
362 while(*key ==
'<' && (p = strchr(key,
'>'))) {
366 MSG(
"Keys::parseKey unknown modifier: %s\n", modstr);
374 keystr = (*key && (p = strchr(key + 1,
' '))) ?
dStrndup(key, p - key - 1) :
380 const char *beyond = keystr + strlen(keystr);
382 }
else if (key[0] ==
'0' && key[1] ==
'x') {
384 keycode = strtol(key, NULL, 0x10);
386 MSG(
"Keys::parseKey unknown keyname: %s\n", keystr);
396 KeyBinding_t *node =
dNew(KeyBinding_t, 1);
397 node->name =
dStrdup(commandName);
399 node->modifier = keymod;
402 _MSG(
"parseKey: Adding key=%d, mod=%d\n", node->key, node->modifier);
412 char *line, *keycomb, *command;
416 while ((line =
dGetline(fp)) != NULL) {
420 _MSG(
"Keys::parse: keycomb=%s, command=%s\n", keycomb, command);
423 MSG(
"Keys::parse: Syntax error in keysrc line %d: "
424 "keycomb=\"%s\" command=\"%s\"\n", lineno, keycomb, command);
442 " <title>Keyboard shortcuts</title>\n"
445 " background: white;\n"
447 " font-size: 16px;\n"
448 " font-family: sans-serif;\n"
449 " line-height: 1.4em;\n"
451 " .main { max-width: 40em; }\n"
452 " p { margin-top: 1em; }\n"
454 " border-collapse: collapse;\n"
457 " padding: 0.25em;\n"
458 " padding: 0.25em;\n"
459 " border-spacing: 0px;\n"
460 " border-top: solid 1px #ccc;\n"
461 " border-bottom: solid 1px #ccc;\n"
464 " min-width: 15em;\n"
467 " min-width: 10em;\n"
470 " background-color: #eee;\n"
473 " display: inline-block;\n"
474 " border: solid 1px #aaa;\n"
475 " padding: 1px 5px;\n"
478 " background: #f5f5f5;\n"
483 "<div class=\"main\">\n"
485 "<h1>Keyboard shortcuts</h1>\n"
487 "<p>The following table contains the current key bindings in Dillo.\n"
488 "To change them, edit the configuration file <code>~/.dillo/keysrc</code> \n"
489 "and restart the browser.</p>\n"
491 "<tr><th>Shortcut<th>Action</tr>\n");
493 for (
int i = 0; i < len; i++) {
506 dStr_sprintfa(table,
"<kbd class=key>%s</kbd></code></td>", key);
507 dStr_sprintfa(table,
"<td class=action><code>%s</code></td>", node->name);
void a_Cache_entry_inject(const DilloUrl *Url, const char *buf, size_t len, int flags)
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)
static int dIsspace(unsigned char c)
static int dIsascii(unsigned char c)
static int dIscntrl(unsigned char c)
#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)