Commit Graph

5858 Commits (0c249de9e534d3fc092171045696101f41d3bb64)

Author SHA1 Message Date
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 e484918ef2 tweaks: reshuffle a few lines, for symmetry with the preceding function 2019-12-01 17:04:15 +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 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 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 9151abcd45 tweaks: avoid setting and resetting a variable when there is no need 2019-10-28 10:28:52 +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 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 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 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 d8c03cd4cd tweaks: elide a variable, and add a condition to elide an assignment 2019-10-14 10:28:45 +02:00