From cbab273a0845b6c186c91ec7fbea5ff2d5535afd Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Wed, 2 Aug 2006 18:38:45 +0000 Subject: [PATCH] in edit_draw(), simplify the setting of paintlen git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3833 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 2 ++ src/winio.c | 41 +++++++++++++++++------------------------ 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index df7c84f3..cd82f194 100644 --- a/ChangeLog +++ b/ChangeLog @@ -178,6 +178,8 @@ CVS code - display_string() - Properly handle buf[start_index]'s being a null terminator. (DLR) + edit_draw() + - Simplify the setting of paintlen. (DLR) titlebar() - Don't display overly long filenames with ellipses if the number of columns is extremely small. (DLR) diff --git a/src/winio.c b/src/winio.c index c0201c55..7ab1a123 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2504,19 +2504,16 @@ void edit_draw(const filestruct *fileptr, const char *converted, int endmatch.rm_eo <= startpos)) goto step_two; - /* Now paint the start of fileptr. */ - if (end_line != fileptr) - /* If the start of fileptr is on a different - * line from the end, paintlen is -1, meaning - * that everything on the line gets painted. */ - paintlen = -1; - else - /* Otherwise, paintlen is the expanded location - * of the end of the match minus the expanded - * location of the beginning of the page. */ - paintlen = actual_x(converted, - strnlenpt(fileptr->data, - endmatch.rm_eo) - start); + /* Now paint the start of fileptr. If the start of + * fileptr is on a different line from the end, + * paintlen is -1, meaning that everything on the + * line gets painted. Otherwise, paintlen is the + * expanded location of the end of the match minus + * the expanded location of the beginning of the + * page. */ + paintlen = (end_line != fileptr) ? -1 : + actual_x(converted, strnlenpt(fileptr->data, + endmatch.rm_eo) - start); mvwaddnstr(edit, line, 0, converted, paintlen); @@ -2635,17 +2632,13 @@ void edit_draw(const filestruct *fileptr, const char *converted, int * mark minus the beginning of the page. */ x_start = strnlenpt(fileptr->data, top_x) - start; - if (bot_x >= endpos) - /* If the end of the mark is off the page, paintlen is - * -1, meaning that everything on the line gets - * painted. */ - paintlen = -1; - else - /* Otherwise, paintlen is the expanded location of the - * end of the mark minus the expanded location of the - * beginning of the mark. */ - paintlen = strnlenpt(fileptr->data, bot_x) - - (x_start + start); + /* If the end of the mark is off the page, paintlen is -1, + * meaning that everything on the line gets painted. + * Otherwise, paintlen is the expanded location of the end + * of the mark minus the expanded location of the beginning + * of the mark. */ + paintlen = (bot_x >= endpos) ? -1 : strnlenpt(fileptr->data, + bot_x) - (x_start + start); /* If x_start is before the beginning of the page, shift * paintlen x_start characters to compensate, and put -- 2.39.5