commit d66a68166d31fb506b99d2fda37c21ced0feb11a
parent 13a4f3130d08b4e6cd611231a58b0396350c818c
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sun, 9 Sep 2018 20:33:27 +0200
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.
Diffstat:
M | src/move.c | | | 53 | ++++++++++++++++++++++++----------------------------- |
1 file changed, 24 insertions(+), 29 deletions(-)
diff --git a/src/move.c b/src/move.c
@@ -170,12 +170,10 @@ void do_page_down(void)
}
#ifdef ENABLE_JUSTIFY
-/* Move to the beginning of the last beginning-of-paragraph line before the
- * current line. If update_screen is TRUE, update the screen afterwards. */
+/* Move to the beginning of the first-found beginning-of-paragraph line
+ * before the current line. */
void do_para_begin(bool update_screen)
{
- filestruct *was_current = openfile->current;
-
if (openfile->current != openfile->fileage)
openfile->current = openfile->current->prev;
@@ -183,21 +181,15 @@ void do_para_begin(bool update_screen)
openfile->current = openfile->current->prev;
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.
* 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
- * screen afterwards. A line is the last line of a paragraph if it is
- * in a paragraph, and the next line either is the beginning line of a
- * paragraph or isn't in a paragraph. */
+ * end of the current line if not. A line is the last line of a paragraph
+ * if it is in a paragraph, and the next line either is the beginning line
+ * of a paragraph or isn't in a paragraph. */
void do_para_end(bool update_screen)
{
- filestruct *was_current = openfile->current;
-
while (openfile->current != openfile->filebot &&
!inpar(openfile->current))
openfile->current = openfile->current->next;
@@ -213,21 +205,26 @@ void do_para_end(bool update_screen)
openfile->current_x = 0;
} else
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. */
void do_para_begin_void(void)
{
+ filestruct *was_current = openfile->current;
+
do_para_begin(TRUE);
+
+ edit_redraw(was_current, CENTERING);
}
/* Move down to just after the first end of a paragraph. */
void do_para_end_void(void)
{
+ filestruct *was_current = openfile->current;
+
do_para_end(TRUE);
+
+ edit_redraw(was_current, CENTERING);
}
#endif /* ENABLE_JUSTIFY */
@@ -272,10 +269,9 @@ void do_next_block(void)
}
/* 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)
{
- filestruct *was_current = openfile->current;
bool seen_a_word = FALSE, step_forward = FALSE;
/* 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. */
openfile->current_x = move_mbright(openfile->current->data,
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
- * instead of their beginnings. If allow_punct is TRUE, treat punctuation
- * as part of a word. When requested, update the screen afterwards.
- * Return TRUE if we started on a word, and FALSE otherwise. */
+ * instead of their beginnings. If allow_punct is TRUE, treat punctuation as
+ * part of a word. Return TRUE if we started on a word, and FALSE otherwise. */
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 +
openfile->current_x, allow_punct);
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;
}
@@ -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. */
void do_prev_word_void(void)
{
+ filestruct *was_current = openfile->current;
+
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
@@ -385,7 +376,11 @@ void do_prev_word_void(void)
* punctuation as part of a word. Update the screen afterwards. */
void do_next_word_void(void)
{
+ filestruct *was_current = openfile->current;
+
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).