- Change translator-specific comments in global.c and prompt.c
so that they show up in nano.pot, and make them all
consistent. (Benno Schulenberg)
+ - Reduce USE_UTF8 to a static bool in chars.c, allow nano.c to
+ set it via a function, and allow winio.c to read its value
+ when needed. New functions utf8_init() and using_utf8();
+ changes to is_alnum_mbchar(), is_blank_mbchar(),
+ is_cntrl_mbchar(), is_punct_mbchar(), control_mbrep(),
+ mbrep(), mbwidth(), mb_cur_max(), make_mbchar(),
+ parse_mbchar(), mbstrncasecmp(), mbstrcasestr(),
+ mbrevstrcasestr(), mbstrnlen(), mbstrchr(), mbstrpbrk(),
+ mbrevstrpbrk(), has_blank_mbchars(), is_valid_mbstring(),
+ main(), display_string(), and do_credits(). (DLR)
+ - Add the ability to use bold text instead of reverse video
+ text, via the -D/--boldtext command line option and the
+ "boldtext" rcfile option. Changes to do_help(), usage(),
+ main(), update_statusbar_prompt(), do_yesno_prompt(),
+ titlebar(), statusbar(), onekey(), edit_draw(),
+ do_replace_highlight(), nano.1, nanorc.5, nano.texi, and
+ nanorc.sample. (DLR, suggested by Benno Schulenberg)
- files.c:
open_file()
- Remove redundant wording in the error message when we try to
.\" warranty.
.\"
.\" $Id$
-.TH NANO 1 "version 1.3.11" "April 5, 2006"
+.TH NANO 1 "version 1.3.11" "April 12, 2006"
.\" Please adjust this date whenever revising the manpage.
.\"
Set the directory where \fBnano\fP puts unique backup files if file
backups are enabled.
.TP
+.B \-D (\-\-boldtext)
+Use bold text instead of reverse video text.
+.TP
.B \-E (\-\-tabstospaces)
Convert typed tabs to spaces.
.TP
.\" warranty.
.\"
.\" $Id$
-.TH NANORC 5 "version 1.3.11" "April 5, 2006"
+.TH NANORC 5 "version 1.3.11" "April 12, 2006"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME
.B set/unset backwards
Do backwards searches by default.
.TP
+.B set/unset boldtext
+Use bold text instead of reverse video text.
+.TP
.B set brackets "\fIstring\fP"
Set the characters treated as closing brackets. They cannot contain
blank characters. Only closing punctuation, optionally followed by
## Do backwards searches by default.
# set backwards
+## Use bold text instead of reverse video text.
+# set boldtext
+
## The characters treated as closing brackets. They cannot contain
## blank characters. Only closing punctuation, optionally followed by
## closing brackets, can end sentences.
## highlight possible errors and parameters
# icolor brightwhite "^[[:space:]]*(set|unset|syntax|i?color).*$"
## set, unset and syntax
-# icolor cyan "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct|quickblank)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|view|whitespace|wordbounds)\>"
+# icolor cyan "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|view|whitespace|wordbounds)\>"
# icolor green "^[[:space:]]*(set|unset|syntax)\>"
## colors
# icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
@smallbook
@set EDITION 0.1
@set VERSION 1.3.10
-@set UPDATED 5 Apr 2006
+@set UPDATED 12 Apr 2006
@dircategory Editors
@direntry
Set the directory where @code{nano} puts unique backup files if file
backups are enabled.
+@item -D, --boldtext
+Use bold text instead of reverse video text.
+
@item -E, --tabstospaces
Convert typed tabs to spaces.
#include <wctype.h>
#endif
+static bool use_utf8 = FALSE;
+ /* Whether we've enabled UTF-8 support. */
static const wchar_t bad_wchar = 0xFFFD;
/* If we get an invalid multibyte sequence, we treat it as
* Unicode FFFD (Replacement Character), unless we're
* match to it. */
static const char *bad_mbchar = "\xEF\xBF\xBD";
static const int bad_mbchar_len = 3;
+
+/* Enable UTF-8 support. */
+void utf8_init(void)
+{
+ use_utf8 = TRUE;
+}
+
+/* Is UTF-8 support enabled? */
+bool using_utf8(void)
+{
+ return use_utf8;
+}
#endif
#ifndef HAVE_ISBLANK
assert(c != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
assert(c != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
assert(c != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
assert(c != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
wchar_t wc;
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
assert(c != NULL && crep != NULL && crep_len != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
assert(c != NULL && crep != NULL && crep_len != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
wchar_t wc;
/* Reject invalid Unicode characters. */
assert(c != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
wchar_t wc;
int width;
{
return
#ifdef ENABLE_UTF8
- ISSET(USE_UTF8) ? MB_CUR_MAX :
+ use_utf8 ? MB_CUR_MAX :
#endif
1;
}
assert(chr_mb_len != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
chr_mb = charalloc(MB_CUR_MAX);
*chr_mb_len = wctomb(chr_mb, (wchar_t)chr);
assert(buf != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
/* Get the number of bytes in the multibyte character. */
buf_mb_len = mblen(buf, MB_CUR_MAX);
int mbstrncasecmp(const char *s1, const char *s2, size_t n)
{
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
char *s1_mb = charalloc(MB_CUR_MAX);
char *s2_mb = charalloc(MB_CUR_MAX);
wchar_t ws1, ws2;
const char *mbstrcasestr(const char *haystack, const char *needle)
{
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
char *r_mb = charalloc(MB_CUR_MAX);
char *q_mb = charalloc(MB_CUR_MAX);
wchar_t wr, wq;
const char *rev_start)
{
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
char *r_mb = charalloc(MB_CUR_MAX);
char *q_mb = charalloc(MB_CUR_MAX);
wchar_t wr, wq;
assert(s != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
size_t n = 0;
int s_mb_len;
assert(s != NULL && c != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
bool bad_s_mb = FALSE, bad_c_mb = FALSE;
char *s_mb = charalloc(MB_CUR_MAX);
const char *q = s;
assert(s != NULL && accept != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
while (*s != '\0') {
if (mbstrchr(accept, s) != NULL)
return (char *)s;
assert(s != NULL && accept != NULL && rev_start != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
bool begin_line = FALSE;
while (!begin_line) {
assert(s != NULL);
#ifdef ENABLE_UTF8
- if (ISSET(USE_UTF8)) {
+ if (use_utf8) {
char *chr_mb = charalloc(MB_CUR_MAX);
bool retval = FALSE;
return
#ifdef ENABLE_UTF8
- ISSET(USE_UTF8) ?
+ use_utf8 ?
(mbstowcs(NULL, s, 0) != (size_t)-1) :
#endif
* maximum, used in regular expression searches. */
#endif
+int reverse_attr = A_REVERSE;
+ /* The curses attribute we use for reverse video. */
bool curses_ended = FALSE;
/* Whether endwin() has ended curses mode and statusbar()
* should hence write to stderr instead of displaying on the
curs_set(0);
blank_edit();
- wattroff(bottomwin, A_REVERSE);
+ wattroff(bottomwin, reverse_attr);
blank_statusbar();
/* Set help_text as the string to display. */
print1opt("-B", "--backup", N_("Save backups of existing files"));
print1opt(_("-C [dir]"), _("--backupdir=[dir]"),
N_("Directory for saving unique backup files"));
+ print1opt("-D", "--boldtext",
+ N_("Use bold instead of reverse video text"));
print1opt("-E", "--tabstospaces",
N_("Convert typed tabs to spaces"));
#endif
#ifdef HAVE_GETOPT_LONG
const struct option long_options[] = {
{"help", 0, NULL, 'h'},
+ {"boldtext", 0, NULL, 'D'},
#ifdef ENABLE_MULTIBUFFER
{"multibuffer", 0, NULL, 'F'},
#endif
if (locale != NULL && (strcasestr(locale, "UTF8") != NULL ||
strcasestr(locale, "UTF-8") != NULL)) {
- SET(USE_UTF8);
#ifdef USE_SLANG
SLutf8_enable(TRUE);
#endif
+ utf8_init();
}
}
#else
while ((optchr =
#ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv,
- "h?ABC:EFHIKLNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz",
+ "h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz",
long_options, NULL)
#else
getopt(argc, argv,
- "h?ABC:EFHIKLNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz")
+ "h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz")
#endif
) != -1) {
switch (optchr) {
case 'C':
backup_dir = mallocstrcpy(backup_dir, optarg);
break;
+#endif
+ case 'D':
+ SET(BOLD_TEXT);
+ break;
+#ifndef NANO_TINY
case 'E':
SET(TABS_TO_SPACES);
break;
#endif
#endif /* ENABLE_NANORC */
+ /* If we're using bold text instead of reverse video text, set it up
+ * now. */
+ if (ISSET(BOLD_TEXT))
+ reverse_attr = A_BOLD;
+
#ifndef NANO_TINY
+ /* Set up the search/replace history. */
history_init();
#ifdef ENABLE_NANORC
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
#define QUICK_BLANK (1<<28)
#define WORD_BOUNDS (1<<29)
#define NO_NEWLINES (1<<30)
-#define USE_UTF8 (1<<31)
+#define BOLD_TEXT (1<<31)
/* Control key sequences. Changing these would be very, very bad. */
#define NANO_CONTROL_SPACE 0
index = strnlenpt(curranswer, index);
page_start = get_statusbar_page_start(start_col, start_col + index);
- wattron(bottomwin, A_REVERSE);
+ wattron(bottomwin, reverse_attr);
blank_statusbar();
reset_statusbar_cursor();
- wattroff(bottomwin, A_REVERSE);
+ wattroff(bottomwin, reverse_attr);
}
/* Put the cursor in the statusbar prompt at statusbar_x. */
onekey("^C", _("Cancel"), width);
}
- wattron(bottomwin, A_REVERSE);
+ wattron(bottomwin, reverse_attr);
blank_statusbar();
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
- wattroff(bottomwin, A_REVERSE);
+ wattroff(bottomwin, reverse_attr);
/* Refresh the edit window and the statusbar before getting
* input. */
extern regmatch_t regmatches[10];
#endif
+extern int reverse_attr;
extern bool curses_ended;
extern char *homedir;
#endif
/* Public functions in chars.c. */
+#ifdef ENABLE_UTF8
+void utf8_init(void);
+bool using_utf8(void);
+#endif
#ifndef HAVE_ISBLANK
bool nisblank(int c);
#endif
#ifdef ENABLE_NANORC
const static rcoption rcopts[] = {
+ {"boldtext", BOLD_TEXT},
#ifndef DISABLE_JUSTIFY
{"brackets", 0},
#endif
}
}
#ifdef ENABLE_UTF8
- else if (ISSET(USE_UTF8) && mbwidth(buf_mb) > 1) {
+ else if (using_utf8() && mbwidth(buf_mb) > 1) {
converted[index++] = ' ';
start_col++;
assert(path != NULL || openfile->filename != NULL);
- wattron(topwin, A_REVERSE);
+ wattron(topwin, reverse_attr);
blank_titlebar();
/* space has to be at least 4: two spaces before the version message,
}
}
- wattroff(topwin, A_REVERSE);
+ wattroff(topwin, reverse_attr);
wnoutrefresh(topwin);
reset_cursor();
start_x = (COLS - foo_len - 4) / 2;
wmove(bottomwin, 0, start_x);
- wattron(bottomwin, A_REVERSE);
+ wattron(bottomwin, reverse_attr);
waddstr(bottomwin, "[ ");
waddstr(bottomwin, foo);
free(foo);
waddstr(bottomwin, " ]");
- wattroff(bottomwin, A_REVERSE);
+ wattroff(bottomwin, reverse_attr);
wnoutrefresh(bottomwin);
reset_cursor();
wnoutrefresh(edit);
assert(keystroke != NULL && desc != NULL);
- wattron(bottomwin, A_REVERSE);
+ wattron(bottomwin, reverse_attr);
waddnstr(bottomwin, keystroke, actual_x(keystroke, len));
- wattroff(bottomwin, A_REVERSE);
+ wattroff(bottomwin, reverse_attr);
if (len > keystroke_len)
len -= keystroke_len;
if (paintlen > 0)
paintlen = actual_x(converted + index, paintlen);
- wattron(edit, A_REVERSE);
+ wattron(edit, reverse_attr);
mvwaddnstr(edit, line, x_start, converted + index,
paintlen);
- wattroff(edit, A_REVERSE);
+ wattroff(edit, reverse_attr);
}
}
#endif /* !NANO_TINY */
reset_cursor();
if (highlight)
- wattron(edit, A_REVERSE);
+ wattron(edit, reverse_attr);
#ifdef HAVE_REGEX_H
/* This is so we can show zero-length regexes. */
waddch(edit, '$');
if (highlight)
- wattroff(edit, A_REVERSE);
+ wattroff(edit, reverse_attr);
}
#ifdef NANO_EXTRA
* Small Letter O with Diaresis) if applicable. */
credits[15] =
#ifdef ENABLE_UTF8
- ISSET(USE_UTF8) ? "Florian K\xC3\xB6nig" :
+ using_utf8() ? "Florian K\xC3\xB6nig" :
#endif
"Florian K\xF6nig";