Compare commits

...

816 Commits
v4.0 ... v4.8

Author SHA1 Message Date
Benno Schulenberg
f8d2f552bd po: update translations and regenerate POT file and PO files 2020-02-07 11:23:43 +01:00
Benno Schulenberg
f2ae08ab19 bump version numbers and add a news item for the 4.8 release 2020-02-07 10:50:44 +01:00
Benno Schulenberg
325d774393 locking: accept a minimal amount of data, enough for PID plus username
Maybe reading from a remote filesystem happens in small chunks;
don't call foul when the first chunk contains all we need.
2020-02-06 16:13:22 +01:00
Benno Schulenberg
0856f53703 docs: mention that -D/--boldtext gets overridden by some nanorc options
Also, remove an obsolete anchor, and add a missing word.
2020-02-06 16:07:11 +01:00
Benno Schulenberg
7f0bfdfeb2 docs: put the three new behaviors in a bulletted list, to catch the eye
Also, move the relevant section down in the nanorc man page, to increase
the contrast between the two pages.
2020-02-06 16:07:11 +01:00
Benno Schulenberg
51371e0ca5 tweaks: exclude two unneeded fragments of code from the tiny version 2020-02-05 11:41:31 +01:00
Benno Schulenberg
3bd66b78c1 tweaks: don't bother including Haiku escape sequences in the tiny version 2020-02-05 11:31:03 +01:00
Benno Schulenberg
5ea6054a75 tweaks: use a simple subtraction instead of a function call 2020-02-05 11:29:36 +01:00
Benno Schulenberg
04738996fc tweaks: rename two parameters, to be more general and to sound shorter 2020-02-04 17:32:05 +01:00
Benno Schulenberg
07a9477213 tweaks: rename five variables, away from a single letter 2020-02-04 17:20:37 +01:00
Benno Schulenberg
a5b48f9a0d build: fix compilation for --enable-{tiny,help,multibuffer} 2020-02-04 12:58:57 +01:00
Benno Schulenberg
d141e849a3 tweaks: unabbreviate "argument" in the documentation
Also, show that the argument in the extendsyntax format is not optional,
as any command requires at least one argument.  Also mention 'tabgives'
among the commands that are allowed in an included file.
2020-02-04 12:23:58 +01:00
Benno Schulenberg
da68ee19e7 tweaks: reorder two symbols 2020-02-04 11:41:05 +01:00
Benno Schulenberg
8b2f7bd5a2 tweaks: drop a message that will never be seen
Since the previous commit, nano exits from curses mode soon after
this message is printed, so that the user does not have any time
to read it or even see it.
2020-02-03 19:59:58 +01:00
Benno Schulenberg
6119756347 speller: avoid messing up the screen when an unknown locale is used
When invoking the "internal" speller, leave curses mode while the three
programs in the pipe array are executing, to prevent 'hunspell' from
writing a long error message to the end of the status bar, making the
screen scroll, and thus messing it up.  Now the error message gets
printed to the screen that nano was started up from, and will thus be
visible when the user exits from nano.  (At least: it will be so on a
terminal emulator -- on a VT, nothing will be seen.)

This fixes https://savannah.gnu.org/bugs/?57728.

Bug existed since version 4.6, commit 4d77e0ad.
2020-02-03 13:50:33 +01:00
Benno Schulenberg
06c80b6ccd tweaks: rearrange a few global variables, to group things better 2020-02-02 17:05:06 +01:00
Benno Schulenberg
7ce1f6d86d locking: when finding a lock file at startup, quit when user cancels
When at startup the user presses Cancel at the "open anyway?" prompt,
cancel the whole startup: quit.  But when the user answers No, just
skip the file and continue starting up.
2020-02-02 13:00:37 +01:00
Benno Schulenberg
88087f2b2f tweaks: move a function to related ones, and after one that it calls 2020-02-02 12:26:33 +01:00
Benno Schulenberg
16c4f5bbd0 tweaks: move a function to be before the ones that call it 2020-02-02 12:21:28 +01:00
Benno Schulenberg
e877c2406e tweaks: allocate the lock data only when ready to write them 2020-02-02 12:05:45 +01:00
Benno Schulenberg
b6a1583e8e tweaks: take just one shot at reading the lock file, and correct a type
Don't bother looping until the 1024 bytes are read.  Writing the lock
file takes just one shot too, and that is more important to get right.

Also, correct the type for the result of read(), so that -1 doesn't
get turned into a positive number, which would mean that any error
would get ignored.
2020-02-02 11:41:20 +01:00
Benno Schulenberg
48df800db3 tweaks: rewrite the same file name into the lock file as the first time
It would be better if nano wrote the full filename into the lock file,
because that would be clearer when Vim displays its warning, but...
this is faster and will do for now.

(Nano should simply also store the full filename in the openfile struct,
so that get_full_path() needs to be called just once for each file.)

This addresses https://savannah.gnu.org/bugs/?57713.
2020-02-02 11:22:22 +01:00
Benno Schulenberg
ee05daab92 tweaks: do not leak a file descriptor when fdopen() fails 2020-02-02 11:08:59 +01:00
Benno Schulenberg
74f4c37d5f locking: avoid crashing when there is a problem writing the lock file
The call of ferror() as parameter of a %s specifier was a mistake --
it returns a number, not a string.  Avoid the problem by combining
two error checks.

The man page of fwrite() does not say anything about errno, but I guess
that the function calls write() and that the possible error numbers of
that function apply.

In theory it is now possible that fclose() fails and returns an error
that then masks an earlier error of fwrite().  But I can't be bothered:
lock files are not essential, and any errors that might occur are most
likely overlooked anyway because they are not displayed in red.

This fixes https://savannah.gnu.org/bugs/?57724.

Bug existed since lock files were introduced, in version 2.3.2,
commit bf88d27a.
2020-02-02 10:55:19 +01:00
Benno Schulenberg
3f5ba950d6 tweaks: suggest a few more alternative key bindings and unbindings
This demonstrates the presence of the 'savefile' function,
and makes the main help text look better.
2020-01-31 17:16:31 +01:00
Benno Schulenberg
0a52e92d4c docs: for the alternative bindings, rebind ^C only in the main menu
Because ^C is needed for Cancel in most other menus.

This fixes https://bugs.debian.org/950223.
Reported-by: Jonas Smedegaard <dr@jones.dk>

Bug existed since version 4.0, commit 3a170d2c.
2020-01-31 16:54:55 +01:00
Benno Schulenberg
7c57806c6f rcfile: require "bright", "start=", and "end=" to be in lowercase too 2020-01-31 16:11:38 +01:00
Benno Schulenberg
a2f8703df5 tweaks: tumble three conditions, for consistency in comparisons 2020-01-31 16:05:51 +01:00
Benno Schulenberg
073251fdb1 tweaks: condense two comments, and reshuffle an #endif
There is no need to fake success when the whole writing of the lock file
is skipped, because also a zero return value means "continue anyway".
2020-01-31 11:39:11 +01:00
Benno Schulenberg
5a0ee3c2f9 tweaks: harmonize the amount of lock data that we read and write
All the things that we need are located within the first 68 bytes of
the .swp file.  We do write byte 1007 when the file is modified, but
we never reference it.  We always wrote just 1024 bytes to the .swp
file, so it makes no sense to read in any more than that.

(Vim writes 4096 bytes to a .swp at first, before adding undo stuff
four seconds later.  But the 1024 bytes appear to be enough for Vim
to recognize it as a lock file.)
2020-01-31 11:06:11 +01:00
Benno Schulenberg
6bd5dce954 tweaks: ensure that editor name and user name are NUL terminated
When copying those pieces from a lock file, it is not certain that
they end with a NUL character.
2020-01-30 20:00:17 +01:00
Benno Schulenberg
f25059c244 tweaks: frob a couple of indentations and white lines 2020-01-30 19:55:26 +01:00
Benno Schulenberg
856f2c433e feedback: ask a clearer question when a valid lock file is encountered
When asking "continue?", I always thought that answering No would mean
that nano would not continue, that it would stop, that it would abort.
But No only means that it will not open the relevant file but continues
anyway to start up.  Asking "open anyway?" is more easily understood in
that way.
2020-01-30 19:44:25 +01:00
Benno Schulenberg
38c5a4465b tweaks: reshuffle some assignments for a return value 2020-01-30 19:43:19 +01:00
Benno Schulenberg
f494bfcbb9 locking: when a lock file is unreadable, open the file itself anyway
Unreadable or corrupt lock files are not a user error nor user intent,
so they should not keep the user from editing the corresponding file.

Also, combine some error conditions to compact the code.

This addresses https://savannah.gnu.org/bugs/?57700.
2020-01-30 19:10:34 +01:00
Benno Schulenberg
b856fc4664 locking: check two magic bytes, to verify that it is a lock file
Also, when the check fails, then nano should continue and simply
open the file, just like Vim.

This fixes https://savannah.gnu.org/bugs/?57698.
2020-01-30 18:48:35 +01:00
Benno Schulenberg
faa96ead44 tweaks: correct the description of what nano writes into the lock file
Also, limit the stored program's name to ten bytes.  Vim uses four for
its name plus a space, and a maximum of six for its version number.
2020-01-30 17:44:04 +01:00
Benno Schulenberg
26444bf8df tweaks: reformat a comment, and resuffle a line to match byte order 2020-01-30 15:55:42 +01:00
Benno Schulenberg
4eaade2938 gnulib: update to its current upstream state 2020-01-29 19:48:15 +01:00
Benno Schulenberg
662e8b2d20 tweaks: remove some superfluous conditions for rewriting a lock file
A lock file needs to be rewritten (with the modified flag) only when the
relevant lock file already exists.  All other conditions are redundant.
2020-01-29 19:38:07 +01:00
Benno Schulenberg
4502295a34 locking: do not write a lock file when in view mode
When in view mode, the file cannot be edited, so there is no need to
warn anyone (through a lock file) that the file might soon change.

This fixes https://savannah.gnu.org/bugs/?57694.
2020-01-29 19:14:41 +01:00
Benno Schulenberg
25b0bf0ae8 tweaks: correct a couple of comments about escape sequences 2020-01-29 18:48:03 +01:00
Benno Schulenberg
f6b6bc47d6 tweaks: remove a redundant call, as there is nothing to free there
At that point, 'u->cutbuffer' will always be NULL, either from the
original creation of the INSERT undo item, or by having been freed
and set to NULL by do_redo().
2020-01-29 12:33:55 +01:00
Benno Schulenberg
a692b01c04 tweaks: reshuffle two lines, to do the linking first, then the content 2020-01-29 12:33:30 +01:00
Benno Schulenberg
a197ccf12d tweaks: move another function, to group the deleting ones together 2020-01-29 12:16:09 +01:00
Benno Schulenberg
67e5913edf tweaks: move another function to before the one that calls it 2020-01-29 10:54:30 +01:00
Benno Schulenberg
e864107046 tweaks: move a function to right before the one that calls it 2020-01-29 10:53:05 +01:00
Benno Schulenberg
7984ea4eb6 tweaks: remove two superfluous assignments, and rename a variable
The 'prev' and 'next' links get assigned to immediately after the
call of copy_node().  And anyway, it does not make sense to link
a copied node to the predecessor and successor of its original.

Also slightly regroup some lines.
2020-01-29 10:47:09 +01:00
Benno Schulenberg
f38bd5030d tweaks: add a little change that was overlooked in the previous commit
Option --showcursor applies also to the help viewer, which means that
it can do something useful in restricted mode too.
2020-01-28 12:00:05 +01:00
Benno Schulenberg
a2fea9928d build: exclude option '-g' when configured without browser and help 2020-01-28 10:33:56 +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
445cd2a6c5 usage: improve the description of --restricted and --quickblank
Give a little more information than just a rehash of the long option.
2020-01-28 10:04:01 +01:00
Benno Schulenberg
fb073ec88d display: ensure the guiding stripe can be shown when not softwrapping
This fixes https://savannah.gnu.org/bugs/?57683.

Bug existed since commit 0b54785f from yesterday.
2020-01-28 09:35:45 +01:00
Benno Schulenberg
c09e96f294 suspension: put in an extra terminal-initialization call for Slang
Also, the disabling of the keyboard interrupt (SIGINT) must happen
after that initialization call, otherwise ^C will still do nothing
after returning from suspension (when nano is built against Slang).

This fixes https://savannah.gnu.org/bugs/?57656.

Bug existed since version 2.2.0, commit daaf468c.
2020-01-27 16:46:01 +01:00
Benno Schulenberg
0b54785fe5 softwrap: suppress the guiding stripe on unaffected chunks
When the guiding stripe (when softwrapping) will be shown in
a later chunk, it shouldn't be shown in the current chunk.

This fixes https://savannah.gnu.org/bugs/?57654.

Bug existed since --guidestripe was introduced, in version 4.0.
2020-01-27 15:46:57 +01:00
Benno Schulenberg
8835c0d486 tweaks: reduce the scope of a variable, and reshuffle a declaration 2020-01-27 13:36:28 +01:00
Benno Schulenberg
0442eef95b tweaks: elide a somewhat costly call by remembering some state
When having prepared a line for displaying on the screen, nano already
determind whether the line extends beyond the right edge or not.  There
is no need to calculate again the full width of the current line later.
Just let display_string() make a note whether the piece of text that
it converted to displayable form still has more text coming after it,
and use this note when it's time to show the ">" continuation sign.

Using a static variable is ugly, but passing it along as a parameter
would be even uglier, because for all other calls of display_string()
the parameter would be just a useless burden.
2020-01-27 13:23:56 +01:00
Benno Schulenberg
6ae11071b3 tweaks: add an error message for something that should never occur 2020-01-27 12:06:27 +01:00
Benno Schulenberg
3c177c1bb9 tweaks: elide a variable, and rename its sister 2020-01-26 19:23:37 +01:00
Benno Schulenberg
e0213b1a41 tweaks: drop a pointless suffix from two function names 2020-01-26 16:36:23 +01:00
Benno Schulenberg
e70ff87c86 tweaks: move another function to after the one that it calls
(The diff is stupid.  It should just remove 440 contiguous lines, and
add back 440 contiguous lines further down.  Instead it tries to find
similarities between what is moved and what remains, and makes a mess.
You have to use --patience or --minimal to get the better diff.)
2020-01-26 16:21:21 +01:00
Benno Schulenberg
db10a421dc tweaks: move a function to after the one that it calls 2020-01-26 16:21:21 +01:00
Benno Schulenberg
5725336149 tweaks: slightly condense a function by conflating case 2020-01-26 16:21:21 +01:00
Benno Schulenberg
b8ba27bbc0 tweaks: fuse two nearly identical functions into a single one
The plain keys that are valid in the help viewer are a perfect subset of
those that are valid in the file browser, so just use the same function
to do the interpretation for both.  It is not a problem that it returns
function pointers for some keystrokes that have no meaning in the help
viewer, because both NULL and an unhandled function pointer result in
the "Unbound key" message.
2020-01-26 16:20:37 +01:00
Benno Schulenberg
e3f6638a76 prompt: for a Yes-No-All, accept the first character of an external paste
Allow the user to paste in the character for Yes, No, or All.  If the
paste contains more than one character, ignore all but the first.

This fully fixes https://savannah.gnu.org/bugs/?57623.
Reported-by: Brand Huntsman <alpha@qzx.com>
2020-01-26 12:22:49 +01:00
Benno Schulenberg
f8553f6d3a feedback: restore a message that can occur in help viewer or file browser
It was mistakenly removed in commit ea874112, two days ago.
2020-01-24 19:45:07 +01:00
Benno Schulenberg
a78da18aa4 input: ignore bracketed pastes in help viewer and file browser
This partially fixes https://savannah.gnu.org/bugs/?57623.
Reported-by: Brand Huntsman <alpha@qzx.com>
2020-01-24 19:20:21 +01:00
Benno Schulenberg
d764d7094f tweaks: don't enable bracketed pasting when not handling such pastes
The tiny version is oblivious of bracketed pastes, as it serves no
purpose: in the tiny version there is no auto-indent nor undo nor
tabs-to-spaces conversion.
2020-01-24 17:21:47 +01:00
Benno Schulenberg
2651554721 syntax: nanorc: colorize all-lowercase Meta key binds as valid too
Also, colorize as valid only ASCII letters, not any Unicode letters.
2020-01-23 13:34:37 +01:00
Benno Schulenberg
fa686457c2 input: ignore modifiers on a VT while executing a macro or a string bind
Any modifier keys that are needed to start the execution of a macro
(or of a string bind) should not affect the interpretation of the
keystrokes that are contained within the macro or the string.

This fixes https://savannah.gnu.org/bugs/?57660.

Bug existed since macros were introduced, in version 2.9.0.
2020-01-23 12:39:23 +01:00
Benno Schulenberg
a65f0ec80c tweaks: elide a function that has become too small for its two calls 2020-01-23 12:06:32 +01:00
Benno Schulenberg
e01e1d8ab5 tweaks: remove the now-unused meta flag from 'keystruct' 2020-01-23 12:06:32 +01:00
Benno Schulenberg
58597b6d9b tweaks: judge from the key code itself whether it is a Meta keystroke 2020-01-23 12:06:32 +01:00
Benno Schulenberg
196e913681 tweaks: elide three checks of a shortcut's meta flag
A control code cannot be a Meta keystroke, and a plain printable
character as key code necessarily means it is a Meta keystroke.
So, comparing just the key code is enough.
2020-01-23 12:06:32 +01:00
Benno Schulenberg
620553b795 input: filter out Ctrl+Meta keystrokes, as they can never be shortcuts
Note that DEL_CODE (0x7F) will never occur as input key code, because
it gets translated to KEY_DC in the input routine (or to KEY_BACKSPACE
when --rebinddelete is in effect).
2020-01-23 12:06:32 +01:00
Benno Schulenberg
6df50790cd input: prevent unintentional marking of text for shifted Meta keystrokes
The Shift detection on a Linux console was meant to affect only the
dedicated cursor-movement keys, not <Shift+Meta+character>.

This fixes https://savannah.gnu.org/bugs/?57598.
Indirectly-reported-by: Brand Huntsman <alpha@qzx.com>
2020-01-23 11:22:23 +01:00
Benno Schulenberg
6cd98e32f7 docs: document the new Sh-M-X format for binding <Shift+Meta+letter> 2020-01-23 11:11:34 +01:00
Benno Schulenberg
f9baa4de71 syntax: nanohelp, nanorc: colorize the Sh-M-X format as a valid key name 2020-01-23 11:11:34 +01:00
Benno Schulenberg
1cd5005d06 bindings: allow to bind shifted Meta+letter combinations with Sh-M-X
As long as the user does not define any Sh-M-X bindings in their nanorc,
<Shift> and <CapsLock> will not have any effect on <Alt+letter> combos.
But as soon as any Sh-M-X combination is bound, <Shift+Alt+letter> will
be seen as different from the unshifted keystroke.

This kind of fulfills https://savannah.gnu.org/bugs/?54659.
Requested-by: Peter Passchier <peter@passchier.net>
2020-01-23 11:11:34 +01:00
Benno Schulenberg
f7a3b996fa bindings: force the first letter in a key name to uppercase
So that converting it to a key code remains easy.

This fixes https://savannah.gnu.org/bugs/?57655.

Bug existed since commit 077d307b from yesterday.
2020-01-22 19:05:23 +01:00
Benno Schulenberg
ea874112d8 tweaks: remove a feedback message that is never shown
A plain printable ASCII character (from 0x20 to 0x7E) can never be
a shortcut, so it also can never get reported as being unbound.
2020-01-22 15:41:04 +01:00
Benno Schulenberg
25d397e7b3 feedback: report Ctrl+Alt keystrokes as unbindable
When reporting them as simply unbound, the user might think that M-^X
keystrokes might somehow become bound.
2020-01-22 15:10:41 +01:00
Benno Schulenberg
5111b20bf5 build: exclude bracketed pasting from the tiny version 2020-01-22 12:58:48 +01:00
Benno Schulenberg
f571d6ba36 tweaks: gather four calls that are always done together into a function 2020-01-22 12:49:00 +01:00
Benno Schulenberg
0e21baf611 tweaks: reshuffle three lines, to make the grouping tighther 2020-01-21 15:47:03 +01:00
Benno Schulenberg
1e78881a70 tweaks: avoid analyzing the key string when the target key code is known
For the special keys, pass the key code directly, so that later on
keycode_from_string() does not need to be called.
2020-01-21 15:40:28 +01:00
Benno Schulenberg
077d307b30 tweaks: trim some excessive error checking and key-name frobbing
Also, it is clearer to say that "key name %s is invalid" than it is
to say that some unspecified key name is too short.
2020-01-21 12:14:07 +01:00
Benno Schulenberg
998992ddcb tweaks: condense three comments to one, and do the masking more directly 2020-01-20 19:00:44 +01:00
Benno Schulenberg
0ff9499583 tweaks: reshuffle some lines, to avoid tallying the menus when not needed 2020-01-20 17:44:41 +01:00
Benno Schulenberg
eb1668ce81 tweaks: reshuffle some declarations 2020-01-20 17:44:01 +01:00
Benno Schulenberg
54b97a6f03 bindings: allow to rebind also ^`, although it is synonymous with ^Space
Since ^@ is rebindable too and also a synonym of ^Space, it makes
more sense to allow the user to specify ^` instead, as it is an
unshifted keystroke on US keyboards.

Also, color ^` as valid in a nanorc file, and color ^` and ^@ in
the help viewer.
2020-01-20 17:19:23 +01:00
Benno Schulenberg
5e48c36877 rcfile: do set the meta flag for plain <Meta+ASCII> combinations
The meta flag needs to be suppressed only for the self-defined
<Meta+arrow> key codes.

This fixes https://savannah.gnu.org/bugs/?57643.

Bug existed since commit 5130c35b from a few hours ago.
2020-01-20 16:37:15 +01:00
Benno Schulenberg
9e3fca4021 rcfile: unbind keys by their key code instead of by their key string
Some key strings map to the same key code, so to unbind also a string's
synonyms, go through the list comparing against the key code.  It has
the additional advantage that it is faster: a plain value comparison
instead of a string comparison.

There is no need to compare also the meta flag, because plain printable
ASCII characters (from 0x20 to 0x7E) cannot be shortcuts, so when such
a character matches, it necessarily means it is a meta keystroke.

This fixes https://savannah.gnu.org/bugs/?57397.
2020-01-20 15:44:17 +01:00
Benno Schulenberg
5130c35b85 tweaks: avoid determining the key code from the key string twice
When assign_keyinfo() gets passed zero as key code, it will call
keycode_from_string() to determine the key code from the string.
So, remember the key code when keycode_from_string() gets called
the first time to avoid the second call.
2020-01-20 15:41:34 +01:00
Benno Schulenberg
e01651cde1 pasting: retain the mark's position when it was set at the cursor
When the mark is set at the current cursor position, and then something
is pasted (either with ^U or from outside of nano), then this entire
pasted text should be marked -- just like when it had been typed.  So,
the mark's position should not be adjusted not only when it is located
before the cursor but also when it is at the same place as the cursor.

This fixes https://savannah.gnu.org/bugs/?57631.

Bug existed since version 2.0.7.
2020-01-20 10:34:27 +01:00
Brand Huntsman
12cf1c9980 input: beep when invalid key is pressed at yesno prompt or in linter menu
Just like nano beeps when an unbound key is pressed at other prompts,
or in the help viewer, or in the file browser.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2020-01-19 16:37:14 +01:00
Benno Schulenberg
092711e412 tweaks: remove the now-unneeded code related to bracketed pasting
The suppression of auto-indentation, automatic hard-wrapping, and
tab-to-spaces conversion is now inherent in the way the reading-in
of a bracketed paste is handled by the previous commit: as a single
block of text.
2020-01-19 14:44:28 +01:00
Benno Schulenberg
0e6d693dc8 input: read in an external paste in one go, to allow undoing with one M-U
This makes an external paste (with mouse or <Shift+Insert>) behave
the same as an internal paste (^U), and also inherently suppresses
auto-indentation, automatic hard-wrapping, and tab conversion.

This fulfills https://savannah.gnu.org/bugs/?54950.
2020-01-19 14:44:28 +01:00
Benno Schulenberg
aac3126183 docs: improve the description of which rc-files are read during startup 2020-01-19 13:27:41 +01:00
Benno Schulenberg
63cddceeaa docs: document the new -f/--rcfile option 2020-01-19 12:55:43 +01:00
Benno Schulenberg
486d4956ff tweaks: elide an 'if', by moving the relevant code to a better place 2020-01-17 19:19:22 +01:00
Benno Schulenberg
7567a67cdd tweaks: elide a small function, as it's in fact needed just once 2020-01-17 19:19:04 +01:00
Benno Schulenberg
c4939c76a5 tweaks: rename a function, to make it not contain the name of another
Also, improve the names of its two parameters,
and make the tiny version a wee bit smaller.
2020-01-17 17:28:48 +01:00
Benno Schulenberg
04e557fdaf tweaks: avoid fiddling with the keybuffer when it's not needed
Just change KEY_MOUSE directly into KEY_ENTER for a double click.
2020-01-17 17:06:17 +01:00
Benno Schulenberg
7dcc8f1d7a tweaks: adjust the indentation after the previous change
Also reshuffle some lines, and adjust the comments.
2020-01-17 16:51:21 +01:00
Benno Schulenberg
343f97b3ac new feature: allow specifying a custom nanorc file on the command line
This fulfills https://savannah.gnu.org/bugs/?57547.
Requested-by: Saagar Jha <saagar@saagarjha.com>
2020-01-17 16:51:21 +01:00
Benno Schulenberg
706f3e93f4 tweaks: in comments, reword "titlebar" and "statusbar" to two words each
To differentiate them from the function names.
2020-01-16 19:37:28 +01:00
Benno Schulenberg
f47ef539db display: skip zero-width characters on a Linux console, to avoid a mess
This is a workaround for the VT not being able to handle zero-width
characters properly, displaying them mistakenly as visible characters.

This avoids https://savannah.gnu.org/bugs/?52954.

The problem has existed since forever, but has become noticeable
since the capability for line numbers was added in version 2.7.1.
2020-01-15 18:50:44 +01:00
Benno Schulenberg
2148e857e5 copyright: update the years for significantly changed files 2020-01-15 12:11:56 +01:00
Benno Schulenberg
afa4c6b9fc copyright: update the years for the FSF 2020-01-15 11:42:38 +01:00
Benno Schulenberg
27127853db tweaks: exclude an unneeded fragment of code from the tiny version 2020-01-14 16:28:28 +01:00
Benno Schulenberg
a81ba0215a display: exclude a bit of feedback from the tiny version 2020-01-14 11:22:28 +01:00
Benno Schulenberg
3e0bd533db tweaks: free two strings as soon as they are no longer needed 2020-01-14 11:01:32 +01:00
Benno Schulenberg
e8d20a8e4b display: clear the help lines before a briefly shown warning
This makes the message stand out more.

Also slightly shorten the duration of the pause.
2020-01-14 10:49:12 +01:00
Benno Schulenberg
6896d8df47 tweaks: reduce the scope of two constants and of four variables 2020-01-14 10:35:54 +01:00
Benno Schulenberg
8455251c35 files: revert the previous commit, as the extra warning is annoying
It also erroneously left the succeeding prompt on the screen.

This fixes https://savannah.gnu.org/bugs/?57593.
2020-01-13 21:42:44 +01:00
Benno Schulenberg
5cf351913e files: warn doubly when the user is about to overwrite an existing file 2020-01-13 20:05:56 +01:00
Benno Schulenberg
416386edcd files: alert the user afterward when an overwritten file is being edited
(The ideal behavior would be that nano would warn the user beforehand,
before the file that is being edited by someone else gets overwritten,
but that would require many more changes.  So... just give a helpful
warning -- that's already better than it was.)
2020-01-13 20:00:07 +01:00
Benno Schulenberg
497f126bb2 files: write a lock file also for a new file and when the name changed
(When the new or changed name is that of an existing file AND this
file is being edited by some other editor (or nano itself), then the
behavior is rather strange: nano asks whether to continue, but the
file has already been overwritten and there is nothing the user can
do to cancel or revert things.  A later commit should improve this.)

This fixes https://savannah.gnu.org/bugs/?47975,
and fixes https://savannah.gnu.org/bugs/?53883.
2020-01-13 20:00:07 +01:00
Benno Schulenberg
4687322398 tweaks: rewrap two lines, for consistency with similar lines 2020-01-13 20:00:07 +01:00
Benno Schulenberg
99f0265d34 tweaks: condense a fragment of code 2020-01-12 12:32:20 +01:00
Benno Schulenberg
7b0b9a12ea docs: mention in the FAQ that auto-indentation is suppressed when pasting
And that ^Js will be filtered out too.
2020-01-12 12:09:09 +01:00
Benno Schulenberg
7d483987ce input: do not auto-indent when something is pasted into nano from outside
Also, do not break overlong lines and do not convert tabs to spaces,
nor interpret a <Tab> as an indent command (when the mark is on).
In other words: accept an outside paste as literally as possible.

This fulfills https://savannah.gnu.org/bugs/?40060.
Requested-by: Egmont Koblinger <egmont@gmail.com>

And fulfills https://savannah.gnu.org/bugs/?57527.
Requested-by: Sébastien Desreux <seb@h-k.fr>
Requested-by: Hans Ecke <hecke@gxt.com>

Original-idea-by: Brand Huntsman <alpha@qzx.com>
2020-01-12 11:18:51 +01:00
Brand Huntsman
f705a9674b input: recognize the start and stop sequences of a bracketed paste
Also, tell the terminal to switch on bracketed-paste mode, and toggle
a boolean when the start and stop sequences of such a paste are seen.
This boolean can later be used to suppress auto-indent and such.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2020-01-12 11:18:51 +01:00
Benno Schulenberg
3233e9cfe0 tweaks: correct a comment
The maximum length was increased two weeks ago, in commit 4dcbd40c.
2020-01-12 11:18:29 +01:00
Benno Schulenberg
5a98a51173 bindings: do not show the Full-Justify keystroke when in View mode
The file may not be modified when in View mode, so it makes no sense
to prominently show the M-J keystroke in the Search menu when in that
mode, especially since the keystroke does not really belong there.

This addresses https://savannah.gnu.org/bugs/?57574.
2020-01-10 17:24:29 +01:00
Benno Schulenberg
2eaba21a4c help: increase the minimum help-text width from 24 to 32 columns
Even at 32 columns, the key descriptions are already hopelessly
fragmented.  Any width smaller than that is useless.
2020-01-09 15:10:52 +01:00
Benno Schulenberg
9a227de3e7 tweaks: recompute the wrapping point just once
Instead of for every row after the intro.
2020-01-09 14:47:48 +01:00
Benno Schulenberg
3f57200e10 help: prevent double spaces from protruding across the right edge
This fixes https://savannah.gnu.org/bugs/?57563.
2020-01-09 12:02:49 +01:00
Benno Schulenberg
1486f32d42 help: when a key description wraps, indent its wrapped part
This prevents the wrapped text from cluttering up the two key columns.

This addresses https://savannah.gnu.org/bugs/?57451.
2020-01-09 11:37:49 +01:00
Benno Schulenberg
e3edce4e7b tweaks: elide a helper function, in preparation for an improvement 2020-01-09 11:02:36 +01:00
Benno Schulenberg
0e559c5bbc tweaks: initialize three more booleans straightaway, at declaration
Also improve three comments.
2020-01-09 10:37:56 +01:00
Benno Schulenberg
edfbfbfd0a tweaks: initialize three booleans straightaway, when they are declared
Also improve three comments.
2020-01-08 16:55:45 +01:00
Benno Schulenberg
a4eae770ce tweaks: rename a function, to be a bit more expressive 2020-01-08 16:13:04 +01:00
Benno Schulenberg
72e5c15110 tweaks: move three functions to the file where they are mainly used
The extract() and copy_from_buffer() functions are mainly used for
cutting a line or a region, so move them to src/cut.c.  Also move
the function for which copy_from_buffer() is a wrapper.
2020-01-08 16:04:49 +01:00
Benno Schulenberg
97c8140cea tweaks: rename two functions, to make more sense 2020-01-08 11:09:57 +01:00
Benno Schulenberg
c5b03ca4ae tweaks: rename two variables, to make more sense 2020-01-08 11:00:51 +01:00
Benno Schulenberg
c2f2c659d9 tweaks: rename a parameter and invert its logic, and correct a comment
This changes the main injection routine in the same way that the prompt
injection routine was changed four years ago in commit e540053e.
2020-01-08 10:49:19 +01:00
Benno Schulenberg
9364bd6c81 tweaks: reword two comments, and rewrap another 2020-01-08 10:27:30 +01:00
Benno Schulenberg
baa2be3217 tweaks: improve a comment by indirectly referring to the ncurses docs
See https://invisible-island.net/ncurses/ncurses-intro.html#xterm.
2020-01-07 20:25:31 +01:00
Benno Schulenberg
12742586e5 tweaks: adjust or reword a few items in the FAQ 2020-01-07 16:55:30 +01:00
Benno Schulenberg
194620c5f0 docs: add a FAQ item about a self-compiled nano not reading /etc/nanorc 2020-01-07 14:34:23 +01:00
Benno Schulenberg
67d37adf98 tweaks: renumber some FAQ items in preparation for adding another 2020-01-07 14:24:47 +01:00
Benno Schulenberg
3f0d2fd5ca display: don't let a message write over the second help line
When suspending nano on a Linux console (or FreeBSD console), the
helpful message about using the 'fg' command overwrote the start
of the second help line, kind of hiding the message.  So, output
a double newline before the message to make it stand out.

Also, drop a pointless cursor movement, as endwin() determines
the placement of the cursor all by itself.
2020-01-07 13:38:52 +01:00
Benno Schulenberg
5b07e5fd1f input: discard partial sequences that Slang produces for F17 to F24
This fixes https://savannah.gnu.org/bugs/?57503.
2020-01-03 12:34:15 +01:00
Benno Schulenberg
3cae32390d display: show the cursor during suspension also when built with Slang
This fixes https://savannah.gnu.org/bugs/?57517.

Bug existed since version 2.9.0.
2020-01-03 12:08:27 +01:00
Benno Schulenberg
1be0285832 tweaks: delete some fragments of code that have become irrelevant
Since the previous commit, USE_SLANG can only be defined when NANO_TINY
is also defined.  This means that code that is present only in non-tiny
versions does not need to cater for Slang.
2020-01-03 12:00:06 +01:00
Benno Schulenberg
2867f1bbde build: restrict the use of --with-slang to together with --enable-tiny
Slang contains bugs that get triggered when resizing the terminal,
or rather: when its existing data structures get reinitialized.
Avoid those bugs by forcing the exclusion of the resizing code
when nano is configured with --with-slang.

(The only reason for not entirely eliminating the support for Slang
is to allow Debian to build a tiny nano against Slang for on their
install image.)

This avoids https://savannah.gnu.org/bugs/?57520,
and avoids https://savannah.gnu.org/bugs/?57518,
and dodges https://savannah.gnu.org/bugs/?57513,
and dodges https://savannah.gnu.org/bugs/?57507.
2020-01-03 11:41:22 +01:00
Benno Schulenberg
c4d2bf59fb display: adjust line and column count upon a resize also when using Slang
This partially fixes https://savannah.gnu.org/bugs/?57513.
2020-01-01 14:17:03 +01:00
Benno Schulenberg
5527883c43 input: don't discard the first keystroke after a resize when using Slang
With ncurses, a window resize will cause getch() to return immediately
with some dummy value, which nano can discard.  But with Slang, getch()
will return only when the next keystroke is typed, so the received code
should then not be discarded.

This fixes https://savannah.gnu.org/bugs/?57507.
2020-01-01 13:54:07 +01:00
Benno Schulenberg
ade93ccf25 docs: use more generally available arrows in the cheatsheet
Use bolded HTML entities for the four arrows, instead of the literal
triangular Unicode "arrows" which many fonts don't include.

This addresses https://savannah.gnu.org/bugs/?57505.
2019-12-30 16:41:22 +01:00
Benno Schulenberg
84b305f3f0 build: exclude the escape sequences for F13...F16 from the tiny version
The F13 to F16 function keys are no longer bound by default, and when
there is no nanorc file, there is no way to bind them, so there is no
point in recognizing their escape sequences.
2019-12-30 11:55:41 +01:00
Benno Schulenberg
67b89459d5 tweaks: drop an unneeded call of keypad() -- we never read from topwin
The title bar is used only for showing things, never for typing anything
into.  That is: we never call wgetch() with 'topwin' as an argument.
2019-12-29 14:14:08 +01:00
Benno Schulenberg
6d916c6c4a tweaks: rewrap a comment and a line, and reshuffle a fragment of code 2019-12-29 14:13:27 +01:00
Benno Schulenberg
87542eeaf1 tweaks: move a function to before the one that calls it
And condense its logic.  And improve its comment.
2019-12-27 17:01:15 +01:00
Benno Schulenberg
29f2e3181a tweaks: rename a function and its parameter, to be more fitting
Also, avoid calling a case-changing function when it's not needed.
And elide a default case that can never occur (because the function
always gets called with one of the four letters).
2019-12-27 16:48:07 +01:00
Benno Schulenberg
8255696b45 tweaks: condense five more fragments of repetitious code 2019-12-27 13:49:03 +01:00
Benno Schulenberg
fc00e89499 tweaks: comment fully, so that all handled escape sequences are findable
Also correct a few other comments.
2019-12-27 13:48:36 +01:00
Benno Schulenberg
55946c15e7 tweaks: reshuffle some lines, to group all ignored keystrokes together 2019-12-27 12:16:50 +01:00
Benno Schulenberg
2e539e2c97 tweaks: stop recognizing escape sequences for a key without meaning
Nano does not do anything for the keystroke anyway (KEY_B2, the center
key on the numeric keypad, gets translated to ERR later on), so there
is no point in recognizing some of its escape sequences -- let those
sequences result in "Unknown sequence" instead.
2019-12-27 12:13:40 +01:00
Benno Schulenberg
38c286c019 input: recognize the raw escape sequences for F13 to F16 on xterm too
For symmetry with Gnome Terminal, Konsole, and the Linux console.

This fixes https://savannah.gnu.org/bugs/?57482.
2019-12-26 17:07:51 +01:00
Benno Schulenberg
56d842258c tweaks: condense three fragments of repetitious code 2019-12-26 16:50:19 +01:00
Benno Schulenberg
8ed8ab69d5 tweaks: make a couple of comments more precise 2019-12-26 14:32:44 +01:00
Benno Schulenberg
4dcbd40c49 input: consume and ignore the raw escape sequences for F17 to F24
When --rawsequences is used, consume the full escape sequences for
the F17 to F24 function keys (on xterm-compatible terminals and on
the Linux console), to prevent them entering junk into the buffer.

This fixes https://savannah.gnu.org/bugs/?57483.
2019-12-26 14:02:17 +01:00
Benno Schulenberg
72645b160d input: correct the escape sequence for PageUp/PageDown on Eterm/Urxvt
There is not a single terminal in the terminfo database that has an
"Esc [ n ^" sequence for any keystroke (where n is a digit).
2019-12-26 12:23:08 +01:00
Benno Schulenberg
dda1b167c9 help: don't waste the last column in the help viewer on narrow terminals
When a line in a help text is wider than the terminal, then do not break
that line at COLS - 1, but simply at COLS.  In olden times it made some
sense to have an empty column on the right of the introductory text, to
mirror the one on the left.  But since the width of the introductions
got limited to 74 columns (four years ago, in commit a9aa0ef9), those
texts have (on a default 80-column terminal) at least six empty columns
on their righthand side.  And on narrower terminals, we really don't
want to waste anything and should use all available space.

Also, this whole mechanism of making an exception for end-of-string or
end-of-paragraph and letting only those make use of the final column,
it was a waste of time: it kind-of did the whole break_line() process
again, but then for the entire string (which can be some five hundred
characters long in the introductory texts).  So... get rid of it, make
it simple.  On an 80-column terminal it doesn't make any difference.
2019-12-25 14:39:17 +01:00
Benno Schulenberg
074cf40409 tweaks: remove a superfluous check
When break_line() is called with its last parameter set to TRUE
(meaning that it will break also at a newline) it will return a
value that is bigger than 1.  So it is pointless to ensure that
it is at least 1.
2019-12-25 14:32:04 +01:00
Benno Schulenberg
6c09504040 docs: stop saying that 'set fill' enables hard-wrapping -- it does not
This fixes https://savannah.gnu.org/bugs/?57477.
2019-12-25 14:20:35 +01:00
Benno Schulenberg
4991b3bb1a input: Ctrl+arrow is "Esc O x" on Eterm, as on rxvt -- not "Esc o x"
(Checked on Eterm-0.9.6 running on Xubuntu 18.04.)
2019-12-24 20:01:48 +01:00
Benno Schulenberg
075b7e75bc po: update translations and regenerate POT file and PO files 2019-12-23 11:37:33 +01:00
Benno Schulenberg
c00431134f bump version numbers and add a news item for the 4.7 release 2019-12-23 11:15:53 +01:00
Benno Schulenberg
51065ff24b gnulib: update to its current upstream state 2019-12-22 13:25:32 +01:00
Benno Schulenberg
4314feae11 build: fix compilation for --enable-tiny --enable-wrapping 2019-12-22 12:56:18 +01:00
Benno Schulenberg
410280b089 build: fix compilation when configured with --disable-justify 2019-12-22 11:32:49 +01:00
Benno Schulenberg
178dd9181f tweaks: slightly streamline the search for a possible wrapping point
That is, elide an 'if' for the it-is-a-blank case.
2019-12-19 19:22:02 +01:00
Benno Schulenberg
d30ca576b7 tweaks: optimize the trimming of trailing whitespace
When justifying a paragraph, always first squeeze() is called on
the text (which at that moment consists of a single long line),
which means that (in its wrappable part) this line contains only
single spaces as word separators (and maybe a double space after
a period).  So there is no need to call the general is_blank()
function -- checking for a space is enough.
2019-12-19 12:16:15 +01:00
Benno Schulenberg
ed520c89bc tweaks: improve two comments and the ordering of some operands 2019-12-19 12:15:47 +01:00
Benno Schulenberg
cb44a2bd2c tweaks: reshuffle and rename a few things, to elide duplication 2019-12-19 10:52:06 +01:00
Benno Schulenberg
a0055f3640 wrapping: never break in the quoting part nor in the indentation part
Rationale: nano should not wrap inside the quoting part of a line
because it would change the quoting level, which would misrepresent
things, nor should it wrap inside the indentation part because when
the user tries to indent something beyond the target wrapping width,
she/he does not intend to create a line containing only whitespace,
but effectively wants to push the text beyond the wrapping width.

This copies the behavior of the rewrap_paragraph() routine that is
used during justification, so that automatic hard-wrapping ends up
with the same result as justifying.

Also, always do automatic hard-wrapping when --breaklonglines is in
effect, also when --autoindent is active.

This fixes https://savannah.gnu.org/bugs/?57425.

The bug was old -- it existed since at least version 2.0.6.

This furthermore avoids https://savannah.gnu.org/bugs/?57422.
Reported-by: Sébastien Desreux <seb@h-k.fr>

That bug existed since version 4.4, commit 8fce33af.
2019-12-18 11:22:30 +01:00
Benno Schulenberg
b00c1d6110 justify: treat consecutive indentations that look the same as the same
That is: allow tabs and spaces to be mixed when comparing indentation.
When the mix of tabs and spaces pushes the text of a line to the same
column as on a consecutive line, then those two lines are considered
to have the same indentation and thus belong to the same paragraph.

This reverts the previous commit (594ef222), and improves upon how
nano has behaved since version 2.9.8.

This fixes https://savannah.gnu.org/bugs/?57404 differently.
2019-12-17 16:56:28 +01:00
Benno Schulenberg
594ef2225f justify: distinguish between tabs and spaces when comparing indentation
That is: two consecutive lines are considered to belong to separate
paragraphs when the smallest indentation of those two lines is not
character-by-character identical with the corresponding piece of
indentation of the other line.

In other words: if one line is indented with spaces, and a consecutive
line is indented by the same distance but with tabs, they are taken to
belong to different paragraphs: a justification will not merge them.

This fixes https://savannah.gnu.org/bugs/?57404.

Bug existed since version 2.9.8, commit 432a7d77.
2019-12-17 12:23:55 +01:00
Benno Schulenberg
9631e858f2 display: don't color the space that separates line numbers from text
Go back to how line numbers were colored in versions 2.7.1 to 4.3 --
coloring the space (when a background color is used) was unintented.

This fixes https://savannah.gnu.org/bugs/?57412.

Bug existed since version 4.4, commit 699cacf7.
2019-12-16 19:23:08 +01:00
Benno Schulenberg
26d88ccbb1 syntax: sh: recognize shell rc files also in dedicated directories
This fulfills https://savannah.gnu.org/bugs/?57411.
2019-12-16 19:09:48 +01:00
Benno Schulenberg
413b9cb774 tweaks: rename a function, to get rid of a useless suffix 2019-12-15 19:47:05 +01:00
Benno Schulenberg
d3a8d81afb tweaks: rename a function, to get out of the way for another rename 2019-12-15 19:40:22 +01:00
Benno Schulenberg
e16026eacd linter: beep when trying to go beyond first or last message 2019-12-15 16:15:54 +01:00
Benno Schulenberg
90f18af8bd tweaks: reshuffle two declarations, for compactness 2019-12-15 15:30:48 +01:00
Benno Schulenberg
011e8de480 rcfile: demand that function 'exit' is bound in the file browser
For symmetry with the help viewer.

Even though the user could still exit with the bare Q, E, or X keys,
these are not listed in the help text, so they don't really count.
2019-12-15 15:28:22 +01:00
Benno Schulenberg
4e8afb2877 tweaks: drop M-Space and ^Space from the browser's key list
The 'prevword' and 'nextword' functions do not exist in the browser.

The mistake was made in commit a8c13d79 from five years ago.
2019-12-13 19:29:15 +01:00
Benno Schulenberg
c7ad5c8d86 tweaks: reshuffle an item, to avoid a lone 'else' 2019-12-13 19:06:39 +01:00
Benno Schulenberg
0b1a766964 rcfile: accept also function names and menu names only in lowercase 2019-12-13 19:03:38 +01:00
Benno Schulenberg
a7e11495bd tweaks: move three functions to the file where they are used
Also move the corresponding two arrays.
2019-12-13 18:57:42 +01:00
Benno Schulenberg
b56db25a35 docs: mention that all keywords in a nanorc file should be in lowercase 2019-12-12 19:19:07 +01:00
Benno Schulenberg
e3957ee5ee rcfile: accept only keywords in all lowercase, for speed of comparison
As was noted two months ago: nowhere in the manual does it say that
keywords are case-insensitive, and the manual shows all keywords in
lowercase, and all the examples are in lowercase too.  So... simply
expect keywords to be in all lowercase.
2019-12-12 19:18:56 +01:00
Benno Schulenberg
2a73b4a050 tweaks: reshuffle a fragment of code, for efficiency
First comparing each keystring that starts with "^" against "^Space"
was a waste of time when only one out of fifty such strings actually
is "^Space".
2019-12-12 19:00:52 +01:00
Benno Schulenberg
ef7c78910c tweaks: reshuffle a few lines, for brevity or speed or consistency
Also, don't compare case-insensitively where it is not needed.
2019-12-12 12:34:56 +01:00
Benno Schulenberg
772f1029e5 tweaks: avoid using strlen() where it is not needed 2019-12-12 12:14:38 +01:00
Benno Schulenberg
3251a216cd tweaks: unwrap a few lines, and move some strings to among their peers 2019-12-12 11:41:04 +01:00
Benno Schulenberg
00b0316ab8 syntax: nanohelp: colorize also ^/ as a possible keystroke
(In addition, colorize F20...F24 too.)

This fixes https://savannah.gnu.org/bugs/?57390.

Bug existed since version 4.6, commit 2a97cb9f.
2019-12-10 15:42:28 +01:00
Benno Schulenberg
76d90617cc build: avoid three compiler warnings when using gcc-9.2 or newer
This addresses https://savannah.gnu.org/bugs/?57360.
Reported-by: Brand Huntsman <alpha@qzx.com>
2019-12-08 11:27:06 +01:00
Benno Schulenberg
f516cddce7 build: fix compilation on macOS, where 'st_mtim' is unknown
This fixes https://savannah.gnu.org/bugs/?57367.
Reported-by: Bo Anderson <bo@toxicflames.co.uk>
Tested-by: Bo Anderson <bo@toxicflames.co.uk>
2019-12-06 12:19:32 +01:00
Benno Schulenberg
60b826e5ee tweaks: trim or adjust some whitespace in HTML, and add two keywords 2019-12-05 17:01:55 +01:00
Benno Schulenberg
fc0fcdea10 build: add the uploading of PDF and cheatsheet to the release script 2019-12-05 12:23:45 +01:00
Benno Schulenberg
1dd7b216a0 docs: add or improve the 'description' meta tag in the two HTML pages 2019-12-05 12:06:24 +01:00
Benno Schulenberg
87bf46ffb6 docs: add the 'lang' attribute in the right place to the two HTML pages 2019-12-05 11:52:17 +01:00
Benno Schulenberg
a921bdadbf tweaks: remove a stray space
Reported-by: Brand Huntsman <alpha@qzx.com>
2019-12-05 11:23:47 +01:00
Benno Schulenberg
0271e4a187 input: make <Tab> indent only when mark and cursor are on different lines
It allows entering a TAB character at the cursor position while the
mark is on the same line as the cursor, as some users sometimes do.

This refines the feature that was added in version 2.9.2, and makes
it behave like in the Gedit and Kate editors, for example.

This addresses https://savannah.gnu.org/bugs/?57357.
Reported-by: Sébastien Desreux <seb@h-k.fr>
2019-12-04 17:29:40 +01:00
Benno Schulenberg
076eb6f6af docs: mention that a negative number after "+" counts from the end
A negative line number given on the command line counts from the end
of the relevant file (-1 meaning the first line from the bottom),
and a negative column number from the end of the relevant line.

The feature was added in version 2.8.5 but not mentioned in the manual.

This addresses https://savannah.gnu.org/bugs/?57342.
Suggested-by: Andreas Schamanek <schamane@fam.tuwien.ac.at>
2019-12-02 17:00:35 +01:00
Benno Schulenberg
e484918ef2 tweaks: reshuffle a few lines, for symmetry with the preceding function 2019-12-01 17:04:15 +01:00
Benno Schulenberg
fdf095c32f po: update translations and regenerate POT file and PO files 2019-11-29 11:26:13 +01:00
Benno Schulenberg
81402101d9 tweaks: baptize the release 2019-11-29 11:19:11 +01:00
Benno Schulenberg
154742c5e3 bump version numbers and add a news item for the 4.6 release 2019-11-29 11:08:22 +01:00
Benno Schulenberg
ec569b4bd0 tweaks: rename a variable, to be a bit more fitting 2019-11-27 11:58:40 +01:00
Benno Schulenberg
38743b0016 tweaks: reshuffle an 'if' to avoid a negation, and improve a comment 2019-11-27 11:56:35 +01:00
Benno Schulenberg
68c3aaf2df softwrap: when switching to another buffer, re-align the starting column
When we switch to another buffer, the window may have been resized
since we were last in this buffer, so make sure that 'firstcolumn'
gets a fitting value.

This fixes https://savannah.gnu.org/bugs/?56991.

Bug existed since version 2.8.0, since the softwrap overhaul.
2019-11-27 11:49:09 +01:00
Benno Schulenberg
2a97cb9f41 bindings: allow to rebind ^/, even though it is synonymous with ^_
This fixes https://savannah.gnu.org/bugs/?57302.
Reported-by: Tiago Almeida <tjamadeira@gmail.com>
2019-11-26 19:25:24 +01:00
Benno Schulenberg
af8ffa8c94 tweaks: silence a warning when configured with --enable-tiny 2019-11-25 19:21:03 +01:00
Benno Schulenberg
3ffefbfddc build: fix compilation for --enable-tiny --enable-histories 2019-11-25 19:17:41 +01:00
Benno Schulenberg
8637acb106 docs: correct the description of the 'spell' menu 2019-11-25 17:42:40 +01:00
Benno Schulenberg
51a3f78d69 docs: mention that 'hunspell' is now the first default spelling program 2019-11-25 17:38:50 +01:00
Benno Schulenberg
4d77e0adbb speller: prefer 'hunspell' over 'spell', because it can handle UTF-8
Also, 'hunspell' is sensitive to the 'LANG' environment variable,
so that spell checking will take place for the language that the
user is using, instead of always for English.  (This is a behavior
change, and some people may not like it, expecting the spell check
to occur always for English, but... we'll see.)
2019-11-25 16:57:04 +01:00
Benno Schulenberg
2b8a73348c gnulib: update to its current upstream state 2019-11-24 13:12:41 +01:00
Benno Schulenberg
576502a5c5 speller: when 'spell' is not found, try running 'hunspell -l' instead
This increases the chances that spell checking will work out of the box,
without any extra installing or configuration.

This addresses https://savannah.gnu.org/bugs/?57296.
2019-11-24 12:12:38 +01:00
Benno Schulenberg
ec9a11c761 display: do refresh the edit window when exiting from the help viewer
There are several cases (searching, replacing, spell checking, ...)
where exiting from the help viewer does NOT return the user to the
editing of the buffer.

This fixes https://savannah.gnu.org/bugs/?57295.

Bug existed since version 4.3, commit 5817e83e.
2019-11-23 20:22:31 +01:00
Benno Schulenberg
1c63bf0e38 bindings: the 'all' keyword should include the browser menu always
Also for the "universal" functions (like cursor movement) and the
special 'implant' function, the 'all' keyword should include the
browser menu.

This fully fixes https://savannah.gnu.org/bugs/?57280.

Bug existed since version 3.2, commit cc01bc3e.
2019-11-22 13:21:20 +01:00
Benno Schulenberg
4aa1678f3b bindings: the 'all' keyword should encompass the browser menu too
This fixes https://savannah.gnu.org/bugs/?57280.
Reported-by: Tiago Almeida <tjamadeira@gmail.com>

Bug existed since version 3.2, commit cc01bc3e.
2019-11-22 12:44:28 +01:00
Benno Schulenberg
c60d3bbb97 tweaks: don't do in the parent something that only the child needs 2019-11-17 08:20:32 +01:00
Benno Schulenberg
90d4b51837 tweaks: group the closing of two descriptors, and reword two comments 2019-11-17 08:15:52 +01:00
Benno Schulenberg
302ea79d1c syntaxes: put the 'linter' and 'formatter' commands on a separate line
To show that they are a different class of thing than the file-matching
regexes and the comment thing, which all kind of "describe" the file.
2019-11-04 20:56:41 +02:00
Benno Schulenberg
ebeed9c013 tweaks: fuse two regexes into one 2019-11-04 20:49:17 +02:00
Benno Schulenberg
75dd9bee38 syntax: javascript: colorize the boolean values 'true' and 'false' too
Original-patch-by: Ryan Westlund <rlwestlund@gmail.com>
2019-11-03 19:50:41 +02:00
Benno Schulenberg
9151abcd45 tweaks: avoid setting and resetting a variable when there is no need 2019-10-28 10:28:52 +01:00
Benno Schulenberg
3258bb0ff4 docs: adjust the compilation instructions to two-digit version numbers 2019-10-27 19:21:55 +01:00
Benno Schulenberg
3f3698640b syntax: ruby: colorize also lowercase global/instance variables
And avoid recoloring the reserved words BEGIN and END as constants.

Inspired-by: Rory Thrasher <thrasher@redhat.com>
2019-10-27 16:34:06 +01:00
Benno Schulenberg
432388b23e tweaks: add two translator hints
And unmark two identical strings, to cause the marked ones to sit
next to each other in the POT file.
2019-10-27 16:30:50 +01:00
Benno Schulenberg
bad618e537 tweaks: harmonize a message with another 2019-10-27 16:19:45 +01:00
Benno Schulenberg
7ae305fdc0 tweaks: group the closing of descriptors together, for compactness 2019-10-27 10:40:09 +01:00
Benno Schulenberg
7d4f279c04 tweaks: close the unused reading ends of two more output pipes
It is done for 'spell', so do it also for 'sort' and 'uniq'.
2019-10-27 10:34:12 +01:00
Benno Schulenberg
f230c46e5e tweaks: drop the unneeded closing of descriptors when exiting anyway
Also, when something goes wrong in the later stages of the pipeline,
the error code would try to close descriptors that are already closed,
which is not right.  So, just let exit() handle any file descriptors
that are still open.
2019-10-27 10:25:37 +01:00
Benno Schulenberg
bc5a225678 tweaks: improve some comments, and trim some repetitive ones 2019-10-27 10:10:03 +01:00
Benno Schulenberg
493b334ebb tweaks: mark two strings for translation
The marking was accidentally lost two weeks ago in commit d12191db.
2019-10-26 17:09:00 +02:00
Benno Schulenberg
7d54207627 tweaks: be explicit about which program complained 2019-10-26 12:04:10 +02:00
Benno Schulenberg
458933f09e tweaks: elide an unneeded and leaky function 2019-10-26 12:01:23 +02:00
Benno Schulenberg
2b49a19793 linter: report it as an error when running the linting program fails
When something goes wrong, nano should beep and the status bar should
use the error color (red by default).

This fixes https://savannah.gnu.org/bugs/?57116.
2019-10-26 11:52:53 +02:00
Benno Schulenberg
fc716156a4 tweaks: correct a comment, and retype a variable 2019-10-26 11:18:38 +02:00
Benno Schulenberg
2b9f06194f formatter: don't let output from the program pollute the screen
Run the formatting program outside of curses mode, so that any output
(complaints) that it produces will be on the terminal after exiting
from nano -- at least on a terminal emulator, not on a Linux VT.

This also allows the formatter to be an interactive program.

The disadvantage is that the screen flickers when typing M-F.

This fixes https://savannah.gnu.org/bugs/?57104.
2019-10-25 19:23:24 +02:00
Benno Schulenberg
631defb8b2 tweaks: reword an undo/redo string that was overlooked during the rename 2019-10-25 19:21:17 +02:00
Benno Schulenberg
a6dae403e6 formatter: accept the formatted result also upon a nonzero exit status
For a nonzero exit status of the formatting program, report on the
status bar that the program "complained", but read in the (probably)
reformatted text anyway -- it can be easily undone with M-U.  Only
report failure when the intended program could not be run.

This fixes https://savannah.gnu.org/bugs/?57105.
2019-10-25 17:45:52 +02:00
Benno Schulenberg
b4dbbe3799 syntax: html: add a formatter command, making use of 'tidy' 2019-10-25 17:27:14 +02:00
Benno Schulenberg
4281b6becb commands: rename 'fixer' to 'formatter', to be less misleading
The word "fixer" sounds too much as if the command would be able
to fix mistakes or correct errors.  Especially when seen next to
"linter", it sounds as if one does a syntax check and the other
fixes the found mistakes.  (Although the command might in theory
be used for this, it is not its intended purpose.)
2019-10-25 17:24:28 +02:00
Benno Schulenberg
34b1824822 syntax: default: don't colorize stuff between two pairs of brackets
That is, don't allow another bracket between the opening and the
closing bracket.
2019-10-25 12:23:40 +02:00
Jeroen Roovers
b025f67805 syntax: gentoo: highlight the BDEPEND variable as well
This fixes https://bugs.gentoo.org/698420.
Reported-by: Alessandro Barbieri <lssndrbarbieri@gmail.com>

Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
2019-10-24 17:24:06 +02:00
Benno Schulenberg
40f8ca0d07 syntax: html: colorize only full attributes, and colorize strings later
Attribute names that are a part of another word should not be colored,
nor should attribute names within strings.

This addresses the other half of https://savannah.gnu.org/patch/?9865.
Original-patch-by: Ryan Westlund <rlwestlund@gmail.com>
2019-10-24 17:19:04 +02:00
Benno Schulenberg
aae752912e syntax: javascript: colorize also special values 'null' and 'undefined'
This addresses one half of https://savannah.gnu.org/patch/?9865.
Original-patch-by: Ryan Westlund <rlwestlund@gmail.com>
2019-10-24 17:19:04 +02:00
Benno Schulenberg
3c695664ec tweaks: elide a function call for the plain ASCII case
When dealing with a plain, seven-bit ASCII character, don't bother
calling is_cntrl_mbchar() but determine directly whether it is a
control character.  Also reshuffle things so that we don't compare
charlen == 1 when we already know it is 1.
2019-10-21 18:52:44 +02:00
Benno Schulenberg
8a7634f070 tweaks: rename two parameters plus a variable, to match others
Also improve a comment and normalize an indentation.
2019-10-21 13:02:17 +02:00
Benno Schulenberg
fa88fcc8f2 tweaks: rename a function, and elide a parameter that is always NULL
After the previous change, all remaining calls of parse_mbchar() have
NULL as their third parameter.  So, drop that parameter and remove the
chunk of code that handles it.  Also rename the function, as there are
already too many functions that start with "parse".
2019-10-21 12:35:14 +02:00
Benno Schulenberg
c2d8641f01 chars: add a faster version of the character-parsing function
It elides a parameter that is always NULL, and elides two ifs
that always take the same path.
2019-10-21 12:24:23 +02:00
Benno Schulenberg
3d5e51bcd0 syntax: nanorc: colorize in bright red everything that is invalid
Random words or mistyped keywords should not stay uncolored.
2019-10-20 14:47:15 +02:00
Benno Schulenberg
95ae124891 history: don't wait when there is something wrong with the history files
Do not wait for the user to press a key when there is some problem
with any of the history files.  Just start and indicate the problem
on the status bar.  The precise error message is stored and will be
shown on the terminal when exiting from nano.

This addresses https://savannah.gnu.org/bugs/?56524.
2019-10-20 14:30:04 +02:00
Benno Schulenberg
1a8646393a tweaks: condense a fragment of code by making use of a helper function
(It copies a byte too many, which then gets overwritten in the next
statement, but this is not speed-critical code.)
2019-10-20 09:45:58 +02:00
Benno Schulenberg
054559dc93 tweaks: rename three variables, to be more descriptive 2019-10-20 09:45:58 +02:00
Benno Schulenberg
fdeab9b4c9 tweaks: order two functions more sensibly 2019-10-20 09:45:58 +02:00
Benno Schulenberg
f26c121ca9 tweaks: adjust two comments, to better fit the actual functions 2019-10-20 09:45:58 +02:00
Benno Schulenberg
17c16a4bf5 tweaks: rename a function and elide its first parameter 2019-10-20 09:45:58 +02:00
Benno Schulenberg
46566572d6 utils: don't accept NULL for the string to be copied
This should not occur, so crash when it does happen.
2019-10-20 09:45:58 +02:00
Benno Schulenberg
b4a5fac744 tweaks: use a literal NULL instead of a variable that is NULL
Now all calls of mallocstrncpy() have NULL as the first parameter
(apart from one call in utils.c, but that can be changed), so the
function can be simplified.
2019-10-20 09:45:58 +02:00
Benno Schulenberg
f816da413a tweaks: elide a variable that is the same as another 2019-10-18 17:12:51 +02:00
Benno Schulenberg
3a0ac428ba tweaks: remove a redundant check for an existing emergency file
This case is caught (by O_EXCL) later on, at the appropriate moment:
when the file is created.

Also, this removes a superfluous lstat() for each temporary file.
2019-10-18 17:04:55 +02:00
Benno Schulenberg
97ab28a164 tweaks: exclude two fragments of code from the tiny version
Also improve a comment, and recorrect an indentation.
2019-10-18 14:25:55 +02:00
Benno Schulenberg
ccb739dd7d tweaks: don't wrap calls of statusline() that slightly overshoot 80 cols 2019-10-18 14:04:15 +02:00
Benno Schulenberg
1082f2adec files: don't mention the name of the temp file when reading goes wrong
When writing a temp file goes wrong, its name is not mentioned either.
2019-10-18 13:38:20 +02:00
Benno Schulenberg
042b8394a0 tweaks: use a simpler positive/negative check for after copy_file() 2019-10-18 13:25:38 +02:00
Benno Schulenberg
f2d6e6fa5e tweaks: check the return value of copy_file() also after its other uses 2019-10-18 12:37:39 +02:00
Benno Schulenberg
5390f96900 files: distinguish between read error and write error when prepending
This fixes https://savannah.gnu.org/bugs/?57066.

Bug existed in this form since version 2.4.3 -- in older versions
it segfaulted.
2019-10-18 12:15:14 +02:00
Benno Schulenberg
50ed18be17 tweaks: move a call of umask() closer to where it is relevant 2019-10-17 17:29:11 +02:00
Benno Schulenberg
a6365707c0 tweaks: remove the superfluous closing of a file descriptor
The file itself is closed three lines earlier; this also closes the
corresponding descriptor.
2019-10-17 16:43:07 +02:00
Benno Schulenberg
6fad6a17da tweaks: rename a variable, to be distinct and visible 2019-10-17 12:17:09 +02:00
Benno Schulenberg
eb757e7c5b tweaks: simplify the opening of files when prepending
There is no need for a file descriptor: all reading and writing
is done on streams.
2019-10-17 12:12:07 +02:00
Benno Schulenberg
b554606047 tweaks: add a local variable, for clarity, to not preuse another one 2019-10-17 11:49:21 +02:00
Benno Schulenberg
e915fb1650 tweaks: adjust the indentation after the previous change, and another 2019-10-17 11:45:03 +02:00
Benno Schulenberg
4e40ec057e tweaks: elide an unneeded check when making a backup
When making a backup, we can be certain that the relevant file
is not a temporary file, so 'stream' will necessarily be NULL.
2019-10-17 11:45:03 +02:00
Benno Schulenberg
bd0026be86 tweaks: elide another two calls of umask(), and rename two variables 2019-10-17 11:43:42 +02:00
Benno Schulenberg
a1bef0e953 tweaks: avoid three unneeded calls of umask() in the normal case 2019-10-16 19:17:42 +02:00
Benno Schulenberg
f5693d4151 tweaks: elide a duplicate opening of the existing file when prepending 2019-10-16 17:40:52 +02:00
Benno Schulenberg
e3807f00a2 tweaks: rename two variables, and add a third, for more contrast 2019-10-16 17:16:48 +02:00
Benno Schulenberg
022cc084a7 files: when opening a file for copying, it should NOT be created
Weird bug.  The first occurrence is probably never hit because the
existing file has been tentatively opened fourteen lines earlier,
but that looks superfluous: double work.  And the second occurrence
will not be hit because the temp file is unlikely to have disappeared.
2019-10-16 16:27:23 +02:00
Benno Schulenberg
0f98466e2f tweaks: adjust the indentation after the previous change
Also, don't bother assigning the stream pointer of the existing file
to variable 'f', as it gets overwritten right away by the pointer of
the temp file.
2019-10-16 16:05:40 +02:00
Benno Schulenberg
40c067133a tweaks: remove two superfluous conditions when prepending
When prepending, we cannot be writing to a temp file,
so 'stream' (and thus 'f') will necessarily be NULL.
2019-10-16 15:47:35 +02:00
Benno Schulenberg
36270748dc tweaks: condense or improve some comments 2019-10-16 13:47:30 +02:00
Benno Schulenberg
1894c81412 tweaks: rename two parameters, for contrast and to match others 2019-10-16 13:07:41 +02:00
Benno Schulenberg
e917ef0105 tweaks: die on an impossible condition -- to be removed later 2019-10-16 12:27:27 +02:00
Benno Schulenberg
3347682fd0 tweaks: remove a pointless updating of the title bar
A possible change in filename won't be pushed to the screen until a
doupdate() is done, and that won't happen until nano is waiting for
a keystroke again.  So... just let it be.
2019-10-16 12:22:39 +02:00
Benno Schulenberg
7c5b104859 tweaks: rename three variables, to match others elsewhere 2019-10-16 11:46:22 +02:00
Benno Schulenberg
3b9a24a7ca tweaks: rename a local variable, to not shadow another 2019-10-16 11:11:19 +02:00
Benno Schulenberg
7d3290fb91 tweaks: rename three variables, to be consistent with other linestructs 2019-10-16 11:04:26 +02:00
Benno Schulenberg
df0ae2ace5 tweaks: reshuffle a few declarations, and reduce the scope of one 2019-10-16 10:48:14 +02:00
Benno Schulenberg
bc91af2e3c tweaks: pass an empty string as an answer instead of a NULL pointer
Also, rename a parameter, to be more distinct and to avoid an abbrev.
2019-10-15 13:39:57 +02:00
Benno Schulenberg
48b94d71c7 tweaks: pass an empty string for copying instead of a non-existent one 2019-10-15 11:49:07 +02:00
Benno Schulenberg
f14be47878 tweaks: move two functions to after the one that they make use of 2019-10-15 11:23:09 +02:00
Benno Schulenberg
c51f5f4bff docs: mention that the 'nopauses' option is obsolete 2019-10-15 11:23:05 +02:00
Benno Schulenberg
7f8851caa8 statusbar: show only the first error message, with dots to indicate more
The old default behavior of showing the first three messages with a
long pause after each of them was annoying, and the final "Further
messages were suppressed" hid the relevant information.  So, when
there is more than one error message, just pause very briefly and
then add trailing dots to the first message.

This makes the 'nopauses' option a no-op.

This addresses https://savannah.gnu.org/bugs/?57048.
2019-10-15 11:17:20 +02:00
Benno Schulenberg
bfdc31fbb4 docs: add the M-F and M-N keystrokes to the cheatsheet 2019-10-14 17:14:07 +02:00
Benno Schulenberg
69d2045c9f syntax: nanorc: colorize only lowercase keywords as valid
Nowhere does the manual say that nanorc keywords are case-insensitive,
and none of the examples use uppercase keywords.  So, simply consider
uppercase keywords to be invalid.  This will later allow nano to use
case-sensitive comparisons, which are slightly faster.
2019-10-14 11:45:56 +02:00
Benno Schulenberg
c63f4c1f58 docs: remove the note about the formatter having been removed
The 'fixer' command has taken the place of the 'formatter' command.

(Also, normalize a double blank line before a chapter.)
2019-10-14 10:30:04 +02:00
Benno Schulenberg
b8dc8d4a37 syntax: nanorc: colorize all arguments of 'fixer' and 'linter' as valid 2019-10-14 10:28:45 +02:00
Benno Schulenberg
8749ccb469 syntax: nanorc: colorize the 'fixer' command as valid
Also add a default formatting command to the Go syntax.
2019-10-14 10:28:45 +02:00
Benno Schulenberg
b5c5cde0d4 docs: document the 'fixer' command, a per-syntax content arranger 2019-10-14 10:28:45 +02:00
Benno Schulenberg
d8c03cd4cd tweaks: elide a variable, and add a condition to elide an assignment 2019-10-14 10:28:45 +02:00
Benno Schulenberg
1536a76ced tweaks: normalize the indentation after the previous change 2019-10-14 10:28:45 +02:00
Benno Schulenberg
d2fb371fe2 feedback: say it when spell check or manipulation did not change anything 2019-10-14 10:28:45 +02:00
Benno Schulenberg
34170611d3 restored feature: a per-syntax 'fixer' command that processes the buffer
The command can be used to run some kind of formatter or corrector or
arranging tool on the buffer.  By default the command is bound to M-F.
The formatter/corrector/arranging program must be non-interactive.

This addresses https://savannah.gnu.org/bugs/?55365,
and addresses https://savannah.gnu.org/bugs/?54651.
2019-10-14 10:28:45 +02:00
Benno Schulenberg
23c36ba667 tweaks: remove two pointless re-inclusion guards
The nano.h file is included only by proto.h, and the proto.h file is
included just once by each src/*.c file.  The include guards for these
two header files serve no purpose.

(Include guards are useful when you have bunches of header files
and several of them include others from amongst themselves.)
2019-10-13 19:14:27 +02: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
f551c07e7a tweaks: add some "fall-through" comments, and reshuffle some breaks 2019-10-13 17:35:57 +02:00
Benno Schulenberg
2656f543f4 undo: don't try to copy a string that doesn't exist
This fixes https://savannah.gnu.org/bugs/?57051.

Bug existed since commit d256d0cb from earlier today.
2019-10-13 17:31:53 +02:00
Benno Schulenberg
ba79602281 tweaks: condense two comments, and rename two parameters
Also use 'while' instead of 'for'.
2019-10-13 16:45:02 +02:00
Benno Schulenberg
094758be15 tweaks: reshuffle a fragment of code into two alternatives 2019-10-13 16:11:15 +02:00
Benno Schulenberg
06bbc70d4a tweaks: use a string-copy function that checks for out-of-memory 2019-10-13 12:38:46 +02:00
Benno Schulenberg
d256d0cbc0 tweaks: add a helper function without the ubiquitous NULL argument
For conciseness and clarity.
2019-10-13 12:24:27 +02:00
Benno Schulenberg
ab6635c3a6 tweaks: use the given string instead of the found match, for clarity 2019-10-13 11:52:09 +02:00
Benno Schulenberg
416ad4c5fd tweaks: use a better variable name for the argument of an option 2019-10-13 11:46:22 +02:00
Benno Schulenberg
0374708597 undo: put the cursor back on the original row for a full-buffer operation
When an operation that replaces the entire buffer is undone, the
position of the viewport is lost.  Compensate for this by storing
the row of the cursor in the undo item, and, after executing the
undo item, arranging the viewport so that the cursor is back on
the original row -- the row where the operation was invoked.

This fixes https://savannah.gnu.org/bugs/?57039.
2019-10-12 11:20:41 +02:00
Benno Schulenberg
101987f5c6 build: fix compilation when configured with --disable-color 2019-10-12 11:20:19 +02:00
Benno Schulenberg
ad451933c6 tweaks: rename a function and add a parameter, so it becomes more general
Also adjust the comments and rename three variables.
2019-10-10 08:28:08 +02:00
Benno Schulenberg
222e67300e tweaks: reshuffle some declarations, and rename a variable 2019-10-10 08:23:16 +02:00
Benno Schulenberg
d12191db5a tweaks: pass any special undo/redo messages to the add_undo() function
For the three operations (justification, spell checking, and filtering)
that need to undo or redo two suboperations (cutting and then pasting)
in one go, pass the message that describes the operation to add_undo(),
so that the undo item does not need to be modified after the call.

This looks better, but does add some twenty NULL parameters elsewhere.
2019-10-09 19:21:27 +02:00
Benno Schulenberg
785efc2087 tweaks: make a function do a check so its calls don't need to 2019-10-09 18:58:30 +02:00
Benno Schulenberg
557ad827f9 tweaks: condense two comments, and rewrap a line 2019-10-09 14:49:42 +02:00
Benno Schulenberg
600f81cf98 tweaks: rename three variables, and reshuffle some lines 2019-10-09 14:20:29 +02:00
Benno Schulenberg
56d98052d1 tweaks: adjust the indentation after the previous change 2019-10-08 11:51:47 +02:00
Benno Schulenberg
265d3245af rcfile: process extensions to file-matching commands straightaway
When 'extendsyntax' is used with a 'header' or 'magic' command, it
must be processed immediately.  It is pointless to store the command,
because when then it is processed (when the syntax gets used), it is
too late to have any effect.

This fixes https://savannah.gnu.org/bugs/?56997.

With-help-from: Brand Huntsman <alpha@qzx.com>

Bug existed since version 4.3, commit cba9d8d0.
2019-10-08 11:37:02 +02:00
Benno Schulenberg
53d4224be9 cutting: do nothing when trying to chop a word leftward at start of file
Instead of marking the buffer as modified, provide the feedback that
"nothing was cut", like when trying to chop a word rightward at the
end of the buffer.

This fixes https://savannah.gnu.org/bugs/?57015.

Bug existed since version 4.4, commit 4314b8de.
2019-10-07 17:24:18 +02:00
Benno Schulenberg
f813fd0f4d rcfile: allow binding also F17...F24
For historical reasons the rebinding code allows binding F13...F16,
which on most terminals are typable with Shift plus F1...F4.  But,
at least on an Xfce Terminal, Shift plus F1...F12 produce F13...F24.
On a Linux console, Shift plus F1...F8 produce F13...F20.  So: allow
to bind the full shifted F13...F24 range.  It costs no extra code
and makes things more rounded.
2019-10-07 16:23:40 +02:00
Benno Schulenberg
e90b40e651 docs: add a note saying that rebinding ^M or ^I is not advisable
Also say that rebinding ^H is sometimes impossible, or when it's
made possible, that it rebinds the Backspace key too.

This addresses https://savannah.gnu.org/bugs/?56994.
Reported-by: Tiago Almeida <tjamadeira@gmail.com>
2019-10-07 13:28:27 +02:00
Benno Schulenberg
07c1e72216 tweaks: slightly reword some fragments in the manual's rebinding section 2019-10-07 13:01:18 +02:00
Benno Schulenberg
7338b45d36 docs: remove some excessive detail from the sample nanorc file
The sample file should just mention the basics.  The manual contains
all the details.
2019-10-06 14:50:27 +02:00
Benno Schulenberg
c95e5362e6 docs: mention that color rules are applied in the order they are listed
Suggested-by: Tiago Almeida <tjamadeira@gmail.com>
2019-10-06 14:27:29 +02:00
Benno Schulenberg
2698a2ba68 syntax: c: recognize some C++ header files by their Emacs modeline
For extensionless files, recognize C/C++ ones from the mode name
between the -*- marks on the first line.

This addresses https://savannah.gnu.org/patch/?9719.

Inspired-by: Devin Hussey <husseydevin@gmail.com>
2019-10-06 12:01:02 +02:00
Benno Schulenberg
ff0e01a69e bindings: don't hard-bind ^H in the help viewer or the file browser
Hard-binding the ^H control code prevents the user from rebinding
the keystroke.

This fixes https://savannah.gnu.org/bugs/?56995.

Bug existed since version 4.0, commit 72a49dbb.
2019-10-05 12:43:46 +02:00
Benno Schulenberg
72b13adeff po: update translations and regenerate POT file and PO files 2019-10-04 12:11:14 +02:00
Benno Schulenberg
481178428b oops: fix typo in Changelog 2019-10-04 12:00:09 +02:00
Benno Schulenberg
9a2ef3a542 bump version numbers and add a news item for the 4.5 release 2019-10-04 11:31:29 +02:00
Benno Schulenberg
b480e7fc9c tweaks: remove some timing code that has served its purpose 2019-10-03 19:00:50 +02:00
Benno Schulenberg
3e33d1eba6 tweaks: rewrap a line, reshuffle a declaration, and improve some comments 2019-10-03 17:22:55 +02:00
Benno Schulenberg
cdb9b04980 docs: add two examples of the 'tabgives' command to the sample nanorc 2019-10-03 16:41:10 +02:00
Benno Schulenberg
31ff7ead73 tweaks: move a function to before its callers and next to its kind
Also, improve the indentation of two random lines.
2019-10-03 11:24:01 +02:00
Benno Schulenberg
5398d986ef tweaks: speed up determining the width of plain ASCII characters 2019-10-03 11:09:21 +02:00
Benno Schulenberg
b02dccc51f tweaks: elide a function from a non-UTF8 build
In a non-UTF8 build, mbwidth() returns always 1, so it is pointless
to call that function and compare its result to zero then.

Also, don't bother special-casing the function for a non-UTF8 locale.
2019-10-03 10:48:10 +02:00
Benno Schulenberg
3158133edd tweaks: rename three variables, for contrast and more sense 2019-10-03 10:12:30 +02:00
Benno Schulenberg
acf50ae26d tweaks: improve a handful of comments, and reduce the needed padding
Reshuffle a few struct elements so they will require less padding.
2019-10-02 19:33:03 +02:00
Benno Schulenberg
01b840890d tweaks: rename another type, again to better fit the general pattern 2019-10-02 19:32:41 +02:00
Benno Schulenberg
9bd60e7d5d tweaks: frob a few comments 2019-10-02 17:46:20 +02:00
Benno Schulenberg
c5e46101b1 tweaks: reshuffle some lines, to elide an unneeded assignment 2019-10-02 17:39:45 +02:00
Benno Schulenberg
53b77cb4c6 tweaks: rename another type, to also better fit the general pattern 2019-10-02 17:18:51 +02:00
Benno Schulenberg
cc4ce8d83b tweaks: rename a type, to better fit the general pattern 2019-10-02 17:09:22 +02:00
Benno Schulenberg
23c8ef70aa tweaks: reshuffle some lines, to have the same order as elsewhere 2019-10-02 15:20:49 +02:00
Benno Schulenberg
2a4d338d97 tweaks: reshuffle a fragment, to group some toggles together 2019-10-02 15:07:04 +02:00
Benno Schulenberg
9c202198a3 tweaks: simplify a calculation, as done elsewhere 2019-10-01 15:03:40 +02:00
Benno Schulenberg
c8dc67717b tweaks: mark as 'const' a parameter that takes fixed strings [coverity] 2019-10-01 15:02:08 +02:00
Benno Schulenberg
4df2f81295 tweaks: avoid recomputing a maximum value every time round the loop 2019-10-01 13:28:50 +02:00
Benno Schulenberg
78def852d1 mouse: make the clickable width of menu items more consistent
When there are fewer than four menu items, act as if there are four:
make their clickable width half the width of the screen.

Until now, when there were two menu items, their clickable width would
be the full width of the screen, which was overwide.  But when there
was just one menu item, its clickable width would suddenly be as small
as when the menu had the maximum number of items (12 for an 80-column
screen).  This was odd.

Also, slightly simplify another computation.
2019-10-01 12:46:31 +02:00
Benno Schulenberg
a4933873c9 tweaks: avoid leaking memory when finding an invalid string [coverity] 2019-09-30 19:42:27 +02:00
Benno Schulenberg
1861052234 tweaks: avoid a comparison between signed and unsigned [coverity] 2019-09-30 19:30:54 +02:00
Benno Schulenberg
2307b31887 tweaks: use 'void' in prototypes of parameterless functions [coverity] 2019-09-30 19:06:25 +02:00
Benno Schulenberg
108a3b0b41 tweaks: sort two keywords strictly alphabetically 2019-09-29 15:11:15 +02:00
Benno Schulenberg
e0d9b7a8af tweaks: add a translator hint, and correct two others 2019-09-29 15:08:57 +02:00
Benno Schulenberg
b3ace4d8f6 tweaks: don't burden all menus with something meant for the WriteOut menu
The first_sc_for() function is somewhat costly, so avoid calling it
when it is not necessary.

Most menus have either so many entries that unbinding some keys does
not reduce the number of shown entries, or they have so few entries
that each entry already has space enough and will not profit from
having more room available.  But the WriteOut menu is an edge case.
Most translators don't use --tempfile and translate the key tags for
the WriteOut menu making use of all 17 positions that are available
for each of them.  This makes that when --tempfile is used, some of
those tags get truncated.  This is not so bad, because --tempfile is
normally not used.  But when it isn't used (when the discardbuffer
function isn't bound), the WriteOut menu should make full use of the
available width to avoid truncating any translated tags.
2019-09-29 13:27:03 +02:00
Dirkjan Ochtman
e9d6ceab0b syntax: rust: add the words reserved in 2018, and remove unreserved ones
See https://doc.rust-lang.org/reference/keywords.html,
and https://rust-lang.github.io/rfcs/2421-unreservations-2018.html.

Signed-off-by: Dirkjan Ochtman <dirkjan@ochtman.nl>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2019-09-28 13:29:23 +02:00
Benno Schulenberg
5103bfe6b8 bindings: add a dedicated keycode for <Tab> for when a region is marked
In this way the keycode cannot be unbound from the 'indent' function,
so pressing <Tab> on a marked region will always indent the region.

This fixes https://savannah.gnu.org/bugs/?56960.

Bug existed since the "tabbing" of a marked region was introduced,
in version 2.9.2, commit 09958ebd.
2019-09-28 12:39:42 +02:00
Benno Schulenberg
cfd17f5722 tweaks: speed up the counting of the menu entries to be shown
Instead of first counting all available entries and then capping it
at MAIN_VISIBLE, simply stop counting when MAIN_VISIBLE is reached.
2019-09-28 12:03:02 +02:00
Benno Schulenberg
43235c2f16 tweaks: rename a function, to be a bit more fitting 2019-09-27 19:07:25 +02:00
Benno Schulenberg
b14ad451a9 tweaks: rename two variables, away from single letters 2019-09-27 18:53:44 +02:00
Benno Schulenberg
cd00d0975e tweaks: move a fragment of common code into the appropriate function 2019-09-27 18:49:39 +02:00
Benno Schulenberg
40f6dbc34e tweaks: move two functions to after the ones that they call 2019-09-27 18:41:22 +02:00
Benno Schulenberg
a9fb56a8c9 tweaks: move a function to a better file, to be amongst its kind 2019-09-27 17:43:28 +02:00
Benno Schulenberg
07c0d29276 gnulib: update to its current upstream state 2019-09-27 11:17:35 +02:00
Benno Schulenberg
310c971d50 docs: describe the new syntax-specific 'tabgives' command 2019-09-25 19:42:16 +02:00
Benno Schulenberg
3644d51b97 new feature: a 'tabgives' command to define what the Tab key produces
The 'tabgives' command is syntax-specific and should be followed by a
string containing the character(s) that a single press of the <Tab> key
should produce -- most likely a single TAB or a small bunch of spaces,
but any string is allowed.  This overrides the 'tabstospaces' option.

When one wants to make sure <Tab> inserts always four spaces and never
a TAB when editing a Python file, one could add to one's nanorc:

  extendsyntax python tabgives "    "

where there are four spaces between the quotes.  And when one wants
to ensure, when editing a Makefile, that <Tab> always inserts a TAB
and never spaces, independent of what tabstospaces is set to, one
could add to one's nanorc:

  extendsyntax makefile tabgives "	"

where there is a literal TAB character between the quotes.

This fulfills https://savannah.gnu.org/bugs/?53661,
Requested-by: Andrew Pennebaker <andrew.pennebaker@gmail.com>
And addresses https://savannah.gnu.org/bugs/?54760.
Requested-by: Henry van Megen <hvanmegen@gmail.com>
And addresses part of https://savannah.gnu.org/bugs/?54775.
Requested-by: Dirkjan Ochtman <dirkjan@ochtman.nl>
2019-09-25 19:35:07 +02:00
Benno Schulenberg
591d3170aa tweaks: add some translator hints, be more precise on permissible length 2019-09-24 17:15:42 +02:00
Benno Schulenberg
752dde1130 docs: mention that gcc must be at least version 5.0
This is needed to get '-std=c11' by default.

Reported-by: Ansuel Smith <ansuelsmth@gmail.com>
in https://lists.gnu.org/archive/html/nano-devel/2019-09/msg00004.html
2019-09-23 13:50:51 +02:00
Benno Schulenberg
b5eda7f812 tweaks: reshuffle two fragments, to group things better 2019-09-23 13:03:52 +02:00
Benno Schulenberg
4d44b03fc8 tweaks: rename a variable, to be more compact 2019-09-22 17:38:22 +02:00
Benno Schulenberg
2d16c27820 tweaks: add two hints for translators, to try and help avoid mistakes 2019-09-22 17:31:27 +02:00
Benno Schulenberg
ad65b79ac7 usage: mark the -J/--guidestripe option plus argument as translatable
This fixes https://savannah.gnu.org/bugs/?56930.

Bug existed since the vertical guiding bar was introduced,
in version 4.0, commit 66c6eb51.
2019-09-21 19:50:55 +02:00
Benno Schulenberg
fe5bd8cdef usage: properly align --help output also when it has accented characters
As printf() is not UTF8-aware, we have to determine ourselves how many
columns each short and long flag take up and add the required number of
spaces (not tabs, because their size is not fixed) to fill things up.

This fixes https://savannah.gnu.org/bugs/?56928.

Bug existed since version 4.3, commit 2f169107.
2019-09-21 19:31:48 +02:00
Benno Schulenberg
c848ec3d53 tweaks: elide two multiplications with something that is always 1 2019-09-18 15:25:42 +02:00
Benno Schulenberg
ab6390cad0 tweaks: remove two superfluous macros, as sizeof(char) is always 1 2019-09-18 15:20:08 +02:00
Benno Schulenberg
48124fdba4 tweaks: use a more effecient way to skip storing an empty file name
Position history refers only to actual files, so when the filename
is blank...  there is nothing that needs to be remembered.
2019-09-18 14:18:48 +02:00
Benno Schulenberg
ebd9eb346d tweaks: improve a bunch of comments, and reshuffle some declarations 2019-09-17 17:38:42 +02:00
Benno Schulenberg
413116e1b5 tweaks: rename another variable, for a better fit 2019-09-17 16:46:11 +02:00
Benno Schulenberg
69a3d39bc4 tweaks: rename three variables, for more contrast 2019-09-17 16:42:53 +02:00
Benno Schulenberg
f081fa3047 tweaks: rename two variables, to better describe what they contain
The 'tilded' variable is used for two purposes: a user's home directory,
and an intermediate user name.
2019-09-17 14:26:09 +02:00
Benno Schulenberg
4383b01b9b tweaks: adjust indentation after previous change, reshuffle declarations 2019-09-17 14:11:45 +02:00
Benno Schulenberg
b901a20a06 tweaks: use an early return when there is no tilde
Also improve a comment, and use a 'while' instead of a 'for'.
2019-09-17 14:09:40 +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
75a6abe6d2 docs: mark the undoing of justifications as done in the TODO list 2019-09-11 17:25:35 +02:00
Benno Schulenberg
ba5b85baf0 tweaks: rename three variables, to better indicate what they hold
They hold not a terminal but flags, settings, state.
2019-09-06 19:40:38 +02:00
Benno Schulenberg
9f95fa9ce5 tweaks: reshuffle a line, to group things better 2019-09-06 19:25:43 +02:00
Brand Huntsman
8853bc448d search: accept a match at start of file when searching from command line
For a forward search from the command line, pass FALSE to 'skipone'
so that an occurrence at the head of the file is not skipped over.

This fixes https://savannah.gnu.org/bugs/?56845.
Reported-by: Derek Wolfe <dwwolfe1@gmail.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-09-02 09:05:50 +02:00
Benno Schulenberg
15148a5e6d search: after search-at-startup, store the column (for vertical movement)
This fixes https://savannah.gnu.org/bugs/?56846.
2019-09-01 16:15:15 +02:00
Benno Schulenberg
7d9ad31cd9 po: update translations and regenerate POT file and PO files 2019-08-25 10:57:32 +02:00
Benno Schulenberg
aecbc6faa9 bump version numbers and add a news item for the 4.4 release 2019-08-25 10:29:14 +02:00
Benno Schulenberg
a06b921f12 docs: document the search-at-startup feature (+/string or +?string) 2019-08-20 19:22:25 +02:00
Benno Schulenberg
bdf1a9d4e7 syntax: perl: avoid upsetting older glibcs with crafty range expression
The regcomp() function from glibc-2.27 (and older) considers the
bracket expression ['-.] to be invalid -- mistakenly.  Avoid using
any range expression in the relevant regex and instead enumerate
all acceptable characters.

This avoids https://savannah.gnu.org/bugs/?56766.
2019-08-19 17:15:29 +02:00
Benno Schulenberg
5c399dfc6e build: exclude the search-at-startup feature from the tiny version 2019-08-18 13:03:11 +02:00
Benno Schulenberg
ed4b6486a1 search: don't wipe the status bar at startup when there was an error 2019-08-18 12:59:23 +02:00
Brand Huntsman
2326bf695e search: accept toggles for case and regex when searching at startup
Allow the user to specify that the search string should be interpreted
case-sensitively and/or as a regular expression by preceding the search
indicator (/ or ?) with c and/or r.  Or to switch these things off by
using C and/or R.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2019-08-18 12:59:04 +02:00
Benno Schulenberg
a9dd73fb16 new feature: allow specifying a search string to "jump to" at startup
The string to "jump to" is specified with +/ for a forward search
(from the top of the file), or with +? for a backward search (from
the bottom of the file).

This fulfills https://savannah.gnu.org/bugs/?54535.
Requested-by: Derek Wolfe <dwwolfe1@gmail.com>

With-help-from: Brand Huntsman <alpha@qzx.com>
2019-08-18 11:16:03 +02:00
Benno Schulenberg
073bd3ad6e rcfile: properly handle an empty syntax before an 'include' statement
So that in the error message the correct filename gets shown
instead of the name of the (first) include file.

Reported-by: Brand Huntsman <alpha@qzx.com>
2019-08-18 10:56:17 +02:00
Benno Schulenberg
4bcc224560 docs: change a few URLs over to https, and rewrap a couple of NEWS items 2019-08-17 17:17:32 +02:00
Benno Schulenberg
f2f367ba9c syntaxes: change some unneeded 'icolor' commands to 'color' commands 2019-08-17 17:01:19 +02:00
Benno Schulenberg
48bff32ee3 gnulib: update to its current upstream state 2019-08-17 15:35:43 +02:00
Brand Huntsman
304f07258b rcfile: for an empty syntax, show the line number of the 'syntax' command
When reporting a syntax without any color commands, show the line number
of the relevant 'syntax' command instead of the line number where the
emptiness is concluded, because the latter can be many lines later.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-08-17 13:47:19 +02:00
Benno Schulenberg
e1c2573c7a tweaks: improve a comment, and drop a superfluous one 2019-08-17 13:28:47 +02:00
Benno Schulenberg
07ec7de8eb tweaks: remove a saving and restoring that has become superfluous
The previous commit saves and restores filename and linenumber for
each single included file (after globbing), so it is now redundant
to do it for each 'include' command.
2019-08-17 13:21:34 +02:00
Brand Huntsman
82f5fed45a rcfile: report the correct command location for an invalid 'include'
For each included file, save and restore file name and line number of
the including file, so that an error message about a faulty 'include'
command can indicate the location of this 'include'.

This fixes https://savannah.gnu.org/bugs/?56488.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-08-17 13:07:20 +02:00
Benno Schulenberg
a2f7e31ba2 new document: a condensed overview of nano's shortcut keystrokes
It's in a two-column format that fits on a single page, and uses the
more widely known Ctrl+X and Alt+X notations (instead of ^X and M-X).

The file is published on https://nano-editor.org/cheatsheet.html.
2019-08-16 19:49:50 +02:00
Benno Schulenberg
55983ee9d1 docs: make the synopsis of --speller and 'set speller' more accurate 2019-08-16 18:50:49 +02:00
Benno Schulenberg
cd274a7830 syntax: perl: don't color the character after a variable name
And generally improve the regex for coloring Perl variable names.

This fixes https://savannah.gnu.org/bugs/?56713.
With-help-from: Brand Huntsman <alpha@qzx.com>

Bug existed since the Perl syntax was introduced,
in version 1.2.2, commit 70047eef.
2019-08-14 09:24:32 +02:00
Benno Schulenberg
f773fa3968 syntax: default: colorize bracketed section headers in some config files 2019-08-14 09:18:51 +02:00
Benno Schulenberg
288355686b syntax: c: allow an underscore in lowercase type names 2019-08-11 20:06:46 +02:00
Benno Schulenberg
f7d5a82a5d search: wipe the status bar before searching again (M-W / M-Q)
So that any message that is on the status bar after the search
will be a response to this search and not some leftover.

This fixes https://savannah.gnu.org/bugs/?56737.
2019-08-10 13:11:41 +02:00
Benno Schulenberg
63e04ac31e tweaks: make a function name unique, to not overlap with others 2019-08-09 19:34:03 +02:00
Benno Schulenberg
0c63b50fdc tweaks: move a general function to a better place 2019-08-09 19:24:30 +02:00
Benno Schulenberg
94c9defde1 docs: slightly reword some of the descriptions around syntax highlighting 2019-08-09 19:16:16 +02:00
Benno Schulenberg
ee91c51e09 syntax: perl: avoid recognizing embedded hash signs as a comment starter
Require that a comment starts at the start of a line or is preceded by
whitespace.  This prevents most hash signs used for other purposes (and
what follows them) getting colored as comments.
2019-08-08 12:08:34 +02:00
Benno Schulenberg
1e3f3a7511 syntaxes: recognize .ctp extension as a PHP file, and .cu as a C/C++ file
This brings color to CakePHP template files, and to CUDA files.

This addresses https://bugs.debian.org/932192.
Requested-by: Jérôme Bardot <bardot.jerome@gmail.com>
2019-08-08 12:02:07 +02:00
Benno Schulenberg
8fce33afe0 text: copy leading quote characters when automatic hard-wrapping occurs
When the user is typing a long text and --breaklonglines is in effect,
then any leading comment or quoting characters are automatically added
to each automatic new line.

This fulfills https://savannah.gnu.org/bugs/?56042.
Requested-by: Sébastien Desreux <seb@h-k.fr>
2019-08-06 09:10:34 +02:00
Benno Schulenberg
4314b8ded3 display: blank the status bar on a successful cut or paste
But don't blank it when using the word-deletion functions.

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

Original-patch-by: Bill Hager <prog00@protonmail.com>
2019-08-03 19:32:54 +02:00
Benno Schulenberg
52e39ae5f7 docs: slightly reword the descriptions of most configure options 2019-08-02 17:10:11 +02:00
Benno Schulenberg
5e7ba03ad1 docs: stop mentioning the 'unjustify' function, as it no longer exists
Unjustifying is done by using the general undo function (M-U).
2019-07-29 19:42:52 +02:00
Benno Schulenberg
97fec5603f docs: mention the M-N toggle instead of the obsolete M-# one
Reported-by: Bill Hager <prog00@protonmail.com>
2019-07-29 19:29:55 +02:00
Benno Schulenberg
3b8847f319 syntax: po: colorize numbers only when they form a self-contained word 2019-07-29 19:12:58 +02:00
Benno Schulenberg
a578d2706c copying: do not prevent M-6 from copying emptiness into the cutbuffer
The check mistakenly prevented the user from copying a region that
ended at EOF.  Removing the check also gives the user a way to clear
the cutbuffer (with M-A M-6 or ^6 M-6, for example).

This fixes https://savannah.gnu.org/bugs/?56563.
Reported-by: Liu Hao <lh_mouse@126.com>
2019-07-29 19:00:22 +02:00
Benno Schulenberg
44d38815cc display: clear the remainder of a row only when there actually is some
Make display_string() report back (via a global variable) whether the
just converted string has room to spare within the allotted span, so
that draw_row() can avoid trying to clear the remainder when there is
nothing to clear.

This fixes https://savannah.gnu.org/bugs/?56562.

Bug existed since commit 699cacf7 from three days ago.
2019-06-28 20:45:47 +02:00
Benno Schulenberg
b23a5d5b29 tweaks: rewrap two lines, and reshuffle some logic to make more sense 2019-06-26 19:44:51 +02:00
Benno Schulenberg
b96cc8c212 tweaks: rename a parameter in three functions, to say what it points to 2019-06-26 19:44:51 +02:00
Benno Schulenberg
09ad0eb5f7 tweaks: rename a function, to suit better, and reshuffle its parameters 2019-06-26 19:44:51 +02:00
Benno Schulenberg
62ca113ed3 tweaks: reword and condense two comments, and correct another 2019-06-26 19:07:08 +02:00
Benno Schulenberg
5cfb74650d scrolling: don't overscroll when the edit window has just one row
If the edit window consists of a single row, then the do_down() call
has already brought the desired line or chunk into view -- no attempt
should then be made to scroll the screen further.

This fixes https://savannah.gnu.org/bugs/?56553.

Bug existed since version 2.9.6, commit 0d9080a2.
2019-06-26 12:55:29 +02:00
Benno Schulenberg
8cd6aa0a32 display: when linenumbering, correctly spotlight text that spans two rows
This fixes https://savannah.gnu.org/bugs/?56552.

Bug existed since line numbers were introduced, in version 2.7.1.
2019-06-26 11:24:44 +02:00
Benno Schulenberg
fcbe41942f tweaks: reshuffle an assignment, and trim some excessive blank lines 2019-06-26 10:18:32 +02:00
Benno Schulenberg
39e5b52734 tweaks: call the correct lighting function directly when softwrapping 2019-06-26 10:12:23 +02:00
Benno Schulenberg
70b347183b tweaks: condense some comments, and drop two unneeded initializations 2019-06-26 09:47:07 +02:00
Benno Schulenberg
699cacf7a4 display: don't clear a row beforehand -- just clear the remainder
It is a waste of time to first fully clear a row when right afterward
text will be written to it (for most of the row, on average).  So...
just clear the part of the row after the written text.  Curses has the
perfect function for this: clrtoeol().
2019-06-25 12:09:28 +02:00
Benno Schulenberg
23cb26c58f tweaks: improve a handful of comments 2019-06-25 11:34:04 +02:00
Benno Schulenberg
3422ec3419 browser: draw a bar of spaces only where needed -- for the selected item
The edit window has been fully cleared just before the list-drawing
loop has started, so there is no need to wipe anything.  Only for the
highlighting bar all its characters need to be drawn with the correct
attributes.
2019-06-25 11:25:03 +02:00
Benno Schulenberg
5f1d9af375 tweaks: drop two parameters that are no longer needed 2019-06-25 11:13:35 +02:00
Benno Schulenberg
f3a441043d display: where needed, use slow blanking, but elsewhere do it much faster
Where the row needs to be filled with spaces with the attributes that
were set (title bar, prompt bar, and browser highlight), use printw().
But when the row needs to be actually cleared, use the much faster
clrtoeol().

This reduces the time needed to clear a full row with 95 percent.
2019-06-25 11:12:27 +02:00
Benno Schulenberg
e6c629951f display: use a somewhat faster method to clear a row
On an 80-column terminal, using a single printw() instead of
a loop of addch() reduces the time taken with 13 percent.
2019-06-23 20:49:01 +02:00
Benno Schulenberg
c06d5452f5 tweaks: move a call from two different places to a single place 2019-06-23 19:57:15 +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
bbab9e2e62 tweaks: shorten two messages that translators tend to make too long 2019-06-19 19:34:19 +02:00
Benno Schulenberg
9ea1cd947c tweaks: add a translator hint, to clarify four short words 2019-06-19 19:14:47 +02:00
Benno Schulenberg
b8987a1e40 po: update translations and regenerate POT file and PO files 2019-06-18 10:33:21 +02:00
Benno Schulenberg
895d2b8e9c bump version numbers and add a news item for the 4.3 release 2019-06-18 10:04:16 +02:00
Benno Schulenberg
47068c3770 build: fix compilation when configured with --disable-color 2019-06-17 09:59:15 +02:00
Benno Schulenberg
345cf5accc files: don't close a newly-created buffer when it is the only one
This fixes https://savannah.gnu.org/bugs/?56504.
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since commit 7e422402 from two weeks ago.
2019-06-16 19:12:52 +02:00
Benno Schulenberg
c7ca60b046 tweaks: don't check the user's nanorc file for accessibility twice
Also, condense some alternatives into a single 'if'.
2019-06-16 17:53:44 +02:00
Benno Schulenberg
01e4f85f29 tweaks: remove a check that is no longer relevant
Since commit 7028adf2 from three days ago, also the color commands of
syntaxes that are defined in a main nanorc will get parsed during a
second pass, so it is perfectly possible to extend such syntaxes
later on in the same (or another) nanorc file.
2019-06-16 11:02:03 +02:00
Benno Schulenberg
6bfbb2bcd9 tweaks: remove two more unneeded assignments
'opensyntax' is relevant only during the first pass through all the
nanorc files (intros_only == TRUE) when it is checked that syntax
commands are grouped properly and not mixed with others.  And
'lastcolor' is relevant only during the second pass of a specific
syntax, because only then the color commands are actually parsed.
2019-06-16 10:41:53 +02:00
Benno Schulenberg
d82c753ba4 rcfile: at terminating points, verify that a defined syntax is not empty
Whenever, in an rcfile, a command is encountered that is not part of a
syntax definition, a currently open syntax should be closed, but only
after checking that the syntax contains at least one color command.

This fixes https://savannah.gnu.org/bugs/?56501.

Bug existed since version 2.3.3.
2019-06-15 19:42:31 +02:00
Benno Schulenberg
0af9ce926b rcfile: close off a syntax when a non-syntax command is encountered
The 'color' commands of a syntax definition should not be allowed to
be interspersed with other, non-syntax commands.

This fixes https://savannah.gnu.org/bugs/?56498.

Bug existed since before version 2.6.0.
2019-06-15 15:07:57 +02:00
Benno Schulenberg
4e14a8a977 tweaks: remove two unneeded assignments, and improve a comment
Also reshuffle a line, for esthetics.
2019-06-15 14:35:53 +02:00
Benno Schulenberg
accd17c249 tweaks: remove four unneeded pre-processor directives
The parse_next_word() function is not being used by the history code
anymore since commit ecd18c16, more than two years ago.
2019-06-15 14:17:13 +02:00
Benno Schulenberg
e8eb30cad6 tweaks: just mark four rcfile errors for translation, like the others
The messages get translated when they get stored in the linked list.
This is to economize on the number of actual calls of gettext().
2019-06-15 14:13:20 +02:00
Benno Schulenberg
36bd68f3ab tweaks: rename a function, to better suit what it does 2019-06-15 14:07:57 +02:00
Benno Schulenberg
03692363a2 tweaks: move a syntax check to a better place, to reduce duplication 2019-06-15 13:04:01 +02:00
Benno Schulenberg
0e94575c6b rcfile: check for missing color commands only when a syntax is still open
This fixes https://savannah.gnu.org/bugs/?56497.

Bug existed since commit 7028adf2 from two days ago.
2019-06-15 12:17:33 +02:00
Benno Schulenberg
27cc3117e2 tweaks: rename two parameters, for more contrast, and elide another
Also rename a function.
2019-06-14 10:56:49 +02:00
Benno Schulenberg
19f71632c8 tweaks: remove an unneeded "closing" of a syntax after extending it
As 'extendsyntax' commands are no longer interpreted immediately when
the rcfiles are read, there is no need to set 'opensyntax' to FALSE
after interpreting such a command -- for a single syntax they are all
interpreted in a row.
2019-06-14 10:56:49 +02:00
Benno Schulenberg
e3f18e7a6c tweaks: rename two variables, and frob some comments
Also reshuffle the newline stripping, as it's pointless for lines
that are skipped.
2019-06-14 10:56:49 +02:00
Benno Schulenberg
b55923f5ec tweaks: reshuffle some lines, to group things more sensibly 2019-06-14 10:56:49 +02:00
Benno Schulenberg
7028adf211 rcfile: fully read each included file, so all its syntaxes are seen
An included file can contain multiple syntaxes.  If reading would stop
as soon as a command different from 'syntax' and 'header' and 'magic'
is found, any later syntaxes would not be seen.  So each nanorc file
needs to be fully scanned -- it's just the interpretation of all the
color commands that we want to delay until the syntax gets actually
used.

This fixes https://savannah.gnu.org/bugs/?56478.

Bug existed since commit cba9d8d0 from a month ago.
2019-06-14 10:49:30 +02:00
Benno Schulenberg
d7df7c694a tweaks: elide a pre-processor #else clause, by using braces instead 2019-06-13 15:47:29 +02:00
Benno Schulenberg
ce69d5be88 tweaks: condense two comments, and normalize the whitespace of a label 2019-06-12 11:10:27 +02:00
Benno Schulenberg
3da4240229 tweaks: rename a variable, to fit a little better 2019-06-12 11:03:03 +02:00
Benno Schulenberg
43caf7bb7b tweaks: avoid an unneeded, extra stat() for temporary files 2019-06-12 10:48:03 +02:00
Benno Schulenberg
e8e30e5197 tweaks: elide an unneeded, duplicate stat() for the FIFO check 2019-06-12 10:34:53 +02:00
Benno Schulenberg
189de5ee78 files: suppress feedback when writing an emergency or temporary file
This fixes https://savannah.gnu.org/bugs/?56474.

Bug existed since commit 47770bd3 from two weeks ago.
2019-06-12 09:51:14 +02:00
Benno Schulenberg
c57d040e99 tweaks: don't bother calling mblen() in a non-UTF-8 build
There is no need, because in non-UTF-8 encodings nano treats
each single byte as one character anyway.
2019-06-11 19:48:03 +02:00
Benno Schulenberg
0adb15c7a1 display: properly show all characters in a non-UTF-8 build
Also, don't use mblen() directly, to not get stuck when it returns -1,
which it will when running a non-UTF-8 build in a UTF-8 locale.

This fixes https://savannah.gnu.org/bugs/?56472.

Bug existed since commit cd094822 from yesterday.
2019-06-11 19:07:34 +02:00
Benno Schulenberg
1e48df388e build: avoid a warning when using --disable-utf8 2019-06-11 14:24:30 +02:00
Benno Schulenberg
d477775871 build: avoid a warning on FreeBSD, OpenBSD, and Alpine 2019-06-11 12:29:32 +02:00
Benno Schulenberg
ed40fd8031 tweaks: reorder some code, to further optimize display_string() for ASCII
The majority of characters in the files that get edited with nano will
be single-byte printable ASCII characters, so their case should come
first in the main loop of display_string().
2019-06-11 12:08:28 +02:00
Benno Schulenberg
5c4b0b38f4 chars: redo the speedup for plain ASCII from three commits ago
It was lost in the elision of length_of_char() two commits ago.
2019-06-11 11:10:53 +02:00
Benno Schulenberg
bd331b0198 tweaks: reshuffle some lines and frob some comments 2019-06-10 20:07:10 +02:00
Benno Schulenberg
cd09482231 tweaks: elide a function that is an amalgam of three others
In addition, the function was used just once, had a weird return value,
and now some more code can be excluded from a non-UTF8 build.

Make use of the fact that any single-byte character always occupies
just one column, and call the costly mbtowc() and wcwidth() only for
characters that actually are multibyte.
2019-06-10 19:43:50 +02:00
Benno Schulenberg
c5955d14ce chars: speed up the determination of length and width for plain ASCII 2019-06-10 17:22:41 +02:00
Benno Schulenberg
7d38379919 tweaks: rename two parameters, away from single letters 2019-06-10 12:36:16 +02:00
Benno Schulenberg
45bf18f8fe tweaks: rename three variables, to get rid of a suffix or an underscore
Also drop an unneeded cast.
2019-06-10 12:34:24 +02:00
Benno Schulenberg
787dca6724 tweaks: elide an unneeded variable 2019-06-10 12:06:12 +02:00
Benno Schulenberg
15e36956b5 tweaks: avoid parsing a character twice
Let mbtowc() do all the work, and thus also elide a variable.
2019-06-10 12:01:10 +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
3457039cee tweaks: rename a variable, to get out of the way of the next commit 2019-06-09 19:31:01 +02:00
Benno Schulenberg
ca77254968 tweaks: use a slightly faster function where appropriate
Also, correct a call of move_mbright() to use the intended format.
2019-06-09 19:22:24 +02:00
Benno Schulenberg
710a600f22 chars: speed up case-insensitive searching by roughly one percent
It is less of a speedup than I was hoping for, though.
2019-06-09 19:13:25 +02:00
Benno Schulenberg
843eef65b8 tweaks: put some timing code back into the search function 2019-06-09 18:48:52 +02:00
Benno Schulenberg
781c7a7a5f chars: create a dedicated function for getting the length of a character
Instead of calling in twenty places parse_mbchar(pointer, NULL, NULL),
use a simpler and faster char_length(pointer).  This saves pushing two
unneeded parameters onto the stack, avoids two needless ifs, and elides
an intermediate variable.

Its main purpose will follow in a later commit: to speed up searching.
2019-06-09 18:38:46 +02:00
Benno Schulenberg
aa205f58ca tweaks: rename a bunch of variables, to become identical to others 2019-06-09 17:07:02 +02:00
Benno Schulenberg
3bf04afa6d tweaks: specifically refer to the manual of GNU grep for more regex info 2019-06-09 12:30:35 +02:00
Benno Schulenberg
71236e145d tweaks: rename two variables, away from a single letter
And adjust the indentation after the previous change.
2019-06-09 11:08:34 +02:00
Benno Schulenberg
7be76af418 tweaks: speed up the counting of characters in mbstrlen()
This function is used in get_totsize(), so speed is important.

There is no reason why the length of the string must limited to a
certain size -- that is just a leftover from the function merge in
commit ba2e6f43 from a year ago.
2019-06-09 11:04:52 +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
Benno Schulenberg
fea1901592 docs: remove "--" from the default value of 'quotestr'
Adjust the documentation to the removal of "--" in the previous commit.
2019-06-08 17:48:44 +02:00
Benno Schulenberg
33fea90bcd justify: remove "--" from the quoting regex, to avoid false paragraphs
The use of a double dash (for an option name or as sentence separator)
is too common to allow it to be seen always as a comment introducer.
Users of Lua and Postgres will have to redefine 'quotestr' themselves
if they want to be able to rewrap block comments with ^J.

The other characters that were added in commit c5a72103 (!, %, and ;)
are less problematic because they tend to be glued to the end of words,
so they are unlikely to appear at the start of a line.

This fixes https://savannah.gnu.org/bugs/?56462,
and fixes https://savannah.gnu.org/bugs/?56461.

Bug existed since version 4.0, commit c5a72103.
2019-06-08 16:47:08 +02:00
Benno Schulenberg
f03c87c300 tweaks: squeeze excess spaces out of a line in situ
There is no need to make a copy of the line, because if there are some
bytes that are moved, they are always moved toward the left -- the line
can only shrink, never expand.
2019-06-08 16:17:59 +02:00
Benno Schulenberg
45b1a38b82 tweaks: factor out a fragment of code that is repeated three times 2019-06-08 14:17:41 +02:00
Benno Schulenberg
c3bf17a801 tweaks: improve a handful of comments 2019-06-08 14:00:24 +02:00
Benno Schulenberg
8582e4a6b9 tweaks: don't bother keeping track of whether a squeezed line has shrunk
When squeezing excess spaces from a line has proved unsuccessful, we
have already copied all of its data, so it hardly makes a difference
whether we free the old or the new data.  Choose to free always the
old data, so that we can simplify things.
2019-06-08 14:00:03 +02:00
Benno Schulenberg
9b34d0a4fb tweaks: rename two variables, to be unique 2019-06-08 10:10:31 +02:00
Benno Schulenberg
26d16ab9d1 tweaks: rename a variable, to better suit its counterpart 2019-06-08 10:05:32 +02:00
Benno Schulenberg
6ca8518428 tweaks: make better use of two variables, and reshuffle two comments 2019-06-08 10:03:15 +02:00
Benno Schulenberg
f2c61c4b9a docs: mention the default value for 'errorcolor' 2019-06-07 11:24:51 +02:00
Benno Schulenberg
c4e04eb682 docs: show double quotes where they are needed
Instead of saying that string parameters should be enclosed in
double quotes, just show the quotes in the relevant commands.

Also, rename the parameters, to better fit the subsequent description.
2019-06-07 11:15:02 +02:00
Benno Schulenberg
0b257fe558 tweaks: sort three translator names better 2019-06-06 15:22:02 +02:00
Benno Schulenberg
941637615b docs: clarify that in nano regexes are extended regular expressions
And add a concise summary of the most important special characters.

This addresses https://savannah.gnu.org/bugs/?56438.
2019-06-06 15:16:56 +02:00
Benno Schulenberg
378aa8bc41 docs: slightly reword the notice about the changed defaults since 4.0 2019-06-05 19:40:15 +02:00
Benno Schulenberg
157098ee75 gnulib: update to its current upstream state 2019-06-05 16:45:27 +02:00
Benno Schulenberg
8d4e171d3c tweaks: improve a couple of comments 2019-06-05 16:23:34 +02:00
Benno Schulenberg
6f1e5912a9 tweaks: stop allocating and freeing a holder struct for every cut/paste
This "holder" information is needed for every cut and paste and other
block operation.  Instead of allocating and freeing it for every such
operation, just have the six elements as static variables.  This saves
a little churn, and saves having to declare a type that is used just
once.  Plus, the access to these variables will be a little quicker.
2019-06-05 16:10:07 +02:00
Benno Schulenberg
28a6d9f300 tweaks: rename four elements of the holder struct, for more contrast 2019-06-05 15:32:50 +02:00
Benno Schulenberg
f92606491c speller: when something goes wrong with 'sort', do not blame 'spell'
That is, check the exit status of 'sort' before the one of 'spell'.
2019-06-05 15:07:33 +02:00
Benno Schulenberg
260588af1e speller: be more concise and to the point when something goes wrong 2019-06-05 14:57:24 +02:00
Benno Schulenberg
cdc9482d8f tweaks: rename three variables, to use full words instead of abbrevs 2019-06-05 14:50:01 +02:00
Benno Schulenberg
7c1b649eb8 tweaks: rename a function and its parameters, to be more fitting
Also, reshuffle their order, and improve or adjust some comments.
And change the type of 'pairnum' to short, what ncurses uses too.
2019-06-05 13:08: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
Benno Schulenberg
edbdcb9b9a docs: add a light warning to the explanation of --nonewlines 2019-06-04 19:54:58 +02:00
Benno Schulenberg
a6978b54f1 docs: say thanks to the Korean translator, and trim a double space 2019-06-04 19:32:52 +02:00
Brand Huntsman
8bc2d18fa9 tweaks: remove an unneeded pre-processor '#else' clause
Commit 1e2e6733 added braces and made the semicolon no longer needed
when libmagic is not used.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-06-04 19:27:34 +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
Benno Schulenberg
9b30bb15cc tweaks: adjust the indentation after the previous change
And reshuffle two declarations.
2019-06-03 15:51:07 +02:00
Benno Schulenberg
a1669e1bfd rcfile: disallow extending a syntax that is defined in a main nanorc
The /etc/nanorc file should not define any syntax directly (and
preferably not include any either, to not slow startup down with
syntaxes the user is never going to use), and if the ~/.nanorc file
defines a syntax directly, there is no need to use 'extendsyntax':
the command can be added to the syntax itself -- it would be better
even: it keeps things together.
2019-06-03 15:42:06 +02:00
Benno Schulenberg
3d6eca3f26 tweaks: reshuffle some lines, to put the most likely candidate first 2019-06-03 15:04:00 +02:00
Benno Schulenberg
c025a60ce9 tweaks: rename a function and a variable, for contrast and variety 2019-06-03 15:01:28 +02:00
Benno Schulenberg
5e1f90d8fa tweaks: don't bother to free the content of 'extendsyntax' commands
Extending a syntax will be rather rare, so the amount of memory it
takes up will be minimal.  It's not worth the trouble to free this
memory -- it only takes time.  Plus: we don't bother to free the
memory of a syntax that gets fully redefined either.
2019-06-03 14:37:27 +02:00
Benno Schulenberg
7f3ffe8544 tweaks: remove a bit of redundant code
When an included file has just been fully parsed, 'lastcolor' is still
pointing at the last color regex that was added to the list -- no need
to refind the end of this list.
2019-06-03 14:21:17 +02:00
Benno Schulenberg
ea1016efdb feedback: make an error check work also when curses hasn't started yet
Add a temporary boolean for this, because isendwin() returns TRUE
only when curses mode has actually been started with initscr() and
then exited with endwin().
2019-06-03 13:38:21 +02:00
Benno Schulenberg
f63fee79e3 tweaks: merge two functions, as the first is called just once 2019-06-01 11:14:21 +02:00
Benno Schulenberg
2003413989 tweaks: move a function to the file where it is used 2019-06-01 10:52:38 +02:00
Benno Schulenberg
9369af77ce tweaks: elide a function that is used just once 2019-06-01 10:43:50 +02:00
Benno Schulenberg
35d2bc6b38 build: fix compilation on another system
The <signal.h> header file is needed to define 'sig_atomic_t'.
(Don't know why on my main system it compiled fine without it.)
2019-05-31 20:53:00 +02:00
Benno Schulenberg
b52d166afa tweaks: rename a type, to make more sense
The sphere, the holder, is everything *around* the partition;
it was confusing to call this holder type 'partition'.

Also correct and improve some comments.
2019-05-31 19:44:47 +02:00
Benno Schulenberg
3952dcb629 tweaks: rename a variable, reduce its scope, and use it consistently 2019-05-31 19:25:50 +02:00
Benno Schulenberg
7e9dd385f5 tweaks: elide a parameter and a return value
As 'filepart' is a global variable, there is no need to pass it around.
Just use it directly.
2019-05-31 19:00:20 +02:00
Benno Schulenberg
2e81023553 tweaks: rename two variables, and reshuffle their declarations 2019-05-31 17:45:51 +02:00
Benno Schulenberg
b9f994b2c0 tweaks: elide a variable, drop a comment, and remove unneeded braces
There is no need to save, clear, and restore the mark when counting
words, lines and characters, because partitioning and unpartitioning
the buffer does not use the mark nor affect it.
2019-05-31 17:43:40 +02:00
Benno Schulenberg
e98847200e tweaks: reshuffle some lines, to reduce duplication 2019-05-31 17:42:42 +02:00
Benno Schulenberg
a77b21388a build: remove two #includes that don't seem to be needed 2019-05-31 17:16:07 +02:00
Benno Schulenberg
58ca5fb0f3 build: move an #include to where it is needed 2019-05-31 17:14:28 +02:00
Benno Schulenberg
844214b4a0 tweaks: rename two variables, to not be abbreviations
Also reshuffle two declarations.
2019-05-31 12:54:20 +02:00
Benno Schulenberg
f9dfca7d5a tweaks: rename a variable, to be shorter 2019-05-31 12:46:15 +02:00
Benno Schulenberg
fe40e8867d tweaks: rename a struct element, to be distinct
And to match the style of its sisters.
2019-05-31 12:25:15 +02:00
Benno Schulenberg
923a90cba0 tweaks: rename a type, for more contrast 2019-05-31 12:18:30 +02:00
Benno Schulenberg
5817e83e33 tweaks: be more sparing in redrawing things when exiting from help viewer
That is: don't redraw the title bar twice, don't redraw the bottom bars
twice, nor unnecessarily redraw the whole screen.
2019-05-31 10:28:23 +02:00
Benno Schulenberg
122cabd3ba tweaks: elide another parameter, and rename the function to match 2019-05-31 09:33:28 +02:00
Benno Schulenberg
c5d157dd9d tweaks: close a buffer differently and elide a parameter 2019-05-31 09:15:12 +02:00
Benno Schulenberg
3a65c0d192 feedback: when the last line is empty, don't include it in the count
Now M-D will report 0 lines instead of 1 line for an empty buffer, and
will match the output of 'wc --lines' as long the file is a POSIX file.

This fixes https://savannah.gnu.org/bugs/?56054.

Bug existed since before version 2.1.10.
2019-05-30 19:51:25 +02:00
Benno Schulenberg
e1c011c9a1 tweaks: rename a variable, to match the style of its brothers 2019-05-30 19:34:57 +02:00
Benno Schulenberg
477ff49f66 feedback: don't try to represent keys outside of the seven-bit range
This fixes https://savannah.gnu.org/bugs/?56415.
2019-05-30 19:06:06 +02:00
Benno Schulenberg
85eb9b9a53 tweaks: use a cheaper way to switch between buffers where possible
For this one quick switch back and forth there is no need to report
anything on the status bar nor to update colors and such.  In this
case, those things are just a waste of time.
2019-05-30 17:42:37 +02:00
Benno Schulenberg
484523b3bb tweaks: drop two checks that were made redundant by the previous commit 2019-05-30 17:18:30 +02:00
Benno Schulenberg
5a48edc9ae tweaks: reshuffle some code to the one place that needs it
The extra things that close_buffer() did are only needed and useful
when manually closing a buffer, so move them there.  The other three
calls of close_buffer() only need to get rid of the current buffer
(making the preceding buffer the new current one) and nothing else.
2019-05-30 17:09:49 +02:00
Benno Schulenberg
6dc8570d55 tweaks: reshuffle a few things, partly to make two chunks more alike 2019-05-30 16:00:11 +02:00
Benno Schulenberg
7e422402d5 tweaks: change a function to void, to make things more direct 2019-05-29 20:02:50 +02:00
Benno Schulenberg
5f03c20ea0 tweaks: switch to the preceding buffer in a cheaper way (when in help)
When a help-text buffer is closed while exiting from the help viewer,
the rest of the exit code takes care that the preceding buffer gets
displayed properly.  And when a help-text buffer is closed because a
SIGWINCH occurred, doing anything for the preceding buffer is a waste
of time because a new help-text buffer will be opened and displayed
instantly.
2019-05-29 19:48:42 +02:00
Benno Schulenberg
71574e7a6f tweaks: reshuffle some closing and switching to a better place
And rename the function and elide a parameter besides.
2019-05-29 19:48:42 +02:00
Benno Schulenberg
821445d284 tweaks: drop some checks that were made redundant by the previous commit
And move one to a better place.
2019-05-29 19:48:42 +02:00
Benno Schulenberg
3eab405e7b help: write the text directly into a new buffer, without using a tempfile
This avoids the substantial overhead of first writing and then reading a
temporary file, and in the bargain removes two possible failure points.

This fulfills https://savannah.gnu.org/bugs/?56371.
2019-05-29 19:48:42 +02:00
Benno Schulenberg
423ed031b4 help: don't cycle through the buffers for every resizing step
Closing a buffer automatically switches to the next buffer.  But for
the help-text buffer this is not the desired behavior, so each closing
needs to be followed by a switch to the preceding buffer.

This fixes https://savannah.gnu.org/bugs/?56411.
2019-05-29 12:33:59 +02:00
Benno Schulenberg
57390cff04 tweaks: exclude another bug check from the tiny version 2019-05-29 11:24:25 +02:00
Benno Schulenberg
4e637cd1c7 tweaks: delete a now-unused function 2019-05-28 17:41:28 +02:00
Benno Schulenberg
add1159675 tweaks: don't bother checking the return value of wait()
It is not done for the external spell checker either.
2019-05-28 17:39:19 +02:00
Benno Schulenberg
dbdf38cce5 tweaks: consistently report failures to fork (and the like) as errors 2019-05-28 17:36:32 +02:00
Benno Schulenberg
47770bd321 feedback: treat statusline() being called outside of curses mode as a bug 2019-05-28 17:19:34 +02:00
Benno Schulenberg
d656b0d3b9 feedback: show an appropriate message when reading a file was cut short 2019-05-28 17:06:07 +02:00
Benno Schulenberg
d9deaf9f2f tweaks: reduce the scope of a variable, and let the compiler zero it
Also, rename the variable, to have a unique name.
2019-05-28 14:09:54 +02:00
Benno Schulenberg
b75563b88e tweaks: use a symbol instead of zero to refer to standard input 2019-05-28 12:31:16 +02:00
Benno Schulenberg
33e1bf1435 startup: remove the now-unneeded workaround for a SIGWINCH during input
The previous commit makes that the terminal's state is only resaved
when standard input is actually reconnected to the terminal, and
leaves it unchanged otherwise.  Apparently this is enough to fix
https://savannah.gnu.org/bugs/?56394.
2019-05-28 12:19:49 +02:00
Benno Schulenberg
d946f38a2b files: when needed, reconnect the keyboard and reenter curses mode
When after reading a file we are not in curses mode, it means we have
read data from standard input, either from the keyboard or from a pipe.
In the latter case, we first need to reconnect standard input to the tty.
And in both cases, we then need to reenter curses mode before being able
to display the number of lines that were read (or an error message).

So, move the reconnecting code from scoop_stdin() to its own function,
and call this function from read_file() when needed.

This fixes https://savannah.gnu.org/bugs/?56310.

Bug existed since version 2.1.8 when reading from stdin was introduced.
2019-05-28 11:28:23 +02:00
Benno Schulenberg
b53dffaeed startup: resave the terminal's state only when there were no signals
For some reason a SIGWINCH or SIGINT "corrupts" the current state of
the terminal, and magically validates the state that was saved first.

This fixes https://savannah.gnu.org/bugs/?56394 properly.
2019-05-27 19:35:46 +02:00
Benno Schulenberg
6dcfcd11ce tweaks: rename two functions, to better describe what they do 2019-05-27 17:24:35 +02:00
Benno Schulenberg
f21b094dad tweaks: condense a couple of comments, and reshuffle a line 2019-05-27 17:21:05 +02:00
Benno Schulenberg
a521ac4ae7 tweaks: exclude a bug check from the tiny version 2019-05-27 10:11:22 +02:00
Benno Schulenberg
d972c17050 build: exclude the ability to open a FIFO from the tiny version 2019-05-27 09:55:24 +02:00
Benno Schulenberg
f6e182ca72 tweaks: check in a single place for files that should not be opened 2019-05-27 09:42:41 +02:00
Benno Schulenberg
6a83bb7508 tweaks: delete a leftover 2019-05-27 09:33:36 +02:00
Benno Schulenberg
728498fde5 files: don't say "Error...: Success" when aborting after resizing
For some reason 'errno' is not EINTR but zero when a SIGINT is
produced after a SIGWINCH.
2019-05-26 19:49:23 +02:00
Brand Huntsman
05f34bbfaf files: block SIGWINCH while opening a FIFO for reading or writing
This fixes https://savannah.gnu.org/bugs/?56354.
Reported-by: Brand Huntsman <alpha@qzx.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-05-26 19:40:33 +02:00
Benno Schulenberg
b7e2da7434 files: don't save the state of the terminal a second time
The user will understand that changing the state of the terminal
while inputting data into nano is not the same as changing this
state before nano has started or after nano has exited.

This fixes https://savannah.gnu.org/bugs/?56394.

Bug existed since version 2.4.2.
2019-05-26 19:16:40 +02:00
Benno Schulenberg
8e2d03b92c build: fix compilation when configured with --enable-tiny 2019-05-26 14:48:14 +02:00
Benno Schulenberg
308a094d8d feedback: show a more fitting message when opening a FIFO is interrupted 2019-05-26 14:17:35 +02:00
Benno Schulenberg
5757aa8a0c tweaks: reuse the install and restore functions for a signal handler 2019-05-26 13:57:29 +02:00
Benno Schulenberg
8c5b67379f tweaks: factor out the installing and restoring of the ^C signal handler
So that these two functions can be used elsewhere too.
2019-05-26 13:55:59 +02:00
Benno Schulenberg
b2926eb675 tweaks: include the enabling of SIGINT into the tiny version
Either this enabling is not needed at all when the original terminal
state has been restored, or it will be needed in the tiny version too.

Also condense some comments.
2019-05-26 13:49:38 +02:00
Benno Schulenberg
ea11709564 files: allow to abort the reading of slow files with Ctrl+C
This addresses https://savannah.gnu.org/bugs/?44907.

Original-patch-by: Martin van Zijl <martin.vanzijl@gmail.com>
2019-05-26 13:34:38 +02:00
Benno Schulenberg
8550c6bd93 files: allow to interrupt the opening of a FIFO for writing with Ctrl+C 2019-05-26 11:45:51 +02:00
Benno Schulenberg
65560a583c tweaks: rename a parameter and a variable, to be more distinct 2019-05-24 19:27:04 +02:00
Benno Schulenberg
35a791dee5 tweaks: remove two unneeded checks for NULL
If the rest of nano is correct, then these checks are superfluous and
only slow the loops down.  But if there is some incorrect code, then
let nano crash on dereferencing NULL so we can find and fix the bug.
2019-05-24 19:17:01 +02:00
Benno Schulenberg
98ffb19746 tweaks: stop checking for a NULL result from line_from_number()
No one ever reported seeing the message that was removed in commit
c039aaad one month ago, so most likely the code is correct and nano
never calls line_from_number() with a non-existent line number.
2019-05-24 19:08:29 +02:00
Benno Schulenberg
93edd12099 tweaks: rename a function, to be clearer and to stop using an old abbrev 2019-05-24 18:56:34 +02:00
Benno Schulenberg
9a475bf2d3 speller: don't crash when the spell-checked tempfile cannot be opened
This addresses https://savannah.gnu.org/bugs/?56361.
2019-05-24 17:31:35 +02:00
Benno Schulenberg
b512e253b6 tweaks: drop an unneeded parameter from open_file()
The 'quiet' parameter is only used when opening a help-text tempfile
or a spell-checked tempfile, and these files necessarily exist, so
'quiet' will never be checked for them.  But in the weird case that
the help-text tempfile could not be opened, it is not a problem that
"New File" gets printed to the status bar because nano will crash
shortly afterwards.  And when the spell-checked tempfile could not
be opened, a "Not Found" message is appropriate, but nano will crash
in this case too.
2019-05-24 13:00:00 +02:00
Benno Schulenberg
137c4467ef speller: ensure that a Shift-selected region is retained
For both an integrated and an external spell check, fake the Shift key
being held so that (when the cursor is moved by a changed length of a
word) a Shift-selected region is not unexpectedly cancelled.

This fixes https://savannah.gnu.org/bugs/?56365.
2019-05-24 12:30:07 +02:00
Benno Schulenberg
4cacb626a0 files: allow to interrupt the opening of a FIFO with Ctrl+C
With-help-from: Brand Huntsman <alpha@qzx.com>
2019-05-24 10:51:56 +02:00
Benno Schulenberg
e3e81879b1 tweaks: condense the setup of the two signal handlers for Ctrl+C
Don't bother checking for an error from sigaction(), because the only
things it could error out for is when it is passed an invalid signal
(which SIGINT isn't) or oldaction/newaction would point to memory that
is outside of nano's control (which is obviously not the case).

Also, the setup of signal handlers during startup does not check for
errors, so why do it here?
2019-05-24 10:48:03 +02:00
Benno Schulenberg
acd23551c3 help: don't check for confinement when opening a temporary help-text file
This fixes https://savannah.gnu.org/bugs/?56369.
2019-05-23 12:43:31 +02:00
Benno Schulenberg
2f1691079e usage: make the --help output independent from the terminal's tab size
Use printf's ability to align things (instead of trying to do it
ourselves and failing when the tab size of the terminal is not 8.)

Suggested-by: Vincent Huisman <site.gentoobugzilla@dataghost.com>

This fixes https://savannah.gnu.org/bugs/?56372.
Reported-by: Vincent Huisman <site.gentoobugzilla@dataghost.com>
2019-05-22 19:55:25 +02:00
Benno Schulenberg
12bf3bfce4 feedback: don't clear off possible error messages after a spell check
If functions deeper down would put up some message on the status bar,
it should not be cleared.  The chance that messages from a spell-check
program stay onscreen is minute: the edit window is fully refreshed,
the status bar is fully drawn, and the help lines (if there are any)
are redrawn.  Only the title bar is not refreshed, but the chance that
an error message has spilled onto the top row...  And anyway, the
spell checker should not print any error messages at all.
2019-05-21 19:42:44 +02:00
Benno Schulenberg
d7555d071f tweaks: adjust a comment and drop two others, and reshuffle two lines 2019-05-21 19:42:08 +02:00
Benno Schulenberg
9596f7de9d tweaks: delete a now-unused function 2019-05-21 18:56:35 +02:00
Benno Schulenberg
20635b40f4 tweaks: merge two very similar functions into a single one 2019-05-21 18:56:13 +02:00
Benno Schulenberg
1128a40d42 tweaks: remove an unneeded setting and unsetting of a flag
This twiddling was made superfluous by commit faa0eb99 from a year ago.
2019-05-21 18:55:34 +02:00
Benno Schulenberg
1e2e6733df tweaks: add a pair of braces, to silence a compiler warning
Also, put an 'else' on the same line as the preceding closing brace.
2019-05-21 17:25:45 +02:00
Benno Schulenberg
2669d3623d tweaks: set a boolean directly, instead of using a function call 2019-05-21 12:15:37 +02:00
Benno Schulenberg
22fc16b2d0 tweaks: add a missing forward declaration of make_new_buffer()
Reported-by: Brand Huntsman <alpha@qzx.com>
2019-05-20 11:53:22 +02:00
Benno Schulenberg
372e858ec8 docs: note David as author of undoable indenting and undoable justifying 2019-05-20 10:55:03 +02:00
Benno Schulenberg
da8c74a44f docs: note Brand as the author of the delayed syntax parsing 2019-05-20 10:45:33 +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
Brand Huntsman
0e29c2a24a rcfile: store errors and display them when nano terminates
This is needed to implement the demand loading of syntax files, as any
errors that these files may contain would otherwise overwrite things on
the screen and the messages wouldn't be on the terminal when nano exits.

It also allows nano to start up on a Linux console when there are errors.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-05-20 10:25:47 +02:00
Benno Schulenberg
9e182722cc feedback: print helpful message only when data comes from keyboard
When the data is fed to nano through a pipe, it is pointless to print
this message as it can be seen only after nano has exited.

This addresses https://savannah.gnu.org/bugs/?56348.
2019-05-19 19:49:47 +02:00
Benno Schulenberg
4f1eb5fdd4 tweaks: remove the two remaining handfuls of asserts
They are just clutter -- no one runs a debug build for any length
of time.
2019-05-19 18:58:02 +02:00
Benno Schulenberg
53352d0b26 files: try matching a syntax after scooping data from standard input
The blank filename should not give any match, but maybe the header line
or the magic finds a fitting syntax.

This fixes https://savannah.gnu.org/bugs/?56344.
2019-05-19 17:48:08 +02:00
Benno Schulenberg
1d3a4df3b3 browser: don't show a mistaken message when exiting from help viewer
This fixes https://savannah.gnu.org/bugs/?56346.

Bug existed since version 3.0, commit 8d6b205e.
2019-05-18 19:59:54 +02:00
Benno Schulenberg
afbaf8ae2d files: give feedback while waiting for a FIFO to open up 2019-05-18 19:14:32 +02:00
Benno Schulenberg
1b2018e921 files: check for writability by the access bits, not by trying to append
Trying to append does not work on a fifo, and we'd like to be able to
open a fifo again.  Also, the append test causes a close event for the
given file at the moment of opening it, which makes using 'inotify' for
waiting for this file to be closed useless.

Commit f8f90272 added the append test, but the original request
(https://lists.gnu.org/archive/html/info-nano/2009-05/msg00000.html
by Damien Joldersma) asked only for a warning when the user did not
have enough privileges to write to the file.

So, drop the append test and just check the access bits.

This fixes https://bugs.debian.org/583196
and fixes https://savannah.gnu.org/bugs/?29312.
2019-05-18 19:13:42 +02:00
Benno Schulenberg
26642a39c3 files: allow a given file to be a special file but not a directory
The original requests (https://bugs.debian.org/551717 by Paul Wise,
and https://savannah.gnu.org/bugs/?45383 by Mike Frysinger) asked
only that specifying a directory instead of a file name should not
open a new buffer.  But commit 98ffb642 excluded everything that was
not a normal file.  This avoids a hang when the user accidentally
tries to open a pipe or a socket, but also prevents any user from
doing so on purpose.  And opening a fifo can be useful when wanting
to handle sensitive data that shouldn't be stored on disk.

This prepares the fix for https://bugs.debian.org/583196.
2019-05-18 17:24:13 +02:00
Benno Schulenberg
8723375443 tweaks: remove a superfluous and ineffective assignment
This assignment became superfluous two years ago, by David's revamping
of read_file() in commit 86f7bc18.
2019-05-18 17:21:54 +02:00
Benno Schulenberg
82aea04c79 bindings: at a Yes-No prompt, accept also ^Y for "Yes"
For symmetry with ^N for "No".

Suggested-by: Brand Huntsman <alpha@qzx.com>
2019-05-17 11:39:40 +02:00
Benno Schulenberg
341601e1a2 bindings: at a Yes-No prompt, accept also ^N and ^Q for "No"
When wanting to exit after having modified a buffer by mistake, I don't
want to politely answer a question by typing precisely an unmodified N,
I want to give a command: ^N, meaning *No!*.  Or seen another way: I
don't want to be obliged to let go of the Ctrl key before typing N.

When at startup --tempfile was used, the user can discard a modified
buffer with ^O ^Q.  It would be nice when (without --tempfile) ^X ^Q
would work too.
2019-05-17 11:31:59 +02:00
Benno Schulenberg
368f1a1c9d tweaks: elide a function that is called in just one place
Since commit b5f15cb5 from a year ago, there remains just one call
of initialize_buffer_text().
2019-05-16 16:16:52 +02:00
Benno Schulenberg
527c6c1ca0 tweaks: reshuffle a few lines, to be more straightforward 2019-05-16 16:04:12 +02:00
Benno Schulenberg
a9e8f88e77 tweaks: enforce the miminum amount of scrolling in a simpler way
This improves the fix for https://savannah.gnu.org/bugs/?56317.
2019-05-16 16:00:42 +02:00
Benno Schulenberg
0cbf1f4027 help: don't show Alt+Left and Alt+Right when running on a Linux console
On a VT, <Alt+Left> and <Alt+Right> switch between VTs and nano
does not receive those keystrokes.
2019-05-13 13:01:10 +02:00
Benno Schulenberg
96baa70cc8 tweaks: reshuffle a couple of lines and adjust a few comments
Also, compute the required space for the keystrokes more tightly:
most of those characters are plain ASCII, so that means 17 bytes
for 17 cells, and at most one of those characters is a three-byte
arrow, which means 2 bytes extra.  Adding the two newlines at the
end, the needed room besides the description is 21 bytes.
2019-05-13 12:25:39 +02:00
Benno Schulenberg
b18e2129ce bindings: bind the Alt+arrow keystrokes also in non-UTF-8 locales
Fall back to using the words "Left", "Right", "Up", and "Down",
instead of graphical arrows.

This fixes https://savannah.gnu.org/bugs/?56313.

Bug was left to exist since the Alt+arrow keys were introduced,
in version 2.8.7, commit 1cc030f7.
2019-05-13 11:35:15 +02:00
Benno Schulenberg
e26cbdd6cd help: make the column for the first keystroke a little wider
To make room for the "M-Right" that is coming in the next commit --
seven characters are needed instead of six.
2019-05-13 11:07:21 +02:00
Benno Schulenberg
0ebfd54e17 softwrap: use smooth scrolling when softwrapping is toggled on
If the cursor is near the bottom row when softwrap gets switched on, the
screen should scroll just the amount needed to keep the cursor onscreen.

This fixes https://savannah.gnu.org/bugs/?56317.

Bug existed since softwrapping was introduced in version 2.1.11.
2019-05-13 10:25:12 +02:00
Benno Schulenberg
8f1cd50f1e syntax: python: avoid miscoloring stuff between two empty strings
The quotes of an empty string ('' or "") should be colored just like
those of a non-empty string, because otherwise the text *between* two
empty strings on the same line gets colored.

Add an extra rule to discolor triple quotes again to not make them
look like valid by themselves.

Also, remove six superfluous backslashes.

This addresses https://savannah.gnu.org/patch/?9801.
Reported-by: Ryan Westlund <rlwestlund@gmail.com>
2019-05-11 19:05:45 +02:00
Benno Schulenberg
4fb9f298c9 tweaks: adjust some indentation after the previous change
Also reshuffle some arguments.
2019-05-08 19:35:42 +02:00
Benno Schulenberg
c338d86843 tweaks: rename some single-letter variables to the same significant word
And simply elide one of those variables.
2019-05-08 19:35:03 +02:00
Benno Schulenberg
247dd8f052 tweaks: rename a variable, reshuffle declarations, and drop an assert 2019-05-08 15:34:06 +02:00
Benno Schulenberg
71d0847b19 tweaks: merge two functions, as the one is used only by the other 2019-05-08 15:25:11 +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
da91a44f9e tweaks: reshuffle two #ifdefs, to avoid an unpaired brace 2019-05-08 13:56:02 +02:00
Benno Schulenberg
02d3a2c0fb tweaks: remove some unneeded braces, and reshuffle for more symmetry 2019-05-06 11:20:31 +02:00
Benno Schulenberg
5764619655 search: stay in the Search menu when trying to Replace in view mode
This fixes https://savannah.gnu.org/bugs/?56274.

Bug existed since version 3.1, commit 6cd53e7f.
2019-05-06 11:08:22 +02:00
Benno Schulenberg
3c959fd038 tweaks: drop a useless tidying-up call, as spelling does not use regexes
The integrated spell checker does not use regular expressions, and
'refresh_needed' is set to TRUE anyway, so the tidy_up_after_search()
call there is effectively a no-op.
2019-05-06 10:57:45 +02:00
Benno Schulenberg
f0bc94fd02 tweaks: move the tyding-up-after-a-search to a single exit point 2019-05-06 10:29:45 +02:00
Benno Schulenberg
8720cfcce9 tweaks: rename two more functions, to be simpler too 2019-05-04 11:21:45 +02:00
Benno Schulenberg
954c4d03ac tweaks: rename two functions, to be simpler 2019-05-04 11:21:45 +02:00
Benno Schulenberg
edf6995be4 zapping: use the 'keep_cutbuffer' logic to keep undo items apart
The 'keep_cutbuffer' variable becomes FALSE whenever there is cursor
movement or there was a marked region.  Use this variable to simplify
the condition for creating a new ZAP undo item.  But then typing the
'zap' shortcut should not cause the variable to be set to FALSE.

This fixes the first part of https://savannah.gnu.org/bugs/?56261.

Bug existed since zapping was introduced, in version 3.2.
2019-05-04 11:18:51 +02:00
Benno Schulenberg
b50d5758ef zapping: disjoin a zap command from earlier ones when the mark is set
This fixes the third part of https://savannah.gnu.org/bugs/?56261.

Bug existed since zapping was introduced, in version 3.2.
2019-05-03 12:58:17 +02:00
Benno Schulenberg
6c4d0d87f0 tweaks: remove a condition that has become superfluous
After the previous change, a copy command will break a chain of cut
commands, so there is no need any more to verify that the line number
hasn't changed.
2019-05-03 12:41:49 +02:00
Benno Schulenberg
a962bceca6 copying: let a copy command break a chain of cut or zap commands
This fixes the second part of https://savannah.gnu.org/bugs/?56261.

Bug existed since zapping was introduced, in version 3.2.
2019-05-03 12:33:42 +02:00
Benno Schulenberg
e0c5c589ad tweaks: remove a superfluous condition, in three places
When 'last_action' has a specific value, then necessarily there must
exist a corresponding current undo item.

(The condition is already absent in do_deletion(), for the BACK and DEL
undo items, and it works fine there.)
2019-05-03 12:18:04 +02:00
Benno Schulenberg
dfe87540c6 syntax: po: colorize also escaped hex and octal codes 2019-05-03 12:12:44 +02:00
Benno Schulenberg
6c4f228f6f tweaks: invert two conditions, in order to elide an extra variable 2019-05-02 14:34:05 +02:00
Benno Schulenberg
fe06ae5f48 tweaks: normalize the indentation after the previous two changes 2019-05-02 14:27:35 +02:00
Benno Schulenberg
07289f437f tweaks: invert a condition, in order to return earlier 2019-05-02 14:12:23 +02:00
Benno Schulenberg
99d155d80f tweaks: reshuffle an assignment, to be able to return earlier 2019-05-02 14:10:23 +02:00
Benno Schulenberg
3346c5395e tweaks: place a function better, and reduce some comments to a single one 2019-05-02 10:17:10 +02:00
Benno Schulenberg
083218aca5 tweaks: rename two parameters, to differentiate them from function names 2019-05-02 10:17:04 +02:00
Benno Schulenberg
fd3b3bc1d6 cutting: clear the cutbuffer when the previous operation was copying
The cut and copy operations (^K and M-6) are different operations and
one should not add to the cutbuffer created by the other.

This fixes https://savannah.gnu.org/bugs/?56251.

Bug existed since version 3.0, commit 71f85937.
2019-05-02 09:27:37 +02:00
Benno Schulenberg
9bc6bc83c0 tweaks: rename two variables, for more contrast 2019-05-01 19:14:06 +02:00
Benno Schulenberg
d4468b2def tweaks: condense a comment and reshuffle a couple of lines 2019-05-01 19:10:56 +02:00
Benno Schulenberg
404a6862cd tweaks: really don't bother renumbering the lines in the cutbuffer
The lines from the cutbuffer will be renumbered when it matters: when
they get pasted.

The only place that used the numbering of (a copy of) the cutbuffer
(the updating of an undo item) already iterates through its lines.
Just add a counter there instead of making use of the line numbers.
2019-05-01 13:09:22 +02:00
Benno Schulenberg
85fc41470b tweaks: stop passing 'cutbuffer' and 'cutbottom' back and forth
All extractions are done into the cutbuffer, so it is pointless to pass
'cutbuffer' and 'cutbottom' in and back out as parameters all the time.
Just use those global variables directly.

Also, rename the function as there is no longer a buffer among its
parameters.
2019-05-01 11:33:37 +02:00
Benno Schulenberg
2b9dd6c574 tweaks: don't bother saving and restoring 'cutbottom' all the time
The 'cutbottom' variable is only ever used when cutting or copying
consecutive lines: for appending the current line to the already
existing lines in the cutbuffer.  As soon as some other operation
is performed, 'cutbottom' becomes irrelevant, it could be set to
anything, it doesn't matter: the pasting of the cutbuffer does not
use the value of 'cutbottom', nor does any other operation.
2019-05-01 11:19:14 +02:00
Benno Schulenberg
9e44a53be7 copying: scroll just one line when M-6 is pressed on the bottom row
This fixes https://savannah.gnu.org/bugs/?56249.

Bug existed since version 2.6.0, commit 318ed6b1.
2019-04-30 19:31:44 +02:00
Benno Schulenberg
0c561f0325 copying: make M-6 do nothing when at end of buffer 2019-04-30 19:03:18 +02:00
Benno Schulenberg
e5831f81bb tweaks: rename two variables, to be less cryptic 2019-04-30 18:41:05 +02:00
Benno Schulenberg
fa21986ecf oops: apparently the line numbers in the cutbuffer do matter
The line numbers don't matter for the cutbuffer itself, but they matter
for the copy of the cutbuffer that is stored in an undo item.

This reverts commit 14140d52 from two hours ago.

This fixes https://savannah.gnu.org/bugs/?56245.
2019-04-30 12:49:57 +02:00
Benno Schulenberg
772137cabe tweaks: rename a variable, to fit a bit better 2019-04-30 12:24:56 +02:00
Benno Schulenberg
4c53e2f56b tweaks: elide two unneeded variables
After extracting a line or region, the current line is always the one
where renumbering should start.  And when ingrafting a buffer, it is
always the first ingrafted line where renumbering should start.  The
'top_save' variable was indirectly getting set to those lines.

Also, renumber immediately after unpartitioning the file buffer, before
doing anything else.
2019-04-30 12:20:41 +02:00
Benno Schulenberg
14140d5249 tweaks: don't bother renumbering the lines in the cutbuffer
The numbering of the lines in the cutbuffer is irrelevant.  These lines
will be renumbered when it matters: when they get pasted.
2019-04-30 10:55:15 +02:00
Benno Schulenberg
17aa9371b5 tweaks: rename a function, to better indicate what it does 2019-04-30 10:27:10 +02:00
Benno Schulenberg
208995e4a7 tweaks: move a bit of timing code to where it will be needed 2019-04-30 10:15:46 +02:00
Benno Schulenberg
b503670750 tweaks: rename a variable, to match another with the same meaning
Also, remove a redundant condition.
2019-04-30 10:15:11 +02:00
Benno Schulenberg
7c08e8ea69 cutting: ignore the mark when a word is deleted
Just like for deleting a word to the left, the mark should be ignored
also when deleting a word to the right.

This fixes https://savannah.gnu.org/bugs/?56241.
2019-04-30 09:53:10 +02:00
Benno Schulenberg
542426f1f1 tweaks: add a warning for something that shouldn't occur 2019-04-30 09:44:47 +02:00
Benno Schulenberg
6319a86178 tweaks: improve some comments, reshuffle a line, and rename a variable 2019-04-29 11:08:21 +02:00
Benno Schulenberg
9888e67b20 tweaks: rename two variables, for more contrast with the partition stuff 2019-04-29 09:45:41 +02:00
Benno Schulenberg
8fe19e344f tweaks: use a more direct call when a single linestruct is deleted 2019-04-28 17:20:08 +02:00
Benno Schulenberg
896cfcef95 tweaks: when OR'ing, put the most likely condition first
Also, slightly reword a comment, adjust some whitespace, and use
a more direct comparison for equality.
2019-04-28 15:53:33 +02:00
Benno Schulenberg
d54180ad8b tweaks: reduce a bit of mark-adjusting code to its essence
It doesn't matter whether the grafted text contains a newline or not.

It only matters whether the mark was before or after the cursor.  When
it was after the cursor, the mark needs to be set to the bottom line of
the grafted text and its x coordinate needs adjustment; and when it was
before the cursor, the mark just needs to be set to the top line of the
grafted text.
2019-04-28 12:18:24 +02:00
Benno Schulenberg
065afe6e0f tweaks: reshuffle a bit of code, to be less intertwined 2019-04-28 11:54:23 +02:00
Benno Schulenberg
37eccd3117 tweaks: rename a function, to be more fitting
Also, adjust some whitespace, for esthetics.
2019-04-28 11:01:51 +02:00
Benno Schulenberg
b9dd572a67 tweaks: set a boolean directly, instead of using a function call 2019-04-28 10:40:37 +02:00
Benno Schulenberg
3fe17e0355 docs: adjust the wording of the README to be factually correct
That is: don't say that nano doesn't change the file contents by default.

Also, correct the style of the preceding paragraph.
2019-04-28 10:35:27 +02:00
Benno Schulenberg
6e3a3964ce tweaks: adjust the indentation after the previous change
Also, condense a couple of comments.
2019-04-27 17:17:06 +02:00
Benno Schulenberg
18eb7e6d21 tweaks: elide an unneeded 'if' and 'break' 2019-04-27 17:10:10 +02:00
Benno Schulenberg
e84a790b5d tweaks: rename a variable, to better indicate it contains two characters
Also rename a function, to differentiate it more from do_find_bracket().
2019-04-27 17:01:34 +02:00
Benno Schulenberg
20d9070aa1 tweaks: move an assignment that is useful only when searching forward 2019-04-27 16:31:57 +02:00
Benno Schulenberg
482b2814b4 tweaks: step away one character from the current bracket, not one byte 2019-04-27 14:41:53 +02:00
Benno Schulenberg
e92c3110a1 po: update translations and regenerate POT file and PO files 2019-04-24 11:08:23 +02:00
Benno Schulenberg
1ca9241eaa bump version numbers and add a news item for the 4.2 release 2019-04-24 10:55:23 +02:00
Benno Schulenberg
0b6889cbd8 tweaks: rename another function, to be distinct and fitting 2019-04-24 10:52:49 +02:00
Benno Schulenberg
00410d83fc tweaks: rename a function, to be distinct and fitting
It was hard to remember that the "pt" stood for "plus tabs", and the
"len" seemed to say it was about number of bytes instead of columns.
2019-04-24 10:52:35 +02:00
Benno Schulenberg
fcad442d80 tweaks: declare a function as const and let its allocated string leak
Avoiding this leak is more trouble than it's worth: invocation_error()
will be called seldomly, and when it is called, the user will probably
quickly exit from nano to fix things.

Also declare the speller functions as const again, so they don't give
the impression that their result can be freed.

Suggested-by: Brand Huntsman <alpha@qzx.com>
2019-04-23 12:07:56 +02:00
Benno Schulenberg
34d22d3f00 wrapping: improve the persistence of the prepending behavior
Now you can have a look elsewhere in the buffer (and even delete
or paste stuff there) and when you return to the original line
and continue typing, any spillover from automatic hard-wrapping
will spill over onto the same line it spilled over to before.

You can even switch to a different buffer and return and continue
typing, and stuff will still spill over to the same line.

In the bargain, this gets rid of a bit of flag-resetting code
that was run for many keystrokes, in most cases needlessly.

This addresses https://savannah.gnu.org/bugs/?56189.
2019-04-23 10:20:12 +02:00
Benno Schulenberg
1326af7eae tweaks: drop an unneeded saving and restoring of a variable
Since commit aa1ae0a1, from three years ago, do_next_word() no longer
changes 'placewewant'.
2019-04-23 10:18:46 +02:00
Benno Schulenberg
11aa191bdc tweaks: rename a variable, to distinguish it from a browser function 2019-04-22 19:58:43 +02:00
Benno Schulenberg
ea844d28fe tweaks: exclude a bit more code from a single-buffer build 2019-04-22 19:38:19 +02:00
Benno Schulenberg
7668bfe6f2 tweaks: remove a redundant, enclosed #ifdef 2019-04-22 19:18:29 +02:00
Benno Schulenberg
493f215513 speller: do not crash by trying to free something that cannot be freed
Most of the returned error messages are fixed strings, not allocated
strings.

This fixes https://savannah.gnu.org/bugs/?56188.
Reported-by: Aliaksei Sakovets <alexeysakovets@gmail.com>

Bug existed since version 4.1, commit f645009a.
2019-04-22 11:32:03 +02:00
Benno Schulenberg
723451a5ce tweaks: adjust a few comments and some indentation 2019-04-21 11:58:08 +02:00
Benno Schulenberg
326e41d799 tweaks: elide an unneeded intermediate variable 2019-04-21 11:41:54 +02:00
Benno Schulenberg
3ce74eb8fe wrapping: compute the width of a succeeding line in the correct manner
Its number of columns needs to be computed, not its number of bytes.
2019-04-21 11:39:06 +02:00
Benno Schulenberg
ec4883b6a9 tweaks: remove an unneeded condition
The 'prepend_wrap' flag gets set to TRUE only when there is a next line,
and it can remain TRUE only when the cursor stays on the current line.
2019-04-21 11:26:00 +02:00
Benno Schulenberg
e8f69e40d1 wrapping: add a missing space only when the remainder will be prepended
When automatic hard-wrapping causes some piece of a line to be pushed
to the next line, then a separating space needs to be added at the tail
of this piece only when this piece actually gets prepended.

This fixes https://savannah.gnu.org/bugs/?56185.

Bug existed since version 2.9.2, commit 29f7654a.
2019-04-21 10:35:11 +02:00
Benno Schulenberg
297fb013cb wrapping: trim any trailing blanks when cursor goes to next line
When typing a space causes both the succeeding word and the cursor to
be pushed to the next line, then this space (and any contiguous ones)
does need to be snipped (when --trimblanks is in effect).

This fixes https://savannah.gnu.org/bugs/?56180.

Bug existed since version 2.9.3, commit 91073be4.
2019-04-21 09:31:18 +02:00
Benno Schulenberg
4e52c75568 options: make --breaklonglines work also when --ignorercfiles is used
This fixes https://savannah.gnu.org/bugs/?56179.

Bug existed since version 4.1, commit 167a8e5c.
2019-04-20 14:04:07 +02:00
Benno Schulenberg
192a303e40 tweaks: condense and improve a handful of comments 2019-04-20 14:00:07 +02:00
Benno Schulenberg
dcec8a4112 tweaks: rename a variable, for a little more meaning 2019-04-19 10:10:14 +02:00
Benno Schulenberg
5316f5078f tweaks: elide an unneeded variable
After a line break, the preceding line is readily available through
the 'prev' element.
2019-04-19 10:06:57 +02:00
Benno Schulenberg
286c877853 tweaks: elide an unneeded parameter, as the function already assumes it
The do_wrap() function always gets 'openfile->current' as parameter,
and, internally, it assumes that it is handling the current line.
2019-04-19 09:47:21 +02:00
Benno Schulenberg
8613285321 build: be more specific and avoid committing accidentally changed files 2019-04-16 10:23:16 +02:00
Benno Schulenberg
8a4639cdd6 docs: put the 'set guidestripe' option into its alphabetical position 2019-04-16 10:05:35 +02:00
Benno Schulenberg
576c20c4e4 po: update translations and regenerate POT file and PO files 2019-04-15 09:57:12 +02:00
Benno Schulenberg
3a0a6b5db8 bump version numbers and add a news item for the 4.1 release 2019-04-15 09:33:07 +02:00
Benno Schulenberg
c039aaad9d tweaks: remove several unneeded bad-state checks and their messages
No one ever reported seeing any of them, and each of these checks
has been there for at least a year.
2019-04-14 19:38:04 +02:00
Benno Schulenberg
145bb6e01a build: don't do fuzzy matching when merging PO files against the POT file
Fuzzy strings don't contribute anything to the translations that the
users get to see.  They are useful only for translators, but translators
fetch or receive their PO files from the TP.  For nano, fuzzy strings
just bloat the distribution tarball.
2019-04-14 10:47:41 +02:00
Benno Schulenberg
9cc70d2069 tweaks: shorten a comment to its essence 2019-04-14 10:10:03 +02:00
Benno Schulenberg
3604ad2950 build: remove obsolete translations from the PO files after merging
These obsolete strings contribute nothing to the translations that the
users get to see.  They are somewhat useful only for translators.  But
as nano is registered at the Translation Project, translators fetch or
receive their PO file from there (or they keep their own archive), so
these obsolete strings are not getting lost.  But for nano, they just
burden the distribution tarball.
2019-04-14 09:55:23 +02:00
Benno Schulenberg
1fe3e2ed69 docs: mention that -b is the opposite of -w also in the latter's item 2019-04-14 08:49:25 +02:00
Benno Schulenberg
baca8bb19e indenting, commenting: ensure a partial line stays displayed properly
Do the same as in the previous commit: re-evaluate the start of the
viewport when lines that are located above this viewport may have
changed.  This is relevant when softwrap is on.
2019-04-13 11:51:14 +02:00
Benno Schulenberg
1c707d4f99 unindent: ensure that a partial line gets displayed properly afterwards
When only the trailing chunk of a line is displayed on the top row of
the screen, and the unindenting of this line leads to a reduction in
the number of chunks, then the starting point of the viewport needs
to be re-evaluated.  For simplicity, do this always when something is
unindented.

This fixes https://savannah.gnu.org/bugs/?56102.
Reported-by: Devin Hussey <husseydevin@gmail.com>

Bug existed since around version 2.9.2.
2019-04-13 11:36:53 +02:00
Benno Schulenberg
c0e3779453 display: report and catch a bad state, to prevent a possible hang 2019-04-12 19:18:21 +02:00
Benno Schulenberg
bf6bcde078 tweaks: initialize a boolean before it is referenced [valgrind]
Found because of a report by Devin Hussey <husseydevin@gmail.com>.
2019-04-12 13:37:54 +02:00
Benno Schulenberg
167a8e5c09 options: make --nowrap override again a contrary nanorc setting
All other options are off by default and can only be switched *on*
(either by a command-line option or a nanorc setting) -- there are
no command-line options to switch them off again.  Except for the
--breaklonglines/--nowrap pair.  So these need special handling.

This fixes https://savannah.gnu.org/bugs/?56119.
Reported-by: Sébastien Desreux <seb@h-k.fr>

Bug existed since version 4.0, commit 4d40bea5.
2019-04-12 10:35:20 +02:00
Benno Schulenberg
90cbdbbe75 docs: mention that M-S now toggles softwrap and M-N line numbers 2019-04-11 17:46:19 +02:00
Benno Schulenberg
d83a8eb359 justify: correctly compute the number of lines to take, to avoid a crash
When the file starts with one or more blank lines, the first paragraph
doesn't start on line 1.

This fixes https://savannah.gnu.org/bugs/?56117.

Bug existed since version 4.0, commit ac8bd2a2.
2019-04-11 16:11:49 +02:00
Benno Schulenberg
98cc39e8e5 tweaks: reshuffle some lines, to elide an 'if' 2019-04-11 15:12:04 +02:00
Benno Schulenberg
b20fadd604 tweaks: free the copy of a linter message in all cases [valgrind] 2019-04-11 14:17:32 +02:00
Benno Schulenberg
cdf0f8e68a tweaks: drop two 'const' qualifiers, to silence the compiler 2019-04-11 12:31:50 +02:00
Benno Schulenberg
f645009a5e tweaks: free the result string from an invocation error [coverity] 2019-04-11 10:05:39 +02:00
Benno Schulenberg
2b2736d41a tweaks: free some memory before a possible error exit [coverity] 2019-04-11 09:55:18 +02:00
Benno Schulenberg
5a6029a938 tweaks: rename some variables, for more contrast and to match others 2019-04-11 09:38:06 +02:00
Benno Schulenberg
8d272db4e6 tweaks: rename two variables, for more contrast 2019-04-11 09:14:30 +02:00
Benno Schulenberg
70885d0f9a tweaks: use a signed type for a result that could be negative [coverity] 2019-04-11 09:11:53 +02:00
Benno Schulenberg
f1e5da6cdd help: don't doubly list toggles that have two keys assigned to them 2019-04-09 19:48:41 +02:00
Benno Schulenberg
d79b9823ae bindings: add easier keystrokes for the linenumber and softwrap toggles
For most people, M-N and M-S are simpler to type than M-# and M-$,
and more mnemonic.
2019-04-09 17:48:26 +02:00
Benno Schulenberg
82f1ce8ebf bindings: remove the jumpy-scrolling toggle entirely
It is still possible to use --jumpyscrolling on the command line or
'set jumpyscrolling' in a nanorc file, but a user will have to restart
nano when they decide they want chunky instead of smooth scrolling,
a decision that should be rather rare.

This frees up the M-S keystroke to be reused for toggling softwrap.
2019-04-09 17:46:21 +02:00
Benno Schulenberg
50ee655f9d gnulib: update to its current upstream state 2019-04-09 14:44:51 +02:00
Benno Schulenberg
5459f56f6d build: add gnulib modules to the list of files with translatable strings
The error messages from gnulib need to be included into nano's POT file
so that those messages get translated when nano is built on a platform
where the modules that contain the messages get used.

This fixes https://savannah.gnu.org/bugs/?56107.

Bug existed since gnulib support was added in version 2.8.0.
The relevant modules were added by commits 3deec435 and 272345cc.
2019-04-09 13:49:36 +02:00
Benno Schulenberg
209531a761 docs: remove all mention of --finalnewline, and undefault --nonewlines 2019-04-07 10:02:22 +02:00
Benno Schulenberg
2552307064 options: remove -f (--finalnewline); go back to auto-adding this newline
For relatively inexperienced users (as most users of nano probably are)
it is far better that nano produces POSIX text files by default, where
each line ends with a newline character.  This means that these files
will "print" properly (not gluing the next prompt at the end of the
last line), tools will see and process each line of them, and, while
editing, adding text at the end is easier.

This addresses https://savannah.gnu.org/bugs/?55997.
Reported-by: Ralph Corderoy <ralph@inputplus.co.uk>
2019-04-07 10:02:05 +02:00
Benno Schulenberg
5601b9a66b tweaks: switch back from checking FINAL_NEWLINE to checking NO_NEWLINES
This effectively reverts commit b6a76223 from a good two months ago.
2019-04-07 08:50:35 +02:00
Benno Schulenberg
81dcb13783 tweaks: remove an unpaired closing parenthesis from the NEWS file 2019-04-06 21:21:38 +02:00
Benno Schulenberg
580fd13424 tweaks: do a check up front instead of every time round the loop
Instead of doing a check every time round the loop when it is useful
only the first time, duplicate a bit a code and do the check and its
related action beforehand.

Also, improve some comments.
2019-04-06 21:07:20 +02:00
Benno Schulenberg
790ce3791a tweaks: reshuffle some lines, condense a comment and drop another
Also, find_bracket_match() is only called when there is a bracket under
the cursor, so stepping forward will never go beyond the end-of-line,
so the central loop does not need to check for that.
2019-04-06 20:37:22 +02:00
Benno Schulenberg
97cd62a8fb tweaks: rename two variables, to make more sense 2019-04-06 20:29:04 +02:00
Benno Schulenberg
2f68bbb5e8 tweaks: reword a comment, and drop an unneeded assert 2019-04-06 20:08:39 +02:00
Benno Schulenberg
55952c0984 tweaks: adjust the indentation after the previous change
Also, improve a comment and shorten another, change a 'for' to a 'while'
(as the end point is not known), and rename a parameter from a single
letter to a word.
2019-04-06 19:45:45 +02:00
Benno Schulenberg
d9cfdd364b tweaks: don't bother special-casing non-UTF8 when seeking a character
This code is seldom used (only when searching for a matching bracket),
so speed is not a priority.
2019-04-06 19:34:09 +02:00
Liu Hao
c9605e7308 syntax: c: change the highlighting of preprocessor directives
Some of these directives are now colored in their entirety, while for
a few others it's still just the keyword itself that is colored.

Signed-off-by: Liu Hao <lh_mouse@126.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2019-04-06 17:51:07 +02:00
Benno Schulenberg
c3f97bc9b7 rcfile: read the syntax files in alphabetical order when globbing
The reading order must be predictable, otherwise things might get
colored differently from system to system.

This fixes https://savannah.gnu.org/bugs/?56012.
2019-04-06 17:50:55 +02:00
Benno Schulenberg
4399b734db bindings: disallow executing an external command when in view mode
Otherwise the user could do something like

  ^R^X  sed -i 's/a/surprise!/g' name-of-current-file  <Enter>

and the file being viewed would be modified anyway.
2019-04-06 17:41:44 +02:00
Benno Schulenberg
b9581bd50a tweaks: rename two variables, to match others
Also, initialize them straightaway.
2019-04-06 11:54:32 +02:00
Benno Schulenberg
408f15954e feedback: replace an assert with a check plus error message at startup 2019-04-06 10:03:52 +02:00
Benno Schulenberg
f585403b36 build: add src/cut.c to the list of files with translatable strings
(Also, adjust the style of one of the messages.)

This fixes https://savannah.gnu.org/bugs/?56083.

Bug existed since version 4.0, commit 50e8f8aa.
2019-04-06 09:40:53 +02:00
Benno Schulenberg
601973ddc2 tweaks: rename another variable, to be more descriptive 2019-04-05 11:01:07 +02:00
Benno Schulenberg
25a5fb8231 tweaks: rename a variable, to get out of the way for another rename 2019-04-05 10:50:15 +02:00
Benno Schulenberg
897e557ce3 tweaks: rename a variable, to be more distinct and more descriptive 2019-04-05 10:45:22 +02:00
Benno Schulenberg
81bee1f5fd tweaks: shorten and improve some comments, and reshuffle a few lines 2019-04-05 10:35:48 +02:00
Benno Schulenberg
691eb1145c tweaks: remove a function that is now unused 2019-04-04 14:53:53 +02:00
Benno Schulenberg
fb04dff6d7 tweaks: don't bother reallocating the data when a line gets hard-wrapped
This will waste some memory, but... if the user keeps editing, she is
likely to revisit the line and the data will get reallocated soon enough.
2019-04-04 14:44:44 +02:00
Benno Schulenberg
c224ea3ce7 tweaks: reshuffle two lines, and reword a comment 2019-04-04 14:23:07 +02:00
Benno Schulenberg
2a2fe7208a tweaks: condense a bit of copying code 2019-04-04 14:11:52 +02:00
Benno Schulenberg
3f9d8011b9 tweaks: don't bother copying the NUL byte -- it is set nine lines down 2019-04-04 13:59:00 +02:00
Benno Schulenberg
4788c5f97d tweaks: don't bother reallocating the squeezed string, just terminate it
The string will be rewrapped right after, within microseconds.
2019-04-04 13:56:41 +02:00
Benno Schulenberg
a5869ba450 tweaks: rename another variable, to be more fitting 2019-04-04 13:52:27 +02:00
Benno Schulenberg
7bc324f276 tweaks: rename two variables, to be more distinct and more fitting 2019-04-04 13:48:34 +02:00
Benno Schulenberg
8d40b568fa tweaks: rename a variable, to be more distinct and more apt 2019-04-04 13:39:11 +02:00
Benno Schulenberg
0c0afb0039 tweaks: simplify a message, and normalize the spelling of another one
The word "buffer" in relation to undo has been confusing to translators.

Also, drop the exclamation mark, as there is nothing important or urgent
about these messages.
2019-04-04 12:55:58 +02:00
Benno Schulenberg
2281ec9a31 tweaks: remove an unneeded check for NULL [coverity] 2019-04-04 12:47:20 +02:00
Benno Schulenberg
cd0917fe10 tweaks: remove an unneeded check for NULL and its associated message
The message (or its equivalent) has been there for years
and no one ever reported seeing it.
2019-04-04 12:40:03 +02:00
Benno Schulenberg
1a1519b6cd tweaks: drop an assignment whose value is never used [scan-build]
This useless assignment has been there for ages, since before 2.0.0.
2019-04-03 19:10:21 +02:00
Benno Schulenberg
947ccbb597 rcfile: don't break a chain of 'else if' [scan-build]
The mistake was made when 'guidestripe' was added, in commit 66c6eb51.
2019-04-03 19:06:04 +02:00
Benno Schulenberg
671db5e1e3 tweaks: rename an overshort type to something that makes some sense 2019-04-03 17:34:05 +02:00
Benno Schulenberg
acfee2538e tweaks: rename a cryptic type to something that makes a little sense 2019-04-03 17:11:24 +02:00
Brand Huntsman
32431cddf8 files: block the resizing signal while reading from an external command
A SIGWINCH somehow causes the input stream to see EOT, with the result
that any remaining output of an external program would be lost.

This fixes https://savannah.gnu.org/bugs/?56038,
and fixes https://savannah.gnu.org/bugs/?56033.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-04-03 15:14:33 +02:00
Benno Schulenberg
8e302738e8 bindings: recognize the ^W^Y and ^W^V legacy keystrokes again
The keystrokes are recognized and acted upon, but they are not visible
in the menu nor in the help text, and they cannot be rebound.  They are
there just to avoid frustrating the muscle memory of long-time users.

This fixes https://savannah.gnu.org/bugs/?56002.
Reported-by: Peter Zwegat <peterzwegat@yopmail.com>
2019-04-03 15:13:47 +02:00
Benno Schulenberg
aa2568858e tweaks: remove a superfluous check for NULL plus the associated message
The message has been there for a year and no one ever reported seeing it.
2019-04-03 15:11:18 +02:00
Benno Schulenberg
5375403b9d syntax: nanorc: colorize also strings preceded by 'start=' or 'end=' 2019-04-02 12:01:56 +02:00
Benno Schulenberg
b0c9809a2e speller: block the resizing signal also during an integrated spell check
Because somehow something goes wrong when SIGWINCHes are handled while
reading from a pipe.

This fixes https://savannah.gnu.org/bugs/?56011.

Bug existed since version 2.4.2, commit 75d64e67.
2019-04-01 20:21:23 +02:00
Benno Schulenberg
19c82e6a43 feedback: spare the user a superfluous scaring when trying to exit
Also, a simple question is easier to answer than an annotated one.
2019-04-01 19:56:10 +02:00
Benno Schulenberg
84d21b0972 tweaks: consistently use .sp instead of .PP to insert a blank line
And use plain .P to start a new paragraph.
2019-04-01 17:31:35 +02:00
Benno Schulenberg
f8e0320722 syntax: nanorc: require whitespace both before and after a quoted string
This ensures that the keyname M-" is not miscolored.
2019-04-01 17:24:19 +02:00
Benno Schulenberg
e5a8c35104 feedback: show a message while executing an external command
Some commands can take a little while to execute; showing just the prompt
during that time could give the impression that nothing is happening.

This addresses https://savannah.gnu.org/bugs/?56041.
2019-03-31 18:04:52 +02:00
Devin Hussey
7ad232d714 files: initialize a variable before referencing it
The lack of initialization caused a nasty bug on some targets (such as
ARMv7) which would make it so that ^S would just say "Cancelled".

While x86 (both 64 and 32 bits) seems to initialize 'response' to zero or
a positive number, ARM does not, and there is usually a negative value in
its place, which triggers the 'if (response < 0)' check and, as a result,
the code says "Cancelled".

This fixes https://savannah.gnu.org/bugs/?56023.
Reported-by: Devin Hussey <husseydevin@gmail.com>

Bug existed since version 4.0, commit 0f9d60a3.

Signed-off-by: Devin Hussey <husseydevin@gmail.com>
2019-03-31 12:57:27 +02:00
Benno Schulenberg
85804ec70d syntax: man: require the dot to be at start of line, not the comment 2019-03-31 12:42:53 +02:00
Benno Schulenberg
e473ba5e6c syntax: man: anchor macros at start of line, as only then they are valid 2019-03-30 20:54:31 +01:00
Benno Schulenberg
9120a62cdd syntax: man: add comments, and color all the safe lowercase macros 2019-03-30 20:47:45 +01:00
Benno Schulenberg
53ecb3225f syntax: default: color in red also versions 4.x of nano 2019-03-30 19:54:58 +01:00
Benno Schulenberg
3f695b8fb7 speller: resizing can happen also when configured with --enable-tiny
When nano was configured with --enable-tiny --enable-speller, the
block_sigwinch() function should be available, to mask SIGWINCHes
during a spell check.
2019-03-30 19:23:15 +01:00
Benno Schulenberg
55699dc171 tweaks: rename some variables, to be less repititious
The repeated 'read_buff_' made everything look the same.
2019-03-30 19:10:44 +01:00
Benno Schulenberg
fa48d523b2 tweaks: stop doing tandem assignments (one passing through the other) 2019-03-30 18:52:45 +01:00
Benno Schulenberg
92cbc7c426 syntax: c: color as a type any lowercase word that ends with "_t" 2019-03-30 17:48:34 +01:00
Benno Schulenberg
6f07f2b444 tweaks: rename a function plus parameter, to stay closer to what it does 2019-03-27 19:46:37 +01:00
Benno Schulenberg
f58869d072 tweaks: put the unblocking of SIGWINCHes in a better place
The blocking is needed only during the wait(), so unblock SIGWINCH
again right after the wait() -- also to have the unblocking before
a possible error exit.
2019-03-27 19:10:24 +01:00
Benno Schulenberg
978c121de1 speller: block the resizing signal again during an external spell check
Somehow a SIGWINCH pushes nano past the wait() in do_alt_speller(),
even though the external spelling program hasn't finished.

This fixes https://savannah.gnu.org/bugs/?56010
by reverting commit 1f39f60b.

Bug existed since version 3.2.
2019-03-27 17:43:43 +01:00
Benno Schulenberg
f6a7983a8a docs: for two of the toggles, mention the new instead of the old option 2019-03-26 17:08:31 +01:00
Benno Schulenberg
a1375474d9 docs: remove the AUTHOR section, per advice from 'man man-pages'
Also because most of nano has meanwhile been written by other people
than Chris.  And because authorship is meta-information, irrelevant
for knowing how to operate nano.
2019-03-25 15:55:34 +01:00
Benno Schulenberg
d0cc75f197 docs: put paths and filenames in italics, per 'man man-pages'
Plus a few other text and formatting tweaks.
2019-03-25 15:31:47 +01:00
Benno Schulenberg
0fccfc0373 docs: re-title the temporary section about the changed defaults
To avoid having both a NOTE and a NOTES section.
2019-03-25 15:22:30 +01:00
Benno Schulenberg
d0a7e6e6a6 docs: give the FILES section in the man page its canonical title
Suggested-by: Michael Siegel <msi@malbolge.net>
2019-03-25 14:59:28 +01:00
98 changed files with 42156 additions and 45099 deletions

View File

@@ -14,7 +14,9 @@ David Lawrence Ramsey <pooka109@gmail.com>
* Former stable series maintainer. Multiple buffer support,
operating dir (-o) option, bug fixes for display routines,
wrapping code, spelling fixes, constantshow mode, parts of
UTF-8 support, softwrap overhaul, and various other fixes.
UTF-8 support, softwrap overhaul, undoable (un)indentations,
undoable justifications, justifiable regions, and numerous
other fixes.
Jordi Mallach <jordi@gnu.org>
* Debian package maintainer, fellow bug squasher.
@@ -67,3 +69,6 @@ Rishabh Dave <rishabhddave@gmail.com>
Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
* Filtering text through an external command.
Brand Huntsman <alpha@qzx.com>
* The delayed parsing of syntax files.

872
ChangeLog
View File

@@ -1,3 +1,875 @@
Changes between v4.7 and v4.8:
------------------------------
Benno Schulenberg (166):
bindings: allow to bind shifted Meta+letter combinations with Sh-M-X
bindings: allow to rebind also ^`, although it is synonymous with ^Space
bindings: do not show the Full-Justify keystroke when in View mode
bindings: force the first letter in a key name to uppercase
build: exclude bracketed pasting from the tiny version
build: exclude option '-g' when configured without browser and help
build: exclude the escape sequences for F13...F16 from the tiny version
build: fix compilation for --enable-{tiny,help,multibuffer}
build: restrict the use of --with-slang to together with --enable-tiny
bump version numbers and add a news item for the 4.8 release
copyright: update the years for significantly changed files
copyright: update the years for the FSF
display: adjust line and column count upon a resize also when using Slang
display: clear the help lines before a briefly shown warning
display: don't let a message write over the second help line
display: ensure the guiding stripe can be shown when not softwrapping
display: exclude a bit of feedback from the tiny version
display: show the cursor during suspension also when built with Slang
display: skip zero-width characters on a Linux console, to avoid a mess
docs: add a FAQ item about a self-compiled nano not reading /etc/nanorc
docs: document the new -f/--rcfile option
docs: document the new Sh-M-X format for binding <Shift+Meta+letter>
docs: for the alternative bindings, rebind ^C only in the main menu
docs: improve the description of which rc-files are read during startup
docs: mention in the FAQ that auto-indentation is suppressed when pasting
docs: mention that -D/--boldtext gets overridden by some nanorc options
docs: put the three new behaviors in a bulletted list, to catch the eye
docs: stop saying that 'set fill' enables hard-wrapping -- it does not
docs: use more generally available arrows in the cheatsheet
feedback: ask a clearer question when a valid lock file is encountered
feedback: report Ctrl+Alt keystrokes as unbindable
feedback: restore a message that can occur in help viewer or file browser
files: alert the user afterward when an overwritten file is being edited
files: revert the previous commit, as the extra warning is annoying
files: warn doubly when the user is about to overwrite an existing file
files: write a lock file also for a new file and when the name changed
gnulib: update to its current upstream state
help: don't waste the last column in the help viewer on narrow terminals
help: increase the minimum help-text width from 24 to 32 columns
help: prevent double spaces from protruding across the right edge
help: when a key description wraps, indent its wrapped part
input: consume and ignore the raw escape sequences for F17 to F24
input: correct the escape sequence for PageUp/PageDown on Eterm/Urxvt
input: Ctrl+arrow is "Esc O x" on Eterm, as on rxvt -- not "Esc o x"
input: discard partial sequences that Slang produces for F17 to F24
input: do not auto-indent when something is pasted into nano from outside
input: don't discard the first keystroke after a resize when using Slang
input: filter out Ctrl+Meta keystrokes, as they can never be shortcuts
input: ignore bracketed pastes in help viewer and file browser
input: ignore modifiers on a VT while executing a macro or a string bind
input: prevent unintentional marking of text for shifted Meta keystrokes
input: read in an external paste in one go, to allow undoing with one M-U
input: recognize the raw escape sequences for F13 to F16 on xterm too
locking: accept a minimal amount of data, enough for PID plus username
locking: avoid crashing when there is a problem writing the lock file
locking: check two magic bytes, to verify that it is a lock file
locking: do not write a lock file when in view mode
locking: when a lock file is unreadable, open the file itself anyway
locking: when finding a lock file at startup, quit when user cancels
new feature: allow specifying a custom nanorc file on the command line
pasting: retain the mark's position when it was set at the cursor
prompt: for a Yes-No-All, accept the first character of an external paste
rcfile: do set the meta flag for plain <Meta+ASCII> combinations
rcfile: require "bright", "start=", and "end=" to be in lowercase too
rcfile: unbind keys by their key code instead of by their key string
softwrap: suppress the guiding stripe on unaffected chunks
speller: avoid messing up the screen when an unknown locale is used
suspension: put in an extra terminal-initialization call for Slang
syntax: nanohelp, nanorc: colorize the Sh-M-X format as a valid key name
syntax: nanorc: colorize all-lowercase Meta key binds as valid too
tweaks: add a little change that was overlooked in the previous commit
tweaks: add an error message for something that should never occur
tweaks: adjust or reword a few items in the FAQ
tweaks: adjust the indentation after the previous change
tweaks: allocate the lock data only when ready to write them
tweaks: avoid analyzing the key string when the target key code is known
tweaks: avoid determining the key code from the key string twice
tweaks: avoid fiddling with the keybuffer when it's not needed
tweaks: comment fully, so that all handled escape sequences are findable
tweaks: condense a fragment of code
tweaks: condense five more fragments of repetitious code
tweaks: condense three comments to one, and do the masking more directly
tweaks: condense three fragments of repetitious code
tweaks: condense two comments, and reshuffle an #endif
tweaks: correct a comment
tweaks: correct a couple of comments about escape sequences
tweaks: correct the description of what nano writes into the lock file
tweaks: delete some fragments of code that have become irrelevant
tweaks: do not leak a file descriptor when fdopen() fails
tweaks: don't bother including Haiku escape sequences in the tiny version
tweaks: don't enable bracketed pasting when not handling such pastes
tweaks: drop a message that will never be seen
tweaks: drop an unneeded call of keypad() -- we never read from topwin
tweaks: drop a pointless suffix from two function names
tweaks: elide a function that has become too small for its two calls
tweaks: elide a helper function, in preparation for an improvement
tweaks: elide an 'if', by moving the relevant code to a better place
tweaks: elide a small function, as it's in fact needed just once
tweaks: elide a somewhat costly call by remembering some state
tweaks: elide a variable, and rename its sister
tweaks: elide three checks of a shortcut's meta flag
tweaks: ensure that editor name and user name are NUL terminated
tweaks: exclude an unneeded fragment of code from the tiny version
tweaks: exclude two unneeded fragments of code from the tiny version
tweaks: free two strings as soon as they are no longer needed
tweaks: frob a couple of indentations and white lines
tweaks: fuse two nearly identical functions into a single one
tweaks: gather four calls that are always done together into a function
tweaks: harmonize the amount of lock data that we read and write
tweaks: improve a comment by indirectly referring to the ncurses docs
tweaks: in comments, reword "titlebar" and "statusbar" to two words each
tweaks: initialize three booleans straightaway, when they are declared
tweaks: initialize three more booleans straightaway, at declaration
tweaks: judge from the key code itself whether it is a Meta keystroke
tweaks: make a couple of comments more precise
tweaks: move a function to after the one that it calls
tweaks: move a function to be before the ones that call it
tweaks: move a function to before the one that calls it
tweaks: move a function to related ones, and after one that it calls
tweaks: move a function to right before the one that calls it
tweaks: move another function to after the one that it calls
tweaks: move another function to before the one that calls it
tweaks: move another function, to group the deleting ones together
tweaks: move three functions to the file where they are mainly used
tweaks: rearrange a few global variables, to group things better
tweaks: recompute the wrapping point just once
tweaks: reduce the scope of a variable, and reshuffle a declaration
tweaks: reduce the scope of two constants and of four variables
tweaks: reformat a comment, and resuffle a line to match byte order
tweaks: remove a feedback message that is never shown
tweaks: remove a redundant call, as there is nothing to free there
tweaks: remove a superfluous check
tweaks: remove some superfluous conditions for rewriting a lock file
tweaks: remove the now-unneeded code related to bracketed pasting
tweaks: remove the now-unused meta flag from 'keystruct'
tweaks: remove two superfluous assignments, and rename a variable
tweaks: rename a function and its parameter, to be more fitting
tweaks: rename a function, to be a bit more expressive
tweaks: rename a function, to make it not contain the name of another
tweaks: rename a parameter and invert its logic, and correct a comment
tweaks: rename five variables, away from a single letter
tweaks: rename two functions, to make more sense
tweaks: rename two parameters, to be more general and to sound shorter
tweaks: rename two variables, to make more sense
tweaks: renumber some FAQ items in preparation for adding another
tweaks: reorder two symbols
tweaks: reshuffle some assignments for a return value
tweaks: reshuffle some declarations
tweaks: reshuffle some declarations, and expand a few variable names
tweaks: reshuffle some lines, to avoid tallying the menus when not needed
tweaks: reshuffle some lines, to group all ignored keystrokes together
tweaks: reshuffle three lines, to make the grouping tighther
tweaks: reshuffle two lines, to do the linking first, then the content
tweaks: reword two comments, and rewrap another
tweaks: rewrap a comment and a line, and reshuffle a fragment of code
tweaks: rewrap two lines, for consistency with similar lines
tweaks: rewrite the same file name into the lock file as the first time
tweaks: slightly condense a function by conflating case
tweaks: stop recognizing escape sequences for a key without meaning
tweaks: suggest a few more alternative key bindings and unbindings
tweaks: take just one shot at reading the lock file, and correct a type
tweaks: trim some excessive error checking and key-name frobbing
tweaks: tumble three conditions, for consistency in comparisons
tweaks: unabbreviate "argument" in the documentation
tweaks: use a simple subtraction instead of a function call
usage: improve the description of --restricted and --quickblank
Brand Huntsman (2):
input: beep when invalid key is pressed at yesno prompt or in linter menu
input: recognize the start and stop sequences of a bracketed paste
Changes between v4.6 and v4.7:
------------------------------
Benno Schulenberg (39):
build: add the uploading of PDF and cheatsheet to the release script
build: avoid three compiler warnings when using gcc-9.2 or newer
build: fix compilation for --enable-tiny --enable-wrapping
build: fix compilation on macOS, where 'st_mtim' is unknown
build: fix compilation when configured with --disable-justify
bump version numbers and add a news item for the 4.7 release
display: don't color the space that separates line numbers from text
docs: add or improve the 'description' meta tag in the two HTML pages
docs: add the 'lang' attribute in the right place to the two HTML pages
docs: mention that all keywords in a nanorc file should be in lowercase
docs: mention that a negative number after "+" counts from the end
gnulib: update to its current upstream state
input: make <Tab> indent only when mark and cursor are on different lines
justify: distinguish between tabs and spaces when comparing indentation
justify: treat consecutive indentations that look the same as the same
linter: beep when trying to go beyond first or last message
rcfile: accept also function names and menu names only in lowercase
rcfile: accept only keywords in all lowercase, for speed of comparison
rcfile: demand that function 'exit' is bound in the file browser
syntax: nanohelp: colorize also ^/ as a possible keystroke
syntax: sh: recognize shell rc files also in dedicated directories
tweaks: avoid using strlen() where it is not needed
tweaks: drop M-Space and ^Space from the browser's key list
tweaks: improve two comments and the ordering of some operands
tweaks: move three functions to the file where they are used
tweaks: optimize the trimming of trailing whitespace
tweaks: remove a stray space
tweaks: rename a function, to get out of the way for another rename
tweaks: rename a function, to get rid of a useless suffix
tweaks: reshuffle a few lines, for brevity or speed or consistency
tweaks: reshuffle a few lines, for symmetry with the preceding function
tweaks: reshuffle a fragment of code, for efficiency
tweaks: reshuffle and rename a few things, to elide duplication
tweaks: reshuffle an item, to avoid a lone 'else'
tweaks: reshuffle two declarations, for compactness
tweaks: slightly streamline the search for a possible wrapping point
tweaks: trim or adjust some whitespace in HTML, and add two keywords
tweaks: unwrap a few lines, and move some strings to among their peers
wrapping: never break in the quoting part nor in the indentation part
Changes between v4.5 and v4.6:
------------------------------
Benno Schulenberg (128):
bindings: allow to rebind ^/, even though it is synonymous with ^_
bindings: don't hard-bind ^H in the help viewer or the file browser
bindings: the 'all' keyword should encompass the browser menu too
bindings: the 'all' keyword should include the browser menu always
build: fix compilation for --enable-tiny --enable-histories
build: fix compilation when configured with --disable-color
build: slightly speed up the compilation of the tiny version
bump version numbers and add a news item for the 4.6 release
chars: add a faster version of the character-parsing function
commands: rename 'fixer' to 'formatter', to be less misleading
cutting: do nothing when trying to chop a word leftward at start of file
display: do refresh the edit window when exiting from the help viewer
docs: add a note saying that rebinding ^M or ^I is not advisable
docs: add the M-F and M-N keystrokes to the cheatsheet
docs: adjust the compilation instructions to two-digit version numbers
docs: correct the description of the 'spell' menu
docs: document the 'fixer' command, a per-syntax content arranger
docs: mention that color rules are applied in the order they are listed
docs: mention that 'hunspell' is now the first default spelling program
docs: mention that the 'nopauses' option is obsolete
docs: remove some excessive detail from the sample nanorc file
docs: remove the note about the formatter having been removed
feedback: say it when spell check or manipulation did not change anything
files: distinguish between read error and write error when prepending
files: don't mention the name of the temp file when reading goes wrong
files: when opening a file for copying, it should NOT be created
formatter: accept the formatted result also upon a nonzero exit status
formatter: don't let output from the program pollute the screen
gnulib: update to its current upstream state
history: don't wait when there is something wrong with the history files
linter: report it as an error when running the linting program fails
rcfile: allow binding also F17...F24
rcfile: process extensions to file-matching commands straightaway
restored feature: a per-syntax 'fixer' command that processes the buffer
softwrap: when switching to another buffer, re-align the starting column
speller: prefer 'hunspell' over 'spell', because it can handle UTF-8
speller: when 'spell' is not found, try running 'hunspell -l' instead
statusbar: show only the first error message, with dots to indicate more
syntax: c: recognize some C++ header files by their Emacs modeline
syntax: default: don't colorize stuff between two pairs of brackets
syntax: html: add a formatter command, making use of 'tidy'
syntax: html: colorize only full attributes, and colorize strings later
syntax: javascript: colorize also special values 'null' and 'undefined'
syntax: javascript: colorize the boolean values 'true' and 'false' too
syntax: nanorc: colorize all arguments of 'fixer' and 'linter' as valid
syntax: nanorc: colorize in bright red everything that is invalid
syntax: nanorc: colorize only lowercase keywords as valid
syntax: nanorc: colorize the 'fixer' command as valid
syntax: ruby: colorize also lowercase global/instance variables
syntaxes: put the 'linter' and 'formatter' commands on a separate line
tweaks: add a helper function without the ubiquitous NULL argument
tweaks: add a local variable, for clarity, to not preuse another one
tweaks: add some "fall-through" comments, and reshuffle some breaks
tweaks: add two translator hints
tweaks: adjust the indentation after the previous change
tweaks: adjust the indentation after the previous change
tweaks: adjust the indentation after the previous change, and another
tweaks: adjust two comments, to better fit the actual functions
tweaks: avoid setting and resetting a variable when there is no need
tweaks: avoid three unneeded calls of umask() in the normal case
tweaks: be explicit about which program complained
tweaks: check the return value of copy_file() also after its other uses
tweaks: close the unused reading ends of two more output pipes
tweaks: condense a fragment of code by making use of a helper function
tweaks: condense or improve some comments
tweaks: condense two comments, and rename two parameters
tweaks: condense two comments, and rewrap a line
tweaks: correct a comment, and retype a variable
tweaks: die on an impossible condition -- to be removed later
tweaks: don't do in the parent something that only the child needs
tweaks: don't wrap calls of statusline() that slightly overshoot 80 cols
tweaks: drop the unneeded closing of descriptors when exiting anyway
tweaks: elide a duplicate opening of the existing file when prepending
tweaks: elide a function call for the plain ASCII case
tweaks: elide another two calls of umask(), and rename two variables
tweaks: elide an unneeded and leaky function
tweaks: elide an unneeded check when making a backup
tweaks: elide a variable, and add a condition to elide an assignment
tweaks: elide a variable that is the same as another
tweaks: exclude two fragments of code from the tiny version
tweaks: fuse two regexes into one
tweaks: group the closing of descriptors together, for compactness
tweaks: group the closing of two descriptors, and reword two comments
tweaks: harmonize a message with another
tweaks: improve some comments, and trim some repetitive ones
tweaks: make a function do a check so its calls don't need to
tweaks: mark two strings for translation
tweaks: move a call of umask() closer to where it is relevant
tweaks: move two functions to after the one that they make use of
tweaks: normalize the indentation after the previous change
tweaks: order two functions more sensibly
tweaks: pass an empty string as an answer instead of a NULL pointer
tweaks: pass an empty string for copying instead of a non-existent one
tweaks: pass any special undo/redo messages to the add_undo() function
tweaks: remove a pointless updating of the title bar
tweaks: remove a redundant check for an existing emergency file
tweaks: remove the superfluous closing of a file descriptor
tweaks: remove two pointless re-inclusion guards
tweaks: remove two superfluous conditions when prepending
tweaks: rename a function and add a parameter, so it becomes more general
tweaks: rename a function, and elide a parameter that is always NULL
tweaks: rename a function and elide its first parameter
tweaks: rename a local variable, to not shadow another
tweaks: rename a variable, to be a bit more fitting
tweaks: rename a variable, to be distinct and visible
tweaks: rename three variables, and reshuffle some lines
tweaks: rename three variables, to be consistent with other linestructs
tweaks: rename three variables, to be more descriptive
tweaks: rename three variables, to match others elsewhere
tweaks: rename two parameters, for contrast and to match others
tweaks: rename two parameters plus a variable, to match others
tweaks: rename two variables, and add a third, for more contrast
tweaks: reshuffle a few declarations, and reduce the scope of one
tweaks: reshuffle a fragment of code into two alternatives
tweaks: reshuffle an 'if' to avoid a negation, and improve a comment
tweaks: reshuffle some declarations, and rename a variable
tweaks: reword an undo/redo string that was overlooked during the rename
tweaks: silence a warning when configured with --enable-tiny
tweaks: simplify the opening of files when prepending
tweaks: slightly reword some fragments in the manual's rebinding section
tweaks: use a better variable name for the argument of an option
tweaks: use a literal NULL instead of a variable that is NULL
tweaks: use a simpler positive/negative check for after copy_file()
tweaks: use a string-copy function that checks for out-of-memory
tweaks: use the given string instead of the found match, for clarity
undo: don't try to copy a string that doesn't exist
undo: put the cursor back on the original row for a full-buffer operation
utils: don't accept NULL for the string to be copied
Jeroen Roovers (1):
syntax: gentoo: highlight the BDEPEND variable as well
Changes between v4.4 and v4.5:
------------------------------
Benno Schulenberg (60):
bindings: add a dedicated keycode for <Tab> for when a region is marked
bump version numbers and add a news item for the 4.5 release
color: don't concatenate an absolute path with the working directory
docs: add two examples of the 'tabgives' command to the sample nanorc
docs: describe the new syntax-specific 'tabgives' command
docs: mark the undoing of justifications as done in the TODO list
docs: mention that gcc must be at least version 5.0
gnulib: update to its current upstream state
mouse: make the clickable width of menu items more consistent
new feature: a 'tabgives' command to define what the Tab key produces
search: after search-at-startup, store the column (for vertical movement)
tweaks: add a translator hint, and correct two others
tweaks: add some translator hints, be more precise on permissible length
tweaks: add two hints for translators, to try and help avoid mistakes
tweaks: adjust indentation after previous change, reshuffle declarations
tweaks: avoid a comparison between signed and unsigned [coverity]
tweaks: avoid leaking memory when finding an invalid string [coverity]
tweaks: avoid recomputing a maximum value every time round the loop
tweaks: don't burden all menus with something meant for the WriteOut menu
tweaks: elide a function from a non-UTF8 build
tweaks: elide two multiplications with something that is always 1
tweaks: frob a few comments
tweaks: improve a bunch of comments, and reshuffle some declarations
tweaks: improve a handful of comments, and reduce the needed padding
tweaks: mark as 'const' a parameter that takes fixed strings [coverity]
tweaks: meld two calls of free() into a single one, to elide an 'else'
tweaks: move a fragment of common code into the appropriate function
tweaks: move a function to a better file, to be amongst its kind
tweaks: move a function to before its callers and next to its kind
tweaks: move two functions to after the ones that they call
tweaks: remove some timing code that has served its purpose
tweaks: remove two superfluous macros, as sizeof(char) is always 1
tweaks: rename a function, to be a bit more fitting
tweaks: rename another type, again to better fit the general pattern
tweaks: rename another type, to also better fit the general pattern
tweaks: rename another variable, for a better fit
tweaks: rename a type, to better fit the general pattern
tweaks: rename a variable, normalize a comment, and reshuffle a free()
tweaks: rename a variable, to be more compact
tweaks: rename three variables, for contrast and more sense
tweaks: rename three variables, for more contrast
tweaks: rename three variables, to better indicate what they hold
tweaks: rename two variables, away from single letters
tweaks: rename two variables, to better describe what they contain
tweaks: reshuffle a fragment, to group some toggles together
tweaks: reshuffle a line, to group things better
tweaks: reshuffle some lines, to elide an unneeded assignment
tweaks: reshuffle some lines, to have the same order as elsewhere
tweaks: reshuffle two fragments, to group things better
tweaks: rewrap a line, reshuffle a declaration, and improve some comments
tweaks: simplify a calculation, as done elsewhere
tweaks: simplify the determination of a canonical path
tweaks: sort two keywords strictly alphabetically
tweaks: speed up determining the width of plain ASCII characters
tweaks: speed up the counting of the menu entries to be shown
tweaks: use a more effecient way to skip storing an empty file name
tweaks: use an early return when there is no tilde
tweaks: use 'void' in prototypes of parameterless functions [coverity]
usage: mark the -J/--guidestripe option plus argument as translatable
usage: properly align --help output also when it has accented characters
Brand Huntsman (1):
search: accept a match at start of file when searching from command line
Dirkjan Ochtman (1):
syntax: rust: add the words reserved in 2018, and remove unreserved ones
Changes between v4.3 and v4.4:
------------------------------
Benno Schulenberg (53):
browser: draw a bar of spaces only where needed -- for the selected item
build: exclude the search-at-startup feature from the tiny version
bump version numbers and add a news item for the 4.4 release
copying: do not prevent M-6 from copying emptiness into the cutbuffer
display: blank the status bar on a successful cut or paste
display: clear the remainder of a row only when there actually is some
display: don't clear a row beforehand -- just clear the remainder
display: use a somewhat faster method to clear a row
display: when linenumbering, correctly spotlight text that spans two rows
display: where needed, use slow blanking, but elsewhere do it much faster
docs: change a few URLs over to https, and rewrap a couple of NEWS items
docs: document the search-at-startup feature (+/string or +?string)
docs: make the synopsis of --speller and 'set speller' more accurate
docs: mention the M-N toggle instead of the obsolete M-# one
docs: slightly reword some of the descriptions around syntax highlighting
docs: slightly reword the descriptions of most configure options
docs: stop mentioning the 'unjustify' function, as it no longer exists
gnulib: update to its current upstream state
new document: a condensed overview of nano's shortcut keystrokes
new feature: allow specifying a search string to "jump to" at startup
rcfile: properly handle an empty syntax before an 'include' statement
scrolling: don't overscroll when the edit window has just one row
search: don't wipe the status bar at startup when there was an error
search: wipe the status bar before searching again (M-W / M-Q)
syntax: c: allow an underscore in lowercase type names
syntax: default: colorize bracketed section headers in some config files
syntaxes: change some unneeded 'icolor' commands to 'color' commands
syntaxes: recognize .ctp extension as a PHP file, and .cu as a C/C++ file
syntax: perl: avoid recognizing embedded hash signs as a comment starter
syntax: perl: avoid upsetting older glibcs with crafty range expression
syntax: perl: don't color the character after a variable name
syntax: po: colorize numbers only when they form a self-contained word
text: copy leading quote characters when automatic hard-wrapping occurs
tweaks: add a translator hint, to clarify four short words
tweaks: call the correct lighting function directly when softwrapping
tweaks: condense some comments, and drop two unneeded initializations
tweaks: drop two parameters that are no longer needed
tweaks: improve a comment, and drop a superfluous one
tweaks: improve a handful of comments
tweaks: make a function name unique, to not overlap with others
tweaks: move a call from two different places to a single place
tweaks: move a function to before the first one that calls it
tweaks: move a general function to a better place
tweaks: remove a saving and restoring that has become superfluous
tweaks: rename a function, to suit better, and reshuffle its parameters
tweaks: rename a parameter in three functions, to say what it points to
tweaks: reshuffle an assignment, and trim some excessive blank lines
tweaks: reshuffle an 'if' out of a function, and rename the function
tweaks: reword and condense two comments, and correct another
tweaks: rewrap two lines, and reshuffle some logic to make more sense
tweaks: shorten two messages that translators tend to make too long
tweaks: try the allocation of a multidata cache just once per line
tweaks: when precalculating, allocate all the cache space upfront
Brand Huntsman (3):
rcfile: for an empty syntax, show the line number of the 'syntax' command
rcfile: report the correct command location for an invalid 'include'
search: accept toggles for case and regex when searching at startup
Changes between v4.2 and v4.3:
------------------------------
Benno Schulenberg (235):
bindings: at a Yes-No prompt, accept also ^N and ^Q for "No"
bindings: at a Yes-No prompt, accept also ^Y for "Yes"
bindings: bind the Alt+arrow keystrokes also in non-UTF-8 locales
browser: don't show a mistaken message when exiting from help viewer
build: avoid a warning on FreeBSD, OpenBSD, and Alpine
build: avoid a warning when using --disable-utf8
build: exclude the ability to open a FIFO from the tiny version
build: fix compilation on another system
build: fix compilation when configured with --disable-color
build: fix compilation when configured with --enable-tiny
build: move an #include to where it is needed
build: remove two #includes that don't seem to be needed
bump version numbers and add a news item for the 4.3 release
chars: create a dedicated function for getting the length of a character
chars: redo the speedup for plain ASCII from three commits ago
chars: speed up case-insensitive searching by roughly one percent
chars: speed up the determination of length and width for plain ASCII
copying: let a copy command break a chain of cut or zap commands
copying: make M-6 do nothing when at end of buffer
copying: scroll just one line when M-6 is pressed on the bottom row
cutting: clear the cutbuffer when the previous operation was copying
cutting: ignore the mark when a word is deleted
display: properly show all characters in a non-UTF-8 build
docs: add a light warning to the explanation of --nonewlines
docs: adjust the wording of the README to be factually correct
docs: clarify that in nano regexes are extended regular expressions
docs: mention the default value for 'errorcolor'
docs: note Brand as the author of the delayed syntax parsing
docs: note David as author of undoable indenting and undoable justifying
docs: remove "--" from the default value of 'quotestr'
docs: say thanks to the Korean translator, and trim a double space
docs: show double quotes where they are needed
docs: slightly reword the notice about the changed defaults since 4.0
feedback: don't clear off possible error messages after a spell check
feedback: don't try to represent keys outside of the seven-bit range
feedback: make an error check work also when curses hasn't started yet
feedback: print helpful message only when data comes from keyboard
feedback: show a more fitting message when opening a FIFO is interrupted
feedback: show an appropriate message when reading a file was cut short
feedback: treat statusline() being called outside of curses mode as a bug
feedback: when the last line is empty, don't include it in the count
files: allow a given file to be a special file but not a directory
files: allow to abort the reading of slow files with Ctrl+C
files: allow to interrupt the opening of a FIFO for writing with Ctrl+C
files: allow to interrupt the opening of a FIFO with Ctrl+C
files: check for writability by the access bits, not by trying to append
files: don't close a newly-created buffer when it is the only one
files: don't save the state of the terminal a second time
files: don't say "Error...: Success" when aborting after resizing
files: give feedback while waiting for a FIFO to open up
files: suppress feedback when writing an emergency or temporary file
files: try matching a syntax after scooping data from standard input
files: when needed, reconnect the keyboard and reenter curses mode
gnulib: update to its current upstream state
help: don't check for confinement when opening a temporary help-text file
help: don't cycle through the buffers for every resizing step
help: don't show Alt+Left and Alt+Right when running on a Linux console
help: make the column for the first keystroke a little wider
help: write the text directly into a new buffer, without using a tempfile
justify: remove "--" from the quoting regex, to avoid false paragraphs
oops: apparently the line numbers in the cutbuffer do matter
rcfile: at terminating points, verify that a defined syntax is not empty
rcfile: check for missing color commands only when a syntax is still open
rcfile: close off a syntax when a non-syntax command is encountered
rcfile: disallow extending a syntax that is defined in a main nanorc
rcfile: fully read each included file, so all its syntaxes are seen
search: stay in the Search menu when trying to Replace in view mode
softwrap: use smooth scrolling when softwrapping is toggled on
speller: be more concise and to the point when something goes wrong
speller: don't crash when the spell-checked tempfile cannot be opened
speller: ensure that a Shift-selected region is retained
speller: when something goes wrong with 'sort', do not blame 'spell'
startup: remove the now-unneeded workaround for a SIGWINCH during input
startup: resave the terminal's state only when there were no signals
syntax: po: colorize also escaped hex and octal codes
syntax: python: avoid miscoloring stuff between two empty strings
tweaks: add a missing forward declaration of make_new_buffer()
tweaks: add a pair of braces, to silence a compiler warning
tweaks: add a warning for something that shouldn't occur
tweaks: adjust a comment and drop two others, and reshuffle two lines
tweaks: adjust some indentation after the previous change
tweaks: adjust some whitespace and rewrap a few lines
tweaks: adjust the indentation after the previous change
tweaks: adjust the indentation after the previous change
tweaks: avoid an unneeded, extra stat() for temporary files
tweaks: avoid parsing a character twice
tweaks: be more sparing in redrawing things when exiting from help viewer
tweaks: change a function to void, to make things more direct
tweaks: check in a single place for files that should not be opened
tweaks: close a buffer differently and elide a parameter
tweaks: condense a comment and reshuffle a couple of lines
tweaks: condense a couple of comments, and reshuffle a line
tweaks: condense the setup of the two signal handlers for Ctrl+C
tweaks: condense two comments, and normalize the whitespace of a label
tweaks: consistently report failures to fork (and the like) as errors
tweaks: delete a leftover
tweaks: delete a now-unused function
tweaks: delete a now-unused function
tweaks: don't bother calling mblen() in a non-UTF-8 build
tweaks: don't bother checking the return value of wait()
tweaks: don't bother keeping track of whether a squeezed line has shrunk
tweaks: don't bother renumbering the lines in the cutbuffer
tweaks: don't bother saving and restoring 'cutbottom' all the time
tweaks: don't bother to free the content of 'extendsyntax' commands
tweaks: don't check the user's nanorc file for accessibility twice
tweaks: drop an unneeded parameter from open_file()
tweaks: drop a useless tidying-up call, as spelling does not use regexes
tweaks: drop most of the remaining debugging code, and some timing code
tweaks: drop some checks that were made redundant by the previous commit
tweaks: drop two checks that were made redundant by the previous commit
tweaks: elide a function that is an amalgam of three others
tweaks: elide a function that is called in just one place
tweaks: elide a function that is used just once
tweaks: elide another parameter, and rename the function to match
tweaks: elide an unneeded, duplicate stat() for the FIFO check
tweaks: elide an unneeded 'if' and 'break'
tweaks: elide an unneeded variable
tweaks: elide a parameter and a return value
tweaks: elide a pre-processor #else clause, by using braces instead
tweaks: elide a variable, drop a comment, and remove unneeded braces
tweaks: elide two unneeded variables
tweaks: enforce the miminum amount of scrolling in a simpler way
tweaks: exclude a bug check from the tiny version
tweaks: exclude another bug check from the tiny version
tweaks: factor out a fragment of code that is repeated three times
tweaks: factor out the installing and restoring of the ^C signal handler
tweaks: improve a couple of comments
tweaks: improve a handful of comments
tweaks: improve some comments, reshuffle a line, and rename a variable
tweaks: include the enabling of SIGINT into the tiny version
tweaks: invert a condition, in order to return earlier
tweaks: invert two conditions, in order to elide an extra variable
tweaks: just mark four rcfile errors for translation, like the others
tweaks: make better use of two variables, and reshuffle two comments
tweaks: merge two functions, as the first is called just once
tweaks: merge two functions, as the one is used only by the other
tweaks: merge two very similar functions into a single one
tweaks: move a bit of timing code to where it will be needed
tweaks: move a function to the file where it is used
tweaks: move an assignment that is useful only when searching forward
tweaks: move a syntax check to a better place, to reduce duplication
tweaks: move the tyding-up-after-a-search to a single exit point
tweaks: normalize the indentation after the previous two changes
tweaks: place a function better, and reduce some comments to a single one
tweaks: put some timing code back into the search function
tweaks: really don't bother renumbering the lines in the cutbuffer
tweaks: reduce a bit of mark-adjusting code to its essence
tweaks: reduce the scope of a variable, and let the compiler zero it
tweaks: remove a bit of redundant code
tweaks: remove a check that is no longer relevant
tweaks: remove a condition that has become superfluous
tweaks: remove an unneeded "closing" of a syntax after extending it
tweaks: remove an unneeded setting and unsetting of a flag
tweaks: remove a superfluous and ineffective assignment
tweaks: remove a superfluous condition, in three places
tweaks: remove four unneeded pre-processor directives
tweaks: remove some unneeded braces, and reshuffle for more symmetry
tweaks: remove the two remaining handfuls of asserts
tweaks: remove two more unneeded assignments
tweaks: remove two unneeded assignments, and improve a comment
tweaks: remove two unneeded checks for NULL
tweaks: rename a bunch of variables, to become identical to others
tweaks: rename a function and a variable, for contrast and variety
tweaks: rename a function and its parameters, to be more fitting
tweaks: rename a function, to be clearer and to stop using an old abbrev
tweaks: rename a function, to be more fitting
tweaks: rename a function, to better indicate what it does
tweaks: rename a function, to better suit what it does
tweaks: rename a parameter and a variable, to be more distinct
tweaks: rename a struct element, to be distinct
tweaks: rename a type, for more contrast
tweaks: rename a type, to make more sense
tweaks: rename a variable, reduce its scope, and use it consistently
tweaks: rename a variable, reshuffle declarations, and drop an assert
tweaks: rename a variable, to be shorter
tweaks: rename a variable, to better indicate it contains two characters
tweaks: rename a variable, to better suit its counterpart
tweaks: rename a variable, to fit a bit better
tweaks: rename a variable, to fit a little better
tweaks: rename a variable, to get out of the way of the next commit
tweaks: rename a variable, to match another with the same meaning
tweaks: rename a variable, to match the style of its brothers
tweaks: rename four elements of the holder struct, for more contrast
tweaks: rename some single-letter variables to the same significant word
tweaks: rename three variables, to get rid of a suffix or an underscore
tweaks: rename three variables, to use full words instead of abbrevs
tweaks: rename two functions, to be simpler
tweaks: rename two functions, to better describe what they do
tweaks: rename two functions, to get rid of the "mb" abbreviation
tweaks: rename two more functions, to be simpler too
tweaks: rename two parameters, away from single letters
tweaks: rename two parameters, for more contrast, and elide another
tweaks: rename two parameters, to differentiate them from function names
tweaks: rename two variables, and frob some comments
tweaks: rename two variables, and reshuffle their declarations
tweaks: rename two variables, away from a single letter
tweaks: rename two variables, for more contrast
tweaks: rename two variables, for more contrast with the partition stuff
tweaks: rename two variables, to be less cryptic
tweaks: rename two variables, to be unique
tweaks: rename two variables, to not be abbreviations
tweaks: reorder some code, to further optimize display_string() for ASCII
tweaks: reshuffle a bit of code, to be less intertwined
tweaks: reshuffle a couple of lines and adjust a few comments
tweaks: reshuffle a few lines, to be more straightforward
tweaks: reshuffle a few things, partly to make two chunks more alike
tweaks: reshuffle an assignment, to be able to return earlier
tweaks: reshuffle some closing and switching to a better place
tweaks: reshuffle some code to the one place that needs it
tweaks: reshuffle some lines and frob some comments
tweaks: reshuffle some lines, to group things more sensibly
tweaks: reshuffle some lines, to put the most likely candidate first
tweaks: reshuffle some lines, to reduce duplication
tweaks: reshuffle two #ifdefs, to avoid an unpaired brace
tweaks: reuse the install and restore functions for a signal handler
tweaks: set a boolean directly, instead of using a function call
tweaks: set a boolean directly, instead of using a function call
tweaks: sort three translator names better
tweaks: specifically refer to the manual of GNU grep for more regex info
tweaks: speed up the counting of characters in mbstrlen()
tweaks: squeeze excess spaces out of a line in situ
tweaks: step away one character from the current bracket, not one byte
tweaks: stop allocating and freeing a holder struct for every cut/paste
tweaks: stop checking for a NULL result from line_from_number()
tweaks: stop passing 'cutbuffer' and 'cutbottom' back and forth
tweaks: switch to the preceding buffer in a cheaper way (when in help)
tweaks: use a cheaper way to switch between buffers where possible
tweaks: use a more direct call when a single linestruct is deleted
tweaks: use a slightly faster function where appropriate
tweaks: use a symbol instead of zero to refer to standard input
tweaks: use FALSE for booleans instead of zero
tweaks: when OR'ing, put the most likely condition first
usage: make the --help output independent from the terminal's tab size
zapping: disjoin a zap command from earlier ones when the mark is set
zapping: use the 'keep_cutbuffer' logic to keep undo items apart
Brand Huntsman (6):
files: block SIGWINCH while opening a FIFO for reading or writing
rcfile: compile the color regexes just once
rcfile: fully parse a syntax file only when needed
rcfile: store errors and display them when nano terminates
startup: prevent a crash when no applicable syntax is found
tweaks: remove an unneeded pre-processor '#else' clause
Changes between v4.1 and v4.2:
------------------------------
Benno Schulenberg (23):
build: be more specific and avoid committing accidentally changed files
bump version numbers and add a news item for the 4.2 release
docs: put the 'set guidestripe' option into its alphabetical position
options: make --breaklonglines work also when --ignorercfiles is used
speller: do not crash by trying to free something that cannot be freed
tweaks: adjust a few comments and some indentation
tweaks: condense and improve a handful of comments
tweaks: declare a function as const and let its allocated string leak
tweaks: drop an unneeded saving and restoring of a variable
tweaks: elide an unneeded intermediate variable
tweaks: elide an unneeded parameter, as the function already assumes it
tweaks: elide an unneeded variable
tweaks: exclude a bit more code from a single-buffer build
tweaks: remove an unneeded condition
tweaks: remove a redundant, enclosed #ifdef
tweaks: rename a function, to be distinct and fitting
tweaks: rename another function, to be distinct and fitting
tweaks: rename a variable, for a little more meaning
tweaks: rename a variable, to distinguish it from a browser function
wrapping: add a missing space only when the remainder will be prepended
wrapping: compute the width of a succeeding line in the correct manner
wrapping: improve the persistence of the prepending behavior
wrapping: trim any trailing blanks when cursor goes to next line
Changes between v4.0 and v4.1:
------------------------------
Benno Schulenberg (85):
bindings: add easier keystrokes for the linenumber and softwrap toggles
bindings: disallow executing an external command when in view mode
bindings: recognize the ^W^Y and ^W^V legacy keystrokes again
bindings: remove the jumpy-scrolling toggle entirely
build: add gnulib modules to the list of files with translatable strings
build: add src/cut.c to the list of files with translatable strings
build: don't do fuzzy matching when merging PO files against the POT file
build: remove obsolete translations from the PO files after merging
bump version numbers and add a news item for the 4.1 release
display: report and catch a bad state, to prevent a possible hang
docs: for two of the toggles, mention the new instead of the old option
docs: give the FILES section in the man page its canonical title
docs: mention that -b is the opposite of -w also in the latter's item
docs: mention that M-S now toggles softwrap and M-N line numbers
docs: put paths and filenames in italics, per 'man man-pages'
docs: remove all mention of --finalnewline, and undefault --nonewlines
docs: remove the AUTHOR section, per advice from 'man man-pages'
docs: re-title the temporary section about the changed defaults
feedback: replace an assert with a check plus error message at startup
feedback: show a message while executing an external command
feedback: spare the user a superfluous scaring when trying to exit
gnulib: update to its current upstream state
help: don't doubly list toggles that have two keys assigned to them
indenting, commenting: ensure a partial line stays displayed properly
justify: correctly compute the number of lines to take, to avoid a crash
options: make --nowrap override again a contrary nanorc setting
options: remove -f (--finalnewline); go back to auto-adding this newline
rcfile: don't break a chain of 'else if' [scan-build]
rcfile: read the syntax files in alphabetical order when globbing
speller: block the resizing signal again during an external spell check
speller: block the resizing signal also during an integrated spell check
speller: resizing can happen also when configured with --enable-tiny
syntax: c: color as a type any lowercase word that ends with "_t"
syntax: default: color in red also versions 4.x of nano
syntax: man: add comments, and color all the safe lowercase macros
syntax: man: anchor macros at start of line, as only then they are valid
syntax: man: require the dot to be at start of line, not the comment
syntax: nanorc: colorize also strings preceded by 'start=' or 'end='
syntax: nanorc: require whitespace both before and after a quoted string
tweaks: adjust the indentation after the previous change
tweaks: condense a bit of copying code
tweaks: consistently use .sp instead of .PP to insert a blank line
tweaks: do a check up front instead of every time round the loop
tweaks: don't bother copying the NUL byte -- it is set nine lines down
tweaks: don't bother reallocating the data when a line gets hard-wrapped
tweaks: don't bother reallocating the squeezed string, just terminate it
tweaks: don't bother special-casing non-UTF8 when seeking a character
tweaks: drop an assignment whose value is never used [scan-build]
tweaks: drop two 'const' qualifiers, to silence the compiler
tweaks: free some memory before a possible error exit [coverity]
tweaks: free the copy of a linter message in all cases [valgrind]
tweaks: free the result string from an invocation error [coverity]
tweaks: initialize a boolean before it is referenced [valgrind]
tweaks: put the unblocking of SIGWINCHes in a better place
tweaks: remove a function that is now unused
tweaks: remove an unneeded check for NULL and its associated message
tweaks: remove an unneeded check for NULL [coverity]
tweaks: remove an unpaired closing parenthesis from the NEWS file
tweaks: remove a superfluous check for NULL plus the associated message
tweaks: remove several unneeded bad-state checks and their messages
tweaks: rename a cryptic type to something that makes a little sense
tweaks: rename a function plus parameter, to stay closer to what it does
tweaks: rename another variable, to be more descriptive
tweaks: rename another variable, to be more fitting
tweaks: rename an overshort type to something that makes some sense
tweaks: rename a variable, to be more distinct and more apt
tweaks: rename a variable, to be more distinct and more descriptive
tweaks: rename a variable, to get out of the way for another rename
tweaks: rename some variables, for more contrast and to match others
tweaks: rename some variables, to be less repititious
tweaks: rename two variables, for more contrast
tweaks: rename two variables, to be more distinct and more fitting
tweaks: rename two variables, to make more sense
tweaks: rename two variables, to match others
tweaks: reshuffle some lines, condense a comment and drop another
tweaks: reshuffle some lines, to elide an 'if'
tweaks: reshuffle two lines, and reword a comment
tweaks: reword a comment, and drop an unneeded assert
tweaks: shorten a comment to its essence
tweaks: shorten and improve some comments, and reshuffle a few lines
tweaks: simplify a message, and normalize the spelling of another one
tweaks: stop doing tandem assignments (one passing through the other)
tweaks: switch back from checking FINAL_NEWLINE to checking NO_NEWLINES
tweaks: use a signed type for a result that could be negative [coverity]
unindent: ensure that a partial line gets displayed properly afterwards
Brand Huntsman (1):
files: block the resizing signal while reading from an external command
Devin Hussey (1):
files: initialize a variable before referencing it
Liu Hao (1):
syntax: c: change the highlighting of preprocessor directives
Changes between v3.2 and v4.0:
------------------------------

View File

@@ -2,6 +2,14 @@ Improvements in GNU nano
========================
Since 4.0:
- Pasting from outside into nano suppresses auto-indentation.
- Such an external paste can be undone with a single M-U.
- Shift+Meta+letter key combos can be bound with 'bind Sh-M-letter ...'.
- A custom nanorc file may be specified with -f / --rcfile.
- What the <Tab> key produces can be specified per syntax with 'tabgives'.
- The ability to perform a search at startup with +/string or +?string.
- Comment characters are copied when automatic hard-wrapping occurs.
- The ability to both read from and write to a FIFO.
- Automatic hard-wrapping is no longer the default.
- Addition of --guidestripe to draw a helpful vertical bar.
- Meta-Up and Meta-Down scroll the screen linewise.

158
NEWS
View File

@@ -1,3 +1,75 @@
2020.02.07 - GNU nano 4.8 "Jaška"
• When something is pasted into nano, auto-indentation is suppressed,
and the paste can be undone as a whole with a single M-U.
• When a lock file is encountered during startup, pressing ^C/Cancel
quits nano. (Pressing 'No' just skips the file and continues.)
• Shift+Meta+letter key combos can be bound with 'bind Sh-M-letter'.
Making any such binding dismisses the default behavior of ignoring
Shift for all Meta+letter keystrokes.
• The configuration option --with-slang (to be avoided when possible)
can now be used only together with --enable-tiny.
• A custom nanorc file can be specified on the command line, with
-f filename or --rcfile=filename.
2019.12.23 - GNU nano 4.7 "Havikskruid"
• A <Tab> will indent a marked region only when mark and cursor are
on different lines.
• Two indentations (any mix of tabs and spaces) are considered the
same when they look the same (that is: indent to the same level).
• When using --breaklonglines or ^J, a line will never be broken in
its leading whitespace or quoting.
• The keywords in nanorc files must be in lowercase.
2019.11.29 - GNU nano 4.6 "And don't you eat that yellow snow"
• The 'formatter' command has returned, bound by default to M-F.
It allows running a syntax-specific command on the contents of
the buffer.
• ^T will try to run 'hunspell' before 'spell', because it checks
spellling for the locale's language and understands UTF-8.
• Multiple errors or warnings on startup will no longer slow nano
down but will be indicated on the status bar with trailing dots.
2019.10.04 - GNU nano 4.5 "Košice"
• The new 'tabgives' command allows you to specify per syntax what
the <Tab> key should produce: some spaces, a hard TAB, ...
• The output of --help is properly aligned again for all languages.
• <Tab> will indent a marked region also when M-} has been rebound.
2019.08.25 - GNU nano 4.4 "Hagelslag"
• At startup, the cursor can be put on the first or last occurrence
of a string by preceding the filename with +/string or +?string.
• When automatic hard-wrapping occurs (--breaklonglines), any leading
quoting characters will be automatically copied to the new line.
• M-6 works again also when the cursor is at end of buffer.
2019.06.18 - GNU nano 4.3 "Musa Kart"
• The ability to read from and write to a FIFO has been regained.
• Startup time is reduced by fully parsing a syntax only when needed.
• Asking for help (^G) when using --operatingdir does not crash.
• The reading of a huge or slow file can be stopped with ^C.
• Cut, zap, and copy operations are undone separately when intermixed.
• M-D reports the correct number of lines (zero for an empty buffer).
2019.04.24 - GNU nano 4.2 "Tax the rich, pay the teachers"
• The integrated spell checker does not crash when 'spell' is missing.
• Option --breaklonglines works also when --ignorercfiles is used.
• Automatic hard-wrapping is more persistent in pushing words to the
same overflow line.
2019.04.15 - GNU nano 4.1 "Qué corchos será eso?"
• By default, a newline character is again automatically added at the
end of a buffer, to produce valid POSIX text files by default, but
also to get back the easy adding of text at the bottom.
• The now unneeded option --finalnewline (-f) has been removed.
• Syntax files are read in alphabetical order when globbing, so that
the precedence of syntaxes becomes predictable.
• In the C syntax, preprocessor directives are highlighted differently.
• M-S now toggles soft wrapping, and M-N toggles line numbers.
• The jumpy-scrolling toggle has been removed.
• The legacy keystrokes ^W^Y and ^W^V are recognized again.
• Executing an external command is disallowed when in view mode.
• Problems with resizing during external or speller commands were fixed.
2019.03.24 - GNU nano 4.0 "Thy Rope of Sands"
• An overlong line is no longer automatically hard-wrapped.
• Smooth scrolling (one line at a time) has become the default.
@@ -13,7 +85,7 @@
• Option --guidestripe=<number> draws a vertical bar at the given column.
• Option --fill=<number> no longer turns on automatic hard-wrapping.
• When a line continues offscreen, it now ends with a highlighted ">".
• The halfs of a split two-column character are shown as "[" and "]".
• The halves of a split two-column character are shown as "[" and "]".
• A line now scrolls horizontally one column earlier.
• The bindable functions 'cutwordleft' and 'cutwordright' were renamed
to 'chopwordleft' and 'chopwordright' as they don't use the cutbuffer.
@@ -587,7 +659,7 @@
like this what could POSSIBLY go WRONG? Hahaha.
Enjoy and if you find new bugs, as always please
use Savannah's bug tracker.
http://savannah.gnu.org/bugs/?func=additem&group=nano
https://savannah.gnu.org/bugs/?func=additem&group=nano
2010.01.17 - GNU nano 2.2.2 is released for you, you, you. This
release includes fixes for: crashes when writing
@@ -670,9 +742,9 @@
without the usual truncation and a '$' symbol at the end
of the line. It can be enabled via Meta-$ inside the
editor, via the -$ or --softwrap command-line flags,
or "set softwrap" in your .nanorc). As always, please
report any bugs to the nano Savannah project page
(http://savannah.gnu.org/bugs/?func=additem&group=nano)
or via "set softwrap" in your .nanorc. As always,
please report any bugs to the nano Savannah project page
(https://savannah.gnu.org/bugs/?func=additem&group=nano)
Remember: data loss happens, back up your files.
2009.07.28 - GNU nano 2.1.10 "Ellie" is released. This version includes
@@ -700,45 +772,41 @@
birthday lenny!
2009.02.07 - GNU nano 2.1.8 "unsafe at any speed" is released. This
release include some long overdue performance
improvements in syntax color highlighting, the ability
to abort running searches (useful mainly when
editing very large files) and the ability to use nano
like a pager for viewing standard input (i.e. "nano -").
Additionally, there are gentoo syntax highlighting
updates and fixes for issues with reading files
in a directory with strange parent directory permissions.
The key bindings code was also substantially changed
in order to be more ISO-C compatible. Be sure to use
the Savannah page not only for bug reports but for any
release includes some long overdue performance improvements
in syntax color highlighting, the ability to abort running
searches (useful mainly when editing very large files) and
the ability to use nano like a pager for viewing standard
input (i.e. "nano -"). Additionally, there are gentoo
syntax highlighting updates and fixes for issues with
reading files in a directory with strange parent directory
permissions. The key-bindings code was also substantially
changed in order to be more ISO-C compatible. Be sure to
use the Savannah page not only for bug reports but for any
features you would like to see before the next stable
series is released. Have fun with it!
2008.11.10 - GNU nano 2.1.7 "Effingham" is ready to make good on those
campaign promises of lower bug rates and 50% more pie.
This release includes a new check for external
modifications when saving a file, some code and
documentation cleanups, and more bug fixes for
the new undo code (but we continue to welcome
your bug reports via the Savannah bug page at
http://savannah.gnu.org/bugs/?func=additem&group=nano).
This release includes a new check for external modifications
when saving a file, some code and documentation cleanups,
and more bug fixes for the new undo code (but we continue
to welcome your bug reports via the Savannah bug page at
https://savannah.gnu.org/bugs/?func=additem&group=nano).
Come get some.
2008.10.03 - GNU nano 2.1.6 was for new features before it was against
them. This release includes more undo capability,
several new syntax highlighting configurations including
Objective C, OCaml, and Fortran, and a new capability
to activate highlighting based on the 1st line of the
file being edited. Also, the new default configure
options now include color syntax highlighting, .nanorc
support, multibuffer and extras. These items can still
be disabled and are not enabled with --enable-tiny. Bug
fixes include better signal handling under Cygwin, and
that's about it. Again please remember to
submit bug reports via Savannah at
http://savannah.gnu.org/bugs/?func=additem&group=nano
as undo functions certainly need more testing.
Bon appetit.
them. This release includes more undo capability, several
new syntax highlighting configurations including Objective
C, OCaml, and Fortran, and a new capability to activate
highlighting based on the 1st line of the file being
edited. Also, the new default configure options now
include color syntax highlighting, .nanorc support,
multibuffer and extras. These items can still be disabled
and are not enabled with --enable-tiny. Bug fixes include
better signal handling under Cygwin, and that's about it.
Again please remember to submit bug reports via Savannah at
https://savannah.gnu.org/bugs/?func=additem&group=nano as
undo functions certainly need more testing. Bon appetit.
2008.08.30 - GNU nano 2.1.5 is ready to lead on day one. This release
contains a better fix for incorrectly reported successful
@@ -761,15 +829,15 @@
are likely to run out of space; see Savannah bug #24000.
Have fun with it!
2008.08.04 - GNU nano 2.1.3 "least stable version ever" is released. This
release includes new (and experimental) undo and redo
functionality for most text operations. The default
key bindings are Meta-U for undo and Meta-E for redo, but
these can be remapped using the new 2.1 keybinding code.
Also included are some fixes for configuring using wide
curses, crashing when invoking the help menu with
certain locales, and not saving the search history when
compiled with configure options.
2008.08.04 - GNU nano 2.1.3 "least stable version ever" is released.
This release includes new (and experimental) undo and redo
functionality for most text operations. The default key
bindings are Meta-U for undo and Meta-E for redo, but these
can be remapped using the new 2.1 keybinding code. Also
included are some fixes for configuring using wide curses,
crashing when invoking the help menu with certain locales,
and not saving the search history when compiled with
configure options.
2008.04.24 - GNU nano 2.1.2 "New York City" is released. This release
contains fixes for binding bad keys, some

12
README
View File

@@ -15,20 +15,20 @@ Overview
Nano aimed to solve these problems by: 1) being truly free software
by using the GPL, 2) emulating the functionality of Pico as closely
as is reasonable, and 3) include extra functionality by default.
as is reasonable, and 3) including extra functionality by default.
Nowadays, nano wants to be a generally useful editor, with default
settings that do not change the file contents automatically.
Nowadays, nano wants to be a generally useful editor with sensible
defaults (linewise scrolling, no automatic line breaking).
The nano editor is an official GNU package. For more information on
GNU and the Free Software Foundation, please see https://www.gnu.org/.
How to compile and install nano
Download the nano source code, then:
Download the latest nano source tarball, then:
tar xvzf nano-x.y.z.tar.gz
cd nano-x.y.z
tar -xvf nano-x.y.tar.gz
cd nano-x.y
./configure
make
make install

View File

@@ -14,13 +14,13 @@ packages:
- autoconf (version >= 2.69)
- automake (version >= 1.14)
- autopoint (version >= 0.18.3)
- gcc (version >= 5.0)
- gettext (version >= 0.18.3)
- git (version >= 2.7.4)
- groff (version >= 1.12)
- make (any version)
- pkg-config (version >= 0.22)
- texinfo (version >= 4.0)
- gcc (any version)
- make (any version)
If you want UTF-8 support, you will also need libncursesw5-dev installed
(version >= 5.7), or libslang2-dev (version >= 2.0) if you use --with-slang.

9
THANKS
View File

@@ -11,6 +11,7 @@ Mario Blättermann <mario.blaettermann@gmail.com> German
Ricardo Cárdenes Medina <ricardo@conisys.com> Spanish
Antonio Ceballos <aceballos@gmail.com> Spanish
Wei-Lun CHAO <chaoweilun@pcmail.com.tw> Chinese (traditional)
Seong-ho Cho <darkcircle.0426@gmail.com> Korean
Yuri Chornoivan <yurchor@ukr.net> Ukrainian
Marco Colombo <magicdice@inwind.it> Italian
Mihai Cristescu <mihai.cristescu@archlinux.info> Romanian
@@ -22,22 +23,22 @@ Rafael Fontenelle <rffontenelle@gmail.com> Brazilian Portuguese
Pavel Fric <pavelfric@seznam.cz> Czech
Jorge González <aloriel@gmail.com> Spanish
Jean-Philippe Guérard <jean-philippe.guerard@laposte.net> French
Geir Helland <pjallabais@users.sourceforge.net> Norwegian Bokmål
Tedi Heriyanto <tedi_h@gmx.net> Indonesian
Václav Haisman <V.Haisman@sh.cvut.cz> Czech
Takeshi Hamasaki <hmatrjp@users.sourceforge.jp> Japanese
Geir Helland <pjallabais@users.sourceforge.net> Norwegian Bokmål
Tedi Heriyanto <tedi_h@gmx.net> Indonesian
Kjetil Torgrim Homme <kjetilho@linpro.no> Norwegian Nynorsk
Szabolcs Horvath <horvaths@janus.gimsz.sulinet.hu> Hungarian
Jorma Karvonen <karvonen.jorma@gmail.com> Finnish
Mehmet Kececi <mkececi@mehmetkececi.com> Turkish
Mehmet Kececi <mkececi@mehmetkececi.com> Turkish
Gabor Kelemen <kelemeng@gnome.hu> Hungarian
Kalle Kivimaa <kalle.kivimaa@iki.fi> Finnish
Eivind Kjørstad <ekj@vestdata.no> Norwegian Nynorsk
Florian König <floki@bigfoot.com> German
Klemen Košir <klemen913@gmail.com> Slovenian
Wojciech Kotwica <wkotwica@post.pl> Polish
Ask Hjorth Larsen <asklarsen@gmail.com> Danish
Clement Laforet <clem_laf@wanadoo.fr> French
Ask Hjorth Larsen <asklarsen@gmail.com> Danish
LI Daobing <lidaobing@gmail.com> Chinese (simplified)
Jordi Mallach <jordi@gnu.org> Catalan
João Victor Duarte Martins <jvdm@sdf.lonestar.org> Brazilian Portuguese

4
TODO
View File

@@ -2,7 +2,6 @@ A list of desired features
--------------------------
Somewhat urgent:
- Make undo/redo work also for justifying.
- Detect when text is being pasted, so that we can handle it faster.
See https://savannah.gnu.org/bugs/?40060.
- Allow color syntaxes to apply to more than just color, so that we can
@@ -17,6 +16,9 @@ Vague musings:
- Make matching bracket searches sophisticated enough to skip over
brackets inside comments?
For version 4.0:
- Make undo/redo work also for justifying. [DONE]
For version 2.9:
- Allow piping (marked) text to an external command and replacing it with
the command's output. That is: implement filtering. [DONE]

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="69c4509f33c6a6ac159f3429d4150bf119ac4d76"
gnulib_hash="e313a5367b1e4edfa19ab5f0d001d0b060a77066"
modules="
futimens

View File

@@ -1,6 +1,6 @@
# Configuration for GNU nano - a small and user-friendly text editor
#
# Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc.
# Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
# Copyright (C) 2014, 2017 Mike Frysinger
#
# GNU nano is free software: you can redistribute it and/or modify
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.
AC_INIT([GNU nano], [4.0], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [4.8], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])
@@ -89,6 +89,12 @@ AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
dnl Checks for options.
if test "x$with_slang" = xyes; then
if test "x$enable_tiny" != xyes; then
AC_MSG_ERROR([--with-slang is supported only together with --enable-tiny])
fi
fi
AC_ARG_ENABLE(browser,
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
if test "x$enable_tiny" = xyes; then
@@ -516,7 +522,6 @@ int main(void)
;;
esac], [AC_MSG_RESULT(no)])
dnl Checks for functions.
if test "x$enable_utf8" != xno; then

134
doc/cheatsheet.html Normal file
View File

@@ -0,0 +1,134 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>Cheatsheet for nano</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="A concise overview of the command shortcuts of the GNU nano editor, grouped by category.">
<meta name="keywords" content="cheatsheet, nano, editor, shortcuts, keystrokes, functions, operations, commands">
<meta name="author" content="Benno Schulenberg">
</head>
<body>
<br>
<h1 align="center">Overview of nano's shortcuts &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h1>
<h3 align="center">The editor's keystrokes and their functions &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h3>
<br>
<table align="center"><tbody>
<tr><td>
<b>File handling</b>
<table><tbody>
<tr><td>Ctrl+S &nbsp;&nbsp;</td><td>Save current file</td></tr>
<tr><td>Ctrl+O</td><td>Offer to write file ("Save as")</td></tr>
<tr><td>Ctrl+R</td><td>Insert a file into current one</td></tr>
<tr><td>Ctrl+X</td><td>Close buffer, exit from nano</td></tr>
</tbody></table>
<br>
<b>Editing</b>
<table><tbody>
<tr><td>Ctrl+K &nbsp;&nbsp;</td><td>Cut current line into cutbuffer</td></tr>
<tr><td>Alt+6</td><td>Copy current line into cutbuffer</td></tr>
<tr><td>Ctrl+U</td><td>Paste contents of cutbuffer</td></tr>
<tr><td>Alt+T</td><td>Cut until end of buffer</td></tr>
<tr><td>Ctrl+]</td><td>Complete current word</td></tr>
<tr><td>Alt+3</td><td>Comment/uncomment line/region</td></tr>
<tr><td>Alt+U</td><td>Undo last action</td></tr>
<tr><td>Alt+E</td><td>Redo last undone action</td></tr>
</tbody></table>
<br>
<b>Search and replace</b>
<table><tbody>
<tr><td>Ctrl+Q &nbsp;&nbsp;</td><td>Start backward search</td></tr>
<tr><td>Ctrl+W</td><td>Start forward search</td></tr>
<tr><td>Alt+Q</td><td>Find next occurrence backward</td></tr>
<tr><td>Alt+W</td><td>Find next occurrence forward</td></tr>
<tr><td>Alt+R</td><td>Start a replacing session</td></tr>
</tbody></table>
<br>
<b>Deletion</b>
<table><tbody>
<tr><td>Ctrl+H</td><td>Delete character before cursor &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
<tr><td>Ctrl+D</td><td>Delete character under cursor</td></tr>
<tr><td>Ctrl+Shift+Del &nbsp;&nbsp;</td><td>Delete word to the left</td></tr>
<tr><td>Ctrl+Del</td><td>Delete word to the right</td></tr>
<tr><td>Alt+Del</td><td>Delete current line</td></tr>
</tbody></table>
<br>
<b>Operations</b>
<table><tbody>
<tr><td>Ctrl+T &nbsp;&nbsp;</td><td>Run a spell check</td></tr>
<tr><td>Ctrl+J</td><td>Justify paragraph or region</td></tr>
<tr><td>Alt+J</td><td>Justify entire buffer</td></tr>
<tr><td>Alt+B</td><td>Run a syntax check</td></tr>
<tr><td>Alt+F</td><td>Run a formatter/fixer/arranger</td></tr>
<tr><td>Alt+:</td><td>Start/stop recording of macro</td></tr>
<tr><td>Alt+;</td><td>Replay macro</td></tr>
</tbody></table>
<br>
</td><td>
<b>Moving around</b>
<table><tbody>
<tr><td>Ctrl+B &nbsp;&nbsp;</td><td>One character backward</td></tr>
<tr><td>Ctrl+F</td><td>One character forward</td></tr>
<tr><td>Ctrl+<b>&leftarrow;</b></td><td>One word backward</td></tr>
<tr><td>Ctrl+<b>&rightarrow;</b></td><td>One word forward</td></tr>
<tr><td>Ctrl+A</td><td>To start of line</td></tr>
<tr><td>Ctrl+E</td><td>To end of line</td></tr>
<tr><td>Ctrl+P</td><td>One line up</td></tr>
<tr><td>Ctrl+N</td><td>One line down</td></tr>
<tr><td>Ctrl+<b>&uparrow;</b></td><td>To previous block</td></tr>
<tr><td>Ctrl+<b>&downarrow;</b></td><td>To next block</td></tr>
<tr><td>Ctrl+Y</td><td>One page up</td></tr>
<tr><td>Ctrl+V</td><td>One page down</td></tr>
<tr><td>Alt+\</td><td>To top of buffer</td></tr>
<tr><td>Alt+/</td><td>To end of buffer</td></tr>
</tbody></table>
<br>
<b>Special movement</b>
<table><tbody>
<tr><td>Alt+G &nbsp;&nbsp;&nbsp;</td><td>Go to specified line</td></tr>
<tr><td>Alt+]</td><td>Go to complementary bracket</td></tr>
<tr><td>Alt+<b>&uparrow;</b></td><td>Scroll viewport up</td></tr>
<tr><td>Alt+<b>&downarrow;</b></td><td>Scroll viewport down</td></tr>
<tr><td>Alt+&lt;</td><td>Switch to preceding buffer</td></tr>
<tr><td>Alt+&gt;</td><td>Switch to succeeding buffer</td></tr>
</tbody></table>
<br>
<b>Information</b>
<table><tbody>
<tr><td>Ctrl+C &nbsp;&nbsp;</td><td>Report cursor position</td></tr>
<tr><td>Alt+D</td><td>Report word/line/char count</td></tr>
<tr><td>Ctrl+G</td><td>Display help text</td></tr>
</tbody></table>
<br>
<b>Various</b>
<table><tbody>
<tr><td>Alt+A</td><td>Turn the mark on/off</td></tr>
<tr><td>Tab</td><td>Indent marked region</td></tr>
<tr><td>Shift+Tab &nbsp;&nbsp;</td><td>Unindent marked region</td></tr>
<tr><td>Alt+N</td><td>Turn line numbers on/off</td></tr>
<tr><td>Alt+P</td><td>Turn visible whitespace on/off</td></tr>
<tr><td>Alt+V</td><td>Enter next keystroke verbatim</td></tr>
<tr><td>Ctrl+L</td><td>Refresh the screen</td></tr>
<tr><td>Ctrl+Z</td><td>Suspend nano</td></tr>
</tbody></table>
<br>
</td></tr>
</tbody></table>
</body>
</html>

View File

@@ -1,9 +1,12 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>The GNU nano editor FAQ</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="The genesis story of the nano editor, plus the solution to some common problems.">
</head>
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
<h1>The GNU nano editor FAQ</h1>
@@ -28,11 +31,12 @@
<a href="#3.1">3.1. How do I install the RPM or DEB package?</a><br>
<a href="#3.2">3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</a><br>
<a href="#3.3">3.3. Why does everything go into /usr/local?</a><br>
<a href="#3.5">3.5. nano should automatically run strip on the binary when installing it!</a><br>
<a href="#3.6">3.6. How can I make the executable smaller? This is too bloated!</a><br>
<a href="#3.7">3.7. Tell me more about this multibuffer stuff!</a><br>
<a href="#3.8">3.8. Tell me more about this verbatim input stuff!</a><br>
<a href="#3.9">3.9. How do I make a .nanorc file that nano will read when I start it?</a><br>
<a href="#3.4">3.4. nano should automatically run strip on the binary when installing it!</a><br>
<a href="#3.5">3.5. How can I make the executable smaller? This is too bloated!</a><br>
<a href="#3.6">3.6. Tell me more about this multibuffer stuff!</a><br>
<a href="#3.7">3.7. Tell me more about this verbatim input stuff!</a><br>
<a href="#3.8">3.8. How do I make a .nanorc file that nano will read when I start it?</a><br>
<a href="#3.9">3.9. Why does my self-compiled nano not read /etc/nanorc?</a><br>
</p></blockquote>
<h3><a href="#4">4. Running</a></h3>
<blockquote><p>
@@ -85,7 +89,7 @@
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h3><a name="1.4"></a>1.4. What is the current version of nano?</h3>
<blockquote><p>The current version of nano <i>should</i> be <b>4.0</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano <i>should</i> be <b>4.8</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
@@ -94,8 +98,8 @@
<h3><a name="2.1"></a>2.1. Web sites that carry nano.</h3>
<blockquote><p>The nano source tarballs can be downloaded from the following web sites:</p>
<ul>
<li><a href="https://nano-editor.org/dist/">https://nano-editor.org/dist/</a></li>
<li><a href="https://ftp.gnu.org/gnu/nano/">https://ftp.gnu.org/gnu/nano/</a></li>
<li><a href="https://nano-editor.org/dist/latest/">https://nano-editor.org/dist/latest/</a></li>
<li><a href="https://ftpmirror.gnu.org/gnu/nano/">https://ftpmirror.gnu.org/gnu/nano/</a></li>
</ul>
</blockquote>
<h3><a name="2.2"></a>2.2. RPM packages (RedHat, OpenSuse, and derivatives).</h3>
@@ -112,7 +116,7 @@
<li><a href="https://packages.debian.org/testing/editors/nano">testing</a></li>
<li><a href="https://packages.debian.org/unstable/editors/nano">unstable</a></li>
</ul>
<p>You can also have a look at the <a href="ftp://ftp.debian.org/debian/pool/main/n/nano/">Package Pool</a> to see all the available binary and source packages.</p>
<p>You can also have a look at the <a href="http://ftp.debian.org/debian/pool/main/n/nano/">Package Pool</a> to see all the available binary and source packages.</p>
</blockquote>
<h3><a name="2.4"></a>2.4. By GIT (for the brave).</h3>
<blockquote><p>For the 'bleeding edge' current version of nano, you can use GIT to download the current source code. <b>Note:</b> believe it or not, by downloading code that has not yet stabilized into an official release, there could quite possibly be bugs, in fact the code may not even compile! Anyway, see <a href="http://git.savannah.gnu.org/cgit/nano.git/tree/README.GIT">the nano GIT document</a> for info on anonymous GIT access to the nano source.</p></blockquote>
@@ -120,23 +124,23 @@
<h1><a name="3"></a>3. Installation and Configuration</h1>
<h3><a name="3.1"></a>3.1. How do I install the RPM or DEB package?</h3>
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y.z-1.i386.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y.z-1.deb</b> if you have a Debian-ish system, where <b>x.y.z</b> is the release of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y-1*.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y-1*.deb</b> if you have a Debian-ish system, where <b>x.y</b> is the version number of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
<h3><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h3>
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
<p><b>tar -xvf nano-x.y.z.tar.gz</b></p>
<p><b>tar -xvf nano-x.y.tar.gz</b></p>
<p>Then you need to run <b>configure</b> with any options you might want (if any).</p>
<p>The average case is this:</p>
<p><b>cd nano-x.y.z/</b><br>
<p><b>cd nano-x.y/</b><br>
<b>./configure</b><br>
<b>make</b><br>
<b>make install</b> (as root, of course)</p></blockquote>
<h3><a name="3.3"></a>3.3. Why does everything go into /usr/local?</h3>
<blockquote><p>Well, that's what the <b>configure</b> script defaults to. If you wish to change this, simply do this:</p>
<p><b>./configure --prefix=/usr</b></p>
<p>to put nano into /usr/bin when you run <b>make install</b>.</p></blockquote>
<h3><a name="3.5"></a>3.5. nano should automatically run strip on the binary when installing it!</h3>
<blockquote><p>Actually, it does, but you have to use <b>make install-strip</b>. The default make install does not, and will not, run strip automatically.</p></blockquote>
<h3><a name="3.6"></a>3.6. How can I make the executable smaller? This is too bloated!</h3>
<p>This will put nano into /usr/bin when you run <b>make install</b>.</p></blockquote>
<h3><a name="3.4"></a>3.4. nano should automatically run strip on the binary when installing it!</h3>
<blockquote><p>It does when you use <b>make install-strip</b>. The default <b>make install</b> does not, and will not, run strip automatically.</p></blockquote>
<h3><a name="3.5"></a>3.5. How can I make the executable smaller? This is too bloated!</h3>
<blockquote><p>Actually, there are several parts of the editor that can be disabled. You can pass arguments to the <b>configure</b> script that disable certain features. Here's a brief list:</p>
<pre>
<b>--disable-browser</b> Disable the built-in file browser
@@ -156,26 +160,28 @@
<b>--disable-tabcomp</b> Disable the tab-completion functions
<b>--disable-wordcomp</b> Disable the word-completion function
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the marker code that you use with Control-^ to select text). Also, if you know you aren't going to be using other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few K to a few dozen K depending on whether you have locale support on your system. And finally, there's always good old <b>strip</b> to strip all debugging code and code that exists in libraries on your system.</p>
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the undo/redo code and the code for selecting text). Also, if you know you don't need other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few kilobytes. And finally, there's always good old <b>strip</b> to remove all unneeded symbols.</p>
</blockquote>
<h3><a name="3.7"></a>3.7. Tell me more about this multibuffer stuff!</h3>
<h3><a name="3.6"></a>3.6. Tell me more about this multibuffer stuff!</h3>
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b> after typing <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>-F</b> or <b>--multibuffer</b> flag when you invoke nano, or add <b>set multibuffer</b> to your .nanorc file.</p>
<p>You can move between the buffers you have open with the <b>Meta-&lt;</b> and <b>Meta-&gt;</b> keys, or more easily without holding Shift: <b>Meta-,</b> and <b>Meta-.</b> (clear as mud, right? =-). When you have more than one buffer open, the ^X shortcut will say &quot;Close&quot;, instead of &quot;Exit&quot;.</p></blockquote>
<h3><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h3>
<h3><a name="3.7"></a>3.7. Tell me more about this verbatim input stuff!</h3>
<blockquote><p>When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message &quot;Verbatim Input&quot; on the status bar), then press the key(s) that generate the character you want.</p>
<p>Alternatively, if Unicode support is enabled (see section <a href="#5.3">5.3</a>), you can press <b>Meta-V</b> and then type a six-digit hexadecimal code (from 000000 to 10FFFF, case-insensitive), and the character with the corresponding value will be inserted. The status bar will change to &quot;Unicode Input: ......&quot; when you do this.</p></blockquote>
<h3><a name="3.9"></a>3.9. How do I make a .nanorc file that will be read when I start nano?</h3>
<blockquote><p>It's not hard at all! But, your nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>. Then simply copy the <b>sample.nanorc</b> that came with the nano source or your nano package (most likely in /usr/doc/nano) to .nanorc in your home directory. If you didn't get one, the syntax of the file is simple. Flags are turned on and off by using the words <b>set</b> and <b>unset</b> plus the long option name for the feature. For example, &quot;set nowrap&quot; or &quot;set smarthome&quot;.</p></blockquote>
<h3><a name="3.8"></a>3.8. How do I make a .nanorc file that will be read when I start nano?</h3>
<blockquote><p>It's not hard at all! Simply copy the <b>sample.nanorc</b> from the doc/ directory in the nano source package (or from /usr/doc/nano on your system) to <b>.nanorc</b> in your home directory, and then edit it. If you didn't get a sample nanorc, the syntax of the file is simple: features are turned on and off by using the words <b>set</b> and <b>unset</b> followed by the long option name of the feature (see <b>man nanorc</b> for the full list of options). For example, &quot;set quickblank&quot; or &quot;set smarthome&quot;. Of course, for this to work, your nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>.</p></blockquote>
<h3><a name="3.9"></a>3.9. Why does my self-compiled nano not read /etc/nanorc?</h3>
<blockquote><p>By default (see <a href="#3.3">3.3</a>), nano gets installed into /usr/local. This also means that, at startup, nano will read <b>/usr/local/etc/nanorc</b> instead of <b>/etc/nanorc</b>. You can make a symlink from the former to the latter if you want your self-compiled nano to read the same nanorc as the system-installed nano. Or you can configure your nano to overwrite the system nano (again, see <a href="#3.3">3.3</a>).</p></blockquote>
<hr width="100%">
<h1><a name="4"></a>4. Running</h1>
<h3><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h3>
<blockquote><p>If a command-line option that begins with '+' is followed by another option, the former is always treated as a starting line and column number, and the latter is always treated as a filename. If a command-line option that begins with '+' isn't followed by another option, it's always treated as a filename. Examples:</p>
<p>To open '+filename.txt' starting on line 1: <b>nano +filename.txt</b><br>
<blockquote><p>If a command-line argument that begins with '+' is followed by another argument, the former is always treated as a starting line (plus column number), and the latter always as a filename. If a command-line argument that begins with '+' isn't followed by another argument, it's treated as a filename. Examples:</p>
<p>To open '+filename.txt': <b>nano +filename.txt</b><br>
To open '+filename.txt' starting on line 10: <b>nano +10 +filename.txt</b><br>
To open '+filename.txt' starting on line 1, column 20: <b>nano +,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 10, column 20: <b>nano +10,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 1 and 'filename.txt' starting on line 40 (if nano has been compiled with multibuffer support): <b>nano +1 +filename.txt +40 filename.txt</b></p></blockquote>
To open '+filename.txt' starting on line 1 and 'filename.txt' starting on line 40: <b>nano +1 +filename.txt +40 filename.txt</b></p></blockquote>
<h3><a name="4.2"></a>4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</h3>
<blockquote><p>Try setting your $TERM variable to 'vt100'. nano doesn't yet support every term entry under the sun.</p>
<p>Bourne shell users (bash and sh): <b>export TERM=vt100</b><br>
@@ -187,9 +193,11 @@
<h3><a name="4.5"></a>4.5. How do I select text for or paste text from the clipboard when nano's mouse support is turned on?</h3>
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
<h3><a name="4.6"></a>4.6. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</h3>
<blockquote><p>You have the <i>autoindent</i> feature turned on. Hit <b>Meta-I</b> to turn it off, paste your text, and then hit <b>Meta-I</b> again to turn it back on.</p></blockquote>
<blockquote><p>You have the <i>autoindent</i> feature turned on. Hit <b>Meta-I</b> to turn it off, paste your text, and then hit <b>Meta-I</b> again to turn it back on.</p>
<p><i>Update:</i> Since version 4.8, nano will suppress auto-indentation during a paste, so you no longer need to toggle it off and on manually.</p></blockquote>
<h3><a name="4.7"></a>4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</h3>
<blockquote><p>When pasting from Windows, in some situations linefeeds are sent instead of carriage returns (Enters). And linefeeds are <b>^J</b>s, which make nano justify (rewrap) the current paragraph. To prevent these linefeeds from causing these unwanted justifications, add this line to your .nanorc on the remote Linux box: <b>unbind ^J main</b> or <b>bind ^J enter main</b>, depending on whether the paste contains CR + LF or only LF.</p></blockquote>
<blockquote><p>When pasting from Windows, in some situations linefeeds are sent instead of carriage returns (Enters). And linefeeds are <b>^J</b>s, which make nano justify (rewrap) the current paragraph. To prevent these linefeeds from causing these unwanted justifications, add this line to your .nanorc on the remote Linux box: <b>unbind ^J main</b> or <b>bind ^J enter main</b>, depending on whether the paste contains CR + LF or only LF.</p>
<p><i>Update:</i> Since version 4.8, nano will ignore linefeed characters in a paste, so you no longer need the above workaround.</p></blockquote>
<h3><a name="4.8"></a>4.8. I've compiled nano with color support, but I don't see any color when I run it!</h3>
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9">3.9</a>.</p></blockquote>
<h3><a name="4.9"></a>4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</h3>
@@ -203,8 +211,8 @@
<b>[ ] enable-alternate-editor-implicitly</b></p>
<p>Then exit (<b>E</b>) and select Yes (<b>Y</b>).</p>
<p>If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
<p><b>my_hdr X-Composer: nano x.y.z</b></p>
<p>Again, replace x.y.z with the version of nano you use.</p></blockquote>
<p><b>my_hdr X-Composer: nano-x.y</b></p>
<p>Again, replace x.y with the version of nano you use.</p></blockquote>
<hr width="100%">
<h1><a name="5"></a>5. Internationalization</h1>

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc.
.\" Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -16,35 +16,54 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 4.0" "March 2019"
.TH NANO 1 "version 4.8" "February 2020"
.SH NAME
nano \- Nano's ANOther editor, inspired by Pico
.SH SYNOPSIS
.B nano
.RI [ options "] [[+" line [, column "]]\ " file "]..."
.RI [ options "] [[\fB+" line [\fB, column "]] " file ]...
.sp
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
.SH NOTE
Starting with version 4.0, \fBnano\fR no longer hard-wraps an overlong
line by default, and no longer automatically adds a newline at the end
of the text if one is missing. Furthermore, it uses smooth scrolling
by default and makes use of the line below the title bar.
.SH NOTICE
Since version 4.0, \fBnano\fR by default:
.sp
.RS 4
\(bu does not automatically hard-wrap lines that become overlong,
.br
\(bu includes the line below the title bar in the editing area,
.br
\(bu does linewise (smooth) scrolling.
.RE
.sp
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
\fB\-\-finalnewline\fR, \fB\-\-jumpyscrolling\fR, and \fB\-\-emptyline\fR
(or \fB\-bfje\fR for short).
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
.SH DESCRIPTION
\fBnano\fP is a small and friendly editor. It copies the look and feel
of Pico, but is free software, and implements several features that Pico
lacks, such as: opening multiple files, scrolling per line, undo/redo,
syntax coloring, line numbering, and soft-wrapping overlong lines.
.sp
When giving a filename on the command line, the cursor can be put on a
specific line by adding the line number with a plus sign (\fB+\fR) before
the filename, and even in a specific column by adding it with a comma.
(Negative numbers count from the end of the file or line.)
The cursor can be put on the first or last occurrence of a specific string
by specifying that string after \fB+/\fR or \fB+?\fR before the filename.
The string can be made case sensitive and/or caused to be interpreted as a
regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign.
These search modes can be explicitly disabled by using the uppercase variant
of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces,
it needs to be enclosed in quotes. To give an example: to open a file at
the first occurrence of the word "Foo", one would do:
.sp
.RS 4
.BI "nano +c/Foo " file
.RE
.sp
As a special case: if instead of a filename a dash (\fB\-\fR) is given,
\fBnano\fR will read data from standard input.
@@ -57,18 +76,18 @@ Consecutive \fB^K\fRs will put all deleted lines together in the cutbuffer.
Any cursor movement or executing any other command will cause the next
\fB^K\fR to overwrite the cutbuffer. A \fB^U\fR will paste the current
contents of the cutbuffer at the current cursor position.
.PP
.sp
When a more precise piece of text needs to be cut or copied, one can mark
its start with \fB^6\fR, move the cursor to its end (the marked text will be
highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to the
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T\fR.
.PP
.sp
On some terminals, text can be selected also by holding down Shift while
using the arrow keys. Holding down the Ctrl or Alt key too will increase
the stride.
Any cursor movement without Shift being held will cancel such a selection.
.PP
.sp
The two lines at the bottom of the screen show some important commands;
the built-in help (\fB^G\fR) lists all the available ones.
The default key bindings can be changed via a \fInanorc\fR file -- see
@@ -93,7 +112,10 @@ numbered one every time a file is saved -- when backups are enabled (\fB\-B\fR).
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
.BR \-D ", " \-\-boldtext
Use bold text instead of reverse video text.
For the interface, use bold instead of reverse video. This will be overridden
by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
\fBfunctioncolor\fP, \fBnumbercolor\fP, and/or \fBselectedcolor\fP in your
nanorc file. See \fBnanorc\fR(5).
.TP
.BR \-E ", " \-\-tabstospaces
Convert typed tabs to spaces.
@@ -123,8 +145,8 @@ properly, please report a bug. Using this option disables \fBnano\fR's
mouse support.
.TP
.BR \-L ", " \-\-nonewlines
Don't automatically add a newline when a file does not end with one.
(This is the default.)
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
.TP
.BR \-M ", " \-\-trimblanks
Snip trailing whitespace from the wrapped line when automatic
@@ -144,7 +166,7 @@ and place it at that position again upon reopening such a file.
.TP
.BR "\-Q ""\fIregex\fB""" ", " "\-\-quotestr=""" \fIregex """
Set the regular expression for matching the quoting part of a line.
The default value is \fB"^([\ \\t]*([!#%:;>|}]|//|\-\-))+"\fP.
The default value is \fB"^([\ \\t]*([!#%:;>|}]|//))+"\fP.
(Note that \fB\\t\fP stands for an actual Tab.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
@@ -213,10 +235,9 @@ system either Backspace acts like Delete or Delete acts like Backspace.
.BR \-e ", " \-\-emptyline
Do not use the line below the title bar, leaving it entirely blank.
.TP
.BR \-f ", " \-\-finalnewline
If the buffer is not empty, ensure that it ends with a newline character.
(This option is the opposite of \fB\-L\fR (\fB\-\-nonewlines\fR) --
the last one given takes effect.)
.BR \-f\ \fIfile ", " \-\-rcfile= \fIfile
Read only this \fIfile\fR for setting nano's options, instead of reading
both the system-wide and the user's nanorc files.
.TP
.BR \-g ", " \-\-showcursor
Make the cursor visible in the file browser (putting it on the
@@ -270,8 +291,9 @@ at the width of the screen minus \fInumber\fR columns, allowing the wrap
point to vary along with the width of the screen if the screen is resized.
The default value is \-8.
.TP
.BR \-s\ \fIprogram ", " \-\-speller= \fIprogram
Use this alternative spell checker command.
.B "\-s ""\fIprogram\fR [\fIargument \fR...]\fB""\fR, \fB\-\-speller=""\fIprogram\fR [\fIargument \fR...]\fB"""
Use this command to perform spell checking and correcting, instead of
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
.TP
.BR \-t ", " \-\-tempfile
Save a changed buffer without prompting (when exiting with \fB^X\fR).
@@ -288,7 +310,9 @@ unless \fB\-\-restricted\fR is given too.
.TP
.BR \-w ", " \-\-nowrap
Do not automatically hard-wrap the current line when it becomes overlong.
(This is the default.)
This is the default. (This option is the opposite of \fB\-b\fR
(\fB\-\-breaklonglines\fR) -- the last one given takes effect.)
.TP
.BR \-x ", " \-\-nohelp
Don't show the two help lines at the bottom of the screen.
@@ -310,16 +334,18 @@ separately (e.g.\& 'nano \-wS \-$').
.SH TOGGLES
Several of the above options can be switched on and off also while
\fBnano\fR is running. For example, \fBM\-L\fR toggles the
hard-wrapping of long lines, \fBM\-$\fR toggles soft-wrapping,
\fBM\-#\fR toggles line numbers, \fBM\-M\fR toggles the mouse,
hard-wrapping of long lines, \fBM\-S\fR toggles soft-wrapping,
\fBM\-N\fR toggles line numbers, \fBM\-M\fR toggles the mouse,
\fBM\-I\fR auto-indentation, and \fBM\-X\fR the help lines.
See at the end of the \fB^G\fR help text for a complete list.
.SH INITIALIZATION FILE
.SH FILES
When \fB\-\-rcfile\fR is given, \fBnano\fR will read just the specified file
for setting its options and syntaxes and key bindings. Without that option,
\fBnano\fR will read two configuration files: first the system's
\fInanorc\fR (if it exists), and then the user's \fInanorc\fR (if it
exists), either \fB~/.nanorc\fR or \fI$XDG_CONFIG_HOME\fB/nano/nanorc\fR
or \fB~/.config/nano/nanorc\fR, whichever is encountered first. See
exists), either \fI~/.nanorc\fR or \fI$XDG_CONFIG_HOME/nano/nanorc\fR
or \fI~/.config/nano/nanorc\fR, whichever is encountered first. See
.BR nanorc (5)
for more information on the possible contents of those files.
@@ -345,21 +371,16 @@ not by default distinguish modified from unmodified arrow keys.
.sp
Please report any other bugs that you encounter via:
.br
\fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
.IR https://savannah.gnu.org/bugs/?group=nano .
.sp
When nano crashes, it will save any modified buffers to emergency .save files.
If you are able to reproduce the crash and you want to get a backtrace, define
the environment variable \fBNANO_NOCATCH\fR.
.SH HOMEPAGE
\fIhttps://nano\-editor.org/\fR
.I https://nano\-editor.org/
.SH SEE ALSO
.BR nanorc (5)
.PP
.sp
\fI/usr/share/doc/nano/\fP (or equivalent on your system)
.SH AUTHOR
Chris Allegretta and others (see the files \fIAUTHORS\fR and
\fITHANKS\fP for details). This manual page was originally written by
Jordi Mallach for the Debian system (but may be used by others).

View File

@@ -8,8 +8,8 @@
@smallbook
@set EDITION 0.5
@set VERSION 4.0
@set UPDATED March 2019
@set VERSION 4.8
@set UPDATED February 2020
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 4.0
@subtitle version 4.8
@author Chris Allegretta
@page
@@ -33,7 +33,7 @@ This manual documents the GNU @command{nano} editor.
This manual is part of the GNU @command{nano} distribution.@*
@sp 4
Copyright @copyright{} 1999-2009, 2014-2019 Free Software Foundation, Inc.
Copyright @copyright{} 1999-2009, 2014-2020 Free Software Foundation, Inc.
@sp 1
This document is dual-licensed. You may distribute and/or modify it
@@ -57,13 +57,13 @@ You may contact the author by
e-mail: @email{chrisa@@asty.org}@*
@end titlepage
@ifnottex
@node Top
@top
This manual documents the GNU @command{nano} editor, version 4.0.
This manual documents the GNU @command{nano} editor, version 4.8.
@menu
* Introduction::
@@ -97,14 +97,13 @@ as is reasonable while offering a superset of Pico's functionality.
Pico differ.
Starting with version 4.0, @command{nano} no longer hard-wraps an overlong
line by default, and no longer automatically adds a newline at the end
of the text if one is missing. Furthermore, it uses smooth scrolling
by default and makes use of the line below the title bar.
line by default. It further uses smooth scrolling by default, and by
default includes the line below the title bar into the editing area.
If you want the old, Pico behavior back, you can use the
following options: @option{--breaklonglines}, @option{--finalnewline},
following options: @option{--breaklonglines},
@option{--jumpyscrolling}, and @option{--emptyline}
(or @option{-bfje} for short).
(or @option{-bje} for short).
Please report bugs via @url{https://savannah.gnu.org/bugs/?group=nano}.
@@ -128,13 +127,22 @@ But it is also possible to specify one or more options (see the next
section), and to edit several files in a row. Additionally, the cursor
can be put on a specific line of a file by adding the line number
with a plus sign before the filename, and even in a specific column by
adding it with a comma. So a more complete command synopsis is:
adding it with a comma.
(Negative numbers count from the end of the file or line.)
The cursor can also be put on the first or last occurrence of a specific string
by specifying that string after @code{+/} or @code{+?} before the filename.
The string can be made case sensitive and/or caused to be interpreted as a
regular expression by inserting a @code{c} and/or @code{r} after the plus sign.
These search modes can be explicitly disabled by using the uppercase variant
of those letters: @code{C} and/or @code{R}. When the string contains spaces,
it needs to be enclosed in quotes.
A more complete command synopsis thus is:
@iftex
@sp 1
@end iftex
@example
@code{nano [OPTION]@dots{} [[+LINE[,COLUMN]|+,COLUMN] FILE]@dots{}}
@code{nano [OPTION]@dots{} [[+LINE[,COLUMN]|+[crCR](/|?)STRING] FILE]@dots{}}
@end example
@iftex
@sp 1
@@ -149,6 +157,7 @@ As a special case: when instead of a filename a dash is given, @command{nano}
will read data from standard input. This means you can pipe the output of
a command straight into a buffer, and then edit it.
@node Command-line Options
@chapter Command-line Options
@@ -177,7 +186,10 @@ The uniquely numbered files are stored in the specified directory.
@item -D
@itemx --boldtext
Use bold text instead of reverse video text.
For the interface, use bold instead of reverse video. This will be overridden
by setting the options @code{titlecolor}, @code{statuscolor}, @code{keycolor},
@code{functioncolor}, @code{numbercolor}, and/or @code{selectedcolor} in your
nanorc file. @xref{@code{set functioncolor}} for details.
@item -E
@itemx --tabstospaces
@@ -215,8 +227,8 @@ mouse support.
@item -L
@itemx --nonewlines
Don't automatically add a newline when a file does not end with one.
(This is the default.)
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
@item -M
@itemx --trimblanks
@@ -241,7 +253,7 @@ and place it at that position again upon reopening such a file.
@item -Q "@var{regex}"
@itemx --quotestr="@var{regex}"
Set the regular expression for matching the quoting part of a line.
The default value is @t{"^([@w{ }\t]*([!#%:;>|@}]|//|--))+"}.
The default value is @t{"^([@w{ }\t]*([!#%:;>|@}]|//))+"}.
(Note that @code{\t} stands for a literal Tab character.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
@@ -325,11 +337,10 @@ system either Backspace acts like Delete or Delete acts like Backspace.
@itemx --emptyline
Do not use the line below the title bar, leaving it entirely blank.
@item -f
@itemx --finalnewline
If the buffer is not empty, ensure that it ends with a newline character.
(This option is the opposite of @option{-L} (@option{--nonewlines}) ---
the last one given takes effect.)
@item -f @var{file}
@itemx --rcfile=@var{file}
Read only this @var{file} for setting nano's options, instead of reading
both the system-wide and the user's nanorc files.
@item -g
@itemx --showcursor
@@ -395,13 +406,14 @@ point to vary along with the width of the screen if the screen is resized.
The default value is @t{-8}.
@anchor{@option{--speller}}
@item -s @var{program}
@itemx --speller=@var{program}
@item -s "@var{program} [@var{argument} @dots{}]"
@itemx --speller="@var{program} [@var{argument} @dots{}]"
Use the given program to do spell checking and correcting. By default,
@command{nano} uses the command specified in the @env{SPELL} environment
variable. If @env{SPELL} is not set, and @option{--speller} is
not specified either, then @command{nano} uses its own interactive spell
corrector, which requires the GNU @command{spell} program to be installed.
corrector, which requires either @command{hunspell} or GNU @command{spell}
to be installed.
@item -t
@itemx --tempfile
@@ -426,9 +438,10 @@ file permissions to implement a read-only file.)
@item -w
@itemx --nowrap
Do not automatically hard-wrap the current line when it becomes overlong.
(This is the default.)
This is the default. (This option is the opposite of @option{-b}
(@option{--breaklonglines}) --- the last one given takes effect.)
@anchor{Expert Mode}
@item -x
@itemx --nohelp
Expert Mode: don't show the Shortcut List at the bottom of the screen.
@@ -611,6 +624,7 @@ The recording and playback of keyboard macros works correctly only on a
terminal emulator, not on a Linux console (VT), because the latter does
not by default distinguish modified from unmodified arrow keys.
@node Built-in Help
@chapter Built-in Help
@@ -643,19 +657,22 @@ The following global toggles are available:
@kbd{Meta-K} toggles the @option{-k} (@option{--cutfromcursor}) command-line option.
@item Long-Line Wrapping
@kbd{Meta-L} toggles the @option{-w} (@option{--nowrap}) command-line option.
@kbd{Meta-L} toggles the @option{-b} (@option{--breaklonglines}) command-line option.
@item Mouse Support
@kbd{Meta-M} toggles the @option{-m} (@option{--mouse}) command-line option.
@item Line Numbers
@kbd{Meta-N} toggles the @option{-l} (@option{--linenumbers}) command-line option.
@item Tabs To Spaces
@kbd{Meta-O} toggles the @option{-E} (@option{--tabstospaces}) command-line option.
@item Whitespace Display
@kbd{Meta-P} toggles the displaying of whitespace (@pxref{Whitespace}).
@item Smooth Scrolling
@kbd{Meta-S} toggles the @option{-S} (@option{--smooth}) command-line option.
@item Soft Wrapping
@kbd{Meta-S} toggles the @option{-$} (@option{--softwrap}) command-line option.
@item Expert/No Help
@kbd{Meta-X} toggles the @option{-x} (@option{--nohelp}) command-line option.
@@ -667,12 +684,6 @@ The following global toggles are available:
@item Suspension
@kbd{Meta-Z} toggles the @option{-z} (@option{--suspend}) command-line option.
@item Line Numbers
@kbd{Meta-#} toggles the @option{-l} (@option{--linenumbers}) command-line option.
@item Soft Wrapping
@kbd{Meta-$} toggles the @option{-$} (@option{--softwrap}) command-line option.
@end table
@@ -681,16 +692,20 @@ The following global toggles are available:
The nanorc files contain the default settings for @command{nano}. They
should be in Unix format, not in DOS or Mac format. During startup,
@command{nano} will first read the system-wide settings, from /etc/nanorc
(the exact path might be different), and then the user-specific settings,
if @option{--rcfile} is not given, @command{nano} will read two files:
first the system-wide settings, from @file{/etc/nanorc} (the exact path
might be different on your system), and then the user-specific settings,
either from @file{~/.nanorc} or from @file{$XDG_CONFIG_HOME/nano/nanorc}
or from @file{.config/nano/nanorc}, whichever exists first.
If @option{--rcfile} is given, @command{nano} will read just the
specified settings file.
A nanorc file accepts a series of "set" and "unset" commands, which can
be used to configure @command{nano} on startup without using command-line
options. Additionally, there are some commands to define syntax highlighting
and to rebind keys --- @pxref{Syntax Highlighting} and @ref{Rebinding Keys}.
@command{nano} will read one command per line.
All commands and keywords should be written in lowercase.
Options in nanorc files take precedence over @command{nano}'s defaults, and
command-line options override nanorc settings. Also, options that do not
@@ -698,10 +713,8 @@ take an argument are unset by default. So using the @code{unset} command
is only needed when wanting to override a setting of the system's nanorc
file in your own nanorc. Options that take an argument cannot be unset.
Quotes inside string parameters don't have to be escaped with
backslashes. The last double quote in the string will be treated as its
end. For example, for the @code{brackets} option, @t{""')>]@}"} will match
@code{"}, @code{'}, @code{)}, @code{>}, @code{]}, and @code{@}}.
Quotes inside the @var{characters} parameters below should not be escaped.
The last double quote on the line will be seen as the closing quote.
@menu
* Settings::
@@ -745,11 +758,11 @@ The uniquely numbered files are stored in the specified directory.
@item set boldtext
Use bold instead of reverse video for the title bar, status bar, key combos,
function tags, line numbers, and selected text. This can be overridden by
function tags, line numbers, and selected text. This is overridden by
setting the options @code{titlecolor}, @code{statuscolor}, @code{keycolor},
@code{functioncolor}, @code{numbercolor}, and @code{selectedcolor}.
@code{functioncolor}, @code{numbercolor}, and/or @code{selectedcolor}.
@item set brackets "@var{string}"
@item set brackets "@var{characters}"
Set the characters treated as closing brackets when justifying
paragraphs. This may not include blank characters. Only closing
punctuation (see @code{set punct}), optionally followed by the specified
@@ -774,11 +787,9 @@ Do not use the line below the title bar, leaving it entirely blank.
@item set errorcolor @var{fgcolor},@var{bgcolor}
Use this color combination for the status bar when an error message is displayed.
The default value is @t{brightwhite,red}.
@xref{@code{set functioncolor}} for valid color names.
@item set finalnewline
If the buffer is not empty, ensure that it ends with a newline character.
@item set fill @var{number}
Set the target width for justifying and automatic hard-wrapping at this
@var{number} of columns. If the value is 0 or less, wrapping will occur
@@ -797,6 +808,10 @@ Valid names for foreground and background color are:
The name of the foreground color may be prefixed with @code{bright}.
And either @var{fgcolor} or ,@var{bgcolor} may be left out.
@item set guidestripe @var{number}
Draw a vertical stripe at the given column, to help judge the width of the
text. (The color of the stripe can be changed with @code{set stripecolor}.)
@item set historylog
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
@@ -815,11 +830,7 @@ Display line numbers to the left of the text area.
@item set locking
Enable vim-style lock-files for when editing files.
@item set guidestripe @var{number}
Draw a vertical stripe at the given column, to help judge the width of the
text. (The color of the stripe can be changed with @code{set stripecolor}.)
@item set matchbrackets "@var{string}"
@item set matchbrackets "@var{characters}"
Set the opening and closing brackets that can be found by bracket
searches. This may not include blank characters. The opening set must
come before the closing set, and the two sets must be in the same order.
@@ -843,12 +854,11 @@ Don't convert files from DOS/Mac format.
Don't display the help lists at the bottom of the screen.
@item set nonewlines
Deprecated option since it has become the default setting.
When needed, use @code{unset finalnewline} instead.
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
@item set nopauses
Don't pause between warnings at startup. This means that only
the last one will be visible (when there are multiple ones).
Obsolete option. Ignored.
@item set nowrap
Deprecated option since it has become the default setting.
@@ -871,7 +881,7 @@ The cursor position is remembered for the 200 most-recently edited files.
@item set preserve
Preserve the XON and XOFF keys (@kbd{^Q} and @kbd{^S}).
@item set punct "@var{string}"
@item set punct "@var{characters}"
Set the characters treated as closing punctuation when justifying
paragraphs. This may not include blank characters. Only the
specified closing punctuation, optionally followed by closing brackets
@@ -884,7 +894,7 @@ keystroke instead of 25. Note that @option{constantshow} overrides this.
@item set quotestr "@var{regex}"
Set the regular expression for matching the quoting part of a line.
The default value is @t{"^([@w{ }\t]*([!#%:;>|@}]|//|--))+"}.
The default value is @t{"^([@w{ }\t]*([!#%:;>|@}]|//))+"}.
(Note that @code{\t} stands for a literal Tab character.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
@@ -901,7 +911,8 @@ and Delete work properly. You should only use this option when on your
system either Backspace acts like Delete or Delete acts like Backspace.
@item set regexp
Do extended regular expression searches by default.
Do regular-expression searches by default.
Regular expressions in @command{nano} are of the extended type (ERE).
@item set selectedcolor @var{fgcolor},@var{bgcolor}
Use this color combination for selected text.
@@ -926,7 +937,7 @@ When needed, use @code{unset jumpyscrolling} instead.
@item set softwrap
Enable soft line wrapping for easier viewing of very long lines.
@item set speller "@var{program}"
@item set speller "@var{program} [@var{argument} @dots{}]"
Use the given program to do spell checking and correcting.
@xref{@option{--speller}} for details.
@@ -970,7 +981,7 @@ This mode allows the user to open also other files for viewing,
unless @option{--restricted} is given on the command line.
@anchor{Whitespace}
@item set whitespace "@var{string}"
@item set whitespace "@var{characters}"
Set the two characters used to indicate the presence of tabs and
spaces. They must be single-column characters. The default pair
for a UTF-8 locale is @t{"»·"}, and for other locales @t{">."}.
@@ -979,7 +990,7 @@ for a UTF-8 locale is @t{"»·"}, and for other locales @t{">."}.
Detect word boundaries differently by treating punctuation
characters as part of a word.
@item set wordchars "@var{string}"
@item set wordchars "@var{characters}"
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words. This overrides the option
@code{wordbounds}.
@@ -1000,6 +1011,20 @@ powerful enough to fully parse a file. Nevertheless, regular
expressions can do a lot and are easy to make, so they are a
good fit for a small editor like @command{nano}.
All regular expressions in @command{nano} are POSIX extended regular expressions
(ERE). This means that @code{.}, @code{?}, @code{*}, @code{+}, @code{^},
@code{$}, and several other characters are special.
The period @code{.} matches any single character,
@code{?} means the preceding item is optional,
@code{*} means the preceding item may be matched zero or more times,
@code{+} means the preceding item must be matched one or more times,
@code{^} matches the beginning of a line, and @code{$} the end,
@code{\<} matches the start of a word, and @code{\>} the end,
and @code{\s} matches a blank.
It also means that lookahead and lookbehind are not possible.
A complete explanation can be found in the manual of GNU grep:
@code{info grep regular}.
A separate syntax can be defined for each kind of file
via the following commands in a nanorc file:
@@ -1018,7 +1043,7 @@ activated by using the @option{-Y} or @option{--syntax}
command-line option followed by the @var{name}.
The @code{default} syntax is special: it takes no @var{fileregex},
and applies to files that don't match any syntax's @var{fileregex}.
and applies to files that don't match any syntax's regexes.
The @code{none} syntax is reserved; specifying it on the
command line is the same as not having a syntax at all.
@@ -1035,7 +1060,13 @@ file, to determine whether this syntax should be used for it.
(This functionality only works when @code{libmagic} is installed
on the system and will be silently ignored otherwise.)
@item linter @var{program} [@var{arg} @dots{}]
@item formatter @var{program} [@var{argument} @dots{}]
Run the given @var{program} on the full contents of the current buffer.
(The current buffer is written out to a temporary file, the program is
run on it, and then the temporary file is read back in, replacing the
contents of the buffer.)
@item linter @var{program} [@var{argument} @dots{}]
Use the given @var{program} to do a syntax check on the current buffer.
@item comment "@var{string}"
@@ -1049,26 +1080,33 @@ Python files. If empty double quotes are specified, the comment/uncomment
functions are disabled; for example, @t{""} for JSON.
The default value is @t{"#"}.
@item tabgives "@var{string}"
Make the <Tab> key produce the given @var{string}. Useful for languages like
Python that want to see only spaces for indentation.
This overrides the setting of the @code{tabstospaces} option.
@item color @var{fgcolor},@var{bgcolor} "@var{regex}" @dots{}
Display all pieces of text that match the
extended regular expression "regex" with foreground color "fgcolor" and
background color "bgcolor", at least one of which must be specified.
Valid names for foreground and background color are:
Paint all pieces of text that match the extended regular expression "regex"
with the given foreground and background colors, at least one of which must
be specified. Valid color names are:
@code{white}, @code{black}, @code{blue}, @code{green},
@code{red}, @code{cyan}, @code{yellow}, @code{magenta}, and @code{normal}
--- where @code{normal} means the default foreground or background color.
You may use the prefix @code{bright}
to get a stronger color highlight for the foreground. If your
terminal supports transparency, not specifying a "bgcolor" tells @command{nano}
to attempt to use a transparent background.
You may use the prefix @code{bright} for the foreground color to get a
stronger highlight.
If your terminal supports transparency, not specifying a "bgcolor"
tells @command{nano} to attempt to use a transparent background.
All coloring commands are applied in the order in which they are specified,
which means that later commands can recolor stuff that was colored earlier.
@item icolor @var{fgcolor},@var{bgcolor} "@var{regex}" @dots{}
Same as above, except that the matching is case insensitive.
@item color @var{fgcolor},@var{bgcolor} start="@var{fromrx}" end="@var{torx}"
Display all pieces of text whose start matches extended regular expression
Paint all pieces of text whose start matches extended regular expression
"fromrx" and whose end matches extended regular expression "torx" with
foreground color "fgcolor" and background color "bgcolor", at least one of
the given foreground and background colors, at least one of
which must be specified. This means that, after an initial instance of
"fromrx", all text until the first instance of "torx" will be colored.
This allows syntax highlighting to span multiple lines.
@@ -1081,31 +1119,16 @@ Read in self-contained color syntaxes from "syntaxfile". Note that
"syntaxfile" may contain only the above commands, from @code{syntax}
to @code{icolor}.
@item extendsyntax @var{name} @var{command} [@var{arg} @dots{}]
@item extendsyntax @var{name} @var{command} @var{argument} @dots{}
Extend the syntax previously defined as "@var{name}" with another @var{command}.
This allows you to add a new @code{color}, @code{icolor}, @code{header},
@code{magic}, @code{comment}, or @code{linter} command to an already
@code{magic}, @code{formatter}, @code{linter}, @code{comment},
or @code{tabgives} command to an already
defined syntax --- useful when you want to slightly improve a syntax defined
in one of the system-installed files (which normally are not writable).
@end table
Note: the @code{formatter} command has been removed. It was superseded by
a more general mechanism: the filtering of buffer or marked text through
an external command. Such filtering is done by typing @code{^R^X} and then
preceding your formatter command with the pipe symbol (@code{|}). It has
the added advantage that the operation can be undone.
If you use such a formatting command regularly, you could assign the relevant
series of keystrokes to a single key in your nanorc:
@example
bind M-F "^R^X|yourformatcommand^M" main
@end example
(Note that the @key{^R}, @key{^X}, and @key{^M} are each a single, literal
control character. You can enter them by preceding each with @key{M-V}.)
@node Rebinding Keys
@section Rebinding Keys
@@ -1116,7 +1139,7 @@ nanorc file:
@item bind key function menu
Rebinds @code{key} to @code{function} in the context of @code{menu}
(or in all menus where the function exists by using @code{all}).
(or in all menus where the function exists when @code{all} is used).
@item bind key "string" menu
Makes @code{key} produce @code{string} in the context of @code{menu}
@@ -1127,7 +1150,7 @@ with @kbd{M-V}.)
@item unbind key menu
Unbinds @code{key} from @code{menu}
(or from all menus where it exists by using @code{all}).
(or from all menus where the key exists when @code{all} is used).
@end table
@@ -1136,22 +1159,36 @@ The format of @code{key} should be one of:
@itemize @w{}
@item
@code{^}@ followed by a Latin letter, by one of several ASCII characters
(@@, ], \, ^, or _), or by the word "Space".
@code{^@var{X}} ------ where @var{X} is a Latin letter, or one of several
ASCII characters (@@, ], \, ^, _), or the word "Space".
Example: @code{^C}.
@item
@code{M-}@ followed by any ASCII character except [, or by the word "Space".
Example: @code{M-C}.
@code{M-@var{X}} ------ where @var{X} is any ASCII character except [,
or the word "Space".
Example: @code{M-8}.
@item
@code{F}@ followed by a numeric value from 1 to 16.
@code{Sh-M-@var{X}} ------ where @var{X} is a Latin letter.
Example: @code{Sh-M-U}.
By default, each Meta+letter keystroke does the same as the corresponding
Shift+Meta+letter. But when any Shift+Meta bind is made, that will
no longer be the case, for all letters.
@item
@code{F@var{n}} ------ where @var{n} is a numeric value from 1 to 24.
Example: @code{F10}.
(Often, @code{F13} to @code{F24} can be typed as @code{F1} to @code{F12}
with Shift.)
@item
the word "Ins" or the word "Del".
@code{Ins} or @code{Del}.
@end itemize
Rebinding @code{^M} (Enter) or @code{^I} (Tab) is probably not a good idea.
On some terminals it's not possible to rebind @code{^H} (unless @code{--raw}
is used) because its keycode is identical to that of the Backspace key.
@sp 1
Valid names for the @code{function} to be bound are:
@@ -1231,8 +1268,12 @@ Shows the current cursor position: the line, column, and character positions.
Counts the number of words, lines and characters in the current buffer.
@item speller
Invokes a spell-checking program, either the default one, or the one
defined by @option{--speller} or @code{set speller}.
Invokes a spell-checking program, either the default @command{hunspell}
or GNU @command{spell}, or the one defined by @option{--speller} or
@code{set speller}.
@item formatter
Invokes a full-buffer-processing program (if the active syntax defines one).
@item linter
Invokes a syntax-checking program (if the active syntax defines one).
@@ -1442,9 +1483,6 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
@item constantshow
Toggles the constant display of the current line, column, and character positions.
@item smoothscroll
Toggles smooth scrolling (when moving around with the arrow keys).
@item softwrap
Toggles the displaying of overlong lines on multiple screen lines.
@@ -1519,7 +1557,7 @@ The menu for inserting output from an external command, reached from the insert
The help-viewer menu.
@item spell
The interactive spell checker Yes/no menu.
The menu of the integrated spell checker where the user can edit a misspelled word.
@item linter
The linter menu.
@@ -1576,17 +1614,11 @@ switched on with the @option{--breaklonglines} option. With that option,
whereas Pico does it at screen width minus six columns. You can make
@command{nano} do as Pico by using @option{--fill=-6}.
@item Magic Newline
Pico ensures that any text always ends with a newline character.
Nano does not do this by default: the user is left in full control
of the formatting. You can get the automatic newline by using the
@option{--finalnewline} option.
@item Scrolling
By default, @command{nano} will scroll just one line (instead of half
a screen) when the cursor is moved to a line that is just out of view.
And when paging up or down, @command{nano} keeps the cursor in the same
screen position as much as possible, instead always placing it on the
screen position as much as possible, instead of always placing it on the
first line of the viewport. The Pico-like behavior can be obtained
with the @option{--jumpyscrolling} option.
@@ -1683,54 +1715,54 @@ The possible options to @code{./configure} are:
@table @code
@item --disable-browser
Disable the mini file browser that can be called with @kbd{^T} when reading
or writing files.
Exclude the mini file browser that can be called with @kbd{^T} when
wanting to read or write a file.
@item --disable-color
Disable support for the syntax coloring of files. This also eliminates
the @option{-Y} command-line option, which chooses a specific syntax.
Exclude support for syntax coloring. This also eliminates the @option{-Y}
command-line option, which allows choosing a specific syntax.
@item --disable-comment
Disable the single-keystroke comment/uncomment function (@kbd{M-3}).
Exclude the single-keystroke comment/uncomment function (@kbd{M-3}).
@item --disable-extra
Disable the Easter egg: a crawl of major contributors.
Exclude the Easter egg: a crawl of major contributors.
@item --disable-help
Disable the help function. Doing this makes the binary much smaller,
but makes it difficult for new users to learn more than very basic
Exclude the help texts (@kbd{^G}). This makes the binary much smaller,
but also makes it difficult for new users to learn more than very basic
things about using the editor.
@item --disable-histories
Disable the code for the handling of the history files: the search and
Exclude the code for handling the history files: the search and
replace strings that were used, and the cursor position at which each
file was closed. This also eliminates the @option{-H} and @option{-P}
command-line options, which switch on the logging of search/replace
strings and cursor positions.
@item --disable-justify
Disable the justify and unjustify functions.
Exclude the justify functions (@kbd{^J} and @kbd{M-J}).
@item --disable-libmagic
Disable the use of the library of magic-number tests (for determining
the file type and thus which syntax to use for colouring --- often the
tests on filename extension and header line will be enough).
Exclude the code for using the library of magic-number tests (for determining
the file type and thus which syntax to use for coloring --- often the regexes
for filename and header line will be enough).
@item --disable-linenumbers
Disable the line-numbering function (@kbd{M-#}). This also eliminates the
Exclude the line-numbering function (@kbd{M-N}). This also eliminates the
@option{-l} command-line option, which turns line numbering on.
@item --disable-mouse
Disable all mouse functionality. This also eliminates the @option{-m}
Exclude all mouse functionality. This also eliminates the @option{-m}
command-line option, which enables the mouse functionality.
@item --disable-multibuffer
Disable support for opening multiple files at a time and switching
Exclude support for opening multiple files at a time and switching
between them on the fly. This also eliminates the @option{-F} command-line
option, which causes a file to be read into a separate buffer by default.
@item --disable-nanorc
Disable support for reading the nanorc files at startup. With such
Exclude support for reading the nanorc files at startup. With such
support, you can store custom settings in a system-wide and a per-user
nanorc file rather than having to pass command-line options to get
the desired behavior. @xref{Nanorc Files} for more info.
@@ -1738,22 +1770,23 @@ Disabling this also eliminates the @option{-I} command-line option,
which inhibits the reading of nanorc files.
@item --disable-operatingdir
Disable setting the operating directory. This also eliminates the @option{-o}
command-line option, which sets the operating directory.
Exclude the code for setting the operating directory. This also eliminates
the @option{-o} command-line option, which sets the operating directory.
@item --disable-speller
Disable use of the spell checker. This also eliminates the @option{-s}
Exclude the code for spell checking. This also eliminates the @option{-s}
command-line option, which allows specifying an alternate spell checker.
@item --disable-tabcomp
Disable tab completion (when nano asks for a filename or a search string).
Exclude tab completion (when nano asks for a filename or a search string).
@item --disable-wordcomp
Disable word completion (@kbd{^]}).
Exclude word completion (@kbd{^]}).
@item --disable-wrapping
Disable all hard-wrapping of overlong lines. This also eliminates the
@option{-w} command-line option, which switches long-line wrapping off.
Exclude all hard-wrapping of overlong lines. This also eliminates the
@option{-b} and @option{-w} command-line options, which switch automatic
long-line wrapping on and off, respectively.
@item --enable-tiny
This option implies all of the above. It also disables some other
@@ -1763,19 +1796,19 @@ counterpart of the above options together with @option{--enable-tiny},
specific features can be switched back on --- but a few cannot.
@item --enable-debug
Enable support for runtime debug output. This can get pretty messy, so
Include some code for runtime debugging output. This can get pretty messy, so
chances are you only want this feature when you're working on the nano source.
@item --disable-nls
Disables Native Language support. This will disable the use of any
Exclude Native Language support. This will disable the use of any
available GNU @command{nano} translations.
@item --enable-utf8
Enable support for reading and writing Unicode files. This will require
Include support for reading and writing Unicode files. This will require
either a wide version of curses, or a UTF-8-enabled version of Slang.
@item --disable-utf8
Disable support for reading and writing Unicode files. Normally the
Exclude support for reading and writing Unicode files. Normally the
configure script auto-detects whether to enable UTF-8 support or not.
You can use this or the previous option to override that detection.

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2003-2011, 2013-2019 Free Software Foundation, Inc.
.\" Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -16,28 +16,36 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 4.0" "March 2019"
.TH NANORC 5 "version 4.8" "February 2020"
.SH NAME
nanorc \- GNU nano's configuration file
.SH NOTE
Starting with version 4.0, \fBnano\fR no longer hard-wraps an overlong
line by default, and no longer automatically adds a newline at the end
of the text if one is missing. Furthermore, it uses smooth scrolling
by default and makes use of the line below the title bar.
.sp
If you want the old, Pico behavior back, you can use \fBset breaklonglines\fR,
\fBset finalnewline\fR, \fBset jumpyscrolling\fR, and \fBset emptyline\fR.
.SH DESCRIPTION
The \fInanorc\fP file contains the default settings for \fBnano\fP, a
small and friendly editor. The file should be in Unix format, not in
DOS or Mac format. During startup, \fBnano\fP will first read the
system-wide settings, from \fB/etc/nanorc\fP (the exact path might be
The \fInanorc\fP files contain the default settings for \fBnano\fP, a
small and friendly editor. They should be in Unix format, not in
DOS or Mac format. During startup, if \fB\-\-rcfile\fR is not given,
\fBnano\fR will read two files: first the
system-wide settings, from \fI/etc/nanorc\fP (the exact path might be
different on your system), and then the user-specific settings, either
from \fB~/.nanorc\fR or from \fI$XDG_CONFIG_HOME\fB/nano/nanorc\fR
or from \fB~/.config/nano/nanorc\fR, whichever is encountered first.
from \fI~/.nanorc\fR or from \fI$XDG_CONFIG_HOME/nano/nanorc\fR
or from \fI~/.config/nano/nanorc\fR, whichever is encountered first.
If \fB\-\-rcfile\fR is given, \fBnano\fR will read just the specified
settings file.
.SH NOTICE
Since version 4.0, \fBnano\fR by default:
.sp
.RS 4
\(bu does not automatically hard-wrap lines that become overlong,
.br
\(bu includes the line below the title bar in the editing area,
.br
\(bu does linewise (smooth) scrolling.
.RE
.sp
To get the old, Pico behavior back, you can use \fBset breaklonglines\fR,
\fBset emptyline\fR, and \fBset jumpyscrolling\fR.
.SH OPTIONS
The configuration file accepts a series of \fBset\fP and \fBunset\fP
@@ -45,20 +53,18 @@ commands, which can be used to configure nano on startup without using
command-line options. Additionally, there are some commands to define
syntax highlighting and to rebind keys -- see the two separate sections
on those. \fBnano\fP reads one command per line.
.PP
All commands and keywords should be written in lowercase.
.sp
Options in \fInanorc\fP files take precedence over nano's defaults, and
command-line options override \fInanorc\fP settings. Also, options that
do not take an argument are unset by default. So using the \fBunset\fR
command is only needed when wanting to override a setting of the system's
\fInanorc\fR file in your own \fInanorc\fR. Options that take an
argument cannot be unset.
.PP
Below, the \fIstring\fR parameters need to be enclosed in double quotes.
Quotes inside these string parameters don't have to be escaped with
backslashes. The last double quote in the string will be treated as its
end. For example, for the \fBbrackets\fP option, "\fB"')>]}\fP" will
match \fB"\fP, \fB'\fP, \fB)\fP, \fB>\fP, \fB]\fP, and \fB}\fP.
.PP
.sp
Quotes inside the \fIcharacters\fR parameters below should not be escaped.
The last double quote on the line will be seen as the closing quote.
.sp
The supported commands and arguments are:
.TP 3
@@ -95,7 +101,7 @@ function tags, line numbers, and selected text. This can be overridden by
setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
\fBfunctioncolor\fP, \fBnumbercolor\fP, and \fBselectedcolor\fP.
.TP
.B set brackets "\fIstring\fP"
.BI "set brackets """ characters """
Set the characters treated as closing brackets when justifying
paragraphs. This may not include blank characters. Only closing
punctuation (see \fBset punct\fP), optionally followed by the specified
@@ -119,23 +125,25 @@ Do not use the line below the title bar, leaving it entirely blank.
.TP
.B set errorcolor \fIfgcolor\fR,\fIbgcolor\fR
Use this color combination for the status bar when an error message is displayed.
The default value is \fBbrightwhite,red\fR.
See \fBset titlecolor\fR for valid color names.
.TP
.B set finalnewline
If the buffer is not empty, ensure that it ends with a newline character.
.TP
.B set fill \fInumber\fR
Set the target width for justifying and automatic hard-wrapping at this
\fInumber\fR of columns. If the value is 0 or less, wrapping will occur
at the width of the screen minus \fInumber\fR columns, allowing the wrap
point to vary along with the width of the screen if the screen is resized.
The default value is \-8.
The default value is \fB\-8\fR.
.TP
.B set functioncolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the function descriptions
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
.B set guidestripe \fInumber
Draw a vertical stripe at the given column, to help judge the width of the
text. (The color of the stripe can be changed with \fBset stripecolor\fR.)
.TP
.B set historylog
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
@@ -154,11 +162,7 @@ Display line numbers to the left of the text area.
.B set locking
Enable vim-style lock-files for when editing files.
.TP
.B set guidestripe \fInumber
Draw a vertical stripe at the given column, to help judge the width of the
text. (The color of the stripe can be changed with \fBset stripecolor\fR.)
.TP
.B set matchbrackets "\fIstring\fP"
.BI "set matchbrackets """ characters """
Set the opening and closing brackets that can be found by bracket
searches. This may not include blank characters. The opening set must
come before the closing set, and the two sets must be in the same order.
@@ -185,12 +189,11 @@ Don't convert files from DOS/Mac format.
Don't display the two help lines at the bottom of the screen.
.TP
.B set nonewlines
Deprecated option since it has become the default setting.
When needed, use \fBunset finalnewline\fR instead.
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
.TP
.B set nopauses
Don't pause between warnings at startup. This means that only
the last one will be visible (when there are multiple ones).
Obsolete option. Ignored.
.TP
.B set nowrap
Deprecated option since it has become the default setting.
@@ -213,7 +216,7 @@ The cursor position is remembered for the 200 most-recently edited files.
.B set preserve
Preserve the XON and XOFF keys (^Q and ^S).
.TP
.B set punct "\fIstring\fP"
.BI "set punct """ characters """
Set the characters treated as closing punctuation when justifying
paragraphs. This may not include blank characters. Only the
specfified closing punctuation, optionally followed by closing brackets
@@ -223,9 +226,9 @@ specfified closing punctuation, optionally followed by closing brackets
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. The option \fBconstantshow\fR overrides this.
.TP
.B set quotestr "\fIregex\fP"
.BI "set quotestr """ regex """
Set the regular expression for matching the quoting part of a line.
The default value is "\fB^([\ \\t]*([!#%:;>|}]|//|\-\-))+\fP".
The default value is "\fB^([\ \\t]*([!#%:;>|}]|//))+\fP".
(Note that \fB\\t\fR stands for an actual Tab character.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
@@ -242,7 +245,8 @@ and Delete work properly. You should only use this option when on your
system either Backspace acts like Delete or Delete acts like Backspace.
.TP
.B set regexp
Do extended regular expression searches by default.
Do regular-expression searches by default.
Regular expressions in \fBnano\fR are of the extended type (ERE).
.TP
.B set selectedcolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for selected text.
@@ -266,9 +270,9 @@ When needed, use \fBunset jumpyscrolling\fR instead.
.B set softwrap
Enable soft line wrapping for easier viewing of very long lines.
.TP
.B set speller "\fIprogram\fP"
Use the given \fIprogram\fR to do spell checking and correcting,
instead of the built-in corrector that calls \fBspell\fR.
.B set speller """\fIprogram\fR [\fIargument \fR...]\fB"""
Use the given \fIprogram\fR to do spell checking and correcting, instead of
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
.TP
.B set statuscolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the status bar.
@@ -314,7 +318,7 @@ Disallow file modification: read-only mode.
This mode allows the user to open also other files for viewing,
unless \fB\-\-restricted\fR is given on the command line.
.TP
.B set whitespace "\fIstring\fP"
.BI "set whitespace """ characters """
Set the two characters used to indicate the presence of tabs and
spaces. They must be single-column characters. The default pair
for a UTF-8 locale is "\fB\[Fc]\[md]\fR", and for other locales "\fB>.\fR".
@@ -323,7 +327,7 @@ for a UTF-8 locale is "\fB\[Fc]\[md]\fR", and for other locales "\fB>.\fR".
Detect word boundaries differently by treating punctuation
characters as parts of words.
.TP
.B set wordchars \fIstring\fP
.BI "set wordchars """ characters """
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words. This overrides the option
\fBwordbounds\fR.
@@ -340,6 +344,20 @@ powerful enough to fully parse a file. Nevertheless, regular
expressions can do a lot and are easy to make, so they are a
good fit for a small editor like \fBnano\fR.
.sp
All regular expressions in \fBnano\fR are POSIX extended regular expressions.
This means that \fB.\fR, \fB?\fR, \fB*\fR, \fB+\fR, \fB^\fR, \fB$\fR, and
several other characters are special.
The period \fB.\fR matches any single character,
\fB?\fR means the preceding item is optional,
\fB*\fR means the preceding item may be matched zero or more times,
\fB+\fR means the preceding item must be matched one or more times,
\fB^\fR matches the beginning of a line, and \fB$\fR the end,
\fB\\<\fR matches the start of a word, and \fB\\>\fR the end,
and \fB\\s\fR matches a blank.
It also means that lookahead and lookbehind are not possible.
A complete explanation can be found in the manual page of GNU grep:
\fBman grep\fR.
.sp
For each kind of file a separate syntax can be defined
via the following commands:
.TP
@@ -373,7 +391,13 @@ file, to determine whether this syntax should be used for it.
(This functionality only works when \fBlibmagic\fP is installed on the
system and will be silently ignored otherwise.)
.TP
.BI linter " program " \fR[ "arg " \fR...]
.BI formatter " program " \fR[ "argument " \fR...]
Run the given \fIprogram\fR on the full contents of the current buffer.
(The current buffer is written out to a temporary file, the program is
run on it, and then the temporary file is read back in, replacing the
contents of the buffer.)
.TP
.BI linter " program " \fR[ "argument " \fR...]
Use the given \fIprogram\fR to run a syntax check on the current buffer.
.TP
.BI "comment """ string """
@@ -387,26 +411,32 @@ for Python files. If empty double quotes are specified, the comment/uncomment
function is disabled; for example, "" for JSON.
The default value is "\fB#\fP".
.TP
.BI "tabgives """ string """
Make the <Tab> key produce the given \fIstring\fR. Useful for languages like
Python that want to see only spaces for indentation.
This overrides the setting of the \fBtabstospaces\fR option.
.TP
.BI "color " fgcolor , bgcolor " """ regex """ " \fR...
Display all pieces of text that match
the extended regular expression \fIregex\fP with foreground color
\fIfgcolor\fP and background color \fIbgcolor\fP, at least one of which
must be specified. Valid names for foreground and background colors are:
Paint all pieces of text that match the extended regular expression
\fIregex\fP with the given foreground and background colors, at least
one of which must be specified. Valid color names are:
.BR white ", " black ", " blue ", " green ", " red ", "
.BR cyan ", " yellow ", " magenta ", and " normal
-- where \fBnormal\fR means the default foreground or background color.
You may use the prefix \fBbright\fR to get a stronger color highlight for the
foreground. If your terminal supports transparency, not specifying a
\fIbgcolor\fP tells \fBnano\fP to attempt to use a transparent
background.
You may use the prefix \fBbright\fR for the foreground color to get a
stronger highlight. If your terminal supports transparency, not specifying
a \fIbgcolor\fP tells \fBnano\fP to attempt to use a transparent background.
.sp
All coloring commands are applied in the order in which they are specified,
which means that later commands can recolor stuff that was colored earlier.
.TP
.BI "icolor " fgcolor , bgcolor " """ regex """ " \fR...
Same as above, except that the matching is case insensitive.
.TP
.BI "color " fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Display all pieces of text whose start matches extended regular expression
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP with
foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
Paint all pieces of text whose start matches extended regular expression
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP
with the given foreground and background colors,
at least one of which must be specified. This means that, after an
initial instance of \fIfromrx\fP, all text until the first instance of
\fItorx\fP will be colored. This allows syntax highlighting to span
@@ -420,39 +450,22 @@ Read in self-contained color syntaxes from \fIsyntaxfile\fP. Note that
\fIsyntaxfile\fP may contain only the above commands, from \fBsyntax\fP
to \fBicolor\fP.
.TP
.BI extendsyntax " name command " \fR[ "arg " \fR...]
.BI extendsyntax " name command argument " \fR...
Extend the syntax previously defined as \fIname\fR with another
\fIcommand\fR. This allows adding a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, or \fBlinter\fP
\fBheader\fR, \fBmagic\fR, \fBformatter\fR, \fBlinter\fR, \fBcomment\fR,
or \fBtabgives\fR
command to an already defined syntax -- useful when you want to
slightly improve a syntax defined in one of the system-installed
files (which normally are not writable).
.P
Note: the \fBformatter\fR command has been removed. It was superseded by
a more general mechanism: the filtering of buffer or marked text through
an external command. Such filtering is done by typing \fB^R^X\fR and then
preceding your formatter command with the pipe symbol (\fB|\fR). It has
the added advantage that the operation can be undone.
.PP
If you use such a formatting command regularly, you could assign the relevant
series of keystrokes to a single key in your nanorc:
.PP
.RS
.B "bind M\-F \(dq^R^X|yourformatcommand^M\(dq main"
.RE
.PP
(Note that the \fB^R\fR, \fB^X\fR, and \fB^M\fR are each a single, literal
control character. You can enter them by preceding each with \fBM\-V\fR.)
.SH REBINDING KEYS
Key bindings can be changed via the following three commands:
.RS 3
.TP
.BI bind " key function menu"
Rebinds the key \fIkey\fP to a new function named \fIfunction\fP in the
context of menu \fImenu\fP (or in all menus where the function exists
by using \fBall\fP).
Rebinds the given \fIkey\fP to the given \fIfunction\fP in the given \fImenu\fP
(or in all menus where the function exists when \fBall\fP is used).
.TP
.BI bind " key " """" string """" " menu"
Makes the given \fIkey\fR produce the given \fIstring\fR in the given
@@ -460,33 +473,45 @@ Makes the given \fIkey\fR produce the given \fIstring\fR in the given
The \fIstring\fR can consist of text or commands or a mix of them.
(To enter a command into the \fIstring\fR, precede its keystroke
with \fBM\-V\fR.)
.TP
.BI unbind " key menu"
Unbinds the key \fIkey\fP from the menu named \fImenu\fP (or from all
menus where it exists by using \fBall\fP).
Unbinds the given \fIkey\fP from the given \fImenu\fP (or from all
menus where the key exists when \fBall\fP is used).
.RE
.TP
The format of \fIkey\fP should be one of:
.RS 3
.TP 3
.B ^
followed by a Latin letter, by one of several ASCII characters
(@, ], \\, ^, or _), or by the word "Space".
.TP 7
.BI ^ X
where \fIX\fR is a Latin letter, or one of several ASCII characters
(@, ], \\, ^, _), or the word "Space".
Example: ^C.
.TP
.B M\-
followed by any ASCII character except [, or by the word "Space".
Example: M\-C.
.BI M\- X
where \fIX\fR is any ASCII character except [, or the word "Space".
Example: M\-8.
.TP
.B F
followed by a numeric value from 1 to 16.
.BI Sh\-M\- X
where \fIX\fR is a Latin letter.
Example: Sh\-M\-U.
By default, each Meta+letter keystroke does the same as the corresponding
Shift+Meta+letter. But when any Shift+Meta bind is made, that will
no longer be the case, for all letters.
.TP
.BI F N
where \fIN\fR is a numeric value from 1 to 24.
Example: F10.
(Often, \fBF13\fR to \fBF24\fR can be typed as \fBF1\fR to \fBF12\fR with Shift.)
.TP
the word "Ins" or the word "Del".
.BR Ins " or " Del .
.RE
Rebinding \fB^M\fR (Enter) or \fB^I\fR (Tab) is probably not a good idea.
On some terminals it's not possible to rebind \fB^H\fR (unless \fB\-\-raw\fR
is used) because its keycode is identical to that of the Backspace key.
.TP
Valid \fIfunction\fP names to be bound are:
.RS 3
@@ -565,8 +590,11 @@ Shows the current cursor position: the line, column, and character positions.
Counts the number of words, lines and characters in the current buffer.
.TP
.B speller
Invokes a spell-checking program, either the default one, or the one
defined by \fB\-\-speller\fR or \fBset speller\fR.
Invokes a spell-checking program, either the default \fBhunspell\fR or GNU
\fBspell\fR, or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
.TP
.B formatter
Invokes a full-buffer-processing program (if the active syntax defines one).
.TP
.B linter
Invokes a syntax-checking program (if the active syntax defines one).
@@ -776,9 +804,6 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
.B constantshow
Toggles the constant display of the current line, column, and character positions.
.TP
.B smoothscroll
Toggles smooth scrolling (when moving around with the arrow keys).
.TP
.B softwrap
Toggles the displaying of overlong lines on multiple screen lines.
.TP
@@ -851,7 +876,7 @@ The menu for inserting output from an external command, reached from the insert
The help-viewer menu.
.TP
.B spell
The interactive spell checker Yes/no menu.
The menu of the integrated spell checker where the user can edit a misspelled word.
.TP
.B linter
The linter menu.
@@ -873,16 +898,11 @@ for \fBunbind\fR it means all menus where the specified \fIkey\fR exists.
.SH FILES
.TP
.B /etc/nanorc
.I /etc/nanorc
System-wide configuration file.
.TP
.BR ~/.nanorc " or " \fI$XDG_CONFIG_HOME\fB/nano/nanorc " or " ~/.config/nano/nanorc
.IR ~/.nanorc " or " $XDG_CONFIG_HOME/nano/nanorc " or " ~/.config/nano/nanorc
Per-user configuration file.
.SH SEE ALSO
.BR nano (1)
.SH AUTHOR
Chris Allegretta and others (see the files \fIAUTHORS\fP and
\fITHANKS\fP for details). This manual page was originally written by
Jordi Mallach for the Debian system (but may be used by others).

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2002-2007, 2014-2019 Free Software Foundation, Inc.
.\" Copyright (C) 2002-2007, 2014-2020 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 4.0" "March 2019"
.TH RNANO 1 "version 4.8" "February 2020"
.SH NAME
rnano \- a restricted nano
@@ -29,7 +29,7 @@ rnano \- a restricted nano
\fBrnano\fR runs the \fBnano\fR editor in restricted mode. This allows
editing only the specified file or files, and doesn't allow the user
access to the filesystem nor to a command shell.
.PP
.sp
In restricted mode, \fBnano\fR will:
.IP \[bu] 2
not allow suspending;
@@ -45,20 +45,16 @@ not make backup files nor do spell checking.
.SH OPTIONS
.TP
.BR \-h ", " \-\-help
Show a summary of command-line options and exit.
.PP
See the \fBnano\fP(1) manpage for all available options.
Show the available command-line options and exit.
.P
For all existing options, see the \fBnano\fR(1) man page.
.SH BUGS
Please report bugs via \fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
Please report bugs via
.IR https://savannah.gnu.org/bugs/?group=nano .
.SH HOMEPAGE
https://nano-editor.org/
.I https://nano-editor.org/
.SH SEE ALSO
.BR nano (1)
.SH AUTHOR
Chris Allegretta and others (see the files \fIAUTHORS\fR and \fITHANKS\fR
for details). This manual page was originally written by Thijs Kinkhorst
for the Debian system (but may be used by others).

View File

@@ -8,10 +8,8 @@
## For the options that take parameters, the default value is given.
## Other options are unset by default.
##
## Quotes inside string parameters don't have to be escaped with
## backslashes. The last double quote in the string will be treated as
## its end. For example, for the "brackets" option, ""')>]}" will match
## ", ', ), >, ], and }.
## Inside string parameters, quotes should not be escaped. The last
## double quote on the line will be seen as the closing quote.
## Make the 'nextword' function (Ctrl+Right) stop at word ends
## instead of at beginnings.
@@ -56,14 +54,11 @@
## Do not use the line below the title bar, leaving it entirely blank.
# set emptyline
## Enable hard-wrapping and set the target width, both for automatic
## line wrapping and for justifying paragraphs. If the value is 0 or
## less, the wrapping point will be the screen width minus this number.
## Set the target width for automatic hard-wrapping and for justifying
## paragraphs. If the specified value is 0 or less, the wrapping point
## will be the terminal's width minus this number.
# set fill -8
## Ensure that a non-empty buffer ends with a newline character.
# set finalnewline
## Remember the used search/replace strings for the next session.
# set historylog
@@ -99,9 +94,8 @@
## Don't display the helpful shortcut lists at the bottom of the screen.
# set nohelp
## Don't pause between warnings at startup. Which means that only the
## last one will be readable (when there are multiple ones).
# set nopauses
## Don't automatically add a newline when a file does not end with one.
# set nonewlines
## Set operating directory. nano will not read or write files outside
## this directory and its subdirectories. Also, the current directory
@@ -127,7 +121,7 @@
## The regular expression that matches quoting characters in email
## or line-comment introducers in source code. The default is:
# set quotestr "^([ ]*([!#%:;>|}]|//|--))+"
# set quotestr "^([ ]*([!#%:;>|}]|//))+"
## Try to work around a mismatching terminfo terminal description.
# set rawsequences
@@ -135,7 +129,8 @@
## Fix Backspace/Delete confusion problem.
# set rebinddelete
## Do extended regular expression searches by default.
## Do regular-expression searches by default.
## Regular expressions are of the extended type (ERE).
# set regexp
## Put the cursor on the highlighted item in the file browser, and show
@@ -219,49 +214,44 @@
## Setup of syntax coloring.
##
## Format:
## syntax "name" ["filename regex" ...]
##
## syntax "short description" ["filename regex" ...]
## color|icolor foreground,background "regex" ["regex"...]
## [...]
##
## The "none" syntax is reserved; specifying it on the command line is
## the same as not having a syntax at all. The "default" syntax is
## special: it takes no filename regexes, and applies to files that
## don't match any other syntax's filename regexes.
##
## color foreground,background "regex" ["regex"...]
## or
## icolor foreground,background "regex" ["regex"...]
##
## "color" will do case-sensitive matches, while "icolor" will do
## 'color' will do case-sensitive matches, while 'icolor' will do
## case-insensitive matches.
##
## Valid color names ares: white, black, normal, red, blue, green,
## yellow, magenta, cyan. For foreground colors, you may use the
## prefix "bright" to get a stronger highlight.
## All color commands are applied in the order in which they are specified,
## meaning that later commands can recolor stuff that was colored earlier.
##
## To use multi-line regexes, use the start="regex" end="regex"
## [start="regex" end="regex"...] format.
## Valid color names for foreground and background are: white, black, normal,
## red, blue, green, yellow, magenta, cyan. For foreground colors, you may
## use the prefix "bright" to get a stronger highlight.
##
## If your system supports transparency, not specifying a background
## color will use a transparent color. If you don't want this, be sure
## to set the background color to black or white.
## All regexes (regular expressions) are of the extended type (ERE).
##
## All regexes should be extended regular expressions.
## If the coloring rule should span multiple lines, use the following format:
##
## color fg,bg start="regex" end="regex"
##
## If you wish, you may put your syntax definitions in separate files.
## You can make use of such files as follows:
##
## include "/path/to/syntax_file.nanorc"
##
## Unless otherwise noted, the name of the syntax file (without the
## ".nanorc" extension) should be the same as the "short description"
## name inside that file. These names are kept fairly short to make
## them easier to remember and faster to type using nano's -Y option.
## include "/path/to/syntax_file.nanorc"
## To include all existing syntax definitions, you can do:
# include "@PKGDATADIR@/*.nanorc"
## If <Tab> should always produce four spaces when editing a Python file,
## independent of the settings of 'tabsize' and 'tabstospaces':
# extendsyntax python tabgives " "
## If <Tab> should always produce an actual TAB when editing a Makefile:
# extendsyntax makefile tabgives " "
## Key bindings.
## See nanorc(5) (section REBINDING KEYS) for more details on this.
@@ -278,6 +268,9 @@
## such as ^O for Open, ^F for Find, ^H for Help, and ^Q for Quit,
## then uncomment these:
#bind ^Q exit all
#bind ^S savefile main
#bind ^W writeout main
#bind ^O insert main
#bind ^H help all
#bind ^H exit help
#bind ^F whereis all
@@ -285,23 +278,23 @@
#bind ^B wherewas all
#bind ^D findprevious all
#bind ^R replace main
#bind ^W writeout main
#bind ^O insert main
#unbind ^V all
#unbind ^Y all
#bind M-X flipnewbuffer all
#bind ^X cut all
#bind ^C copy all
#bind ^C copy main
#bind ^V paste all
#bind ^P curpos main
#bind ^A mark main
#unbind ^K main
#unbind ^U all
#unbind ^N main
#unbind ^Y all
#unbind M-J main
#unbind M-T main
#bind ^T gotoline main
#bind ^T gotodir browser
#bind ^Y speller main
#unbind ^K all
#unbind ^U all
#bind M-U undo main
#bind M-R redo main
#bind ^U undo main
#bind ^E redo main
#unbind M-J main
#unbind M-T main
#set multibuffer

View File

@@ -11,15 +11,12 @@ top_builddir = ..
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --keyword=P_:1,2
# This is the copyright holder that gets inserted into the header of the
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
# package. (Note that the msgstr strings, extracted from the package's
# sources, belong to the copyright holder of the package.) Translators are
# expected to transfer the copyright for their translations to this person
# or entity, or to disclaim their copyright. The empty string stands for
# the public domain; in this case the translators are expected to disclaim
# their copyright.
# $(DOMAIN).pot file. Translators are expected to disclaim their copyright.
COPYRIGHT_HOLDER = Free Software Foundation, Inc.
# This is the list of locale categories, beyond LC_MESSAGES, for which the
# message catalogs shall be used. It is usually empty.
EXTRA_LOCALE_CATEGORIES =
# Don't do fuzzy matching when merging the PO files against the POT file.
MSGMERGE_OPTIONS = --no-fuzzy-matching

View File

@@ -2,6 +2,7 @@
src/browser.c
src/color.c
src/cut.c
src/files.c
src/global.c
src/help.c
@@ -13,3 +14,6 @@ src/search.c
src/text.c
src/utils.c
src/winio.c
lib/getopt.c
lib/regcomp.c

2283
po/bg.po

File diff suppressed because it is too large Load Diff

2230
po/ca.po

File diff suppressed because it is too large Load Diff

2019
po/cs.po

File diff suppressed because it is too large Load Diff

2325
po/da.po

File diff suppressed because it is too large Load Diff

1686
po/de.po

File diff suppressed because it is too large Load Diff

1840
po/eo.po

File diff suppressed because it is too large Load Diff

1982
po/es.po

File diff suppressed because it is too large Load Diff

2561
po/eu.po

File diff suppressed because it is too large Load Diff

2145
po/fi.po

File diff suppressed because it is too large Load Diff

1630
po/fr.po

File diff suppressed because it is too large Load Diff

2118
po/ga.po

File diff suppressed because it is too large Load Diff

2027
po/gl.po

File diff suppressed because it is too large Load Diff

2002
po/hr.po

File diff suppressed because it is too large Load Diff

1839
po/hu.po

File diff suppressed because it is too large Load Diff

2704
po/id.po

File diff suppressed because it is too large Load Diff

1686
po/it.po

File diff suppressed because it is too large Load Diff

1989
po/ja.po

File diff suppressed because it is too large Load Diff

1641
po/ko.po

File diff suppressed because it is too large Load Diff

2624
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2098
po/nb.po

File diff suppressed because it is too large Load Diff

1848
po/nl.po

File diff suppressed because it is too large Load Diff

2721
po/nn.po

File diff suppressed because it is too large Load Diff

1853
po/pl.po

File diff suppressed because it is too large Load Diff

2057
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1875
po/ro.po

File diff suppressed because it is too large Load Diff

2297
po/ru.po

File diff suppressed because it is too large Load Diff

2466
po/sl.po

File diff suppressed because it is too large Load Diff

2049
po/sr.po

File diff suppressed because it is too large Load Diff

2449
po/sv.po

File diff suppressed because it is too large Load Diff

2070
po/tr.po

File diff suppressed because it is too large Load Diff

1931
po/uk.po

File diff suppressed because it is too large Load Diff

View File

@@ -21,8 +21,11 @@ fi
echo "Regenerating POT file and remerging and recompiling PO files..."
make update-po
# Ensure that the PO files are newer than the POT.
touch *.po
echo "Removing the dead weight of obsolete and fuzzy translations..."
for pofile in *.po; do
msgattrib --no-obsolete --no-fuzzy $pofile >trimmed.po || exit 4
mv trimmed.po $pofile || exit 4
done
# If needed, fix a problem in the Makefile template.
grep -q '^datarootdir' Makefile.in.in || \

2017
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
#!/bin/bash
VERSION="4.0"
VERSION="4.8"
./configure -C --enable-tiny && make && ./configure -C &&
@@ -12,8 +12,8 @@ po/update_linguas.sh &&
make distcheck && make dist-xz &&
git add po/*.po &&
git commit -a -m "$(git log -1 --grep 'po: up' | grep o: | sed 's/^ //')" &&
git add po/*.po po/nano.pot &&
git commit -m "$(git log -1 --grep 'po: up' | grep o: | sed 's/^ //')" &&
gpg -a -b nano-$VERSION.tar.gz &&
gpg -a -b nano-$VERSION.tar.xz &&
@@ -22,6 +22,10 @@ gpg --verify nano-$VERSION.tar.xz.asc &&
git tag -u A0ACE884 -a v$VERSION -m "the nano $VERSION release" &&
make pdf && rm -rf doc/nano.t2p &&
scp doc/nano.pdf bens@wh0rd.org:nano.pdf &&
scp doc/cheatsheet.html bens@wh0rd.org:cheatsheet.html &&
for file in nano-$VERSION.tar.*z*; do scp $file bens@wh0rd.org:$file; done &&
gnupload --to ftp.gnu.org:nano nano-$VERSION.tar.*z &&

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* browser.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2015-2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -21,13 +21,13 @@
#include "proto.h"
#ifdef ENABLE_BROWSER
#include <errno.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#ifdef ENABLE_BROWSER
static char **filelist = NULL;
/* The list of files to display in the file browser. */
static size_t filelist_len = 0;
@@ -77,8 +77,6 @@ char *do_browser(char *path)
present_name = mallocstrcpy(present_name, filelist[selected]);
}
assert(path != NULL && path[strlen(path) - 1] == '/');
if (dir != NULL) {
/* Get the file list, and set longest and width in the process. */
read_the_list(path, dir);
@@ -140,14 +138,20 @@ char *do_browser(char *path)
/* If we selected the same filename as last time, fake a
* press of the Enter key so that the file is read in. */
if (old_selected == selected)
unget_kbinput(KEY_ENTER, FALSE);
kbinput = KEY_ENTER;
}
continue;
if (kbinput == KEY_MOUSE)
continue;
}
#endif /* ENABLE_MOUSE */
func = parse_browser_input(&kbinput);
#ifndef NANO_TINY
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
func = interpret(&kbinput);
if (func == total_refresh) {
total_redraw();
@@ -155,9 +159,9 @@ char *do_browser(char *path)
/* Simulate a window resize to force a directory reread. */
kbinput = KEY_WINCH;
#endif
} else if (func == do_help_void) {
} else if (func == do_help) {
#ifdef ENABLE_HELP
do_help_void();
do_help();
#ifndef NANO_TINY
/* The window dimensions might have changed, so act as if. */
kbinput = KEY_WINCH;
@@ -221,13 +225,11 @@ char *do_browser(char *path)
selected = 0;
} else if (func == to_last_file) {
selected = filelist_len - 1;
} else if (func == goto_dir_void) {
} else if (func == goto_dir) {
/* Ask for the directory to go to. */
int i = do_prompt(TRUE, FALSE, MGOTODIR, NULL, NULL,
/* TRANSLATORS: This is a prompt. */
browser_refresh, _("Go To Directory"));
if (i < 0) {
if (do_prompt(TRUE, FALSE, MGOTODIR, "", NULL,
/* TRANSLATORS: This is a prompt. */
browser_refresh, _("Go To Directory")) < 0) {
statusbar(_("Cancelled"));
continue;
}
@@ -289,7 +291,7 @@ char *do_browser(char *path)
/* If it isn't a directory, a file was selected -- we're done. */
if (!S_ISDIR(st.st_mode)) {
retval = mallocstrcpy(NULL, filelist[selected]);
retval = copy_of(filelist[selected]);
break;
}
@@ -305,13 +307,12 @@ char *do_browser(char *path)
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MBROWSER, func)->expansion);
#endif
} else if (func == do_exit) {
/* Exit from the file browser. */
break;
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
;
; /* Nothing to do. */
#endif
} else if (func == do_exit) {
break;
} else
unbound_key(kbinput);
@@ -319,7 +320,7 @@ char *do_browser(char *path)
/* If the window resized, refresh the file list. */
if (kbinput == KEY_WINCH) {
/* Remember the selected file, to be able to reselect it. */
present_name = mallocstrcpy(NULL, filelist[selected]);
present_name = copy_of(filelist[selected]);
/* Reread the contents of the current directory. */
goto read_directory_contents;
}
@@ -394,13 +395,11 @@ void read_the_list(const char *path, DIR *dir)
const struct dirent *nextdir;
size_t i = 0, path_len = strlen(path);
assert(path != NULL && path[strlen(path) - 1] == '/' && dir != NULL);
longest = 0;
/* Find the length of the longest filename in the current folder. */
while ((nextdir = readdir(dir)) != NULL) {
size_t name_len = strlenpt(nextdir->d_name);
size_t name_len = breadth(nextdir->d_name);
if (name_len > longest)
longest = name_len;
@@ -445,8 +444,6 @@ void read_the_list(const char *path, DIR *dir)
* filelist, so record it. */
filelist_len = i;
assert(filelist != NULL);
/* Sort the list of names. */
qsort(filelist, filelist_len, sizeof(char *), diralphasort);
@@ -456,50 +453,10 @@ void read_the_list(const char *path, DIR *dir)
width = (COLS + 2) / (longest + 2);
}
/* Return the function that is bound to the given key, accepting certain
* plain characters too, for compatibility with Pico. */
functionptrtype parse_browser_input(int *kbinput)
{
if (!meta_key) {
switch (*kbinput) {
case BS_CODE:
case '-':
return do_page_up;
case ' ':
return do_page_down;
case '?':
return do_help_void;
case 'E':
case 'e':
case 'Q':
case 'q':
case 'X':
case 'x':
return do_exit;
case 'G':
case 'g':
return goto_dir_void;
case 'S':
case 's':
return do_enter;
case 'W':
case 'w':
case '/':
return do_search_forward;
case 'N':
return do_findprevious;
case 'n':
return do_findnext;
}
}
return func_from_key(kbinput);
}
/* Set width to the number of files that we can display per screen row,
* if necessary, and display the list of files. */
void browser_refresh(void)
{
size_t i;
int row = 0, col = 0;
/* The current row and column while the list is getting displayed. */
int the_row = 0, the_column = 0;
@@ -512,13 +469,12 @@ void browser_refresh(void)
wmove(edit, 0, 0);
i = selected - selected % (editwinrows * width);
for (; i < filelist_len && row < editwinrows; i++) {
for (size_t index = selected - selected % (editwinrows * width);
index < filelist_len && row < editwinrows; index++) {
struct stat st;
const char *thename = tail(filelist[i]);
const char *thename = tail(filelist[index]);
/* The filename we display, minus the path. */
size_t namelen = strlenpt(thename);
size_t namelen = breadth(thename);
/* The length of the filename in columns. */
size_t infolen;
/* The length of the file information in columns. */
@@ -533,16 +489,15 @@ void browser_refresh(void)
/* The filename (or a fragment of it) in displayable format.
* When a fragment, account for dots plus one space padding. */
/* If this is the selected item, start its highlighting, and
/* If this is the selected item, draw its highlighted bar upfront, and
* remember its location to be able to place the cursor on it. */
if (i == selected) {
if (index == selected) {
wattron(edit, interface_color_pair[SELECTED_TEXT]);
mvwprintw(edit, row, col, "%*s", longest, " ");
the_row = row;
the_column = col;
}
blank_row(edit, row, col, longest);
/* If the name is too long, we display something like "...ename". */
if (dots)
mvwaddstr(edit, row, col, "...");
@@ -555,19 +510,19 @@ void browser_refresh(void)
/* Show information about the file: "--" for symlinks (except when
* they point to a directory) and for files that have disappeared,
* "(dir)" for directories, and the file size for normal files. */
if (lstat(filelist[i], &st) == -1 || S_ISLNK(st.st_mode)) {
if (stat(filelist[i], &st) == -1 || !S_ISDIR(st.st_mode))
info = mallocstrcpy(NULL, "--");
if (lstat(filelist[index], &st) == -1 || S_ISLNK(st.st_mode)) {
if (stat(filelist[index], &st) == -1 || !S_ISDIR(st.st_mode))
info = copy_of("--");
else
/* TRANSLATORS: Try to keep this at most 7 characters. */
info = mallocstrcpy(NULL, _("(dir)"));
info = copy_of(_("(dir)"));
} else if (S_ISDIR(st.st_mode)) {
if (strcmp(thename, "..") == 0) {
/* TRANSLATORS: Try to keep this at most 12 characters. */
info = mallocstrcpy(NULL, _("(parent dir)"));
info = copy_of(_("(parent dir)"));
infomaxlen = 12;
} else
info = mallocstrcpy(NULL, _("(dir)"));
info = copy_of(_("(dir)"));
} else {
off_t result = st.st_size;
char modifier;
@@ -598,7 +553,7 @@ void browser_refresh(void)
}
/* Make sure info takes up no more than infomaxlen columns. */
infolen = strlenpt(info);
infolen = breadth(info);
if (infolen > infomaxlen) {
info[actual_x(info, infomaxlen)] = '\0';
infolen = infomaxlen;
@@ -607,7 +562,7 @@ void browser_refresh(void)
mvwaddstr(edit, row, col - infolen, info);
/* If this is the selected item, finish its highlighting. */
if (i == selected)
if (index == selected)
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
free(info);
@@ -672,14 +627,15 @@ int filesearch_init(bool forwards)
thedefault = charalloc(strlen(disp) + 7);
/* We use (COLS / 3) here because we need to see more on the line. */
sprintf(thedefault, " [%s%s]", disp,
(strlenpt(last_search) > COLS / 3) ? "..." : "");
(breadth(last_search) > COLS / 3) ? "..." : "");
free(disp);
} else
thedefault = mallocstrcpy(NULL, "");
thedefault = copy_of("");
/* Now ask what to search for. */
response = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, &search_history,
response = do_prompt(FALSE, FALSE, MWHEREISFILE, "", &search_history,
browser_refresh, "%s%s%s", _("Search"),
/* TRANSLATORS: A modifier of the Search prompt. */
!forwards ? _(" [Backwards]") : "", thedefault);
free(thedefault);
@@ -802,7 +758,7 @@ void to_last_file(void)
* The returned string is dynamically allocated, and should be freed. */
char *strip_last_component(const char *path)
{
char *copy = mallocstrcpy(NULL, path);
char *copy = copy_of(path);
char *last_slash = strrchr(copy, '/');
if (last_slash != NULL)

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* chars.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 2016-2018 Benno Schulenberg *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2016-2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -70,7 +70,7 @@ bool is_alpha_mbchar(const char *c)
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
return FALSE;
return iswalpha(wc);
} else
@@ -86,7 +86,7 @@ bool is_alnum_mbchar(const char *c)
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
return FALSE;
return iswalnum(wc);
} else
@@ -102,7 +102,7 @@ bool is_blank_mbchar(const char *c)
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
return FALSE;
return iswblank(wc);
} else
@@ -139,7 +139,7 @@ bool is_punct_mbchar(const char *c)
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
return FALSE;
return iswpunct(wc);
} else
@@ -160,7 +160,7 @@ bool is_word_mbchar(const char *c, bool allow_punct)
if (word_chars != NULL && *word_chars != '\0') {
char symbol[MAXCHARLEN + 1];
int symlen = parse_mbchar(c, symbol, NULL);
int symlen = collect_char(c, symbol);
symbol[symlen] = '\0';
return (strstr(word_chars, symbol) != NULL);
@@ -200,41 +200,12 @@ char control_mbrep(const char *c, bool isdata)
return control_rep(*c);
}
/* Assess how many bytes the given (multibyte) character occupies. Return -1
* if the byte sequence is invalid, and return the number of bytes minus 8
* when it encodes an invalid codepoint. Also, in the second parameter,
* return the number of columns that the character occupies. */
int length_of_char(const char *c, int *width)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
int charlen = mbtowc(&wc, c, MAXCHARLEN);
/* If the sequence is invalid... */
if (charlen < 0)
return -1;
/* If the codepoint is invalid... */
if (!is_valid_unicode(wc))
return charlen - 8;
else {
*width = wcwidth(wc);
/* If the codepoint is unassigned, assume a width of one. */
if (*width < 0)
*width = 1;
return charlen;
}
} else
#endif
return 1;
}
/* This function is equivalent to wcwidth() for multibyte characters. */
/* Return the width in columns of the given (multibyte) character. */
int mbwidth(const char *c)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
/* Ask for the width only when the character isn't plain ASCII. */
if ((signed char)*c <= 0) {
wchar_t wc;
int width;
@@ -243,96 +214,148 @@ int mbwidth(const char *c)
width = wcwidth(wc);
if (width == -1)
if (width < 0)
return 1;
return width;
} else
return 1;
}
#endif
/* Convert the Unicode value in code to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return an undefined (dynamically
* allocated) multibyte character and a length of zero. */
char *make_mbchar(long code, int *length)
{
char *mb_char;
#ifdef ENABLE_UTF8
if (use_utf8) {
mb_char = charalloc(MAXCHARLEN);
*length = wctomb(mb_char, (wchar_t)code);
/* Reject invalid Unicode characters. */
if (*length < 0 || !is_valid_unicode((wchar_t)code)) {
IGNORE_CALL_RESULT(wctomb(NULL, 0));
*length = 0;
}
} else
#endif
{
mb_char = measured_copy((char *)&code, 1);
*length = 1;
}
return mb_char;
}
/* Return the length (in bytes) of the character located at *pointer. */
int char_length(const char *pointer)
{
#ifdef ENABLE_UTF8
/* If possibly a multibyte character, get its length; otherwise, it's 1. */
if ((signed char)*pointer < 0) {
int length = mblen(pointer, MAXCHARLEN);
return (length < 0 ? 1 : length);
} else
#endif
return 1;
}
/* Convert the Unicode value in chr to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return an undefined (dynamically
* allocated) multibyte character and a length of zero. */
char *make_mbchar(long chr, int *chr_mb_len)
/* Return the number of (multibyte) characters in the given string. */
size_t mbstrlen(const char *pointer)
{
char *chr_mb;
size_t count = 0;
while (*pointer != '\0') {
#ifdef ENABLE_UTF8
if (use_utf8) {
chr_mb = charalloc(MAXCHARLEN);
*chr_mb_len = wctomb(chr_mb, (wchar_t)chr);
if ((signed char)*pointer < 0) {
int length = mblen(pointer, MAXCHARLEN);
/* Reject invalid Unicode characters. */
if (*chr_mb_len < 0 || !is_valid_unicode((wchar_t)chr)) {
IGNORE_CALL_RESULT(wctomb(NULL, 0));
*chr_mb_len = 0;
}
} else
pointer += (length < 0 ? 1 : length);
} else
#endif
{
*chr_mb_len = 1;
chr_mb = mallocstrncpy(NULL, (char *)&chr, 1);
pointer++;
count++;
}
return chr_mb;
return count;
}
/* Parse a multibyte character from buf. Return the number of bytes
* used. If chr isn't NULL, store the multibyte character in it. If
* col isn't NULL, add the character's width (in columns) to it. */
int parse_mbchar(const char *buf, char *chr, size_t *col)
/* Return the length (in bytes) of the character at the start of the
* given string, and return a copy of this character in *thechar. */
int collect_char(const char *string, char *thechar)
{
int length;
int charlen;
#ifdef ENABLE_UTF8
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
if ((signed char)*buf < 0) {
length = mblen(buf, MAXCHARLEN);
if ((signed char)*string < 0) {
charlen = mblen(string, MAXCHARLEN);
/* When the multibyte sequence is invalid, only take the first byte. */
if (length <= 0)
length = 1;
if (charlen <= 0)
charlen = 1;
} else
#endif
length = 1;
charlen = 1;
/* When requested, store the multibyte character in chr. */
if (chr != NULL)
for (int i = 0; i < length; i++)
chr[i] = buf[i];
for (int i = 0; i < charlen; i++)
thechar[i] = string[i];
/* When requested, add the width of the character to col. */
if (col != NULL) {
/* If we have a tab, compute its width in columns based on the
* current value of col. */
if (*buf == '\t')
*col += tabsize - *col % tabsize;
/* If we have a control character, it's two columns wide: one
* column for the "^", and one for the visible character. */
else if (is_cntrl_mbchar(buf))
*col += 2;
/* If we have a normal character, get its width normally. */
else if (length == 1)
*col += 1;
return charlen;
}
/* Return the length (in bytes) of the character at the start of
* the given string, and add this character's width to *column. */
int advance_over(const char *string, size_t *column)
{
#ifdef ENABLE_UTF8
else
*col += mbwidth(buf);
#endif
}
if ((signed char)*string < 0) {
int charlen = mblen(string, MAXCHARLEN);
return length;
if (charlen > 0) {
if (is_cntrl_mbchar(string))
*column += 2;
else
*column += mbwidth(string);
} else {
charlen = 1;
*column += 1;
}
return charlen;
}
#endif
if ((unsigned char)*string < 0x20) {
if (*string == '\t')
*column += tabsize - *column % tabsize;
else
*column += 2;
} else if (*string == 0x7F)
*column += 2;
#ifndef ENABLE_UTF8
else if (0x7F < (unsigned char)*string && (unsigned char)*string < 0xA0)
*column += 2;
#endif
else
*column += 1;
return 1;
}
/* Return the index in buf of the beginning of the multibyte character
* before the one at pos. */
size_t move_mbleft(const char *buf, size_t pos)
size_t step_left(const char *buf, size_t pos)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t before, char_len = 0;
size_t before, charlen = 0;
if (pos < 4)
before = 0;
@@ -355,21 +378,21 @@ size_t move_mbleft(const char *buf, size_t pos)
/* Move forward again until we reach the original character,
* so we know the length of its preceding character. */
while (before < pos) {
char_len = parse_mbchar(buf + before, NULL, NULL);
before += char_len;
charlen = char_length(buf + before);
before += charlen;
}
return before - char_len;
return before - charlen;
} else
#endif
return (pos == 0 ? 0 : pos - 1);
return (pos == 0 ? 0 : pos - 1);
}
/* Return the index in buf of the beginning of the multibyte character
* after the one at pos. */
size_t move_mbright(const char *buf, size_t pos)
size_t step_right(const char *buf, size_t pos)
{
return pos + parse_mbchar(buf + pos, NULL, NULL);
return pos + char_length(buf + pos);
}
/* This function is equivalent to strcasecmp() for multibyte strings. */
@@ -402,8 +425,8 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
return difference;
}
s1 += move_mbright(s1, 0);
s2 += move_mbright(s2, 0);
s1 += char_length(s1);
s2 += char_length(s2);
n--;
}
@@ -424,13 +447,13 @@ char *mbstrcasestr(const char *haystack, const char *needle)
if (mbstrncasecmp(haystack, needle, needle_len) == 0)
return (char *)haystack;
haystack += move_mbright(haystack, 0);
haystack += char_length(haystack);
}
return NULL;
} else
#endif
return (char *) strcasestr(haystack, needle);
return (char *)strcasestr(haystack, needle);
}
/* This function is equivalent to strstr(), except in that it scans the
@@ -496,142 +519,86 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
if (pointer == haystack)
return NULL;
pointer = haystack + move_mbleft(haystack, pointer - haystack);
pointer = haystack + step_left(haystack, pointer - haystack);
}
} else
#endif
return revstrcasestr(haystack, needle, pointer);
}
/* Count the number of (multibyte) characters in the given string. */
size_t mbstrlen(const char *s)
{
size_t maxlen = (size_t)-1;
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t n = 0;
while (*s != '\0' && maxlen > 0) {
if ((signed char)*s < 0) {
int length = mblen(s, MAXCHARLEN);
s += (length < 0 ? 1 : length);
} else
s++;
maxlen--;
n++;
}
return n;
} else
#endif
return strnlen(s, maxlen);
}
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
/* This function is equivalent to strchr() for multibyte strings. */
char *mbstrchr(const char *s, const char *c)
char *mbstrchr(const char *string, const char *chr)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
bool bad_s_mb = FALSE, bad_c_mb = FALSE;
char symbol[MAXCHARLEN];
const char *q = s;
bool bad_s = FALSE, bad_c = FALSE;
wchar_t ws, wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
wc = (unsigned char)*c;
bad_c_mb = TRUE;
if (mbtowc(&wc, chr, MAXCHARLEN) < 0) {
wc = (unsigned char)*chr;
bad_c = TRUE;
}
while (*s != '\0') {
int sym_len = parse_mbchar(s, symbol, NULL);
while (*string != '\0') {
int symlen = mbtowc(&ws, string, MAXCHARLEN);
if (mbtowc(&ws, symbol, sym_len) < 0) {
ws = (unsigned char)*s;
bad_s_mb = TRUE;
if (symlen < 0) {
ws = (unsigned char)*string;
bad_s = TRUE;
}
if (bad_s_mb == bad_c_mb && ws == wc)
if (ws == wc && bad_s == bad_c)
break;
s += sym_len;
q += sym_len;
string += symlen;
}
if (*s == '\0')
q = NULL;
if (*string == '\0')
return NULL;
return (char *)q;
return (char *)string;
} else
#endif
return (char *) strchr(s, *c);
return strchr(string, *chr);
}
#endif /* !NANO_TINY || ENABLE_JUSTIFY */
#ifndef NANO_TINY
/* This function is equivalent to strpbrk() for multibyte strings. */
char *mbstrpbrk(const char *s, const char *accept)
/* Locate, in the given string, the first occurrence of any of
* the characters in accept, searching forward. */
char *mbstrpbrk(const char *string, const char *accept)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
for (; *s != '\0'; s += move_mbright(s, 0)) {
if (mbstrchr(accept, s) != NULL)
return (char *)s;
}
while (*string != '\0') {
if (mbstrchr(accept, string) != NULL)
return (char *)string;
return NULL;
} else
#endif
return (char *) strpbrk(s, accept);
}
/* Locate, in the string that starts at head, the first occurrence of any of
* the characters in the string accept, starting from pointer and searching
* backwards. */
char *revstrpbrk(const char *head, const char *accept, const char *pointer)
{
if (*pointer == '\0') {
if (pointer == head)
return NULL;
pointer--;
}
while (pointer >= head) {
if (strchr(accept, *pointer) != NULL)
return (char *)pointer;
pointer--;
string += char_length(string);
}
return NULL;
}
/* The same as the preceding function but then for multibyte strings. */
/* Locate, in the string that starts at head, the first occurrence of any of
* the characters in accept, starting from pointer and searching backwards. */
char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
if (*pointer == '\0') {
if (pointer == head)
return NULL;
pointer = head + move_mbleft(head, pointer - head);
}
if (*pointer == '\0') {
if (pointer == head)
return NULL;
pointer = head + step_left(head, pointer - head);
}
while (TRUE) {
if (mbstrchr(accept, pointer) != NULL)
return (char *)pointer;
while (TRUE) {
if (mbstrchr(accept, pointer) != NULL)
return (char *)pointer;
/* If we've reached the head of the string, we found nothing. */
if (pointer == head)
return NULL;
/* If we've reached the head of the string, we found nothing. */
if (pointer == head)
return NULL;
pointer = head + move_mbleft(head, pointer - head);
}
} else
#endif
return revstrpbrk(head, accept, pointer);
pointer = head + step_left(head, pointer - head);
}
}
#endif /* !NANO_TINY */
@@ -643,7 +610,7 @@ bool has_blank_char(const char *string)
char symbol[MAXCHARLEN];
while (*string != '\0') {
string += parse_mbchar(string, symbol, NULL);
string += collect_char(string, symbol);
if (is_blank_mbchar(symbol))
return TRUE;
@@ -653,6 +620,15 @@ bool has_blank_char(const char *string)
}
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
/* Return TRUE when the given string is empty or consists of only blanks. */
bool white_string(const char *string)
{
while (*string != '\0' && (is_blank_mbchar(string) || *string == '\r'))
string += char_length(string);
return !*string;
}
#ifdef ENABLE_UTF8
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
bool is_valid_unicode(wchar_t wc)

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* color.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -21,14 +21,13 @@
#include "proto.h"
#ifdef ENABLE_COLOR
#include <errno.h>
#ifdef HAVE_MAGIC_H
#include <magic.h>
#endif
#include <string.h>
#include <unistd.h>
#ifdef ENABLE_COLOR
/* For early versions of ncurses-6.0, use an additional A_PROTECT attribute
* for all colors, in order to work around an ncurses miscoloring bug. */
@@ -39,13 +38,35 @@
#define A_BANDAID A_NORMAL
#endif
/* Assign pair numbers for the colors in the given syntax, giving identical
* color pairs the same number. */
void set_syntax_colorpairs(syntaxtype *sint)
{
int new_number = NUMBER_OF_ELEMENTS + 1;
colortype *ink;
for (ink = sint->color; ink != NULL; ink = ink->next) {
const colortype *beforenow = sint->color;
while (beforenow != ink && (beforenow->fg != ink->fg ||
beforenow->bg != ink->bg))
beforenow = beforenow->next;
if (beforenow != ink)
ink->pairnum = beforenow->pairnum;
else
ink->pairnum = new_number++;
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
}
}
/* Initialize the colors for nano's interface, and assign pair numbers
* for the colors in each syntax. */
* for the colors in each loaded syntax. */
void set_colorpairs(void)
{
const syntaxtype *sint;
syntaxtype *sint;
bool using_defaults = FALSE;
size_t i;
/* Tell ncurses to enable colors. */
start_color();
@@ -56,53 +77,37 @@ void set_colorpairs(void)
#endif
/* Initialize the color pairs for nano's interface elements. */
for (i = 0; i < NUMBER_OF_ELEMENTS; i++) {
colortype *combo = color_combo[i];
for (size_t index = 0; index < NUMBER_OF_ELEMENTS; index++) {
colortype *combo = color_combo[index];
if (combo != NULL) {
if (combo->fg == USE_THE_DEFAULT && !using_defaults)
combo->fg = COLOR_WHITE;
if (combo->bg == USE_THE_DEFAULT && !using_defaults)
combo->bg = COLOR_BLACK;
init_pair(i + 1, combo->fg, combo->bg);
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BANDAID |
combo->attributes;
init_pair(index + 1, combo->fg, combo->bg);
interface_color_pair[index] = COLOR_PAIR(index + 1) | A_BANDAID |
combo->attributes;
} else {
if (i == FUNCTION_TAG)
interface_color_pair[i] = A_NORMAL;
else if (i == GUIDE_STRIPE)
interface_color_pair[i] = A_REVERSE;
else if (i == ERROR_MESSAGE) {
init_pair(i + 1, COLOR_WHITE, COLOR_RED);
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BOLD | A_BANDAID;
if (index == FUNCTION_TAG)
interface_color_pair[index] = A_NORMAL;
else if (index == GUIDE_STRIPE)
interface_color_pair[index] = A_REVERSE;
else if (index == ERROR_MESSAGE) {
init_pair(index + 1, COLOR_WHITE, COLOR_RED);
interface_color_pair[index] = COLOR_PAIR(index + 1) |
A_BOLD | A_BANDAID;
} else
interface_color_pair[i] = hilite_attribute;
interface_color_pair[index] = hilite_attribute;
}
free(color_combo[i]);
free(color_combo[index]);
}
/* For each syntax, go through its list of colors and assign each
* its pair number, giving identical color pairs the same number. */
for (sint = syntaxes; sint != NULL; sint = sint->next) {
colortype *ink;
int new_number = NUMBER_OF_ELEMENTS + 1;
for (ink = sint->color; ink != NULL; ink = ink->next) {
const colortype *beforenow = sint->color;
while (beforenow != ink && (beforenow->fg != ink->fg ||
beforenow->bg != ink->bg))
beforenow = beforenow->next;
if (beforenow != ink)
ink->pairnum = beforenow->pairnum;
else
ink->pairnum = new_number++;
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
}
}
/* For each loaded syntax, assign pair numbers to color combinations. */
for (sint = syntaxes; sint != NULL; sint = sint->next)
if (sint->filename == NULL)
set_syntax_colorpairs(sint);
}
/* Initialize the color information. */
@@ -163,7 +168,6 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
void color_update(void)
{
syntaxtype *sint = NULL;
colortype *ink;
/* If the rcfiles were not read, or contained no syntaxes, get out. */
if (syntaxes == NULL)
@@ -187,20 +191,7 @@ void color_update(void)
/* If no syntax-override string was specified, or it didn't match,
* try finding a syntax based on the filename (extension). */
if (sint == NULL && !inhelp) {
char *reserved = charalloc(PATH_MAX + 1);
char *currentdir = getcwd(reserved, PATH_MAX + 1);
char *joinednames = charalloc(PATH_MAX + 1);
char *fullname = NULL;
if (currentdir == NULL)
free(reserved);
else {
/* Concatenate the current working directory with the
* specified filename, and canonicalize the result. */
sprintf(joinednames, "%s/%s", currentdir, openfile->filename);
fullname = get_full_path(joinednames);
free(currentdir);
}
char *fullname = get_full_path(openfile->filename);
if (fullname == NULL)
fullname = mallocstrcpy(fullname, openfile->filename);
@@ -210,7 +201,6 @@ void color_update(void)
break;
}
free(joinednames);
free(fullname);
}
@@ -267,22 +257,23 @@ void color_update(void)
}
}
/* When the syntax isn't loaded yet, parse it and initialize its colors. */
if (sint != NULL && sint->filename != NULL) {
parse_one_include(sint->filename, sint);
set_syntax_colorpairs(sint);
}
openfile->syntax = sint;
openfile->colorstrings = (sint == NULL ? NULL : sint->color);
}
/* If a syntax was found, compile its specified regexes (which have
* already been checked for validity when they were read in). */
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
if (ink->start == NULL) {
ink->start = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(ink->start, ink->start_regex, ink->rex_flags);
}
/* Allocate and initialize (for the given line) the cache for multiline info. */
void set_up_multicache(linestruct *line)
{
line->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
if (ink->end_regex != NULL && ink->end == NULL) {
ink->end = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(ink->end, ink->end_regex, ink->rex_flags);
}
}
for (int index = 0; index < openfile->syntax->nmultis; index++)
line->multidata[index] = -1;
}
/* Determine whether the matches of multiline regexes are still the same,
@@ -298,13 +289,14 @@ void check_the_multis(linestruct *line)
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0)
return;
if (line->multidata == NULL)
set_up_multicache(line);
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
/* If it's not a multiline regex, skip. */
if (ink->end == NULL)
continue;
alloc_multidata_if_needed(line);
astart = (regexec(ink->start, line->data, 1, &startmatch, 0) == 0);
afterstart = line->data + (astart ? startmatch.rm_eo : 0);
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
@@ -331,19 +323,6 @@ void check_the_multis(linestruct *line)
}
}
/* Allocate (for one line) the cache space for multiline color regexes. */
void alloc_multidata_if_needed(linestruct *fileptr)
{
int i;
if (fileptr->multidata == NULL) {
fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
for (i = 0; i < openfile->syntax->nmultis; i++)
fileptr->multidata[i] = -1;
}
}
/* Precalculate the multi-line start and end regex info so we can
* speed up rendering (with any hope at all...). */
void precalc_multicolorinfo(void)
@@ -355,9 +334,9 @@ void precalc_multicolorinfo(void)
if (openfile->colorstrings == NULL || ISSET(NO_COLOR_SYNTAX))
return;
#ifdef DEBUG
fprintf(stderr, "Precalculating the multiline color info...\n");
#endif
/* For each line, allocate cache space for the multiline-regex info. */
for (line = openfile->filetop; line != NULL; line = line->next)
set_up_multicache(line);
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
/* If this is not a multi-line regex, skip it. */
@@ -367,7 +346,6 @@ void precalc_multicolorinfo(void)
for (line = openfile->filetop; line != NULL; line = line->next) {
int index = 0;
alloc_multidata_if_needed(line);
/* Assume nothing applies until proven otherwise below. */
line->multidata[ink->id] = CNONE;
@@ -380,14 +358,14 @@ void precalc_multicolorinfo(void)
/* When the line contains a start match, look for an end, and if
* found, mark all the lines that are affected. */
while (regexec(ink->start, line->data + index, 1,
&startmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
&startmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
/* Begin looking for an end match after the start match. */
index += startmatch.rm_eo;
/* If there is an end match on this line, mark the line, but
* continue looking for other starts after it. */
if (regexec(ink->end, line->data + index, 1,
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
line->multidata[ink->id] = CSTARTENDHERE;
index += endmatch.rm_eo;
/* If both start and end are mere anchors, step ahead. */
@@ -396,7 +374,7 @@ void precalc_multicolorinfo(void)
/* When at end-of-line, we're done. */
if (line->data[index] == '\0')
break;
index = move_mbright(line->data, index);
index = step_right(line->data, index);
}
continue;
}
@@ -419,12 +397,9 @@ void precalc_multicolorinfo(void)
* the lines in between and the end properly. */
line->multidata[ink->id] = CENDAFTER;
for (line = line->next; line != tailline; line = line->next) {
alloc_multidata_if_needed(line);
for (line = line->next; line != tailline; line = line->next)
line->multidata[ink->id] = CWHOLELINE;
}
alloc_multidata_if_needed(tailline);
tailline->multidata[ink->id] = CBEGINBEFORE;
/* Begin looking for a new start after the end match. */

378
src/cut.c
View File

@@ -1,7 +1,7 @@
/**************************************************************************
* cut.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mark Majeres *
* Copyright (C) 2016, 2018, 2019 Benno Schulenberg *
* *
@@ -35,16 +35,14 @@ void do_deletion(undo_type action)
/* When in the middle of a line, delete the current character. */
if (openfile->current->data[openfile->current_x] != '\0') {
int char_len = parse_mbchar(openfile->current->data +
openfile->current_x, NULL, NULL);
size_t line_len = strlen(openfile->current->data +
openfile->current_x);
int charlen = char_length(openfile->current->data + openfile->current_x);
size_t line_len = strlen(openfile->current->data + openfile->current_x);
#ifndef NANO_TINY
/* If the type of action changed or the cursor moved to a different
* line, create a new undo item, otherwise update the existing item. */
if (action != openfile->last_action ||
openfile->current->lineno != openfile->current_undo->lineno)
add_undo(action);
add_undo(action, NULL);
else
update_undo(action);
@@ -52,14 +50,14 @@ void do_deletion(undo_type action)
old_amount = number_of_chunks_in(openfile->current);
#endif
/* Move the remainder of the line "in", over the current character. */
charmove(&openfile->current->data[openfile->current_x],
&openfile->current->data[openfile->current_x + char_len],
line_len - char_len + 1);
memmove(&openfile->current->data[openfile->current_x],
&openfile->current->data[openfile->current_x + charlen],
line_len - charlen + 1);
#ifndef NANO_TINY
/* Adjust the mark if it is after the cursor on the current line. */
if (openfile->mark == openfile->current &&
openfile->mark_x > openfile->current_x)
openfile->mark_x -= char_len;
openfile->mark_x -= charlen;
#endif
/* Otherwise, when not at end of buffer, join this line with the next. */
} else if (openfile->current != openfile->filebot) {
@@ -67,16 +65,16 @@ void do_deletion(undo_type action)
/* If there is a magic line, and we're before it: don't eat it. */
if (joining == openfile->filebot && openfile->current_x != 0 &&
ISSET(FINAL_NEWLINE)) {
!ISSET(NO_NEWLINES)) {
#ifndef NANO_TINY
if (action == BACK)
add_undo(BACK);
add_undo(BACK, NULL);
#endif
return;
}
#ifndef NANO_TINY
add_undo(action);
add_undo(action, NULL);
#endif
/* Add the contents of the next line to those of the current one. */
openfile->current->data = charealloc(openfile->current->data,
@@ -91,7 +89,7 @@ void do_deletion(undo_type action)
}
#endif
unlink_node(joining);
renumber(openfile->current);
renumber_from(openfile->current);
/* Two lines were joined, so we need to refresh the screen. */
refresh_needed = TRUE;
@@ -148,12 +146,10 @@ void chop_word(bool forward)
/* Remember the current cursor position. */
linestruct *is_current = openfile->current;
size_t is_current_x = openfile->current_x;
/* Remember where the cutbuffer is and then make it seem blank. */
/* Remember where the cutbuffer is, then make it seem blank. */
linestruct *is_cutbuffer = cutbuffer;
linestruct *is_cutbottom = cutbottom;
cutbuffer = NULL;
cutbottom = NULL;
/* Move the cursor to a word start, to the left or to the right.
* If that word is on another line and the cursor was not already
@@ -186,28 +182,192 @@ void chop_word(bool forward)
openfile->current_x = is_current_x;
/* Now kill the marked region and a word is gone. */
do_cut_text_void();
add_undo(CUT, NULL);
do_snip(FALSE, TRUE, FALSE, FALSE);
update_undo(CUT);
/* Discard the cut word and restore the cutbuffer. */
free_lines(cutbuffer);
cutbuffer = is_cutbuffer;
cutbottom = is_cutbottom;
}
/* Delete a word leftward. */
void chop_previous_word(void)
{
chop_word(BACKWARD);
if (openfile->current->prev == NULL && openfile->current_x == 0)
statusbar(_("Nothing was cut"));
else
chop_word(BACKWARD);
}
/* Delete a word rightward. */
void chop_next_word(void)
{
openfile->mark = NULL;
if (is_cuttable(openfile->current_x > 0))
chop_word(FORWARD);
}
#endif /* !NANO_TINY */
/* Move all text between (top, top_x) and (bot, bot_x) from the current buffer
* into the cutbuffer. */
void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
{
bool edittop_inside = (openfile->edittop->lineno >= top->lineno &&
openfile->edittop->lineno <= bot->lineno);
#ifndef NANO_TINY
bool mark_inside = (openfile->mark &&
openfile->mark->lineno >= top->lineno &&
openfile->mark->lineno <= bot->lineno &&
(openfile->mark != top || openfile->mark_x >= top_x) &&
(openfile->mark != bot || openfile->mark_x <= bot_x));
bool same_line = (openfile->mark == top);
if (top == bot && top_x == bot_x)
return;
#endif
/* Reduce the buffer to cover just the text that needs to be extracted. */
partition_buffer(top, top_x, bot, bot_x);
/* Subtract the number of characters in that text from the file size. */
openfile->totsize -= get_totsize(top, bot);
/* If the cutbuffer is currently empty, just move all the text directly
* into it; otherwise, append the text to what is already there. */
if (cutbuffer == NULL) {
cutbuffer = openfile->filetop;
cutbottom = openfile->filebot;
} else {
/* Tack the data of the first line of the text onto the data of
* the last line in the given buffer. */
cutbottom->data = charealloc(cutbottom->data,
strlen(cutbottom->data) +
strlen(openfile->filetop->data) + 1);
strcat(cutbottom->data, openfile->filetop->data);
/* Attach the second line of the text (if any) to the last line
* of the buffer, then remove the now superfluous first line. */
cutbottom->next = openfile->filetop->next;
delete_node(openfile->filetop);
/* If there is a second line, make the reverse attachment too and
* update the buffer pointer to point at the end of the text. */
if (cutbottom->next != NULL) {
cutbottom->next->prev = cutbottom;
cutbottom = openfile->filebot;
}
}
/* Since the text has now been saved, remove it from the file buffer. */
openfile->filetop = make_new_node(NULL);
openfile->filetop->data = copy_of("");
openfile->filebot = openfile->filetop;
/* Set the cursor at the point where the text was removed. */
openfile->current = openfile->filetop;
openfile->current_x = top_x;
#ifndef NANO_TINY
/* If the mark was inside the partition, put it where the cursor now is. */
if (mark_inside) {
openfile->mark = openfile->current;
openfile->mark_x = openfile->current_x;
} else if (same_line)
/* Update the pointer to this partially cut line. */
openfile->mark = openfile->current;
#endif
/* Glue the texts before and after the extraction together. */
unpartition_buffer();
renumber_from(openfile->current);
/* If the top of the edit window was inside the old partition, put
* it in range of current. */
if (edittop_inside) {
adjust_viewport(STATIONARY);
refresh_needed = TRUE;
}
/* If the text doesn't end with a newline, and it should, add one. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();
}
/* Meld the buffer that starts at topline into the current file buffer
* at the current cursor position. */
void ingraft_buffer(linestruct *topline)
{
size_t current_x_save = openfile->current_x;
/* Remember whether the current line is at the top of the edit window. */
bool edittop_inside = (openfile->edittop == openfile->current);
#ifndef NANO_TINY
/* Remember whether mark and cursor are on the same line, and their order. */
bool same_line = (openfile->mark == openfile->current);
bool right_side_up = (openfile->mark &&
(openfile->mark->lineno < openfile->current->lineno ||
(same_line && openfile->mark_x <= openfile->current_x)));
#endif
/* Partition the buffer so that it contains no text, then delete it.*/
partition_buffer(openfile->current, openfile->current_x,
openfile->current, openfile->current_x);
delete_node(openfile->filetop);
/* Replace the current buffer with the passed buffer. */
openfile->filetop = topline;
openfile->filebot = topline;
while (openfile->filebot->next != NULL)
openfile->filebot = openfile->filebot->next;
/* Put the cursor at the end of the pasted text. */
openfile->current = openfile->filebot;
openfile->current_x = strlen(openfile->filebot->data);
/* When the pasted stuff contains no newline, adjust the cursor's
* x coordinate for the text that is before the pasted stuff. */
if (openfile->filetop == openfile->filebot)
openfile->current_x += current_x_save;
#ifndef NANO_TINY
/* When needed, refresh the mark's pointer and compensate the mark's
* x coordinate for the change in the current line. */
if (same_line) {
if (!right_side_up) {
openfile->mark = openfile->filebot;
openfile->mark_x += openfile->current_x - current_x_save;
} else
openfile->mark = openfile->filetop;
}
#endif
/* Add the number of characters in the copied text to the file size. */
openfile->totsize += get_totsize(openfile->filetop, openfile->filebot);
/* If we pasted onto the first line of the edit window, the corresponding
* record has been freed, so... point at the start of the copied text. */
if (edittop_inside)
openfile->edittop = openfile->filetop;
/* Weld the pasted text into the surrounding content of the buffer. */
unpartition_buffer();
renumber_from(topline);
/* If the text doesn't end with a newline, and it should, add one. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();
}
/* Meld a copy of the given buffer into the current file buffer. */
void copy_from_buffer(linestruct *somebuffer)
{
linestruct *the_copy = copy_buffer(somebuffer);
ingraft_buffer(the_copy);
}
/* Move the whole current line from the current buffer to the cutbuffer. */
void cut_line(void)
{
@@ -215,28 +375,15 @@ void cut_line(void)
* head of this line to the head of the next line into the cutbuffer;
* otherwise, move all of the text of this line into the cutbuffer. */
if (openfile->current != openfile->filebot)
extract_buffer(&cutbuffer, &cutbottom, openfile->current, 0,
openfile->current->next, 0);
extract_segment(openfile->current, 0, openfile->current->next, 0);
else
extract_buffer(&cutbuffer, &cutbottom, openfile->current, 0,
extract_segment(openfile->current, 0,
openfile->current, strlen(openfile->current->data));
openfile->placewewant = 0;
}
#ifndef NANO_TINY
/* Move all marked text from the current buffer into the cutbuffer. */
void cut_marked(bool *right_side_up)
{
linestruct *top, *bot;
size_t top_x, bot_x;
mark_order((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x, right_side_up);
extract_buffer(&cutbuffer, &cutbottom, top, top_x, bot, bot_x);
openfile->placewewant = xplustabs();
}
/* Move all text from the cursor position until the end of this line into
* the cutbuffer. But when already at the end of a line, then move this
* "newline" to the cutbuffer. */
@@ -248,87 +395,101 @@ void cut_to_eol(void)
* the cutbuffer. Otherwise, when not at the end of the buffer,
* move the line separation into the cutbuffer. */
if (openfile->current_x < data_len)
extract_buffer(&cutbuffer, &cutbottom, openfile->current,
openfile->current_x, openfile->current, data_len);
extract_segment(openfile->current, openfile->current_x,
openfile->current, data_len);
else if (openfile->current != openfile->filebot) {
extract_buffer(&cutbuffer, &cutbottom, openfile->current,
openfile->current_x, openfile->current->next, 0);
extract_segment(openfile->current, openfile->current_x,
openfile->current->next, 0);
openfile->placewewant = xplustabs();
}
}
/* Move all marked text from the current buffer into the cutbuffer. */
void cut_marked(bool *right_side_up)
{
linestruct *top, *bot;
size_t top_x, bot_x;
get_region((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x, right_side_up);
extract_segment(top, top_x, bot, bot_x);
openfile->placewewant = xplustabs();
}
/* Move all text from the cursor position to end-of-file into the cutbuffer. */
void cut_to_eof(void)
{
extract_buffer(&cutbuffer, &cutbottom,
openfile->current, openfile->current_x,
extract_segment(openfile->current, openfile->current_x,
openfile->filebot, strlen(openfile->filebot->data));
}
#endif /* !NANO_TINY */
/* Move text from the current buffer into the cutbuffer. If
* copy_text is TRUE, copy the text back into the buffer afterward.
* If cut_till_eof is TRUE, move all text from the current cursor
* copying is TRUE, copy the text back into the buffer afterward.
* If until_eof is TRUE, move all text from the current cursor
* position to the end of the file into the cutbuffer. If append
* is TRUE (when zapping), always append the cut to the cutbuffer. */
void do_cut_text(bool copy_text, bool marked, bool cut_till_eof, bool append)
void do_snip(bool copying, bool marked, bool until_eof, bool append)
{
#ifndef NANO_TINY
linestruct *cb_save = NULL;
linestruct *was_bottom = NULL;
/* The current end of the cutbuffer, before we add text to it. */
size_t cb_save_len = 0;
size_t botlen = 0;
/* The length of the string at the current end of the cutbuffer,
* before we add text to it. */
bool using_magicline = ISSET(FINAL_NEWLINE);
bool using_magicline = !ISSET(NO_NEWLINES);
/* Whether an automatic newline should be added at end-of-buffer. */
bool right_side_up = TRUE;
/* There *is* no region, *or* it is marked forward. */
#endif
static bool precedent = FALSE;
/* Whether the previous operation was a copying operation. */
/* If cuts were not continuous, or when cutting a region, clear the slate. */
if (!append && (!keep_cutbuffer || marked || cut_till_eof)) {
if ((!keep_cutbuffer || marked || until_eof || copying != precedent) &&
!append) {
free_lines(cutbuffer);
cutbuffer = NULL;
/* After a line cut, future line cuts should add to the cutbuffer. */
keep_cutbuffer = !marked && !cut_till_eof;
}
/* After a line operation, future ones should add to the cutbuffer. */
keep_cutbuffer = !marked && !until_eof;
precedent = copying;
#ifndef NANO_TINY
if (copy_text) {
if (copying) {
/* If the cutbuffer isn't empty, remember where it currently ends. */
if (cutbuffer != NULL) {
cb_save = cutbottom;
cb_save_len = strlen(cutbottom->data);
was_bottom = cutbottom;
botlen = strlen(cutbottom->data);
}
/* Don't add a magic line when moving text to the cutbuffer. */
UNSET(FINAL_NEWLINE);
SET(NO_NEWLINES);
}
if (cut_till_eof) {
/* Move all text up to the end of the file into the cutbuffer. */
/* Now move the relevant piece of text into the cutbuffer. */
if (until_eof)
cut_to_eof();
} else if (openfile->mark) {
/* Move the marked text to the cutbuffer, and turn the mark off. */
else if (openfile->mark) {
cut_marked(&right_side_up);
openfile->mark = NULL;
} else if (ISSET(CUT_FROM_CURSOR))
/* Move all text up to the end of the line into the cutbuffer. */
cut_to_eol();
else
#endif
/* Move the entire line into the cutbuffer. */
cut_line();
#ifndef NANO_TINY
if (copy_text) {
/* Copy the text that is in the cutbuffer (starting at its saved end,
* if there is one) back into the current buffer. This effectively
* uncuts the text we just cut. */
if (copying) {
/* Copy the text that was put into the cutbuffer back into the current
* file buffer, so that in the end nothing has been deleted. */
if (cutbuffer != NULL) {
if (cb_save != NULL) {
cb_save->data += cb_save_len;
copy_from_buffer(cb_save);
cb_save->data -= cb_save_len;
if (was_bottom != NULL) {
was_bottom->data += botlen;
copy_from_buffer(was_bottom);
was_bottom->data -= botlen;
} else
copy_from_buffer(cutbuffer);
@@ -339,11 +500,11 @@ void do_cut_text(bool copy_text, bool marked, bool cut_till_eof, bool append)
}
/* Restore the magic-line behavior now that we're done fiddling. */
if (using_magicline)
SET(FINAL_NEWLINE);
UNSET(NO_NEWLINES);
} else
#endif /* !NANO_TINY */
#endif
set_modified();
set_modified();
refresh_needed = TRUE;
}
@@ -358,21 +519,21 @@ bool is_cuttable(bool test_cliff)
(openfile->mark == openfile->current &&
openfile->mark_x == openfile->current_x) ||
(test_cliff && openfile->current->data[openfile->current_x] == '\0' &&
((!ISSET(FINAL_NEWLINE) && openfile->current == openfile->filebot) ||
(ISSET(FINAL_NEWLINE) && openfile->current == openfile->filebot->prev))
((ISSET(NO_NEWLINES) && openfile->current == openfile->filebot) ||
(!ISSET(NO_NEWLINES) && openfile->current == openfile->filebot->prev))
#endif
)) {
#ifndef NANO_TINY
statusbar(_("Nothing was cut"));
openfile->mark = NULL;
#endif
statusbar(_("Nothing was cut"));
return FALSE;
} else
return TRUE;
}
/* Move text from the current buffer into the cutbuffer. */
void do_cut_text_void(void)
void cut_text(void)
{
#ifndef NANO_TINY
if (!is_cuttable(ISSET(CUT_FROM_CURSOR) && openfile->mark == NULL))
@@ -380,25 +541,27 @@ void do_cut_text_void(void)
/* Only add a new undo item when the current item is not a CUT or when
* the current cut is not contiguous with the previous cutting. */
if (openfile->last_action != CUT || openfile->current_undo == NULL ||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
!keep_cutbuffer)
add_undo(CUT);
do_cut_text(FALSE, openfile->mark != NULL, FALSE, FALSE);
if (openfile->last_action != CUT || !keep_cutbuffer) {
keep_cutbuffer = FALSE;
add_undo(CUT, NULL);
}
do_snip(FALSE, openfile->mark != NULL, FALSE, FALSE);
update_undo(CUT);
#else
if (is_cuttable(FALSE))
do_cut_text(FALSE, FALSE, FALSE, FALSE);
do_snip(FALSE, FALSE, FALSE, FALSE);
#endif
wipe_statusbar();
}
#ifndef NANO_TINY
/* Move text from the current buffer into the cutbuffer, and copy it
* back into the buffer afterward. If the mark is set or the cursor
* was moved, blow away previous contents of the cutbuffer. */
void do_copy_text(void)
void copy_text(void)
{
static linestruct *next_contiguous_line = NULL;
bool mark_is_set = (openfile->mark != NULL);
/* Remember the current viewport and cursor position. */
@@ -407,36 +570,34 @@ void do_copy_text(void)
ssize_t is_current_lineno = openfile->current->lineno;
size_t is_current_x = openfile->current_x;
if (mark_is_set || openfile->current != next_contiguous_line)
keep_cutbuffer = FALSE;
do_cut_text(TRUE, mark_is_set, FALSE, FALSE);
/* If the mark was set, blow away the cutbuffer on the next copy. */
next_contiguous_line = (mark_is_set ? NULL : openfile->current);
do_snip(TRUE, mark_is_set, FALSE, FALSE);
/* If the mark was set, restore the viewport and cursor position. */
if (mark_is_set) {
openfile->edittop = fsfromline(is_edittop_lineno);
openfile->edittop = line_from_number(is_edittop_lineno);
openfile->firstcolumn = is_firstcolumn;
openfile->current = fsfromline(is_current_lineno);
openfile->current = line_from_number(is_current_lineno);
openfile->current_x = is_current_x;
}
} else
focusing = FALSE;
openfile->last_action = OTHER;
}
/* Cut from the current cursor position to the end of the file. */
void do_cut_till_eof(void)
void cut_till_eof(void)
{
if ((openfile->current == openfile->filebot && openfile->current->data[0] == '\0') ||
(ISSET(FINAL_NEWLINE) && openfile->current->next == openfile->filebot &&
(!ISSET(NO_NEWLINES) && openfile->current->next == openfile->filebot &&
openfile->current->data[openfile->current_x] == '\0')) {
statusbar(_("Nothing was cut"));
return;
}
add_undo(CUT_TO_EOF);
do_cut_text(FALSE, FALSE, TRUE, FALSE);
add_undo(CUT_TO_EOF, NULL);
do_snip(FALSE, FALSE, TRUE, FALSE);
update_undo(CUT_TO_EOF);
wipe_statusbar();
}
/* Erase text (current line or marked region), sending it into oblivion. */
@@ -444,33 +605,29 @@ void zap_text(void)
{
/* Remember the current cutbuffer so it can be restored after the zap. */
linestruct *was_cutbuffer = cutbuffer;
linestruct *was_cutbottom = cutbottom;
if (!is_cuttable(ISSET(CUT_FROM_CURSOR) && openfile->mark == NULL))
return;
/* Add a new undo item only when the current item is not a ZAP or when
* the current zap is not contiguous with the previous zapping. */
if (openfile->last_action != ZAP || openfile->current_undo == NULL ||
openfile->current_undo->mark_begin_lineno != openfile->current->lineno ||
openfile->current_undo->xflags & (MARK_WAS_SET|WAS_MARKED_FORWARD))
add_undo(ZAP);
if (openfile->last_action != ZAP || !keep_cutbuffer)
add_undo(ZAP, NULL);
/* Use the cutbuffer from the ZAP undo item, so the cut can be undone. */
cutbuffer = openfile->current_undo->cutbuffer;
cutbottom = openfile->current_undo->cutbottom;
do_cut_text(FALSE, openfile->mark != NULL, FALSE, TRUE);
do_snip(FALSE, openfile->mark != NULL, FALSE, TRUE);
update_undo(ZAP);
wipe_statusbar();
cutbuffer = was_cutbuffer;
cutbottom = was_cutbottom;
}
#endif /* !NANO_TINY */
/* Copy text from the cutbuffer into the current buffer. */
void do_uncut_text(void)
void paste_text(void)
{
ssize_t was_lineno = openfile->current->lineno;
/* The line number where we started the paste. */
@@ -478,12 +635,12 @@ void do_uncut_text(void)
/* The leftedge where we started the paste. */
if (cutbuffer == NULL) {
statusbar(_("The cutbuffer is empty"));
statusbar(_("Cutbuffer is empty"));
return;
}
#ifndef NANO_TINY
add_undo(PASTE);
add_undo(PASTE, NULL);
if (ISSET(SOFTWRAP))
was_leftedge = leftedge_for(xplustabs(), openfile->current);
@@ -505,5 +662,6 @@ void do_uncut_text(void)
openfile->placewewant = xplustabs();
set_modified();
wipe_statusbar();
refresh_needed = TRUE;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,9 @@
/**************************************************************************
* help.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2000-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 2000-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2017 Rishabh Dave *
* Copyright (C) 2014-2018 Benno Schulenberg *
* Copyright (C) 2014-2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -22,11 +22,11 @@
#include "proto.h"
#ifdef ENABLE_HELP
#include <errno.h>
#include <string.h>
#ifdef ENABLE_HELP
static char *help_text = NULL;
/* The text displayed in the help window. */
@@ -39,45 +39,57 @@ static char *end_of_intro = NULL;
static size_t location;
/* The offset (in bytes) of the topleft of the shown help text. */
char *tempfilename = NULL;
/* Name of the temporary file used for wrapping the help text. */
/* Hard-wrap the help text, write it to the existing temporary file, and
* read that file into a new buffer. */
void wrap_the_help_text(bool redisplaying)
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
void wrap_help_text_into_buffer(void)
{
size_t sum = 0;
/* Avoid overtight and overwide paragraphs in the introductory text. */
size_t wrapping_point = (COLS < 32) ? 32 : (COLS > 74) ? 74 : COLS;
const char *ptr = start_of_body;
FILE *tempfile = fopen(tempfilename, "w+b");
/* If re-opening the temporary file failed, give up. */
if (tempfile == NULL) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
return;
}
make_new_buffer();
/* Write the body of the help_text into the temporary file. */
/* Copy the help text into the just-created new buffer. */
while (*ptr != '\0') {
int length = help_line_len(ptr);
int length, shim;
char *oneline;
if (ptr == end_of_intro)
wrapping_point = (COLS < 32) ? 32 : COLS;
if (ptr > end_of_intro && *(ptr - 1) != '\n') {
length = break_line(ptr, (COLS < 32) ? 14 : COLS - 18, TRUE);
oneline = nmalloc(length + 5);
snprintf(oneline, length + 5, "\t\t %s", ptr);
} else {
length = break_line(ptr, wrapping_point, TRUE);
oneline = nmalloc(length + 1);
shim = (*(ptr + length - 1) == ' ') ? 0 : 1;
snprintf(oneline, length + shim, "%s", ptr);
}
free(openfile->current->data);
openfile->current->data = oneline;
fwrite(ptr, sizeof(char), length, tempfile);
ptr += length;
/* Hard-wrap the lines in the help text. */
if (*ptr != '\n')
fwrite("\n", sizeof(char), 1, tempfile);
else while (*ptr == '\n')
fwrite(ptr++, sizeof(char), 1, tempfile);
ptr--;
/* Create a new line, and then one more for each extra \n. */
do {
openfile->current->next = make_new_node(openfile->current);
openfile->current = openfile->current->next;
openfile->current->data = copy_of("");
} while (*(++ptr) == '\n');
}
fclose(tempfile);
openfile->filebot = openfile->current;
openfile->current = openfile->filetop;
if (redisplaying)
close_buffer();
open_buffer(tempfilename, TRUE);
remove_magicline();
#ifdef ENABLE_COLOR
color_update();
#endif
prepare_for_display();
/* Move to the position in the file where we were before. */
@@ -91,8 +103,8 @@ void wrap_the_help_text(bool redisplaying)
openfile->edittop = openfile->current;
}
/* Our main help-viewer function. */
void do_help(void)
/* Assemble a help text, display it, and allow scrolling through it. */
void show_help(void)
{
int kbinput = ERR;
functionptrtype func;
@@ -106,26 +118,15 @@ void do_help(void)
#ifdef ENABLE_COLOR
char *was_syntax = syntaxstr;
#endif
char *saved_answer = (answer != NULL) ? strdup(answer) : NULL;
char *saved_answer = (answer != NULL) ? copy_of(answer) : NULL;
/* The current answer when the user invokes help at the prompt. */
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
linestruct *line;
int length;
FILE *fp;
blank_statusbar();
/* Get a temporary file for the help text. If it fails, give up. */
tempfilename = safe_tempfile(&fp);
if (tempfilename == NULL) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
free(saved_answer);
return;
}
fclose(fp);
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
@@ -154,8 +155,9 @@ void do_help(void)
#endif
curs_set(0);
/* Compose the help text from all the pieces. */
/* Compose the help text from all the relevant pieces. */
help_init();
inhelp = TRUE;
location = 0;
didfind = 0;
@@ -164,8 +166,7 @@ void do_help(void)
/* Extract the title from the head of the help text. */
length = break_line(help_text, MAX_BUF_SIZE, TRUE);
title = charalloc(length * sizeof(char) + 1);
strncpy(title, help_text, length);
title = measured_copy(help_text, length + 1);
title[length] = '\0';
titlebar(title);
@@ -175,7 +176,7 @@ void do_help(void)
while (*start_of_body == '\n')
start_of_body++;
wrap_the_help_text(FALSE);
wrap_help_text_into_buffer();
edit_refresh();
while (TRUE) {
@@ -186,7 +187,13 @@ void do_help(void)
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
didfind = 0;
func = parse_help_input(&kbinput);
#ifndef NANO_TINY
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
func = interpret(&kbinput);
if (func == total_refresh) {
total_redraw();
@@ -210,19 +217,16 @@ void do_help(void)
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MHELP, func)->expansion);
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
#ifdef ENABLE_MOUSE
} else if (kbinput == KEY_MOUSE) {
int dummy_row, dummy_col;
get_mouseinput(&dummy_row, &dummy_col, TRUE);
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
} else if (func == do_exit) {
/* Exit from the help viewer. */
close_buffer();
curs_set(0);
break;
} else
unbound_key(kbinput);
@@ -240,6 +244,9 @@ void do_help(void)
}
}
/* Discard the help-text buffer. */
close_buffer();
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
@@ -250,35 +257,35 @@ void do_help(void)
tabsize = was_tabsize;
#ifdef ENABLE_COLOR
syntaxstr = was_syntax;
have_palette = FALSE;
#endif
/* Switch back to the buffer we were invoked from. */
switch_to_prev_buffer();
free(title);
title = NULL;
free(answer);
answer = saved_answer;
free(help_text);
inhelp = FALSE;
curs_set(0);
if (ISSET(NO_HELP)) {
currmenu = oldmenu;
window_init();
} else
} else {
wipe_statusbar();
bottombars(oldmenu);
free(title);
title = NULL;
inhelp = FALSE;
}
#ifdef ENABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
browser_refresh();
else
#endif
total_refresh();
free(answer);
answer = saved_answer;
remove(tempfilename);
free(tempfilename);
free(help_text);
{
titlebar(NULL);
edit_refresh();
}
}
/* Allocate space for the help text for the current menu, and concatenate
@@ -291,8 +298,8 @@ void help_init(void)
/* Untranslated help introduction. We break it up into three chunks
* in case the full string is too long for the compiler to handle. */
char *ptr;
const subnfunc *f;
const sc *s;
const funcstruct *f;
const keystruct *s;
/* First, set up the initial help text for the current function. */
if (currmenu == MWHEREIS || currmenu == MREPLACE || currmenu == MREPLACEWITH) {
@@ -464,22 +471,22 @@ void help_init(void)
allocsize += strlen(htx[2]);
/* Calculate the length of the shortcut help text. Each entry has
* one or two keys, which fill 16 columns, plus translated text,
* one or two keys, which fill 17 cells, plus translated text,
* plus one or two \n's. */
for (f = allfuncs; f != NULL; f = f->next)
if (f->menus & currmenu)
allocsize += (16 * MAXCHARLEN) + strlen(_(f->help)) + 2;
allocsize += strlen(_(f->help)) + 21;
#ifndef NANO_TINY
/* If we're on the main list, we also count the toggle help text.
* Each entry has "M-%c\t\t", five chars which fill 16 columns,
* plus a space, plus translated text, plus one or two '\n's. */
* Each entry has "M-%c\t\t ", six chars which fill 17 cells, plus
* two translated texts, plus a space, plus one or two '\n's. */
if (currmenu == MMAIN) {
size_t endis_len = strlen(_("enable/disable"));
size_t onoff_len = strlen(_("enable/disable"));
for (s = sclist; s != NULL; s = s->next)
if (s->func == do_toggle_void)
allocsize += strlen(_(flagtostr(s->toggle))) + endis_len + 8;
allocsize += strlen(_(flagtostr(s->toggle))) + onoff_len + 9;
}
#endif
@@ -493,40 +500,39 @@ void help_init(void)
if (htx[2] != NULL)
strcat(help_text, htx[2]);
ptr = help_text + strlen(help_text);
/* Remember this end-of-introduction, start-of-shortcuts. */
end_of_intro = ptr;
end_of_intro = help_text + strlen(help_text);
ptr = end_of_intro;
/* Now add our shortcut info. */
/* Now add the shortcuts and their descriptions. */
for (f = allfuncs; f != NULL; f = f->next) {
int tally = 0;
if ((f->menus & currmenu) == 0)
continue;
/* Let's simply show the first two shortcuts from the list. */
/* Show the first two shortcuts (if any) for each function. */
for (s = sclist; s != NULL; s = s->next) {
if ((s->menus & currmenu) && s->func == f->func) {
/* Make the first column narrower (6) than the second (10),
* but allow it to spill into the second, for "M-Space". */
/* Make the first column 7 cells wide and the second 10. */
if (++tally == 1) {
sprintf(ptr, "%s ", s->keystr);
sprintf(ptr, "%s ", s->keystr);
/* Unicode arrows take three bytes instead of one. */
ptr += (strstr(s->keystr, "\xE2") != NULL ? 8 : 6);
ptr += (strstr(s->keystr, "\xE2") != NULL ? 9 : 7);
} else {
ptr += sprintf(ptr, "(%s)\t", s->keystr);
sprintf(ptr, "(%s) ", s->keystr);
ptr += (strstr(s->keystr, "\xE2") != NULL ? 12 : 10);
break;
}
}
}
if (tally == 0)
ptr += sprintf(ptr, "\t\t");
ptr += sprintf(ptr, "\t\t ");
else if (tally == 1)
ptr += 10;
/* The shortcut's help text. */
/* The shortcut's description. */
ptr += sprintf(ptr, "%s\n", _(f->help));
if (f->blank_after)
@@ -547,7 +553,7 @@ void help_init(void)
counter++;
for (s = sclist; s != NULL; s = s->next)
if (s->toggle && s->ordinal == counter) {
ptr += sprintf(ptr, "%s\t\t%s %s\n", (s->menus == MMAIN ? s->keystr : ""),
ptr += sprintf(ptr, "%s\t\t %s %s\n", (s->menus == MMAIN ? s->keystr : ""),
_(flagtostr(s->toggle)), _("enable/disable"));
if (s->toggle == NO_COLOR_SYNTAX || s->toggle == TABS_TO_SPACES)
ptr += sprintf(ptr, "\n");
@@ -556,78 +562,14 @@ void help_init(void)
}
}
#endif /* !NANO_TINY */
if (strlen(help_text) > allocsize)
statusline(ALERT, "Help text spilled over -- please report a bug");
}
/* Return the function that is bound to the given key, accepting certain
* plain characters too, for consistency with the file browser. */
functionptrtype parse_help_input(int *kbinput)
{
if (!meta_key) {
switch (*kbinput) {
case BS_CODE:
case '-':
return do_page_up;
case ' ':
return do_page_down;
case 'W':
case 'w':
case '/':
return do_search_forward;
case 'N':
return do_findprevious;
case 'n':
return do_findnext;
case 'E':
case 'e':
case 'Q':
case 'q':
case 'X':
case 'x':
return do_exit;
}
}
return func_from_key(kbinput);
}
/* Calculate the displayable length of the help-text line starting at ptr. */
size_t help_line_len(const char *ptr)
{
size_t wrapping_point = (COLS > 24) ? COLS - 1 : 24;
/* The target width for wrapping long lines. */
ssize_t wrap_location;
/* Actual position where the line can be wrapped. */
size_t length = 0;
/* Full length of the line, until the first newline. */
/* Avoid overwide paragraphs in the introductory text. */
if (ptr < end_of_intro && COLS > 74)
wrapping_point = 74;
wrap_location = break_line(ptr, wrapping_point, TRUE);
/* Get the length of the entire line up to a null or a newline. */
while (*(ptr + length) != '\0' && *(ptr + length) != '\n')
length = move_mbright(ptr, length);
/* If the entire line will just fit the screen, don't wrap it. */
if (strnlenpt(ptr, length) <= wrapping_point + 1)
return length;
else if (wrap_location > 0)
return wrap_location;
else
return 1;
}
#endif /* ENABLE_HELP */
/* Start the help viewer. */
void do_help_void(void)
/* Start the help viewer, or indicate that there is no help. */
void do_help(void)
{
#ifdef ENABLE_HELP
do_help();
show_help();
#else
if (currmenu == MMAIN)
say_there_is_no_help();

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* history.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2003-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 2016-2017 Benno Schulenberg *
* Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -21,11 +21,11 @@
#include "proto.h"
#ifdef ENABLE_HISTORIES
#include <errno.h>
#include <string.h>
#ifdef ENABLE_HISTORIES
#ifndef SEARCH_HISTORY
#define SEARCH_HISTORY "search_history"
#endif
@@ -48,17 +48,17 @@ static poshiststruct *position_history = NULL;
void history_init(void)
{
search_history = make_new_node(NULL);
search_history->data = mallocstrcpy(NULL, "");
search_history->data = copy_of("");
searchtop = search_history;
searchbot = search_history;
replace_history = make_new_node(NULL);
replace_history->data = mallocstrcpy(NULL, "");
replace_history->data = copy_of("");
replacetop = replace_history;
replacebot = replace_history;
execute_history = make_new_node(NULL);
execute_history->data = mallocstrcpy(NULL, "");
execute_history->data = copy_of("");
executetop = execute_history;
executebot = execute_history;
}
@@ -119,7 +119,7 @@ void update_history(linestruct **item, const char *text)
*htop = after;
unlink_node(thesame);
renumber(after);
renumber_from(after);
}
/* If the history is full, delete the oldest item (the one at the
@@ -129,14 +129,14 @@ void update_history(linestruct **item, const char *text)
*htop = (*htop)->next;
unlink_node(oldest);
renumber(*htop);
renumber_from(*htop);
}
/* Store the fresh string in the last item, then create a new item. */
(*hbot)->data = mallocstrcpy((*hbot)->data, text);
splice_node(*hbot, make_new_node(*hbot));
*hbot = (*hbot)->next;
(*hbot)->data = mallocstrcpy(NULL, "");
(*hbot)->data = copy_of("");
/* Indicate that the history needs to be saved on exit. */
history_changed = TRUE;
@@ -229,19 +229,6 @@ char *get_history_completion(linestruct **h, char *s, size_t len)
}
#endif /* ENABLE_TABCOMP */
void history_error(const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
vfprintf(stderr, _(msg), ap);
va_end(ap);
fprintf(stderr, _("\nPress Enter to continue\n"));
while (getchar() != '\n')
;
}
/* Check whether we have or could make a directory for history files. */
bool have_statedir(void)
{
@@ -280,14 +267,14 @@ bool have_statedir(void)
free(statepath);
}
if (mkdir(statedir, S_IRWXU) == -1) {
history_error(N_("Unable to create directory %s: %s\n"
jot_error(N_("Unable to create directory %s: %s\n"
"It is required for saving/loading "
"search history or cursor positions.\n"),
statedir, strerror(errno));
return FALSE;
}
} else if (!S_ISDIR(dirstat.st_mode)) {
history_error(N_("Path %s is not a directory and needs to be.\n"
jot_error(N_("Path %s is not a directory and needs to be.\n"
"Nano will be unable to load or save "
"search history or cursor positions.\n"),
statedir);
@@ -308,7 +295,7 @@ void load_history(void)
if (errno != ENOENT) {
/* When reading failed, don't save history when we quit. */
UNSET(HISTORYLOG);
history_error(N_("Error reading %s: %s"), histname,
jot_error(N_("Error reading %s: %s"), histname,
strerror(errno));
}
} else {
@@ -404,7 +391,7 @@ void load_poshistory(void)
if (errno != ENOENT) {
/* When reading failed, don't save history when we quit. */
UNSET(POSITIONLOG);
history_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
}
} else {
char *line = NULL, *lineptr, *xptr;
@@ -414,7 +401,7 @@ void load_poshistory(void)
/* Read and parse each line, and store the extracted data. */
while ((read = getline(&line, &buf_len, hisfile)) > 5) {
/* Decode nulls as embedded newlines. */
/* Decode NULs as embedded newlines. */
unsunder(line, read);
/* Find where the x index and line number are in the line. */
@@ -431,7 +418,7 @@ void load_poshistory(void)
/* Create a new position record. */
newrecord = (poshiststruct *)nmalloc(sizeof(poshiststruct));
newrecord->filename = mallocstrcpy(NULL, line);
newrecord->filename = copy_of(line);
newrecord->lineno = atoi(lineptr);
newrecord->xno = atoi(xptr);
newrecord->next = NULL;
@@ -484,7 +471,7 @@ void save_poshistory(void)
posptr->filename, posptr->lineno, posptr->xno);
length = strlen(path_and_place);
/* Encode newlines in filenames as nulls. */
/* Encode newlines in filenames as NULs. */
sunder(path_and_place);
/* Restore the terminating newline. */
path_and_place[length - 1] = '\n';
@@ -528,7 +515,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
poshiststruct *posptr, *theone, *posprev = NULL;
char *fullpath = get_full_path(filename);
if (fullpath == NULL || fullpath[strlen(fullpath) - 1] == '/' || inhelp) {
if (fullpath == NULL || *filename == '\0') {
free(fullpath);
return;
}
@@ -563,7 +550,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
* not at the end, move the matching one to the end. */
if (theone == NULL) {
theone = (poshiststruct *)nmalloc(sizeof(poshiststruct));
theone->filename = mallocstrcpy(NULL, fullpath);
theone->filename = copy_of(fullpath);
if (position_history == NULL)
position_history = theone;
else

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* move.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2014-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -75,7 +75,7 @@ size_t proper_x(linestruct *line, size_t *leftedge, bool forward,
#ifndef NANO_TINY
if (ISSET(SOFTWRAP) && line->data[index] == '\t' &&
((forward && strnlenpt(line->data, index) < *leftedge) ||
((forward && wideness(line->data, index) < *leftedge) ||
(!forward && column / tabsize == (*leftedge - 1) / tabsize &&
column / tabsize < (*leftedge + editwincols - 1) / tabsize))) {
index++;
@@ -85,7 +85,7 @@ size_t proper_x(linestruct *line, size_t *leftedge, bool forward,
}
if (ISSET(SOFTWRAP))
*leftedge = leftedge_for(strnlenpt(line->data, index), line);
*leftedge = leftedge_for(wideness(line->data, index), line);
#endif
return index;
@@ -109,7 +109,7 @@ void set_proper_index_and_pww(size_t *leftedge, size_t target, bool forward)
openfile->placewewant = *leftedge + target;
}
/* Move up nearly one screenful. */
/* Move up almost one screenful. */
void do_page_up(void)
{
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
@@ -139,7 +139,7 @@ void do_page_up(void)
refresh_needed = TRUE;
}
/* Move down nearly one screenful. */
/* Move down almost one screenful. */
void do_page_down(void)
{
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
@@ -278,7 +278,7 @@ void do_prev_word(bool allow_punct)
}
/* Step back one character. */
openfile->current_x = move_mbleft(openfile->current->data,
openfile->current_x = step_left(openfile->current->data,
openfile->current_x);
if (is_word_mbchar(openfile->current->data + openfile->current_x,
@@ -296,7 +296,7 @@ void do_prev_word(bool allow_punct)
if (step_forward)
/* Move one character forward again to sit on the start of the word. */
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x = step_right(openfile->current->data,
openfile->current_x);
}
@@ -324,7 +324,7 @@ bool do_next_word(bool after_ends, bool allow_punct)
seen_space = TRUE;
} else {
/* Step forward one character. */
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x = step_right(openfile->current->data,
openfile->current_x);
}
@@ -534,7 +534,7 @@ void do_down(void)
}
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
/* Scroll up one line or chunk without scrolling the cursor. */
/* Scroll up one line or chunk without moving the cursor textwise. */
void do_scroll_up(void)
{
/* When the top of the file is onscreen, we can't scroll. */
@@ -548,18 +548,18 @@ void do_scroll_up(void)
edit_scroll(BACKWARD);
}
/* Scroll down one line or chunk without scrolling the cursor. */
/* Scroll down one line or chunk without moving the cursor textwise. */
void do_scroll_down(void)
{
if (openfile->current_y == 0)
do_down();
if (openfile->edittop->next != NULL
if (editwinrows > 1 && (openfile->edittop->next != NULL
#ifndef NANO_TINY
|| chunk_for(openfile->firstcolumn, openfile->edittop) <
number_of_chunks_in(openfile->edittop)
#endif
)
))
edit_scroll(FORWARD);
}
#endif
@@ -570,7 +570,7 @@ void do_left(void)
linestruct *was_current = openfile->current;
if (openfile->current_x > 0)
openfile->current_x = move_mbleft(openfile->current->data,
openfile->current_x = step_left(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->filetop) {
openfile->current = openfile->current->prev;
@@ -586,7 +586,7 @@ void do_right(void)
linestruct *was_current = openfile->current;
if (openfile->current->data[openfile->current_x] != '\0')
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x = step_right(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->filebot) {
openfile->current = openfile->current->next;

1330
src/nano.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* nano.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -19,9 +19,6 @@
* *
**************************************************************************/
#ifndef NANO_H
#define NANO_H 1
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -59,11 +56,9 @@
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
/* Macros for character allocation and more. */
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char))
#define charmove(dest, src, n) memmove(dest, src, (n) * sizeof(char))
#define charset(dest, src, n) memset(dest, src, (n) * sizeof(char))
/* Macros for allocation of character strings. */
#define charalloc(howmuch) (char *)nmalloc(howmuch)
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, howmuch)
/* In UTF-8 a character is at most six bytes long. */
#ifdef ENABLE_UTF8
@@ -113,14 +108,11 @@
#define N_(string) gettext_noop(string)
/* Mark a string that will be sent to gettext() later. */
#include <stddef.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <regex.h>
#include <signal.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/stat.h>
/* If we aren't using an ncurses with mouse support, exclude any
* mouse routines, as they are useless then. */
@@ -147,10 +139,12 @@
#define BAD_COLOR -2
#endif
#define STANDARD_INPUT 0
/* Enumeration types. */
typedef enum {
NIX_FILE, DOS_FILE, MAC_FILE
} file_format;
} format_type;
typedef enum {
HUSH, NOTICE, MILD, ALERT
@@ -188,21 +182,14 @@ typedef struct colortype {
/* This syntax's foreground color. */
short bg;
/* This syntax's background color. */
int pairnum;
/* The color pair number used for this foreground color and
* background color. */
short pairnum;
/* The pair number for this foreground/background color combination. */
int attributes;
/* Pair number and brightness composed into ready-to-use attributes. */
int rex_flags;
/* The regex compilation flags (with or without REG_ICASE). */
char *start_regex;
/* The start (or all) of the regex string. */
regex_t *start;
/* The compiled start (or all) of the regex string. */
char *end_regex;
/* The end (if any) of the regex string. */
/* The compiled regular expression for 'start=', or the only one. */
regex_t *end;
/* The compiled end (if any) of the regex string. */
/* The compiled regular expression for 'end=', if any. */
struct colortype *next;
/* Next set of colors. */
int id;
@@ -216,9 +203,26 @@ typedef struct regexlisttype {
/* The next regex. */
} regexlisttype;
typedef struct augmentstruct {
char *filename;
/* The file where the syntax is extended. */
ssize_t lineno;
/* The number of the line of the extendsyntax command. */
char *data;
/* The text of the line. */
struct augmentstruct *next;
/* Next node. */
} augmentstruct;
typedef struct syntaxtype {
char *name;
/* The name of this syntax. */
char *filename;
/* File where the syntax is defined, or NULL if not an included file. */
size_t lineno;
/* The line number where the 'syntax' command was found. */
struct augmentstruct *augmentations;
/* List of extendsyntax commands to apply when loaded. */
regexlisttype *extensions;
/* The list of extensions that this syntax applies to. */
regexlisttype *headers;
@@ -227,6 +231,10 @@ typedef struct syntaxtype {
/* The list of libmagic results that this syntax applies to. */
char *linter;
/* The command with which to lint this type of file. */
char *formatter;
/* The command with which to format/modify/arrange this type of file. */
char *tab;
/* What the Tab key should produce; NULL for default behavior. */
#ifdef ENABLE_COMMENT
char *comment;
/* The line comment prefix (and postfix) for this type of file. */
@@ -285,64 +293,44 @@ typedef struct linestruct {
#endif
} linestruct;
typedef struct partition {
linestruct *filetop;
/* The top line of this portion of the file. */
linestruct *top_prev;
/* The line before the top line of this portion of the file. */
char *top_data;
/* The text before the beginning of the top line of this portion
* of the file. */
linestruct *filebot;
/* The bottom line of this portion of the file. */
linestruct *bot_next;
/* The line after the bottom line of this portion of the
* file. */
char *bot_data;
/* The text after the end of the bottom line of this portion of
* the file. */
} partition;
#ifndef NANO_TINY
typedef struct undo_group {
typedef struct groupstruct {
ssize_t top_line;
/* First line of group. */
ssize_t bottom_line;
/* Last line of group. */
char **indentations;
/* String data used to restore the affected lines; one per line. */
struct undo_group *next;
} undo_group;
struct groupstruct *next;
/* The next group, if any. */
} groupstruct;
typedef struct undo {
ssize_t lineno;
typedef struct undostruct {
undo_type type;
/* What type of undo this was. */
/* The operation type that this undo item is for. */
int xflags;
/* Some flag data to mark certain corner cases. */
ssize_t lineno;
/* The line number where the operation began or ended. */
size_t begin;
/* Where did this action begin or end. */
/* The x position where the operation began or ended. */
char *strdata;
/* String type data we will use for copying the affected line back. */
/* String data to help restore the affected line. */
size_t wassize;
/* The file size before the action. */
size_t newsize;
/* The file size after the action. */
int xflags;
/* Some flag data we need. */
undo_group *grouping;
groupstruct *grouping;
/* Undo info specific to groups of lines. */
/* Cut-specific stuff we need. */
linestruct *cutbuffer;
/* Copy of the cutbuffer. */
linestruct *cutbottom;
/* Copy of cutbottom. */
/* A copy of the cutbuffer. */
ssize_t mark_begin_lineno;
/* Mostly the line number of the current line; sometimes something else. */
size_t mark_begin_x;
/* The x position corresponding to the above line number. */
struct undo *next;
struct undostruct *next;
/* A pointer to the undo item of the preceding action. */
} undo;
} undostruct;
#endif /* !NANO_TINY */
#ifdef ENABLE_HISTORIES
@@ -352,8 +340,9 @@ typedef struct poshiststruct {
ssize_t lineno;
/* Line number we left off on. */
ssize_t xno;
/* x position in the file we left off on. */
/* The x position in the file we left off on. */
struct poshiststruct *next;
/* The next item of position history. */
} poshiststruct;
#endif
@@ -379,10 +368,12 @@ typedef struct openfilestruct {
/* The file's x position we would like. */
ssize_t current_y;
/* The file's y-coordinate position. */
bool modified;
/* Whether the file has been modified. */
struct stat *current_stat;
/* The file's current stat information. */
#ifdef ENABLE_WRAPPING
linestruct *spillage_line;
/* The line for prepending stuff to during automatic hard-wrapping. */
#endif
#ifndef NANO_TINY
linestruct *mark;
/* The line in the file where the mark is set; NULL if not set. */
@@ -390,19 +381,21 @@ typedef struct openfilestruct {
/* The mark's x position in the above line. */
mark_type kind_of_mark;
/* Whether it is a soft (with Shift) or a hard mark. */
file_format fmt;
format_type fmt;
/* The file's format -- Unix or DOS or Mac or mixed. */
undo *undotop;
char *lock_filename;
/* The path of the lockfile, if we created one. */
undostruct *undotop;
/* The top of the undo list. */
undo *current_undo;
undostruct *current_undo;
/* The current (i.e. next) level of undo. */
undo *last_saved;
undostruct *last_saved;
/* The undo item at which the file was last saved. */
undo_type last_action;
/* The type of the last action the user performed. */
char *lock_filename;
/* The path of the lockfile, if we created one. */
#endif
bool modified;
/* Whether the file has been modified. */
#ifdef ENABLE_COLOR
syntaxtype *syntax;
/* The syntax struct for this file, if any. */
@@ -426,17 +419,15 @@ typedef struct rcoption {
} rcoption;
#endif
typedef struct sc {
typedef struct keystruct {
const char *keystr;
/* The string that describes a keystroke, like "^C" or "M-R". */
bool meta;
/* Whether this is a Meta keystroke. */
/* The string that describes the keystroke, like "^C" or "M-R". */
int keycode;
/* The integer that, together with meta, identifies the keystroke. */
int menus;
/* Which menus this applies to. */
/* The menus in which this keystroke is bound. */
void (*func)(void);
/* The function we're going to run. */
/* The function to which this keystroke is bound. */
#ifndef NANO_TINY
int toggle;
/* If a toggle, what we're toggling. */
@@ -448,11 +439,11 @@ typedef struct sc {
char *expansion;
/* The string of keycodes to which this shortcut is expanded. */
#endif
struct sc *next;
struct keystruct *next;
/* Next in the list. */
} sc;
} keystruct;
typedef struct subnfunc {
typedef struct funcstruct {
void (*func)(void);
/* The actual function to call. */
int menus;
@@ -470,9 +461,9 @@ typedef struct subnfunc {
/* Is this function allowed when in view mode? */
long toggle;
/* If this is a toggle, which toggle to affect. */
struct subnfunc *next;
struct funcstruct *next;
/* Next item in the list. */
} subnfunc;
} funcstruct;
#ifdef ENABLE_WORDCOMPLETION
typedef struct completion_word {
@@ -543,7 +534,6 @@ enum
AFTER_ENDS,
LET_THEM_ZAP,
BREAK_LONG_LINES,
FINAL_NEWLINE,
JUMPY_SCROLLING,
EMPTY_LINE
};
@@ -577,6 +567,7 @@ enum
/* Basic control codes. */
#define BS_CODE 0x08
#define TAB_CODE 0x09
#define CR_CODE 0x0D
#define ESC_CODE 0x1B
#define DEL_CODE 0x7F
@@ -615,6 +606,12 @@ enum
#define SHIFT_DELETE 0x45D
#define SHIFT_TAB 0x45F
/* A special keycode for when <Tab> is pressed while the mark is on. */
#define INDENT_KEY 0x4F1
/* A special keycode to signal the beginning and end of a bracketed paste. */
#define BRACKETED_PASTE_MARKER 0x4FB
#ifdef USE_SLANG
#ifdef ENABLE_UTF8
#define KEY_BAD 0xFF /* Clipped error code. */
@@ -636,9 +633,6 @@ enum
#define WAS_MARKED_FORWARD (1<<5)
#endif /* !NANO_TINY */
/* The maximum number of entries displayed in the main shortcut list. */
#define MAIN_VISIBLE (((COLS + 40) / 20) * 2)
/* The default number of columns from end of line where wrapping occurs. */
#define COLUMNS_FROM_EOL 8
@@ -657,5 +651,3 @@ enum
/* The largest size_t number that doesn't have the high bit set. */
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
#endif /* !NANO_H */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* prompt.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -24,26 +24,26 @@
#include <string.h>
static char *prompt = NULL;
/* The prompt string used for statusbar questions. */
/* The prompt string used for status-bar questions. */
static size_t typing_x = HIGHEST_POSITIVE;
/* The cursor position in answer. */
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
/* Handle a mouse click on the status-bar prompt or the shortcut list. */
int do_statusbar_mouse(void)
{
int click_row, click_col;
int retval = get_mouseinput(&click_row, &click_col, TRUE);
/* We can click on the statusbar window text to move the cursor. */
/* We can click on the status-bar window text to move the cursor. */
if (retval == 0 && wmouse_trafo(bottomwin, &click_row, &click_col, FALSE)) {
size_t start_col = strlenpt(prompt) + 2;
size_t start_col = breadth(prompt) + 2;
/* Move to where the click occurred. */
if (click_row == 0 && click_col >= start_col)
typing_x = actual_x(answer,
get_statusbar_page_start(start_col, start_col +
strnlenpt(answer, typing_x)) + click_col - start_col);
wideness(answer, typing_x)) + click_col - start_col);
}
return retval;
@@ -61,7 +61,7 @@ int do_statusbar_input(bool *finished)
/* The input buffer. */
static size_t kbinput_len = 0;
/* The length of the input buffer. */
const sc *shortcut;
const keystruct *shortcut;
*finished = FALSE;
@@ -115,7 +115,7 @@ int do_statusbar_input(bool *finished)
if ((shortcut || get_key_buffer_len() == 0) && kbinput != NULL) {
/* Inject all characters in the input buffer at once, filtering out
* control characters. */
do_statusbar_output(kbinput, kbinput_len, TRUE);
inject_into_answer(kbinput, kbinput_len, TRUE);
/* Empty the input buffer. */
kbinput_len = 0;
@@ -150,8 +150,8 @@ int do_statusbar_input(bool *finished)
else if (ISSET(RESTRICTED) && currmenu == MWRITEFILE &&
openfile->filename[0] != '\0' &&
(shortcut->func == do_verbatim_input ||
shortcut->func == do_cut_text_void ||
shortcut->func == do_uncut_text ||
shortcut->func == cut_text ||
shortcut->func == paste_text ||
shortcut->func == do_delete ||
shortcut->func == do_backspace))
;
@@ -161,13 +161,13 @@ int do_statusbar_input(bool *finished)
#endif
else if (shortcut->func == do_verbatim_input)
do_statusbar_verbatim_input();
else if (shortcut->func == do_cut_text_void)
else if (shortcut->func == cut_text)
do_statusbar_cut_text();
else if (shortcut->func == do_delete)
do_statusbar_delete();
else if (shortcut->func == do_backspace)
do_statusbar_backspace();
else if (shortcut->func == do_uncut_text) {
else if (shortcut->func == paste_text) {
if (cutbuffer != NULL)
do_statusbar_uncut_text();
} else {
@@ -185,12 +185,11 @@ int do_statusbar_input(bool *finished)
/* The user typed input_len multibyte characters. Add them to the answer,
* filtering out ASCII control characters if filtering is TRUE. */
void do_statusbar_output(int *the_input, size_t input_len,
bool filtering)
void inject_into_answer(int *the_input, size_t input_len, bool filtering)
{
char *output = charalloc(input_len + 1);
char onechar[MAXCHARLEN];
size_t char_len, i, j = 0;
size_t charlen, i, j = 0;
/* Copy the typed stuff so it can be treated. */
for (i = 0; i < input_len; i++)
@@ -203,21 +202,21 @@ void do_statusbar_output(int *the_input, size_t input_len,
output[j] = '\n';
/* Interpret the next multibyte character. */
char_len = parse_mbchar(output + j, onechar, NULL);
charlen = collect_char(output + j, onechar);
j += char_len;
j += charlen;
/* When filtering, skip any ASCII control character. */
if (filtering && is_ascii_cntrl_char(*(output + j - char_len)))
if (filtering && is_ascii_cntrl_char(*(output + j - charlen)))
continue;
/* Insert the typed character into the existing answer string. */
answer = charealloc(answer, strlen(answer) + char_len + 1);
charmove(answer + typing_x + char_len, answer + typing_x,
answer = charealloc(answer, strlen(answer) + charlen + 1);
memmove(answer + typing_x + charlen, answer + typing_x,
strlen(answer) - typing_x + 1);
strncpy(answer + typing_x, onechar, char_len);
strncpy(answer + typing_x, onechar, charlen);
typing_x += char_len;
typing_x += charlen;
}
free(output);
@@ -239,24 +238,24 @@ void do_statusbar_end(void)
void do_statusbar_left(void)
{
if (typing_x > 0)
typing_x = move_mbleft(answer, typing_x);
typing_x = step_left(answer, typing_x);
}
/* Move right one character. */
void do_statusbar_right(void)
{
if (answer[typing_x] != '\0')
typing_x = move_mbright(answer, typing_x);
typing_x = step_right(answer, typing_x);
}
/* Delete one character. */
void do_statusbar_delete(void)
{
if (answer[typing_x] != '\0') {
int char_len = parse_mbchar(answer + typing_x, NULL, NULL);
int charlen = char_length(answer + typing_x);
charmove(answer + typing_x, answer + typing_x + char_len,
strlen(answer) - typing_x - char_len + 1);
memmove(answer + typing_x, answer + typing_x + charlen,
strlen(answer) - typing_x - charlen + 1);
}
}
@@ -264,7 +263,7 @@ void do_statusbar_delete(void)
void do_statusbar_backspace(void)
{
if (typing_x > 0) {
typing_x = move_mbleft(answer, typing_x);
typing_x = step_left(answer, typing_x);
do_statusbar_delete();
}
}
@@ -288,7 +287,7 @@ void do_statusbar_next_word(void)
/* Move forward until we reach either the end or the start of a word,
* depending on whether the AFTER_ENDS flag is set or not. */
while (answer[typing_x] != '\0') {
typing_x = move_mbright(answer, typing_x);
typing_x = step_right(answer, typing_x);
if (ISSET(AFTER_ENDS)) {
/* If this is a word character, continue; else it's a separator,
@@ -315,7 +314,7 @@ void do_statusbar_prev_word(void)
/* Move backward until we pass over the start of a word. */
while (typing_x != 0) {
typing_x = move_mbleft(answer, typing_x);
typing_x = step_left(answer, typing_x);
if (is_word_mbchar(answer + typing_x, FALSE))
seen_a_word = TRUE;
@@ -328,7 +327,7 @@ void do_statusbar_prev_word(void)
if (step_forward)
/* Move one character forward again to sit on the start of the word. */
typing_x = move_mbright(answer, typing_x);
typing_x = step_right(answer, typing_x);
}
#endif /* !NANO_TINY */
@@ -340,7 +339,7 @@ void do_statusbar_verbatim_input(void)
kbinput = get_verbatim_kbinput(bottomwin, &kbinput_len);
do_statusbar_output(kbinput, kbinput_len, FALSE);
inject_into_answer(kbinput, kbinput_len, FALSE);
free(kbinput);
}
@@ -363,7 +362,7 @@ void do_statusbar_uncut_text(void)
}
/* Return the column number of the first character of the answer that is
* displayed in the statusbar when the cursor is at the given column,
* displayed in the status bar when the cursor is at the given column,
* with the available room for the answer starting at base. Note that
* (0 <= column - get_statusbar_page_start(column) < COLS). */
size_t get_statusbar_page_start(size_t base, size_t column)
@@ -385,16 +384,16 @@ void put_cursor_at_end_of_answer(void)
/* Redraw the promptbar and place the cursor at the right spot. */
void draw_the_promptbar(void)
{
size_t base = strlenpt(prompt) + 2;
size_t base = breadth(prompt) + 2;
size_t the_page, end_page, column;
char *expanded;
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, typing_x));
end_page = get_statusbar_page_start(base, base + strlenpt(answer) - 1);
the_page = get_statusbar_page_start(base, base + wideness(answer, typing_x));
end_page = get_statusbar_page_start(base, base + breadth(answer) - 1);
/* Color the promptbar over its full width. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
blank_statusbar();
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
mvwaddstr(bottomwin, 0, 0, prompt);
waddch(bottomwin, ':');
@@ -404,7 +403,7 @@ void draw_the_promptbar(void)
waddstr(bottomwin, expanded);
free(expanded);
if (base + strlenpt(answer) != COLS && the_page < end_page)
if (base + breadth(answer) != COLS && the_page < end_page)
mvwaddch(bottomwin, 0, COLS - 1, '>');
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
@@ -414,7 +413,7 @@ void draw_the_promptbar(void)
wrefresh(bottomwin);
/* Place the cursor at the right spot. */
column = base + strnlenpt(answer, typing_x);
column = base + wideness(answer, typing_x);
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
wnoutrefresh(bottomwin);
}
@@ -424,19 +423,19 @@ void draw_the_promptbar(void)
void add_or_remove_pipe_symbol_from_answer(void)
{
if (answer[0] == '|') {
charmove(answer, answer + 1, strlen(answer) + 1);
memmove(answer, answer + 1, strlen(answer) + 1);
if (typing_x > 0)
typing_x--;
} else {
answer = charealloc(answer, strlen(answer) + 2);
charmove(answer + 1, answer, strlen(answer) + 1);
memmove(answer + 1, answer, strlen(answer) + 1);
answer[0] = '|';
typing_x++;
}
}
#endif
/* Get a string of input at the statusbar prompt. */
/* Get a string of input at the status-bar prompt. */
functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
bool allow_files, bool *listed, linestruct **history_list,
void (*refresh_func)(void))
@@ -543,14 +542,18 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
}
} else
#endif /* ENABLE_HISTORIES */
if (func == do_help_void) {
if (func == do_help) {
/* This key has a shortcut-list entry when it's used to go to
* the help browser or display a message indicating that help
* the help viewer or display a message indicating that help
* is disabled, which means that finished has been set to TRUE.
* Set it back to FALSE here, so that we aren't kicked out of
* the statusbar prompt. */
* the status-bar prompt. */
finished = FALSE;
}
#ifndef NANO_TINY
else if (func == do_nothing)
finished = FALSE;
#endif
/* If we have a shortcut with an associated function, break out if
* we're finished after running or trying to run the function. */
@@ -575,30 +578,30 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
return func;
}
/* Ask a question on the statusbar. Return 0 when text was entered,
/* Ask a question on the status bar. Return 0 when text was entered,
* -1 for a cancelled entry, -2 for a blank string, and the relevant
* keycode when a valid shortcut key was pressed.
*
* The allow_tabs parameter indicates whether tab completion is allowed,
* and allow_files indicates whether all files (and not just directories)
* can be tab completed. The curranswer parameter is the default answer
* can be tab completed. The 'provided' parameter is the default answer
* for when simply Enter is typed. */
int do_prompt(bool allow_tabs, bool allow_files,
int menu, const char *curranswer, linestruct **history_list,
int menu, const char *provided, linestruct **history_list,
void (*refresh_func)(void), const char *msg, ...)
{
va_list ap;
int retval;
functionptrtype func = NULL;
bool listed = FALSE;
/* Save a possible current statusbar x position and prompt. */
/* Save a possible current status-bar x position and prompt. */
size_t was_typing_x = typing_x;
char *saved_prompt = prompt;
bottombars(menu);
if (answer != curranswer || answer == NULL)
answer = mallocstrcpy(answer, curranswer);
if (answer != provided)
answer = mallocstrcpy(answer, provided);
#ifndef NANO_TINY
redo_theprompt:
@@ -645,7 +648,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
}
/* Ask a simple Yes/No (and optionally All) question, specified in msg,
* on the statusbar. Return 1 for Yes, 0 for No, 2 for All (if all is
* on the status bar. Return 1 for Yes, 0 for No, 2 for All (if all is
* TRUE when passed in), and -1 for Cancel. */
int do_yesno_prompt(bool all, const char *msg)
{
@@ -667,7 +670,7 @@ int do_yesno_prompt(bool all, const char *msg)
if (!ISSET(NO_HELP)) {
char shortstr[MAXCHARLEN + 2];
/* Temporary string for (translated) " Y", " N" and " A". */
const sc *cancelshortcut = first_sc_for(MYESNO, do_cancel);
const keystruct *cancelshortcut = first_sc_for(MYESNO, do_cancel);
/* The keystroke that is bound to the Cancel function. */
if (COLS < 32)
@@ -695,9 +698,9 @@ int do_yesno_prompt(bool all, const char *msg)
post_one_key(cancelshortcut->keystr, _("Cancel"), width);
}
/* Color the statusbar over its full width and display the question. */
/* Color the promptbar over its full width and display the question. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
blank_statusbar();
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
wnoutrefresh(bottomwin);
@@ -707,6 +710,12 @@ int do_yesno_prompt(bool all, const char *msg)
/* When not replacing, show the cursor while waiting for a key. */
kbinput = get_kbinput(bottomwin, !all);
#ifndef NANO_TINY
/* Accept the first character of an external paste. */
if (bracketed_paste && kbinput == BRACKETED_PASTE_MARKER)
kbinput = get_kbinput(bottomwin, BLIND);
#endif
#ifdef ENABLE_NLS
letter[index++] = (unsigned char)kbinput;
#ifdef ENABLE_UTF8
@@ -738,6 +747,12 @@ int do_yesno_prompt(bool all, const char *msg)
choice = 2;
else if (func_from_key(&kbinput) == do_cancel)
choice = -1;
/* Interpret ^N and ^Q as "No", to allow exiting in anger. */
else if (kbinput == '\x0E' || kbinput == '\x11')
choice = 0;
/* And interpret ^Y as "Yes". */
else if (kbinput == '\x19')
choice = 1;
#ifdef ENABLE_MOUSE
else if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
@@ -756,6 +771,14 @@ int do_yesno_prompt(bool all, const char *msg)
}
}
#endif /* ENABLE_MOUSE */
else
beep();
#ifndef NANO_TINY
/* Ignore the rest of an external paste. */
while (bracketed_paste)
kbinput = get_kbinput(bottomwin, BLIND);
#endif
}
return choice;

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* proto.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -18,9 +18,6 @@
* *
**************************************************************************/
#ifndef PROTO_H
#define PROTO_H 1
#include "nano.h"
/* All external variables. See global.c for their descriptions. */
@@ -29,32 +26,44 @@
extern volatile sig_atomic_t the_window_resized;
#endif
#ifdef __linux__
extern bool on_a_vt;
#endif
extern bool shifted_metas;
extern bool meta_key;
extern bool shift_held;
extern bool mute_modifiers;
extern bool bracketed_paste;
extern bool started_curses;
extern bool we_are_running;
extern bool more_than_one;
extern bool inhelp;
extern char *title;
extern bool focusing;
extern bool as_an_at;
extern bool control_C_was_pressed;
extern bool suppress_cursorpos;
extern message_type lastmessage;
extern linestruct *pletion_line;
extern bool inhelp;
extern char *title;
extern bool more_than_one;
extern bool also_the_last;
extern char *answer;
extern char *last_search;
extern int didfind;
extern char *present_path;
extern unsigned flags[4];
extern int controlleft, controlright;
extern int controlup, controldown;
extern int controlhome, controlend;
@@ -73,15 +82,10 @@ extern int shiftaltup, shiftaltdown;
#endif
#ifdef ENABLED_WRAPORJUSTIFY
extern ssize_t fill, wrap_at;
extern ssize_t fill;
extern size_t wrap_at;
#endif
extern char *last_search;
extern char *present_path;
extern unsigned flags[4];
extern WINDOW *topwin;
extern WINDOW *edit;
extern WINDOW *bottomwin;
@@ -96,9 +100,10 @@ extern linestruct *cutbuffer;
extern linestruct *cutbottom;
extern bool keep_cutbuffer;
extern partition *filepart;
extern openfilestruct *openfile;
extern openfilestruct *firstfile;
#ifdef ENABLE_MULTIBUFFER
extern openfilestruct *startfile;
#endif
#ifndef NANO_TINY
extern char *matchbrackets;
@@ -117,14 +122,10 @@ extern regex_t quotereg;
extern char *word_chars;
extern char *answer;
extern ssize_t tabsize;
#ifndef NANO_TINY
extern char *backup_dir;
extern const char *locking_prefix;
extern const char *locking_suffix;
#endif
#ifdef ENABLE_OPERATINGDIR
extern char *operating_dir;
@@ -143,9 +144,9 @@ extern bool have_palette;
extern bool refresh_needed;
extern int currmenu;
extern sc *sclist;
extern subnfunc *allfuncs;
extern subnfunc *exitfunc;
extern keystruct *sclist;
extern funcstruct *allfuncs;
extern funcstruct *exitfunc;
extern linestruct *search_history;
extern linestruct *replace_history;
@@ -170,8 +171,11 @@ extern int interface_color_pair[NUMBER_OF_ELEMENTS];
extern char *homedir;
extern char *statedir;
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
extern char *startup_problem;
#endif
#ifdef ENABLE_NANORC
extern char *rcfile_with_errors;
extern char *custom_nanorc;
#endif
extern bool spotlighted;
@@ -207,18 +211,21 @@ bool is_ascii_cntrl_char(int c);
bool is_cntrl_mbchar(const char *c);
bool is_word_mbchar(const char *c, bool allow_punct);
char control_mbrep(const char *c, bool isdata);
int length_of_char(const char *c, int *width);
#ifdef ENABLE_UTF8
int mbwidth(const char *c);
#endif
char *make_mbchar(long chr, int *chr_mb_len);
int parse_mbchar(const char *buf, char *chr, size_t *col);
size_t move_mbleft(const char *buf, size_t pos);
size_t move_mbright(const char *buf, size_t pos);
int char_length(const char *pointer);
size_t mbstrlen(const char *s);
int collect_char(const char *buf, char *chr);
int advance_over(const char *string, size_t *column);
size_t step_left(const char *buf, size_t pos);
size_t step_right(const char *buf, size_t pos);
int mbstrcasecmp(const char *s1, const char *s2);
int mbstrncasecmp(const char *s1, const char *s2, size_t n);
char *mbstrcasestr(const char *haystack, const char *needle);
char *revstrstr(const char *haystack, const char *needle, const char *index);
char *mbrevstrcasestr(const char *haystack, const char *needle, const char *index);
size_t mbstrlen(const char *s);
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
char *mbstrchr(const char *s, const char *c);
#endif
@@ -230,6 +237,7 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
bool has_blank_char(const char *s);
#endif
bool white_string(const char *s);
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
@@ -239,8 +247,8 @@ bool is_valid_unicode(wchar_t wc);
void set_colorpairs(void);
void color_init(void);
void color_update(void);
void set_up_multicache(linestruct *line);
void check_the_multis(linestruct *line);
void alloc_multidata_if_needed(linestruct *fileptr);
void precalc_multicolorinfo(void);
#endif
@@ -250,37 +258,44 @@ void do_backspace(void);
#ifndef NANO_TINY
void chop_previous_word(void);
void chop_next_word(void);
#endif
void extract_segment(linestruct *top, size_t top_x,
linestruct *bot, size_t bot_x);
void ingraft_buffer(linestruct *somebuffer);
void copy_from_buffer(linestruct *somebuffer);
#ifndef NANO_TINY
void cut_marked(bool *right_side_up);
#endif
void do_cut_text(bool copy_text, bool marked, bool cut_till_eof, bool append);
void do_snip(bool copying, bool marked, bool until_eof, bool append);
bool is_cuttable(bool test_cliff);
void do_cut_text_void(void);
void cut_text(void);
#ifndef NANO_TINY
void do_copy_text(void);
void do_cut_till_eof(void);
void copy_text(void);
void cut_till_eof(void);
void zap_text(void);
#endif
void do_uncut_text(void);
void paste_text(void);
/* Most functions in files.c. */
void initialize_buffer_text(void);
void set_modified(void);
void make_new_buffer(void);
#ifndef NANO_TINY
int delete_lockfile(const char *lockfilename);
#endif
bool open_buffer(const char *filename, bool new_buffer);
#ifdef ENABLE_SPELLER
void replace_buffer(const char *filename);
#ifndef NANO_TINY
void replace_marked_buffer(const char *filename);
#endif
bool replace_buffer(const char *filename, undo_type action, bool marked,
const char *operation);
#endif
void set_modified(void);
void prepare_for_display(void);
#ifdef ENABLE_MULTIBUFFER
void mention_name_and_linecount(void);
void switch_to_prev_buffer(void);
void switch_to_next_buffer(void);
bool close_buffer(void);
void close_buffer(void);
#endif
void read_file(FILE *f, int fd, const char *filename, bool undoable);
int open_file(const char *filename, bool newfie, bool quiet, FILE **f);
int open_file(const char *filename, bool newfie, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
void do_insertfile_void(void);
char *get_full_path(const char *origpath);
@@ -291,8 +306,6 @@ bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
#endif
#ifndef NANO_TINY
void init_backup_dir(void);
int delete_lockfile(const char *lockfilename);
int write_lockfile(const char *lockfilename, const char *origfilename, bool modified);
#endif
int copy_file(FILE *inn, FILE *out, bool close_out);
bool write_file(const char *name, FILE *f_open, bool tmp,
@@ -314,31 +327,25 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
#endif
/* Some functions in global.c. */
size_t length_of_list(int menu);
const sc *first_sc_for(int menu, void (*func)(void));
const keystruct *first_sc_for(int menu, void (*func)(void));
int the_code_for(void (*func)(void), int defaultval);
size_t shown_entries_for(int menu);
const keystruct *get_shortcut(int *kbinput);
functionptrtype func_from_key(int *kbinput);
int keycode_from_string(const char *keystring);
void assign_keyinfo(sc *s, const char *keystring, const int keycode);
void print_sclist(void);
void shortcut_init(void);
const subnfunc *sctofunc(const sc *s);
const char *flagtostr(int flag);
#ifdef ENABLE_NANORC
sc *strtosc(const char *input);
int name_to_menu(const char *name);
char *menu_to_name(int menu);
#if defined(ENABLE_BROWSER) || defined(ENABLE_HELP)
functionptrtype interpret(int *keycode);
#endif
int keycode_from_string(const char *keystring);
void shortcut_init(void);
const char *flagtostr(int flag);
/* All functions in help.c. */
#ifdef ENABLE_HELP
void wrap_the_help_text(bool redisplaying);
void do_help(void);
void wrap_help_text_into_buffer(void);
void help_init(void);
functionptrtype parse_help_input(int *kbinput);
size_t help_line_len(const char *ptr);
#endif
void do_help_void(void);
void do_help(void);
/* Most functions in history.c. */
#ifdef ENABLE_HISTORIES
@@ -395,20 +402,12 @@ void unlink_node(linestruct *fileptr);
void delete_node(linestruct *fileptr);
linestruct *copy_buffer(const linestruct *src);
void free_lines(linestruct *src);
void renumber(linestruct *line);
partition *partition_buffer(linestruct *top, size_t top_x,
linestruct *bot, size_t bot_x);
void unpartition_buffer(partition **p);
void extract_buffer(linestruct **file_top, linestruct **file_bot,
linestruct *top, size_t top_x, linestruct *bot, size_t bot_x);
void ingraft_buffer(linestruct *somebuffer);
void copy_from_buffer(linestruct *somebuffer);
#ifdef ENABLE_MULTIBUFFER
void unlink_opennode(openfilestruct *fileptr);
void delete_opennode(openfilestruct *fileptr);
#endif
void renumber_from(linestruct *line);
void partition_buffer(linestruct *top, size_t top_x,
linestruct *bot, size_t bot_x);
void unpartition_buffer(void);
void print_view_warning(void);
void show_restricted_warning(void);
bool in_restricted_mode(void);
#ifndef ENABLE_HELP
void say_there_is_no_help(void);
#endif
@@ -418,18 +417,25 @@ void emergency_save(const char *die_filename, struct stat *die_stat);
void window_init(void);
void do_exit(void);
void close_and_go(void);
void install_handler_for_Ctrl_C(void);
void restore_handler_for_Ctrl_C(void);
void reconnect_and_store_state(void);
RETSIGTYPE handle_hupterm(int signal);
#ifndef DEBUG
RETSIGTYPE handle_crash(int signal);
#endif
RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_continue(int signal);
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER)
void block_sigwinch(bool blockit);
#endif
#ifndef NANO_TINY
RETSIGTYPE handle_sigwinch(int signal);
void regenerate_screen(void);
void do_toggle(int flag);
void enable_signals(void);
#endif
void disable_kb_interrupt(void);
void enable_kb_interrupt(void);
void disable_flow_control(void);
void enable_flow_control(void);
void terminal_init(void);
@@ -437,11 +443,11 @@ void terminal_init(void);
void confirm_margin(void);
#endif
void unbound_key(int code);
bool okay_for_view(const sc *shortcut);
void do_output(char *output, size_t output_len, bool allow_cntrls);
bool okay_for_view(const keystruct *shortcut);
void inject(char *output, size_t output_len, bool filtering);
/* Most functions in prompt.c. */
void do_statusbar_output(int *the_input, size_t input_len, bool filtering);
void inject_into_answer(int *the_input, size_t input_len, bool filtering);
void do_statusbar_home(void);
void do_statusbar_end(void);
void do_statusbar_left(void);
@@ -464,15 +470,22 @@ int do_prompt(bool allow_tabs, bool allow_files,
int do_yesno_prompt(bool all, const char *msg);
/* Most functions in rcfile.c. */
#if defined(ENABLE_NANORC) || defined(ENABLE_HISTORIES)
void display_rcfile_errors(void);
void jot_error(const char *msg, ...);
#endif
#ifdef ENABLE_NANORC
#ifdef ENABLE_COLOR
void parse_one_include(char *file, syntaxtype *syntax);
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
bool parse_syntax_commands(char *keyword, char *ptr);
#endif
void parse_rcfile(FILE *rcstream, bool syntax_only);
void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only);
void do_rcfiles(void);
#endif /* ENABLE_NANORC */
/* Most functions in search.c. */
bool regexp_init(const char *regexp);
void tidy_up_after_search(void);
int findnextstr(const char *needle, bool whole_word_only, int modus,
size_t *match_len, bool skipone, const linestruct *begin, size_t begin_x);
@@ -504,7 +517,6 @@ void do_tab(void);
void do_indent(void);
void do_unindent(void);
#endif
bool white_string(const char *s);
#ifdef ENABLE_COMMENT
void do_comment(void);
#endif
@@ -514,22 +526,22 @@ void do_enter(void);
#ifndef NANO_TINY
RETSIGTYPE cancel_command(int signal);
bool execute_command(const char *command);
void discard_until(const undo *thisitem, openfilestruct *thefile, bool keep);
void add_undo(undo_type action);
void discard_until(const undostruct *thisitem, openfilestruct *thefile, bool keep);
void add_undo(undo_type action, const char *message);
void update_multiline_undo(ssize_t lineno, char *indentation);
void update_undo(undo_type action);
#endif /* !NANO_TINY */
#ifdef ENABLE_WRAPPING
void wrap_reset(void);
bool do_wrap(linestruct *line);
bool do_wrap(void);
#endif
#if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY)
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
#endif
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
#if !defined(NANO_TINY) || defined(ENABLED_WRAPORJUSTIFY)
size_t indent_length(const char *line);
#endif
#ifdef ENABLE_JUSTIFY
size_t quote_length(const char *line);
bool begpar(const linestruct *const foo, int depth);
bool inpar(const linestruct *const foo);
void do_justify(bool full_justify);
@@ -541,6 +553,7 @@ void do_spell(void);
#endif
#ifdef ENABLE_COLOR
void do_linter(void);
void do_formatter(void);
#endif
#ifndef NANO_TINY
void do_wordlinechar_count(void);
@@ -557,9 +570,8 @@ int digits(ssize_t n);
#endif
bool parse_num(const char *str, ssize_t *val);
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
void null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len);
void sunder(char *str);
void unsunder(char *string, size_t length);
void sunder(char *string);
#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
void free_chararray(char **array, size_t len);
#endif
@@ -568,44 +580,40 @@ bool is_separate_word(size_t position, size_t length, const char *buf);
#endif
const char *strstrwrapper(const char *haystack, const char *needle,
const char *start);
void nperror(const char *s);
void *nmalloc(size_t howmuch);
void *nrealloc(void *ptr, size_t howmuch);
char *mallocstrncpy(char *dest, const char *src, size_t n);
char *measured_copy(const char *src, size_t n);
char *mallocstrcpy(char *dest, const char *src);
char *copy_of(const char *string);
char *free_and_assign(char *dest, char *src);
size_t get_page_start(size_t column);
size_t xplustabs(void);
size_t actual_x(const char *text, size_t column);
size_t strnlenpt(const char *text, size_t maxlen);
size_t strlenpt(const char *text);
size_t wideness(const char *text, size_t maxlen);
size_t breadth(const char *text);
void new_magicline(void);
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
void remove_magicline(void);
#endif
#ifndef NANO_TINY
void mark_order(const linestruct **top, size_t *top_x,
void get_region(const linestruct **top, size_t *top_x,
const linestruct **bot, size_t *bot_x, bool *right_side_up);
void get_range(const linestruct **top, const linestruct **bot);
#endif
size_t get_totsize(const linestruct *begin, const linestruct *end);
#ifndef NANO_TINY
linestruct *fsfromline(ssize_t lineno);
linestruct *line_from_number(ssize_t lineno);
#endif
/* Most functions in winio.c. */
void record_macro(void);
void run_macro(void);
size_t get_key_buffer_len(void);
void put_back(int keycode);
void unget_kbinput(int kbinput, bool metakey);
#ifdef ENABLE_NANORC
void implant(const char *string);
#endif
int get_kbinput(WINDOW *win, bool showcursor);
int parse_kbinput(WINDOW *win);
int arrow_from_abcd(int kbinput);
int parse_escape_sequence(WINDOW *win, int kbinput);
int get_kbinput(WINDOW *win, bool showcursor);
int get_byte_kbinput(int kbinput);
int get_control_kbinput(int kbinput);
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
@@ -613,8 +621,6 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
#ifdef ENABLE_MOUSE
int get_mouseinput(int *mouse_row, int *mouse_col, bool allow_shortcuts);
#endif
const sc *get_shortcut(int *kbinput);
void blank_row(WINDOW *win, int y, int x, int n);
void blank_edit(void);
void blank_statusbar(void);
void wipe_statusbar(void);
@@ -623,14 +629,12 @@ void check_statusblank(void);
char *display_string(const char *buf, size_t column, size_t span,
bool isdata, bool isprompt);
void titlebar(const char *path);
void statusline(message_type importance, const char *msg, ...);
void statusbar(const char *msg);
void warn_and_shortly_pause(const char *msg);
void statusline(message_type importance, const char *msg, ...);
void bottombars(int menu);
void post_one_key(const char *keystroke, const char *tag, int width);
void place_the_cursor(void);
void edit_draw(linestruct *fileptr, const char *converted,
int line, size_t from_col);
int update_line(linestruct *fileptr, size_t index);
#ifndef NANO_TINY
int update_softwrapped_line(linestruct *fileptr);
@@ -675,10 +679,11 @@ void backwards_void(void);
void flip_replace(void);
void flip_goto(void);
#ifdef ENABLE_BROWSER
void to_files_void(void);
void goto_dir_void(void);
void to_files(void);
void goto_dir(void);
#endif
#ifndef NANO_TINY
void do_nothing(void);
void do_toggle_void(void);
void dos_format_void(void);
void mac_format_void(void);
@@ -694,5 +699,3 @@ void flip_newbuffer(void);
#endif
void discard_buffer(void);
void do_cancel(void);
#endif /* !PROTO_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* search.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 2015-2018 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2015-2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -22,9 +22,6 @@
#include "proto.h"
#include <string.h>
#ifdef DEBUG
#include <time.h>
#endif
static bool came_full_circle = FALSE;
/* Have we reached the starting line again while searching? */
@@ -79,7 +76,7 @@ void search_init(bool replacing, bool keep_the_answer)
/* When starting a new search, clear the current answer. */
if (!keep_the_answer)
answer = mallocstrcpy(answer, NULL);
answer = mallocstrcpy(answer, "");
/* If something was searched for earlier, include it in the prompt. */
if (*last_search != '\0') {
@@ -88,23 +85,24 @@ void search_init(bool replacing, bool keep_the_answer)
thedefault = charalloc(strlen(disp) + 7);
/* We use (COLS / 3) here because we need to see more on the line. */
sprintf(thedefault, " [%s%s]", disp,
(strlenpt(last_search) > COLS / 3) ? "..." : "");
(breadth(last_search) > COLS / 3) ? "..." : "");
free(disp);
} else
thedefault = mallocstrcpy(NULL, "");
thedefault = copy_of("");
while (TRUE) {
functionptrtype func;
/* Ask the user what to search for (or replace). */
int i = do_prompt(FALSE, FALSE,
int response = do_prompt(FALSE, FALSE,
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
answer, &search_history,
answer, &search_history, edit_refresh,
/* TRANSLATORS: This is the main search prompt. */
edit_refresh, "%s%s%s%s%s%s", _("Search"),
"%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next four modify the search prompt. */
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "",
replacing ?
#ifndef NANO_TINY
openfile->mark ? _(" (to replace) in selection") :
#endif
@@ -112,15 +110,13 @@ void search_init(bool replacing, bool keep_the_answer)
/* If the search was cancelled, or we have a blank answer and
* nothing was searched for yet during this session, get out. */
if (i == -1 || (i == -2 && *last_search == '\0')) {
if (response == -1 || (response == -2 && *last_search == '\0')) {
statusbar(_("Cancelled"));
tidy_up_after_search();
free(thedefault);
return;
break;
}
/* If Enter was pressed, prepare to do a replace or a search. */
if (i == 0 || i == -2) {
if (response == 0 || response == -2) {
/* If an actual answer was typed, remember it. */
if (*answer != '\0') {
last_search = mallocstrcpy(last_search, answer);
@@ -139,38 +135,35 @@ void search_init(bool replacing, bool keep_the_answer)
go_looking();
}
tidy_up_after_search();
free(thedefault);
return;
break;
}
func = func_from_key(&i);
func = func_from_key(&response);
/* If we're here, one of the five toggles was pressed, or
* a shortcut was executed. */
if (func == case_sens_void) {
if (func == case_sens_void)
TOGGLE(CASE_SENSITIVE);
} else if (func == backwards_void) {
else if (func == backwards_void)
TOGGLE(BACKWARDS_SEARCH);
} else if (func == regexp_void) {
else if (func == regexp_void)
TOGGLE(USE_REGEXP);
} else if (func == flip_replace) {
else if (func == flip_replace) {
if (ISSET(VIEW_MODE)) {
print_view_warning();
tidy_up_after_search();
free(thedefault);
return;
}
replacing = !replacing;
} else {
if (func == flip_goto)
do_gotolinecolumn(openfile->current->lineno,
openfile->placewewant + 1, TRUE, TRUE);
tidy_up_after_search();
free(thedefault);
return;
}
napms(600);
} else
replacing = !replacing;
} else if (func == flip_goto) {
do_gotolinecolumn(openfile->current->lineno,
openfile->placewewant + 1, TRUE, TRUE);
break;
} else
break;
}
tidy_up_after_search();
free(thedefault);
}
/* Look for needle, starting at (current, current_x). begin is the line
@@ -230,10 +223,10 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
if (skipone) {
skipone = FALSE;
if (ISSET(BACKWARDS_SEARCH) && from != line->data) {
from = line->data + move_mbleft(line->data, from - line->data);
from = line->data + step_left(line->data, from - line->data);
found = strstrwrapper(line->data, needle, from);
} else if (!ISSET(BACKWARDS_SEARCH) && *from != '\0') {
from += move_mbright(from, 0);
from += char_length(from);
found = strstrwrapper(line->data, needle, from);
}
} else
@@ -248,7 +241,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
* if it's not, continue looking in the rest of the line. */
if (whole_word_only && !is_separate_word(found - line->data,
found_len, line->data)) {
from = found + move_mbright(found, 0);
from = found + char_length(found);
continue;
}
#endif
@@ -366,6 +359,8 @@ void do_research(void)
/* Use the search-menu key bindings, to allow cancelling. */
currmenu = MWHEREIS;
wipe_statusbar();
go_looking();
tidy_up_after_search();
@@ -389,7 +384,7 @@ void do_findnext(void)
void not_found_msg(const char *str)
{
char *disp = display_string(str, 0, (COLS / 2) + 1, FALSE, FALSE);
size_t numchars = actual_x(disp, strnlenpt(disp, COLS / 2));
size_t numchars = actual_x(disp, wideness(disp, COLS / 2));
statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp,
(disp[numchars] == '\0') ? "" : "...");
@@ -402,7 +397,10 @@ void go_looking(void)
{
linestruct *was_current = openfile->current;
size_t was_current_x = openfile->current_x;
#ifdef DEBUG
//#define TIMEIT 12
#ifdef TIMEIT
#include <time.h>
clock_t start = clock();
#endif
@@ -419,7 +417,7 @@ void go_looking(void)
else if (didfind == 0)
not_found_msg(last_search);
#ifdef DEBUG
#ifdef TIMEIT
statusline(HUSH, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
#endif
@@ -472,21 +470,20 @@ int replace_regexp(char *string, bool create)
/* Return a copy of the current line with one needle replaced. */
char *replace_line(const char *needle)
{
char *copy;
size_t new_size = strlen(openfile->current->data) + 1;
size_t match_len;
size_t new_line_size = strlen(openfile->current->data) + 1;
char *copy;
/* First adjust the size of the new line for the change. */
if (ISSET(USE_REGEXP)) {
match_len = regmatches[0].rm_eo - regmatches[0].rm_so;
new_line_size += replace_regexp(NULL, FALSE) - match_len;
new_size += replace_regexp(NULL, FALSE) - match_len;
} else {
match_len = strlen(needle);
new_line_size += strlen(answer) - match_len;
new_size += strlen(answer) - match_len;
}
/* Create the buffer. */
copy = charalloc(new_line_size);
copy = charalloc(new_size);
/* Copy the head of the original line. */
strncpy(copy, openfile->current->data, openfile->current_x);
@@ -497,8 +494,6 @@ char *replace_line(const char *needle)
else
strcpy(copy + openfile->current_x, answer);
assert(openfile->current_x + match_len <= strlen(openfile->current->data));
/* Copy the tail of the original line. */
strcat(copy, openfile->current->data + openfile->current_x + match_len);
@@ -529,8 +524,8 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
/* If the mark is on, frame the region, and turn the mark off. */
if (openfile->mark) {
mark_order((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x, &right_side_up);
get_region((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x, &right_side_up);
openfile->mark = NULL;
modus = INREGION;
@@ -577,7 +572,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
if (!replaceall) {
spotlighted = TRUE;
light_from_col = xplustabs();
light_to_col = strnlenpt(openfile->current->data,
light_to_col = wideness(openfile->current->data,
openfile->current_x + match_len);
/* Refresh the edit window, scrolling it if necessary. */
@@ -603,7 +598,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
size_t length_change;
#ifndef NANO_TINY
add_undo(REPLACE);
add_undo(REPLACE, NULL);
#endif
copy = replace_line(needle);
@@ -681,7 +676,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
/* If "automatic newline" is enabled, and text has been added to the
* magic line, make a new magic line. */
if (ISSET(FINAL_NEWLINE) && openfile->filebot->data[0] != '\0')
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
new_magicline();
return numreplaced;
@@ -704,22 +699,22 @@ void ask_for_replacement(void)
linestruct *edittop_save, *begin;
size_t firstcolumn_save, begin_x;
ssize_t numreplaced;
int i = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL, &replace_history,
/* TRANSLATORS: This is a prompt. */
edit_refresh, _("Replace with"));
int response = do_prompt(FALSE, FALSE, MREPLACEWITH, "",
/* TRANSLATORS: This is a prompt. */
&replace_history, edit_refresh, _("Replace with"));
#ifdef ENABLE_HISTORIES
/* If the replace string is not "", add it to the replace history list. */
if (i == 0)
if (response == 0)
update_history(&replace_history, answer);
#endif
/* When cancelled, or when a function was run, get out. */
if (i == -1 || i > 0) {
if (i == -1)
statusbar(_("Cancelled"));
if (response == -1) {
statusbar(_("Cancelled"));
return;
} else if (response > 0)
return;
}
/* Save where we are. */
edittop_save = openfile->edittop;
@@ -762,18 +757,18 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
{
if (interactive) {
/* Ask for the line and column. */
int i = do_prompt(FALSE, FALSE, MGOTOLINE,
use_answer ? answer : NULL, NULL,
/* TRANSLATORS: This is a prompt. */
edit_refresh, _("Enter line number, column number"));
int response = do_prompt(FALSE, FALSE, MGOTOLINE,
use_answer ? answer : "", NULL, edit_refresh,
/* TRANSLATORS: This is a prompt. */
_("Enter line number, column number"));
/* If the user cancelled or gave a blank answer, get out. */
if (i < 0) {
if (response < 0) {
statusbar(_("Cancelled"));
return;
}
if (func_from_key(&i) == flip_goto) {
if (func_from_key(&response) == flip_goto) {
UNSET(BACKWARDS_SEARCH);
/* Retain what the user typed so far and switch to searching. */
search_init(FALSE, TRUE);
@@ -781,7 +776,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
}
/* If a function was executed, we're done here. */
if (i > 0)
if (response > 0)
return;
/* Try to extract one or two numbers from the user's response. */
@@ -810,7 +805,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
/* Take a negative column number to mean: from the end of the line. */
if (column < 0)
column = strlenpt(openfile->current->data) + column + 2;
column = breadth(openfile->current->data) + column + 2;
if (column < 1)
column = 1;
@@ -820,8 +815,8 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
#ifndef NANO_TINY
if (ISSET(SOFTWRAP) && openfile->placewewant / editwincols >
strlenpt(openfile->current->data) / editwincols)
openfile->placewewant = strlenpt(openfile->current->data);
breadth(openfile->current->data) / editwincols)
openfile->placewewant = breadth(openfile->current->data);
#endif
/* When the position was manually given, center the target line. */
@@ -858,62 +853,57 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
void do_gotolinecolumn_void(void)
{
do_gotolinecolumn(openfile->current->lineno,
openfile->placewewant + 1, FALSE, TRUE);
openfile->placewewant + 1, FALSE, TRUE);
}
#ifndef NANO_TINY
/* Search for a match to one of the two characters in bracket_set. If
* reverse is TRUE, search backwards for the leftmost bracket.
* Otherwise, search forwards for the rightmost bracket. Return TRUE if
* we found a match, and FALSE otherwise. */
bool find_bracket_match(bool reverse, const char *bracket_set)
/* Search, starting from the current position, for any of the two characters
* in bracket_pair. If reverse is TRUE, search backwards, otherwise forwards.
* Return TRUE when one of the brackets was found, and FALSE otherwise. */
bool find_a_bracket(bool reverse, const char *bracket_pair)
{
linestruct *fileptr = openfile->current;
const char *rev_start = NULL, *found = NULL;
linestruct *line = openfile->current;
const char *pointer, *found;
assert(mbstrlen(bracket_set) == 2);
/* Step away from the current bracket, either backwards or forwards. */
if (reverse) {
if (openfile->current_x == 0) {
line = line->prev;
if (line == NULL)
return FALSE;
pointer = line->data + strlen(line->data);
} else
pointer = line->data + step_left(line->data, openfile->current_x);
} else
pointer = line->data + step_right(line->data, openfile->current_x);
/* rev_start might end up 1 character before the start or after the
* end of the line. This won't be a problem because we'll skip over
* it below in that case, and rev_start will be properly set when
* the search continues on the previous or next line. */
if (reverse)
rev_start = fileptr->data + (openfile->current_x - 1);
else
rev_start = fileptr->data + (openfile->current_x + 1);
/* Look for either of the two characters in bracket_set. rev_start
* can be 1 character before the start or after the end of the line.
* In either case, just act as though no match is found. */
/* Now seek for any of the two brackets, either backwards or forwards. */
while (TRUE) {
if ((rev_start > fileptr->data && *(rev_start - 1) == '\0') ||
rev_start < fileptr->data)
found = NULL;
else if (reverse)
found = mbrevstrpbrk(fileptr->data, bracket_set, rev_start);
if (reverse)
found = mbrevstrpbrk(line->data, bracket_pair, pointer);
else
found = mbstrpbrk(rev_start, bracket_set);
found = mbstrpbrk(pointer, bracket_pair);
if (found)
break;
if (reverse)
fileptr = fileptr->prev;
line = line->prev;
else
fileptr = fileptr->next;
line = line->next;
/* If we've reached the start or end of the buffer, get out. */
if (fileptr == NULL)
if (line == NULL)
return FALSE;
rev_start = fileptr->data;
pointer = line->data;
if (reverse)
rev_start += strlen(fileptr->data);
pointer += strlen(line->data);
}
/* Set the current position to the found matching bracket. */
openfile->current = fileptr;
openfile->current_x = found - fileptr->data;
/* Set the current position to the found bracket. */
openfile->current = line;
openfile->current_x = found - line->data;
return TRUE;
}
@@ -922,104 +912,78 @@ bool find_bracket_match(bool reverse, const char *bracket_set)
* there is one. */
void do_find_bracket(void)
{
linestruct *current_save;
size_t current_x_save;
linestruct *was_current = openfile->current;
size_t was_current_x = openfile->current_x;
/* The current cursor position, in case we don't find a complement. */
const char *ch;
/* The location in matchbrackets of the bracket at the current
* cursor position. */
/* The location in matchbrackets of the bracket under the cursor. */
int ch_len;
/* The length of ch in bytes. */
const char *wanted_ch;
/* The location in matchbrackets of the bracket complementing
* the bracket at the current cursor position. */
/* The location in matchbrackets of the complementing bracket. */
int wanted_ch_len;
/* The length of wanted_ch in bytes. */
char bracket_set[MAXCHARLEN * 2 + 1];
char bracket_pair[MAXCHARLEN * 2 + 1];
/* The pair of characters in ch and wanted_ch. */
size_t i;
/* Generic loop variable. */
size_t matchhalf;
/* The number of single-byte characters in one half of
* matchbrackets. */
size_t mbmatchhalf;
/* The number of multibyte characters in one half of
* matchbrackets. */
size_t count = 1;
size_t halfway = 0;
/* The index in matchbrackets where the closing brackets start. */
size_t charcount = mbstrlen(matchbrackets) / 2;
/* Half the number of characters in matchbrackets. */
size_t balance = 1;
/* The initial bracket count. */
bool reverse;
/* The direction we search. */
assert(mbstrlen(matchbrackets) % 2 == 0);
ch = mbstrchr(matchbrackets, openfile->current->data + openfile->current_x);
ch = openfile->current->data + openfile->current_x;
if ((ch = mbstrchr(matchbrackets, ch)) == NULL) {
if (ch == NULL) {
statusbar(_("Not a bracket"));
return;
}
/* Save where we are. */
current_save = openfile->current;
current_x_save = openfile->current_x;
/* Find the halfway point in matchbrackets, where the closing ones start. */
for (size_t i = 0; i < charcount; i++)
halfway += char_length(matchbrackets + halfway);
/* If we're on an opening bracket, which must be in the first half
* of matchbrackets, we want to search forwards for a closing
* bracket. If we're on a closing bracket, which must be in the
* second half of matchbrackets, we want to search backwards for an
* opening bracket. */
matchhalf = 0;
mbmatchhalf = mbstrlen(matchbrackets) / 2;
/* When on a closing bracket, we have to search backwards for a matching
* opening bracket; otherwise, forward for a matching closing bracket. */
reverse = (ch >= (matchbrackets + halfway));
for (i = 0; i < mbmatchhalf; i++)
matchhalf += parse_mbchar(matchbrackets + matchhalf, NULL, NULL);
reverse = ((ch - matchbrackets) >= matchhalf);
/* If we're on an opening bracket, set wanted_ch to the character
* that's matchhalf characters after ch. If we're on a closing
* bracket, set wanted_ch to the character that's matchhalf
* characters before ch. */
/* Step half the number of total characters either backwards or forwards
* through matchbrackets to find the wanted complementary bracket. */
wanted_ch = ch;
while (mbmatchhalf > 0) {
while (charcount-- > 0) {
if (reverse)
wanted_ch = matchbrackets + move_mbleft(matchbrackets,
wanted_ch - matchbrackets);
wanted_ch = matchbrackets + step_left(matchbrackets,
wanted_ch - matchbrackets);
else
wanted_ch += move_mbright(wanted_ch, 0);
mbmatchhalf--;
wanted_ch += char_length(wanted_ch);
}
ch_len = parse_mbchar(ch, NULL, NULL);
wanted_ch_len = parse_mbchar(wanted_ch, NULL, NULL);
ch_len = char_length(ch);
wanted_ch_len = char_length(wanted_ch);
/* Fill bracket_set in with the values of ch and wanted_ch. */
strncpy(bracket_set, ch, ch_len);
strncpy(bracket_set + ch_len, wanted_ch, wanted_ch_len);
bracket_set[ch_len + wanted_ch_len] = '\0';
/* Copy the two complementary brackets into a single string. */
strncpy(bracket_pair, ch, ch_len);
strncpy(bracket_pair + ch_len, wanted_ch, wanted_ch_len);
bracket_pair[ch_len + wanted_ch_len] = '\0';
while (TRUE) {
if (find_bracket_match(reverse, bracket_set)) {
/* If we found an identical bracket, increment count. If we
* found a complementary bracket, decrement it. */
count += (strncmp(openfile->current->data + openfile->current_x,
ch, ch_len) == 0) ? 1 : -1;
while (find_a_bracket(reverse, bracket_pair)) {
/* Increment/decrement balance for an identical/other bracket. */
balance += (strncmp(openfile->current->data + openfile->current_x,
ch, ch_len) == 0) ? 1 : -1;
/* If count is zero, we've found a matching bracket. Update
* the screen and get out. */
if (count == 0) {
edit_redraw(current_save, FLOWING);
break;
}
} else {
/* We didn't find either an opening or closing bracket.
* Indicate this, restore where we were, and get out. */
statusbar(_("No matching bracket"));
openfile->current = current_save;
openfile->current_x = current_x_save;
break;
/* When balance reached zero, we've found the complementary bracket. */
if (balance == 0) {
edit_redraw(was_current, FLOWING);
return;
}
}
statusbar(_("No matching bracket"));
/* Restore the cursor position. */
openfile->current = was_current;
openfile->current_x = was_current_x;
}
#endif /* !NANO_TINY */

1490
src/text.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* utils.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2019 Free Software Foundation, Inc. *
* Copyright (C) 2016-2017 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -49,7 +49,7 @@ void get_homedir(void)
/* Only set homedir if some home directory could be determined,
* otherwise keep homedir NULL. */
if (homenv != NULL && *homenv != '\0')
homedir = mallocstrcpy(NULL, homenv);
homedir = copy_of(homenv);
}
}
@@ -149,7 +149,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
if (comma == str)
return retval;
firstpart = mallocstrcpy(NULL, str);
firstpart = copy_of(str);
firstpart[comma - str] = '\0';
retval = parse_num(firstpart, line) && retval;
@@ -159,30 +159,24 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
return retval;
}
/* Null a string at a certain index and align it. */
void null_at(char **data, size_t index)
/* In the given string, recode each embedded NUL as a newline. */
void unsunder(char *string, size_t length)
{
*data = charealloc(*data, index + 1);
(*data)[index] = '\0';
}
/* For non-null-terminated lines. A line, by definition, shouldn't
* normally have newlines in it, so encode its nulls as newlines. */
void unsunder(char *str, size_t true_len)
{
for (; true_len > 0; true_len--, str++) {
if (*str == '\0')
*str = '\n';
while (length > 0) {
if (*string == '\0')
*string = '\n';
length--;
string++;
}
}
/* For non-null-terminated lines. A line, by definition, shouldn't
* normally have newlines in it, so decode its newlines as nulls. */
void sunder(char *str)
/* In the given string, recode each embedded newline as a NUL. */
void sunder(char *string)
{
for (; *str != '\0'; str++) {
if (*str == '\n')
*str = '\0';
while (*string != '\0') {
if (*string == '\n')
*string = '\0';
string++;
}
}
@@ -209,8 +203,8 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
size_t word_end = position + length;
/* Get the characters before and after the word, if any. */
parse_mbchar(buf + move_mbleft(buf, position), before, NULL);
parse_mbchar(buf + word_end, after, NULL);
collect_char(buf + step_left(buf, position), before);
collect_char(buf + word_end, after);
/* If the word starts at the beginning of the line OR the character before
* the word isn't a letter, and if the word ends at the end of the line OR
@@ -253,7 +247,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
/* If this is the last possible match, don't try to advance. */
if (last_find == ceiling)
break;
next_rung = move_mbright(haystack, last_find);
next_rung = step_right(haystack, last_find);
regmatches[0].rm_so = next_rung;
regmatches[0].rm_eo = far_end;
if (regexec(&search_regexp, haystack, 1, regmatches,
@@ -294,17 +288,6 @@ const char *strstrwrapper(const char *haystack, const char *needle,
return mbstrcasestr(start, needle);
}
/* This is a wrapper for the perror() function. The wrapper temporarily
* leaves curses mode, calls perror() (which writes to stderr), and then
* reenters curses mode, updating the screen in the process. Note that
* nperror() causes the window to flicker once. */
void nperror(const char *s)
{
endwin();
perror(s);
doupdate();
}
/* This is a wrapper for the malloc() function that properly handles
* things when we run out of memory. */
void *nmalloc(size_t howmuch)
@@ -329,28 +312,32 @@ void *nrealloc(void *ptr, size_t howmuch)
return r;
}
/* Allocate and copy the first n characters of the given src string, after
* freeing the destination. Usage: "dest = mallocstrncpy(dest, src, n);". */
char *mallocstrncpy(char *dest, const char *src, size_t n)
/* Return an appropriately reallocated dest string holding a copy of src.
* Usage: "dest = mallocstrcpy(dest, src);". */
char *mallocstrcpy(char *dest, const char *src)
{
if (src == NULL)
src = "";
size_t count = strlen(src) + 1;
#ifndef NANO_TINY
if (src == dest)
fprintf(stderr, "\r*** Copying a string to itself -- please report a bug ***");
#endif
dest = charealloc(dest, n);
strncpy(dest, src, n);
dest = charealloc(dest, count);
strncpy(dest, src, count);
return dest;
}
/* Free the dest string and return a malloc'ed copy of src. Should be used as:
* "dest = mallocstrcpy(dest, src);". */
char *mallocstrcpy(char *dest, const char *src)
/* Return an allocated copy of the first count characters of the given string. */
char *measured_copy(const char *string, size_t count)
{
return mallocstrncpy(dest, src, (src == NULL) ? 1 : strlen(src) + 1);
char *thecopy = charalloc(count);
strncpy(thecopy, string, count);
return thecopy;
}
/* Return an allocated copy of the given string. */
char *copy_of(const char *string)
{
return measured_copy(string, strlen(string) + 1);
}
/* Free the string at dest and return the string at src. */
@@ -379,7 +366,7 @@ size_t get_page_start(size_t column)
* column position of the cursor. */
size_t xplustabs(void)
{
return strnlenpt(openfile->current->data, openfile->current_x);
return wideness(openfile->current->data, openfile->current_x);
}
/* Return the index in text of the character that (when displayed) will
@@ -392,7 +379,7 @@ size_t actual_x(const char *text, size_t column)
/* The current accumulated span, in columns. */
while (*text != '\0') {
int charlen = parse_mbchar(text, NULL, &width);
int charlen = advance_over(text, &width);
if (width > column)
break;
@@ -405,16 +392,15 @@ size_t actual_x(const char *text, size_t column)
/* A strnlen() with tabs and multicolumn characters factored in:
* how many columns wide are the first maxlen bytes of text? */
size_t strnlenpt(const char *text, size_t maxlen)
size_t wideness(const char *text, size_t maxlen)
{
size_t width = 0;
/* The screen display width to text[maxlen]. */
if (maxlen == 0)
return 0;
while (*text != '\0') {
size_t charlen = parse_mbchar(text, NULL, &width);
size_t charlen = advance_over(text, &width);
if (maxlen <= charlen)
break;
@@ -427,12 +413,12 @@ size_t strnlenpt(const char *text, size_t maxlen)
}
/* Return the number of columns that the given text occupies. */
size_t strlenpt(const char *text)
size_t breadth(const char *text)
{
size_t span = 0;
while (*text != '\0')
text += parse_mbchar(text, NULL, &span);
text += advance_over(text, &span);
return span;
}
@@ -441,7 +427,7 @@ size_t strlenpt(const char *text)
void new_magicline(void)
{
openfile->filebot->next = make_new_node(openfile->filebot);
openfile->filebot->next->data = mallocstrcpy(NULL, "");
openfile->filebot->next->data = copy_of("");
openfile->filebot = openfile->filebot->next;
openfile->totsize++;
}
@@ -454,7 +440,7 @@ void remove_magicline(void)
if (openfile->filebot->data[0] == '\0' &&
openfile->filebot != openfile->filetop) {
openfile->filebot = openfile->filebot->prev;
free_lines(openfile->filebot->next);
delete_node(openfile->filebot->next);
openfile->filebot->next = NULL;
openfile->totsize--;
}
@@ -462,15 +448,15 @@ void remove_magicline(void)
#endif
#ifndef NANO_TINY
/* Set (top, top_x) and (bot, bot_x) to the start and end "coordinates" of
* the marked region. If right_side_up isn't NULL, set it to TRUE when the
* mark is at the top of the marked region, and to FALSE otherwise. */
void mark_order(const linestruct **top, size_t *top_x,
const linestruct **bot, size_t *bot_x, bool *right_side_up)
/* Return in (top, top_x) and (bot, bot_x) the start and end "coordinates"
* of the marked region. If right_side_up isn't NULL, set it to TRUE when
* the mark is at the top of the marked region, and to FALSE otherwise. */
void get_region(const linestruct **top, size_t *top_x,
const linestruct **bot, size_t *bot_x, bool *right_side_up)
{
if ((openfile->current->lineno == openfile->mark->lineno &&
openfile->current_x > openfile->mark_x) ||
openfile->current->lineno > openfile->mark->lineno) {
if (openfile->mark->lineno < openfile->current->lineno ||
(openfile->mark == openfile->current &&
openfile->mark_x < openfile->current_x)) {
*top = openfile->mark;
*top_x = openfile->mark_x;
*bot = openfile->current;
@@ -498,7 +484,7 @@ void get_range(const linestruct **top, const linestruct **bot)
} else {
size_t top_x, bot_x;
mark_order(top, &top_x, bot, &bot_x, NULL);
get_region(top, &top_x, bot, &bot_x, NULL);
if (bot_x == 0 && *bot != *top && !also_the_last)
*bot = (*bot)->prev;
@@ -507,24 +493,19 @@ void get_range(const linestruct **top, const linestruct **bot)
}
}
/* Given a line number, return a pointer to the corresponding struct. */
linestruct *fsfromline(ssize_t lineno)
/* Return a pointer to the line that has the given line number. */
linestruct *line_from_number(ssize_t number)
{
linestruct *f = openfile->current;
linestruct *line = openfile->current;
if (lineno <= openfile->current->lineno)
while (f->lineno != lineno && f->prev != NULL)
f = f->prev;
if (line->lineno > number)
while (line->lineno != number)
line = line->prev;
else
while (f->lineno != lineno && f->next != NULL)
f = f->next;
while (line->lineno != number)
line = line->next;
if (f->lineno != lineno) {
statusline(ALERT, "Gone undo line -- please report a bug");
return NULL;
}
return f;
return line;
}
#endif /* !NANO_TINY */

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@ color red "\<[A-Z_]{2,}\>"
color brightgreen "\.(data|subsection|text)"
color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single|struct|word)"
icolor brightred "^[[:space:]]*[.0-9A-Z_]*:"
color brightred "^[[:space:]]*[.0-9A-Za-z_]*:"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
# Strings.

View File

@@ -6,7 +6,7 @@ magic "awk script"
comment "#"
# Records.
icolor brightred "\$[0-9A-Z_!@#$*?-]+"
color brightred "\$[0-9A-Za-z_!@#$*?-]+"
# Awk-set variables.
color red "\<(ARGC|ARGIND|ARGV|BINMODE|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS)\>"
color red "\<(FILENAME|FNR|FS|IGNORECASE|LINT|NF|NR|OFMT|OFS|ORS)\>"

View File

@@ -1,6 +1,7 @@
## Here is an example for C/C++.
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|H|hh|ii?)$"
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|cu|H|hh|ii?)$"
header "-\*-.*\<C(\+\+)?((;|\s).*)?-\*-"
magic "^(C|C\+\+) (source|program)"
comment "//"
@@ -10,12 +11,11 @@ color brightred "\<[A-Z_][0-9A-Z_]+\>"
color brightmagenta "^[[:space:]]*[A-Z_a-z]+:[[:space:]]*$"
color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
color green "\<((s?size)|((u_?)?int(8|16|32|64|ptr)))_t\>"
color green "\<([[:lower:]][[:lower:]_]*|(u_?)?int(8|16|32|64))_t\>"
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|override|using|mutable|volatile|register|explicit)\>"
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
color magenta "\<(goto|continue|break|return)\>"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)"
color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
# GCC builtins.
@@ -23,11 +23,15 @@ color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidd
# Strings. In general you will want your strings and comments to come last,
# because highlighting rules are applied in the order they are read in.
color brightyellow ""([^"]|\\")*"" "<[^[:blank:]=]*>"
color brightyellow ""([^"]|\\")*"" "#[[:space:]]*include[[:space:]]+<[^[:blank:]=]*>"
# Multiline strings. This regex is VERY resource intensive,
# and sometimes colours things that shouldn't be coloured.
###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
# Preprocessor directives.
color brightcyan start="^[[:space:]]*#[[:space:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|else|endif|include(_next)?|undef)\>"
# Comments.
color brightblue "//.*"
color brightblue start="/\*" end="\*/"

View File

@@ -3,7 +3,7 @@
syntax cmake "(CMakeLists\.txt|\.cmake)$"
comment "#"
icolor green "^[[:space:]]*[A-Z0-9_]+"
color green "^[[:space:]]*[0-9A-Za-z_]+"
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
icolor brightgreen "^[[:space:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
@@ -12,7 +12,7 @@ color brightgreen "[[:space:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS
icolor brightred "^[[:space:]]*((end)?(function|macro)|return)"
icolor cyan start="\$(\{|ENV\{)" end="\}"
icolor cyan start="\$(ENV)?\{" end="\}"
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
color brightblue "(^|[[:space:]])#.*"

View File

@@ -11,7 +11,10 @@ color cyan "^[[:space:]]*#.*"
color ,red " + +"
# Nano's name, including version.
color brightred "(GNU )?[Nn]ano [1-3]\.[0-9][-.[:alnum:]]*\>"
color brightred "(GNU )?[Nn]ano [1-4]\.[0-9][-.[:alnum:]]*\>"
# Email addresses.
color magenta "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"
# Bracketed captions in certain config files.
color brightgreen "^\[[^][]+\]$"

View File

@@ -34,7 +34,7 @@ icolor yellow "\<(.or.|repeat|select case|then|where|while)\>"
icolor magenta "\<(continue|cycle|exit|go?to|result|return)\>"
# Strings.
icolor yellow "<[^= ]*>" ""(\\.|[^"])*""
color yellow "<[^= ]*>" ""(\\.|[^"])*""
# Comments.
icolor blue "!.*"
color blue "!.*"

View File

@@ -17,7 +17,7 @@ color green "-(eq|ne|gt|lt|ge|le)\>"
## Variables... official portage ones in red, all others in bright red:
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:digit:]]|@)+\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[HPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BHPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|E?ROOT|WORKDIR)\>"
color red "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>" "\<(MERGE_TYPE|REPLACING_VERSIONS|REPLACED_BY_VERSION)\>"
color red "\<EBUILD_PHASE(_FUNC)?\>"

View File

@@ -3,6 +3,8 @@
syntax go "\.go$"
comment "//"
formatter gofmt -w
# Types.
color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>"
color green "\<((<-[[:space:]]*)chan|chan[[:space:]]*<-|const|func|interface|map|struct|type|var)\>"

View File

@@ -4,6 +4,8 @@ syntax html "\.html?$"
magic "HTML document"
comment "<!--|-->"
formatter tidy -m -q
# Tags:
color cyan "<[[:alpha:]/!?][^>]*>"
# Bold, italic, and underlined:
@@ -11,18 +13,19 @@ color brightmagenta "</?[biu]>"
# Named character references:
color red "&[^;[:space:]]*;"
# Attributes:
color red "\<(abbr|accept(-charset)?|accesskey|action|alink|align|alt|archive|axis|background|bgcolor|border)="
color red "\<(cell(padding|spacing)|char(off|set)?|checked|cite|class(id)?|compact|code(base|tag)?|cols(pan)?)="
color red "\<(content(editable)?|contextmenu|coords|data|datetime|declare|defer|dir|disabled|enctype)="
color red "\<(for|frame(border)?|headers|height|hidden|href(lang)?|hspace|http-equiv|id|ismap)="
color red "\<(label|lang|link|longdesc|margin(height|width)|maxlength|media|method|multiple)="
color red "\<(name|nohref|noresize|noshade|object|onclick|onfocus|onload|onmouseover|profile|readonly|rel|rev)="
color red "\<(rows(pan)?|rules|scheme|scope|scrolling|selected|shape|size|span|src|standby|start|style|summary)="
color red "\<(tabindex|target|text|title|type|usemap|valign|value(type)?|vlink|vspace|width|xmlns|xml:space)="
# Strings:
color green ""(\\.|[^"])*""
# Attributes:
color red "(abbr|accept(-charset)?|accesskey|action|alink|align|alt|archive|axis|background|bgcolor|border)="
color red "(cell(padding|spacing)|char(off|set)?|checked|cite|class(id)?|compact|code(base|tag)?|cols(pan)?)="
color red "(content(editable)?|contextmenu|coords|data|datetime|declare|defer|dir|disabled|enctype)="
color red "(for|frame(border)?|headers|height|hidden|href(lang)?|hspace|http-equiv|id|ismap)="
color red "(label|lang|link|longdesc|margin(height|width)|maxlength|media|method|multiple)="
color red "(name|nohref|noresize|noshade|object|onclick|onfocus|onload|onmouseover|profile|readonly|rel|rev)="
color red "(rows(pan)?|rules|scheme|scope|scrolling|selected|shape|size|span|src|standby|start|style|summary)="
color red "(tabindex|target|text|title|type|usemap|valign|value(type)?|vlink|vspace|width|xmlns|xml:space)="
# Comments:
color yellow start="<!--" end="-->"

View File

@@ -12,7 +12,9 @@ color brightyellow "\<(await|export|import|throw|try|catch|finally|new|delete)\>
color magenta "\<(break|continue|return|yield)\>"
# Octal/decimal and hexadecimal numbers.
color cyan "\<[0-9]+\>" "\<0x[0-9A-Fa-f]+\>"
color cyan "\<([0-9]+|0x[0-9A-Fa-f]+)\>"
# Special values.
color cyan "\<(true|false|null|undefined)\>"
# Strings.
color brightmagenta ""(\\.|[^"])*"" "'(\\.|[^'])*'" "`(\\.|[^`])*`"

View File

@@ -5,9 +5,10 @@
syntax lua "\.lua$"
magic "Lua script"
linter "luacheck --no-color"
comment "--"
linter luacheck --no-color
color brightwhite "\[\[.*\]\]"
# Operators
@@ -44,7 +45,7 @@ color brightmagenta "\<(false|nil|true)\>"
# Decimal and hexadecimal numbers
color red "\<[0-9]+(\.[0-9]*)?([Ee][+-]?[0-9]+)?\>"
icolor red "\<0x[0-9a-f]+(\.[0-9a-f]*)?(p[+-]?[0-9]+)?\>"
color red "\<0x[0-9A-Fa-f]+(\.[0-9A-Fa-f]*)?([Pp][+-]?[0-9]+)?\>"
# Brackets
color brightmagenta "\(|\)|\[|\]|\{|\}"

View File

@@ -1,18 +1,23 @@
## Here is an example for manpages.
## Syntax highlighting for man pages.
syntax man "\.[1-9]x?$"
magic "troff or preprocessor input"
comment ".\""
color green "\.(SH|SS|TH) .*"
color brightgreen "\.(SH|SS|TH) " "\.([HIT]P)"
color brightred "\.(B[IR]?|I[BR]?|R[BI]|S[BM]) .*"
color brightblue "\.(B[IR]?|I[BR]?|R[BI]|S[BM]) " "\.([LP]?P)$"
# Section headers, title line, and indented paragraphs.
color green "^\.(SH|SS|TH) .*"
color brightgreen "^\.(SH|SS|TH) " "^\.([HIT]P)"
# Type faces, and normal paragraphs.
color brightred "^\.(B[IR]?|I[BR]?|R[BI]|S[BM]) .*"
color brightblue "^\.(B[IR]?|I[BR]?|R[BI]|S[BM]) " "^\.([LP]?P)$"
# Inline type faces.
color magenta "\\f[BIPR]"
color yellow "\.(br|DT|RS|RE|PD)"
# Relative margins, hyperlinks, and various other stuff.
color yellow "^\.(RS|RE|UR|UE|PD|DT)"
color yellow "^\.(ad|bp|br|ce|de|ds|el|ie|if|fi|ft|hy|ig|in|na|ne|nf|nh|ps|so|sp|ti|tr)"
# Comments.
color cyan "\.?\\\".*"
color cyan "(^\.)?\\\".*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -4,6 +4,6 @@ syntax mgp "\.mgp$"
header "^%include.*"
comment "#"
icolor green "^%[a-z].*"
color green "^%[A-Za-z].*"
color cyan "(^|[[:space:]])(#|%%).*"
color ,green "[[:space:]]+$"

View File

@@ -4,7 +4,7 @@
syntax nanohelp
# Key combos:
color cyan "\^[]4-8A-Z^\_◀▶▲▼]" "[◀▶▲▼]" "\<M-." "\<F1?[0-9]"
color cyan "\^[]/4-8@A-Z\^_`◀▶▲▼]" "[◀▶▲▼]" "\<(M|S[Hh]-[Mm])-." "\<F([1-9]|1[0-9]|2[0-4])"
color cyan "\<((Sh-)?Tab|Enter|Ins|(Sh-\^?)?Del|Space|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
# Quoted indicators:

View File

@@ -3,26 +3,26 @@
syntax nanorc "\.?nanorc$"
comment "#"
# Possible errors and parameters
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|i?color|extendsyntax).*"
# Everything that does not get recolored is invalid
color brightred ".*"
# Keywords
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|finalnewline|historylog|jumpyscrolling|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabstospaces|tempfile|trimblanks|unix|view|wordbounds|zap)\>"
icolor yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|stripe|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
icolor brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>"
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+([[:alpha:]]+|".*")[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter)[[:space:]]+.*"
icolor brightgreen "^[[:space:]]*(syntax|linter)[[:space:]]+[^[:blank:]]+"
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|extendsyntax)\>"
color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|finalnewline|historylog|jumpyscrolling|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabstospaces|tempfile|trimblanks|unix|view|wordbounds|zap)\>"
color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|stripe|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
color brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>"
color brightgreen "^[[:space:]]*bind[[:space:]]+((\^([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)[[:space:]]+([a-z]+|".*")[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
color brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([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)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
color brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:space:]]+.*"
color brightgreen "^[[:space:]]*(syntax[[:space:]]+[^[:blank:]]+|(formatter|linter)[[:space:]]+.+)"
color green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"
# Strings
color brightmagenta "".+"([[:space:]]|$)"
color brightmagenta "([[:space:]]|(start|end)=)".+"([[:space:]]|$)"
# Colors
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="
color yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
color magenta "^[[:space:]]*i?color\>" "\<(start|end)="
# Comments
color brightblue "(^|[[:space:]]+)#.*"

View File

@@ -7,9 +7,18 @@ comment "#"
color red "\<(accept|alarm|atan2|bin(d|mode)|c(aller|h(dir|mod|op|own|root)|lose(dir)?|onnect|os|rypt)|d(bm(close|open)|efined|elete|ie|o|ump)|e(ach|of|val|x(ec|ists|it|p))|f(cntl|ileno|lock|ork))\>" "\<(get(c|login|peername|pgrp|ppid|priority|pwnam|(host|net|proto|serv)byname|pwuid|grgid|(host|net)byaddr|protobynumber|servbyport)|([gs]et|end)(pw|gr|host|net|proto|serv)ent|getsock(name|opt)|gmtime|goto|grep|hex|index|int|ioctl|join)\>" "\<(keys|kill|last|length|link|listen|local(time)?|log|lstat|m|mkdir|msg(ctl|get|snd|rcv)|next|oct|open(dir)?|ord|pack|pipe|pop|printf?|push|q|qq|qx|rand|re(ad(dir|link)?|cv|do|name|quire|set|turn|verse|winddir)|rindex|rmdir|s|scalar|seek(dir)?)\>" "\<(se(lect|mctl|mget|mop|nd|tpgrp|tpriority|tsockopt)|shift|shm(ctl|get|read|write)|shutdown|sin|sleep|socket(pair)?|sort|spli(ce|t)|sprintf|sqrt|srand|stat|study|substr|symlink|sys(call|read|tem|write)|tell(dir)?|time|tr(y)?|truncate|umask)\>" "\<(un(def|link|pack|shift)|utime|values|vec|wait(pid)?|wantarray|warn|write)\>"
color magenta "\<(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne|lt|gt|le|ge|cmp|x|my|sub|use|package|can|isa)\>"
icolor cyan start="[$@%]" end="( |[^0-9A-Z_]|-)"
# Variable names.
color cyan "[$%&@]([A-Za-z_][0-9A-Za-z_]*|\^[][A-Z?\^_]|[0-9]+)\>"
color cyan "[$%&@]\{(\^?[A-Za-z_][0-9A-Za-z_]*|\^[][?\^][0-9]+)\}"
color cyan "[$%&@]([][!"#'()*+,.:;<=>?`|~-]|\{[][!-/:-@\`|~]\})|\$[$%&@]"
color cyan "(^|[[:space:]])[$%@][/\]"
color yellow "".*"|qq\|.*\|"
color white "[sm]/.*/"
color white start="(^use| = new)" end=";"
color green "#.*"
# Comments.
color green "(^|[[:space:]])#.*"
color yellow start="<< 'STOP'" end="STOP"

View File

@@ -1,6 +1,6 @@
## Here is an example for PHP.
syntax php "\.ph(p[23457s~]?|tml)$"
syntax php "\.(php[23457s~]?|phtml|ctp)$"
magic "PHP script"
comment "//"

View File

@@ -12,7 +12,7 @@ color brightmagenta "\<(Project\-Id\-Version|Report\-Msgid\-Bugs\-To|Last\-Trans
color cyan "\<(POT\-Creation\-Date|PO\-Revision\-Date|MIME\-Version|Content\-Type|Content\-Transfer\-Encoding)\>"
# Encodings and numbers.
color yellow "\<(UTF|ISO|Windows|Mac|IBM)-[0-9]+"
color yellow "[0-9]|pre[0-9]|[0-9]bit"
color yellow "\<((pre|rc)?[0-9]+|[0-9]bit)\>"
# Msgids.
color brightblue "^(msgid|msgid_plural|msgstr)\>"
# Tags.
@@ -22,7 +22,7 @@ color yellow " (no-)?[-[:alpha:]]+-format(,|$)"
color brightmagenta "%([1-9]\$)?[a-z]*"
# Quotes and escaped characters.
color yellow "\""
color cyan "\\[abcefnrtv"\]"
color cyan "\\([abcefnrtv"\]|x[0-9abcdefABCDEF]{2}|[0-7]{3})"
# Reminders.
color brightwhite,yellow "(FIXME|TODO|XXX)"
# Obsolete strings.

View File

@@ -3,11 +3,12 @@
syntax python "\.py$"
header "^#!.*python"
magic "Python script"
linter pyflakes
comment "#"
linter pyflakes
# Function definitions.
icolor brightblue "def [0-9A-Z_]+"
color brightblue "def [0-9A-Za-z_]+"
# Keywords.
color brightcyan "\<(and|as|assert|async|await|break|class|continue)\>"
color brightcyan "\<(def|del|elif|else|except|finally|for|from)\>"
@@ -22,14 +23,15 @@ color brightcyan "\<(exec|print)([[:blank:]]|$)"
# Special values.
color brightmagenta "\<(False|None|True)\>"
# Single-quoted strings.
color brightgreen "'([^'\]|\\.)+'"
color brightgreen ""([^"\]|\\.)+""
# Mono-quoted strings.
color brightgreen "'([^'\]|\\.)*'|'''"
color brightgreen ""([^"\]|\\.)*"|""""
color normal "'''|""""
# Comments.
color brightred "(^|[[:blank:]])#.*"
# Triple-quoted strings.
color brightgreen start="'''([^'),]|$)" end="(^|[^(\])'''"
color brightgreen start="\"\"\"([^"),]|$)" end="(^|[^(\])\"\"\""
color brightgreen start=""""([^"),]|$)" end="(^|[^(\])""""
# Reminders.
color brightwhite,yellow "(FIXME|TODO|XXX)"

View File

@@ -6,13 +6,13 @@ magic "Ruby script"
linter ruby -w -c
comment "#"
# Constants.
color brightblue "\<[A-Z]+[0-9A-Z_a-z]*|(\$|@|@@)[0-9A-Z_a-z]+"
# Reserved words.
color yellow "\<(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module)\>"
color yellow "\<(next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\>"
# Constants.
color brightblue "(\$|@|@@)?\<[A-Z]+[0-9A-Z_a-z]*"
# Ruby "symbols".
icolor magenta "([ ]|^):[0-9A-Z_]+\>"
color magenta "([ ]|^):[0-9A-Za-z_]+\>"
# Some unique things we want to stand out.
color brightyellow "\<(__FILE__|__LINE__)\>"
# Regular expressions.

View File

@@ -11,7 +11,7 @@ comment "//"
color magenta "fn [a-z_0-9]+"
# Reserved words
color yellow "\<(abstract|alignof|as|become|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\>"
color yellow "\<(abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|true|try|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\>"
# Macros
color red "[a-z_]+!"

View File

@@ -1,11 +1,12 @@
## Here is an example for Bourne shell scripts.
syntax sh "(\.sh|\.(a|ba|c|da|k|mk|pdk|tc|z)(sh|shrc|sh_profile)|/(etc/|\.)profile)$"
syntax sh "(\.sh|(\.|/)(a|ba|c|da|k|mk|pdk|tc|z)sh(rc|_profile)?|/(etc/|\.)profile)$"
header "^#!.*/(((a|ba|c|da|k|mk|pdk|tc|z)?sh)|(busybox|env) +sh|openrc-run|runscript)"
magic "(POSIX|Bourne-Again) shell script.*text"
linter dash -n
comment "#"
linter dash -n
# Function declarations.
color brightgreen "^[A-Za-z0-9_-]+\(\)"

View File

@@ -2,9 +2,10 @@
syntax tex "\.tex$"
magic "(La)?TeX document"
linter chktex -v0 -q -I
comment "%"
icolor green "\\.|\\[A-Z]*"
linter chktex -v0 -q -I
color green "\\.|\\[A-Za-z]*"
color magenta "[{}]"
color blue "(^|[^\])%.*"