From: Daniel Carl Date: Mon, 13 Jan 2014 22:13:34 +0000 (+0100) Subject: Allow to toggle between two locations with '' (#57). X-Git-Url: https://git.owens.tech/about.html/about.html/git?a=commitdiff_plain;h=3ecee68a8aab3e5b9753e437827902b7cc76949c;p=vimb.git Allow to toggle between two locations with '' (#57). --- diff --git a/doc/vimb.1 b/doc/vimb.1 index 1c55ee4..86045e1 100644 --- a/doc/vimb.1 +++ b/doc/vimb.1 @@ -3,8 +3,8 @@ .\" groff -man -Tascii vimb.1 .TH vimb 1 "DATE" "vimb/VERSION" "Vimb Manual" .SH NAME -vimb - Vim Browser - A modal web browser based on webkit thats inspired by -vim the great editor. +vimb - Vim Browser - A modal web browser based on webkit, inspired by vim the +great editor. .SH SYNOPSIS .BI "vimb [" "OPTION" "] [" "URI" "]" .SH DESCRIPTION @@ -180,6 +180,10 @@ removed. .TP .BI '\-{ a-z } Jump to the mark {\fIa-z\fP} on current page. +.TP +.B '\-' +Jumps to the position before the latest jump, or where the last "m'" command +was given. .SS Hinting The hinting is the way to do what you would do with the mouse in common mouse-driven browsers. Open URI, yank URI, save page and so on. If the hinting diff --git a/src/main.h b/src/main.h index c95f5dd..ccf09b3 100644 --- a/src/main.h +++ b/src/main.h @@ -104,7 +104,9 @@ #define VB_WIDGET_SET_STATE(w, s) (gtk_widget_set_state(w, s)) #endif -#define VB_MARK_CHARS "abcdefghijklmnopqrstuvwxyz" +/* the special mark ' must be the first in the list for easiest lookup */ +#define VB_MARK_CHARS "'abcdefghijklmnopqrstuvwxyz" +#define VB_MARK_TICK 0 #define VB_MARK_SIZE (sizeof(VB_MARK_CHARS) - 1) /* enums */ diff --git a/src/normal.c b/src/normal.c index 61fc739..acb03a6 100644 --- a/src/normal.c +++ b/src/normal.c @@ -499,8 +499,10 @@ static VbResult normal_input_open(const NormalCmdInfo *info) static VbResult normal_mark(const NormalCmdInfo *info) { + gdouble current; char *mark; int idx; + /* check if the second char is a valid mark char */ if (!(mark = strchr(VB_MARK_CHARS, info->key2))) { return RESULT_ERROR; @@ -516,7 +518,14 @@ static VbResult normal_mark(const NormalCmdInfo *info) if ((int)(vb.state.marks[idx] - .5) < 0) { return RESULT_ERROR; } + + current = gtk_adjustment_get_value(vb.gui.adjust_v); + + /* jump to the location */ gtk_adjustment_set_value(vb.gui.adjust_v, vb.state.marks[idx]); + + /* save previous adjust as last position */ + vb.state.marks[VB_MARK_TICK] = current; } return RESULT_COMPLETE; } @@ -666,6 +675,8 @@ static VbResult normal_scroll(const NormalCmdInfo *info) adjust = vb.gui.adjust_v; max = gtk_adjustment_get_upper(adjust) - gtk_adjustment_get_page_size(adjust); new = info->count ? (max * info->count / 100) : gtk_adjustment_get_upper(adjust); + /* save the position to mark ' */ + vb.state.marks[VB_MARK_TICK] = gtk_adjustment_get_value(adjust); break; case '0': adjust = vb.gui.adjust_h;