nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH] scrolling: add a function and key binding to center


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] scrolling: add a function and key binding to center the cursor line
Date: Wed, 27 Apr 2016 15:11:51 +0200

---
 src/global.c | 7 +++++++
 src/move.c   | 7 +++++++
 src/proto.h  | 1 +
 3 files changed, 15 insertions(+)

diff --git a/src/global.c b/src/global.c
index 37de038..af4efdf 100644
--- a/src/global.c
+++ b/src/global.c
@@ -573,6 +573,8 @@ void shortcut_init(void)
        N_("Scroll up one line without scrolling the cursor");
     const char *nano_scrolldown_msg =
        N_("Scroll down one line without scrolling the cursor");
+    const char *nano_center_msg =
+       N_("Center the line where the cursor is");
 #endif
 #ifndef DISABLE_MULTIBUFFER
     const char *nano_prevfile_msg = N_("Switch to the previous file buffer");
@@ -933,6 +935,9 @@ void shortcut_init(void)
     add_to_funcs(do_savefile, MMAIN,
        N_("Save"), IFSCHELP(nano_savefile_msg), BLANKAFTER, NOVIEW);
 
+    add_to_funcs(do_center, MMAIN,
+       N_("Center"), IFSCHELP(nano_center_msg), BLANKAFTER, VIEW);
+
     add_to_funcs(do_findprevious, MMAIN,
        N_("Previous"), IFSCHELP(nano_findprev_msg), TOGETHER, VIEW);
     add_to_funcs(do_findnext, MMAIN,
@@ -1127,6 +1132,8 @@ void shortcut_init(void)
     add_to_sclist(MMAIN, "^Z", do_suspend_void, 0);
 
 #ifndef NANO_TINY
+    add_to_sclist(MMAIN, "M-'", do_center, 0);
+
     /* Group of "Appearance" toggles. */
     add_to_sclist(MMAIN, "M-X", do_toggle_void, NO_HELP);
     add_to_sclist(MMAIN, "M-C", do_toggle_void, CONST_UPDATE);
diff --git a/src/move.c b/src/move.c
index e2f9823..21a0565 100644
--- a/src/move.c
+++ b/src/move.c
@@ -528,6 +528,13 @@ void do_scroll_down(void)
 {
     do_down(TRUE);
 }
+
+/* Scroll the line with the cursor to the center of the screen. */
+void do_center(void)
+{
+    edit_update(CENTERING);
+    refresh_needed = TRUE;
+}
 #endif
 
 /* Move left one character. */
diff --git a/src/proto.h b/src/proto.h
index 6ad900b..cf3025c 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -425,6 +425,7 @@ void do_down(
 void do_down_void(void);
 #ifndef NANO_TINY
 void do_scroll_down(void);
+void do_center(void);
 #endif
 void do_left(void);
 void do_right(void);
-- 
2.8.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]