Commit 0cf5be08 authored by Faye's avatar Faye

Add a snap_to_page command

parent 13119854
......@@ -289,6 +289,10 @@ They can also be combined with modifiers:
Set an option.
* ``snap_to_page``
Snaps to the current page. Equivalent to ``goto <current_page>``
* ``toggle_fullscreen``
Toggle fullscreen.
......
......@@ -358,6 +358,8 @@ config_load_default(zathura_t* zathura)
\
girara_shortcut_add(gsession, 0, GDK_KEY_n, NULL, sc_search, (mode), FORWARD, NULL); \
girara_shortcut_add(gsession, 0, GDK_KEY_N, NULL, sc_search, (mode), BACKWARD, NULL); \
\
girara_shortcut_add(gsession, 0, GDK_KEY_P, NULL, sc_snap_to_page, (mode), 0, NULL); \
\
girara_shortcut_add(gsession, 0, GDK_KEY_Tab, NULL, sc_toggle_index, (mode), 0, NULL); \
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_n, NULL, girara_sc_toggle_statusbar, (mode), 0, NULL); \
......@@ -527,6 +529,7 @@ config_load_default(zathura_t* zathura)
girara_shortcut_mapping_add(gsession, "rotate", sc_rotate);
girara_shortcut_mapping_add(gsession, "scroll", sc_scroll);
girara_shortcut_mapping_add(gsession, "search", sc_search);
girara_shortcut_mapping_add(gsession, "snap_to_page", sc_snap_to_page);
girara_shortcut_mapping_add(gsession, "toggle_fullscreen", sc_toggle_fullscreen);
girara_shortcut_mapping_add(gsession, "toggle_index", sc_toggle_index);
girara_shortcut_mapping_add(gsession, "toggle_page_mode", sc_toggle_page_mode);
......
......@@ -1469,3 +1469,16 @@ sc_nohlsearch(girara_session_t* session, girara_argument_t* UNUSED(argument), gi
return false;
}
bool sc_snap_to_page(girara_session_t *session,
girara_argument_t *UNUSED(argument),
girara_event_t *UNUSED(event), unsigned int UNUSED(t)) {
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t *zathura = session->global.data;
g_return_val_if_fail(zathura->document != NULL, false);
zathura_document_t *document = zathura->document;
int page = zathura_document_get_current_page_number(document);
return page_set(zathura, page);
}
......@@ -303,5 +303,15 @@ bool sc_exec(girara_session_t* session, girara_argument_t* argument, girara_even
*/
bool sc_nohlsearch(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
/**
* Snaps the current view to the current page
*
* @param session The used girara session
* @param argument The used argument
* @param event Girara event
* @param t Number of executions
* @return true if no error occurred otherwise false
*/
bool sc_snap_to_page(girara_session_t *session, girara_argument_t *argument, girara_event_t *event, unsigned int t);
#endif // SHORTCUTS_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment