[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nano-devel
Subject:    [PATCH] options: add --hold (and -.) to keep a search match spotlighted
From:       Benno Schulenberg <bensberg () telfort ! nl>
Date:       2021-08-25 15:27:13
Message-ID: 20210825152713.6259-1-bensberg () telfort ! nl
[Download RAW message or body]

The automatic dropping of the spotlighting after a search can be
annoying (especially when using --quick).  So, allow the user to
specify that the spotlighting should not be dropped.

Of course, a 'set hold' nanorc option is added too.
---
 src/definitions.h    | 3 ++-
 src/nano.c           | 7 ++++++-
 src/rcfile.c         | 1 +
 src/winio.c          | 3 ++-
 syntax/nanorc.nanorc | 2 +-
 5 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/definitions.h b/src/definitions.h
index 2ce72260..954e5952 100644
--- a/src/definitions.h
+++ b/src/definitions.h
@@ -346,7 +346,8 @@ enum {
 	BOOKSTYLE,
 	STATEFLAGS,
 	USE_MAGIC,
-	MINIBAR
+	MINIBAR,
+	HOLD
 };
 
 /* Structure types. */
diff --git a/src/nano.c b/src/nano.c
index 3dd9f917..146ab2cb 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -643,6 +643,7 @@ void usage(void)
 	if (!ISSET(RESTRICTED))
 		print_opt("-z", "--suspendable", N_("Enable suspension"));
 #ifndef NANO_TINY
+	print_opt("-.", "--hold", N_("Keep the found search match spotlighted"));
 	print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
 	print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom"));
 #endif
@@ -1754,6 +1755,7 @@ int main(int argc, char **argv)
 		{"indicator", 0, NULL, 'q'},
 		{"unix", 0, NULL, 'u'},
 		{"afterends", 0, NULL, 'y'},
+		{"hold", 0, NULL, '.'},
 		{"stateflags", 0, NULL, '%'},
 		{"minibar", 0, NULL, '_'},
 #endif
@@ -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':
@@ -2037,6 +2039,9 @@ int main(int argc, char **argv)
 				SET(SUSPENDABLE);
 				break;
 #ifndef NANO_TINY
+			case '.':
+				SET(HOLD);
+				break;
 			case '%':
 				SET(STATEFLAGS);
 				break;
diff --git a/src/rcfile.c b/src/rcfile.c
index 6b77b810..3c5fed90 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -104,6 +104,7 @@ static const rcoption rcopts[] = {
 	{"cutfromcursor", CUT_FROM_CURSOR},
 	{"emptyline", EMPTY_LINE},
 	{"guidestripe", 0},
+	{"hold", HOLD},
 	{"indicator", INDICATOR},
 	{"jumpyscrolling", JUMPY_SCROLLING},
 	{"locking", LOCKING},
diff --git a/src/winio.c b/src/winio.c
index 6984a247..f1b81f00 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -193,7 +193,8 @@ void read_keys_from(WINDOW *win)
 		curs_set(1);
 
 #ifndef NANO_TINY
-	if (currmenu == MMAIN && (spotlighted || ((ISSET(MINIBAR) || LINES == 1) &&
+	if (currmenu == MMAIN && ((spotlighted && !ISSET(HOLD)) ||
+						((ISSET(MINIBAR) || LINES == 1) &&
 						lastmessage > HUSH &&
 						lastmessage != INFO && lastmessage < ALERT))) {
 		timed = TRUE;
diff --git a/syntax/nanorc.nanorc b/syntax/nanorc.nanorc
index 27a0438b..8e2372c7 100644
--- a/syntax/nanorc.nanorc
+++ b/syntax/nanorc.nanorc
@@ -10,7 +10,7 @@ color brightred ".*"
 color yellow "^[[:blank:]]*(i?color|set[[:blank:]]+((error|function|key|mini|number|p \
rompt|scroller|selected|spotlight|status|stripe|title)color))[[:blank:]]+(bold,)?(ital \
ic,)?(((bright|light)?(white|black|red|blue|green|yellow|magenta|cyan))|normal|pink|pu \
rple|mauve|lagoon|mint|lime|peach|orange|latte|grey|gray)?(,(((light)?(white|black|red \
|blue|green|yellow|magenta|cyan))|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte|grey|gray))?\>"
  
 # Keywords
-color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure_back \
up|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|constant \
show|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|m \
agic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickb \
lank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
 +color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure_bac \
kup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|constan \
tshow|cutfromcursor|emptyline|historylog|hold|indicator|jumpyscrolling|linenumbers|loc \
king|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve| \
quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
  color brightgreen "^[[:blank:]]*set[[:blank:]]+(backupdir|brackets|errorcolor|functi \
oncolor|keycolor|matchbrackets|minicolor|numbercolor|operatingdir|promptcolor|punct|qu \
otestr|scrollercolor|selectedcolor|speller|spotlightcolor|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:blank:]]+"
  color brightgreen "^[[:blank:]]*set[[:blank:]]+(fill[[:blank:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:blank:]]+[1-9][0-9]*)\>"
  color brightgreen "^[[:blank:]]*bind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss \
][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0- \
9]|2[0-4])|Ins|Del)[[:blank:]]+([a-z]+|".*")[[:blank:]]+(main|help|search|replace(with \
)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:blank:]]+#|[[:blank:]]*$)"
                
-- 
2.29.3


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic