diff --git a/ChangeLog b/ChangeLog index ad6b2785..7280b16b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-02-16 Chris Allegretta + * Add new argument to reset_multis for force redraws without attempting to + guess whether we need to, force updates when running a non-viewok function. + New utility function color.c:reset_multis_for_id(). Fixes e.g. incorrect + highlighting when cutting text. + 2009-02-15 Chris Allegretta * configure.ac, doc/man/Makefile.am - Add check for HTML output support in GNU groff. Fixes Savannah bug #24461: build traps on groff. Also, add installation diff --git a/src/color.c b/src/color.c index c20ace02..e93d1aac 100644 --- a/src/color.c +++ b/src/color.c @@ -305,9 +305,18 @@ void reset_multis_before(filestruct *fileptr, int mindex) edit_refresh_needed = TRUE; } +/* Reset one multiline regex info */ +void reset_multis_for_id(filestruct *fileptr, int num) +{ + reset_multis_before(fileptr, num); + reset_multis_after(fileptr, num); + fileptr->multidata[num] = -1; +} -/* Reset multi line strings around a filestruct ptr, trying to be smart about stopping */ -void reset_multis(filestruct *fileptr) +/* Reset multi line strings around a filestruct ptr, trying to be smart about stopping + force = reset everything regardless, useful when we don't know how much screen state + has changed */ +void reset_multis(filestruct *fileptr, bool force) { int nobegin, noend; regmatch_t startmatch, endmatch; @@ -323,6 +332,11 @@ void reset_multis(filestruct *fileptr) continue; alloc_multidata_if_needed(fileptr); + if (force == TRUE) { + reset_multis_for_id(fileptr, tmpcolor->id); + continue; + } + /* Figure out where the first begin and end are to determine if things changed drastically for the precalculated multi values */ nobegin = regexec(tmpcolor->start, fileptr->data, 1, &startmatch, 0); @@ -337,9 +351,7 @@ void reset_multis(filestruct *fileptr) } /* If we got here assume the worst */ - reset_multis_before(fileptr, tmpcolor->id); - reset_multis_after(fileptr, tmpcolor->id); - fileptr->multidata[tmpcolor->id] = -1; + reset_multis_for_id(fileptr, tmpcolor->id); } } #endif /* ENABLE_COLOR */ diff --git a/src/cut.c b/src/cut.c index f92f9b3c..d4cc7c14 100644 --- a/src/cut.c +++ b/src/cut.c @@ -211,9 +211,8 @@ void do_cut_text( * modified. */ set_modified(); - /* Update the screen. */ - edit_refresh(); + edit_refresh_needed = TRUE; #ifdef DEBUG dump_filestruct(cutbuffer); @@ -276,7 +275,7 @@ void do_uncut_text(void) set_modified(); /* Update the screen. */ - edit_refresh(); + edit_refresh_needed = TRUE; #ifdef DEBUG dump_filestruct_reverse(); diff --git a/src/nano.c b/src/nano.c index 08e9ca7c..87c37051 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1598,9 +1598,9 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool #endif iso_me_harder_funcmap(s->scfunc); #ifdef ENABLE_COLOR - if (!f->viewok && openfile->syntax != NULL - && openfile->current->multidata && openfile->syntax->nmultis > 0) { - reset_multis(openfile->current); + if (!f->viewok && openfile->syntax != NULL + && openfile->syntax->nmultis > 0) { + reset_multis(openfile->current, TRUE); } if (edit_refresh_needed) { edit_refresh(); @@ -1927,7 +1927,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) #ifdef ENABLE_COLOR - reset_multis(openfile->current); + reset_multis(openfile->current, FALSE); #endif if (do_refresh) { edit_refresh(); diff --git a/src/proto.h b/src/proto.h index 2328cc13..e29055fb 100644 --- a/src/proto.h +++ b/src/proto.h @@ -543,7 +543,7 @@ void parse_syntax(char *ptr); void parse_include(char *ptr); short color_to_short(const char *colorname, bool *bright); void parse_colors(char *ptr, bool icase); -void reset_multis(filestruct *fileptr); +void reset_multis(filestruct *fileptr, bool force); void alloc_multidata_if_needed(filestruct *fileptr); #endif void parse_rcfile(FILE *rcstream