Commit Graph

10413 Commits

Author SHA1 Message Date
Benno Schulenberg
3922b531a8 input: allocate a small keystroke buffer, and never free it
Instead of allocating and freeing a tiny fragment of memory for every
keystroke, reserve a small piece in the beginning and then retain it,
because it will be needed again and again and again.  Increase the size
when needed (for a large paste, probably), but don't bother to shrink
it afterward.

This addresses the first part of https://savannah.gnu.org/bugs/?63086.
2022-09-25 09:22:29 +02:00
Benno Schulenberg
0d1438a731 tweaks: reshuffle a declaration, and correct the wording of a comment
Also, drop an unneeded condition, as memmove() allows moving zero bytes.
2022-09-23 09:34:14 +02:00
Benno Schulenberg
7eb66d3e09 tweaks: condense a comment, add two small ones, and reshuffle a line
(Apart from reducing the verbosity of the long comment, also harmonize
its format: mentioning the FreeBSD key always first.)
2022-09-22 10:50:05 +02:00
Benno Schulenberg
c7a600063d tweaks: reshuffle some lines, to be more readable instead of compact 2022-09-20 16:21:32 +02:00
Benno Schulenberg
5b654ce9fb docs: suggest a key binding for snipping trailing blanks
This addresses https://savannah.gnu.org/bugs/?63062.
2022-09-18 10:44:05 +02:00
Benno Schulenberg
98e9a881c0 docs: mention in the man page how M-V can insert any Unicode code point
This addresses https://savannah.gnu.org/bugs/?63055.

Inspired-by: Tasos Papastylianou <tpapastylianou@hotmail.com>
2022-09-18 09:05:28 +02:00
Benno Schulenberg
f420f7c177 verbatim: do not overwrite the status bar when the code is invalid
Move the triggering of the line redraw out of the error path, and
into a better place: next to the normal clearing of the feedback.

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

Bug existed since version 6.0, commit 6d828cf4.
2022-09-13 16:57:28 +02:00
Benno Schulenberg
50954a4b6a search: skip a match on the magic line, as it is a just convenience line
As the magic line isn't really a line (it is not counted in the number
of lines read and written), and nothing is on it (not even a newline),
it doesn't make sense to allow any regex, like ^ or $, to match it.

This fixes https://savannah.gnu.org/bugs/?63034.
Indirectly-reported-by: Mike Scalora <mike@scalora.org>

Bug existed since before version 2.0.0.
2022-09-12 08:47:51 +02:00
Benno Schulenberg
567310e698 tweaks: reduce four variations of a message to a single common form
(This could have been done a long time ago, but it simply didn't occur
to me.)
2022-09-12 08:45:37 +02:00
Benno Schulenberg
f90b710c9b tweaks: group the special keycodes for implanted strings together
This shows better that they are related.
2022-09-11 17:49:44 +02:00
Benno Schulenberg
bdaec3f934 docs: clarify the distinction between binding a function and "{function}"
This addresses https://savannah.gnu.org/bugs/?63010.

Inspired-by: Tasos Papastylianou <tpapastylianou@hotmail.com>
2022-09-11 16:29:18 +02:00
Benno Schulenberg
8198fd9c58 tweaks: reword and/or condense four comments 2022-09-11 16:29:02 +02:00
Benno Schulenberg
358a10e3cc tweaks: elide an assignment by iterating with the target variable 2022-09-11 12:03:06 +02:00
Benno Schulenberg
7b935e0d40 tweaks: elide an intermediary variable that is no longer needed 2022-09-11 11:57:11 +02:00
Benno Schulenberg
7034c3cc47 tweaks: drop shunting of flags by calling the needed function directly
Calling strstrwrapper() with the Backwards, Casesens, and Regex flags
unset is equivalent to calling mbstrcasestr().  So... do that instead
and quit saving and restoring the flags for each call of findfile().

This saving-and-restoring has been redundant since commit b0957254
from eight years ago.
2022-09-11 11:51:34 +02:00
Benno Schulenberg
e30eadb4de verbatim: don't show dots during Unicode input, as they give wrong idea
The dots gave the impression that the next keystroke (hex digit) would
land somewhere on the dots.  But this is not so -- the current digits
are instead shifted to the left and the new digit is added at the end.

Also adjust and improve several comments.
2022-09-11 09:23:44 +02:00
Benno Schulenberg
3e3f4a167a tweaks: elide a function that does not need to be a separate function
Also elide three calls of tolower(), using ORing with 0x20 instead,
as we're dealing with plain ASCII here.

Rename a variable too, away from a double abbreviation.
2022-09-11 09:01:06 +02:00
Benno Schulenberg
c98528f8d3 tweaks: simplify a function now that a Unicode code can be typed quicker 2022-09-11 09:01:06 +02:00
Benno Schulenberg
75e5f885e5 verbatim: allow the user to finish Unicode input with <Enter> or <Space>
Instead of requiring always six digits, allow the user to indicate
with <Enter> or <Space> that the digits typed so far are the complete
Unicode code point (when prefixed with the missing number of zeroes).

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

Inspired-by: the <Ctrl+Shift+U> shortcut that some desktops have
2022-09-11 09:01:06 +02:00
Benno Schulenberg
40b9e68e02 goto: don't center the current line when the user specified a column only
This does not quite do what I would have liked (scroll only when needed)
when on a softwrapped line and jumping to a different chunk, but... it's
still better than needlessly centering the line.

(The user can still center the line, if that is what they want, by using
a period or a slash instead of a comma.)

This addresses https://savannah.gnu.org/bugs/?63008.
2022-09-04 10:49:52 +02:00
Benno Schulenberg
e7491920fd docs: explain how to include a double quote plus space in a nanorc regex
As double-quote-plus-space indicates the end of a regular expression
in a nanorc file, the inclusion of this combination *in* a regular
expression requires breaking the juxtaposition of the two, which
can be achieved by putting either of them between square brackets.

(It can also be achieved by preceding the space with a backslash,
which is shorter, but... the above method is more symmetrical.)

This addresses https://savannah.gnu.org/bugs/?62997.
2022-09-01 17:29:04 +02:00
Benno Schulenberg
9904aa5538 tweaks: make the crawl use the whole screen also in the tiny version
Nobody will configure nano with --enable-tiny --enable-extra, but *if*
someone does, the title bar should be absent during the crawl.

Also, swap two messages, so that their order in the POT file will be
more sensible -- a closing brace comes after the function name.
2022-09-01 08:38:18 +02:00
Benno Schulenberg
41b89aef8c tweaks: move the arrays of menu names and symbols to where they are used
Also, use a better return value for the "unrecognized name" case,
so that it cannot possibly be confused with the "all menus" case.
2022-08-31 17:28:09 +02:00
Benno Schulenberg
3925c137a4 tweaks: make two error messages more succinct and easier to translate
"Cannot map name %s to <thing>..." was unnecessarily verbose and vague.
I have kept these strings unchanged all these years because I didn't
want to invalidate the existing translations.  But now it's time to
harmonize things and simply say "Unknown <thing>: %s" for an invalid
function name, menu name, option name, and syntax name.

("No such <thing>: %s" is nice and snappy, but its translations often
are clumsy and longer and unclear.)
2022-08-31 16:57:58 +02:00
Benno Schulenberg
97fa42c82b memory: avoid a leak when a string bind specifies an unknown menu
(It is a harmless leak, but LeakSanitizer is loud when it complains.)

After having determined that there is a menu name, first check that
it is valid, before processing the string or the function name.

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

Problem existed since version 2.9.4, since string binds were introduced.
2022-08-31 16:32:40 +02:00
Benno Schulenberg
ccabaac5a0 build: exclude two unneeded functions correctly from the tiny version
This also amends commit 4f9abb52 from yesterday -- I don't know how I
managed to overlook the warning.  :/
2022-08-29 12:31:39 +02:00
Benno Schulenberg
80f7852941 docs: describe --disable-formatter and --disable-linter configure options 2022-08-29 08:30:30 +02:00
Benno Schulenberg
6243831dfb build: add options --disable-formatter and --disable-linter to configure
This makes more sense than letting the formatter and the linter depend
on ENABLE_COLOR (which maybe should have been named ENABLE_SYNTAX).

This fulfills https://savannah.gnu.org/bugs/?50080.
2022-08-29 08:28:28 +02:00
Benno Schulenberg
4f9abb52a4 build: fix compilation when configured with --enable-tiny
Problem existed since commit d1e28417 from four days ago.
2022-08-28 14:56:44 +02:00
Benno Schulenberg
7bab8780ad tweaks: rewrap some lines, drop a redundant call, and reshuffle a line
Six years ago, commit a878f5f1 introduced a call of regenerate_screen()
directly in the input routine, which made the call of refresh_func() in
the prompt routine redundant -- except when in the file browser.
2022-08-28 09:03:09 +02:00
Benno Schulenberg
d0dc270eec tweaks: rename two record elements and three parameters, for clarity 2022-08-28 08:58:36 +02:00
Benno Schulenberg
cd9402075a tweaks: elide a variable, rename another, and reshuffle an assignment 2022-08-26 09:29:44 +02:00
Benno Schulenberg
b1f3bdfcbd extra: use the whole terminal for the crawl, and quicken it a bit
Since version 6.0, with option --zero, the edit window can cover
the whole terminal.  Make use of this also for the credits crawl.

Also, shorten and quicken the crawl a bit, and make it start always
on the bottom row, instead of (for mysterious reasons) one row higher
when the terminal has an odd number of rows.

Furthermore, don't put back the key the user typed to stop the crawl.
2022-08-26 09:17:17 +02:00
Benno Schulenberg
541a2dbc88 feedback: suppress undo/redo messages when option --zero is in effect
This fixes https://savannah.gnu.org/bugs/?62956.

Problem existed since version 6.0, since --zero was introduced.
2022-08-25 08:48:07 +02:00
Benno Schulenberg
d1e28417d5 tweaks: move to a given line number more efficiently
Instead of starting always from the top of the buffer, start at the
current line, as it is quite likely to be near the target line.

(Since the previous commit we're assuming that openfile->current is
always valid, so we might as well make use of this assumption.)

Also, rename a parameter to make its meaning more explicit.
2022-08-24 16:29:29 +02:00
Benno Schulenberg
9410a55679 undo: make sure the current line is defined before it is referenced
After undoing an <Enter> or redoing a line join, it is likely that the
"eaten" and freed line was the current line.  In fact, goto_line_posx()
should not refer to it any more, but... accommodate for this and just
set openfile->current to a valid value before calling goto_line_posx().

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

Bug existed since version 6.3, commit eea3e1f0.
2022-08-24 15:45:24 +02:00
Benno Schulenberg
25ceefbd89 prompt: ingest queued characters before handling any subsequent function
This fixes https://savannah.gnu.org/bugs/?62946.

Bug existed since commit 40a4225e from five days ago.
2022-08-24 09:28:14 +02:00
Benno Schulenberg
a37c4bb59e tweaks: reshuffle a line, to group things better 2022-08-23 15:40:27 +02:00
Benno Schulenberg
ee1f8a0494 prompt: return FALSE for non-editing functions also in the tiny version
This fixes https://savannah.gnu.org/bugs/?62942.

Bug existed since commit 2f25b6a6 from four days ago.
2022-08-23 15:32:30 +02:00
Benno Schulenberg
2c5459a1b7 tweaks: fold two cases together, because they basically do the same 2022-08-21 16:57:03 +02:00
Benno Schulenberg
b561c386c3 tweaks: discard a bracketed paste in the browser more efficiently 2022-08-21 10:45:49 +02:00
Benno Schulenberg
a374dd0359 prompt: toggle the help lines only for the 'nohelp' toggle
This fixes https://savannah.gnu.org/bugs/?62914.

Problem existed since commit 958ec294 from three days ago.
2022-08-21 10:22:38 +02:00
Benno Schulenberg
aba4f4e0e2 tweaks: avoid sometimes calling a function three times in a row 2022-08-21 09:59:55 +02:00
Benno Schulenberg
210c94d82f prompt: allow rebinding also ^N, ^Q, and ^Y at the yes-no prompt
Checking for the literal ^N, ^Q, and ^Y before checking for do_toggle
and full_refresh made it impossible to rebind any of those keystrokes
to these two functions.  (Not that anyone would want this, but...)

Problem existed since version 4.3, commits 341601e1 and 82aea04c.
2022-08-21 09:42:21 +02:00
Benno Schulenberg
c410ba4d42 tweaks: reshuffle two lines, for conciseness and in preparation 2022-08-21 09:28:07 +02:00
Benno Schulenberg
f3738fe164 tweaks: don't use a pointer when the value itself is all that is needed 2022-08-21 09:12:35 +02:00
Benno Schulenberg
04a08fe6a5 tweaks: rename a variable, away from an abbreviation 2022-08-21 09:02:32 +02:00
Benno Schulenberg
69d33ec170 tweaks: rewrap line, improve wording, and correct typo in old news item 2022-08-19 16:58:09 +02:00
Benno Schulenberg
40a4225ed8 tweaks: reshuffle some code, to not determine a shortcut twice
This addresses https://savannah.gnu.org/bugs/?62913.

Problem has existed since version 2.1.0, commit eb64314f.
2022-08-19 16:38:55 +02:00
Benno Schulenberg
801622ce19 tweaks: normalize the indentation after the previous change 2022-08-19 12:48:15 +02:00