From 535193ca196c03e9c53a85080d0452f3f3d378ef Mon Sep 17 00:00:00 2001 From: davidhcefx Date: Sun, 9 Jul 2023 02:39:22 +0800 Subject: [PATCH] Update README.md --- README.md | 160 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 115 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index c527cdb6..24068763 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # GNU nano (5.4) - nosearchwrap -[![build](https://github.com/davidhcefx/GNU_nano_5.4_nosearchwrap/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/davidhcefx/GNU_nano_5.4_nosearchwrap/actions/workflows/build.yml) +[![build](https://github.com/davidhcefx/GNU_nano_5.4_nosearchwrap/actions/workflows/build.yml/badge.svg)](https://github.com/davidhcefx/GNU_nano_5.4_nosearchwrap/actions/workflows/build.yml) - While performing textual search, many editors, for instance [Sublime](https://www.sublimetext.com/), support toggling the option **Wrap**, which is to wrap past end-of-file and proceed searching. It will be nice if Nano can have this too! @@ -29,48 +29,118 @@ set nosearchwrap ## Modification Summary ```diff -doc/nano.1 -325a326,328 -> .TP -> .BR \-\-nosearchwrap -> Don't wrap around to the start or end of the buffer when performing search or replace. - -doc/nanorc.5 -201a202,204 -> .B set nosearchwrap -> Don't wrap around to the start or end of the buffer when performing search or replace. -> .TP - -src/nano.c -639a640 -> print_opt("", "--nosearchwrap", N_("Don't wrap past EOF when search/replace")); -1750a1752 -> {"nosearchwrap", 0, NULL, '\x01'}, -2036a2039,2041 -> break; -> case 0x01: -> SET(NO_SEARCH_WRAP); - -src/nano.h -546c546,547 -< INDICATOR ---- -> INDICATOR, -> NO_SEARCH_WRAP - -src/rcfile.c -111a112 -> {"nosearchwrap", NO_SEARCH_WRAP}, - -src/search.c -265c265 -< if (whole_word_only || modus == INREGION) { ---- -> if (whole_word_only || modus == INREGION || ISSET(NO_SEARCH_WRAP)) { - -syntax/nanorc.nanorc -10c10 -< color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|finalnewline|historylog|indicator|jumpyscrolling|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|smooth|softwrap|suspendable|tabstospaces|trimblanks|unix|view|wordbounds|zap)\>" ---- -> color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|finalnewline|historylog|indicator|jumpyscrolling|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nosearchwrap|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|smooth|softwrap|suspendable|tabstospaces|trimblanks|unix|view|wordbounds|zap)\>" +diff --git a/doc/nano.1 b/doc/nano.1 +index a759f359..7e3c5316 100644 +--- a/doc/nano.1 ++++ b/doc/nano.1 +@@ -340,6 +340,9 @@ filename in the center of the title bar. + .BR \-! ", " \-\-magic + When neither the file's name nor its first line give a clue, + try using libmagic to determine the applicable syntax. ++.TP ++.BR \-\-nosearchwrap ++Don't wrap around to the start or end of the buffer when performing search or replace. + + .SH TOGGLES + Several of the above options can be switched on and off also while +diff --git a/doc/nanorc.5 b/doc/nanorc.5 +index 5716a4b1..a383d7c4 100644 +--- a/doc/nanorc.5 ++++ b/doc/nanorc.5 +@@ -209,6 +209,9 @@ Don't automatically add a newline when a text does not end with one. + .B set nopauses + Obsolete option. Ignored. + .TP ++.B set nosearchwrap ++Don't wrap around to the start or end of the buffer when performing search or replace. ++.TP + .B set nowrap + Deprecated option since it has become the default setting. + When needed, use \fBunset breaklonglines\fR instead. +diff --git a/src/definitions.h b/src/definitions.h +index 7924f8ab..f1302ec6 100644 +--- a/src/definitions.h ++++ b/src/definitions.h +@@ -348,7 +348,8 @@ enum { + INDICATOR, + BOOKSTYLE, + STATEFLAGS, +- USE_MAGIC ++ USE_MAGIC, ++ NO_SEARCH_WRAP + }; + + /* Structure types. */ +diff --git a/src/nano.c b/src/nano.c +index 4c97375a..74c56faf 100644 +--- a/src/nano.c ++++ b/src/nano.c +@@ -639,6 +639,7 @@ void usage(void) + #ifdef HAVE_LIBMAGIC + print_opt("-!", "--magic", N_("Also try magic to determine syntax")); + #endif ++ print_opt("", "--nosearchwrap", N_("Don't wrap past EOF when search/replace")); + } + + /* Display the version number of this nano, a copyright notice, some contact +@@ -1744,6 +1745,7 @@ int main(int argc, char **argv) + {"unix", 0, NULL, 'u'}, + {"afterends", 0, NULL, 'y'}, + {"stateflags", 0, NULL, '%'}, ++ {"nosearchwrap", 0, NULL, '\x01'}, + #endif + #ifdef HAVE_LIBMAGIC + {"magic", 0, NULL, '!'}, +@@ -2044,6 +2046,9 @@ int main(int argc, char **argv) + SET(USE_MAGIC); + break; + #endif ++ case 0x01: ++ SET(NO_SEARCH_WRAP); ++ break; + default: + printf(_("Type '%s -h' for a list of available options.\n"), argv[0]); + exit(1); +diff --git a/src/nano.exe b/src/nano.exe +new file mode 100755 +index 00000000..c70b3f2e +Binary files /dev/null and b/src/nano.exe differ +diff --git a/src/rcfile.c b/src/rcfile.c +index ef410369..dfaa9d43 100644 +--- a/src/rcfile.c ++++ b/src/rcfile.c +@@ -111,6 +111,7 @@ static const rcoption rcopts[] = { + {"locking", LOCKING}, + {"matchbrackets", 0}, + {"noconvert", NO_CONVERT}, ++ {"nosearchwrap", NO_SEARCH_WRAP}, + {"showcursor", SHOW_CURSOR}, + {"smarthome", SMART_HOME}, + {"smooth", SMOOTH_SCROLL}, /* Deprecated; remove in 2021. */ +diff --git a/src/search.c b/src/search.c +index c0c89804..8ac9452a 100644 +--- a/src/search.c ++++ b/src/search.c +@@ -243,7 +243,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus, + /* If we've reached the start or end of the buffer, wrap around; + * but stop when spell-checking or replacing in a region. */ + if (line == NULL) { +- if (whole_word_only || modus == INREGION) { ++ if (whole_word_only || modus == INREGION || ISSET(NO_SEARCH_WRAP)) { + nodelay(edit, FALSE); + return 0; + } +diff --git a/syntax/nanorc.nanorc b/syntax/nanorc.nanorc +index 22eb9fcb..191b80fb 100644 +--- a/syntax/nanorc.nanorc ++++ b/syntax/nanorc.nanorc +@@ -7,7 +7,7 @@ comment "#" + color brightred ".*" + + # Keywords +-color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>" ++color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|mouse|multibuffer|noconvert|nohelp|nosearchwrap|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>" + color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|prompt|scroller|selected|status|stripe|title)color)[[:space:]]+(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>" + color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+" + color brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>" ```