commit 653432b6a8aa3472670924354c5e4c4bb6b0a65c
parent 4d4c231dad2bf455aefeb5e20a251bc34326e8d2
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 4 Jul 2025 17:29:18 +0200
tweaks: reshuffle some lines, to group things better
Diffstat:
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/prototypes.h b/src/prototypes.h
@@ -484,9 +484,9 @@ void ask_for_and_do_replacements(void);
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined (ENABLE_LINTER) || defined (ENABLE_FORMATTER)
void goto_line_posx(ssize_t line, size_t pos_x);
#endif
+void do_gotolinecolumn(void);
void ask_for_line_and_column(char *provided);
void goto_line_and_column(ssize_t line, ssize_t column, bool hugfloor);
-void do_gotolinecolumn(void);
#ifndef NANO_TINY
void do_find_bracket(void);
void put_or_lift_anchor(void);
diff --git a/src/search.c b/src/search.c
@@ -762,6 +762,12 @@ void goto_line_posx(ssize_t linenumber, size_t pos_x)
}
#endif
+/* Implement the Go To Line menu. */
+void do_gotolinecolumn(void)
+{
+ ask_for_line_and_column("");
+}
+
/* Ask for a line and maybe column number, and then jump there. */
void ask_for_line_and_column(char *provided)
{
@@ -811,14 +817,13 @@ void ask_for_line_and_column(char *provided)
/* Go to the specified line and column. (Note that both are one-based.) */
void goto_line_and_column(ssize_t line, ssize_t column, bool hugfloor)
{
- if (line == 0)
- line = openfile->current->lineno;
- if (column == 0)
- column = openfile->placewewant + 1;
+ int rows_from_tail;
/* Take a negative line number to mean: from the end of the file. */
if (line < 0)
line = openfile->filebot->lineno + line + 1;
+ else if (line == 0)
+ line = openfile->current->lineno;
if (line < 1)
line = 1;
@@ -836,6 +841,8 @@ void goto_line_and_column(ssize_t line, ssize_t column, bool hugfloor)
/* Take a negative column number to mean: from the end of the line. */
if (column < 0)
column = breadth(openfile->current->data) + column + 2;
+ else if (column == 0)
+ column = openfile->placewewant + 1;
if (column < 1)
column = 1;
@@ -852,8 +859,6 @@ void goto_line_and_column(ssize_t line, ssize_t column, bool hugfloor)
if (!hugfloor)
return;
- int rows_from_tail;
-
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
linestruct *currentline = openfile->current;
@@ -876,12 +881,6 @@ void goto_line_and_column(ssize_t line, ssize_t column, bool hugfloor)
adjust_viewport(CENTERING);
}
-/* Go to the specified line and column, asking for them beforehand. */
-void do_gotolinecolumn(void)
-{
- ask_for_line_and_column("");
-}
-
#ifndef NANO_TINY
/* Search, starting from the current position, for any of the two characters
* in bracket_pair. If reverse is TRUE, search backwards, otherwise forwards.