From 699cacf7a4ef90224095ac2dcd9e052b8f74865c Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 25 Jun 2019 11:57:15 +0200 Subject: [PATCH] display: don't clear a row beforehand -- just clear the remainder It is a waste of time to first fully clear a row when right afterward text will be written to it (for most of the row, on average). So... just clear the part of the row after the written text. Curses has the perfect function for this: clrtoeol(). --- src/winio.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/winio.c b/src/winio.c index e410a614..78010f21 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2427,9 +2427,6 @@ void edit_draw(linestruct *fileptr, const char *converted, * might be beyond the null terminator of the string. */ #endif - /* Wipe out any existing text on the row. */ - blank_row(edit, row); - #ifdef ENABLE_LINENUMBERS /* If line numbering is switched on, put a line number in front of * the text -- but only for the parts that are not softwrapped. */ @@ -2437,10 +2434,10 @@ void edit_draw(linestruct *fileptr, const char *converted, wattron(edit, interface_color_pair[LINE_NUMBER]); #ifndef NANO_TINY if (ISSET(SOFTWRAP) && from_col != 0) - mvwprintw(edit, row, 0, "%*s", margin - 1, " "); + mvwprintw(edit, row, 0, "%*s", margin, " "); else #endif - mvwprintw(edit, row, 0, "%*zd", margin - 1, fileptr->lineno); + mvwprintw(edit, row, 0, "%*zd ", margin - 1, fileptr->lineno); wattroff(edit, interface_color_pair[LINE_NUMBER]); } #endif @@ -2448,6 +2445,7 @@ void edit_draw(linestruct *fileptr, const char *converted, /* First simply write the converted line -- afterward we'll add colors * and the marking highlight on just the pieces that need it. */ mvwaddstr(edit, row, margin, converted); + wclrtoeol(edit); #ifdef USING_OLD_NCURSES /* Tell ncurses to really redraw the line without trying to optimize