nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 9c4ebed3ffb471e0ac3ca284c6595d2696b8e3f1
parent e64e54d57fe2e35ce71520917933d6a1fdb28412
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Fri,  1 May 2020 12:38:02 +0200

tweaks: remove an unneeded element from the openfilestruct

Diffstat:
Msrc/color.c | 9++++-----
Msrc/files.c | 1-
Msrc/nano.h | 4+---
Msrc/search.c | 2+-
Msrc/winio.c | 6+++---
5 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/color.c b/src/color.c @@ -116,7 +116,7 @@ void prepare_palette(void) #endif /* For each coloring expression, initialize the color pair. */ - for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) { + for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) { foreground = ink->fg; background = ink->bg; @@ -249,7 +249,6 @@ void find_and_prime_applicable_syntax(void) } openfile->syntax = sntx; - openfile->colorstrings = (sntx == NULL ? NULL : sntx->color); } /* Allocate and initialize (for the given line) the cache for multiline info. */ @@ -277,7 +276,7 @@ void check_the_multis(linestruct *line) if (line->multidata == NULL) set_up_multicache(line); - for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) { + for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) { /* If it's not a multiline regex, skip. */ if (ink->end == NULL) continue; @@ -316,14 +315,14 @@ void precalc_multicolorinfo(void) regmatch_t startmatch, endmatch; linestruct *line, *tailline; - if (openfile->colorstrings == NULL || ISSET(NO_COLOR_SYNTAX)) + if (openfile->syntax == NULL || ISSET(NO_COLOR_SYNTAX)) return; /* For each line, allocate cache space for the multiline-regex info. */ for (line = openfile->filetop; line != NULL; line = line->next) set_up_multicache(line); - for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) { + for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) { /* If this is not a multi-line regex, skip it. */ if (ink->end == NULL) continue; diff --git a/src/files.c b/src/files.c @@ -97,7 +97,6 @@ void make_new_buffer(void) #endif #ifdef ENABLE_COLOR openfile->syntax = NULL; - openfile->colorstrings = NULL; #endif } diff --git a/src/nano.h b/src/nano.h @@ -403,9 +403,7 @@ typedef struct openfilestruct { /* Whether the file has been modified. */ #ifdef ENABLE_COLOR syntaxtype *syntax; - /* The syntax struct for this file, if any. */ - colortype *colorstrings; - /* The file's associated colors. */ + /* The syntax that applies to this file, if any. */ #endif #ifdef ENABLE_MULTIBUFFER struct openfilestruct *next; diff --git a/src/search.c b/src/search.c @@ -646,7 +646,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only, #ifdef ENABLE_COLOR /* When doing syntax coloring, the replacement might require * a change of colors, so refresh the whole edit window. */ - if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) + if (openfile->syntax && !ISSET(NO_COLOR_SYNTAX)) edit_refresh(); else #endif diff --git a/src/winio.c b/src/winio.c @@ -2422,8 +2422,8 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col) #ifdef ENABLE_COLOR /* If color syntaxes are available and turned on, apply them. */ - if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) { - const colortype *varnish = openfile->colorstrings; + if (openfile->syntax && !ISSET(NO_COLOR_SYNTAX)) { + const colortype *varnish = openfile->syntax->color; /* If there are multiline regexes, make sure there is a cache. */ if (openfile->syntax->nmultis > 0 && line->multidata == NULL) @@ -3259,7 +3259,7 @@ void edit_refresh(void) #ifdef ENABLE_COLOR /* When needed and useful, initialize the colors for the current syntax. */ - if (!have_palette && has_colors()) + if (openfile->syntax && !have_palette && !ISSET(NO_COLOR_SYNTAX) && has_colors()) prepare_palette(); #endif