nano

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

commit dd08b638c1e30fd3ef04e7ad8ec22c955a500ffc
parent 93152d325842df61936d58dead79f4e8dd68e00f
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Tue,  7 Mar 2017 16:54:40 -0600

softwrap: account for softwrapped chunks when adding text

Now that we can add text to the bottom right corner of the screen
without scrolling the full line onscreen, do_output() needs to refresh
the screen in that case, since it would put the cursor offscreen
otherwise.  Accomplish this by borrowing logic from do_right().

Diffstat:
Msrc/nano.c | 17++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/nano.c b/src/nano.c @@ -1811,7 +1811,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) { size_t current_len, i = 0; #ifndef NANO_TINY - size_t orig_rows = 0; + size_t orig_rows = 0, original_row = 0; #endif char *char_buf = charalloc(mb_cur_max()); int char_len; @@ -1819,8 +1819,11 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) current_len = strlen(openfile->current->data); #ifndef NANO_TINY - if (ISSET(SOFTWRAP)) + if (ISSET(SOFTWRAP)) { + if (openfile->current_y == editwinrows - 1) + original_row = xplustabs() / editwincols; orig_rows = strlenpt(openfile->current->data) / editwincols; + } #endif while (i < output_len) { @@ -1881,10 +1884,14 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) } #ifndef NANO_TINY - /* If the number of screen rows that a softwrapped line occupies - * has changed, we need a full refresh. */ + /* If the number of screen rows that a softwrapped line occupies has + * changed, we need a full refresh. And if we were on the last line + * of the edit window, and we moved one screen row, we're now below + * the last line of the edit window, so we need a full refresh too. */ if (ISSET(SOFTWRAP) && refresh_needed == FALSE) - if ((strlenpt(openfile->current->data) / editwincols) != orig_rows) + if ((strlenpt(openfile->current->data) / editwincols) != orig_rows || + (openfile->current_y == editwinrows - 1 && + xplustabs() / editwincols != original_row)) refresh_needed = TRUE; #endif