nano-devel
[Top][All Lists]
Advanced

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

[PATCH 3/4] options: add --markmatch and -^ for activating the select-ma


From: Benno Schulenberg
Subject: [PATCH 3/4] options: add --markmatch and -^ for activating the select-match behavior
Date: Sun, 20 Dec 2020 17:04:31 +0100

And add, of course, the 'set markmatch' nanorc option.
---
 src/definitions.h | 3 ++-
 src/nano.c        | 7 ++++++-
 src/rcfile.c      | 1 +
 src/search.c      | 2 +-
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/definitions.h b/src/definitions.h
index 2d3f1381..b9af9e9d 100644
--- a/src/definitions.h
+++ b/src/definitions.h
@@ -342,7 +342,8 @@ enum {
        INDICATOR,
        BOOKSTYLE,
        STATEFLAGS,
-       USE_MAGIC
+       USE_MAGIC,
+       MARK_MATCH
 };
 
 /* Structure types. */
diff --git a/src/nano.c b/src/nano.c
index 24a8998c..846bb62f 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -635,6 +635,7 @@ void usage(void)
                print_opt("-z", "--suspendable", N_("Enable suspension"));
 #ifndef NANO_TINY
        print_opt("-%", "--stateflags", N_("Show some states on the title 
bar"));
+       print_opt("-^", "--markmatch", N_("Select the match of a search"));
 #endif
 #ifdef HAVE_LIBMAGIC
        print_opt("-!", "--magic", N_("Also try magic to determine syntax"));
@@ -1746,6 +1747,7 @@ int main(int argc, char **argv)
                {"unix", 0, NULL, 'u'},
                {"afterends", 0, NULL, 'y'},
                {"stateflags", 0, NULL, '%'},
+               {"markmatch", 0, NULL, '^'},
 #endif
 #ifdef HAVE_LIBMAGIC
                {"magic", 0, NULL, '!'},
@@ -1800,7 +1802,7 @@ int main(int argc, char **argv)
                SET(RESTRICTED);
 
        while ((optchr = getopt_long(argc, argv, 
"ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
-                               "abcdef:ghijklmno:pqr:s:tuvwxyz$%!", 
long_options, NULL)) != -1) {
+                               "abcdef:ghijklmno:pqr:s:tuvwxyz$%^!", 
long_options, NULL)) != -1) {
                switch (optchr) {
 #ifndef NANO_TINY
                        case 'A':
@@ -2040,6 +2042,9 @@ int main(int argc, char **argv)
                        case '%':
                                SET(STATEFLAGS);
                                break;
+                       case '^':
+                               SET(MARK_MATCH);
+                               break;
 #endif
 #ifdef HAVE_LIBMAGIC
                        case '!':
diff --git a/src/rcfile.c b/src/rcfile.c
index ef410369..19e5d7db 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -109,6 +109,7 @@ static const rcoption rcopts[] = {
        {"indicator", INDICATOR},
        {"jumpyscrolling", JUMPY_SCROLLING},
        {"locking", LOCKING},
+       {"markmatch", MARK_MATCH},
        {"matchbrackets", 0},
        {"noconvert", NO_CONVERT},
        {"showcursor", SHOW_CURSOR},
diff --git a/src/search.c b/src/search.c
index 3ee435ff..5eba59e8 100644
--- a/src/search.c
+++ b/src/search.c
@@ -323,7 +323,7 @@ int findnextstr(const char *needle, bool whole_word_only, 
int modus,
                *match_len = found_len;
 
 #ifndef NANO_TINY
-       if (modus == JUSTFIND && (!openfile->mark || openfile->softmark)) {
+       if (modus == JUSTFIND && ISSET(MARK_MATCH) && (!openfile->mark || 
openfile->softmark)) {
                openfile->mark = line;
                openfile->mark_x = found_x + found_len;
                openfile->softmark = TRUE;
-- 
2.29.2




reply via email to

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