- Since KEEP_CUTBUFFER is only used in cut.c, make it a static
variable in cut.c instead of a flag, and unset it in other
files via the new function cutbuffer_reset(). (DLR)
+ - Add the ability to change the characters used to display the
+ beginning characters of tabs and spaces via the rcfile entry
+ "whitespace". This is disabled if nanorc support is disabled
+ or if we're in tiny mode. (Mike Frysinger; minor changes and
+ adaptations by DLR)
- files.c:
add_open_file()
- Rearrange the NANO_SMALL #ifdef so that the code to set the
- Convert to properly handle strings generated by
display_string() that have been used in the search prompt
since 1.3.0. (David Benbennick)
+ - Use display_string() directly to display the text that we
+ didn't find instead of relying on statusbar() to do it
+ indirectly, since the latter won't display its text with the
+ user-specified whitespace characters and the former will.
+ (DLR)
- utils.c:
is_blank_char()
- New function used as an isblank() equivalent, since isblank()
- Document the smart home key option. (DLR)
- nanorc.5:
- Document the smart home key option. (DLR)
+ - Document the whitespace option. (DLR, adapted from
+ documentation by Mike Frysinger)
- nano.texi:
- Fix toggle inaccuracies: Meta-L now toggles line wrapping, and
Meta-< and Meta-> aren't toggles. (DLR)
- Add missing mouse entry, and update the nanorc sample regexes
to account for the backupdir and mouse options. (DLR)
- Add smarthome description. (DLR)
+ - Document the whitespace option. (DLR, adapted from
+ documentation by Mike Frysinger)
- README.CVS:
- Increase the minimum required autoconf version to 2.54, and
change the recommended automake version 1.7 to the minimum
\fBset/unset view\fP
Disallow file modification.
.TP
+\fBset whitespace "\fIstring\fP"\fP
+Set the two characters used to display the first characters of tabs and
+spaces. They cannot be control characters.
+.TP
.B syntax "\fIstr\fP" ["\fIfileregex\fP" ... ]
Defines a syntax named \fIstr\fP which can be activated via the \fB-Y\fP
flag, or will be automatically activated if the current filename matches
## Disallow file modification, why would you want this in an rc file? ;)
# set view
+## The two characters used to display the first characters of tabs and
+## spaces. ASCII 187 and ASCII 183 seem to be good values for these.
+# set whitespace " "
+
## Color setup
## Format:
## syntax "short description" ["filename regex" ...]
## highlight possible errors and parameters
#color brightwhite "^ *(set|unset|syntax|color).*$"
## set, unset and syntax
-#color cyan "^ *(set|unset) +(autoindent|backup|backupdir|const|cut|fill|historylog|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|quotestr|rebinddelete|regexp|smarthome|smooth|speller|suspend|tabsize|tempfile|view)"
+#color cyan "^ *(set|unset) +(autoindent|backup|backupdir|const|cut|fill|historylog|mouse|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|quotestr|rebinddelete|regexp|smarthome|smooth|speller|suspend|tabsize|tempfile|view|whitespace)"
#color green "^ *(set|unset|syntax)\>"
## colors
#color yellow "^ *color +(bright)?(white|black|red|blue|green|yellow|magenta|cyan)(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
#ifndef NANO_SMALL
char *backup_dir = NULL; /* Backup directory. */
+#ifdef ENABLE_NANORC
+char *whitespace = NULL; /* Characters used when displaying
+ the first characters of tabs and
+ spaces. */
+#endif
#endif
int resetstatuspos; /* Hack for resetting the status bar
#ifndef DISABLE_WRAPPING
char *toggle_wrap_msg;
#endif
+#ifdef ENABLE_COLOR
+ char *toggle_syntax_msg;
+#endif
#ifdef ENABLE_MULTIBUFFER
char *toggle_multibuffer_msg;
#endif
-#ifdef ENABLE_COLOR
- char *toggle_syntax_msg;
+#ifdef ENABLE_NANORC
+ char *toggle_whitespace_msg;
#endif
/* There is no need to reinitialize the toggles. They can't
#ifdef ENABLE_MULTIBUFFER
toggle_multibuffer_msg = _("Multiple file buffers");
#endif
+#ifdef ENABLE_NANORC
+ toggle_whitespace_msg = _("Whitespace display");
+#endif
toggle_init_one(TOGGLE_NOHELP_KEY, toggle_nohelp_msg, NO_HELP);
#ifdef ENABLE_MULTIBUFFER
#ifdef ENABLE_COLOR
toggle_init_one(TOGGLE_SYNTAX_KEY, toggle_syntax_msg, COLOR_SYNTAX);
#endif
+#ifdef ENABLE_NANORC
+ toggle_init_one(TOGGLE_WHITESPACE_KEY, toggle_whitespace_msg, WHITESPACE_DISPLAY);
+#endif
}
#ifdef DEBUG
case TOGGLE_SYNTAX_KEY:
edit_refresh();
break;
+#endif
+#ifdef ENABLE_NANORC
+ case TOGGLE_WHITESPACE_KEY:
+ edit_refresh();
+ break;
#endif
}
}
#endif
+#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
+ if (whitespace == NULL)
+ whitespace = mallocstrcpy(NULL, " ");
+#endif
+
if (tabsize == -1)
tabsize = 8;
#define HISTORYLOG (1<<27)
#define RESTRICTED (1<<28)
#define SMART_HOME (1<<29)
+#define WHITESPACE_DISPLAY (1<<30)
/* Control key sequences, changing these would be very very bad. */
#define NANO_CONTROL_SPACE 0
#define TOGGLE_BACKUP_KEY NANO_ALT_B
#define TOGGLE_SYNTAX_KEY NANO_ALT_Y
#define TOGGLE_SMARTHOME_KEY NANO_ALT_H
+#define TOGGLE_WHITESPACE_KEY NANO_ALT_P
#endif /* !NANO_SMALL */
#define MAIN_VISIBLE 12
#ifndef NANO_SMALL
extern char *backup_dir;
+#ifdef ENABLE_NANORC
+extern char *whitespace;
+#endif
#endif
extern WINDOW *topwin, *edit, *bottomwin;
{"tabsize", 0},
{"tempfile", TEMP_OPT},
{"view", VIEW_MODE},
+#ifndef NANO_SMALL
+ {"whitespace", 0},
+#endif
{NULL, 0}
};
return ptr;
}
-/* The keywords operatingdir, backupdir, fill, tabsize, speller, and
- * quotestr take an argument when set. Among these, operatingdir,
- * backupdir, speller, and quotestr have to allow tabs and spaces in the
- * argument. Thus, if the next word starts with a ", we say it ends
- * with the last " of the line. Otherwise, the word is interpreted as
- * usual. That is so the arguments can contain "s too. */
+/* The keywords operatingdir, backupdir, fill, tabsize, speller,
+ * quotestr, and whitespace take an argument when set. Among these,
+ * operatingdir, backupdir, speller, quotestr, and whitespace have to
+ * allow tabs and spaces in the argument. Thus, if the next word starts
+ * with a ", we say it ends with the last " of the line. Otherwise, the
+ * word is interpreted as usual. That is so the arguments can contain
+ * "s too. */
char *parse_argument(char *ptr)
{
const char *ptr_bak = ptr;
#endif
#ifndef NANO_SMALL
|| !strcasecmp(rcopts[i].name, "backupdir")
+ || !strcasecmp(rcopts[i].name, "whitespace")
#endif
#ifndef DISABLE_SPELLER
|| !strcasecmp(rcopts[i].name, "speller")
if (!strcasecmp(rcopts[i].name, "backupdir"))
backup_dir = mallocstrcpy(NULL, option);
else
+
+ if (!strcasecmp(rcopts[i].name, "whitespace")) {
+ size_t ws_len;
+ whitespace = mallocstrcpy(NULL, option);
+ ws_len = strlen(whitespace);
+ if (ws_len != 2 || (ws_len == 2 && (is_cntrl_char(whitespace[0]) || is_cntrl_char(whitespace[1])))) {
+ rcfile_error(_("Two non-control characters required"));
+ free(whitespace);
+ whitespace = NULL;
+ } else
+ SET(WHITESPACE_DISPLAY);
+ } else
#endif
#ifndef DISABLE_SPELLER
if (!strcasecmp(rcopts[i].name, "speller"))
void not_found_msg(const char *str)
{
- int numchars = actual_x(str, COLS / 2);
-
+ char *disp;
+ int numchars;
+
assert(str != NULL);
- statusbar(_("\"%.*s%s\" not found"), numchars, str,
- str[numchars] == '\0' ? "" : "...");
+
+ disp = display_string(str, 0, (COLS / 2) + 1);
+ numchars = strnlen(disp, COLS / 2);
+
+ statusbar(_("\"%.*s%s\" not found"), numchars, disp,
+ disp[numchars] == '\0' ? "" : "...");
+
+ free(disp);
}
void search_abort(void)
index = 0;
for (; index < alloc_len; buf++) {
- if (*buf == '\t')
- do {
+ if (*buf == '\t') {
+ converted[index++] =
+#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
+ ISSET(WHITESPACE_DISPLAY) ? whitespace[0] :
+#endif
+ ' ';
+ while ((column + index) % tabsize)
converted[index++] = ' ';
- } while ((column + index) % tabsize);
- else if (is_cntrl_char(*buf)) {
+ } else if (is_cntrl_char(*buf)) {
converted[index++] = '^';
if (*buf == '\n')
/* Treat newlines embedded in a line as encoded nulls;
converted[index++] = '?';
else
converted[index++] = *buf + 64;
- } else
+ } else if (*buf == ' ')
+ converted[index++] =
+#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
+ ISSET(WHITESPACE_DISPLAY) ? whitespace[1] :
+#endif
+ ' ';
+ else
converted[index++] = *buf;
}
assert(len <= alloc_len + column - start_col);
char *bar;
char *foo;
size_t start_x = 0, foo_len;
+#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
+ int old_whitespace = ISSET(WHITESPACE_DISPLAY);
+ UNSET(WHITESPACE_DISPLAY);
+#endif
bar = charalloc(COLS - 3);
vsnprintf(bar, COLS - 3, msg, ap);
va_end(ap);
foo = display_string(bar, 0, COLS - 4);
+#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
+ if (old_whitespace)
+ SET(WHITESPACE_DISPLAY);
+#endif
free(bar);
foo_len = strlen(foo);
start_x = (COLS - foo_len - 4) / 2;