nano-devel
[Top][All Lists]
Advanced

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

[PATCH 1/2] dreamy feature: keystrokes to stepwise increase/decrease the


From: Benno Schulenberg
Subject: [PATCH 1/2] dreamy feature: keystrokes to stepwise increase/decrease the fill width
Date: Tue, 6 Jul 2021 16:41:06 +0200

With M-( and M-) the fill width can be decreased/increased one column
per keystroke.  If there is a marked region, it gets rejustified.

[This is just a rough proof of concept.  I don't think this should
become part of nano.  I'm just posting it for the benefit of anyone
who is interested in tweaking the fill width while nano is running.]

This kind of fulfills https://savannah.gnu.org/bugs/?60773.
---
 src/global.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/global.c b/src/global.c
index 0e9b0618..f585f9b8 100644
--- a/src/global.c
+++ b/src/global.c
@@ -355,6 +355,29 @@ void do_cancel(void)
 {
 }
 
+#ifndef NANO_TINY
+/* Decrement or increment the fill width, and rejustify a marked region. */
+void shove_fill(int change)
+{
+       wrap_at += change;
+
+       if (openfile->mark && openfile->mark != openfile->current)
+               do_justify();
+
+       statusline(REMARK, "Fill = %zu", wrap_at);
+}
+
+void less_fill(void)
+{
+       shove_fill((wrap_at > 1) ? -1 : 0);
+}
+
+void more_fill(void)
+{
+       shove_fill(+1);
+}
+#endif
+
 /* Add a function to the linked list of functions. */
 void add_to_funcs(void (*func)(void), int menus, const char *desc,
                                        const char *help, bool blank_after, 
bool viewok)
@@ -1342,9 +1365,7 @@ void shortcut_init(void)
        add_to_sclist(MMAIN, "M-7", 0, to_prev_block, 0);
        add_to_sclist(MMAIN, "M-8", 0, to_next_block, 0);
 #ifdef ENABLE_JUSTIFY
-       add_to_sclist(MMAIN, "M-(", 0, to_para_begin, 0);
        add_to_sclist(MMAIN, "M-9", 0, to_para_begin, 0);
-       add_to_sclist(MMAIN, "M-)", 0, to_para_end, 0);
        add_to_sclist(MMAIN, "M-0", 0, to_para_end, 0);
 #endif
 #ifndef NANO_TINY
@@ -1376,6 +1397,8 @@ void shortcut_init(void)
        add_to_sclist(MMAIN, "M-T", 0, cut_till_eof, 0);
        add_to_sclist(MEXECUTE, "^V", 0, cut_till_eof, 0);
        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);
 #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]