diff options
-rw-r--r-- | doc/nano.texi | 6 | ||||
-rw-r--r-- | doc/nanorc.5 | 6 | ||||
-rw-r--r-- | src/definitions.h | 5 | ||||
-rw-r--r-- | src/search.c | 10 |
4 files changed, 18 insertions, 9 deletions
diff --git a/doc/nano.texi b/doc/nano.texi index 9bfe049e..5fcf977f 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -1696,8 +1696,10 @@ Goes to the first line of the file. Goes to the last line of the file. @item gotoline -Goes to a specific line (and column if specified). Negative numbers count -from the end of the file (and end of the line). +Goes to a specific line (and column if given). +A negative number counts from the end of the buffer (and end of the line). +Putting @code{++} or @code{--} before the first number will jump the given +number of lines forward or backward. @item findbracket Moves the cursor to the bracket (or brace or parenthesis, etc.) that matches diff --git a/doc/nanorc.5 b/doc/nanorc.5 index d73de26f..f608840c 100644 --- a/doc/nanorc.5 +++ b/doc/nanorc.5 @@ -839,8 +839,10 @@ Goes to the first line of the file. Goes to the last line of the file. .TP .B gotoline -Goes to a specific line (and column if specified). Negative numbers count -from the end of the file (and end of the line). +Goes to a specific line (and column if given). +A negative number counts from the end of the buffer (and end of the line). +Putting \fB++\fR or \fB\-\-\fR before the first number will jump the given +number of lines forward or backward. .TP .B findbracket Moves the cursor to the bracket (or brace or parenthesis, etc.\&) that matches diff --git a/src/definitions.h b/src/definitions.h index b461caf9..c73b4a82 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -60,10 +60,7 @@ #include <stdlib.h> #include <sys/stat.h> -/* Prefer wide ncurses over normal ncurses over curses. */ -#if defined(HAVE_NCURSESW_NCURSES_H) -#include <ncursesw/ncurses.h> -#elif defined(HAVE_NCURSES_H) +#ifdef HAVE_NCURSES_H #include <ncurses.h> #else #include <curses.h> diff --git a/src/search.c b/src/search.c index e2e6f685..dd635322 100644 --- a/src/search.c +++ b/src/search.c @@ -774,6 +774,7 @@ void goto_line_and_column(ssize_t line, ssize_t column, bool retain_answer, int response = do_prompt(MGOTOLINE, retain_answer ? answer : "", NULL, /* TRANSLATORS: This is a prompt. */ edit_refresh, _("Enter line number, column number")); + int doublesign = 0; /* If the user cancelled or gave a blank answer, get out. */ if (response < 0) { @@ -792,11 +793,18 @@ void goto_line_and_column(ssize_t line, ssize_t column, bool retain_answer, if (response > 0) return; + /* A ++ or -- before the number signifies a relative jump. */ + if ((answer[0] == '+' && answer[1] == '+') || (answer[0] == '-' && answer[1] == '-')) + doublesign = 1; + /* Try to extract one or two numbers from the user's response. */ - if (!parse_line_column(answer, &line, &column)) { + if (!parse_line_column(answer + doublesign, &line, &column)) { statusline(AHEM, _("Invalid line or column number")); return; } + + if (doublesign) + line += openfile->current->lineno; } else { if (line == 0) line = openfile->current->lineno; |