nano-devel
[Top][All Lists]
Advanced

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

[PATCH 2/2] imaginary feature: keystrokes to stepwise move the guidestri


From: Benno Schulenberg
Subject: [PATCH 2/2] imaginary feature: keystrokes to stepwise move the guidestripe left/right
Date: Tue, 6 Jul 2021 16:41:07 +0200

With M-{ and M-} the guiding stripe can be moved left/right one column
per keystroke.  When the stripe is off, it is switched on and set to
the current fill width, which seems like a good place to start.

[Also this is just a rough proof of concept.  I don't think it should
become part of nano.  I'm posting it just for tickles.]
---
 src/global.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/src/global.c b/src/global.c
index f585f9b8..e0afd508 100644
--- a/src/global.c
+++ b/src/global.c
@@ -376,6 +376,28 @@ void more_fill(void)
 {
        shove_fill(+1);
 }
+
+/* Push the guide stripe one column left or right, or switch it on when off. */
+void shift_stripe(int change)
+{
+       if (stripe_column > 0)
+               stripe_column += change;
+       else
+               stripe_column = wrap_at;
+
+       statusline(REMARK, "Stripe column is %zi", stripe_column);
+       refresh_needed = TRUE;
+}
+
+void lefter_stripe(void)
+{
+       shift_stripe((stripe_column > 1) ? -1 : 0);
+}
+
+void righter_stripe(void)
+{
+       shift_stripe(+1);
+}
 #endif
 
 /* Add a function to the linked list of functions. */
@@ -1290,9 +1312,7 @@ void shortcut_init(void)
        add_to_sclist(MMAIN, "^^", 0, do_mark, 0);
        add_to_sclist(MMAIN, "M-6", 0, copy_text, 0);
        add_to_sclist(MMAIN, "M-^", 0, copy_text, 0);
-       add_to_sclist(MMAIN, "M-}", 0, do_indent, 0);
        add_to_sclist(MMAIN, "Tab", INDENT_KEY, do_indent, 0);
-       add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
        add_to_sclist(MMAIN, "Sh-Tab", SHIFT_TAB, do_unindent, 0);
        add_to_sclist(MMAIN, "M-:", 0, record_macro, 0);
        add_to_sclist(MMAIN, "M-;", 0, run_macro, 0);
@@ -1399,6 +1419,8 @@ void shortcut_init(void)
        add_to_sclist(MMAIN, "M-D", 0, do_wordlinechar_count, 0);
        add_to_sclist(MMAIN, "M-(", 0, less_fill, 0);
        add_to_sclist(MMAIN, "M-)", 0, more_fill, 0);
+       add_to_sclist(MMAIN, "M-{", 0, lefter_stripe, 0);
+       add_to_sclist(MMAIN, "M-}", 0, righter_stripe, 0);
 #else
        add_to_sclist(MMAIN, "M-H", 0, do_help, 0);
 #endif
-- 
2.29.3




reply via email to

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