From b1c20629f532a07941e0a836e5f2154f305b8ff2 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Thu, 22 Dec 2016 13:01:27 -0600 Subject: [PATCH] weeding: remove unnecessary settings of openfile->current_y Many of the adjustments of the value of openfile->current_y appear to be a holdover from the days when certain functions had to account for what is now called STATIONARY scrolling mode, which depends on the value of current_y. Remove these adjustement where they are superfluous. do_para_begin(), do_para_end(), and do_bracket_match() update the screen through edit_redraw(), which uses either CENTERING or FLOWING scrolling mode, so their setting of current_y is redundant and useless, as it will be ignored and then overridden by the next call to reset_cursor(). findnextstr() is called by go_looking() [which calls edit_redraw(), see above], and by do_replace_loop() and do_int_spell_fix(), which both call edit_refresh(), which in this case only uses CENTERING scrolling mode since focusing is TRUE. (Additionally, the adjustments of current_y in findnextstr() and do_bracket_match() use incorrect values when in softwrap mode.) find_paragraph() doesn't need to save or restore current_y, because it doesn't do any screen updates. do_justify() calls edit_refresh() with focusing set to TRUE, so it uses the CENTERING scrolling mode. do_alt_speller() and do_formatter() do not need to save and restore current_y, because they don't modify it in any way. This addresses https://savannah.gnu.org/patch/?9197. --- src/move.c | 6 ++---- src/search.c | 2 -- src/text.c | 16 ++-------------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/move.c b/src/move.c index bbdcce5a..e3265280 100644 --- a/src/move.c +++ b/src/move.c @@ -138,10 +138,9 @@ void do_para_begin(bool allow_update) filestruct *was_current = openfile->current; if (openfile->current != openfile->fileage) { - do { + do openfile->current = openfile->current->prev; - openfile->current_y--; - } while (!begpar(openfile->current)); + while (!begpar(openfile->current)); } openfile->current_x = 0; @@ -175,7 +174,6 @@ void do_para_end(bool allow_update) inpar(openfile->current->next) && !begpar(openfile->current->next)) { openfile->current = openfile->current->next; - openfile->current_y++; } if (openfile->current != openfile->filebot) { diff --git a/src/search.c b/src/search.c index 7343aebc..37dc0e2f 100644 --- a/src/search.c +++ b/src/search.c @@ -378,7 +378,6 @@ int findnextstr(const char *needle, bool whole_word_only, size_t *match_len, /* Set the current position to point at what we found. */ openfile->current = fileptr; openfile->current_x = found_x; - openfile->current_y = fileptr->lineno - openfile->edittop->lineno; /* When requested, pass back the length of the match. */ if (match_len != NULL) @@ -999,7 +998,6 @@ bool find_bracket_match(bool reverse, const char *bracket_set) /* Set the current position to the found matching bracket. */ openfile->current = fileptr; openfile->current_x = found - fileptr->data; - openfile->current_y = fileptr->lineno - openfile->edittop->lineno; return TRUE; } diff --git a/src/text.c b/src/text.c index 92d45729..5a3c1aee 100644 --- a/src/text.c +++ b/src/text.c @@ -2117,9 +2117,6 @@ bool find_paragraph(size_t *const quote, size_t *const par) /* Number of lines in the paragraph we search for. */ filestruct *current_save; /* The line at the beginning of the paragraph we search for. */ - ssize_t current_y_save; - /* The y-coordinate at the beginning of the paragraph we search - * for. */ #ifdef HAVE_REGEX_H if (quoterc != 0) { @@ -2168,7 +2165,6 @@ bool find_paragraph(size_t *const quote, size_t *const par) * of lines in this paragraph. */ quote_len = quote_length(openfile->current->data); current_save = openfile->current; - current_y_save = openfile->current_y; do_para_end(FALSE); par_len = openfile->current->lineno - current_save->lineno; @@ -2179,7 +2175,6 @@ bool find_paragraph(size_t *const quote, size_t *const par) if (openfile->current_x > 0) par_len++; openfile->current = current_save; - openfile->current_y = current_y_save; /* Save the values of quote_len and par_len. */ assert(quote != NULL && par != NULL); @@ -2451,7 +2446,6 @@ void do_justify(bool full_justify) /* Go to the next line. */ par_len--; - openfile->current_y++; openfile->current = openfile->current->next; } @@ -2462,7 +2456,6 @@ void do_justify(bool full_justify) /* Go to the next line, if possible. If there is no next line, * move to the end of the current line. */ if (openfile->current != openfile->filebot) { - openfile->current_y++; openfile->current = openfile->current->next; } else openfile->current_x = strlen(openfile->current->data); @@ -2480,9 +2473,8 @@ void do_justify(bool full_justify) } /* We are now done justifying the paragraph or the file, so clean - * up. current_y and totsize have been maintained above. If we - * actually justified something, set last_par_line to the new end of - * the paragraph. */ + * up. totsize has been maintained above. If we actually justified + * something, set last_par_line to the new end of the paragraph. */ if (first_par_line != NULL) last_par_line = openfile->current; @@ -2920,7 +2912,6 @@ const char *do_alt_speller(char *tempfile_name) int alt_spell_status; size_t current_x_save = openfile->current_x; size_t pww_save = openfile->placewewant; - ssize_t current_y_save = openfile->current_y; ssize_t lineno_save = openfile->current->lineno; struct stat spellfileinfo; time_t timestamp; @@ -3070,7 +3061,6 @@ const char *do_alt_speller(char *tempfile_name) goto_line_posx(lineno_save, current_x_save); if (openfile->current_x > strlen(openfile->current->data)) openfile->current_x = strlen(openfile->current->data); - openfile->current_y = current_y_save; openfile->placewewant = pww_save; adjust_viewport(STATIONARY); @@ -3469,7 +3459,6 @@ void do_formatter(void) FILE *temp_file; int format_status; ssize_t lineno_save = openfile->current->lineno; - ssize_t current_y_save = openfile->current_y; size_t current_x_save = openfile->current_x; size_t pww_save = openfile->placewewant; pid_t pid_format; @@ -3551,7 +3540,6 @@ void do_formatter(void) goto_line_posx(lineno_save, current_x_save); if (openfile->current_x > strlen(openfile->current->data)) openfile->current_x = strlen(openfile->current->data); - openfile->current_y = current_y_save; openfile->placewewant = pww_save; adjust_viewport(STATIONARY);