nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 5d5666fba6205b84b49581d2c78cc1d392104698
parent 980e334e3711e0f663efd893da1bcc3f23ee2a5c
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Fri, 13 Jan 2017 19:18:08 +0100

tweaks: swap two blocks of code to reduce the number of #ifdefs

Diffstat:
Msrc/winio.c | 42++++++++++++++++++++----------------------
1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/src/winio.c b/src/winio.c @@ -2689,28 +2689,7 @@ int update_line(filestruct *fileptr, size_t index) return 0; #ifndef NANO_TINY - if (!ISSET(SOFTWRAP)) { -#endif - /* First, blank out the row. */ - blank_row(edit, row, 0, COLS); - - /* Next, find out from which column to start displaying the line. */ - from_col = get_page_start(strnlenpt(fileptr->data, index)); - - /* Expand the line, replacing tabs with spaces, and control - * characters with their displayed forms. */ - converted = display_string(fileptr->data, from_col, editwincols, TRUE); - - /* Draw the line. */ - edit_draw(fileptr, converted, row, from_col); - free(converted); - - if (from_col > 0) - mvwaddch(edit, row, margin, '$'); - if (strlenpt(fileptr->data) > from_col + editwincols) - mvwaddch(edit, row, COLS - 1, '$'); -#ifndef NANO_TINY - } else { + if (ISSET(SOFTWRAP)) { size_t full_length = strlenpt(fileptr->data); for (from_col = 0; from_col <= full_length && @@ -2733,6 +2712,25 @@ int update_line(filestruct *fileptr, size_t index) } #endif + /* First, blank out the row. */ + blank_row(edit, row, 0, COLS); + + /* Next, find out from which column to start displaying the line. */ + from_col = get_page_start(strnlenpt(fileptr->data, index)); + + /* Expand the line, replacing tabs with spaces, and control + * characters with their displayed forms. */ + converted = display_string(fileptr->data, from_col, editwincols, TRUE); + + /* Draw the line. */ + edit_draw(fileptr, converted, row, from_col); + free(converted); + + if (from_col > 0) + mvwaddch(edit, row, margin, '$'); + if (strlenpt(fileptr->data) > from_col + editwincols) + mvwaddch(edit, row, COLS - 1, '$'); + return 0; }