Code

Jump to line when a number is entered in the prompt
authorJonas Fonseca <fonseca@diku.dk>
Sat, 7 Feb 2009 14:20:57 +0000 (15:20 +0100)
committerJonas Fonseca <fonseca@diku.dk>
Sat, 7 Feb 2009 20:23:55 +0000 (21:23 +0100)
NEWS
tig.c

diff --git a/NEWS b/NEWS
index 39ad78423a13427452a9545b9c2145b2e46804b5..0e829203bad868c0eee0837e35bbd88a50d61e80 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Improvements:
  - Status view: improve "on branch" information inspired by the prompt
    code in git's bash completion script.
  - Colors for 256-capable terminals can be specified as colorN.
+ - Entering a number in the prompt will jump to that line number.
 
 tig-0.14
 --------
diff --git a/tig.c b/tig.c
index 38daacee531fdc4eabd4f1e4a5d59e1291ef35ff..8a55aab9288ab2c3ea861c619649324937f27a9e 100644 (file)
--- a/tig.c
+++ b/tig.c
@@ -6943,7 +6943,17 @@ main(int argc, const char *argv[])
                {
                        char *cmd = read_prompt(":");
 
-                       if (cmd) {
+                       if (cmd && isdigit(*cmd)) {
+                               int lineno = view->lineno + 1;
+
+                               if (parse_int(&lineno, cmd, 1, view->lines + 1) == OK) {
+                                       select_view_line(view, lineno - 1);
+                                       report("");
+                               } else {
+                                       report("Unable to parse '%s' as a line number", cmd);
+                               }
+
+                       } else if (cmd) {
                                struct view *next = VIEW(REQ_VIEW_PAGER);
                                const char *argv[SIZEOF_ARG] = { "git" };
                                int argc = 1;