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
master
Benno Schulenberg 2015-08-09 16:05:50 +00:00
parent 2a5bd555e7
commit 90798fbfba
6 changed files with 17 additions and 24 deletions

View File

@ -1,3 +1,9 @@
2015-08-09 Benno Schulenberg <bensberg@justemail.net>
* 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 <bensberg@justemail.net> 2015-08-08 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (display_string): For some reason the reallocation done * src/winio.c (display_string): For some reason the reallocation done
by null_at() messes things up. So put in the null byte "manually". by null_at() messes things up. So put in the null byte "manually".

View File

@ -89,14 +89,10 @@ openfilestruct *openfile = NULL;
char *matchbrackets = NULL; char *matchbrackets = NULL;
/* The opening and closing brackets that can be found by bracket /* The opening and closing brackets that can be found by bracket
* searches. */ * searches. */
#endif
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
char *whitespace = NULL; char *whitespace = NULL;
/* The characters used when displaying the first characters of /* The characters used when visibly showing tabs and spaces. */
* tabs and spaces. */
int whitespace_len[2]; int whitespace_len[2];
/* The length of these characters. */ /* The length in bytes of these characters. */
#endif #endif
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY

View File

@ -197,11 +197,9 @@ void help_init(void)
int scsfound = 0; int scsfound = 0;
#ifndef NANO_TINY #ifndef NANO_TINY
#ifndef DISABLE_NANORC
bool old_whitespace = ISSET(WHITESPACE_DISPLAY); bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY); UNSET(WHITESPACE_DISPLAY);
#endif
#endif #endif
/* First, set up the initial help text for the current function. */ /* 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) if (old_whitespace)
SET(WHITESPACE_DISPLAY); SET(WHITESPACE_DISPLAY);
#endif
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
/* If all went well, we didn't overwrite the allocated space for /* If all went well, we didn't overwrite the allocated space for

View File

@ -1457,12 +1457,10 @@ void do_toggle(int flag)
case SUSPEND: case SUSPEND:
signal_init(); signal_init();
break; break;
#ifndef DISABLE_NANORC
case WHITESPACE_DISPLAY: case WHITESPACE_DISPLAY:
titlebar(NULL); titlebar(NULL);
edit_refresh(); edit_refresh();
break; break;
#endif
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
case NO_COLOR_SYNTAX: case NO_COLOR_SYNTAX:
#endif #endif
@ -2646,7 +2644,6 @@ int main(int argc, char **argv)
if (matchbrackets == NULL) if (matchbrackets == NULL)
matchbrackets = mallocstrcpy(NULL, "(<[{)>]}"); matchbrackets = mallocstrcpy(NULL, "(<[{)>]}");
#ifndef DISABLE_NANORC
/* If whitespace wasn't specified, set its default value. If we're /* If whitespace wasn't specified, set its default value. If we're
* using UTF-8, it's Unicode 00BB (Right-Pointing Double Angle * using UTF-8, it's Unicode 00BB (Right-Pointing Double Angle
* Quotation Mark) and Unicode 00B7 (Middle Dot). Otherwise, it's * Quotation Mark) and Unicode 00B7 (Middle Dot). Otherwise, it's
@ -2665,7 +2662,6 @@ int main(int argc, char **argv)
whitespace_len[1] = 1; whitespace_len[1] = 1;
} }
} }
#endif /* !DISABLE_NANORC */
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
/* Initialize the search and replace strings. */ /* Initialize the search and replace strings. */

View File

@ -62,7 +62,7 @@ extern openfilestruct *openfile;
extern char *matchbrackets; extern char *matchbrackets;
#endif #endif
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC) #ifndef NANO_TINY
extern char *whitespace; extern char *whitespace;
extern int whitespace_len[2]; extern int whitespace_len[2];
#endif #endif

View File

@ -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 contains a tab character, interpret it. */
if (*buf_mb == '\t') { if (*buf_mb == '\t') {
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC) #ifndef NANO_TINY
if (ISSET(WHITESPACE_DISPLAY)) { if (ISSET(WHITESPACE_DISPLAY)) {
int i; int i;
@ -1982,7 +1982,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
free(ctrl_buf_mb); free(ctrl_buf_mb);
/* If buf contains a space character, interpret it. */ /* If buf contains a space character, interpret it. */
} else if (*buf_mb == ' ') { } else if (*buf_mb == ' ') {
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC) #ifndef NANO_TINY
if (ISSET(WHITESPACE_DISPLAY)) { if (ISSET(WHITESPACE_DISPLAY)) {
int i; int i;
@ -2240,8 +2240,10 @@ void statusbar(const char *msg, ...)
va_list ap; va_list ap;
char *bar, *foo; char *bar, *foo;
size_t start_x; size_t start_x;
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC) #ifndef NANO_TINY
bool old_whitespace; bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
#endif #endif
va_start(ap, msg); va_start(ap, msg);
@ -2256,16 +2258,13 @@ void statusbar(const char *msg, ...)
blank_statusbar(); 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)); bar = charalloc(mb_cur_max() * (COLS - 3));
vsnprintf(bar, mb_cur_max() * (COLS - 3), msg, ap); vsnprintf(bar, mb_cur_max() * (COLS - 3), msg, ap);
va_end(ap); va_end(ap);
foo = display_string(bar, 0, COLS - 4, FALSE); foo = display_string(bar, 0, COLS - 4, FALSE);
free(bar); free(bar);
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
#ifndef NANO_TINY
if (old_whitespace) if (old_whitespace)
SET(WHITESPACE_DISPLAY); SET(WHITESPACE_DISPLAY);
#endif #endif