fix multibyte bracket search breakage, and add documentation fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3261 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
1a16df9284
commit
db2dc81cee
|
@ -79,8 +79,9 @@ strings.
|
||||||
.TP
|
.TP
|
||||||
.B set matchbrackets "\fIstring\fP"
|
.B set matchbrackets "\fIstring\fP"
|
||||||
Set the opening and closing brackets that can be found by bracket
|
Set the opening and closing brackets that can be found by bracket
|
||||||
searches. The former set must come before the latter set, and both must
|
searches. They cannot contain blank characters. The former set must
|
||||||
be in the same order. The default value is "\fI(<[{)>]}\fP".
|
come before the latter set, and both must be in the same order. The
|
||||||
|
default value is "\fI(<[{)>]}\fP".
|
||||||
.TP
|
.TP
|
||||||
.B set/unset morespace
|
.B set/unset morespace
|
||||||
Allow use of the blank line below the titlebar as extra editing space.
|
Allow use of the blank line below the titlebar as extra editing space.
|
||||||
|
|
|
@ -46,8 +46,8 @@
|
||||||
# set historylog
|
# set historylog
|
||||||
|
|
||||||
## The opening and closing brackets that can be found by bracket
|
## The opening and closing brackets that can be found by bracket
|
||||||
## searches. The former set must come before the latter set, and both
|
## searches. They cannot contain blank characters. The former set must
|
||||||
## must be in the same order.
|
## come before the latter set, and both must be in the same order.
|
||||||
##
|
##
|
||||||
# set matchbrackets "(<[{)>]}"
|
# set matchbrackets "(<[{)>]}"
|
||||||
|
|
||||||
|
|
20
src/prompt.c
20
src/prompt.c
|
@ -723,8 +723,14 @@ void do_statusbar_find_bracket(void)
|
||||||
/* The length of wanted_ch in bytes. */
|
/* The length of wanted_ch in bytes. */
|
||||||
char *bracket_set;
|
char *bracket_set;
|
||||||
/* The pair of characters in ch and wanted_ch. */
|
/* The pair of characters in ch and wanted_ch. */
|
||||||
|
size_t i;
|
||||||
|
/* Generic loop variable. */
|
||||||
size_t matchhalf;
|
size_t matchhalf;
|
||||||
/* The number of characters in one half of matchbrackets. */
|
/* The number of single-byte characters in one half of
|
||||||
|
* matchbrackets. */
|
||||||
|
size_t mbmatchhalf;
|
||||||
|
/* The number of multibyte characters in one half of
|
||||||
|
* matchbrackets. */
|
||||||
size_t count = 1;
|
size_t count = 1;
|
||||||
/* The initial bracket count. */
|
/* The initial bracket count. */
|
||||||
bool reverse;
|
bool reverse;
|
||||||
|
@ -748,7 +754,13 @@ void do_statusbar_find_bracket(void)
|
||||||
* bracket. If we're on a closing bracket, which must be in the
|
* bracket. If we're on a closing bracket, which must be in the
|
||||||
* second half of matchbrackets, we want to search backwards for an
|
* second half of matchbrackets, we want to search backwards for an
|
||||||
* opening bracket. */
|
* opening bracket. */
|
||||||
matchhalf = mbstrlen(matchbrackets) / 2;
|
matchhalf = 0;
|
||||||
|
mbmatchhalf = mbstrlen(matchbrackets) / 2;
|
||||||
|
|
||||||
|
for (i = 0; i < mbmatchhalf; i++)
|
||||||
|
matchhalf += parse_mbchar(matchbrackets + matchhalf, NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
reverse = ((ch - matchbrackets) > matchhalf);
|
reverse = ((ch - matchbrackets) > matchhalf);
|
||||||
|
|
||||||
/* If we're on an opening bracket, set wanted_ch to the character
|
/* If we're on an opening bracket, set wanted_ch to the character
|
||||||
|
@ -757,14 +769,14 @@ void do_statusbar_find_bracket(void)
|
||||||
* characters before ch. */
|
* characters before ch. */
|
||||||
wanted_ch = ch;
|
wanted_ch = ch;
|
||||||
|
|
||||||
while (matchhalf > 0) {
|
while (mbmatchhalf > 0) {
|
||||||
if (reverse)
|
if (reverse)
|
||||||
wanted_ch = matchbrackets + move_mbleft(matchbrackets,
|
wanted_ch = matchbrackets + move_mbleft(matchbrackets,
|
||||||
wanted_ch - matchbrackets);
|
wanted_ch - matchbrackets);
|
||||||
else
|
else
|
||||||
wanted_ch += move_mbright(wanted_ch, 0);
|
wanted_ch += move_mbright(wanted_ch, 0);
|
||||||
|
|
||||||
matchhalf--;
|
mbmatchhalf--;
|
||||||
}
|
}
|
||||||
|
|
||||||
ch_len = parse_mbchar(ch, NULL, NULL);
|
ch_len = parse_mbchar(ch, NULL, NULL);
|
||||||
|
|
20
src/search.c
20
src/search.c
|
@ -1142,8 +1142,14 @@ void do_find_bracket(void)
|
||||||
/* The length of wanted_ch in bytes. */
|
/* The length of wanted_ch in bytes. */
|
||||||
char *bracket_set;
|
char *bracket_set;
|
||||||
/* The pair of characters in ch and wanted_ch. */
|
/* The pair of characters in ch and wanted_ch. */
|
||||||
|
size_t i;
|
||||||
|
/* Generic loop variable. */
|
||||||
size_t matchhalf;
|
size_t matchhalf;
|
||||||
/* The number of characters in one half of matchbrackets. */
|
/* The number of single-byte characters in one half of
|
||||||
|
* matchbrackets. */
|
||||||
|
size_t mbmatchhalf;
|
||||||
|
/* The number of multibyte characters in one half of
|
||||||
|
* matchbrackets. */
|
||||||
size_t count = 1;
|
size_t count = 1;
|
||||||
/* The initial bracket count. */
|
/* The initial bracket count. */
|
||||||
bool reverse;
|
bool reverse;
|
||||||
|
@ -1170,7 +1176,13 @@ void do_find_bracket(void)
|
||||||
* bracket. If we're on a closing bracket, which must be in the
|
* bracket. If we're on a closing bracket, which must be in the
|
||||||
* second half of matchbrackets, we want to search backwards for an
|
* second half of matchbrackets, we want to search backwards for an
|
||||||
* opening bracket. */
|
* opening bracket. */
|
||||||
matchhalf = mbstrlen(matchbrackets) / 2;
|
matchhalf = 0;
|
||||||
|
mbmatchhalf = mbstrlen(matchbrackets) / 2;
|
||||||
|
|
||||||
|
for (i = 0; i < mbmatchhalf; i++)
|
||||||
|
matchhalf += parse_mbchar(matchbrackets + matchhalf, NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
reverse = ((ch - matchbrackets) > matchhalf);
|
reverse = ((ch - matchbrackets) > matchhalf);
|
||||||
|
|
||||||
/* If we're on an opening bracket, set wanted_ch to the character
|
/* If we're on an opening bracket, set wanted_ch to the character
|
||||||
|
@ -1179,14 +1191,14 @@ void do_find_bracket(void)
|
||||||
* characters before ch. */
|
* characters before ch. */
|
||||||
wanted_ch = ch;
|
wanted_ch = ch;
|
||||||
|
|
||||||
while (matchhalf > 0) {
|
while (mbmatchhalf > 0) {
|
||||||
if (reverse)
|
if (reverse)
|
||||||
wanted_ch = matchbrackets + move_mbleft(matchbrackets,
|
wanted_ch = matchbrackets + move_mbleft(matchbrackets,
|
||||||
wanted_ch - matchbrackets);
|
wanted_ch - matchbrackets);
|
||||||
else
|
else
|
||||||
wanted_ch += move_mbright(wanted_ch, 0);
|
wanted_ch += move_mbright(wanted_ch, 0);
|
||||||
|
|
||||||
matchhalf--;
|
mbmatchhalf--;
|
||||||
}
|
}
|
||||||
|
|
||||||
ch_len = parse_mbchar(ch, NULL, NULL);
|
ch_len = parse_mbchar(ch, NULL, NULL);
|
||||||
|
|
Loading…
Reference in New Issue