+2009-02-05 Chris Allegretta <chrisa@asty.org>
+ * More color syntax speedups: Determine in reset_multis() whether we really need to call
+ edit_refresh(). Additional global var edit_refresh_needed() to hopefully reduce
+ repeated calls to the function. New helper funcs reset_multis_before() and
+ reset_multis_after().
+
+2009-02-02 Chris Allegretta <chrisa@asty.org>
+ * New color precalculation code for mult-line regexes. New function precalc_multicolorinfo(),
+ new structure multidata for keeping track of where regexes start/stop. More
+ performance improvements forthcoming.
+
2009-01-29 Chris Allegretta <chrisa@asty.org>
* nano.c (move_to_filestruct) - properky initialize new fileage for multiswatching, sigh.
Fix cut sefaults discovered by Mike Frysinger.
}
}
-/* Reset multi line strings around a filestruct ptr, trying to be smart about stopping */
-void reset_multis(filestruct *fileptr)
+/* Reset the multicolor info cache for records for any lines which need
+ to be recalculated */
+void reset_multis_after(filestruct *fileptr, int mindex)
+{
+ filestruct *oof;
+ for (oof = fileptr->next; oof != NULL; oof = oof->next) {
+ if (oof->multidata == NULL)
+ continue;
+ if (oof->multidata[mindex] != 0)
+ oof->multidata[mindex] = -1;
+ else
+ break;
+ }
+}
+
+void reset_multis_before(filestruct *fileptr, int mindex)
{
- int i;
filestruct *oof;
+ for (oof = fileptr->prev; oof != NULL; oof = oof->prev) {
+ if (oof->multidata == NULL)
+ continue;
+ if (oof->multidata[mindex] != 0)
+ oof->multidata[mindex] = -1;
+ else
+ break;
+ }
+}
+
+
+/* Reset multi line strings around a filestruct ptr, trying to be smart about stopping */
+void reset_multis(filestruct *fileptr)
+{
+ int nobegin, noend;
+ regmatch_t startmatch, endmatch;
+ const colortype *tmpcolor = openfile->colorstrings;
if (!openfile->syntax)
return;
- for (i = 0; i < openfile->syntax->nmultis; i++) {
- for (oof = fileptr->next; oof != NULL; oof = oof->next) {
- if (oof->multidata == NULL)
+ for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
+
+ /* If it's not a multi-line regex, amscray */
+ if (tmpcolor->end == NULL)
+ 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);
+ noend = regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0);
+ if (fileptr->multidata[tmpcolor->id] == CWHOLELINE) {
+ if (nobegin && noend)
continue;
- if (oof->multidata[i] != 0)
- oof->multidata[i] = -1;
- else
- break;
+ } else if (fileptr->multidata[tmpcolor->id] & CBEGINBEFORE && !noend
+ && (nobegin || endmatch.rm_eo > startmatch.rm_eo)) {
+ reset_multis_after(fileptr, tmpcolor->id);
+ continue;
}
- for (oof = fileptr->prev; oof != NULL; oof = oof->prev) {
- if (oof->multidata == NULL)
- continue;
- if (oof->multidata[i] == 0)
- oof->multidata[i] = -1;
- else
- break;
- }
- fileptr->multidata[i] = -1;
+
+ /* If we got here assume the worst */
+ reset_multis_before(fileptr, tmpcolor->id);
+ reset_multis_after(fileptr, tmpcolor->id);
+ fileptr->multidata[tmpcolor->id] = -1;
}
}
#endif /* ENABLE_COLOR */
#endif
if (do_refresh)
- edit_refresh();
+ edit_refresh_needed = TRUE;
else
update_line(openfile->current, openfile->current_x);
}
set_modified();
/* Update the screen. */
- edit_refresh();
+ edit_refresh_needed = TRUE;
}
}
openfile->mark_set = FALSE;
openfile->mark_begin = NULL;
openfile->mark_begin_x = 0;
- edit_refresh();
+ edit_refresh_needed = TRUE;
}
/* Undo the last thing(s) we did */
openfile->placewewant = xplustabs();
- edit_refresh();
+ edit_refresh_needed = TRUE;
}
#ifndef NANO_TINY
last_par_line = openfile->filebot;
break;
} else {
- edit_refresh();
+ edit_refresh_needed = TRUE;
return;
}
}
if (!openfile->modified)
titlebar(NULL);
- edit_refresh();
+ edit_refresh_needed = TRUE;
}
} else {
unget_kbinput(kbinput, meta_key, func_key);
free(read_buff);
search_replace_abort();
- edit_refresh();
+ edit_refresh_needed = TRUE;
/* Process the end of the spell process. */
waitpid(pid_spell, &spell_status, 0);