From: Jonas Fonseca Date: Sat, 7 Feb 2009 14:20:57 +0000 (+0100) Subject: Jump to line when a number is entered in the prompt X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=06d4108f0806a5ef028b7a88e55efb07baa86f65;p=tig.git Jump to line when a number is entered in the prompt --- diff --git a/NEWS b/NEWS index 39ad784..0e82920 100644 --- 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 38daace..8a55aab 100644 --- 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;