1
1

tweaks: rename a function, and drop an unneeded parameter

When replacements are made, nothing needs to be reset any more
(it was done insufficiently anyway).  Just make sure the screen
is refreshed when all is done -- this may be superfluous when
doing interactive replacements, but not when replacing all.
Этот коммит содержится в:
Benno Schulenberg 2017-02-13 19:11:04 +01:00
родитель fccfcccd37
Коммит 9ec546d293
5 изменённых файлов: 18 добавлений и 23 удалений

Просмотреть файл

@ -292,7 +292,7 @@ void color_update(void)
/* Determine whether the matches of multiline regexes are still the same,
* and if not, schedule a screen refresh, so things will be repainted. */
void reset_multis(filestruct *fileptr, bool force)
void check_the_multis(filestruct *line)
{
const colortype *ink;
int nobegin = 0, noend = 0;
@ -307,27 +307,25 @@ void reset_multis(filestruct *fileptr, bool force)
if (ink->end == NULL)
continue;
alloc_multidata_if_needed(fileptr);
alloc_multidata_if_needed(line);
if (force == FALSE) {
/* Check whether the multidata still matches the current situation. */
nobegin = regexec(ink->start, fileptr->data, 1, &startmatch, 0);
noend = regexec(ink->end, fileptr->data, 1, &endmatch, 0);
if (fileptr->multidata[ink->id] == CNONE ||
fileptr->multidata[ink->id] == CWHOLELINE) {
nobegin = regexec(ink->start, line->data, 1, &startmatch, 0);
noend = regexec(ink->end, line->data, 1, &endmatch, 0);
if (line->multidata[ink->id] == CNONE ||
line->multidata[ink->id] == CWHOLELINE) {
if (nobegin && noend)
continue;
} else if (fileptr->multidata[ink->id] == CSTARTENDHERE) {
} else if (line->multidata[ink->id] == CSTARTENDHERE) {
if (!nobegin && !noend && startmatch.rm_so < endmatch.rm_so)
continue;
} else if (fileptr->multidata[ink->id] == CBEGINBEFORE) {
} else if (line->multidata[ink->id] == CBEGINBEFORE) {
if (nobegin && !noend)
continue;
} else if (fileptr->multidata[ink->id] == CENDAFTER) {
} else if (line->multidata[ink->id] == CENDAFTER) {
if (!nobegin && noend)
continue;
}
}
refresh_needed = TRUE;
return;

Просмотреть файл

@ -194,7 +194,7 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
refresh_needed = TRUE;
#ifndef DISABLE_COLOR
reset_multis(openfile->current, FALSE);
check_the_multis(openfile->current);
#endif
#ifdef DEBUG
@ -291,7 +291,7 @@ void do_uncut_text(void)
refresh_needed = TRUE;
#ifndef DISABLE_COLOR
reset_multis(openfile->current, FALSE);
check_the_multis(openfile->current);
#endif
#ifdef DEBUG

Просмотреть файл

@ -1690,7 +1690,7 @@ int do_input(bool allow_funcs)
#endif
#ifndef DISABLE_COLOR
if (f && !f->viewok)
reset_multis(openfile->current, FALSE);
check_the_multis(openfile->current);
#endif
if (!refresh_needed && (s->scfunc == do_delete || s->scfunc == do_backspace))
update_line(openfile->current, openfile->current_x);
@ -1891,7 +1891,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
openfile->placewewant = xplustabs();
#ifndef DISABLE_COLOR
reset_multis(openfile->current, FALSE);
check_the_multis(openfile->current);
#endif
if (!refresh_needed)

Просмотреть файл

@ -266,7 +266,7 @@ bool is_valid_mbstring(const char *s);
void set_colorpairs(void);
void color_init(void);
void color_update(void);
void reset_multis(filestruct *fileptr, bool force);
void check_the_multis(filestruct *line);
void alloc_multidata_if_needed(filestruct *fileptr);
void precalc_multicolorinfo(void);
#endif

Просмотреть файл

@ -719,13 +719,6 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
free(openfile->current->data);
openfile->current->data = copy;
#ifndef DISABLE_COLOR
/* Reset the precalculated multiline-regex hints only when
* the first replacement has been made. */
if (numreplaced == 0)
reset_multis(openfile->current, TRUE);
#endif
if (!replaceall) {
#ifndef DISABLE_COLOR
/* When doing syntax coloring, the replacement might require
@ -745,6 +738,10 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
if (numreplaced == -1)
not_found_msg(needle);
#ifndef DISABLE_COLOR
else if (numreplaced > 0)
refresh_needed = TRUE;
#endif
#ifndef NANO_TINY
if (mark_was_set)