mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-25 06:09:38 +03:00
Using a simpler algorithm for jumping to the next word.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5595 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
5688c160a9
commit
a93a11eb42
@ -5,6 +5,7 @@
|
||||
* src/prompt.c (do_statusbar_prev_word): When in the middle of a
|
||||
word, jump to the start of the current word, not to the start of
|
||||
the preceding one. This fixes Savannah bug #46970.
|
||||
* src/prompt.c (do_statusbar_next_word): Use simpler algorithm.
|
||||
|
||||
2016-01-25 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/files.c (update_poshistory): Handle an update of the first
|
||||
|
48
src/prompt.c
48
src/prompt.c
@ -420,52 +420,22 @@ void do_statusbar_cut_text(void)
|
||||
/* Move to the next word in the prompt text. */
|
||||
void do_statusbar_next_word(void)
|
||||
{
|
||||
char *char_mb;
|
||||
int char_mb_len;
|
||||
bool end_line = FALSE;
|
||||
bool seen_space = !is_word_mbchar(answer + statusbar_x, FALSE);
|
||||
|
||||
assert(answer != NULL);
|
||||
|
||||
char_mb = charalloc(mb_cur_max());
|
||||
/* Move forward until we reach the start of a word. */
|
||||
while (answer[statusbar_x] != '\0') {
|
||||
statusbar_x = move_mbright(answer, statusbar_x);
|
||||
|
||||
/* Move forward until we find the character after the last letter of
|
||||
* the current word. */
|
||||
while (!end_line) {
|
||||
char_mb_len = parse_mbchar(answer + statusbar_x, char_mb, NULL);
|
||||
|
||||
/* If we've found it, stop moving forward through the current
|
||||
* line. */
|
||||
if (!is_word_mbchar(char_mb, FALSE))
|
||||
/* If this is not a word character, then it's a separator; else
|
||||
* if we've already seen a separator, then it's a word start. */
|
||||
if (!is_word_mbchar(answer + statusbar_x, FALSE))
|
||||
seen_space = TRUE;
|
||||
else if (seen_space)
|
||||
break;
|
||||
|
||||
if (answer[statusbar_x] == '\0')
|
||||
end_line = TRUE;
|
||||
else
|
||||
statusbar_x += char_mb_len;
|
||||
}
|
||||
|
||||
/* Move forward until we find the first letter of the next word. */
|
||||
if (answer[statusbar_x] == '\0')
|
||||
end_line = TRUE;
|
||||
else
|
||||
statusbar_x += char_mb_len;
|
||||
|
||||
while (!end_line) {
|
||||
char_mb_len = parse_mbchar(answer + statusbar_x, char_mb, NULL);
|
||||
|
||||
/* If we've found it, stop moving forward through the current
|
||||
* line. */
|
||||
if (is_word_mbchar(char_mb, FALSE))
|
||||
break;
|
||||
|
||||
if (answer[statusbar_x] == '\0')
|
||||
end_line = TRUE;
|
||||
else
|
||||
statusbar_x += char_mb_len;
|
||||
}
|
||||
|
||||
free(char_mb);
|
||||
|
||||
update_the_bar();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user