Commit Graph

9582 Commits (8d974cd2922db2222be7b3d3e6f47899b98f6ec8)

Author SHA1 Message Date
Benno Schulenberg 5a635db262 chars: reduce searching time with roughly 85 percent for plain ASCII
Make case-insensitive searching in a UTF-8 locale eight times faster
when the actual characters involved are plain ASCII.

This makes us faster than 'less', and as fast as Vim and Emacs.

The disadvantage of this change is that searching for a string that
begins with a multibyte character is nearly ten times slower than
searching for one that begins with an ASCII character.  This may be
unsettling when searching a huge file first for a simple ASCII string
and later for a UTF-8 one.  Doing this second search, the user might
get impatient: "Why is it taking so long?"

(This patch fell through the cracks four years ago, when I worked on
the searching code.  It sat in a branch on top of other changes that
I never applied because I made different improvements.  The speedup
at the time, on that machine, was only around sixty percent, though.
But measuring it now again on the same machine, it clocks in at an
82 percent reduction with -O0 and an 87 percent reduction with -O2.)
2020-09-01 19:35:34 +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 5c63975097 tweaks: rename four variables, reshuffle them, and correct one type
Also, drop three unneeded comments.
2020-08-25 12:13:55 +02:00
Benno Schulenberg fee905a34a tweaks: drop the unneeded saving and restoring of a global variable
The two functions findnextstr() and do_replace_loop() do not change
or even touch 'last_search', so there is no need to save and then
restore its value when doing corrections of misspelled words.
2020-08-25 11:58:04 +02:00
Benno Schulenberg 070c9c60ec po: update translations and regenerate POT file and PO files 2020-08-24 11:08:23 +02:00
Benno Schulenberg 63ac050733 bump version numbers and add a news item for the 5.2 release 2020-08-24 09:53:07 +02:00
Benno Schulenberg 3ade8b29cc build: stop distributing the README.GIT file
There is no need for normal users to build from git.  Do not give
the impression that that procedure is in any way recommended.
2020-08-24 09:29:05 +02:00
Benno Schulenberg 51a6d5897e gnulib: back away from a commit that causes trouble when using clang
The issue has been reported here:
  https://lists.gnu.org/archive/html/bug-gnulib/2020-08/msg00202.html
2020-08-23 10:52:20 +02:00
Benno Schulenberg 785d28d5d1 gnulib: update to its current upstream state 2020-08-23 09:10:35 +02:00
Benno Schulenberg 4873cc26f2 build: stop mentioning Slang in two ./configure messages
Nobody ought to be using Slang, so don't give people the wrong
impression by mentioning it (and even mentioning it *first*).
2020-08-23 09:05:47 +02:00
Benno Schulenberg 0f8423eb4c tweaks: elide an unneeded variable
Storing the orientation of the marked region beforehand is not needed,
as this orientation is readily available also after the justification.

(By the way, cursor and mark need to be swapped after justifying
a backward-marked region because the rule is that the cursor gets
placed *after* the justified paragraph.  Maybe that should change?)
2020-08-22 19:35:48 +02:00
Benno Schulenberg b60fec5db3 history: do not interpret a failing stat() as an error
The most likely reason for stat() returning -1 is that the file
does not exist.  And an absent positionlog file is not an error.
(In some cases it is, like immediately after writing the file,
but even then we don't want to complain, because it may have
been some other process that deleted the file straightaway.)

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

Bug existed since version 5.0, commit fcb9e58b.
2020-08-22 10:27:02 +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 0287be7660 tweaks: move the keyboard-checking code to the end of the search loop 2020-08-20 10:51:19 +02:00
Benno Schulenberg e6709d684b tweaks: condense two fragments of code, for compactness 2020-08-20 10:44:06 +02:00
Benno Schulenberg aa257ef58e display: restore the ability to resize the screen while searching
This ability was lost in commit 92298349 from two hours ago, which
bypasses the keystroke buffer and its integrated screen resizing.

This new implementation is better than it was before, because it
responds almost instantly to a resize instead of with a delay of
up to a second.
2020-08-20 10:31:58 +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 8a5449cebe input: allow also a Meta keystroke to abort a Search command
(Still, this does not allow a full escape sequence to be used as
the Cancel command, but I think that is an acceptable limitation,
because 1) nobody ought to be using --rawsequences, and 2) very
few people will bind Cancel to something like F3 or Ins.)

This improves the fix for https://savannah.gnu.org/bugs/?58825.
2020-08-20 09:17:03 +02:00
Benno Schulenberg 9229834935 search: poll the input stream directly, not nano's own keystroke buffer
When checking (during a Search command) whether the user has pressed
the Cancel keystroke, look at ncurses' input stream directly instead
of at nano's own keystroke buffer, because the latter may contain the
copied keystrokes of a macro and we don't want to discard those.

(This does not yet allow a Meta keystroke to be used for Cancel, but
the next commit will fix that.)

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

Bug existed since version 2.9.0, since the macro was introduced.
2020-08-20 08:25:26 +02:00
Benno Schulenberg 6469e9668b tweaks: condense two declarations 2020-08-19 16:52:28 +02:00
Benno Schulenberg 68d71f649e rcfile: make sure that "bright"/"light" are prefixes, not separate words
This fixes https://savannah.gnu.org/bugs/?58984.

The bug was old -- it existed since at least version 2.0.6.
2020-08-19 16:18:29 +02:00
Benno Schulenberg 71752f47cb docs: reshuffle the section about the file browser to a better place
First mention the three main 'pieces' of the editor: Editing window,
Help viewer, and File browser.  Then mention how to change settings:
with the toggles or with nanorc files.
2020-08-19 08:54:30 +02:00
Benno Schulenberg 51f27d3f0c input: hold on to a shift-selected region when an unbound key is struck
There is no reason to deselect the region, as nothing has changed.

(This also retains the shift-selected region when a non-shortcut key is
typed in view mode, which makes sense, as again nothing was changed.)

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

Bug existed since version 4.9, commit 0ed62e84.
2020-08-19 08:36:00 +02:00
Benno Schulenberg b38265cfb8 search: retain the current answer when something is toggled
This fixes https://savannah.gnu.org/bugs/?58972.

Bug existed since version 5.0, commit bccb0ea0.
2020-08-18 09:17:39 +02:00
Benno Schulenberg b5fb41e963 docs: mention in the FAQ how to change the escape sequences of urxvt
Replace an obsolete question that doesn't have a good answer: setting
TERM to vt100 is unlikely to make the more complicated keystrokes work,
which are the ones that are most likely not to work.
2020-08-18 09:00:56 +02:00
Benno Schulenberg a14c894325 docs: add a cross-reference from 'findbracket' to 'set matchbrackets' 2020-08-17 14:20:03 +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 4b6090ded3 replacing: do not try to wipe nonexistent multidata, to avoid crashing
This fixes https://savannah.gnu.org/bugs/?58970.
Reported-by: Matteo Raso <mraso@uoguelph.ca>

Bug existed since version 5.0, commit 569d0056.
2020-08-17 10:05:25 +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 306906a8a7 docs: adjust description of ^T in cheatsheet, and mention M-Bsp 2020-08-13 07:21:21 +02:00
Benno Schulenberg 6e2c245ecc po: update translations and regenerate POT file and PO files 2020-08-12 08:35:14 +02:00
Benno Schulenberg 74a0ffcbc5 tweaks: baptize the release 2020-08-12 08:24:06 +02:00
Benno Schulenberg b1a0f5e65a bump version numbers and add a news item for the 5.1 release 2020-08-12 07:57:31 +02:00
Benno Schulenberg 7e8b1ed420 build: stop distributing the two old Changelogs
For installing and using nano, those two Changelogs are useless,
and for inspecting the history of nano, 'git log' is much better.

Only the most recent Changelog is somewhat useful for some users,
for walking in some detail through the changes that were made in
the last few versions.
2020-08-11 20:12:56 +02:00
Benno Schulenberg b2ea7d29d0 build: fix compilation for --enable-tiny --enable-nanorc --enable-color 2020-08-11 20:10:40 +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 d7b2b55bf5 display: show the cursor position also right after the screen is resized
Bug existed since commit 8e226a9f from half an hour ago.
2020-08-10 12:16:18 +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