Allow to toggle between two locations with '' (#57).
authorDaniel Carl <danielcarl@gmx.de>
Mon, 13 Jan 2014 22:13:34 +0000 (23:13 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 13 Jan 2014 22:13:34 +0000 (23:13 +0100)
doc/vimb.1
src/main.h
src/normal.c

index 1c55ee4..86045e1 100644 (file)
@@ -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
index c95f5dd..ccf09b3 100644 (file)
 #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 */
index 61fc739..acb03a6 100644 (file)
@@ -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;