Commit Graph

221 Commits

Author SHA1 Message Date
Benno Schulenberg
a4675acdba copyright: update to the current year for significantly changed files 2020-11-30 12:01:47 +01:00
Benno Schulenberg
7d35f71c87 weeding: remove a workaround for early versions of ncurses-6.0
Those versions are more than five years old.  If there are still
machines with those versions, people should upgrade ncurses too
if they want the newest version of nano.
2020-11-15 10:27:22 +01:00
Benno Schulenberg
58a3293efc options: require --magic or 'set magic' to enable the use of libmagic
Trying to determine which syntax to apply with the help of libmagic
can be a somewhat time-consuming and yet often still fruitless affair.
Therefore using libmagic should not be the default; it should require
an option to tell nano to try using libmagic when it can't determine
the applicable syntax from the file's name or first line.

This is better than having a --nomagic option (and using libmagic by
default), because when the user has 'set nomagic' in their nanorc or
--nomagic in their alias, then switching the use of libmagic back on
is troublesome.  But with --magic (and not using libmagic by default),
when nano fails to recognize a file, it is a simple ^X, add -! to the
command line, and restart.

The short form of the option is -! because we have run out of letters.

This addresses https://savannah.gnu.org/bugs/?59028.
2020-09-25 16:34:01 +02:00
Benno Schulenberg
46e769a113 rcfile: add 'set scrollercolor', for changing the color of the indicator
This fulfills https://savannah.gnu.org/bugs/?59041.
2020-09-02 19:55:24 +02:00
Hussam al-Homsi
c87bc1d55f tweaks: stop casting the return of malloc() and friends
Those casts are redundant, and sometimes ugly.  And as the types of
variables are extremely unlikely to change any more at this point,
the protection they offer against miscompilations is moot.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-08-31 12:17:27 +02:00
Benno Schulenberg
90f6342fd1 tweaks: rename two header files, to be distinct and not an abbreviation 2020-06-20 12:09:31 +02:00
Benno Schulenberg
bafcc19b7a tweaks: rename a symbol, from a phrase to a noun 2020-06-18 15:31:06 +02:00
Benno Schulenberg
1c8c02f63b tweaks: move a function, to be in the order in which they are called
In addition, rename two variables and adjust the type of one of them.
2020-06-13 17:16:33 +02:00
Benno Schulenberg
43a1756783 tweaks: call init_pair() just once for each pair number 2020-06-13 14:17:45 +02:00
Benno Schulenberg
34528db096 tweaks: remove unneeded variables after the previous change 2020-06-13 14:17:45 +02:00
Benno Schulenberg
c79b52da1d tweaks: do the conversion of -1 to a specific color just once
Do the conversion (when needed) when the syntax is loaded,
not for each buffer switch.
2020-06-13 14:17:45 +02:00
Benno Schulenberg
454dc6e1ec tweaks: elide two ifs for the most likely case, when defaults are allowed 2020-06-13 14:17:45 +02:00
Benno Schulenberg
23460bc6a8 tweaks: rename a variable, for more contrast with the function name 2020-06-13 14:17:45 +02:00
Benno Schulenberg
ba2807c6f7 tweaks: call use_default_colors() just once for each run 2020-06-13 14:17:45 +02:00
Benno Schulenberg
3899a09dea tweaks: rename a variable, improve a comment, and reshuffle a few things 2020-06-11 19:23:37 +02:00
Benno Schulenberg
b535714671 tweaks: reshuffle a statement, to have major initialization in nano.c 2020-06-11 16:48:52 +02:00
Benno Schulenberg
1bbf07b27e color: avoid allocating emptiness when there are no multiline regexes
When a file is saved under a different name, and as a result the
applicable syntax changes, and the old syntax had multiline regexes
and the new syntax doesn't, then the call of precalc_multicolorinfo()
in write_file() should not result in nano setting up a multicache of
zero bytes for each line in the buffer.

(Problem was found by locally letting nano crash when zero bytes are
allocated, and then happening to rename a file.py to a file.sh.)
2020-05-01 13:59:56 +02:00
Benno Schulenberg
b9deb883fa tweaks: shorten the name of a symbol, to match its bindable function 2020-05-01 13:25:15 +02:00
Benno Schulenberg
9c4ebed3ff tweaks: remove an unneeded element from the openfilestruct 2020-05-01 12:38:02 +02:00
Benno Schulenberg
5ca2fd887a startup: initialize colors only when the terminal is capable of colors
This avoids trying to show colors on a vt100, for example.
2020-04-29 12:07:31 +02:00
Benno Schulenberg
d1e1438ca0 tweaks: delete some unneeded code, and rename the function accordingly
When set_colorpairs() is called, no files have been loaded yet, so
no syntaxes will have been loaded yet either.  Thus it is pointless
to run through the list of available syntaxes.
2020-04-28 16:49:45 +02:00
Benno Schulenberg
382ec84248 tweaks: rename a function, to match with the boolean that guards it 2020-04-28 16:38:27 +02:00
Benno Schulenberg
bc4240dda5 tweaks: rename a function, to better describe what it does
Its major function is to find an applicable syntax, if there is any.
And if the syntax hasn't been used before, to prime its color pairs.

Also, reshuffle a line to be able to elide an #ifdef.
2020-04-28 16:34:45 +02:00
Benno Schulenberg
72ad00f9d0 tweaks: change an integer to a short, and reshuffle it for better packing
A short allows for more than 32 thousand values, and the maximum number
of multiline regexes in any of the current syntaxes is... just four.

Reshuffle it to the beginning also because it is used the most often.
2020-03-02 19:50:08 +01:00
Benno Schulenberg
c802f91f4e tweaks: remove some unneeded braces, not used elsewhere either 2020-02-21 17:07:11 +01:00
Benno Schulenberg
51913542f4 tweaks: rename a variable, and reshuffle a declaration 2020-02-21 17:02:24 +01:00
Benno Schulenberg
c64f506933 tweaks: reshuffle some declarations, and expand a few variable names 2020-01-28 10:21:34 +01:00
Benno Schulenberg
afa4c6b9fc copyright: update the years for the FSF 2020-01-15 11:42:38 +01:00
Benno Schulenberg
31d5cb1118 build: slightly speed up the compilation of the tiny version
Don't include header files when they won't actually be needed.

(Also, remove a superfluous #ifdef.)
2019-10-13 18:55:49 +02:00
Benno Schulenberg
d6e05d8376 tweaks: simplify the determination of a canonical path
Suggested-by: Brand Huntsman <alpha@qzx.com>
2019-09-17 13:32:15 +02:00
Benno Schulenberg
21e307e820 tweaks: rename a variable, normalize a comment, and reshuffle a free() 2019-09-16 17:25:47 +02:00
Benno Schulenberg
dbcf4f0cbe color: don't concatenate an absolute path with the working directory
When the user specified an absolute path... it is NOT relative to the
current working directory.

This fixes https://savannah.gnu.org/bugs/?56902.
Reported-by: Brand Huntsman <alpha@qzx.com>

Bug existed since version 2.4.2, commit ec8d51be.
2019-09-16 17:12:25 +02:00
Benno Schulenberg
7b88557ef5 tweaks: meld two calls of free() into a single one, to elide an 'else' 2019-09-16 16:55:03 +02:00
Benno Schulenberg
1fcb9b99cf tweaks: move a function to before the first one that calls it 2019-06-23 12:29:17 +02:00
Benno Schulenberg
d8c840692e tweaks: reshuffle an 'if' out of a function, and rename the function 2019-06-23 12:15:19 +02:00
Benno Schulenberg
8c7b6bd21a tweaks: when precalculating, allocate all the cache space upfront
Instead of doing it haphazardly while lines are getting categorized.
2019-06-23 11:57:27 +02:00
Benno Schulenberg
21d0755de5 tweaks: try the allocation of a multidata cache just once per line
It does not need to be allocated for each multiline regex separately.
2019-06-23 11:45:03 +02:00
Benno Schulenberg
967f581860 tweaks: adjust some whitespace and rewrap a few lines
And remove two unneeded casts.
2019-06-09 20:03:44 +02:00
Benno Schulenberg
1075de1222 tweaks: rename two functions, to get rid of the "mb" abbreviation
Also, for me "move" is about moving the cursor.  But these functions
are about moving an index in a text, which is more general.
2019-06-09 19:37:56 +02:00
Benno Schulenberg
fb17929fab tweaks: use FALSE for booleans instead of zero
Also adjust some indentation and reduce the scope of a variable.
2019-06-09 10:41:14 +02:00
Brand Huntsman
57b3f83cfe rcfile: compile the color regexes just once
When a syntax gets parsed, store the compiled color regexes right away,
instead of compiling them a second time in color_update().

This addresses https://savannah.gnu.org/bugs/?56432.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2019-06-04 19:57:46 +02:00
Brand Huntsman
fb10a94f35 startup: prevent a crash when no applicable syntax is found
This fixes https://savannah.gnu.org/bugs/?56434.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-06-04 12:42:24 +02:00
Brand Huntsman
cba9d8d05e rcfile: fully parse a syntax file only when needed
When parsing an included syntax file, stop reading when a command other
than 'syntax', 'header' or 'magic' is encountered.  The syntax file is
fully parsed the first time that a file needs it.  Each 'extendsyntax'
command is stored for unloaded syntaxes and applied after the syntax
is loaded.

Closing a buffer does not unload the syntax, even if no longer used by
another buffer.

This addresses https://savannah.gnu.org/bugs/?54928.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-05-20 10:25:47 +02:00
Benno Schulenberg
c55d144748 tweaks: drop most of the remaining debugging code, and some timing code 2019-05-08 15:23:36 +02:00
Benno Schulenberg
cddfcb1b9d tweaks: rename a struct element, to make sense 2019-03-21 17:23:49 +01:00
Benno Schulenberg
aac4fc46e9 tweaks: rename a type, to make more sense 2019-03-21 17:08:52 +01:00
Benno Schulenberg
916b4d81d0 rcfile: add 'stripecolor' for changing the color of the guiding stripe
The default is now simply reverse video, which works better than a
"loud" colored bar in an interface that for the rest is monochrome.
2019-03-09 09:27:08 +01:00
Benno Schulenberg
79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg
798695ff1e utils: retire the fixbounds() function -- it is no longer needed
All tested systems (FreeBSD, NetBSD, OpenBSD, Alpine, and Ubuntu)
support the GNU-style word boundaries (\< and \>), either natively
or through using the regex module from gnulib.

If this change breaks regexes containing \< or \> on your system,
please report a bug: https://savannah.gnu.org/bugs/?group=nano

This addresses https://savannah.gnu.org/bugs/?55207.
2018-12-31 13:49:07 +01:00
Brand Huntsman
b5ede4ff65 tweaks: remove the 'bright' field from the colortype struct
Put the corresponding value into the 'attributes' field sooner.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-08-25 10:54:20 +02:00