Add default shortcuts

This commit is contained in:
Moritz Lipp 2010-11-13 10:05:28 +01:00
parent 98d42ed3ce
commit 9348a128ff
4 changed files with 146 additions and 60 deletions

View file

@ -9,5 +9,67 @@ config_load_default()
if(!Zathura.UI.session) if(!Zathura.UI.session)
return; return;
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_q, NULL, sc_quit, 0, 0, NULL); /* define default shortcuts */
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, ALL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_Escape, NULL, sc_abort, ALL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_a, NULL, sc_adjust_window, NORMAL, ADJUST_BESTFIT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_s, NULL, sc_adjust_window, NORMAL, ADJUST_WIDTH, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_BackSpace, NULL, sc_change_buffer, ALL, DELETE_LAST, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_i, NULL, sc_change_mode, NORMAL, INSERT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_m, NULL, sc_change_mode, NORMAL, ADD_MARKER, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_apostrophe, NULL, sc_change_mode, NORMAL, EVAL_MARKER, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_slash, NULL, sc_focus_inputbar, NORMAL, 0, &("/"));
girara_shortcut_add(Zathura.UI.session, GDK_SHIFT_MASK, GDK_slash, NULL, sc_focus_inputbar, NORMAL, 0, &("/"));
girara_shortcut_add(Zathura.UI.session, 0, GDK_question, NULL, sc_focus_inputbar, NORMAL, 0, &("?"));
girara_shortcut_add(Zathura.UI.session, 0, GDK_colon, NULL, sc_focus_inputbar, NORMAL, 0, &(":"));
girara_shortcut_add(Zathura.UI.session, 0, GDK_o, NULL, sc_focus_inputbar, NORMAL, 0, &(":open "));
girara_shortcut_add(Zathura.UI.session, 0, GDK_O, NULL, sc_focus_inputbar, NORMAL, APPEND_FILEPATH, &(":open "));
girara_shortcut_add(Zathura.UI.session, 0, GDK_f, NULL, sc_follow, NORMAL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, 0, "gg", sc_goto, NORMAL | FULLSCREEN, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, 0, "G", sc_goto, NORMAL | FULLSCREEN, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_J, NULL, sc_navigate, NORMAL, NEXT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_K, NULL, sc_navigate, NORMAL, PREVIOUS, NULL);
girara_shortcut_add(Zathura.UI.session, GDK_MOD1_MASK, GDK_Right, NULL, sc_navigate, NORMAL, NEXT, NULL);
girara_shortcut_add(Zathura.UI.session, GDK_MOD1_MASK, GDK_Left, NULL, sc_navigate, NORMAL, PREVIOUS, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_Left, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_Up, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_Down, NULL, sc_navigate, FULLSCREEN, NEXT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_Right, NULL, sc_navigate, FULLSCREEN, NEXT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_k, NULL, sc_navigate_index, INDEX, UP, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_j, NULL, sc_navigate_index, INDEX, DOWN, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_h, NULL, sc_navigate_index, INDEX, COLLAPSE, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_l, NULL, sc_navigate_index, INDEX, EXPAND, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_space, NULL, sc_navigate_index, INDEX, SELECT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_Return, NULL, sc_navigate_index, INDEX, SELECT, NULL);
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_i, NULL, sc_recolor, NORMAL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_R, NULL, sc_reload, NORMAL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_r, NULL, sc_rotate, NORMAL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_h, NULL, sc_scroll, NORMAL, LEFT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_j, NULL, sc_scroll, NORMAL, DOWN, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_k, NULL, sc_scroll, NORMAL, UP, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_l, NULL, sc_scroll, NORMAL, RIGHT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_Left, NULL, sc_scroll, NORMAL, LEFT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_Up, NULL, sc_scroll, NORMAL, DOWN, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_Down, NULL, sc_scroll, NORMAL, RIGHT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_Right, NULL, sc_scroll, NORMAL, UP, NULL);
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_d, NULL, sc_scroll, NORMAL, HALF_DOWN, NULL);
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_u, NULL, sc_scroll, NORMAL, HALF_UP, NULL);
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_f, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL);
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_b, NULL, sc_scroll, NORMAL, FULL_UP, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_space, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL);
girara_shortcut_add(Zathura.UI.session, 0, 0, "%", sc_scroll, NORMAL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_n, NULL, sc_search, NORMAL, FORWARD, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_N, NULL, sc_search, NORMAL, BACKWARD, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_0, NULL, sc_switch_goto_mode, NORMAL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_Tab, NULL, sc_toggle_index, NORMAL | INDEX, 0, NULL);
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_m, NULL, sc_toggle_inputbar, NORMAL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_F5, NULL, sc_toggle_fullscreen, NORMAL | FULLSCREEN, 0, NULL);
girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_n, NULL, sc_toggle_statusbar, NORMAL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_q, NULL, sc_quit, NORMAL, 0, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_plus, NULL, sc_zoom, NORMAL | FULLSCREEN, ZOOM_IN, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_minus, NULL, sc_zoom, NORMAL | FULLSCREEN, ZOOM_OUT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, GDK_equal, NULL, sc_zoom, NORMAL | FULLSCREEN, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(Zathura.UI.session, 0, 0, "zI", sc_zoom, NORMAL | FULLSCREEN, ZOOM_IN, NULL);
girara_shortcut_add(Zathura.UI.session, 0, 0, "zO", sc_zoom, NORMAL | FULLSCREEN, ZOOM_OUT, NULL);
girara_shortcut_add(Zathura.UI.session, 0, 0, "z0", sc_zoom, NORMAL | FULLSCREEN, ZOOM_ORIGINAL, NULL);
} }

View file

@ -6,115 +6,121 @@
#include "callbacks.h" #include "callbacks.h"
#include "shortcuts.h" #include "shortcuts.h"
void bool
sc_abort(girara_session_t* session, girara_argument_t* argument) sc_abort(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_adjust_window(girara_session_t* session, girara_argument_t* argument) sc_adjust_window(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_change_buffer(girara_session_t* session, girara_argument_t* argument) sc_change_buffer(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_change_mode(girara_session_t* session, girara_argument_t* argument) sc_change_mode(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument) sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_follow(girara_session_t* session, girara_argument_t* argument) sc_follow(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_goto(girara_session_t* session, girara_argument_t* argument)
{
return false;
}
bool
sc_navigate(girara_session_t* session, girara_argument_t* argument) sc_navigate(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_recolor(girara_session_t* session, girara_argument_t* argument) sc_recolor(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_reload(girara_session_t* session, girara_argument_t* argument) sc_reload(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_rotate(girara_session_t* session, girara_argument_t* argument) sc_rotate(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_scroll(girara_session_t* session, girara_argument_t* argument) sc_scroll(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_search(girara_session_t* session, girara_argument_t* argument) sc_search(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_switch_goto_mode(girara_session_t* session, girara_argument_t* argument) sc_switch_goto_mode(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_navigate_index(girara_session_t* session, girara_argument_t* argument) sc_navigate_index(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_toggle_index(girara_session_t* session, girara_argument_t* argument) sc_toggle_index(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_toggle_inputbar(girara_session_t* session, girara_argument_t* argument) sc_toggle_inputbar(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* argument) sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_toggle_statusbar(girara_session_t* session, girara_argument_t* argument) sc_toggle_statusbar(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }
void bool
sc_quit(girara_session_t* session, girara_argument_t* argument) sc_quit(girara_session_t* session, girara_argument_t* argument)
{ {
girara_argument_t arg = { GIRARA_HIDE, NULL }; girara_argument_t arg = { GIRARA_HIDE, NULL };
@ -123,10 +129,12 @@ sc_quit(girara_session_t* session, girara_argument_t* argument)
cb_destroy(NULL, NULL); cb_destroy(NULL, NULL);
gtk_main_quit(); gtk_main_quit();
return false;
} }
void bool
sc_zoom(girara_session_t* session, girara_argument_t* argument) sc_zoom(girara_session_t* session, girara_argument_t* argument)
{ {
return false;
} }

View file

@ -5,25 +5,26 @@
#include <girara.h> #include <girara.h>
void sc_abort(girara_session_t* session, girara_argument_t* argument); bool sc_abort(girara_session_t* session, girara_argument_t* argument);
void sc_adjust_window(girara_session_t* session, girara_argument_t* argument); bool sc_adjust_window(girara_session_t* session, girara_argument_t* argument);
void sc_change_buffer(girara_session_t* session, girara_argument_t* argument); bool sc_change_buffer(girara_session_t* session, girara_argument_t* argument);
void sc_change_mode(girara_session_t* session, girara_argument_t* argument); bool sc_change_mode(girara_session_t* session, girara_argument_t* argument);
void sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument); bool sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument);
void sc_follow(girara_session_t* session, girara_argument_t* argument); bool sc_follow(girara_session_t* session, girara_argument_t* argument);
void sc_navigate(girara_session_t* session, girara_argument_t* argument); bool sc_goto(girara_session_t* session, girara_argument_t* argument);
void sc_recolor(girara_session_t* session, girara_argument_t* argument); bool sc_navigate(girara_session_t* session, girara_argument_t* argument);
void sc_reload(girara_session_t* session, girara_argument_t* argument); bool sc_recolor(girara_session_t* session, girara_argument_t* argument);
void sc_rotate(girara_session_t* session, girara_argument_t* argument); bool sc_reload(girara_session_t* session, girara_argument_t* argument);
void sc_scroll(girara_session_t* session, girara_argument_t* argument); bool sc_rotate(girara_session_t* session, girara_argument_t* argument);
void sc_search(girara_session_t* session, girara_argument_t* argument); bool sc_scroll(girara_session_t* session, girara_argument_t* argument);
void sc_switch_goto_mode(girara_session_t* session, girara_argument_t* argument); bool sc_search(girara_session_t* session, girara_argument_t* argument);
void sc_navigate_index(girara_session_t* session, girara_argument_t* argument); bool sc_switch_goto_mode(girara_session_t* session, girara_argument_t* argument);
void sc_toggle_index(girara_session_t* session, girara_argument_t* argument); bool sc_navigate_index(girara_session_t* session, girara_argument_t* argument);
void sc_toggle_inputbar(girara_session_t* session, girara_argument_t* argument); bool sc_toggle_index(girara_session_t* session, girara_argument_t* argument);
void sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* argument); bool sc_toggle_inputbar(girara_session_t* session, girara_argument_t* argument);
void sc_toggle_statusbar(girara_session_t* session, girara_argument_t* argument); bool sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* argument);
void sc_quit(girara_session_t* session, girara_argument_t* argument); bool sc_toggle_statusbar(girara_session_t* session, girara_argument_t* argument);
void sc_zoom(girara_session_t* session, girara_argument_t* argument); bool sc_quit(girara_session_t* session, girara_argument_t* argument);
bool sc_zoom(girara_session_t* session, girara_argument_t* argument);
#endif // SHORTCUTS_H #endif // SHORTCUTS_H

View file

@ -6,6 +6,21 @@
#include <stdbool.h> #include <stdbool.h>
#include <girara.h> #include <girara.h>
enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT,
DELETE_LAST_WORD, DELETE_LAST_CHAR, DEFAULT, ERROR, WARNING, NEXT_GROUP,
PREVIOUS_GROUP, ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, ZOOM_SPECIFIC, FORWARD,
BACKWARD, ADJUST_BESTFIT, ADJUST_WIDTH, ADJUST_NONE, CONTINUOUS, DELETE_LAST,
ADD_MARKER, EVAL_MARKER, EXPAND, COLLAPSE, SELECT, GOTO_DEFAULT, GOTO_LABELS,
GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP, FULL_DOWN, NEXT_CHAR, PREVIOUS_CHAR,
DELETE_TO_LINE_START, APPEND_FILEPATH };
/* define modes */
#define ALL (1 << 0)
#define FULLSCREEN (1 << 1)
#define INDEX (1 << 2)
#define NORMAL (1 << 3)
#define INSERT (1 << 4)
struct struct
{ {
struct struct