From 381a386b015ced15e3e91e8a80f05de8129d06e7 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Fri, 21 Jul 2017 23:26:59 -0500 Subject: [PATCH] weeding: drop the forreal parameter from place_the_cursor() Commit 28beb3f added the 'forreal' parameter to prevent spotlight() from placing the cursor wrongly due to an invalid placewewant. However, since the variable-width softwrap overhaul (specifically, since commit 8490f4a), place_the_cursor() no longer checks placewewant, so the parameter is no longer needed. Furthermore, dropping 'forreal' and thus always setting current_y won't affect the operation of spotlight(), since the only functions that use spotlight() (do_replace_loop() and do_int_spell_fix()) both call edit_refresh() beforehand, which means that current_y will already have been set to the value it will be set to again. --- src/nano.c | 2 +- src/proto.h | 2 +- src/text.c | 6 +++--- src/winio.c | 11 +++++------ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/nano.c b/src/nano.c index b82245a5..8bfa6d75 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2626,7 +2626,7 @@ int main(int argc, char **argv) /* Refresh just the cursor position or the entire edit window. */ if (!refresh_needed) { - place_the_cursor(TRUE); + place_the_cursor(); wnoutrefresh(edit); } else edit_refresh(); diff --git a/src/proto.h b/src/proto.h index 34d4343c..c8fbb1ff 100644 --- a/src/proto.h +++ b/src/proto.h @@ -649,7 +649,7 @@ void warn_and_shortly_pause(const char *msg); void statusline(message_type importance, const char *msg, ...); void bottombars(int menu); void onekey(const char *keystroke, const char *desc, int length); -void place_the_cursor(bool forreal); +void place_the_cursor(void); void edit_draw(filestruct *fileptr, const char *converted, int line, size_t from_col); int update_line(filestruct *fileptr, size_t index); diff --git a/src/text.c b/src/text.c index fda74581..eac86524 100644 --- a/src/text.c +++ b/src/text.c @@ -2443,7 +2443,7 @@ void do_justify(bool full_justify) do { #endif statusbar(_("Can now UnJustify!")); - place_the_cursor(TRUE); + place_the_cursor(); curs_set(1); kbinput = do_input(FALSE); #ifndef NANO_TINY @@ -3313,7 +3313,7 @@ void do_linter(void) } /* Place and show the cursor to indicate the affected line. */ - place_the_cursor(TRUE); + place_the_cursor(); wnoutrefresh(edit); curs_set(1); @@ -3561,7 +3561,7 @@ void do_verbatim_input(void) /* TRANSLATORS: This is displayed when the next keystroke will be * inserted verbatim. */ statusbar(_("Verbatim Input")); - place_the_cursor(TRUE); + place_the_cursor(); curs_set(1); /* Read in all the verbatim characters. */ diff --git a/src/winio.c b/src/winio.c index dce6b252..6b727dc7 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1252,7 +1252,7 @@ int parse_escape_sequence(WINDOW *win, int kbinput) suppress_cursorpos = FALSE; lastmessage = HUSH; if (currmenu == MMAIN) { - place_the_cursor(TRUE); + place_the_cursor(); curs_set(1); } } @@ -2275,7 +2275,7 @@ void onekey(const char *keystroke, const char *desc, int length) /* Redetermine current_y from the position of current relative to edittop, * and put the cursor in the edit window at (current_y, "current_x"). */ -void place_the_cursor(bool forreal) +void place_the_cursor(void) { ssize_t row = 0; size_t col, xpt = xplustabs(); @@ -2306,8 +2306,7 @@ void place_the_cursor(bool forreal) if (row < editwinrows) wmove(edit, row, margin + col); - if (forreal) - openfile->current_y = row; + openfile->current_y = row; } /* edit_draw() takes care of the job of actually painting a line into @@ -3241,7 +3240,7 @@ void edit_refresh(void) while (row < editwinrows) blank_row(edit, row++, 0, COLS); - place_the_cursor(TRUE); + place_the_cursor(); wnoutrefresh(edit); refresh_needed = FALSE; @@ -3394,7 +3393,7 @@ void spotlight(bool active, size_t from_col, size_t to_col) char *word; size_t word_span, room; - place_the_cursor(FALSE); + place_the_cursor(); #ifndef NANO_TINY if (ISSET(SOFTWRAP)) {