nano

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

commit 52eb0e992d1bbfdbd401a250f7091f85a83b1295
parent 19ddc081c19cc688d6c4374b71dd8ffff608af3d
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 24 Mar 2024 15:05:06 +0100

new feature: functions that jump to the top or bottom of the viewport

(The next commit will preserve the horizontal cursor position.)

Diffstat:
Msrc/move.c | 24++++++++++++++++++++++++
Msrc/prototypes.h | 4++++
2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/move.c b/src/move.c @@ -176,6 +176,30 @@ void do_page_down(void) refresh_needed = TRUE; } +#ifndef NANO_TINY +/* Place the cursor on the first row in the viewport. */ +void to_top_row(void) +{ + openfile->current = openfile->edittop; + openfile->current_x = actual_x(openfile->current->data, openfile->firstcolumn); + + place_the_cursor(); +} + +/* Place the cursor on the last row in the viewport, when possible. */ +void to_bottom_row(void) +{ + size_t leftedge = openfile->firstcolumn; + + openfile->current = openfile->edittop; + + go_forward_chunks(editwinrows - 1, &openfile->current, &leftedge); + openfile->current_x = actual_x(openfile->current->data, leftedge); + + place_the_cursor(); +} +#endif + #ifdef ENABLE_JUSTIFY /* Move to the first beginning of a paragraph before the current line. */ void do_para_begin(linestruct **line) diff --git a/src/prototypes.h b/src/prototypes.h @@ -361,6 +361,10 @@ void to_first_line(void); void to_last_line(void); void do_page_up(void); void do_page_down(void); +#ifndef NANO_TINY +void to_top_row(void); +void to_bottom_row(void); +#endif #ifdef ENABLE_JUSTIFY void do_para_begin(linestruct **line); void do_para_end(linestruct **line);