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>
* src/winio.c (display_string): For some reason the reallocation done
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;
/* 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

View File

@ -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

View File

@ -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. */

View File

@ -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

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_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