diff --git a/ChangeLog b/ChangeLog index ad6b27859a2fc61a1c00115910d4140b14a1bc65..7280b16be6c30dd7bf89bfd33bf794b3549d947d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-02-16 Chris Allegretta <chrisa@asty.org> + * 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 <chrisa@asty.org> * 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 c20ace02e6f6c89f579d7ec327c96563be8f0a07..e93d1aaca043cde5bccd35a907cfa121c082c661 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 f92f9b3c4e99b1d8efeb6d441388f1b1feab5be5..d4cc7c14e1594248979746226db9010457d2fcf7 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 08e9ca7c7eb10bdb1279c90e3c6d468c43bf95a4..87c370514eaa9e39d34fec407666a3199f8ee382 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 2328cc13af7d1d4cb178506af9b972aa5d7b1d54..e29055fbe03da8ecaece9886110d1ec511042e26 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