options: add --markmatch and -^ for activating the select-match behavior

And add, of course, the 'set markmatch' nanorc option.
master
Benno Schulenberg 2020-12-19 13:44:42 +01:00
parent caef3128eb
commit d0bceb1449
4 changed files with 10 additions and 3 deletions

View File

@ -343,7 +343,8 @@ enum {
BOOKSTYLE,
STATEFLAGS,
USE_MAGIC,
MINIBAR
MINIBAR,
MARK_MATCH
};
/* Structure types. */

View File

@ -641,6 +641,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"));
print_opt("-_", "--minibar", N_("Show bar at bottom with some state info"));
#endif
#ifdef HAVE_LIBMAGIC
@ -1759,6 +1760,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, '!'},
@ -1813,7 +1815,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':
@ -2056,6 +2058,9 @@ int main(int argc, char **argv)
case '%':
SET(STATEFLAGS);
break;
case '^':
SET(MARK_MATCH);
break;
#endif
#ifdef HAVE_LIBMAGIC
case '!':

View File

@ -109,6 +109,7 @@ static const rcoption rcopts[] = {
{"indicator", INDICATOR},
{"jumpyscrolling", JUMPY_SCROLLING},
{"locking", LOCKING},
{"markmatch", MARK_MATCH},
{"matchbrackets", 0},
{"minibar", MINIBAR},
{"noconvert", NO_CONVERT},

View File

@ -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;