Commit 5b7fc5de authored by Marwan Tanager's avatar Marwan Tanager Committed by Sebastian Ramacher

Make jumping with ^o and ^i more compatible with Vim

    - Allow the user to always start with the very last (or first) jump on the
      jumplist when pressing ^o (or ^i), while the jumplist iterator is
      pointing to the last (or first) jump, and the document is not currently
      at the position of this pointed-to jump. This is instead of jumping
      directly to the previous/next jump, and skipping the last/first one.

    - Don't jump to the current jump pointed to by the jumplist iterator, if
      there is no more next jumps, and the jump direction is FORWARD.

    - Don't jump to the current jump pointed to by the jumplist iterator, if
      there is no more previous jumps, and the jump direction is BACKWARD.
Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent 14b8399a
......@@ -722,24 +722,51 @@ sc_jumplist(girara_session_t* session, girara_argument_t* argument,
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(zathura->document != NULL, false);
const double scale = zathura_document_get_scale(zathura->document);
double x = gtk_adjustment_get_value(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view))) / scale;
double y = gtk_adjustment_get_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view))) / scale;
zathura_jump_t* jump = NULL;
zathura_jump_t* prev_jump = zathura_jumplist_current(zathura);
bool go_to_current = false;
if (!zathura_jumplist_has_next(zathura) || !zathura_jumplist_has_previous(zathura)) {
if (x == prev_jump->x && y == prev_jump->y) {
go_to_current = false;
} else {
go_to_current = true;
}
}
switch(argument->n) {
case FORWARD:
zathura_jumplist_forward(zathura);
jump = zathura_jumplist_current(zathura);
if (go_to_current == true && zathura_jumplist_has_previous(zathura) == false) {
jump = zathura_jumplist_current(zathura);
} else {
zathura_jumplist_forward(zathura);
jump = zathura_jumplist_current(zathura);
}
break;
case BACKWARD:
zathura_jumplist_backward(zathura);
jump = zathura_jumplist_current(zathura);
if (go_to_current == true && zathura_jumplist_has_next(zathura) == false) {
jump = zathura_jumplist_current(zathura);
} else {
zathura_jumplist_backward(zathura);
jump = zathura_jumplist_current(zathura);
}
break;
}
if (jump == prev_jump) {
if (zathura_jumplist_has_previous(zathura) == false && argument->n == BACKWARD ||
zathura_jumplist_has_next(zathura) == false && argument->n == FORWARD) {
jump = NULL;
}
}
if (jump != NULL) {
zathura_document_set_current_page_number(zathura->document, jump->page);
statusbar_page_number_update(zathura);
const double s = zathura_document_get_scale(zathura->document);
position_set_delayed(zathura, jump->x * s, jump->y * s);
position_set_delayed(zathura, jump->x * scale, jump->y * scale);
}
return false;
......
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