mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-15 03:03:45 +01:00
Simple map function without any parsing
This commit is contained in:
parent
ac0461d357
commit
c6a9d72f36
@ -224,7 +224,7 @@ Setting settings[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* shortcut names */
|
/* shortcut names */
|
||||||
ShortcutName shorcut_names[] = {
|
ShortcutName shortcut_names[] = {
|
||||||
{"abort", sc_abort},
|
{"abort", sc_abort},
|
||||||
{"adjust_window", sc_adjust_window},
|
{"adjust_window", sc_adjust_window},
|
||||||
{"change_buffer", sc_change_buffer},
|
{"change_buffer", sc_change_buffer},
|
||||||
|
46
zathura.c
46
zathura.c
@ -2756,7 +2756,53 @@ gboolean
|
|||||||
cmd_map(int argc, char** argv)
|
cmd_map(int argc, char** argv)
|
||||||
{
|
{
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
/* search for the right shortcut function */
|
||||||
|
int sc_id = -1;
|
||||||
|
|
||||||
|
int sc_c;
|
||||||
|
for(sc_c = 0; sc_c < LENGTH(shortcut_names); sc_c++)
|
||||||
|
{
|
||||||
|
if(!strcmp(argv[1], shortcut_names[sc_c].name))
|
||||||
|
{
|
||||||
|
sc_id = sc_c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sc_id == -1)
|
||||||
|
{
|
||||||
|
notify(WARNING, "No such shortcut function exists");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* search for existing binding */
|
||||||
|
ShortcutList* sc = Zathura.Bindings.sclist;
|
||||||
|
while(sc && sc->next != NULL)
|
||||||
|
{
|
||||||
|
sc = sc->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create new entry */
|
||||||
|
ShortcutList* entry = malloc(sizeof(ShortcutList));
|
||||||
|
if(!entry)
|
||||||
|
out_of_memory();
|
||||||
|
|
||||||
|
Argument arg;
|
||||||
|
entry->element.mask = 0;
|
||||||
|
entry->element.key = GDK_y;
|
||||||
|
entry->element.function = shortcut_names[sc_id].function;
|
||||||
|
entry->element.mode = -1;
|
||||||
|
entry->element.argument = arg;
|
||||||
|
entry->next = NULL;
|
||||||
|
|
||||||
|
/* append to list */
|
||||||
|
if(!Zathura.Bindings.sclist)
|
||||||
|
Zathura.Bindings.sclist = entry;
|
||||||
|
|
||||||
|
if(sc)
|
||||||
|
sc->next = entry;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user