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.
master
David Lawrence Ramsey 2016-12-22 13:01:27 -06:00 committed by Benno Schulenberg
parent 7373e4cd46
commit b1c20629f5
3 changed files with 4 additions and 20 deletions

View File

@ -138,10 +138,9 @@ void do_para_begin(bool allow_update)
filestruct *was_current = openfile->current; filestruct *was_current = openfile->current;
if (openfile->current != openfile->fileage) { if (openfile->current != openfile->fileage) {
do { do
openfile->current = openfile->current->prev; openfile->current = openfile->current->prev;
openfile->current_y--; while (!begpar(openfile->current));
} while (!begpar(openfile->current));
} }
openfile->current_x = 0; openfile->current_x = 0;
@ -175,7 +174,6 @@ void do_para_end(bool allow_update)
inpar(openfile->current->next) && inpar(openfile->current->next) &&
!begpar(openfile->current->next)) { !begpar(openfile->current->next)) {
openfile->current = openfile->current->next; openfile->current = openfile->current->next;
openfile->current_y++;
} }
if (openfile->current != openfile->filebot) { if (openfile->current != openfile->filebot) {

View File

@ -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. */ /* Set the current position to point at what we found. */
openfile->current = fileptr; openfile->current = fileptr;
openfile->current_x = found_x; openfile->current_x = found_x;
openfile->current_y = fileptr->lineno - openfile->edittop->lineno;
/* When requested, pass back the length of the match. */ /* When requested, pass back the length of the match. */
if (match_len != NULL) 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. */ /* Set the current position to the found matching bracket. */
openfile->current = fileptr; openfile->current = fileptr;
openfile->current_x = found - fileptr->data; openfile->current_x = found - fileptr->data;
openfile->current_y = fileptr->lineno - openfile->edittop->lineno;
return TRUE; return TRUE;
} }

View File

@ -2117,9 +2117,6 @@ bool find_paragraph(size_t *const quote, size_t *const par)
/* Number of lines in the paragraph we search for. */ /* Number of lines in the paragraph we search for. */
filestruct *current_save; filestruct *current_save;
/* The line at the beginning of the paragraph we search for. */ /* 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 #ifdef HAVE_REGEX_H
if (quoterc != 0) { if (quoterc != 0) {
@ -2168,7 +2165,6 @@ bool find_paragraph(size_t *const quote, size_t *const par)
* of lines in this paragraph. */ * of lines in this paragraph. */
quote_len = quote_length(openfile->current->data); quote_len = quote_length(openfile->current->data);
current_save = openfile->current; current_save = openfile->current;
current_y_save = openfile->current_y;
do_para_end(FALSE); do_para_end(FALSE);
par_len = openfile->current->lineno - current_save->lineno; 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) if (openfile->current_x > 0)
par_len++; par_len++;
openfile->current = current_save; openfile->current = current_save;
openfile->current_y = current_y_save;
/* Save the values of quote_len and par_len. */ /* Save the values of quote_len and par_len. */
assert(quote != NULL && par != NULL); assert(quote != NULL && par != NULL);
@ -2451,7 +2446,6 @@ void do_justify(bool full_justify)
/* Go to the next line. */ /* Go to the next line. */
par_len--; par_len--;
openfile->current_y++;
openfile->current = openfile->current->next; 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, /* Go to the next line, if possible. If there is no next line,
* move to the end of the current line. */ * move to the end of the current line. */
if (openfile->current != openfile->filebot) { if (openfile->current != openfile->filebot) {
openfile->current_y++;
openfile->current = openfile->current->next; openfile->current = openfile->current->next;
} else } else
openfile->current_x = strlen(openfile->current->data); 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 /* We are now done justifying the paragraph or the file, so clean
* up. current_y and totsize have been maintained above. If we * up. totsize has been maintained above. If we actually justified
* actually justified something, set last_par_line to the new end of * something, set last_par_line to the new end of the paragraph. */
* the paragraph. */
if (first_par_line != NULL) if (first_par_line != NULL)
last_par_line = openfile->current; last_par_line = openfile->current;
@ -2920,7 +2912,6 @@ const char *do_alt_speller(char *tempfile_name)
int alt_spell_status; int alt_spell_status;
size_t current_x_save = openfile->current_x; size_t current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant; size_t pww_save = openfile->placewewant;
ssize_t current_y_save = openfile->current_y;
ssize_t lineno_save = openfile->current->lineno; ssize_t lineno_save = openfile->current->lineno;
struct stat spellfileinfo; struct stat spellfileinfo;
time_t timestamp; time_t timestamp;
@ -3070,7 +3061,6 @@ const char *do_alt_speller(char *tempfile_name)
goto_line_posx(lineno_save, current_x_save); goto_line_posx(lineno_save, current_x_save);
if (openfile->current_x > strlen(openfile->current->data)) if (openfile->current_x > strlen(openfile->current->data))
openfile->current_x = strlen(openfile->current->data); openfile->current_x = strlen(openfile->current->data);
openfile->current_y = current_y_save;
openfile->placewewant = pww_save; openfile->placewewant = pww_save;
adjust_viewport(STATIONARY); adjust_viewport(STATIONARY);
@ -3469,7 +3459,6 @@ void do_formatter(void)
FILE *temp_file; FILE *temp_file;
int format_status; int format_status;
ssize_t lineno_save = openfile->current->lineno; 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 current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant; size_t pww_save = openfile->placewewant;
pid_t pid_format; pid_t pid_format;
@ -3551,7 +3540,6 @@ void do_formatter(void)
goto_line_posx(lineno_save, current_x_save); goto_line_posx(lineno_save, current_x_save);
if (openfile->current_x > strlen(openfile->current->data)) if (openfile->current_x > strlen(openfile->current->data))
openfile->current_x = strlen(openfile->current->data); openfile->current_x = strlen(openfile->current->data);
openfile->current_y = current_y_save;
openfile->placewewant = pww_save; openfile->placewewant = pww_save;
adjust_viewport(STATIONARY); adjust_viewport(STATIONARY);