nano

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

commit e478682c5542e9d0fffe6ffb4df9639984e94afe
parent bd2d0863d6ba7d40154c6c524fcd46fd62d360e5
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Fri, 20 Jan 2017 02:07:15 -0600

softwrap: improve End's behavior with softwrapped chunks

Make do_end() more useful in softwrap mode: let it move to the end of the
current chunk instead of the end of the line; only when already at the end
of a chunk, let it move to the end of the line.  This is "dynamic end".

Diffstat:
Msrc/move.c | 35++++++++++++++++++++++++++++++-----
1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/src/move.c b/src/move.c @@ -410,18 +410,43 @@ void do_home_void(void) do_home(); } -/* Move to the end of the current line. */ +/* Move to the end of the current line (or softwrapped chunk). + * + * Try to do a dynamic end if it's possible and we're in softwrap mode. */ void do_end(void) { size_t was_column = xplustabs(); + size_t line_len = strlen(openfile->current->data); + filestruct *was_current = openfile->current; + bool moved_off_chunk = TRUE; + +#ifndef NANO_TINY + if (ISSET(SOFTWRAP)) { + size_t rightedge_x = actual_x(openfile->current->data, + ((was_column / editwincols) * editwincols) + + (editwincols - 1)); + + /* If already at the right edge of the screen, move fully to the + * end of the line. Otherwise, move to the right edge. */ + if (openfile->current_x == rightedge_x) + openfile->current_x = line_len; + else { + openfile->current_x = rightedge_x; + moved_off_chunk = FALSE; + } + } else +#endif + openfile->current_x = line_len; - openfile->current_x = strlen(openfile->current->data); openfile->placewewant = xplustabs(); - if (line_needs_update(was_column, openfile->placewewant)) + /* If we changed chunk, we might be offscreen. Otherwise, + * update current if the mark is on or we changed "page". */ + if (ISSET(SOFTWRAP) && moved_off_chunk) { + focusing = FALSE; + edit_redraw(was_current); + } else if (line_needs_update(was_column, openfile->placewewant)) update_line(openfile->current, openfile->current_x); - - ensure_line_is_visible(); } void do_end_void(void)