Commit Graph

1648 Commits (511a2850a1b25389e40d6ba970be7e73eedcc9bb)

Author SHA1 Message Date
Benno Schulenberg ba4f4bdc64 minibar: show the line count in the bar (at startup and when saving)
Show the line count too when switching between buffers.
2020-12-23 12:17:06 +01:00
Benno Schulenberg 2b6c08b955 minibar: add an [x/y] "counter" when multiple files are open 2020-12-23 12:17:06 +01:00
Benno Schulenberg b86f7868d1 feedback: differentiate between remarks, mistakes, and information
Remarks are about unsurprising things but it's good to give feedback
on them; "mistakes" are unexpected things, and get colored like an
error; and information is something that the user requested and thus
needs to stay on the status bar until the next keystroke.
2020-12-23 12:17:06 +01:00
Benno Schulenberg 54995defd2 input: intercept ^Z also when --minibar is active
For some reason, calling halfdelay() undoes the ISIG mask.
So, mask keyboard interrupts again immediately after the call.

Reported-by: Peter Passchier <peter@passchier.net>
2020-12-23 12:17:06 +01:00
Benno Schulenberg b89bc2cce6 minibar: show the info bar again some 0.8 seconds after a message
Instead of redisplaying the minibar only upon the next keystroke
(when some feedback message is shown on the status bar), time the
waiting for the keystroke out after four fifths of a second, then
redisplay the minibar and continue the wait.
2020-12-23 12:17:06 +01:00
Benno Schulenberg d31cc373de display: add code for showing minimal state-information bar at the bottom
When activated, it suppresses the title bar, and suppresses feedback
on the status bar for toggles whose effect is obvious or whose state
is already shown in the minibar.

This addresses https://savannah.gnu.org/bugs/?58152,
and addresses https://savannah.gnu.org/bugs/?58789.
2020-12-23 12:17:05 +01:00
Benno Schulenberg f52f503c38 tweaks: move the displaying of the state letters into a separate function 2020-12-23 12:17:05 +01:00
Benno Schulenberg 8939163659 tweaks: reshuffle two lines, and rename a variable to a plain word 2020-12-22 19:23:40 +01:00
Benno Schulenberg 265bdd94f1 mouse: do not offset the shortcuts by 'margin' when using --linenumbers
The bottom window (the prompt bar and the shortcuts) does not shift
its position when line numbers are active, so mouse clicks in this
window should be not be compensated for the line-numbers margin.

This fixes https://savannah.gnu.org/bugs/?59749.
Indirectly-reported-by: ObeliX <ObeliX-@gmx.de>

Bug existed since version 2.7.0, since line numbers were introduced.
2020-12-22 19:15:32 +01:00
Benno Schulenberg 5c4c30e26b display: do not show the state flags in the help viewer or file browser
The state flags are relevant only when editing.

This fixes https://savannah.gnu.org/bugs/?59744.
Indirectly-reported-by: ObeliX <ObeliX-@gmx.de>

Bug existed since version 5.3, since --stateflags was introduced.
2020-12-21 14:59:18 +01:00
Benno Schulenberg d8500f0467 tweaks: remove some #ifdefs that were there only for Slang 2020-12-05 12:34:17 +01:00
Benno Schulenberg 7ebf5f52b8 tweaks: clean up after the previous change 2020-12-05 12:12:11 +01:00
Benno Schulenberg 4f7593b704 general: remove support for Slang
Slang has too many bugs to be useful.

This addresses https://savannah.gnu.org/bugs/?59210.
2020-12-05 11:57:08 +01:00
Benno Schulenberg 2157738a18 tweaks: correct two comments after the previous changes 2020-12-04 17:03:10 +01:00
Benno Schulenberg 681d11c0cf tweaks: rename a variable, to be similar to its sister 2020-12-04 16:57:17 +01:00
Benno Schulenberg d96f296b8e input: interpret a keystroke as Meta only when an earlier escape was solo
This allows using <Esc> <Esc> <letter> in a macro as an alternative
for <Ctrl+letter>, but it does require that one does not type <Esc>
by accident when recording a macro as it might modify the subsequent
keystroke when the macro is replayed.

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

Bug existed since version 3.0, commit ecc9211a.
2020-12-04 16:35:28 +01:00
Benno Schulenberg 048ab0ee0b tweaks: reduce the scope of a static variable 2020-12-04 16:30:28 +01:00
Benno Schulenberg a3a1391a51 tweaks: rename two variables, one for contrast, another for visibility
Also normalize two bits of whitespace.
2020-11-30 13:32:22 +01:00
Benno Schulenberg a4675acdba copyright: update to the current year for significantly changed files 2020-11-30 12:01:47 +01:00
Benno Schulenberg 00ac41f632 weeding: remove another unneeded workaround for VTE
The issue is only reproducible when lying about the width
of the terminal.

It was a workaround for https://savannah.gnu.org/bugs/?49106.
2020-11-28 16:12:20 +01:00
Benno Schulenberg fe22da6b2a build: exclude a workaround for VTE/Konsole when using a recent ncurses
The workaround was for https://savannah.gnu.org/bugs/?51335
(a cursor-misplacement bug), but both an recent Xfce Terminal
and a recent Konsole appear unaffected by the issue.  So, drop
the workaround for modern systems.
2020-11-27 14:15:42 +01:00
Benno Schulenberg 0c87a4ba41 build: include a workaround for VTE only when using an older libvte
Checking for the actual version of libvte is too complicated, so
assume that libvte is 0.58 or newer (where the problem is fixed)
when ncurses is 6.2 or newer.
2020-11-27 12:31:41 +01:00
Benno Schulenberg 9da23799ff tweaks: reshuffle a fragment of code, for clarity 2020-11-26 17:32:30 +01:00
Benno Schulenberg 29276d1d3a help: allow the penultimate item extra space when the number is uneven
This avoids unnecessarily truncating the last help item on the
very bottom row when there is still plenty of room.

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

Bug has been visible since at least version 2.5.1.
2020-11-26 17:12:09 +01:00
Benno Schulenberg b7539ea985 weeding: remove a workaround for versions of ncurses before 5.9
(Yes, the test is for 6.0, but the bug was actually fixed in 5.9,
as far as I remember -- I just wasn't sure and didn't want to bother
building different versions of ncurses myself.)
2020-11-15 10:27:22 +01:00
Benno Schulenberg d2869ab348 build: include some raw sequences for the graphical Debian installer
The terminal window in the graphical Debian installer (the default)
produces the same escape sequences as xterm for F1 to F4.  Though
TERM is set to xterm, the xterm terminfo data is not available, so
ncurses is unable to translate the sequences for us.  :|  Therefore,
recognize the relevant raw escape sequences.

Also, eat all bytes of the non-recognized modified function and arrow
keys, so that they do not enter junk into the buffer.
2020-10-01 14:43:34 +02:00
Benno Schulenberg 3f938e29b6 build: exclude bunches of raw escape sequences from the tiny version
The tiny version is probably only ever used in the Debian installer,
on the bterm terminal, which produces escape sequences like those of
a Linux console.  So, exclude all other raw sequences.

(After support for Slang has been removed, we can maybe even exclude
ALL raw sequences from the tiny version, and the corresponding option
(-K/--rawsequences) too.)
2020-10-01 09:06:12 +02:00
Benno Schulenberg 037b77555e tweaks: condense a bit of code after the previous change 2020-09-30 19:51:29 +02:00
Benno Schulenberg 51b9e86d13 tweaks: remove mistaken escape sequences for function keys on xterm
At least since version 229 of xterm (from August 2007), the escape
sequences for F1 to F4 have been "Esc O P" to "Esc O S".  There is
no bracket in those sequences, and there probably never was -- most
likely the extra "[" in nano's code was a slip of the fingers.
2020-09-30 19:46:48 +02:00
Benno Schulenberg 4a403ae00f display: do not unnecessarily wipe the status bar
It would wipe the edit window if there is just one row.

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

Bug existed since version 2.9.3.
2020-09-25 16:52:31 +02:00
Benno Schulenberg 0906181d75 tweaks: reshuffle a condition, to elide a blank string 2020-09-24 16:24:34 +02:00
Benno Schulenberg 7ff6b97e5c tweaks: reshuffle some lines and adjust indentation after previous change
Also, exclude the state-flag stuff from the tiny version.
2020-09-23 19:48:03 +02:00
Benno Schulenberg d679bbc802 new feature: option --stateflags to show some states in top-right corner
With --stateflags (short form: -%) or 'set stateflags', nano reserves
the righthand end of the title bar not for showing "Modified" but for
showing the state of auto-indentation (I), the mark (M), the breaking
of long lines (L), macro recording (R), and softwrapping (S).

When the buffer is modified, this is indicated with a star (*) after
the file name (shown in the center of the title bar).

This fulfills https://savannah.gnu.org/bugs/?57953.
Requested-by: Sébastien Desreux <seb@h-k.fr>
2020-09-23 19:48:03 +02:00
Benno Schulenberg cb841de3fc feedback: make an "Unbound key" message disappear on the next keystroke
When nano reports "Unbound key" or "Unknown sequence", this message
should stay onscreen only for the relevant keystroke, not for any
succeeding keystroke.

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

Bug existed since before version 2.0.6.
2020-09-17 19:36:04 +02:00
Benno Schulenberg e12f397140 build: do not let Slang translate escape sequences to key codes
Slang fails to translate the longer sequences, and then truncates
these sequences to just four bytes, effectively destroying them.

Therefore, when built with --with-slang, always activate --raw-sequences.

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

Bug was visible since version 2.5.0, since bindings
for Ctrl+Left/Ctrl+Right were added.
2020-09-17 16:54:41 +02:00
Benno Schulenberg 93b25ce014 tweaks: adjust some whitespace in the docs, and improve a comment 2020-09-12 12:21:24 +02:00
Benno Schulenberg b9a1a586c0 display: force the cursor to reappear in a better way (when using Slang)
The cursor would disappear after any message on the status bar --
for example, also when M-W is typed and nothing is found -- so the
mitigation trick needs to be performed in statusline() itself.

This addresses https://savannah.gnu.org/bugs/?59091.
2020-09-11 18:54:49 +02:00
Benno Schulenberg d2d0c665b1 display: force the cursor to reappear after a message (when using Slang)
For some reason, when running a tiny nano built with Slang on the bterm
of a Debian installer image, the cursor disappears when certain things
are written to the status bar.  Make the cursor reappear by rewriting
the two help lines with dummy items (and then rewriting it again with
the normal menu in the central loop).  Of course, this does not help
when the user uses -x or --nohelp to suppress the help lines, but at
least in the default setup the cursor doesn't get hidden now and then.

This mitigates https://savannah.gnu.org/bugs/?59091.

Bug existed since before version 2.2.4.
2020-09-10 18:46:48 +02:00
Benno Schulenberg cf4901da2d suspension: do not enter an invalid byte upon resume (when using Slang)
Instead of stuffing 0x91 into the input stream, use 0xFF when built
with Slang -- the same code that Slang itself produces when resuming
from an externally induced suspension.  This byte is ignored.

In a UTF-8 locale, it should be safe to ignore the byte 0xFF coming
from the keyboard, as no valid UTF-8 sequence can contain 0xFF.

In an ISO8859 locale, this change prevents ÿ from being typed on the
keyboard -- it can still be entered with <Esc> <Esc> 255, though.
My apologies to the people of Pierre Louÿs and L'Haÿ-les-Roses.
2020-09-07 17:09:57 +02:00
Benno Schulenberg 46e769a113 rcfile: add 'set scrollercolor', for changing the color of the indicator
This fulfills https://savannah.gnu.org/bugs/?59041.
2020-09-02 19:55:24 +02:00
Hussam al-Homsi c87bc1d55f tweaks: stop casting the return of malloc() and friends
Those casts are redundant, and sometimes ugly.  And as the types of
variables are extremely unlikely to change any more at this point,
the protection they offer against miscompilations is moot.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-08-31 12:17:27 +02:00
Benno Schulenberg 7ffbf01607 tweaks: improve three comments and an indentation 2020-08-21 16:06:38 +02:00
Benno Schulenberg f6b4c243d8 tweaks: reshuffle four declarations, and rename two variables 2020-08-21 16:03:59 +02:00
Benno Schulenberg 8daa7cbda0 tweaks: remove a variable and two functions that have become redundant 2020-08-20 09:17:48 +02:00
Benno Schulenberg bc6b9bf955 tweaks: rename a variable, to not seem to refer to the scrollbar 2020-08-17 13:36:03 +02:00
Benno Schulenberg fb98f0ced7 tweaks: adjust a comment, and reshuffle the setting of a boolean 2020-08-15 16:07:30 +02:00
Benno Schulenberg d09055db43 input: dawdle after an ESC also when --rawsequences is used
When keypad() is set to FALSE, like for verbatim input, ncurses is
not waiting its fifty milliseconds after an ESC to see if another
code will follow it, so nano itself will have to pause a little.

Otherwise 'solitary' could get set to TRUE when in fact the ESC
is followed very closely by another code.

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

Bug existed since version 2.6.2, commit f2150d3f.
2020-08-15 14:45:02 +02:00
Benno Schulenberg 50b61bef6f input: discard any multibyte character when <Alt> is being held
Otherwise the <Alt> key would simply be ignored.  It's better to reject
the combination, to compel the user to be precise in what they type.
2020-08-15 14:00:53 +02:00
Benno Schulenberg 3d0bfb0a00 input: do not enter invalid bytes when holding down both Alt keys
This fixes https://savannah.gnu.org/bugs/?58954.

Bug existed since version 5.1, commit 49231191.
2020-08-15 13:18:48 +02:00
Benno Schulenberg 3cb55c8b27 verbatim: reserve enough space for the result also in non-UTF-8 locales
Also when each character is just one byte, parse_verbatim_kbinput()
can produce two bytes; plus the terminating NUL that is three bytes.

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

Bug existed since version 4.9, commit 03d296eb.
2020-08-15 11:55:48 +02:00
Benno Schulenberg e597ad4908 build: fix compilation when configured with --enable-tiny 2020-08-11 19:59:24 +02:00
Benno Schulenberg 100747f56b verbatim: discard entire keystroke when it's not valid for Unicode Input
This will not work for the deviant escape sequences for F1 to F5
on the Linux console nor for Alt+arrow on urxvt and such, but...
I can't be bothered to handle those too.

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

Bug existed since commit be203832 from earlier today.
2020-08-10 16:18:03 +02:00
Benno Schulenberg 9875252fd7 tweaks: remove an unneeded beep, and reshuffle the lines for compactness
The beep is produced later, after get_verbatim_kbinput() returns.
2020-08-10 12:07:16 +02:00
Benno Schulenberg 1551c1c771 verbatim: do not report "Invalid code" when a Unicode character is typed
This fixes https://savannah.gnu.org/bugs/?58928.

Bug existed since version 5.0, commit 5899181a.
2020-08-10 11:48:31 +02:00
Benno Schulenberg 8e226a9f28 verbatim: do not report "Invalid code" when the terminal is resized
During verbatim input at most four integers are produced (the longest
possible unicode sequence), so use the value 999 to indicate a special
condition (a screen resize) that should not enter anything into the
buffer AND should not produce any error message or beep.

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

Bug existed since version 5.0, commit 5899181a.
2020-08-10 11:42:09 +02:00
Benno Schulenberg be20383240 verbatim: report and ignore an invalid keystroke for Unicode input
When Unicode Input has started (by typing 0 or 1 at the Verbatim Input
"prompt"), and something is typed that is not a hexadecimal digit, then
don't try to enter this character into the buffer but simply report it
as invalid and ignore it.  Because most likely the user mistyped and
actually meant to enter a valid hex digit.

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

The bug was old -- it existed since at least version 2.0.6.
2020-08-10 09:31:24 +02:00
Benno Schulenberg cf769bbd2f tweaks: adjust the indentation after the previous change 2020-08-10 07:55:00 +02:00
Benno Schulenberg 4ec96f9f2e tweaks: reshuffle a few lines, to condense the code, and improve comment 2020-08-10 07:53:41 +02:00
Benno Schulenberg bdc856812f tweaks: read keycodes from the keystroke buffer without copying them
Allocating and freeing memory for reading every single keycode
is a waste of time and effort.

This addresses https://savannah.gnu.org/bugs/?58806.
2020-08-10 07:39:29 +02:00
Benno Schulenberg 07e69d54b2 tweaks: elide two variables that are no longer needed, and update comment 2020-08-09 15:40:53 +02:00
Benno Schulenberg aeb15e9549 tweaks: parse the escape-sequence bytes without copying them first 2020-08-09 15:25:22 +02:00
Benno Schulenberg 435d9acb5c tweaks: exclude old and mistaken "Esc O" sequences from the tiny version
The correct sequences begin with "Esc [" instead.  I cannot find in the
histories of VTE and Gnome Terminal when these sequences were corrected.

Also exclude a bug check from the tiny version.
2020-08-09 10:48:03 +02:00
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
Benno Schulenberg 62ffc221aa tweaks: rename a function, and move it to before the one that calls it 2020-07-11 19:43:37 +02:00
Benno Schulenberg ec8fd9f365 tweaks: reshuffle some code, to avoid needlessly calling a function 2020-07-11 19:11:00 +02:00
Benno Schulenberg d3a8488b0e tweaks: use a better symbol than 'ERR' to signify a valid hex digit 2020-07-11 18:58:12 +02:00
Benno Schulenberg b3d6c27502 tweaks: improve a comment, rename a function, and elide a parameter
Checking the current menu instead of the current subwindow works fine.
2020-07-11 18:36:52 +02:00
Benno Schulenberg 2e4d78a714 tweaks: fold translation of all modified keypad keystrokes together
The escape-sequence codes for the different keypad keys are simply
the relevant ASCII code plus 0x40, so they are easy to translate.

Also, do not accept keypad keys with multiple modifiers (Shift+Alt,
Shift+Ctrl, Alt+Ctrl, Shift+Alt+Ctrl) -- report "Unknown sequence"
for those.
2020-07-11 12:16:18 +02:00
Benno Schulenberg 476c838753 bindings: allow typing digits on the numeric keypad by holding Shift
Until now, on an xterm, Shift plus any keypad key would say
"Unknown sequence", which is not useful.  On other terminal
emulators (urxvt, Pantheon, LXTerminal), Shift plus a keypad
key already produces the relevant digit or symbol, so this
change harmonizes the behavior of the different emulators.

However, on a Linux console, Shift plus a keypad key moves
the cursor and selects the text that is passed over.  And
holding Alt while pressing a keypad key does nothing at all.
2020-07-11 11:49:41 +02:00
Benno Schulenberg ecb4dac494 bindings: stop <Alt+operator> on the keypad from entering spurious letter
For the operator keys on the numeric keypad (/, *, -, and +),
make both the Alt and the Ctrl modifier a no-op.

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

Bug existed since version 2.9.3, commit e734488c.
2020-07-11 11:46:43 +02:00
Benno Schulenberg 95df7dbc8e tweaks: correct some comments, as VT100 and such have smaller keypads
The DEC VTnnn terminals only have period, comma, and minus on the
numeric keypad, not slash nor star nor plus nor Insert nor Delete.
2020-07-11 11:44:23 +02:00
Benno Schulenberg 97a993d401 verbatim: turn bracketed-paste mode off while waiting for input
This allows pasting six hexadecimal digits after typing M-V
in order to enter a specific Unicode character.

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

Bug existed since version 4.8, since bracketed pastes
were introduced in commit f705a967.
2020-07-08 16:24:53 +02:00
Benno Schulenberg abfde53945 tweaks: drop an unneeded assignment, and reshuffle a few lines
And reset the 'lastmessage' variable to a more fitting value.
2020-07-04 09:36:17 +02:00
Benno Schulenberg f21508f071 tweaks: improve some comments, and reshuffle an assignment 2020-07-03 19:10:48 +02:00
Benno Schulenberg 1388af2bdc tweaks: elide a wrapper function, by checking a precondition earlier 2020-07-03 12:41:40 +02:00
Benno Schulenberg 2e6886406c tweaks: elide an unneeded global variable
The constant cursor display must be suppressed whenever a message
was printed to the status bar.  That is: whenever 'lastmessage' is
something other than 'VACUUM'.
2020-07-03 12:41:40 +02:00
Benno Schulenberg 009fb2fae6 tweaks: make three hard-bindings of special keys more efficiently
Instead of calling a function that tries to find the relevant operation,
just add three hidden hard-bindings at the end of the shortcuts list.

They are hidden because we don't want them to show up in the help text,
because we don't know what to call them (as a Cancel and Suspend key
don't exist on normal keyboards) or naming the key would be confusing
(Sh-Ins is grabbed by the desktop manager and doesn't reach nano).
2020-06-27 10:20:45 +02:00
Benno Schulenberg 90f6342fd1 tweaks: rename two header files, to be distinct and not an abbreviation 2020-06-20 12:09:31 +02:00
Benno Schulenberg fd28e5f36c build: fix compilation when configured with --enable-tiny 2020-06-15 12:38:16 +02:00
Benno Schulenberg 7f40eeab0a tweaks: call the spotlighting routines only for the relevant line
Otherwise the affected piece of text gets drawn and spotlighted as
many times as there are rows in the edit window.
2020-06-15 09:45:01 +02:00
Benno Schulenberg d67faa2bb5 tweaks: remove a superfluous global variable
There were no calls of statusbar() or statusline() before curses mode
was entered.  But since the previous commit curses mode is entered
even earlier, so...
2020-06-14 13:09:23 +02:00
Benno Schulenberg 9a9f36fca7 indicator: rework how the "scrollbar" is computed when softwrapping
Instead of storing for each line the ordinal number of the first chunk
in that line, simply store the number of extra chunks in the line.

It now takes some more computation to actually draw the scrollbar, but
it saves a lot of computation when just inserting or deleting characters
(when using --softwrap and causing a change in chunk count).

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

Bug existed since commit 6bccedb3 from two days ago.
2020-06-06 19:21:23 +02:00
Marco Diego Aurélio Mesquita 6bccedb319 display: support the position indicator also when --softwrap is used
A new member ('chunk_nr') is added to each 'linestruct', to store
the serial number of the first chunk of that line, so that, when
softwrap is on, the scroll-bar thing can be computed relative to
chunks instead of relative to actual lines.

To guarantee that 'chunk_nr' is correctly synced, the buffer is
renumbered whenever the number of chunks in a line changes, and
also when softwrap is toggled on, and when buffers are switched.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-06-04 18:52:28 +02:00
Benno Schulenberg b33a62af8c new feature: a position-plus-portion indicator on the righthand side
This displays a scrollbar-like thing on the right edge of the screen,
giving a rough indication where in the buffer the text that is being
shown in the viewport is located, and how large/small a portion of
the buffer this text is.

(Support for softwrapping, and an option to turn the indicator on,
will arrive in subsequent commits.)

This fulfills https://savannah.gnu.org/bugs/?57956.

Original-patch-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2020-06-04 18:52:28 +02:00
Benno Schulenberg bc92e28b30 tweaks: elide an unused parameter, and rename the other and a variable
Also, regroup a few lines.
2020-06-03 18:45:14 +02:00
Benno Schulenberg c5b0e1958a feedback: beep also at a prompt when receiving an unknown escape sequence
Nano would beep (and report "Unknown sequence") only when in the main
edit window, in the help viewer, or in the file browser.  But the same
keystroke at a prompt would be enigmatically silent.

Also, in the file browser, nano would leave the cursor at the end of
the "Unknown sequence" message when --showcursor was used.

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

Bug existed (in this form) since around version 2.7.4,
and in a worse form since around version 2.3.5.
2020-06-03 17:15:51 +02:00
Benno Schulenberg da43cc0959 display: reposition the cursor after an error message also in a help text
A help text is contained in a normal buffer (since quite a while now),
so cursor placement should work like in a regular edit window.

Also, remove an unneeded switching on of the cursor -- it is already on
as nano is waiting for keyboard input.

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

Bug existed since version 3.2, commit 10d9742c, since --showcursor
shows the cursor also in the help viewer.
2020-06-03 10:38:08 +02:00
Benno Schulenberg 506f617d5b tweaks: remove an unneeded call of wnoutrefresh()
On NetBSD, nano requires ncurses nowadays.  With ncurses, cursor
placement works fine without the extra call of wnoutrefresh().
2020-06-03 10:14:50 +02:00
Benno Schulenberg 881106c487 tweaks: drop two unneeded wnoutrefresh() calls in the spotlight routines
The call will be made at the end of edit_refresh() or in the main loop.
2020-06-01 20:28:07 +02:00
Benno Schulenberg 2a44cb2ed8 tweaks: rename a function, to leave the old names behind
What the function does has changed, so better change the name too.
2020-06-01 09:43:08 +02:00
Benno Schulenberg 19a124e806 display: avoid an additional redrawing when redrawing the screen
When resizing the screen or toggling the help lines or refreshing
the screen with ^L, what used to be total_refresh() would first call
what used to be total_redraw(), to tell ncurses to redraw whatever
had been on the screen so far, before proceeding to fully redraw the
content of the title bar and the edit window and the bottom bars.
That was duplicate work.

Thus, rename total_redraw() to total_refresh(), so that ^L in the
edit window, help viewer, and file browser will redraw the screen
just once.  This also preserves whatever was on the status bar
(when --quickblank isn't used).

Rename the old total_refresh() to draw_all_subwindows() and call
this routine when resizing the screen or toggling the help lines
or returning from the credits crawl.
2020-06-01 09:40:09 +02:00
Benno Schulenberg 933dd567de tweaks: separate a symbol from its definition by two spaces
It's a little clearer, and new ones were like that already.
2020-05-29 18:45:14 +02:00
Benno Schulenberg 6d00e75dc2 tweaks: rename a function, to be more correct 2020-05-28 16:59:50 +02:00
Benno Schulenberg 15fadd700a tweaks: rename a function, to be more precise, and reshuffle it 2020-05-13 12:43:22 +02:00
Benno Schulenberg 78bfc9223a tweaks: add a condition, so that two ifs can be elided
Now all functions that are relevant only to softwrapping
get called only when softwrapping is on.

This also allows to elide an intermediate function call.
2020-05-13 12:32:57 +02:00
Benno Schulenberg e8e9b8ad82 tweaks: move an 'if', to not call leftedge_for() when not softwrapping 2020-05-13 12:01:55 +02:00
Benno Schulenberg b47d111a3d tweaks: don't use a symbol for other purposes 2020-05-11 16:18:03 +02:00
Benno Schulenberg 56fc8f6d30 tweaks: improve a comment, reshuffle a scroll command, elide a variable
Also, drop an unneeded keyboard check: the next check is just a few
microseconds away.
2020-05-06 17:29:20 +02:00
Benno Schulenberg b9deb883fa tweaks: shorten the name of a symbol, to match its bindable function 2020-05-01 13:25:15 +02:00
Benno Schulenberg 9c4ebed3ff tweaks: remove an unneeded element from the openfilestruct 2020-05-01 12:38:02 +02:00
Benno Schulenberg 5ca2fd887a startup: initialize colors only when the terminal is capable of colors
This avoids trying to show colors on a vt100, for example.
2020-04-29 12:07:31 +02:00