From 90798fbfbab54d5d0027f5785046ec4eb7167967 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 9 Aug 2015 16:05:50 +0000 Subject: [PATCH] Allowing to toggle whitespace display also when support for nanorc files has not been built in, since the default values are quite usable. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5348 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 6 ++++++ src/global.c | 8 ++------ src/help.c | 4 ---- src/nano.c | 4 ---- src/proto.h | 2 +- src/winio.c | 17 ++++++++--------- 6 files changed, 17 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3f3278b..81c2d304 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-08-09 Benno Schulenberg + * src/global.c, src/help.c (help_init), src/nano.c (do_toggle, main), + src/winio.c (display_string, statusbar): Allow toggling the display + of whitespace also when support for nanorc files was not built in, + because the default values are quite usable. + 2015-08-08 Benno Schulenberg * src/winio.c (display_string): For some reason the reallocation done by null_at() messes things up. So put in the null byte "manually". diff --git a/src/global.c b/src/global.c index 725ac904..4cc01189 100644 --- a/src/global.c +++ b/src/global.c @@ -89,14 +89,10 @@ openfilestruct *openfile = NULL; char *matchbrackets = NULL; /* The opening and closing brackets that can be found by bracket * searches. */ -#endif - -#if !defined(NANO_TINY) && !defined(DISABLE_NANORC) char *whitespace = NULL; - /* The characters used when displaying the first characters of - * tabs and spaces. */ + /* The characters used when visibly showing tabs and spaces. */ int whitespace_len[2]; - /* The length of these characters. */ + /* The length in bytes of these characters. */ #endif #ifndef DISABLE_JUSTIFY diff --git a/src/help.c b/src/help.c index a6246bae..4c9e5534 100644 --- a/src/help.c +++ b/src/help.c @@ -197,11 +197,9 @@ void help_init(void) int scsfound = 0; #ifndef NANO_TINY -#ifndef DISABLE_NANORC bool old_whitespace = ISSET(WHITESPACE_DISPLAY); UNSET(WHITESPACE_DISPLAY); -#endif #endif /* First, set up the initial help text for the current function. */ @@ -462,10 +460,8 @@ void help_init(void) } } -#ifndef DISABLE_NANORC if (old_whitespace) SET(WHITESPACE_DISPLAY); -#endif #endif /* !NANO_TINY */ /* If all went well, we didn't overwrite the allocated space for diff --git a/src/nano.c b/src/nano.c index 69c1d225..6a35faca 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1457,12 +1457,10 @@ void do_toggle(int flag) case SUSPEND: signal_init(); break; -#ifndef DISABLE_NANORC case WHITESPACE_DISPLAY: titlebar(NULL); edit_refresh(); break; -#endif #ifndef DISABLE_COLOR case NO_COLOR_SYNTAX: #endif @@ -2646,7 +2644,6 @@ int main(int argc, char **argv) if (matchbrackets == NULL) matchbrackets = mallocstrcpy(NULL, "(<[{)>]}"); -#ifndef DISABLE_NANORC /* If whitespace wasn't specified, set its default value. If we're * using UTF-8, it's Unicode 00BB (Right-Pointing Double Angle * Quotation Mark) and Unicode 00B7 (Middle Dot). Otherwise, it's @@ -2665,7 +2662,6 @@ int main(int argc, char **argv) whitespace_len[1] = 1; } } -#endif /* !DISABLE_NANORC */ #endif /* !NANO_TINY */ /* Initialize the search and replace strings. */ diff --git a/src/proto.h b/src/proto.h index 70e7ee6a..b975b1a4 100644 --- a/src/proto.h +++ b/src/proto.h @@ -62,7 +62,7 @@ extern openfilestruct *openfile; extern char *matchbrackets; #endif -#if !defined(NANO_TINY) && !defined(DISABLE_NANORC) +#ifndef NANO_TINY extern char *whitespace; extern int whitespace_len[2]; #endif diff --git a/src/winio.c b/src/winio.c index b2d5904d..32f9921b 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1949,7 +1949,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool /* If buf contains a tab character, interpret it. */ if (*buf_mb == '\t') { -#if !defined(NANO_TINY) && !defined(DISABLE_NANORC) +#ifndef NANO_TINY if (ISSET(WHITESPACE_DISPLAY)) { int i; @@ -1982,7 +1982,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool free(ctrl_buf_mb); /* If buf contains a space character, interpret it. */ } else if (*buf_mb == ' ') { -#if !defined(NANO_TINY) && !defined(DISABLE_NANORC) +#ifndef NANO_TINY if (ISSET(WHITESPACE_DISPLAY)) { int i; @@ -2240,8 +2240,10 @@ void statusbar(const char *msg, ...) va_list ap; char *bar, *foo; size_t start_x; -#if !defined(NANO_TINY) && !defined(DISABLE_NANORC) - bool old_whitespace; +#ifndef NANO_TINY + bool old_whitespace = ISSET(WHITESPACE_DISPLAY); + + UNSET(WHITESPACE_DISPLAY); #endif va_start(ap, msg); @@ -2256,16 +2258,13 @@ void statusbar(const char *msg, ...) blank_statusbar(); -#if !defined(NANO_TINY) && !defined(DISABLE_NANORC) - old_whitespace = ISSET(WHITESPACE_DISPLAY); - UNSET(WHITESPACE_DISPLAY); -#endif bar = charalloc(mb_cur_max() * (COLS - 3)); vsnprintf(bar, mb_cur_max() * (COLS - 3), msg, ap); va_end(ap); foo = display_string(bar, 0, COLS - 4, FALSE); free(bar); -#if !defined(NANO_TINY) && !defined(DISABLE_NANORC) + +#ifndef NANO_TINY if (old_whitespace) SET(WHITESPACE_DISPLAY); #endif