Commit e8bc7b1e authored by Sebastian Neuser's avatar Sebastian Neuser

Implement shortcuts for scrolling to page top/bottom

parent 1d398dfa
......@@ -281,6 +281,8 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add(gsession, 0, GDK_KEY_Up, NULL, sc_scroll, NORMAL, UP, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Down, NULL, sc_scroll, NORMAL, DOWN, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Right, NULL, sc_scroll, NORMAL, RIGHT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_H, NULL, sc_scroll, NORMAL, PAGE_TOP, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_L, NULL, sc_scroll, NORMAL, PAGE_BOTTOM, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_t, NULL, sc_scroll, NORMAL, HALF_LEFT, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_d, NULL, sc_scroll, NORMAL, HALF_DOWN, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_u, NULL, sc_scroll, NORMAL, HALF_UP, NULL);
......@@ -436,6 +438,8 @@ config_load_default(zathura_t* zathura)
girara_argument_mapping_add(gsession, "left", LEFT);
girara_argument_mapping_add(gsession, "next", NEXT);
girara_argument_mapping_add(gsession, "out", ZOOM_OUT);
girara_argument_mapping_add(gsession, "page-top", PAGE_TOP);
girara_argument_mapping_add(gsession, "page-bottom", PAGE_BOTTOM);
girara_argument_mapping_add(gsession, "previous", PREVIOUS);
girara_argument_mapping_add(gsession, "right", RIGHT);
girara_argument_mapping_add(gsession, "specific", ZOOM_SPECIFIC);
......
......@@ -500,6 +500,22 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument,
return false;
}
/* Retrieve current page and position */
const unsigned int page_id = zathura_document_get_current_page_number(zathura->document);
double pos_x = zathura_document_get_position_x(zathura->document);
double pos_y = zathura_document_get_position_y(zathura->document);
/* If PAGE_TOP or PAGE_BOTTOM, go there and we are done */
if (argument->n == PAGE_TOP) {
page_number_to_position(zathura->document, page_id, 0.5, 0.0, &pos_x, &pos_y);
position_set(zathura, -1, pos_y);
return false;
} else if (argument->n == PAGE_BOTTOM) {
page_number_to_position(zathura->document, page_id, 0.5, 1.0, &pos_x, &pos_y);
position_set(zathura, -1, pos_y);
return false;
}
if (t == 0) {
t = 1;
}
......@@ -527,11 +543,6 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument,
bool scroll_wrap = false;
girara_setting_get(session, "scroll-wrap", &scroll_wrap);
double pos_x = zathura_document_get_position_x(zathura->document);
double pos_y = zathura_document_get_position_y(zathura->document);
const unsigned int page_id = zathura_document_get_current_page_number(zathura->document);
/* compute the direction of scrolling */
double direction = 1.0;
if ((argument->n == LEFT) || (argument->n == FULL_LEFT) || (argument->n == HALF_LEFT) ||
......
......@@ -16,7 +16,8 @@ enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT,
BACKWARD, CONTINUOUS, DELETE_LAST, EXPAND, EXPAND_ALL, COLLAPSE_ALL, COLLAPSE,
SELECT, GOTO_DEFAULT, GOTO_LABELS, GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP,
FULL_DOWN, HALF_LEFT, HALF_RIGHT, FULL_LEFT, FULL_RIGHT, NEXT_CHAR,
PREVIOUS_CHAR, DELETE_TO_LINE_START, APPEND_FILEPATH, ROTATE_CW, ROTATE_CCW };
PREVIOUS_CHAR, DELETE_TO_LINE_START, APPEND_FILEPATH, ROTATE_CW, ROTATE_CCW,
PAGE_BOTTOM, PAGE_TOP };
/* unspecified page number */
enum {
......
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