Commit 157ce912 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

speed up character output, and fix edit_refresh() breakage

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2877 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 19 additions and 11 deletions
+19 -11
...@@ -85,6 +85,10 @@ CVS code - ...@@ -85,6 +85,10 @@ CVS code -
do_next_word() do_next_word()
- Rework to be more like do_prev_word(), to avoid a potential - Rework to be more like do_prev_word(), to avoid a potential
problem if we start at the end of a line. (DLR) problem if we start at the end of a line. (DLR)
do_output()
- When adding a character, just add its length in bytes to
current_x instead of calling do_right(), and set placewewant
afterward. (DLR)
do_alt_speller() do_alt_speller()
- If we can't invoke the spell checker, use sprintf() instead of - If we can't invoke the spell checker, use sprintf() instead of
snprintf() to write the error string we return, as the one snprintf() to write the error string we return, as the one
...@@ -142,6 +146,9 @@ CVS code - ...@@ -142,6 +146,9 @@ CVS code -
do_statusbar_next_word() do_statusbar_next_word()
- Rework to be more like do_statusbar_prev_word(), to avoid a - Rework to be more like do_statusbar_prev_word(), to avoid a
potential problem if we start at the end of a line. (DLR) potential problem if we start at the end of a line. (DLR)
do_statusbar_output()
- When adding a character, just add its length in bytes to
statusbar_x instead of calling do_statusbar_right(). (DLR)
display_string() display_string()
- Display invalid multibyte sequences as Unicode 0xFFFD - Display invalid multibyte sequences as Unicode 0xFFFD
(Replacement Character). (DLR) (Replacement Character). (DLR)
......
...@@ -4142,7 +4142,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) ...@@ -4142,7 +4142,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
openfile->mark_begin_x += char_buf_len; openfile->mark_begin_x += char_buf_len;
#endif #endif
do_right(FALSE); openfile->current_x += char_buf_len;
#ifndef DISABLE_WRAPPING #ifndef DISABLE_WRAPPING
/* If we're wrapping text, we need to call edit_refresh(). */ /* If we're wrapping text, we need to call edit_refresh(). */
...@@ -4173,6 +4173,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) ...@@ -4173,6 +4173,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
free(char_buf); free(char_buf);
openfile->placewewant = xplustabs();
if (do_refresh) if (do_refresh)
edit_refresh(); edit_refresh();
else else
......
...@@ -2139,7 +2139,7 @@ void do_statusbar_output(char *output, size_t output_len, bool ...@@ -2139,7 +2139,7 @@ void do_statusbar_output(char *output, size_t output_len, bool
strncpy(&answer[statusbar_x], char_buf, char_buf_len); strncpy(&answer[statusbar_x], char_buf, char_buf_len);
answer_len += char_buf_len; answer_len += char_buf_len;
do_statusbar_right(); statusbar_x += char_buf_len;
} }
free(char_buf); free(char_buf);
...@@ -3606,35 +3606,34 @@ void edit_redraw(const filestruct *old_current, size_t old_pww) ...@@ -3606,35 +3606,34 @@ void edit_redraw(const filestruct *old_current, size_t old_pww)
/* Refresh the screen without changing the position of lines. */ /* Refresh the screen without changing the position of lines. */
void edit_refresh(void) void edit_refresh(void)
{ {
int nlines = 0; const filestruct *foo;
const filestruct *foo = openfile->edittop; int nlines;
if (openfile->current->lineno < openfile->edittop->lineno || if (openfile->current->lineno < openfile->edittop->lineno ||
openfile->current->lineno >= openfile->edittop->lineno + openfile->current->lineno >= openfile->edittop->lineno +
editwinrows) editwinrows)
/* Put the top line of the edit window in the range of the /* Put the top line of the edit window in range of the current
* current line. */ * line. */
edit_update( edit_update(
#ifndef NANO_SMALL #ifndef NANO_SMALL
ISSET(SMOOTH_SCROLL) ? NONE : ISSET(SMOOTH_SCROLL) ? NONE :
#endif #endif
CENTER); CENTER);
foo = openfile->edittop;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "edit_refresh(): edittop->lineno = %ld\n", (long)openfile->edittop->lineno); fprintf(stderr, "edit_refresh(): edittop->lineno = %ld\n", (long)openfile->edittop->lineno);
#endif #endif
while (nlines < editwinrows && foo != NULL) { for (nlines = 0; nlines < editwinrows && foo != NULL; nlines++) {
update_line(foo, (foo == openfile->current) ? update_line(foo, (foo == openfile->current) ?
openfile->current_x : 0); openfile->current_x : 0);
foo = foo->next; foo = foo->next;
nlines++;
} }
while (nlines < editwinrows) { for (; nlines < editwinrows; nlines++)
blank_line(edit, nlines, 0, COLS); blank_line(edit, nlines, 0, COLS);
nlines++;
}
reset_cursor(); reset_cursor();
wrefresh(edit); wrefresh(edit);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment