nano-devel
[Top][All Lists]
Advanced

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

[PATCH 3/4] options: add --indicator and -q for switching on the scroll-


From: Benno Schulenberg
Subject: [PATCH 3/4] options: add --indicator and -q for switching on the scroll-bar thing
Date: Thu, 28 May 2020 11:07:28 +0200

By default, the position indicator is off.  It can be turned on
by passing -q or --indicator on the command line, or by adding
'set indicator' in your nanorc file.
---
 src/nano.c   | 17 +++++++++++++----
 src/nano.h   |  3 ++-
 src/rcfile.c |  1 +
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/nano.c b/src/nano.c
index 497c6c24..47c5d941 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -570,6 +570,9 @@ void usage(void)
                                        N_("Set operating directory"));
 #endif
        print_opt("-p", "--preserve", N_("Preserve XON (^Q) and XOFF (^S) 
keys"));
+#ifndef NANO_TINY
+       print_opt("-q", "--indicator", N_("Show a position+portion indicator"));
+#endif
 #ifdef ENABLED_WRAPORJUSTIFY
        print_opt(_("-r <number>"), _("--fill=<number>"),
                                        N_("Set width for hard-wrap and 
justify"));
@@ -1055,7 +1058,7 @@ void regenerate_screen(void)
        LINES = win.ws_row;
 #endif
 #ifndef NANO_TINY
-       thebar = (LINES > 5 && COLS > 9) ? 1 : 0;
+       thebar = (ISSET(INDICATOR) && LINES > 5 && COLS > 9) ? 1 : 0;
        bardata = nrealloc(bardata, LINES * sizeof(int));
 #endif
        editwincols = COLS - margin - thebar;
@@ -1105,7 +1108,7 @@ void do_toggle(int flag)
                                renumber_from(openfile->filetop);
                        else
                                openfile->firstcolumn = 0;
-                       thebar = (LINES > 5 && COLS > 9) ? 1 : 0;
+                       thebar = (ISSET(INDICATOR) && LINES > 5 && COLS > 9) ? 
1 : 0;
                        bardata = nrealloc(bardata, LINES * sizeof(int));
                        editwincols = COLS - margin - thebar;
                        refresh_needed = TRUE;
@@ -1761,6 +1764,7 @@ int main(int argc, char **argv)
                {"atblanks", 0, NULL, 'a'},
                {"autoindent", 0, NULL, 'i'},
                {"cutfromcursor", 0, NULL, 'k'},
+               {"indicator", 0, NULL, 'q'},
                {"unix", 0, NULL, 'u'},
                {"afterends", 0, NULL, 'y'},
 #endif
@@ -1819,7 +1823,7 @@ int main(int argc, char **argv)
                SET(RESTRICTED);
 
        while ((optchr = getopt_long(argc, argv, 
"ABC:DEFGHIJ:KLMNPQ:RST:UVWX:Y:Z"
-                               "abcdef:ghijklmno:pr:s:tuvwxyz$", long_options, 
NULL)) != -1) {
+                               "abcdef:ghijklmno:pqr:s:tuvwxyz$", 
long_options, NULL)) != -1) {
                switch (optchr) {
 #ifndef NANO_TINY
                        case 'A':
@@ -2001,6 +2005,11 @@ int main(int argc, char **argv)
                        case 'p':
                                SET(PRESERVE);
                                break;
+#ifndef NANO_TINY
+                       case 'q':
+                               SET(INDICATOR);
+                               break;
+#endif
 #ifdef ENABLED_WRAPORJUSTIFY
                        case 'r':
                                if (!parse_num(optarg, &fill)) {
@@ -2305,7 +2314,7 @@ int main(int argc, char **argv)
        curs_set(0);
 
 #ifndef NANO_TINY
-       thebar = (LINES > 5 && COLS > 9) ? 1 : 0;
+       thebar = (ISSET(INDICATOR) && LINES > 5 && COLS > 9) ? 1 : 0;
        bardata = nrealloc(bardata, LINES * sizeof(int));
 #endif
        editwincols = COLS - thebar;
diff --git a/src/nano.h b/src/nano.h
index 75ad30e4..ad52f4cb 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -542,7 +542,8 @@ enum
        LET_THEM_ZAP,
        BREAK_LONG_LINES,
        JUMPY_SCROLLING,
-       EMPTY_LINE
+       EMPTY_LINE,
+       INDICATOR
 };
 
 /* Flags for the menus in which a given function should be present. */
diff --git a/src/rcfile.c b/src/rcfile.c
index ff752488..c18f5288 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -105,6 +105,7 @@ static const rcoption rcopts[] = {
        {"backupdir", 0},
        {"cutfromcursor", CUT_FROM_CURSOR},
        {"guidestripe", 0},
+       {"indicator", INDICATOR},
        {"locking", LOCKING},
        {"matchbrackets", 0},
        {"noconvert", NO_CONVERT},
-- 
2.25.4




reply via email to

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