From 157ce9120bfa4f50aa6f26f21f9d1fd5a2ff79cb Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Sat, 16 Jul 2005 23:36:10 +0000 Subject: [PATCH] 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 --- ChangeLog | 7 +++++++ src/nano.c | 4 +++- src/winio.c | 19 +++++++++---------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 87264452..de7a0295 100644 --- a/ChangeLog +++ b/ChangeLog @@ -85,6 +85,10 @@ CVS code - do_next_word() - Rework to be more like do_prev_word(), to avoid a potential 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() - If we can't invoke the spell checker, use sprintf() instead of snprintf() to write the error string we return, as the one @@ -142,6 +146,9 @@ CVS code - do_statusbar_next_word() - Rework to be more like do_statusbar_prev_word(), to avoid a 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 invalid multibyte sequences as Unicode 0xFFFD (Replacement Character). (DLR) diff --git a/src/nano.c b/src/nano.c index 7a5cbf0e..8ce2db67 100644 --- a/src/nano.c +++ b/src/nano.c @@ -4142,7 +4142,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) openfile->mark_begin_x += char_buf_len; #endif - do_right(FALSE); + openfile->current_x += char_buf_len; #ifndef DISABLE_WRAPPING /* 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) free(char_buf); + openfile->placewewant = xplustabs(); + if (do_refresh) edit_refresh(); else diff --git a/src/winio.c b/src/winio.c index e1dd6b52..5aa70392 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2139,7 +2139,7 @@ void do_statusbar_output(char *output, size_t output_len, bool strncpy(&answer[statusbar_x], char_buf, char_buf_len); answer_len += char_buf_len; - do_statusbar_right(); + statusbar_x += char_buf_len; } free(char_buf); @@ -3606,35 +3606,34 @@ void edit_redraw(const filestruct *old_current, size_t old_pww) /* Refresh the screen without changing the position of lines. */ void edit_refresh(void) { - int nlines = 0; - const filestruct *foo = openfile->edittop; + const filestruct *foo; + int nlines; if (openfile->current->lineno < openfile->edittop->lineno || openfile->current->lineno >= openfile->edittop->lineno + editwinrows) - /* Put the top line of the edit window in the range of the - * current line. */ + /* Put the top line of the edit window in range of the current + * line. */ edit_update( #ifndef NANO_SMALL ISSET(SMOOTH_SCROLL) ? NONE : #endif CENTER); + foo = openfile->edittop; + #ifdef DEBUG fprintf(stderr, "edit_refresh(): edittop->lineno = %ld\n", (long)openfile->edittop->lineno); #endif - while (nlines < editwinrows && foo != NULL) { + for (nlines = 0; nlines < editwinrows && foo != NULL; nlines++) { update_line(foo, (foo == openfile->current) ? openfile->current_x : 0); foo = foo->next; - nlines++; } - while (nlines < editwinrows) { + for (; nlines < editwinrows; nlines++) blank_line(edit, nlines, 0, COLS); - nlines++; - } reset_cursor(); wrefresh(edit);