make whitespace display mode work with multibyte characters
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2346 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
202d3c2f97
commit
6e60db6989
|
@ -171,6 +171,10 @@ CVS code -
|
||||||
parse_syntax(), parse_colors(), parse_rcfile(), do_rcfile(),
|
parse_syntax(), parse_colors(), parse_rcfile(), do_rcfile(),
|
||||||
etc. (David Benbennick) DLR: Rename colortoint() to
|
etc. (David Benbennick) DLR: Rename colortoint() to
|
||||||
color_to_int(), and add a few miscellaneous tweaks.
|
color_to_int(), and add a few miscellaneous tweaks.
|
||||||
|
- Still more steps toward full wide/multibyte character support.
|
||||||
|
Make whitespace display mode work with multibyte characters,
|
||||||
|
and add a few related documentation updates. Changes to
|
||||||
|
do_help(), main(), parse_rcfile(), and display_string(). (DLR)
|
||||||
- cut.c:
|
- cut.c:
|
||||||
do_cut_text()
|
do_cut_text()
|
||||||
- If keep_cutbuffer is FALSE, only blow away the text in the
|
- If keep_cutbuffer is FALSE, only blow away the text in the
|
||||||
|
@ -325,6 +329,9 @@ CVS code -
|
||||||
Piefel)
|
Piefel)
|
||||||
- Add the "morespace" option. (DLR)
|
- Add the "morespace" option. (DLR)
|
||||||
- Add support for characters to the "c-file" regexes. (DLR)
|
- Add support for characters to the "c-file" regexes. (DLR)
|
||||||
|
- Add the hexadecimal equivalents of the decimal values
|
||||||
|
suggested for whitespace display, now that it can handle
|
||||||
|
multibyte characters. (DLR)
|
||||||
- nano.1. nanorc.5, nano.texi:
|
- nano.1. nanorc.5, nano.texi:
|
||||||
- Add the "morespace" option, and sync with the descriptions in
|
- Add the "morespace" option, and sync with the descriptions in
|
||||||
nanorc.sample in a few places. (DLR)
|
nanorc.sample in a few places. (DLR)
|
||||||
|
|
|
@ -118,11 +118,12 @@
|
||||||
## Save automatically on exit, don't prompt.
|
## Save automatically on exit, don't prompt.
|
||||||
# set tempfile
|
# set tempfile
|
||||||
|
|
||||||
## Disallow file modification, why would you want this in an rc file? ;)
|
## Disallow file modification; why would you want this in an rcfile? ;)
|
||||||
# set view
|
# set view
|
||||||
|
|
||||||
## The two characters used to display the first characters of tabs and
|
## The two characters used to display the first characters of tabs and
|
||||||
## spaces. 187 and 183 seem to be good values for these.
|
## spaces. 187 decimal (00BB hexadecimal) and 183 decimal (00B7
|
||||||
|
## hexadecimal) seem to be good values for these.
|
||||||
# set whitespace " "
|
# set whitespace " "
|
||||||
|
|
||||||
## Color setup
|
## Color setup
|
||||||
|
|
|
@ -78,6 +78,7 @@ openfilestruct *open_files = NULL; /* The list of open file
|
||||||
char *whitespace = NULL; /* Characters used when displaying
|
char *whitespace = NULL; /* Characters used when displaying
|
||||||
the first characters of tabs and
|
the first characters of tabs and
|
||||||
spaces. */
|
spaces. */
|
||||||
|
int whitespace_len[2]; /* The length of the characters. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
|
|
13
src/nano.c
13
src/nano.c
|
@ -380,10 +380,10 @@ void help_init(void)
|
||||||
"Esc key twice. Escape-key sequences are notated with the Meta "
|
"Esc key twice. Escape-key sequences are notated with the Meta "
|
||||||
"(M) symbol and can be entered using either the Esc, Alt or "
|
"(M) symbol and can be entered using either the Esc, Alt or "
|
||||||
"Meta key depending on your keyboard setup. Also, pressing Esc "
|
"Meta key depending on your keyboard setup. Also, pressing Esc "
|
||||||
"twice and then typing a three-digit number from 000 to 255 "
|
"twice and then typing a three-digit decimal number from 000 to "
|
||||||
"will enter the character with the corresponding value. The "
|
" 255 will enter the character with the corresponding value. "
|
||||||
"following keystrokes are available in the main editor window. "
|
"The following keystrokes are available in the main editor "
|
||||||
"Alternative keys are shown in parentheses:\n\n");
|
" window. Alternative keys are shown in parentheses:\n\n");
|
||||||
|
|
||||||
htx = _(htx);
|
htx = _(htx);
|
||||||
|
|
||||||
|
@ -4271,8 +4271,11 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
||||||
/* If whitespace wasn't specified, set its default value. */
|
/* If whitespace wasn't specified, set its default value. */
|
||||||
if (whitespace == NULL)
|
if (whitespace == NULL) {
|
||||||
whitespace = mallocstrcpy(NULL, " ");
|
whitespace = mallocstrcpy(NULL, " ");
|
||||||
|
whitespace_len[0] = 1;
|
||||||
|
whitespace_len[1] = 1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If tabsize wasn't specified, set its default value. */
|
/* If tabsize wasn't specified, set its default value. */
|
||||||
|
|
|
@ -47,6 +47,7 @@ extern int currslen;
|
||||||
|
|
||||||
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
||||||
extern char *whitespace;
|
extern char *whitespace;
|
||||||
|
extern int whitespace_len[2];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_JUSTIFY
|
#ifndef DISABLE_JUSTIFY
|
||||||
|
|
21
src/rcfile.c
21
src/rcfile.c
|
@ -570,13 +570,24 @@ void parse_rcfile(FILE *rcstream)
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (strcasecmp(rcopts[i].name, "whitespace") == 0) {
|
if (strcasecmp(rcopts[i].name, "whitespace") == 0) {
|
||||||
size_t ws_len;
|
/* We use display_string() here so that any
|
||||||
whitespace = mallocstrcpy(NULL, option);
|
* invalid multibyte characters in option
|
||||||
ws_len = strlen(whitespace);
|
* will be converted to valid multibyte
|
||||||
if (ws_len != 2 || (ws_len == 2 && (is_cntrl_char(whitespace[0]) || is_cntrl_char(whitespace[1])))) {
|
* characters in whitespace. */
|
||||||
rcfile_error(N_("Two non-control characters required"));
|
whitespace = display_string(option, 0, 3, FALSE);
|
||||||
|
|
||||||
|
if (mbstrlen(whitespace) != 2 || strlenpt(whitespace) != 2) {
|
||||||
|
rcfile_error(N_("Two single-column characters required"));
|
||||||
free(whitespace);
|
free(whitespace);
|
||||||
whitespace = NULL;
|
whitespace = NULL;
|
||||||
|
} else {
|
||||||
|
whitespace_len[0] =
|
||||||
|
parse_mbchar(whitespace, NULL,
|
||||||
|
NULL, NULL);
|
||||||
|
whitespace_len[1] =
|
||||||
|
parse_mbchar(whitespace +
|
||||||
|
whitespace_len[0], NULL,
|
||||||
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
21
src/winio.c
21
src/winio.c
|
@ -2278,11 +2278,15 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (*buf_mb == '\t') {
|
if (*buf_mb == '\t') {
|
||||||
converted[index++] =
|
|
||||||
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
||||||
ISSET(WHITESPACE_DISPLAY) ? whitespace[0] :
|
if (ISSET(WHITESPACE_DISPLAY)) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < whitespace_len[0]; i++)
|
||||||
|
converted[index++] = whitespace[i];
|
||||||
|
} else
|
||||||
#endif
|
#endif
|
||||||
' ';
|
converted[index++] = ' ';
|
||||||
start_col++;
|
start_col++;
|
||||||
while (start_col % tabsize != 0) {
|
while (start_col % tabsize != 0) {
|
||||||
converted[index++] = ' ';
|
converted[index++] = ' ';
|
||||||
|
@ -2308,11 +2312,16 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
|
||||||
|
|
||||||
free(ctrl_buf_mb);
|
free(ctrl_buf_mb);
|
||||||
} else if (*buf_mb == ' ') {
|
} else if (*buf_mb == ' ') {
|
||||||
converted[index++] =
|
|
||||||
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
|
||||||
ISSET(WHITESPACE_DISPLAY) ? whitespace[1] :
|
if (ISSET(WHITESPACE_DISPLAY)) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = whitespace_len[0]; i < whitespace_len[0] +
|
||||||
|
whitespace_len[1]; i++)
|
||||||
|
converted[index++] = whitespace[i];
|
||||||
|
} else
|
||||||
#endif
|
#endif
|
||||||
' ';
|
converted[index++] = ' ';
|
||||||
start_col++;
|
start_col++;
|
||||||
} else {
|
} else {
|
||||||
int i;
|
int i;
|
||||||
|
|
Loading…
Reference in New Issue