nano

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

commit 5ecefb876653872b73de904edcb23515d947cb90
parent 52eb0e992d1bbfdbd401a250f7091f85a83b1295
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 24 Mar 2024 15:45:50 +0100

moving: preserve horizontal position when jumping to top or bottom row

Diffstat:
Msrc/move.c | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/move.c b/src/move.c @@ -180,8 +180,14 @@ void do_page_down(void) /* Place the cursor on the first row in the viewport. */ void to_top_row(void) { + size_t leftedge, offset; + + get_edge_and_target(&leftedge, &offset); + openfile->current = openfile->edittop; - openfile->current_x = actual_x(openfile->current->data, openfile->firstcolumn); + leftedge = openfile->firstcolumn; + + set_proper_index_and_pww(&leftedge, offset, FALSE); place_the_cursor(); } @@ -189,12 +195,15 @@ void to_top_row(void) /* Place the cursor on the last row in the viewport, when possible. */ void to_bottom_row(void) { - size_t leftedge = openfile->firstcolumn; + size_t leftedge, offset; + + get_edge_and_target(&leftedge, &offset); openfile->current = openfile->edittop; + leftedge = openfile->firstcolumn; go_forward_chunks(editwinrows - 1, &openfile->current, &leftedge); - openfile->current_x = actual_x(openfile->current->data, leftedge); + set_proper_index_and_pww(&leftedge, offset, TRUE); place_the_cursor(); }