From 06d4108f0806a5ef028b7a88e55efb07baa86f65 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sat, 7 Feb 2009 15:20:57 +0100 Subject: [PATCH] Jump to line when a number is entered in the prompt --- NEWS | 1 + tig.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) 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; -- 2.32.0.93.g670b81a890