tweaks: move some calls of edit_redraw() to where they are needed
Only when actually moving the cursor does the screen need to be redrawn, not when the wrapped functions are called in other places.master
parent
13a4f3130d
commit
d66a68166d
53
src/move.c
53
src/move.c
|
@ -170,12 +170,10 @@ void do_page_down(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_JUSTIFY
|
#ifdef ENABLE_JUSTIFY
|
||||||
/* Move to the beginning of the last beginning-of-paragraph line before the
|
/* Move to the beginning of the first-found beginning-of-paragraph line
|
||||||
* current line. If update_screen is TRUE, update the screen afterwards. */
|
* before the current line. */
|
||||||
void do_para_begin(bool update_screen)
|
void do_para_begin(bool update_screen)
|
||||||
{
|
{
|
||||||
filestruct *was_current = openfile->current;
|
|
||||||
|
|
||||||
if (openfile->current != openfile->fileage)
|
if (openfile->current != openfile->fileage)
|
||||||
openfile->current = openfile->current->prev;
|
openfile->current = openfile->current->prev;
|
||||||
|
|
||||||
|
@ -183,21 +181,15 @@ void do_para_begin(bool update_screen)
|
||||||
openfile->current = openfile->current->prev;
|
openfile->current = openfile->current->prev;
|
||||||
|
|
||||||
openfile->current_x = 0;
|
openfile->current_x = 0;
|
||||||
|
|
||||||
if (update_screen)
|
|
||||||
edit_redraw(was_current, CENTERING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move down to the beginning of the last line of the current paragraph.
|
/* Move down to the beginning of the last line of the current paragraph.
|
||||||
* Then move down one line farther if there is such a line, or to the
|
* Then move down one line farther if there is such a line, or to the
|
||||||
* end of the current line if not. If update_screen is TRUE, update the
|
* end of the current line if not. A line is the last line of a paragraph
|
||||||
* screen afterwards. A line is the last line of a paragraph if it is
|
* if it is in a paragraph, and the next line either is the beginning line
|
||||||
* in a paragraph, and the next line either is the beginning line of a
|
* of a paragraph or isn't in a paragraph. */
|
||||||
* paragraph or isn't in a paragraph. */
|
|
||||||
void do_para_end(bool update_screen)
|
void do_para_end(bool update_screen)
|
||||||
{
|
{
|
||||||
filestruct *was_current = openfile->current;
|
|
||||||
|
|
||||||
while (openfile->current != openfile->filebot &&
|
while (openfile->current != openfile->filebot &&
|
||||||
!inpar(openfile->current))
|
!inpar(openfile->current))
|
||||||
openfile->current = openfile->current->next;
|
openfile->current = openfile->current->next;
|
||||||
|
@ -213,21 +205,26 @@ void do_para_end(bool update_screen)
|
||||||
openfile->current_x = 0;
|
openfile->current_x = 0;
|
||||||
} else
|
} else
|
||||||
openfile->current_x = strlen(openfile->current->data);
|
openfile->current_x = strlen(openfile->current->data);
|
||||||
|
|
||||||
if (update_screen)
|
|
||||||
edit_redraw(was_current, CENTERING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move up to first start of a paragraph before the current line. */
|
/* Move up to first start of a paragraph before the current line. */
|
||||||
void do_para_begin_void(void)
|
void do_para_begin_void(void)
|
||||||
{
|
{
|
||||||
|
filestruct *was_current = openfile->current;
|
||||||
|
|
||||||
do_para_begin(TRUE);
|
do_para_begin(TRUE);
|
||||||
|
|
||||||
|
edit_redraw(was_current, CENTERING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move down to just after the first end of a paragraph. */
|
/* Move down to just after the first end of a paragraph. */
|
||||||
void do_para_end_void(void)
|
void do_para_end_void(void)
|
||||||
{
|
{
|
||||||
|
filestruct *was_current = openfile->current;
|
||||||
|
|
||||||
do_para_end(TRUE);
|
do_para_end(TRUE);
|
||||||
|
|
||||||
|
edit_redraw(was_current, CENTERING);
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_JUSTIFY */
|
#endif /* ENABLE_JUSTIFY */
|
||||||
|
|
||||||
|
@ -272,10 +269,9 @@ void do_next_block(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move to the previous word. If allow_punct is TRUE, treat punctuation
|
/* Move to the previous word. If allow_punct is TRUE, treat punctuation
|
||||||
* as part of a word. When requested, update the screen afterwards. */
|
* as part of a word. */
|
||||||
void do_prev_word(bool allow_punct, bool update_screen)
|
void do_prev_word(bool allow_punct, bool update_screen)
|
||||||
{
|
{
|
||||||
filestruct *was_current = openfile->current;
|
|
||||||
bool seen_a_word = FALSE, step_forward = FALSE;
|
bool seen_a_word = FALSE, step_forward = FALSE;
|
||||||
|
|
||||||
/* Move backward until we pass over the start of a word. */
|
/* Move backward until we pass over the start of a word. */
|
||||||
|
@ -309,18 +305,13 @@ void do_prev_word(bool allow_punct, bool update_screen)
|
||||||
/* Move one character forward again to sit on the start of the word. */
|
/* Move one character forward again to sit on the start of the word. */
|
||||||
openfile->current_x = move_mbright(openfile->current->data,
|
openfile->current_x = move_mbright(openfile->current->data,
|
||||||
openfile->current_x);
|
openfile->current_x);
|
||||||
|
|
||||||
if (update_screen)
|
|
||||||
edit_redraw(was_current, FLOWING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move to the next word. If after_ends is TRUE, stop at the ends of words
|
/* Move to the next word. If after_ends is TRUE, stop at the ends of words
|
||||||
* instead of their beginnings. If allow_punct is TRUE, treat punctuation
|
* instead of their beginnings. If allow_punct is TRUE, treat punctuation as
|
||||||
* as part of a word. When requested, update the screen afterwards.
|
* part of a word. Return TRUE if we started on a word, and FALSE otherwise. */
|
||||||
* Return TRUE if we started on a word, and FALSE otherwise. */
|
|
||||||
bool do_next_word(bool after_ends, bool allow_punct, bool update_screen)
|
bool do_next_word(bool after_ends, bool allow_punct, bool update_screen)
|
||||||
{
|
{
|
||||||
filestruct *was_current = openfile->current;
|
|
||||||
bool started_on_word = is_word_mbchar(openfile->current->data +
|
bool started_on_word = is_word_mbchar(openfile->current->data +
|
||||||
openfile->current_x, allow_punct);
|
openfile->current_x, allow_punct);
|
||||||
bool seen_space = !started_on_word;
|
bool seen_space = !started_on_word;
|
||||||
|
@ -366,10 +357,6 @@ bool do_next_word(bool after_ends, bool allow_punct, bool update_screen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update_screen)
|
|
||||||
edit_redraw(was_current, FLOWING);
|
|
||||||
|
|
||||||
/* Return whether we started on a word. */
|
|
||||||
return started_on_word;
|
return started_on_word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +364,11 @@ bool do_next_word(bool after_ends, bool allow_punct, bool update_screen)
|
||||||
* word if the WORD_BOUNDS flag is set, and update the screen afterwards. */
|
* word if the WORD_BOUNDS flag is set, and update the screen afterwards. */
|
||||||
void do_prev_word_void(void)
|
void do_prev_word_void(void)
|
||||||
{
|
{
|
||||||
|
filestruct *was_current = openfile->current;
|
||||||
|
|
||||||
do_prev_word(ISSET(WORD_BOUNDS), TRUE);
|
do_prev_word(ISSET(WORD_BOUNDS), TRUE);
|
||||||
|
|
||||||
|
edit_redraw(was_current, FLOWING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move to the next word in the file. If the AFTER_ENDS flag is set, stop
|
/* Move to the next word in the file. If the AFTER_ENDS flag is set, stop
|
||||||
|
@ -385,7 +376,11 @@ void do_prev_word_void(void)
|
||||||
* punctuation as part of a word. Update the screen afterwards. */
|
* punctuation as part of a word. Update the screen afterwards. */
|
||||||
void do_next_word_void(void)
|
void do_next_word_void(void)
|
||||||
{
|
{
|
||||||
|
filestruct *was_current = openfile->current;
|
||||||
|
|
||||||
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS), TRUE);
|
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS), TRUE);
|
||||||
|
|
||||||
|
edit_redraw(was_current, FLOWING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move to the beginning of the current line (or softwrapped chunk).
|
/* Move to the beginning of the current line (or softwrapped chunk).
|
||||||
|
|
Loading…
Reference in New Issue