[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC] [PATCH 1/3] new feature: functions that jump to the top or bottom
From: |
Benno Schulenberg |
Subject: |
[RFC] [PATCH 1/3] new feature: functions that jump to the top or bottom of the viewport |
Date: |
Mon, 25 Mar 2024 11:07:08 +0100 |
(The next commit will preserve the horizontal cursor position.)
---
src/move.c | 24 ++++++++++++++++++++++++
src/prototypes.h | 4 ++++
2 files changed, 28 insertions(+)
diff --git a/src/move.c b/src/move.c
index 7320e912..fe171bfc 100644
--- 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
index aa73f5c8..0afdadad 100644
--- 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);
--
2.42.1
- [RFC] [PATCH 1/3] new feature: functions that jump to the top or bottom of the viewport,
Benno Schulenberg <=