Commit Graph

1486 Commits (12fe0a3b29df6335f77c0ca8760b912ff43d9515)

Author SHA1 Message Date
Benno Schulenberg 12fe0a3b29 tweaks: normalize the indentation after the previous change
This finally gets rid of the piece of specially reduced indentation
(<-<- ... ->->) that made it hard to see the structure of the code.
2020-08-09 10:48:03 +02:00
Benno Schulenberg c14e77ce9e tweaks: split a function into two, one for "Esc O" and one for "Esc [" 2020-08-09 10:48:03 +02:00
Benno Schulenberg 2c8c061e67 tweaks: pass first byte of sequence directly to the decoding function
Don't bother stuffing it back into the keyboard buffer when it will be
taken out again straight afterward.
2020-08-09 10:48:03 +02:00
Benno Schulenberg 5fab1e6754 verbatim: pause a little after an ESC, to not miss a succeeding code
When we get an ESC from the keyboard, it might be the start of an
escape sequence, but the keyboard routines will need a little time
(tens of microseconds, probably) to get these codes to ncurses.
So, when doing verbatim input, pause a moment after an ESC.

This completes the fix for https://savannah.gnu.org/bugs/?58909.
2020-08-08 07:51:47 +02:00
Benno Schulenberg b0e3767af5 input: understand M-Bsp also when terminfo does not match the terminal
Always interpret ESC followed by BS or DEL as <Alt+Backspace>.

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

Bug existed since commit 40b03162 from one week ago,
since M-Bsp was hard-bound to deleting a word backwards.
2020-08-07 19:17:36 +02:00
Benno Schulenberg 4923119174 tweaks: reshuffle some fragments, to make the next change easier 2020-08-07 18:46:55 +02:00
Benno Schulenberg cdd6882541 verbatim: insert the full code sequence when <Alt+Backspace> is pressed
(This could lead to unwanted behavior when the user wants to enter
a literal escape character (0x1B) while the input is somehow getting
stalled, because then a command keystroke after the M-V <Esc> would
get inserted verbatim too, instead of getting acted upon.  But that
is a small price to pay for getting the correct behavior for both
M-V M-Bsp and M-V M-Enter.)

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

Bug existed since version 2.6.3, commit 08c51cfd,
but also occurred erratically beforehand.
2020-08-07 16:21:21 +02:00
Benno Schulenberg 4c63ef204d tweaks: make a few more direct returns, and reshuffle another bit of code 2020-08-05 11:03:35 +02:00
Benno Schulenberg 4c6b6cad99 tweaks: elide an unneeded variable, by transforming the key code directly 2020-08-05 10:51:02 +02:00
Benno Schulenberg cc6d1d59a6 tweaks: optimize for byte-range characters, and shorten some comments 2020-08-05 10:12:03 +02:00
Benno Schulenberg f80ce71d13 tweaks: adjust the indentation after the previous change 2020-08-05 10:09:49 +02:00
Benno Schulenberg 2bbbd85852 tweaks: stop using a 'switch' when there are just three possibilities 2020-08-05 10:08:51 +02:00
Benno Schulenberg 54238a5c46 tweaks: reshuffle the zeroing of a counter, to allow some direct returns 2020-08-05 10:06:43 +02:00
Benno Schulenberg 71c0cde5ce anchor: show an anchor also when the line is horizontally scrolled
This fixes https://savannah.gnu.org/bugs/?58884.

Bug existed since version 5.0, since anchors were introduced.
2020-08-03 10:02:09 +02:00
Benno Schulenberg 18a4658d4f anchor: in a UTF-8 locale, show an anchor as a diamond, for visibility 2020-08-03 09:43:55 +02:00
Benno Schulenberg 7942dab014 tweaks: make a misplaced call of statusline() more obvious by crashing
Also, reshuffle the lines, to take advantage of an other #ifndef.
2020-08-02 14:50:50 +02:00
Benno Schulenberg 40b03162c3 bindings: make <Alt+Backspace> delete a word backwards, like in Bash
It jars a bit that it is <Ctrl+Delete> that deletes a word rightward
and <Alt+Backspace> that deletes a word leftward.  But it's good to
also have a two-key keystroke bound by default to 'chopwordleft',
and not just the three-key <Ctrl+Shift+Delete>.

This fulfills https://savannah.gnu.org/bugs/?58709.
Requested-by: Axel Scheepers <axel.scheepers76+gnu@gmail.com>
2020-07-31 18:52:51 +02:00
Benno Schulenberg cf52f2ed62 tweaks: rename a variable, and condense a comment 2020-07-25 13:51:34 +02:00
Benno Schulenberg 294051769c tweaks: remove a superfluous check on the length of the key buffer
None of the calls of get_input() ask for more codes than those which
already were or will now have become available in the key buffer.
2020-07-25 13:42:06 +02:00
Benno Schulenberg 5ca4e9f5b3 tweaks: remove three unneeded while loops from two input routines
The whiles are unneeded because the result of get_input() can
never be NULL when in waiting mode -- and only when searching
for something are we NOT in waiting mode.
2020-07-25 12:11:48 +02:00
Benno Schulenberg 3e899b15c2 tweaks: reduce the indentation after the previous change 2020-07-24 17:12:31 +02:00
Benno Schulenberg a33b04ce90 tweaks: cascade the ifs properly: without increasing the indentation 2020-07-24 17:08:53 +02:00
Benno Schulenberg 36ab5d91de input: interpret an escape sequence only when it starts with "[" or "O"
This fixes https://savannah.gnu.org/bugs/?58818.

Bug existed since version 2.9.0, since macros were introduced.
2020-07-24 16:49:39 +02:00
Benno Schulenberg 8dc1b97465 tweaks: three escapes is the same as either zero escapes or one escape 2020-07-24 13:38:44 +02:00
Benno Schulenberg 350115242d bindings: stop supporting <Esc> <Esc> <numeric slash> without NumLock
<Ctrl+numeric slash> does not invoke Go To Line, so it is fitting
that <Esc> <Esc> <numeric slash> does neither.  If some user does
want the double escape plus slash to work, they can use --raw.

(Also, if someone really uses <Esc> <Esc> <numeric slash>, they
probably also type the desired line number on the numeric keypad,
and for that to work they needed to have NumLock engaged, and in
that case the double escape plus slash will work fine.)

(Getting rid of this numeric-slash support makes the three-escapes
case very similar to the one-escape case, allowing the first to be
folded into the latter in the next commit.)
2020-07-24 13:16:41 +02:00
Benno Schulenberg 7bf413db76 tweaks: rename two parameters, away from an abbreviation 2020-07-23 09:56:38 +02:00
Benno Schulenberg aafda2358f tweaks: rename two variables, away from abbreviations 2020-07-23 09:44:14 +02:00
Benno Schulenberg 6b9084ad09 tweaks: reshuffle a few lines, to elide an 'if' from the most common path
And for compactness.
2020-07-22 20:32:38 +02:00
Benno Schulenberg 364a1518de tweaks: reshuffle some lines, to better separate the three cases 2020-07-22 11:07:20 +02:00
Benno Schulenberg 93b2877758 tweaks: use three switches instead of cascading ifs, for brevity 2020-07-22 10:56:41 +02:00
Benno Schulenberg 832037e2ec tweaks: condense some cases to a single line, for more clarity
And return directly for codes that will not be changed any more.
2020-07-22 10:43:24 +02:00
Benno Schulenberg ad2920acd0 tweaks: handle the double escapes directly, instead of going round again
Immediately pull the available extra character from the keyboard buffer,
instead of cycling through the whole circus again.
2020-07-22 10:17:48 +02:00
Benno Schulenberg e59a0f5e77 build: replace the non-standard backslash escape "\e" with "\x1B"
Older compilers do not understand "\e".  Also, it's not in the standard
(see http://open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf, §6.4.4.4).

This addresses https://savannah.gnu.org/bugs/?58799.
Reported-by: Henry Bent <henry.r.bent@gmail.com>
2020-07-22 09:17:57 +02:00
Benno Schulenberg fd10c0eadd tweaks: rake a common statement to the end of the case
With the two situations that need to preserve the escape counter
now returning directly, the resetting of this counter can happen
at the end of each case block.
2020-07-21 14:03:18 +02:00
Benno Schulenberg 7e53fcb581 tweaks: remove two redundant conditions, and make a more direct return
The escape-parsing routine nowadays returns FOREIGN_SEQUENCE instead
of ERR when encountering an unknown sequence.  So, with the two cases
that demand ERR now handled directly, there is no need to check for
ERR any more.
2020-07-21 14:02:55 +02:00
Benno Schulenberg 43b39ed04f tweaks: use knowledge of Unicode to skip the general multibyte conversion
The relevant range is so small (128 bytes) that "manual" conversion
is much faster (and a bit shorter, eliding two variables).
2020-07-20 19:31:25 +02:00
Benno Schulenberg 17a8b24fe5 tweaks: skip the conversion to multibyte for plain ASCII codes
Converting an ASCII code to "multibyte" is a no-op: it stays one byte.
2020-07-20 19:16:45 +02:00
Benno Schulenberg b9db967bc4 tweaks: reshuffle some lines, for esthetics
There is no need to reset the digit counter (because this counter
matters only when the escape counter equals two) -- resetting the
escape counter is enough.
2020-07-20 19:06:16 +02:00
Benno Schulenberg 2a5d129738 tweaks: rename a variable, and normalize the indentation 2020-07-20 18:25:19 +02:00
Benno Schulenberg 6980cfbf70 tweaks: change a 'switch' to 'if', to elide a dummy 'return' 2020-07-20 18:21:43 +02:00
Benno Schulenberg a0d2e63c8e tweaks: improve four comments 2020-07-20 17:15:06 +02:00
Benno Schulenberg 57c52de99a tweaks: rename a function, and move it to before the one that calls it 2020-07-20 17:04:48 +02:00
Benno Schulenberg 9067f7a0c7 tweaks: elide a variable, by returning the result directly 2020-07-20 16:54:22 +02:00
Benno Schulenberg e4fa0b54a2 tweaks: remove two superfluous assignments
The digit counter will be reset to zero the next time when <Esc>
is pressed, and the byte holder gets re-initialized when the next
first digit is pressed.  And the escape counter is reset to zero
after returning from a result-giving call of get_byte_kbinput().
2020-07-20 16:28:36 +02:00
Benno Schulenberg b41405233f tweaks: remove some superfluous conditions
When get_byte_kbinput() is called, it has already been determined that
the keyboard input is a digit from zero to nine (or from zero to two
for the first digit), so there is no need to check this again.
2020-07-20 12:40:26 +02:00
Benno Schulenberg 88561506c9 tweaks: improve two comments, and reshuffle some lines for conciseness 2020-07-20 11:47:10 +02:00
Benno Schulenberg a08ca026f0 input: reset the counters when a three-digit sequence is not completed
When <Esc><Esc> is followed by digit 0 or 1 or 2 but then NOT two more
digits follow, then both the escape counter and the digit counter should
start afresh when a new ESC code arrives.

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

Bug existed since before version 2.0.6.
2020-07-20 11:19:44 +02:00
Benno Schulenberg d18cfb26cd tweaks: adjust the indentation after the previous change 2020-07-19 11:52:57 +02:00
Benno Schulenberg eb70578c5e tweaks: do not use 'switch' when there are just two possibilities
Also, remove an unneeded 'if', as parse_escape_sequence() is only
ever called when there are at least two bytes after the Esc code.
(If there were not, the 'for' loop after calling convert_sequence()
would use an uninitialized 'consumed' value.)
2020-07-19 11:52:47 +02:00
Benno Schulenberg 63efc59758 tweaks: don't check for escape sequences that start with a lowercase "o"
Such escape sequences don't exist -- those mistaken sequences were
removed in commit 4991b3bb from half a year ago.
2020-07-19 11:50:30 +02:00