Sorting the prev_word() and next_word() functions in the standard way:

the backward one first.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5661 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
Benno Schulenberg 2016-02-22 12:49:08 +00:00
parent 9d8c72951f
commit c115166f5b
3 changed files with 63 additions and 63 deletions

View File

@ -2,6 +2,8 @@
* src/nano.c (free_openfilestruct): Elide this function. * src/nano.c (free_openfilestruct): Elide this function.
* scr/global.c (thanks_for_all_the_fish, free_list_item): Condense. * scr/global.c (thanks_for_all_the_fish, free_list_item): Condense.
* src/winio.c (edit_scroll): The amount to scroll is never zero. * src/winio.c (edit_scroll): The amount to scroll is never zero.
* src/prompt.c (do_statusbar_prev_word, do_statusbar_next_word),
src/move.c (do_prev_word, do_next_word): Sort these in standard way.
2016-02-21 Benno Schulenberg <bensberg@justemail.net> 2016-02-21 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (input_tab): If the first Tab added the part that all * src/files.c (input_tab): If the first Tab added the part that all

View File

@ -215,63 +215,6 @@ void do_para_end_void(void)
#endif /* !DISABLE_JUSTIFY */ #endif /* !DISABLE_JUSTIFY */
#ifndef NANO_TINY #ifndef NANO_TINY
/* Move to the next word in the file. If allow_punct is TRUE, treat
* punctuation as part of a word. If allow_update is TRUE, update the
* screen afterwards. Return TRUE if we started on a word, and FALSE
* otherwise. */
bool do_next_word(bool allow_punct, bool allow_update)
{
size_t pww_save = openfile->placewewant;
filestruct *current_save = openfile->current;
bool started_on_word = is_word_mbchar(openfile->current->data +
openfile->current_x, allow_punct);
bool seen_space = !started_on_word;
assert(openfile->current != NULL && openfile->current->data != NULL);
/* Move forward until we reach the start of a word. */
while (TRUE) {
/* If at the end of a line, move to the beginning of the next one. */
if (openfile->current->data[openfile->current_x] == '\0') {
/* If at the end of the file, stop. */
if (openfile->current->next == NULL)
break;
openfile->current = openfile->current->next;
openfile->current_x = 0;
seen_space = TRUE;
} else {
/* Step forward one character. */
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x);
}
/* 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(openfile->current->data + openfile->current_x,
allow_punct))
seen_space = TRUE;
else if (seen_space)
break;
}
openfile->placewewant = xplustabs();
/* If allow_update is TRUE, update the screen. */
if (allow_update)
edit_redraw(current_save, pww_save);
/* Return whether we started on a word. */
return started_on_word;
}
/* Move to the next word in the file, treating punctuation as part of a
* word if the WORD_BOUNDS flag is set, and update the screen
* afterwards. */
void do_next_word_void(void)
{
do_next_word(ISSET(WORD_BOUNDS), TRUE);
}
/* Move to the previous word in the file. If allow_punct is TRUE, treat /* Move to the previous word in the file. If allow_punct is TRUE, treat
* punctuation as part of a word. If allow_update is TRUE, update the * punctuation as part of a word. If allow_update is TRUE, update the
* screen afterwards. */ * screen afterwards. */
@ -321,13 +264,68 @@ void do_prev_word(bool allow_punct, bool allow_update)
edit_redraw(current_save, pww_save); edit_redraw(current_save, pww_save);
} }
/* Move to the previous word in the file, treating punctuation as part /* Move to the previous word in the file, treating punctuation as part of a
* of a word if the WORD_BOUNDS flag is set, and update the screen * word if the WORD_BOUNDS flag is set, and update the screen afterwards. */
* afterwards. */
void do_prev_word_void(void) void do_prev_word_void(void)
{ {
do_prev_word(ISSET(WORD_BOUNDS), TRUE); do_prev_word(ISSET(WORD_BOUNDS), TRUE);
} }
/* Move to the next word in the file. If allow_punct is TRUE, treat
* punctuation as part of a word. If allow_update is TRUE, update the
* screen afterwards. Return TRUE if we started on a word, and FALSE
* otherwise. */
bool do_next_word(bool allow_punct, bool allow_update)
{
size_t pww_save = openfile->placewewant;
filestruct *current_save = openfile->current;
bool started_on_word = is_word_mbchar(openfile->current->data +
openfile->current_x, allow_punct);
bool seen_space = !started_on_word;
assert(openfile->current != NULL && openfile->current->data != NULL);
/* Move forward until we reach the start of a word. */
while (TRUE) {
/* If at the end of a line, move to the beginning of the next one. */
if (openfile->current->data[openfile->current_x] == '\0') {
/* If at the end of the file, stop. */
if (openfile->current->next == NULL)
break;
openfile->current = openfile->current->next;
openfile->current_x = 0;
seen_space = TRUE;
} else {
/* Step forward one character. */
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x);
}
/* 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(openfile->current->data + openfile->current_x,
allow_punct))
seen_space = TRUE;
else if (seen_space)
break;
}
openfile->placewewant = xplustabs();
/* If allow_update is TRUE, update the screen. */
if (allow_update)
edit_redraw(current_save, pww_save);
/* Return whether we started on a word. */
return started_on_word;
}
/* Move to the next word in the file, treating punctuation as part of a word
* if the WORD_BOUNDS flag is set, and update the screen afterwards. */
void do_next_word_void(void)
{
do_next_word(ISSET(WORD_BOUNDS), TRUE);
}
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
/* Move to the beginning of the current line. If the SMART_HOME flag is /* Move to the beginning of the current line. If the SMART_HOME flag is

View File

@ -399,10 +399,10 @@ void do_para_end(bool allow_update);
void do_para_end_void(void); void do_para_end_void(void);
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
bool do_next_word(bool allow_punct, bool allow_update);
void do_next_word_void(void);
void do_prev_word(bool allow_punct, bool allow_update); void do_prev_word(bool allow_punct, bool allow_update);
void do_prev_word_void(void); void do_prev_word_void(void);
bool do_next_word(bool allow_punct, bool allow_update);
void do_next_word_void(void);
#endif #endif
void do_home(void); void do_home(void);
void do_end(void); void do_end(void);
@ -524,8 +524,8 @@ void do_statusbar_backspace(void);
void do_statusbar_delete(void); void do_statusbar_delete(void);
void do_statusbar_cut_text(void); void do_statusbar_cut_text(void);
#ifndef NANO_TINY #ifndef NANO_TINY
void do_statusbar_next_word(void);
void do_statusbar_prev_word(void); void do_statusbar_prev_word(void);
void do_statusbar_next_word(void);
#endif #endif
void do_statusbar_verbatim_input(bool *got_enter); void do_statusbar_verbatim_input(bool *got_enter);
size_t statusbar_xplustabs(void); size_t statusbar_xplustabs(void);