Commit Graph

8716 Commits (f3b030c8e535c93c9a23cd09cb2b8bde43ece187)

Author SHA1 Message Date
Benno Schulenberg 620553b795 input: filter out Ctrl+Meta keystrokes, as they can never be shortcuts
Note that DEL_CODE (0x7F) will never occur as input key code, because
it gets translated to KEY_DC in the input routine (or to KEY_BACKSPACE
when --rebinddelete is in effect).
2020-01-23 12:06:32 +01:00
Benno Schulenberg 6df50790cd input: prevent unintentional marking of text for shifted Meta keystrokes
The Shift detection on a Linux console was meant to affect only the
dedicated cursor-movement keys, not <Shift+Meta+character>.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2020-01-12 11:18:51 +01:00