Commit Graph

1642 Commits (9c9de85afb15f2bf2e6b031dced1d12af922856c)

Author SHA1 Message Date
Benno Schulenberg 6d916c6c4a tweaks: rewrap a comment and a line, and reshuffle a fragment of code 2019-12-29 14:13:27 +01:00
Benno Schulenberg 87542eeaf1 tweaks: move a function to before the one that calls it
And condense its logic.  And improve its comment.
2019-12-27 17:01:15 +01:00
Benno Schulenberg 29f2e3181a tweaks: rename a function and its parameter, to be more fitting
Also, avoid calling a case-changing function when it's not needed.
And elide a default case that can never occur (because the function
always gets called with one of the four letters).
2019-12-27 16:48:07 +01:00
Benno Schulenberg 8255696b45 tweaks: condense five more fragments of repetitious code 2019-12-27 13:49:03 +01:00
Benno Schulenberg fc00e89499 tweaks: comment fully, so that all handled escape sequences are findable
Also correct a few other comments.
2019-12-27 13:48:36 +01:00
Benno Schulenberg 55946c15e7 tweaks: reshuffle some lines, to group all ignored keystrokes together 2019-12-27 12:16:50 +01:00
Benno Schulenberg 2e539e2c97 tweaks: stop recognizing escape sequences for a key without meaning
Nano does not do anything for the keystroke anyway (KEY_B2, the center
key on the numeric keypad, gets translated to ERR later on), so there
is no point in recognizing some of its escape sequences -- let those
sequences result in "Unknown sequence" instead.
2019-12-27 12:13:40 +01:00
Benno Schulenberg 38c286c019 input: recognize the raw escape sequences for F13 to F16 on xterm too
For symmetry with Gnome Terminal, Konsole, and the Linux console.

This fixes https://savannah.gnu.org/bugs/?57482.
2019-12-26 17:07:51 +01:00
Benno Schulenberg 56d842258c tweaks: condense three fragments of repetitious code 2019-12-26 16:50:19 +01:00
Benno Schulenberg 8ed8ab69d5 tweaks: make a couple of comments more precise 2019-12-26 14:32:44 +01:00
Benno Schulenberg 4dcbd40c49 input: consume and ignore the raw escape sequences for F17 to F24
When --rawsequences is used, consume the full escape sequences for
the F17 to F24 function keys (on xterm-compatible terminals and on
the Linux console), to prevent them entering junk into the buffer.

This fixes https://savannah.gnu.org/bugs/?57483.
2019-12-26 14:02:17 +01:00
Benno Schulenberg 72645b160d input: correct the escape sequence for PageUp/PageDown on Eterm/Urxvt
There is not a single terminal in the terminfo database that has an
"Esc [ n ^" sequence for any keystroke (where n is a digit).
2019-12-26 12:23:08 +01:00
Benno Schulenberg 4991b3bb1a input: Ctrl+arrow is "Esc O x" on Eterm, as on rxvt -- not "Esc o x"
(Checked on Eterm-0.9.6 running on Xubuntu 18.04.)
2019-12-24 20:01:48 +01:00
Benno Schulenberg 9631e858f2 display: don't color the space that separates line numbers from text
Go back to how line numbers were colored in versions 2.7.1 to 4.3 --
coloring the space (when a background color is used) was unintented.

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

Bug existed since version 4.4, commit 699cacf7.
2019-12-16 19:23:08 +01:00
Benno Schulenberg a921bdadbf tweaks: remove a stray space
Reported-by: Brand Huntsman <alpha@qzx.com>
2019-12-05 11:23:47 +01:00
Benno Schulenberg 0271e4a187 input: make <Tab> indent only when mark and cursor are on different lines
It allows entering a TAB character at the cursor position while the
mark is on the same line as the cursor, as some users sometimes do.

This refines the feature that was added in version 2.9.2, and makes
it behave like in the Gedit and Kate editors, for example.

This addresses https://savannah.gnu.org/bugs/?57357.
Reported-by: Sébastien Desreux <seb@h-k.fr>
2019-12-04 17:29:40 +01:00
Benno Schulenberg e484918ef2 tweaks: reshuffle a few lines, for symmetry with the preceding function 2019-12-01 17:04:15 +01:00
Benno Schulenberg 9151abcd45 tweaks: avoid setting and resetting a variable when there is no need 2019-10-28 10:28:52 +01:00
Benno Schulenberg fa88fcc8f2 tweaks: rename a function, and elide a parameter that is always NULL
After the previous change, all remaining calls of parse_mbchar() have
NULL as their third parameter.  So, drop that parameter and remove the
chunk of code that handles it.  Also rename the function, as there are
already too many functions that start with "parse".
2019-10-21 12:35:14 +02:00
Benno Schulenberg c2d8641f01 chars: add a faster version of the character-parsing function
It elides a parameter that is always NULL, and elides two ifs
that always take the same path.
2019-10-21 12:24:23 +02:00
Benno Schulenberg f14be47878 tweaks: move two functions to after the one that they make use of 2019-10-15 11:23:09 +02:00
Benno Schulenberg 7f8851caa8 statusbar: show only the first error message, with dots to indicate more
The old default behavior of showing the first three messages with a
long pause after each of them was annoying, and the final "Further
messages were suppressed" hid the relevant information.  So, when
there is more than one error message, just pause very briefly and
then add trailing dots to the first message.

This makes the 'nopauses' option a no-op.

This addresses https://savannah.gnu.org/bugs/?57048.
2019-10-15 11:17:20 +02:00
Benno Schulenberg d256d0cbc0 tweaks: add a helper function without the ubiquitous NULL argument
For conciseness and clarity.
2019-10-13 12:24:27 +02:00
Benno Schulenberg 31ff7ead73 tweaks: move a function to before its callers and next to its kind
Also, improve the indentation of two random lines.
2019-10-03 11:24:01 +02:00
Benno Schulenberg b02dccc51f tweaks: elide a function from a non-UTF8 build
In a non-UTF8 build, mbwidth() returns always 1, so it is pointless
to call that function and compare its result to zero then.

Also, don't bother special-casing the function for a non-UTF8 locale.
2019-10-03 10:48:10 +02:00
Benno Schulenberg 9c202198a3 tweaks: simplify a calculation, as done elsewhere 2019-10-01 15:03:40 +02:00
Benno Schulenberg 78def852d1 mouse: make the clickable width of menu items more consistent
When there are fewer than four menu items, act as if there are four:
make their clickable width half the width of the screen.

Until now, when there were two menu items, their clickable width would
be the full width of the screen, which was overwide.  But when there
was just one menu item, its clickable width would suddenly be as small
as when the menu had the maximum number of items (12 for an 80-column
screen).  This was odd.

Also, slightly simplify another computation.
2019-10-01 12:46:31 +02:00
Benno Schulenberg 5103bfe6b8 bindings: add a dedicated keycode for <Tab> for when a region is marked
In this way the keycode cannot be unbound from the 'indent' function,
so pressing <Tab> on a marked region will always indent the region.

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

Bug existed since the "tabbing" of a marked region was introduced,
in version 2.9.2, commit 09958ebd.
2019-09-28 12:39:42 +02:00
Benno Schulenberg 43235c2f16 tweaks: rename a function, to be a bit more fitting 2019-09-27 19:07:25 +02:00
Benno Schulenberg cd00d0975e tweaks: move a fragment of common code into the appropriate function 2019-09-27 18:49:39 +02:00
Benno Schulenberg a9fb56a8c9 tweaks: move a function to a better file, to be amongst its kind 2019-09-27 17:43:28 +02:00
Benno Schulenberg 44d38815cc display: clear the remainder of a row only when there actually is some
Make display_string() report back (via a global variable) whether the
just converted string has room to spare within the allotted span, so
that draw_row() can avoid trying to clear the remainder when there is
nothing to clear.

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

Bug existed since commit 699cacf7 from three days ago.
2019-06-28 20:45:47 +02:00
Benno Schulenberg b23a5d5b29 tweaks: rewrap two lines, and reshuffle some logic to make more sense 2019-06-26 19:44:51 +02:00
Benno Schulenberg b96cc8c212 tweaks: rename a parameter in three functions, to say what it points to 2019-06-26 19:44:51 +02:00
Benno Schulenberg 09ad0eb5f7 tweaks: rename a function, to suit better, and reshuffle its parameters 2019-06-26 19:44:51 +02:00
Benno Schulenberg 62ca113ed3 tweaks: reword and condense two comments, and correct another 2019-06-26 19:07:08 +02:00
Benno Schulenberg 8cd6aa0a32 display: when linenumbering, correctly spotlight text that spans two rows
This fixes https://savannah.gnu.org/bugs/?56552.

Bug existed since line numbers were introduced, in version 2.7.1.
2019-06-26 11:24:44 +02:00
Benno Schulenberg fcbe41942f tweaks: reshuffle an assignment, and trim some excessive blank lines 2019-06-26 10:18:32 +02:00
Benno Schulenberg 39e5b52734 tweaks: call the correct lighting function directly when softwrapping 2019-06-26 10:12:23 +02:00
Benno Schulenberg 70b347183b tweaks: condense some comments, and drop two unneeded initializations 2019-06-26 09:47:07 +02:00
Benno Schulenberg 699cacf7a4 display: don't clear a row beforehand -- just clear the remainder
It is a waste of time to first fully clear a row when right afterward
text will be written to it (for most of the row, on average).  So...
just clear the part of the row after the written text.  Curses has the
perfect function for this: clrtoeol().
2019-06-25 12:09:28 +02:00
Benno Schulenberg 23cb26c58f tweaks: improve a handful of comments 2019-06-25 11:34:04 +02:00
Benno Schulenberg 5f1d9af375 tweaks: drop two parameters that are no longer needed 2019-06-25 11:13:35 +02:00
Benno Schulenberg f3a441043d display: where needed, use slow blanking, but elsewhere do it much faster
Where the row needs to be filled with spaces with the attributes that
were set (title bar, prompt bar, and browser highlight), use printw().
But when the row needs to be actually cleared, use the much faster
clrtoeol().

This reduces the time needed to clear a full row with 95 percent.
2019-06-25 11:12:27 +02:00
Benno Schulenberg e6c629951f display: use a somewhat faster method to clear a row
On an 80-column terminal, using a single printw() instead of
a loop of addch() reduces the time taken with 13 percent.
2019-06-23 20:49:01 +02:00
Benno Schulenberg c06d5452f5 tweaks: move a call from two different places to a single place 2019-06-23 19:57:15 +02:00
Benno Schulenberg d8c840692e tweaks: reshuffle an 'if' out of a function, and rename the function 2019-06-23 12:15:19 +02:00
Benno Schulenberg 0adb15c7a1 display: properly show all characters in a non-UTF-8 build
Also, don't use mblen() directly, to not get stuck when it returns -1,
which it will when running a non-UTF-8 build in a UTF-8 locale.

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

Bug existed since commit cd094822 from yesterday.
2019-06-11 19:07:34 +02:00
Benno Schulenberg 1e48df388e build: avoid a warning when using --disable-utf8 2019-06-11 14:24:30 +02:00
Benno Schulenberg d477775871 build: avoid a warning on FreeBSD, OpenBSD, and Alpine 2019-06-11 12:29:32 +02:00
Benno Schulenberg ed40fd8031 tweaks: reorder some code, to further optimize display_string() for ASCII
The majority of characters in the files that get edited with nano will
be single-byte printable ASCII characters, so their case should come
first in the main loop of display_string().
2019-06-11 12:08:28 +02:00
Benno Schulenberg 5c4b0b38f4 chars: redo the speedup for plain ASCII from three commits ago
It was lost in the elision of length_of_char() two commits ago.
2019-06-11 11:10:53 +02:00
Benno Schulenberg bd331b0198 tweaks: reshuffle some lines and frob some comments 2019-06-10 20:07:10 +02:00
Benno Schulenberg cd09482231 tweaks: elide a function that is an amalgam of three others
In addition, the function was used just once, had a weird return value,
and now some more code can be excluded from a non-UTF8 build.

Make use of the fact that any single-byte character always occupies
just one column, and call the costly mbtowc() and wcwidth() only for
characters that actually are multibyte.
2019-06-10 19:43:50 +02:00
Benno Schulenberg 967f581860 tweaks: adjust some whitespace and rewrap a few lines
And remove two unneeded casts.
2019-06-09 20:03:44 +02:00
Benno Schulenberg 1075de1222 tweaks: rename two functions, to get rid of the "mb" abbreviation
Also, for me "move" is about moving the cursor.  But these functions
are about moving an index in a text, which is more general.
2019-06-09 19:37:56 +02:00
Benno Schulenberg 781c7a7a5f chars: create a dedicated function for getting the length of a character
Instead of calling in twenty places parse_mbchar(pointer, NULL, NULL),
use a simpler and faster char_length(pointer).  This saves pushing two
unneeded parameters onto the stack, avoids two needless ifs, and elides
an intermediate variable.

Its main purpose will follow in a later commit: to speed up searching.
2019-06-09 18:38:46 +02:00
Benno Schulenberg ea1016efdb feedback: make an error check work also when curses hasn't started yet
Add a temporary boolean for this, because isendwin() returns TRUE
only when curses mode has actually been started with initscr() and
then exited with endwin().
2019-06-03 13:38:21 +02:00
Benno Schulenberg c5d157dd9d tweaks: close a buffer differently and elide a parameter 2019-05-31 09:15:12 +02:00
Benno Schulenberg 5a48edc9ae tweaks: reshuffle some code to the one place that needs it
The extra things that close_buffer() did are only needed and useful
when manually closing a buffer, so move them there.  The other three
calls of close_buffer() only need to get rid of the current buffer
(making the preceding buffer the new current one) and nothing else.
2019-05-30 17:09:49 +02:00
Benno Schulenberg 5f03c20ea0 tweaks: switch to the preceding buffer in a cheaper way (when in help)
When a help-text buffer is closed while exiting from the help viewer,
the rest of the exit code takes care that the preceding buffer gets
displayed properly.  And when a help-text buffer is closed because a
SIGWINCH occurred, doing anything for the preceding buffer is a waste
of time because a new help-text buffer will be opened and displayed
instantly.
2019-05-29 19:48:42 +02:00
Benno Schulenberg 71574e7a6f tweaks: reshuffle some closing and switching to a better place
And rename the function and elide a parameter besides.
2019-05-29 19:48:42 +02:00
Benno Schulenberg 57390cff04 tweaks: exclude another bug check from the tiny version 2019-05-29 11:24:25 +02:00
Benno Schulenberg 47770bd321 feedback: treat statusline() being called outside of curses mode as a bug 2019-05-28 17:19:34 +02:00
Benno Schulenberg 37eccd3117 tweaks: rename a function, to be more fitting
Also, adjust some whitespace, for esthetics.
2019-04-28 11:01:51 +02:00
Benno Schulenberg 0b6889cbd8 tweaks: rename another function, to be distinct and fitting 2019-04-24 10:52:49 +02:00
Benno Schulenberg 00410d83fc tweaks: rename a function, to be distinct and fitting
It was hard to remember that the "pt" stood for "plus tabs", and the
"len" seemed to say it was about number of bytes instead of columns.
2019-04-24 10:52:35 +02:00
Benno Schulenberg 11aa191bdc tweaks: rename a variable, to distinguish it from a browser function 2019-04-22 19:58:43 +02:00
Benno Schulenberg c039aaad9d tweaks: remove several unneeded bad-state checks and their messages
No one ever reported seeing any of them, and each of these checks
has been there for at least a year.
2019-04-14 19:38:04 +02:00
Benno Schulenberg c0e3779453 display: report and catch a bad state, to prevent a possible hang 2019-04-12 19:18:21 +02:00
Benno Schulenberg bf6bcde078 tweaks: initialize a boolean before it is referenced [valgrind]
Found because of a report by Devin Hussey <husseydevin@gmail.com>.
2019-04-12 13:37:54 +02:00
Benno Schulenberg 671db5e1e3 tweaks: rename an overshort type to something that makes some sense 2019-04-03 17:34:05 +02:00
Benno Schulenberg acfee2538e tweaks: rename a cryptic type to something that makes a little sense 2019-04-03 17:11:24 +02:00
Benno Schulenberg b58418b32f tweaks: rename a variable, to be more distinct 2019-03-21 19:21:45 +01:00
Benno Schulenberg cddfcb1b9d tweaks: rename a struct element, to make sense 2019-03-21 17:23:49 +01:00
Benno Schulenberg aac4fc46e9 tweaks: rename a type, to make more sense 2019-03-21 17:08:52 +01:00
Benno Schulenberg 513d2ae905 build: fix compilation when configured with --disable-utf8 2019-03-15 16:41:02 +01:00
Benno Schulenberg 47f3dc75d8 display: use non-breaking space instead of dot for VTE-bug workaround
When UTF-8 is available, it is better to use a character that displays
as a space.

This improves the fix for https://savannah.gnu.org/bugs/?55896.
2019-03-15 14:58:37 +01:00
Benno Schulenberg 5f529a48e6 tweaks: don't bother trying to draw characters beyond the screen's edge 2019-03-15 14:04:23 +01:00
Benno Schulenberg d9faac618d display: dot the stripe when it's in the last column, to defeat a VTE bug
This addresses https://savannah.gnu.org/bugs/?55896.
2019-03-15 13:49:12 +01:00
David Lawrence Ramsey 93ee0a8a65 display: show the guide stripe for double-width/multi-byte characters
Determine the actual number of bytes the striped character consists of,
instead of assuming it's simply one, and determine the real column that
the character starts in, instead of assuming it's the stripe column.

This fixes https://savannah.gnu.org/bugs/?55917
and fixes https://savannah.gnu.org/bugs/?55922.

Condensed-by: Benno Schulenberg <bensberg@telfort.nl>
2019-03-15 13:29:11 +01:00
Benno Schulenberg 15959346fb tweaks: exclude the guide-stripe code from the tiny version
The option is not available, so including the code is pointless.
2019-03-14 19:34:35 +01:00
Benno Schulenberg 902b4674f9 display: account for horizontal scrolling when drawing the guide stripe
That is, draw the stripe relative to the column at which the current
"chunk" starts.

This fixes https://savannah.gnu.org/bugs/?55920.
2019-03-14 17:01:48 +01:00
Benno Schulenberg a20340b5a8 copyright: update the years for significantly changed files 2019-03-10 17:03:42 +01:00
Benno Schulenberg 916b4d81d0 rcfile: add 'stripecolor' for changing the color of the guiding stripe
The default is now simply reverse video, which works better than a
"loud" colored bar in an interface that for the rest is monochrome.
2019-03-09 09:27:08 +01:00
Benno Schulenberg 66c6eb5166 new feature: option --guidestripe that shows a vertical guiding bar
Option -J (--guidestripe) takes a column number as argument and then
shows a vertical, colored bar over the entire height of the buffer,
to aid the user in regulating the width of the text when the terminal
is wider than this desired width.

This fulfills https://bugs.debian.org/916392.
Requested-by: Arturo Borrero González <arturo@debian.org>
And fulfills https://savannah.gnu.org/bugs/?55315.
Requested-by: Bryan Christ <bryan.christ@gmail.com>
2019-03-09 09:27:08 +01:00
David Lawrence Ramsey 43b42246d3 display: properly handle double-width characters when spotlighting
When the right half of a two-column character gets overwritten by the
">" continuation character, then represent its left half as "[" also
when spotlighting a replacement candidate.  Achieve this by calling
display_string() in the overshooting case with 'isprompt' set to TRUE,
which also makes this function reserve space for the ">" continuation
character so spotlight() doesn't need to do this any more.

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

Improved-by: Benno Schulenberg <bensberg@telfort.nl>
2019-03-08 19:56:52 +01:00
David Lawrence Ramsey 40a74e46e6 display: correct the logic for making room for the ">" character
The change in commit edc0d628 was flawed.  The old logic covered
every case but one: having reached the end of 'buf' but 'column'
still having overshot the screen width.  Now cover this latter
case too.

This fixes https://savannah.gnu.org/bugs/?55638 properly,
allowing the next commit to fix another buglet.

Condensed-by: Benno Schulenberg <bensberg@telfort.nl>
2019-03-08 19:52:33 +01:00
David Lawrence Ramsey f13dd140eb display: correctly trim an overshooting character from a prompt answer
Tell display_string() explicitly when we're at a prompt, instead of
letting it glean this from the current menu not being MMAIN, which
fails in some circumstances.

This improves the fix for https://savannah.gnu.org/bugs/?55620,
fixes https://savannah.gnu.org/bugs/?55680 in a better way,
and fixes https://savannah.gnu.org/bugs/?55773.
2019-02-28 19:47:55 +01:00
Benno Schulenberg 1eb639d55e display: show "[" for half of two-column character also when softwrapping
This should have been part of commit ad505e7f.
2019-02-24 21:45:53 +01:00
Benno Schulenberg 79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg 7c30d1fa69 display: account for zero-width characters when reserving space for '>'
That is: keep nibbling off characters until a character is eaten that
takes up at least one column.

This fixes https://savannah.gnu.org/bugs/?55759.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>

Bug existed since version 2.8.0, commit 5283acdc.
2019-02-24 11:28:52 +01:00
Benno Schulenberg 82492ead47 tweaks: rename two variables, to be less confusing 2019-02-20 16:43:03 +01:00
Benno Schulenberg 420fe4d1e6 tweaks: switch from checking MORE_SPACE to checking EMPTY_LINE 2019-02-19 19:53:19 +01:00
Benno Schulenberg 322a6f46fa tweaks: switch from checking SMOOTH_SCROLL to checking JUMPY_SCROLLING 2019-02-19 19:52:57 +01:00
Benno Schulenberg 252bb60036 display: highlight the ">"/"<" continuation characters in reverse video
To make it obvious that they are not actual characters in the file.

The default highlighting is in reverse video, but this can be changed
to bold by using --bold or 'set boldtext'.

This fulfills https://savannah.gnu.org/bugs/?55571.
2019-02-15 17:15:28 +01:00
Benno Schulenberg 6d34b8a5cd display: change the "$" continuation character to ">" and "<"
The angular brackets look a bit like arrows and thus hint much more
at the idea of continuation than a dollar sign.

With-help-from: David Lawrence Ramsey <pooka109@gmail.com>
2019-02-15 17:12:57 +01:00
Benno Schulenberg ad505e7fff display: represent half of a double-width character with "[" and "]"
When the screen's edge leaves just one column for a two-column
character, then show its left half as "[" and its right half as "]".

(They used to be shown as ">" and "<", but these characters will be
repurposed in the next commit.)

This addresses https://savannah.gnu.org/bugs/?55657.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2019-02-15 17:12:34 +01:00
Benno Schulenberg 5618189643 prompt: trim a double-width character at the screen's edge
It needs to be trimmed and substituted with a single-width placeholder
to prevent the continuation character ">" from getting pushed to the
next row.

Also, use the correct width for the answer so that the continuation
character is only displayed when the answer does not fit any more.

This fixes https://savannah.gnu.org/bugs/?55620.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>

Original-patch-by: David Lawrence Ramsey <pooka109@gmail.com>
2019-02-07 20:04:56 +01:00
David Lawrence Ramsey edc0d6280a display: properly trim double-width characters at the edit window's edge
When a line ends with a two-column character, and this character straddles
the edit window's edge, then, although we've reached the end of 'buf', we
have exceeded the 'beyond' column and this two-column character needs to
be trimmed from the 'converted' string, otherwise it would get printed on
the next row.

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

Bug existed since version 2.8.0, commit 5283acdc.
2019-02-06 10:09:55 +01:00
David Lawrence Ramsey e771503ee5 tweaks: adjust indentation after the previous commit 2019-01-15 19:47:11 +01:00
David Lawrence Ramsey 194d18586c input: properly handle <Escape>s followed by a shifted Meta+letter
After a series of escapes, also <Shift+Meta+letter> should be recognized
as a command keystroke, not just <Meta+letter>.

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

Bug existed since the ignoring of <Escape>s before a valid command
keystroke was introduced in version 3.0, commit ecc9211a.
2019-01-15 19:41:48 +01:00
Benno Schulenberg 15320d3b96 tweaks: word some comments more concisely 2018-12-30 21:30:26 +01:00
Benno Schulenberg 0e9fb6a0da tweaks: rename two variables, to be more descriptive 2018-12-30 20:18:29 +01:00
Benno Schulenberg fb4ce71cfc tweaks: correct a comment typo, and trim a few other comments 2018-12-30 18:00:28 +01:00
Benno Schulenberg 7a2c851dfc tweaks: reorder some ifs, to reduce the average number of comparisons 2018-12-30 17:50:10 +01:00
Benno Schulenberg 4d55748999 tweaks: reduce a bunch of repetitious comments to their essence
And in the bargain add two missing equivalences.
2018-12-30 17:31:36 +01:00
Benno Schulenberg e7198f49a4 tweaks: elide an unneeded intermediate variable 2018-12-30 16:48:48 +01:00
Benno Schulenberg 997826d794 tweaks: rename a symbol, to match its corresponding option 2018-12-28 17:47:03 +01:00
Benno Schulenberg 0946153b47 tweaks: hard-bind ASCII DEL in a slightly more economical way
And in the bargain get rid of a duplicate help-text entry for
either "Del" or "Bsp".
2018-12-28 17:20:18 +01:00
Benno Schulenberg 9b2c2697cb options: make -d (--rebinddelete) work without -K (--rebindkeypad)
When the terminfo selected by TERM does not match the terminal and
the <Delete> key behaves the same as <Backspace> (deleting leftward)
or the <Backspace> key behaves the same as <Delete> (deleting without
moving the cursor), then using just -d or --rebinddelete should make
the deviant key behave correctly again without affecting the other.
2018-12-28 17:19:09 +01:00
Benno Schulenberg 55537dc218 display: show it in title bar when starting up in restricted mode 2018-12-03 12:33:00 +01:00
David Lawrence Ramsey 5474a9f34b input: properly consume a modified Delete key also in the tiny version
This fixes https://savannah.gnu.org/bugs/?54981.

Bug existed since commit fb8d981b from a month ago.
2018-11-08 18:12:39 +01:00
Benno Schulenberg e938c24d04 tweaks: renumber a couple of symbols, and reshuffle a bit of code
Also, contract the regex for key strings.
2018-11-07 19:30:04 +01:00
David Lawrence Ramsey f55a3fabef input: recognize some escape sequences for <Shift+Delete>
Also, hard-bind <Shift+Delete> in the same way as <Backspace>.

This fixes https://savannah.gnu.org/bugs/?54948,
and fixes https://savannah.gnu.org/bugs/?54975.
2018-11-07 19:17:16 +01:00
Benno Schulenberg 7ee07af081 tweaks: reshuffle a couple of conditions, to group things better 2018-11-06 20:56:16 +01:00
Benno Schulenberg 15ec0eb3ee bindings: make <Alt+Up> and <Alt+Down> work also on a Linux console
This fixes https://savannah.gnu.org/bugs/?54964.
2018-11-06 20:55:09 +01:00
Benno Schulenberg 7dad21f4f4 tweaks: don't bother asking ncurses for keycodes for shifted Left/Right
These modified keys have codes by default: KEY_SLEFT and KEY_SRIGHT.
It's just the shifted Up/Down keys that don't have default codes.
2018-11-06 19:18:54 +01:00
Benno Schulenberg 9923b073af tweaks: include an extra function call only where it is needed
And fix a typo.
2018-11-05 10:21:17 +01:00
Benno Schulenberg 9d9ae8dc76 tweaks: add two more translator hints 2018-11-05 09:54:06 +01:00
Benno Schulenberg 77826c2b06 tweaks: stop setting and requiring the Meta flag for special keycodes
Set the Meta flag only for the regular Meta keystrokes: "M-" plus a
printable ASCII character.  The special keycodes are unique and do
not need any extra flags to differentiate them.
2018-11-04 20:35:15 +01:00
Benno Schulenberg 89760cd6ec tweaks: reshuffle some conditions, putting the least likely one first 2018-11-04 20:34:50 +01:00
David Lawrence Ramsey f02e2d3b6e input: properly recognize Alt+Delete when using -K/--rebindkeypad
This works for xterm, rxvt, Eterm, Konsole, and xfce4-terminal, which
generate "Esc [ 3 ; 3 ~", but not for urxvt, which generates one of
its double-escape sequences, "Esc Esc [ 3 ~".
2018-11-04 11:47:09 +01:00
Brand Huntsman 252f14796e bindings: hard-bind the zap function to M-Del (Alt+Delete)
So that the function is available in a default setup.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-11-04 11:47:03 +01:00
Benno Schulenberg 518a2b4c45 tweaks: remove some old debugging code 2018-10-24 17:41:32 +02:00
Benno Schulenberg b7f53096fb display: use a different color when showing a linting message
This is a second step to address https://savannah.gnu.org/bugs/?54714.
2018-10-23 19:31:40 +02:00
Benno Schulenberg f7f7767e7d display: let the title bar show when nano is in linting mode
This is a first step to address https://savannah.gnu.org/bugs/?54714.
2018-10-23 19:30:22 +02:00
Brand Huntsman d342cbbff8 display: make all dying messages end in a newline
So that the following shell prompt will not be glued onto the message
but will be on a line by itself.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-10-21 17:27:58 +02:00
David Lawrence Ramsey 6ed0a12d80 tweaks: join two lines, and add a clarifying comment 2018-10-16 19:18:58 +02:00
David Lawrence Ramsey dda9d4e357 input: don't detect <Ctrl+Shift+Delete> on Linux console in tiny version 2018-10-16 19:15:33 +02:00
David Lawrence Ramsey 53865ced9d weeding: remove the 'active' parameter from spotlight()
After the previous change, it is always TRUE and thus pointless.
2018-10-09 20:03:52 +02:00
David Lawrence Ramsey c2e4f77594 display: do spotlighting as part of drawing the screen
When something is spotlighted, it should survive a refresh of
the screen and an excursion to a help text, so the spotlight
should get painted whenever the edit window is drawn.

This fully fixes https://savannah.gnu.org/bugs/?54721.
2018-10-09 20:03:47 +02:00
Benno Schulenberg 826be439db bindings: make the Shift+arrow keys work by default on more terminals
Ask ncurses for the codes for the Shift+arrow keys, so that also
<Shift+Up> and <Shift+Down> can be recognized, for which ncurses
doesn't have standard codes.

This fixes https://savannah.gnu.org/bugs/?54790.
Reported-by: Javier Valencia <javiervalencia80@gmail.com>
2018-10-07 10:17:10 +02:00
Benno Schulenberg 8bffc8ea53 tweaks: add a comment, and correct an indentation 2018-10-05 20:32:02 +02:00
Benno Schulenberg fb8d981bfa tweaks: exclude word-deletion keystrokes from the tiny version
Because word deletion is not available there.
2018-10-05 19:24:38 +02:00
Benno Schulenberg 0b63de335e tweaks: elide a wrapper function that is no longer useful 2018-09-28 20:09:12 +02:00
Benno Schulenberg 628eef28b3 bindings: make the linter separately accessible, through M-B by default
This allows running the speller (default binding: ^T) also on files for
which a linter has been defined.  This makes it possible to spell check
comment blocks in source files, for example.

This fulfills https://savannah.gnu.org/bugs/?54711.
Requested-by: Mike Frysinger <vapier@gentoo.org>
2018-09-28 20:08:59 +02:00
Benno Schulenberg 600295a3af bindings: when implanting a string, make sure to use positive values
This fixes https://savannah.gnu.org/bugs/?54712.
2018-09-28 19:51:53 +02:00
Benno Schulenberg e998814bbc help: show the keystroke <Ctrl+Shift+Delete> as "Sh-^Del"
And in the bargain always return a fixed code instead of searching for
a keystroke that is bound to 'cutwordleft' (which might fail).
2018-09-23 19:57:04 +02:00
Benno Schulenberg fe6cb6e516 bindings: recognize <Ctrl+Shift+Delete> also on a Linux console
This fixes https://savannah.gnu.org/bugs/?54716.
2018-09-23 19:43:27 +02:00
Benno Schulenberg 65e4784eec bindings: bind ASCII DEL during startup instead of repeatedly at runtime 2018-09-18 19:14:05 +02:00
Benno Schulenberg 4e7b92ed4c tweaks: sharpen an optimization, to allow DEL to be a shortcut 2018-09-16 19:21:27 +02:00
Benno Schulenberg b84d7bf7a5 input: keep the cursor in edit window after message, also on NetBSD
This fixes https://savannah.gnu.org/bugs/?54632.
2018-09-12 15:22:53 +02:00
Benno Schulenberg 6840205e84 tweaks: remove a superfluous comment and a redundant assignment 2018-09-12 15:07:44 +02:00
Benno Schulenberg 3c5e5d4b6f input: recognize the sequences for Ctrl+Shift+Delete on xterm and urxvt
This fixes https://savannah.gnu.org/bugs/?54648.
2018-09-12 15:04:59 +02:00
Benno Schulenberg c7affe17c0 build: fix compilation again when configured with --enable-tiny 2018-09-08 12:24:12 +02:00
Benno Schulenberg e6429e782a bindings: hard-bind <Ctrl+Shift+Delete> to 'cutwordleft'
On FreeBSD and NetBSD (when reached through ssh from a Linux machine)
this has the absurd effect of making <Ctrl+Backspace> do a 'cutwordleft'
by default, out of the box, without needing any rebindings.  Weird, but
wonderful, because the ideal behavior.

Also ensure that <Shift+Delete> always does a Backspace.

This makes that we have the following set of "congruent" keys:

  <Tab> moves text to the right,
  <Shift+Tab> moves text to the left,
  <Delete> "eats" a character to the right,
  <Shift+Delete> "eats" a character to the left,
  <Ctrl+Delete> "eats" a word to the right,
  <Shift+Ctrl+Delete> "eats" a word to the left.
2018-09-07 19:31:38 +02:00
Brand Huntsman 6e80772311 tweaks: correct four spaces of indentation to a tab, in two places
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-08-29 18:01:21 +02:00
Brand Huntsman 25e9877607 statusbar: elevate three messages to an ALERT, to make them more visible
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-08-28 20:02:59 +02:00
Benno Schulenberg 975b491235 dropping a feature: remove the ability to use the 'formatter' command
Since the last version, the user can filter an entire buffer through
an external command.  This external command can also be a formatting
program, so there is no longer any need for this specific and special
formatter command.
2018-08-09 20:29:30 +02:00
Marco Diego Aurélio Mesquita a67f6c6031 input: erase the next word when Ctrl is held while pressing Delete
Bind the until-now unbound function 'cutwordright' to <Ctrl+Delete>.
The complementary function, 'cutwordleft', is not bound by default
because on many terminals the keystroke <Ctrl+Backspace> generates
^H -- the canonical ASCII backspace character.  We cannot change the
existing action of ^H without upsetting some users.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-07-22 19:27:50 +02:00
Benno Schulenberg 46f5d51fb5 input: fully consume modified PgUp and PgDn keys also in the tiny version
They should not enter a digit plus a squiggle into the buffer.
2018-07-17 18:28:55 +02:00
Benno Schulenberg b99ec28a60 tweaks: recognize escape sequences of modified Ins/Del more precisely
The third character after the escape must be a semicolon.
2018-07-16 18:45:41 +02:00
Benno Schulenberg b2acffe5be input: stop <Alt+Insert> from entering "3~" into the buffer 2018-07-16 18:45:21 +02:00
Benno Schulenberg 2fef7f647d input: stop a modified Delete key from entering stuff into the buffer
When using option -K on an xterm-like terminal, pressing <Shift+Del>,
<Alt+Del>, or <Ctrl+Del> would enter "2~", "3~", or "5~", respectively,
into the buffer.  Now it will just report an "Unknown sequence".
2018-07-15 09:22:55 +02:00
Benno Schulenberg 89c0e7493f tweaks: don't call va_start() without calling va_end() [coverity scan] 2018-07-14 21:15:23 +02:00
Benno Schulenberg ecc9211afc input: ignore any <Escape>s before a valid command keystroke
Just like an <Esc> before a Ctrl+letter keystroke is ignored, an <Esc>
before an Alt+letter keystroke should be ignored too -- it should not
be interpreted as if the user had typed <Esc> <Esc> letter.

This fixes https://savannah.gnu.org/bugs/?54301.
2018-07-13 09:27:38 +02:00
Benno Schulenberg ab0897072a input: consume the whole escape sequence for modified PgUp and PgDn keys
Even when we don't act on most of these combinations, at least eat up
the whole sequence so the unknown keystroke doesn't enter things like
"3~" into the buffer.

This fixes https://savannah.gnu.org/bugs/?54291.
2018-07-13 09:25:01 +02:00
David Lawrence Ramsey fce54a724d tweaks: fix some grammar plus a typo in the comments 2018-05-27 20:19:46 +02:00
Benno Schulenberg 455899fe27 credits: sort the names roughly according to amount of influence
And spell-fix a name.
2018-05-16 12:05:40 +02:00
Benno Schulenberg 87283711ee tweaks: improve a couple of comments 2018-05-10 18:10:23 +02:00
Benno Schulenberg 0da554e6d7 startup: suggest using ^D to finish reading from standard input
Also, add a period after the "Read nn lines" message, and
don't let the next shell prompt overwrite this message.

This addresses https://savannah.gnu.org/bugs/?53779.
2018-05-01 11:15:19 +02:00
Benno Schulenberg d4304ca88c search: use a better value to mean "nothing was typed"
When the keyboard buffer is empty, return a value that is not equivalent
to <Ctrl+Space>, so that typing a bunch of these while searching is going
on will not result in some of them getting executed afterward.
2018-04-13 20:13:05 +02:00
Benno Schulenberg bf1a080923 build: exclude more things when configured with --disable-multibuffer
This will make the tiny version slightly smaller.
2018-03-23 11:09:37 +01:00
Benno Schulenberg 1ebb1da382 tweaks: elide a parameter that is always 1
And adjust the comments accordingly.
2018-03-10 12:43:33 +01:00
Benno Schulenberg 5eccaa7633 tweaks: refactor the implanting of a key expansion 2018-02-27 13:34:32 +01:00
Benno Schulenberg ffebd31cbb tweaks: shorten the name of two record elements
Exclude the confusing, pleonastic 'sc' abbreviation from their names.
2018-02-24 19:31:11 +01:00
Benno Schulenberg b027263a37 small addition: allow customizing the color of an error message
The new option 'set errorcolor' allows the user to specify the color
combination for the status bar when an error message is displayed.
2018-02-23 12:35:17 +01:00
Benno Schulenberg a083d7f1e1 tweaks: rename a variable to be more distinct and greppable 2018-02-04 18:25:10 +01:00
Benno Schulenberg 58ed3a8152 display: wipe the status bar when doing a total refresh
This fixes https://savannah.gnu.org/bugs/?52997.
2018-01-28 21:08:28 +01:00
Benno Schulenberg e11021a7a5 input: recognize the deviant keycode for <Ctrl+End> in urxvt
This fixes https://savannah.gnu.org/bugs/?52972.
Reported-by: Brand Huntsman <alpha@qzx.com>
2018-01-28 16:15:21 +01:00
Benno Schulenberg 83c264939b tweaks: move a bunch of comments to the lines that they refer to 2018-01-28 13:41:46 +01:00
Benno Schulenberg b18e76d4d8 tweaks: drop two unneeded initializations, and trim a comment 2018-01-27 20:26:15 +01:00
Benno Schulenberg f5c87a7fee tweaks: swap the row and col parameters to a more consistent order 2018-01-27 20:00:14 +01:00
Benno Schulenberg 18bf2af9c1 tweaks: rename a function, to be more distinct
So one doesn't find it when grepping for get_input().
2018-01-27 11:29:11 +01:00
Benno Schulenberg f72fecee9b copyright: update the years for the FSF
And one for me, for the much changed keyboard stuff.
2018-01-24 10:14:43 +01:00
Benno Schulenberg fa7e9b11df input: recognize more escape sequences for <Shift+Home> and <Shift+End>
This fixes the second part of https://savannah.gnu.org/bugs/?52960.
2018-01-23 19:44:18 +01:00
Benno Schulenberg 838b175d4f input: recognize escape sequences for <Shift+PageUp> and <Shift+PageDown>
This fixes the first part of https://savannah.gnu.org/bugs/?52960.
2018-01-23 19:32:13 +01:00
Benno Schulenberg 6795d079b1 tweaks: mark the two blocks that have a deviant indentation
Also, reshuffle a case, to put the short one first and lose a line.
2018-01-23 18:10:22 +01:00
Benno Schulenberg e739448cd0 input: consume only the actual length of an escape sequence
Instead of assuming that the entire contents of the keybuffer are an
escape sequence (even if this is far longer than any escape sequence
can be), remove from the keybuffer only those integers that actually
constituted a sequence, valid or invalid.

This fixes https://savannah.gnu.org/bugs/?48659.
2018-01-23 17:31:48 +01:00
Benno Schulenberg 8e328e43c2 input: make <Shift+Tab> do an unindent also on a Manjaro console
This fixes https://savannah.gnu.org/bugs/?52943.
2018-01-23 16:52:51 +01:00
Benno Schulenberg 4ad0490ce4 tweaks: rename a variable, for more contrast 2018-01-20 18:22:24 +01:00
Benno Schulenberg 96b47f2877 tweaks: transform a parameter, from a pointer to the value itself 2018-01-15 20:09:03 +01:00
Benno Schulenberg 7da391beb7 tweaks: drop a superfluous parameter, as it is always 1 2018-01-15 19:54:12 +01:00
Benno Schulenberg 90cf4838d2 tweaks: don't bother to reallocate when the keybuffer size decreases
It will be reallocated soon enough when the size increases again.
2018-01-15 19:46:16 +01:00
Benno Schulenberg caeed6821c tweaks: reshuffle two condition series, to look better 2018-01-11 13:02:55 +01:00
Benno Schulenberg eb1bf8f927 tweaks: rename a variable, and further condense some comments 2018-01-11 12:52:14 +01:00
Benno Schulenberg 2c8b99d5e9 tweaks: condense and rewrap some comments, and reindent two lines
Also drop an old debugging fragment.
2018-01-11 10:51:18 +01:00
Benno Schulenberg 091dd71f08 tweaks: remove a superfluous case -- there can never be four digits 2018-01-11 10:31:23 +01:00
Benno Schulenberg 837475519b input: fully reset state when a three-digit character code is cut short
There shouldn't be two separate variables (but with the same name) that
count the number of digits seen.  Fuse them into a single static var.

This fixes https://savannah.gnu.org/bugs/?52863.
2018-01-11 10:17:51 +01:00
Benno Schulenberg 31540e3e7e tweaks: remove a superfluous check, as we insert always one code 2018-01-10 21:32:32 +01:00
Benno Schulenberg ae3b8579fa tweaks: condense a condition and a comment, and reshuffle a line 2018-01-10 21:25:19 +01:00
Benno Schulenberg e1199cd94d tweaks: elide a tiny intermediate buffer, and rename two variables
Use the same method as in parse_verbatim_kbinput() for Unicode input.
2018-01-10 20:33:12 +01:00
Benno Schulenberg 45d2458b47 tweaks: don't bother freeing the key buffer, just reallocate it 2018-01-10 19:25:23 +01:00
Benno Schulenberg 4c505e5127 tweaks: rename a function, for aptness, and drop a superfluous check 2018-01-10 17:40:07 +01:00
Benno Schulenberg 0bb6c0234f tweaks: condense the conditional compilation of shortcut reassignments
These three functions are needed only when both linter and speller
are available.
2018-01-09 13:31:58 +01:00
Benno Schulenberg 17429d7f38 tweaks: fix some whitespace errors, and convert alignment tabs to spaces 2017-12-29 21:35:14 +01:00
Benno Schulenberg 87206c0607 tweaks: convert the indentation to use only tabs
Each leading tab is converted to two tabs, and any leading four spaces
is converted to one tab.  The intended tab size (for keeping most lines
within 80 columns) is now four.
2017-12-29 20:06:50 +01:00
Benno Schulenberg b574f73e60 tweaks: add a separate function that actually wipes the status bar 2017-12-29 17:40:41 +01:00
Benno Schulenberg 12073001c2 tweaks: condense, reword, and rewrap a bunch of comments 2017-12-26 22:14:25 +01:00
David Lawrence Ramsey 62ebd93579 tweaks: use printf's z modifier for (s)size_t, instead of casting 2017-12-26 14:11:18 +01:00
Benno Schulenberg 7ad5afb935 tweaks: remove some unneeded parentheses, and shorten two function calls 2017-12-17 20:32:17 +01:00
Benno Schulenberg e1b0f2b275 display: ensure that cursor is visible when compiled with --with-slang
This fixes https://savannah.gnu.org/bugs/?52651.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-12-17 16:34:02 +01:00
Benno Schulenberg 0e0fb452a3 input: optimize a bit for non-shortcut keys, as they are most frequent 2017-12-17 12:49:04 +01:00
David Lawrence Ramsey f66432e999 input: support backtab when Slang and/or --rebindkeypad is used
The escape sequence "Esc [ Z" is a backtab on most supported terminals,
so make sure convert_sequence() treats it as such.
2017-12-17 12:11:35 +01:00
Benno Schulenberg 08e9d30fa2 tweaks: condense some debugging code, and rewrap a line 2017-12-16 21:50:10 +01:00
Benno Schulenberg 031305c205 tweaks: strip some debugging stuff, and condense a bit of code 2017-12-16 19:56:15 +01:00
Benno Schulenberg 09958ebdff input: allow using <Tab> and <Shift+Tab> to (un)indent selected region
When the mark is on, instead of letting a <Tab> simply insert a Tab
character at the cursor position, let it indent the marked region.

Original-idea-by: Chris Allegretta <chrisa@asty.org>
2017-12-12 20:37:41 +01:00
Benno Schulenberg a95c6c5fe8 tweaks: condense or rewrap a bunch of repetitious comments 2017-12-11 20:02:43 +01:00
Benno Schulenberg c24e95e3d6 tweaks: elide the 'mark_set' boolean -- the 'mark' pointer is enough
The pointer not being NULL is enough indication that the mark is set.

Also, rename the pointer from 'mark_begin' to simply 'mark', since
the former is kind of pleonastic.
2017-11-21 21:14:33 +01:00
Benno Schulenberg 2b438e6ef4 input: make the macro key discoverable by giving feedback when undefined 2017-11-20 19:57:33 +01:00
Benno Schulenberg 5239e7c52b copyright: update some years, and standardize on the dashed format 2017-11-12 10:46:20 +01:00
Benno Schulenberg 0c2b54a276 tweaks: rename a function plus two parameters, to be more fitting 2017-11-11 20:58:56 +01:00
David Lawrence Ramsey 477b246771 tweaks: use printf's z modifier for most of the size_t/ssize_t types
Also, properly refer to numreplaced as signed, since it's ssize_t
(even though it's only shown when positive).
2017-11-07 17:55:21 +01:00
Benno Schulenberg d054044d30 tweaks: transform the token DISABLE_EXTRA to ENABLE_EXTRA 2017-11-01 20:33:14 +01:00
Benno Schulenberg d5ac1ed395 tweaks: transform the token DISABLE_COLOR to ENABLE_COLOR 2017-11-01 19:45:50 +01:00
Benno Schulenberg c4d2a92d4c tweaks: reshuffle some code in order to elide a variable
Initialize 'breaking_col' to what it needs to be when the current chunk
consists of only a tab -- a tab that spreads across both start and end
of the chunk -- so that the last 'if' can move into the preceding one,
which allows the elision of 'char_len'.
2017-10-30 21:02:23 +01:00
David Lawrence Ramsey d344c3d042 display: don't cut off zero-width characters at the end of a chunk
This fixes https://savannah.gnu.org/bugs/?52258.
Reported-by: Peter Passchier <peter@passchier.net>
2017-10-25 19:07:38 +02:00
Marco Diego Aurélio Mesquita 501d05c5d1 new feature: the ability to record and play back a series of keystrokes
Allow the user to record and run a single macro.  The default binding
for starting and stopping the recording is M-: (Alt + colon) and for
running the macro M-; (Alt + semicolon).

This fulfills https://savannah.gnu.org/bugs/?50314.
Requested-by: Peter Passchier <peter@passchier.net>

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-10-15 20:40:40 +02:00
Benno Schulenberg ca8317e820 tweaks: reduce a bit of code duplication
This also removes a call of ungetch(), as it does not seem to be
needed any more: nano does not lose a character when waking from
suspension.
2017-10-04 21:51:47 +02:00
Benno Schulenberg 1bd17c44b0 display: keep the cursor switched on when resizing the screen
This fixes https://savannah.gnu.org/bugs/?52149.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-10-04 21:38:46 +02:00
Benno Schulenberg c8a2f36e87 input: recognize Option+Arrow keys on iTerm2 in "xterm mode"
Inspired-by: Mike Frysinger <vapier@gentoo.org>

This kind of addresses https://savannah.gnu.org/bugs/?51685.
2017-09-26 21:44:01 +02:00
Benno Schulenberg f2f7498f12 tweaks: rename two variables, for contrast, and frob some comments 2017-09-26 20:54:04 +02:00
Benno Schulenberg 762f997244 tweaks: elide two variables by using a pointer instead of an index 2017-09-26 20:39:58 +02:00
David Lawrence Ramsey 504a97256b softwrap: break before multi-column Unicode blanks when they overshoot
In atblanks mode, if a softwrapped chunk ends with a double-width space
character (say, Unicode 003000, Ideographic Space), and that would put
half of the character past the edge of the screen, break before it.

This fixes https://savannah.gnu.org/bugs/?51671.
2017-09-26 19:56:48 +02:00
Benno Schulenberg 7c3c3cbb3b tweaks: discard some obsolete debugging stuff 2017-09-22 21:59:51 +02:00
Benno Schulenberg c74d2632bb tweaks: make the switching on and off of the cursor a bit more compact 2017-09-22 21:31:01 +02:00
Benno Schulenberg ae34825f58 display: rework the switching on and off of the cursor
The basic idea is that the cursor is always off, except when it needs
to be on: when waiting for text input, and in a few other cases: when
something was searched and found in the help viewer, and in the file
browser when option -g is in effect.

This fixes https://savannah.gnu.org/bugs/?51923.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-09-20 21:35:25 +02:00
Benno Schulenberg 153dea1732 tweaks: discard another set of useless asserts 2017-09-13 19:34:45 +02:00
Benno Schulenberg bb8d65e89c tweaks: reshuffle some code, and rename a variable 2017-09-13 19:34:28 +02:00
Benno Schulenberg f9bf320fd5 titlebar: don't show nano's name and version when in the file browser 2017-09-13 19:34:14 +02:00
Benno Schulenberg 9738c7997b titlebar: drop the prefix "File: " from before the filename 2017-09-13 19:30:07 +02:00
Benno Schulenberg cbf4f77d6b titlebar: don't reshow version when dropping back to a single buffer
When multiple files were open and [x/n] was being shown in the title
bar, don't show nano's name and version number when just one buffer
remains open, but show [1/1] instead.  It is less surprising.
2017-09-13 19:29:56 +02:00
Marco Diego Aurélio Mesquita 3fc89e0853 new feature: show current and total number of open buffers in title bar
When multiple buffers are open, replace nano's name and version number
with an indication how many buffers are open preceded by the sequence
number of the current buffer.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-09-13 19:29:38 +02:00
Benno Schulenberg ae25e15d61 startup: don't produce more than three consecutive beeps
This fixes https://savannah.gnu.org/bugs/?51918.
2017-09-02 15:31:02 +02:00
Benno Schulenberg 21ffa883f7 tweaks: use mnemonic constants instead of TRUE and FALSE
And use these constants in another context too.
2017-08-31 22:14:06 +02:00
David Lawrence Ramsey 59451da3ac softwrap: correctly move vertically through overwide tabs
Don't skip rows that contain something when moving up, and do put
the cursor in the desired column whenever possible when moving down.

This fixes http://savannah.gnu.org/bugs/?51827
and fixes http://savannah.gnu.org/bugs/?51828.
2017-08-26 10:14:01 +02:00
Benno Schulenberg 243380c4a2 mouse: one click of the wheel should move three lines, not three pages
This fixes https://savannah.gnu.org/bugs/?51802.
2017-08-20 20:45:56 +02:00
David Lawrence Ramsey 5fcda555ea display: constrain line numbers on softwrapped lines with sprawling tabs
Check the column number, not the character index, when suppressing the
line number on chunks other than the first, since the index can be zero
when in fact we're on a later chunk.

This fixes https://savannah.gnu.org/bugs/index.php?51790.
2017-08-19 20:50:01 +02:00
Benno Schulenberg 86e71fa09d tweaks: specify more directly in what manner to move the viewport 2017-08-18 21:46:55 +02:00
David Lawrence Ramsey e09dbf18b1 display: do show the visible character for a tab when it starts a row
Regardless of whether the row start is at a multiple of the tab size.

This completes the fix for https://savannah.gnu.org/bugs/?51669.
2017-08-17 20:09:50 +02:00
David Lawrence Ramsey f08d169aa1 softwrap: make sure char_len is set when a tab is wider than a chunk
This fixes https://savannah.gnu.org/bugs/?51770,
and fixes https://savannah.gnu.org/bugs/?51768.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-08-17 19:39:51 +02:00
Benno Schulenberg cf14ee2ef3 moving: the current chunk is always 0 when not in softwrap mode
This is a partial fix for https://savannah.gnu.org/bugs/?51770.
Analysis-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-08-17 19:33:43 +02:00
David Lawrence Ramsey 566a2daf12 tweaks: remove unneeded parentheses and blank line and braces 2017-08-14 21:46:25 +02:00
Benno Schulenberg 9f6c3a6269 display: don't doubly show tabs that cross a chunk boundary
This fixes https://savannah.gnu.org/bugs/?51669.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-08-14 21:31:55 +02:00
Benno Schulenberg 4562401505 bindings: hard-bind Alt+Up and Alt+Down to findprevious and findnext
So that these functions have bindings by default, and easy bindings.
Add them to the help viewer too, so that searching backward becomes
possible there.
2017-08-14 10:34:15 +02:00
Urja Rannikko 1cc030f7c1 bindings: hard-bind Alt+Left and Alt+Right to buffer switching
This also fixes https://savannah.gnu.org/bugs/?51735.
Reported-by: Urja Rannikko <urjaman@gmail.com>

Signed-off-by: Urja Rannikko <urjaman@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-08-14 10:06:29 +02:00
David Lawrence Ramsey 65d1655134 softwrap: don't push a straddling tab to the next chunk
Tabs are of variable length depending on position, so allow them
to be displayed partially on one chunk and partially on another.

This fixes http://savannah.gnu.org/bugs/?51621.
2017-08-13 21:06:23 +02:00
Benno Schulenberg ee3254b614 tweaks: simply set the proper scrolling mode, instead of imitating it 2017-08-10 12:28:39 +02:00
Benno Schulenberg 938aa63dfa tweaks: drop some debugging stuff 2017-08-08 22:09:22 +02:00
Benno Schulenberg 06ffcfaf40 display: catch all cases where the cursor can be pushed offscreen
Discarding (in commit 6f9bb53b) the cap on the number of chunks to
move backwards had as an unforeseen side effect that the screen can
fail to scroll when the cursor is somehow pushed offscreen.

Fix this by setting the target row (for smooth scrolling) always to
the bottom row of the edit window when nano notices that the cursor
has gone offscreen.

This fixes https://savannah.gnu.org/bugs/?51676.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-08-08 22:06:55 +02:00
Benno Schulenberg 11072ed587 tweaks: sort the includes, so it's a little easier to see what is there 2017-08-06 19:40:30 +02:00
David Lawrence Ramsey 1c1cbae6bc small addition: allow customizing the color of selected text
The new option 'set selectedcolor' applies to marked text, to the
currently selected file in the file browser, and to the highlighted
match during interactive search-and-replace.
2017-08-06 09:30:32 +02:00
Benno Schulenberg 80686bb525 tweaks: remove includes that appear to be superfluous
Without them, nano still compiles for me, with everything enabled,
even when using --enable-debug, --enable-utf8, and --with-slang.
2017-08-06 09:08:30 +02:00
David Lawrence Ramsey ac2c81fad1 tweaks: correct a comment typo and an indentation error 2017-07-31 21:42:39 +02:00
David Lawrence Ramsey 381a386b01 weeding: drop the forreal parameter from place_the_cursor()
Commit 28beb3f added the 'forreal' parameter to prevent spotlight() from
placing the cursor wrongly due to an invalid placewewant.  However, since
the variable-width softwrap overhaul (specifically, since commit 8490f4a),
place_the_cursor() no longer checks placewewant, so the parameter is no
longer needed.

Furthermore, dropping 'forreal' and thus always setting current_y won't
affect the operation of spotlight(), since the only functions that use
spotlight() (do_replace_loop() and do_int_spell_fix()) both call
edit_refresh() beforehand, which means that current_y will already
have been set to the value it will be set to again.
2017-07-24 21:07:42 +02:00
David Lawrence Ramsey 6f9bb53b2d tweaks: set the target row for smooth scrolling more directly
The function place_the_cursor() assumes that the viewport is up to date,
i.e., that current is in range of edittop.  When uncutting or inserting,
however, place_the_cursor() gets called on the out-of-date viewport
first, and then a screen refresh is scheduled (which would put the
viewport up to date).  This is backwards: the refresh should come before
the cursor placement, and the only reason it works anyway is because the
cap on the number of chunks to move backward papers over the problem by
keeping current_y in screen range regardless.

Fix this properly by simply setting current_y to the bottom row of the
screen instead of calling place_the_cursor().  This value of current_y
is only ever used when in smooth scrolling mode and the insertion (or
paste) pushed the cursor offscreen.  In other situations, this value is
overridden when place_the_cursor() gets called after a screen refresh.

After that fix, the cap on the number of chunks to move backward is no
longer needed.
2017-07-23 12:16:59 +02:00
David Lawrence Ramsey ee8681d7cc tweaks: only compensate for a partially-offscreen line in softwrap mode
A line can only be partially offscreen when doing softwrapping.
2017-07-20 12:27:40 +02:00
Benno Schulenberg a1fba43452 pasting: restore the cap on the number of chunks to move backward
This fixes https://savannah.gnu.org/bugs/?51514.
2017-07-20 09:41:27 +02:00
Benno Schulenberg 0e4cbd4bfd softwrap: when possible, go back a whole bunch of chunks at a time
This improves https://savannah.gnu.org/bugs/?51479 for the +-1 case.
2017-07-19 09:47:56 +02:00
David Lawrence Ramsey ce68f81b2b softwrap: remove unneeded caps on the number of chunks to move 2017-07-19 09:45:22 +02:00
Benno Schulenberg 43a5c87682 suspension: prevent entering an invalid byte upon resume (with S-Lang)
For some reason, when returning from suspension, SLang will produce
either a clipped error code (0xFF instead of 0xFFFF, when returning
from an externally induced suspension), or it will clip the code of
first subsequent keystroke to a single byte (when returning from a
normal, in-editor suspension: ^Z).

Side-step this by ignoring the clipped error code, and by using an
undefined control code as the first fake keystroke.  Ignoring the
clipped error code is not possible when using a single-byte locale,
otherwise the user would not be able to type the character with
code 0xFF (although it could still be entered with Esc Esc 255).

This fixes https://savannah.gnu.org/bugs/?51477.
2017-07-16 13:55:59 +02:00
Benno Schulenberg 8b3213cadb tweaks: chuck some debugging stuff 2017-07-15 11:49:56 +02:00
David Lawrence Ramsey 4f3249de56 display: when converting tabs, don't go beyond the screen width
This fixes https://savannah.gnu.org/bugs/?51427.
2017-07-10 09:34:55 +02:00
Benno Schulenberg fbbf501f8f tweaks: rename four functions, to be more distinct 2017-07-09 21:07:38 +02:00
Benno Schulenberg 09723b07a8 tweaks: fix compilation with --enable-tiny 2017-07-07 13:07:10 +02:00
David Lawrence Ramsey dd667ce92c softwrap: don't flag EOL too early, nor break continuous text too early
This should eliminate all cases where the newline is pushed off the edge
of the screen in non-atblanks softwrap mode.  Also, it allows the use of
the last column of the screen in atblanks softwrap mode when a piece of
text does not contain any blanks.

This avoids the unreachable end-of-line reported on the mailing list:
http://lists.gnu.org/archive/html/nano-devel/2017-06/msg00011.html.
2017-07-07 13:07:10 +02:00
Benno Schulenberg 482fb352b8 tweaks: elide unneeded calls of get_last_chunk_leftedge()
And then elide the function entirely as it's called just once.
2017-07-07 13:07:10 +02:00
Benno Schulenberg 8766e7bdcb tweaks: reshuffle some things to condense the code 2017-07-07 13:07:10 +02:00
David Lawrence Ramsey bb4d0d548a new feature: allow lines to be softwrapped at whitespace
Extend get_softwrap_breakpoint() to break softwrapped lines on
whitespace when a flag is set.  This flag is controlled by the new
rcfile option "atblanks".  The '>' characters marking two-column
characters at the edge of the screen are disabled when it's on.

If get_softwrap_breakpoint() can't find whitespace in screen range, it
will break the line on the screen edge.  (In this case, a blank can be
on the last column of the screen, but text can't, so that a blank on the
last column doesn't become invisible and possibly break the display.)

This fulfills https://savannah.gnu.org/bugs/index.php?49959.
Requested-by: Nicholas Boel <axxisd@gmail.com>
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey aa04ad4f83 replacing: make spotlight() account for varying chunk width
spotlight() now displays softwrapped lines chunk by chunk instead of all
at once.  Since softwrapped lines are no longer of constant width, the
latter approach would fail if softwrapping breaks the spotlighted text.

Instead of taking a string, spotlight() now takes the starting and ending
columns of that string.  Also, its handling of softwrapped lines is now
split off into a separate function, spotlight_softwrapped().
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey 4d7735c8f9 softwrap: in do_mouse(), keep the cursor before a softwrap breakpoint
Add the new function actual_last_column() to accomplish this.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey 8490f4acab softwrap: make the changes to actually allow the chunk width to vary
get_chunk_row() and get_chunk_leftedge() now become wrappers around
get_chunk(); the latter is only used directly in place_the_cursor()
when we need to get both the row and the leftedge.  get_chunk() now
uses the proper formula to implement varying chunk width.

Since chunk width now varies, place_the_cursor() sets the x position
relative to the leftedge in a different way that works regardless
of chunk width, update_softwrapped_line() loops until it gets all
softwrap breakpoints instead of calculating the full length in
advance and getting one full row at a time, the chunk iterators
now count leftedges instead of rows, and fix_firstcolumn() does a
full recalculation of the chunk that firstcolumn is on instead of
simply shifting it back.

Also, in update_softwrapped_line(), when a line's softwrap breakpoint
is before the last column of the edit window, a ">" is now added to
the end of it.

The workaround in place_the_cursor() for when two-column characters
straddle the edge of the screen is removed, as it's no longer needed
now that chunks end before such characters.

Furthermore, do_home() and do_end() use xplustabs() instead of
placewewant again when calculating the leftedge, since placewewant
refers to a column that may or may not be available (if it's not,
the cursor will be placed wrongly).  Make get_edge_and_target() use
xplustabs() instead of placewewant for the same reason; this also lets
us simplify get_edge_and_target(), since xplustabs() will never be
greater than strlenpt().  Finally, since do_end() now has to calculate
rightedge as well as rightedge_x, use the former to implement the same
time-saving optimizations as in do_home().

The cursor is not yet adjusted when we try to go directly to a column
past the end of a softwrap breakpoint, and placewewant handling in the
vertical movement code is not yet adjusted for varying chunk lengths,
but fixes for these are forthcoming.

This fixes https://savannah.gnu.org/bugs/?49440.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey e375995d98 softwrap: add new functions for chunks of varying width
get_chunk_row() replaces the formula "column / editwincols".

get_chunk_leftedge() replaces "(column / editwincols) * editwincols".

get_last_chunk_row() replaces "strlenpt() / editwincols".

get_last_chunk_leftedge() replaces "(strlenpt() / editwincols) * editwincols".

This prepares us for any changes in those formulas, and for more such
functions later.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey 35f6a1767a softwrap: prepare for allowing the chunk width to vary
The new function find_softwrap_breakpoint() returns the column number
of the last position in screen range where we can wrap the given text
without breaking a two-column character in half (as was done until now).
The returned column number is the leftedge of the next softwrapped chunk.

If the end of the text is reached while searching for a wrapping point,
the parameter end_of_line is set to TRUE.

The new function get_chunk() uses find_softwrap_breakpoint() to find the
row and leftedge corresponding to a given column of a given line.
2017-07-07 13:07:10 +02:00
Benno Schulenberg 8e3f40155c input: recognize the Ctrl+Arrow key sequences from Haiku's Terminal 2017-07-02 11:58:43 +02:00
Benno Schulenberg 4239e5fe1a tweaks: put declarations always first, so it will compile on Haiku 2017-07-02 11:53:59 +02:00
Benno Schulenberg b93767b54f screen: defeat a VTE/Konsole bug also for the case of --constantshow
When also --nohelp is active and the terminal is so narrow that the
message that --constantshow displays on the bottom row does not fit,
this causes the cursor to be pushed "offscreen".  Some terminal
emulators don't handle this case correctly, and leave the cursor
in an invisible or mistaken position.  Compensate for this by
moving the cursor back to the start of the row.

This fixes https://savannah.gnu.org/bugs/?51335.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-06-30 10:08:17 +02:00
Benno Schulenberg 84cd0abd6f tweaks: avoid compiler warning about implicit type 2017-06-04 12:59:05 +02:00
Benno Schulenberg 6a70d2b6e2 tweaks: rename two functions and a variable, and invert its logic 2017-06-04 12:34:21 +02:00
Benno Schulenberg 16482f99b8 tweaks: unglobalize the nodelay_mode variable 2017-06-04 12:15:26 +02:00
Benno Schulenberg a2038a9b2b input: give an appropriate message when there are too many errors
This fixes a secondary part of https://savannah.gnu.org/bugs/?51124.
2017-05-31 15:11:11 +02:00
Benno Schulenberg a969adf804 suspension: fake a SIGWINCH when coming back out of the background
When receiving a SIGCONT, don't call regenerate_screen() directly
but act as if a SIGWINCH occurred.  Also insert a dummy key, and
thus let the relevant input routine redraw the relevant subwindows.

Use KEY_F0 as the dummy key, as both Ncurses and Slang know it, and
it should normally do nothing at all.

This fixes https://savannah.gnu.org/bugs/?51124.
2017-05-31 14:57:56 +02:00
Benno Schulenberg 59b0f81bfa display: redraw title bar and edit window only when needed
When we are in the file browser, browser_refresh() will take care of
redrawing the title bar and the file list, so total_refresh() should
leave those two subwindows alone in that case.

This fixes https://savannah.gnu.org/bugs/?51147.
2017-05-31 12:44:02 +02:00
Benno Schulenberg 6ad3d3d6c0 display: show the cursor position also when searching took a while
Achieve this by making the suppression flag global, so that we can
just reset it instead of making an improper call of do_cursorpos().

This fixes the secondary part of https://savannah.gnu.org/bugs/?51134.
2017-05-29 22:15:38 +02:00
Benno Schulenberg ca70885564 tweaks: don't bother calculating the position when we won't show it
Also, remove a useless assert.
2017-05-29 21:51:47 +02:00
Benno Schulenberg cfa20c3f42 display: don't show the cursor while we are busy calculating its position
This fixes https://savannah.gnu.org/bugs/?51134.
2017-05-29 21:47:38 +02:00
Benno Schulenberg 7b23878b42 tweaks: do actual screen refreshes in a single call, when possible 2017-05-19 16:31:08 +02:00
Benno Schulenberg aa14526cb3 tweaks: exclude from the tiny version five error-betraying messages 2017-05-16 22:13:10 +02:00
Benno Schulenberg 28beb3f9c5 replacing: don't let placewewant influence the placement of the cursor
When spotlighting the string to be replaced, placewewant isn't valid,
so tell place_the_cursor() to ignore its value to avoid the cursor
getting mistakenly placed at the beginning of the next row.

This fixes https://savannah.gnu.org/bugs/?50997.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-05-11 22:28:34 +02:00
Benno Schulenberg dc3610fc8e tweaks: transform the token DISABLE_BROWSER to ENABLE_BROWSER
Also, allow Ctrl+Left/Right with --enable-tiny --enable-browser.
2017-05-08 21:56:50 +02:00
David Lawrence Ramsey 03c3e2b7c0 tweaks: fix several whitespace irregularities
Add missing spaces, remove excess spaces, and
replace groups of indentation spaces with tabs.
2017-05-07 18:20:01 +02:00
Benno Schulenberg 5a3de7f117 tweaks: avoid an empty function call in tiny version with line numbers 2017-05-05 12:39:20 +02:00
David Lawrence Ramsey 2b38547875 display: ensure smooth scrolling when the edit window is resized
When the editing space gets narrower, either by toggling line numbers on
or making nano's window smaller, and when the cursor is near the bottom,
it can be pushed offscreen.  In that case, don't get it back onscreen by
centering the current line but by putting it on the bottom row.  This
makes for a smoother experience.

This fixes http://savannah.gnu.org/bugs/?50933.
2017-05-05 12:31:02 +02:00
Benno Schulenberg 5033cfd81a tweaks: transform the token DISABLE_MOUSE to ENABLE_MOUSE
Also, trim some comments and avoid an unused-variable warning.
2017-05-01 20:53:07 +02:00
Benno Schulenberg a9c4682c25 tweaks: rename another function, to better describe what it does
Also, reshuffle two initializations to go sit with the other ones.
2017-05-01 17:54:48 +02:00
Benno Schulenberg 3275c4e514 display: initialize the colors only when starting to draw the content
This avoids https://savannah.gnu.org/bugs/?49912 while at the same time
avoiding to draw the edit window twice in a row -- the first drawing
would use a wrong margin, which results in a visible and irritating
shift left or right of the content upon the second drawing.

This fixes https://savannah.gnu.org/bugs/?50877.
2017-04-30 17:29:17 +02:00
Benno Schulenberg 8edaa38a1e tweaks: condense two bits of code, and drop two asserts 2017-04-28 15:57:51 +02:00
Benno Schulenberg 1f55c8819b tweaks: swap the names of two variables, to make more sense
An iterator should not be called "start_col", because it is only the
starting column at the very beginning.

Also, start_col (after the rename) can never be /larger/ than column.
2017-04-28 15:48:50 +02:00
Benno Schulenberg 03ecbf3d55 tweaks: remove a superfluous check
The mbwidth() function itself checks whether UTF-8 is being used
and does the right thing.
2017-04-28 15:47:53 +02:00
Benno Schulenberg 26fe2118c4 docs: update the list of who authored what
Also, mention that help texts can now be searched through, update
a copyright notice, and update and simplify a copyright year.
2017-04-25 20:32:05 +02:00
Benno Schulenberg 46430999d5 build: make --enable-help properly depend on --enable-multibuffer
And in the process transform the token DISABLE_HELP to ENABLE_HELP.
2017-04-25 18:27:55 +02:00
Benno Schulenberg f9fea02fc5 help: suppress nano's name and number to make it clearer this is help
The top-left corner changing is far more conspicuous than the top right.
2017-04-25 17:21:02 +02:00
Rishabh Dave 90bd25c1bb new feature: add a search facility to the help viewer
Allow the user to search in a help text with ^W and M-W.

Achieve this by not writing the help text directly to the screen
but first writing it to a temporary file and then opening this file
in a new buffer, and treating it specially: the normal file-reading
feedback is suppressed, the titlebar shows the headline of the text,
the cursor is hidden, and the menu is limited to just the up and down
movements and searching.

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

Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
2017-04-25 17:20:34 +02:00
Benno Schulenberg ca6d7b6a46 input: avoid crashing when resizing the window during verbatim input
This fixes https://savannah.gnu.org/bugs/?50872.
2017-04-25 13:01:21 +02:00
Benno Schulenberg 861d81edba scrolling: don't bother to limit the number of lines to step back
The go_back_chunks() function will do this clipping.

This fixes https://savannah.gnu.org/bugs/?50866.
2017-04-24 19:48:55 +02:00
Benno Schulenberg 1fbe7596f8 options: allow -U (--quickblank) to be used in the tiny version
It takes almost no code and is a useful little improvement over Pico.
2017-04-19 13:47:40 +02:00
Benno Schulenberg 74f128859b tweaks: rename a constant, to match the corresponding option 2017-04-17 11:51:48 +02:00
Benno Schulenberg 3dc6ccbe86 tweaks: rename a function, to be more accurate
Because nothing gets reset to zero or to some initial value.
2017-04-17 11:29:29 +02:00
Benno Schulenberg b98545f455 display: push the titlebar to the screen as soon as it has been drawn
To avoid an ncurses hiccup (miscoloring) when running on musl.

This fixes https://savannah.gnu.org/bugs/?50787.
Reported-by: Avi Halachmi <avihpit@yahoo.com>
2017-04-17 10:53:38 +02:00
Benno Schulenberg 5a741a0205 tweaks: remove some superfluous placements of the cursor
The cursor needs to be placed in its proper spot in the edit window
/only/ when nano is about to accept input from the user and needs to
show where this input will go.

(This might cause a scrolling issue to appear, because reset_cursor()
does not just place the cursor, it also recomputes current_y, which
is used in several places to determine whether and how much to scroll.
If it so happens, we'll deal with that fallout later.)
2017-04-17 10:35:05 +02:00
Benno Schulenberg 6723ac6fcc tweaks: add three warnings for conditions that should never occur 2017-04-17 10:17:47 +02:00
Benno Schulenberg 999d99c6e4 tweaks: delete a function that hasn't been used since 2005 2017-04-09 13:33:25 +02:00
Benno Schulenberg 754c62c5cc copyright: update the years, use ranges, and explain this usage
The interval 2013-2017 for the Free Software Foundation is valid
because in those years there were releases with changes by either
Chris or David, and the GNU maintainers guide advises to mention
a new year in all files of a package, not just in the ones that
actually changed, and be done with it for the rest of the year.
2017-04-09 12:09:23 +02:00
David Lawrence Ramsey 23ae7bfbbf input: support escape sequences for ^Home and ^End
Make nano recognize the escape sequences for Ctrl-Home, Ctrl-End,
Shift-Ctrl-Home, and Shift-Ctrl-End on xterm, rxvt, and Eterm.
2017-04-06 21:25:41 +02:00
Benno Schulenberg cb0806b2a0 bindings: make ^Home and ^End go to top and tail of buffer
On some terminal emulators, Ctrl+Home and Ctrl+End produce special
keycodes, distinct from plain Home and End.  Make the users of those
emulators (and of the Linux console) glad by making ^Home and ^End
do the obvious thing, and the combinations with Shift too.
2017-04-06 21:19:00 +02:00
Benno Schulenberg f3e2ad945d display: with softwrap, show the cursor where the eye expects it
When a multi-column character straddles a chunk boundary, and the
preferred column (placewewant) for the cursor is zero, cheat: show
the cursor not where the character starts but on the beginning of
the next row.  This makes the cursor move smoothly in the leftmost
column of the screen when using <Up> and <Down> and such, instead
of jumping around.

In this way the scrolling logic won't get confused and the screen
will scroll properly when stepping beyond the top or bottom row.

This fixes https://savannah.gnu.org/bugs/?50687.
2017-04-06 19:51:07 +02:00
Benno Schulenberg 6ec65d5500 display: check the correct character for being double-width
This fixes https://savannah.gnu.org/bugs/?50741.
2017-04-06 17:39:58 +02:00
Benno Schulenberg aedc3ddd49 tweaks: replace a function call or a macro with a hard number
Verify at startup that the number is not too small.
2017-04-04 19:17:02 +02:00
David Lawrence Ramsey f9a8d6ff4e scrolling: properly compensate for the onscreen chunks
If edittop is partially offscreen before we scroll, and it gets
scrolled more offscreen, we do need to compensate for the chunks
between firstcolumn and leftedge -- that is: the chunks between
the top row and the cursor row.

This fixes https://savannah.gnu.org/bugs/?50691.
2017-04-04 10:55:24 +02:00
David Lawrence Ramsey c3830517cc display: show '<' and '>' placeholders for characters that get split
When a two-column character cannot be shown because it straddles the
boundary between two chunks of a line, show the '>' placeholder for
its left "half", and '<' for its right "half".

This mitigates https://savannah.gnu.org/bugs/?49440.
2017-04-03 21:51:46 +02:00
Benno Schulenberg 33cefa9208 tweaks: elide an intermediate variable 2017-03-29 10:20:41 +02:00
Benno Schulenberg 873e3d6fa6 tweaks: don't loop over an initializer 2017-03-29 10:13:08 +02:00
Benno Schulenberg 54e4505b2f tweaks: frob a couple of comments 2017-03-28 19:44:41 +02:00
Benno Schulenberg 8091d0a574 tweaks: simplify and correct a computation
The leftedge variable is a column number, not an x position.
2017-03-28 19:24:37 +02:00
David Lawrence Ramsey 93c6248956 display: don't compensate for chunks before firstcolumn
The number of rows to draw shouldn't be compensated for the chunks
of edittop that are before firstcolumn, because they are offscreen.

This completes the fix for https://savannah.gnu.org/bugs/?50621.
2017-03-28 19:10:45 +02:00
David Lawrence Ramsey 66ef8f45a3 display: don't draw more chunks than the screen can hold
There is no need to always increase nrows by 1 or 2 -- an increase
of 1 is only needed when the line that borders on the scrolled region
needs to redrawn too: when this line was horizontally scrolled or when
the mark is on.

This fixes https://savannah.gnu.org/bugs/?50621.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-28 12:32:51 +02:00
Benno Schulenberg 58faff50ae tweaks: shorten a bit of logic 2017-03-24 21:37:06 +01:00
David Lawrence Ramsey 87a7c2e42d tweaks: fix a comment typo 2017-03-24 21:21:51 +01:00
Benno Schulenberg e46c6c9607 tweaks: ehm... the warning is more important for the softwrap case
But apparently none of these cases occur, because I can't trigger them.
2017-03-22 11:05:22 +01:00
Benno Schulenberg 8b7bbebeeb tweaks: add a warning for a condition that should never occur 2017-03-22 10:50:59 +01:00
Benno Schulenberg 55159b7b39 painting: don't try to start highlighting before column zero
This could happen when a tab or a double-width character straddles
the boundary between two softwrapped chunks.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey 0389a1d939 softwrap: adjust firstcolumn when the window width changes
If the number of columns in the edit window changes (which currently
only happens in two places: in regenerate_screen(), called when the
window is resized; and in main(), when line numbering mode is toggled),
the display will break if we're in softwrap mode and firstcolumn is
nonzero.  This is because the column width of softwrapped chunks has
changed, and firstcolumn is no longer the starting column of a chunk,
an assumption that all code using firstcolumn relies on.

To fix this problem, add a new function, ensure_firstcolumn_is_aligned(),
to adjust firstcolumn to the starting column of the chunk it's on, and
use it when the number of columns in the edit window changes.

(Note that this function uses the simplest possible fix, and could
probably be made more sophisticated.)
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey 2f6c8987ea softwrap: move the updating of a softwrapped line to a new function
The new function, update_softwrapped_line(), is called from inside
update_line() when softwrap mode is on, so that existing calls remain
unchanged.  It takes no index, instead displaying edittop from column
firstcolumn, and all other lines from column zero.

If current is on edittop, it's displayed using the edittop rules, but
this is not a problem: if current[current_x] is above edittop at column
firstcolumn, it's offscreen, and that should be handled before calling
update_line() anyway.

Together with the preceding bunch of changes,
this fixes https://savannah.gnu.org/bugs/?47667.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey 98b029cf3e softwrap: account for firstcolumn in reset_cursor()
When counting rows in softwrap mode, reset_cursor() should compensate for
the number of softwrapped chunks that edittop takes up before firstcolumn.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey c0fa3f04b1 softwrap: account for firstcolumn when checking for offscreen current
Make current_is_above_screen() check for current[current_x] being above
edittop at column firstcolumn, and make current_is_below_screen() start
counting down from edittop at column firstcolumn instead of edittop at
column zero.  This means that both functions now account for softwrapped
chunks properly.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey e52d5b0672 softwrap: remove and replace workarounds for firstcolumn
Actually enable scrolling edittop partially off the screen by making
edit_scroll() and adjust_viewport() use firstcolumn properly when
iterating through softwrapped chunks in softwrap mode, or lines in
non-softwrap mode.

In non-softwrap mode, firstcolumn should still always be zero, because
it's initially set to that, and because passing it through the iterators
will maintain it at that.

This fixes https://savannah.gnu.org/bugs/?49100.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey 812ecaeb0c weeding: remove maxlines and related code
Since all lines can be partially scrolled off the screen now
(except for edittop, which is forthcoming), the maxlines global
variable and its computation mechanism are no longer needed.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey 2abf7b755b softwrap: iterate through softwrapped chunks in adjust_viewport()
Use go_back_chunks() to adjust edittop, instead of special casing
the computation of goal when softwrapping.  Now softwrap mode and
non-softwrap mode will behave the same way when edittop can be
partially scrolled off the screen, which is forthcoming.

(Note that the top line of the screen can't be partially scrolled
yet, so we have to work around that for now.)
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey ba4858de83 softwrap: iterate through softwrapped chunks in edit_scroll()
Use go_back_chunks() and go_forward_chunks() to adjust edittop and to
move up or down to the scrolled region before updating the rows there.
Now softwrap mode and non-softwrap mode will behave the same way when
we can scroll the top line of the screen partially off the screen,
which is forthcoming.

(Note that the top line of the screen can't be partially scrolled yet,
so we have to work around that for now.)
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey fa025f0ca3 display: limit an optimization to non-softwrap mode
Not drawing a line on a row if we're on the top row and scrolled down,
or if we're on the bottom row and scrolled up, will only work properly
if the line on that row takes up only that row.  The latter might not
be the case in softwrap mode: if the line occupies multiple chunks and
begins on that row -- in that case none of the chunks would be drawn.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey eb369c0e00 tweaks: rename need_horizontal_scroll() to line_needs_update()
The old name made it sound as if it didn't apply in softwrap mode.  But
it does: in softwrap mode a line needs updating  when the mark is on.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 380ad30a53 softwrap: account for softwrap when checking whether current is offscreen
Add the new functions current_is_above_screen() (which doesn't account
for softwrapped chunks yet, but will when we can scroll edittop partially
off the screen, which is forthcoming), current_is_below_screen() (which
determines whether current[current_x] is past the softwrapped chunk at
the bottom of the screen), and current_is_offscreen() (the union of the
previous two functions).

edit_redraw() and edit_refresh() now use current_is_offscreen() to check
whether they should adjust the viewport, and adjust_viewport() now uses
current_is_above_screen() to determine whether current is on or below
the screen in FLOWING mode.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 4f9c563e6b softwrap: count softwrapped chunks properly in do_uncut_text()
Add the new function less_than_a_screenful() to accomplish this.
It uses go_back_chunks() to count the number of softwrapped chunks
between the end point and the starting point of the paste.

Now softwrap mode and non-softwrap mode behave the same way when
uncutting fewer than editwinrows rows of text.  Accordingly, remove
the call to ensure_line_is_visible(), as it no longer applies.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 456d66b904 softwrap: add two chunk-iterator functions
These functions, go_back_chunks() and go_forward_chunks(), take a number
of softwrapped chunks (screen rows) to move, a pointer to a buffer, and
a location (specifically, a starting column of a softwrapped chunk).  If
they move successfully, they will update the buffer pointer and location
to point to the beginning of the softwrapped chunk they moved to.

Since non-softwrap mode is effectively just a subset of softwrap mode
in which every line takes up one chunk, these functions also work in
non-softwrap mode.  In this case, their starting column will always be
zero, as it would be in softwrap mode on a line that takes up one chunk.

Nothing uses these functions yet, but that is forthcoming.
2017-03-22 10:44:04 +01:00
Benno Schulenberg 6d873d3760 startup: add option 'nopauses' to disable pausing after a warning
This addresses a followup of https://savannah.gnu.org/bugs/?50362.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-03-16 19:26:39 +01:00
Benno Schulenberg 5283acdcf3 tweaks: trim a displayable string in a more efficient manner
Instead of redetermining the entire span of the converted string,
simply move one character left, and then bite it off to make place
for the trailing $.
2017-03-14 21:20:50 +01:00
Benno Schulenberg 69784d51db screen: don't push the longer-line indicator ($) to the next row
If the last two columns of a row would be taken up by a double-width
character (and the line is longer than that), don't print it, because
it wouldn't leave any room for the $ character.

This fixes https://savannah.gnu.org/bugs/?50491.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-08 21:24:13 +01:00
Benno Schulenberg 355a07bbce tweaks: don't optimize for the wrong case
Running strlenpt() on a string that takes up more than 80 columns
(the width of an average terminal) takes /more/ time than simply
converting an extra character (the one that will be overwritten
by the "$" at the edge of the terminal).  So... just convert one
more character than necessary when the line is overlong.  In the
most common case, however, the line will fit fully onscreen, and
we save a whole call of strlenpt().
2017-02-28 17:07:38 +01:00
David Lawrence Ramsey 0404474ec2 tweaks: stop converting text once we overshoot span columns
Since we only need span columns of the string, stop scanning the string
as soon as we have that many columns, instead of scanning the string all
the way to the end.  This speeds up the conversion of very long lines.
2017-02-28 16:50:22 +01:00