Commit Graph

5858 Commits (0c249de9e534d3fc092171045696101f41d3bb64)

Author SHA1 Message Date
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
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 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 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 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 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
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 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 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 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 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
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 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 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 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