Commit Graph

1007 Commits (c0fa3f04b1f32e5c7b5e996eb9a78f777acc2edb)

Author SHA1 Message Date
Benno Schulenberg 9f884810b6 tweaks: use a subtraction instead of a counter
And return a better value, so that less calculation is needed.
2017-01-13 19:33:32 +01:00
Benno Schulenberg 5d5666fba6 tweaks: swap two blocks of code to reduce the number of #ifdefs 2017-01-13 19:29:39 +01:00
Benno Schulenberg 980e334e37 tweaks: rearrange some code to separate softwrap and normal mode more
(Ignore the indentation for the moment.)
2017-01-13 19:17:59 +01:00
Benno Schulenberg 9bb64fccef tweaks: chuck some obscuring debugging stuff 2017-01-13 17:47:55 +01:00
David Lawrence Ramsey 6e3adf31b8 tweaks: let update_line() return the correct value on error
If the given line is out of range of editwinrows, we don't display it
at all, so we obviously don't display more than one line of it.  Thus,
the return value in this case should be zero, not one.
2017-01-13 17:41:26 +01:00
David Lawrence Ramsey c67c431239 tweaks: improve comments and formatting in update_line() 2017-01-13 17:36:02 +01:00
Benno Schulenberg bf0268d41d tweaks: condense a comment, rename a variable, and use a while loop 2017-01-12 21:31:08 +01:00
Benno Schulenberg b7c2513f7d tweaks: rename some variables, to better distinguish rows from lines
And columns from indexes -- columns are places on the screen, while
indexes point to characters in a line in the current buffer.
2017-01-12 19:32:21 +01:00
Benno Schulenberg 892762d99c tweaks: rename some variables, to show they refer to screen rows 2017-01-12 18:03:36 +01:00
Benno Schulenberg f7d320d932 tweaks: rename a function, to show it refers to screen rows 2017-01-12 17:48:33 +01:00
Benno Schulenberg 0208ae7149 tweaks: rename a variable -- lines refers to buffer, rows to screen 2017-01-12 17:33:46 +01:00
Benno Schulenberg 26fb907aa6 screen: ehm... no, that was wrong: page_start /is/ a column position
(The mistake becomes visible when you go to the end of a very long line
of double-width characters: the $ will be shown on the right edge, even
though you're already at line's end.)

This reverts commit 16a7fd4b from yesterday.
2017-01-12 10:29:20 +01:00
Benno Schulenberg 16a7fd4bfc screen: don't compare a character index with a column position
This addresses part of https://savannah.gnu.org/patch/?9216.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-01-11 17:22:46 +01:00
Benno Schulenberg a898fa5dcc tweaks: if there is no end match, there is nothing to paint
When there is no end match after a start, it is pointless to look
for any more starts because also they will not have any end match,
so nothing will get painted -- just cut the loop short.
2017-01-09 19:14:51 +01:00
Benno Schulenberg c0aa5ad258 tweaks: miscellaneous frobbings 2017-01-09 18:25:25 +01:00
Benno Schulenberg f6fbc1572d tweaks: adjust whitespace after the previous change 2017-01-09 12:01:27 +01:00
Benno Schulenberg 38d7362f20 tweaks: rename two variables to be just one as they play the same role
The renamed variable 'index' is not the start of a match (as some comment
mistakenly said), but from where in the line we start looking for a next
match.

Also, use one more goto to allow unindenting a big piece of code, and
shortcircuit two while loops for two more small unindents.
2017-01-09 11:39:37 +01:00
Benno Schulenberg 26683a9e5f tweaks: frob some comments, and transform one variable 2017-01-08 21:31:49 +01:00
Benno Schulenberg a89437219d tweaks: don't use a variable for two different purposes
At first paintlen was computed as a column span, and then converted
to a character count...  Confusing.
2017-01-08 13:34:10 +01:00
Benno Schulenberg aa28441071 tweaks: the starting point for painting /cannot/ be offscreen
The top_x variable has already been forced to become equal to from_x
if it was before it.  So start_col will be at least zero.
2017-01-08 13:34:04 +01:00
Benno Schulenberg 5dbd288254 tweaks: rename another variable, to show it refers to columns not chars 2017-01-08 13:12:40 +01:00
Benno Schulenberg 8f21d256fb tweaks: rename two variables, for distinguishing characters from columns 2017-01-08 13:12:36 +01:00
Benno Schulenberg 08cfdbcbdb tweaks: don't compare a character offset with a column position
It is the misuse of "x_" to mean a column position on screen, and the
misuse of "_col" to mean a character position in a string that causes
this confusion.
2017-01-08 13:12:11 +01:00
Benno Schulenberg 6103c47f1c tweaks: rename three painting variables, to be more distinct
All these different "start"s and "end"s are confusing.  Use instead
'from_x and 'till_x' to remember which part of the current line is
visible now on screen and is thus represented in 'converted'.
2017-01-08 11:35:07 +01:00
Benno Schulenberg 88cf22f804 tweaks: rearrange and reindent some lines in the painting routines
Also adjust a few comments.
2017-01-08 11:33:57 +01:00
Benno Schulenberg 8177e62c18 screen: examine the whole line when painting, to set the correct info
In order to determine the correct multidata for a line that doesn't
have such data yet, the whole line must be examined, not just the
part that fits within the screen width.

This fixes https://savannah.gnu.org/bugs/?49978.
2017-01-08 11:33:57 +01:00
Benno Schulenberg 908663e8fc input: discard a verbatim 0x0A or 0x00 byte, depending on the mode
This disallows entering a verbatim ^J (0x0A) when typing text or
search terms, and disallows a verbatim ^@ (0x00) when typing a
filename.  Nano beeps when the disallowed code is attempted.

This addresses https://savannah.gnu.org/bugs/?49897.
2016-12-27 16:46:09 +01:00
Benno Schulenberg c92b9be6cd tweaks: rename three variables, to be more fitting 2016-12-23 13:01:15 +01:00
Benno Schulenberg eef7d1047a screen: display byte value 0x0A in the right places as ^@ or as ^J
In path names and file names, 0x0A means an embedded newline and
should be shown as ^J, but in anything related to the file's data,
0x0A is an encoded NUL and should be displayed as ^@.

So... switch mode at the two main entry points into the "file system"
(reading in a file, and writing out a file), and also when drawing the
titlebar.  Switch back to the default mode in the main loop.

This fixes https://savannah.gnu.org/bugs/?49893.
2016-12-23 11:00:55 +01:00
Benno Schulenberg a9b5a0e029 tweaks: rename a function to something less abbrevy
Also, swap the logic around, to use less braces.
2016-12-22 12:04:10 +01:00
Benno Schulenberg 026393a91a binding: use plain codes instead of function calls for the jumping keys
Which is possible because those keycodes are hard-bound to the relevant
functions.
2016-12-22 11:50:24 +01:00
Benno Schulenberg db897b574f input: detect again when both Shift and Ctrl are being held on a VT
In nano 2.7.1 and 2.7.2, pressing Shift+Ctrl+Arrow on a Linux console
would behave as if Shift wasn't held.  It got broken three months ago,
by commit 08cd197b, messing up the proper order of the checks.

This fixes https://savannah.gnu.org/bugs/?49906.
2016-12-22 11:13:39 +01:00
Benno Schulenberg 2b1bc6866a input: don't crash when receiving a KEY_CANCEL
On some systems, typing ^C apparently results in a KEY_CANCEL in
the input stream, which gets hard-bound to the do_cancel function.
But in the main menu there is no Cancel function.  So... in that
case, let it fall back to the plain old Ctrl-C code: 0x03.

Reported-by: Liam Gretton <liam.gretton@leicester.ac.uk>
2016-12-21 17:42:15 +01:00
Benno Schulenberg b77e6bd99d general: simplify the detection of a SIGWINCH
There is no need for a counter, nor an old counter to compare it with.
2016-12-19 10:04:01 +01:00
Benno Schulenberg eafae5d417 screen: show an embedded newline in filenames as ^J instead of ^@
The byte 0x0A means 0x00 *only* when it is found in nano's internal
representation of a file's data, not when it occurs in a file name.

This fixes the second part of https://savannah.gnu.org/bugs/?49867.
2016-12-18 11:13:50 +01:00
Benno Schulenberg dfff78dffe titlebar: always pass a pathname through display_string()
So that embedded control characters will be represented
instead of acted upon.

This fixes the first part of https://savannah.gnu.org/bugs/?49867.
2016-12-18 11:13:49 +01:00
Benno Schulenberg eb88ad980a tweaks: use a slightly faster comparison 2016-12-15 13:15:46 +01:00
Benno Schulenberg a772194102 tweaks: rename two variables, for self-documentation 2016-12-13 17:13:38 +01:00
Benno Schulenberg faf77fb1ec tweaks: don't bother making the next line of an end point NULL 2016-12-13 17:12:52 +01:00
David Lawrence Ramsey c9f743f676 tweaks: elide two unneeded variables from line numbering mode
Instead compute directly whether we're at a softwrapped part or not.
2016-12-13 17:01:39 +01:00
David Lawrence Ramsey bd920b1f49 tweaks: adjust the type of two arguments
Convert digits() to take a ssize_t instead of an int, since it's
used on ssize_t line numbers.  And properly use the long modifier
when displaying a line number.

Also, conditionalize the digits() prototype.
2016-12-13 13:06:20 +01:00
Benno Schulenberg 2fa93ae999 tweaks: rename two variables to make more sense 2016-12-09 12:47:00 +01:00
David Lawrence Ramsey c8c6340ce8 tweaks: conditionalize a bit of softwrap code
This addresses https://savannah.gnu.org/bugs/?49803.
2016-12-09 12:34:56 +01:00
Benno Schulenberg 86121cf3fc tweaks: move a cursor-on switch to a more logical place (again)
But do it correctly this time: don't switch it on when replacing.
2016-12-05 15:47:44 +01:00
Benno Schulenberg 372bd0f7dd screen: switch the cursor back on only in the main loop
This fixes https://savannah.gnu.org/bugs/?49750.
2016-12-03 18:03:11 +01:00
Benno Schulenberg 0f3e303d1a tweaks: get rid of some spurious textual references to edit_refresh() 2016-12-02 18:13:10 +01:00
Benno Schulenberg c9680b8b64 input: add the shifted PageUp and PageDown keycodes produced by VTE
Modern VTE-based terminals now produce codes for those keys and
no longer swallow them when nano is active.

This addresses https://savannah.gnu.org/bugs/?49746.
2016-12-01 17:34:57 +01:00
Benno Schulenberg c6512a9717 screen: don't request an update of the edit window for every yesno prompt
Only when doing replacements does the edit window need a refresh: for
every new spotlight.  So, do the update request in the latter routine.
2016-12-01 15:20:05 +01:00
Benno Schulenberg ac41587d4e oops: the yesno prompt for replacing does not want a visible cursor 2016-11-30 13:47:50 +01:00
Benno Schulenberg 72e8bcb027 tweaks: move a switching on of the cursor to a more logical place 2016-11-30 11:11:06 +01:00
Benno Schulenberg 7401670d58 tweaks: fix compilation when configured with --enable-tiny 2016-11-30 11:05:07 +01:00
David Lawrence Ramsey e4d452424b files: give feedback when restricted mode prevents overwriting a file
Achieve this by reusing the code that gives feedback when trying to
save a buffer while using --tempfile and the file has no name yet.

This fixes https://savannah.gnu.org/bugs/?48622.
2016-11-29 12:08:39 +01:00
David Lawrence Ramsey d48071b2b2 input: properly check the full escape sequences for all keys
Also for Delete, End, PageUp and PageDown (on some terminals)
the last byte in the sequence needs to be checked.

This fixes https://savannah.gnu.org/bugs/?49710.
2016-11-27 20:31:12 +01:00
Benno Schulenberg 3cc561e36e input: distinguish <Shift+Home> from <Home> on an rxvt terminal
That is: when --rebindkeypad is in effect -- without this option
they were already getting distinguished.
2016-11-26 12:25:36 +01:00
Benno Schulenberg 0333b87ad7 input: distinguish <Alt+Left> from <Alt+Right> on an rxvt terminal
Both would jump a word to the left -- now each jumps a word in the
proper direction.
2016-11-26 12:07:33 +01:00
David Lawrence Ramsey 059c8efb44 input: make Shift+Alt+Arrow work properly on rxvt and Eterm terminals
This fixes https://savannah.gnu.org/bugs/?49636.
2016-11-26 11:57:39 +01:00
Benno Schulenberg 55b1403542 tweaks: adjust some whitespace and a comment 2016-10-23 17:26:19 +02:00
Benno Schulenberg 9d5ee16614 tweaks: don't bother redrawing some lines when whole screen will be redrawn 2016-10-23 17:26:19 +02:00
Benno Schulenberg 01bbf7e82f tweaks: rename a function to better describe what it does
It does not update anything -- it just picks a new point from
where to start displaying the buffer.  All actual updating of
the screen is done by edit_refresh() and edit_redraw() and such.
2016-10-23 17:26:19 +02:00
Benno Schulenberg 023edffe3d screen: move the margin determination to the main loop
There is no need to look at this for every painted line, because
the margin can only change when some key is struck.
2016-10-21 14:56:56 +02:00
Benno Schulenberg 2789bb0813 screen: repaint the edit window in a single place -- the main loop
Instead of doing this in two places: after interpreting shortcuts,
and after injecting characters.
2016-10-21 14:56:53 +02:00
Benno Schulenberg 4d996e4c39 screen: suppress line numbers when the terminal is very narrow
To prevent the display from getting messed up, making nano unusable.
2016-10-21 14:55:43 +02:00
Benno Schulenberg de2aa4f24a rcfile: add an option to customize the color of line numbers 2016-10-20 16:48:45 +02:00
Faissal Bensefia de95ca68f7 new feature: the ability to show line numbers before the text
It can be activated with --linenumbers on the command line or with
'set linenumbers' in a nanorc file, and it can be toggled with M-#.

Signed-off-by: Faissal Bensefia <faissaloo@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-10-20 16:47:52 +02:00
Benno Schulenberg fdee0df849 input: keep the Ctrl+Arrow keys working when their synonyms are unbound
This fixes https://savannah.gnu.org/bugs/?49058 reported by Rishabh Dave.
2016-10-15 17:03:10 +02:00
Benno Schulenberg 0a18d8912b screen: defeat a VTE bug by doing an extra cursor move and update
This fixes https://savannah.gnu.org/bugs/?49106.
2016-10-12 13:56:48 +02:00
Benno Schulenberg 598e0af7af softwrap: scroll the current line fully into view when jumping words
This fixes https://savannah.gnu.org/bugs/?47710
and fixes https://savannah.gnu.org/bugs/?49088.
2016-09-20 12:29:10 +02:00
Benno Schulenberg 8ba57cf87b input: don't return zero when some function is completely unbound
Returning a zero would mean returning a ^Space -- the keycode that
by default is bound to the Next-Word function.  So, unbinding the
keys to which the modified Arrow keys are hard bound would cause
the latter ones to mysteriously jump to the next word.

This partially fixes https://savannah.gnu.org/bugs/?49058.
2016-09-20 11:11:44 +02:00
Benno Schulenberg fc9c7b4917 softwrap: scroll when searching lands on an overlong bottom line
This fixes https://savannah.gnu.org/bugs/index.php?42189.
2016-09-14 11:02:36 +02:00
Benno Schulenberg 08cd197bf1 general: include word-jumping and block-jumping into the tiny version
And also case-sensitive searches, backward searches, and searching again.
2016-09-13 09:27:04 +02:00
Benno Schulenberg ad83ed22d9 input: handle the "resize key" in a better way
And correct a comment: the key /does/ occur also in the tiny version.
2016-09-06 12:09:18 +02:00
Benno Schulenberg acd8809d71 tweaks: use hard-baked keycodes where possible
These keycodes have non-rebindable entries in the list of shortcuts, so
they will always be there -- no need for a function call to find them.
2016-09-02 12:04:29 +02:00
Benno Schulenberg 272a953889 tweaks: fix compilation when configured with --with-slang 2016-08-30 10:12:02 +02:00
Benno Schulenberg db310ac9b6 input: ignore the resize "key", to prevent reporting an unbound key
In the tiny version it would beep and report an unbound key for every
window resize.
2016-08-30 09:40:51 +02:00
Benno Schulenberg 514cd9a099 update the license text to the preferred version
Mentioning "GNU nano" instead of "This program" and referring to the
website instead of to a postal address.
2016-08-29 21:27:16 +02:00
Benno Schulenberg 406e5242a3 update the copyright notices 2016-08-29 21:27:05 +02:00
Benno Schulenberg 382c9d792d new feature: allow text selection by holding Shift with the cursor keys
Add the keycodes and routines to allow the user to forego setting the
mark explicitly (with M-A / ^6) and instead quickly select a few words
or lines by holding down Shift together with the movement keys.

(Some combinations with Shift are swallowed by some terminal emulators.
To work around some of those, the combinations Shift+Alt+Left/Right work
as Shift+Home/End and Shift+Alt+Up/Down work as Shift+PageUp/PageDown.)
2016-08-28 11:29:28 +02:00
Benno Schulenberg c05c914eee tweaks: rename three variables 2016-08-27 12:10:18 +02:00
Benno Schulenberg c19f0c732e tweaks: simplify the determination of the number of shown help items 2016-08-27 12:06:08 +02:00
Benno Schulenberg 21cb01e543 tweaks: rename two variables, to make some sense
And move a statement to a better place.
2016-08-25 11:45:05 +02:00
Benno Schulenberg ea9aaee8c7 statusbar: leave out the brackets when the message is very long
This also prevents the message from spilling into the help lines
when the terminal is less than four columns wide.  (Not that one
can read anything then, but it looks better.)
2016-08-25 11:45:01 +02:00
Benno Schulenberg 76a960d73d screen: continue to function also in a terminal with very few lines
This fixes https://savannah.gnu.org/bugs/?48787.
2016-08-17 10:13:22 +02:00
Benno Schulenberg 0dd2a55284 screen: don't die when the window is narrower than four columns
This fixes https://savannah.gnu.org/bugs/?48520.
2016-08-15 17:25:33 +02:00
Benno Schulenberg 928a24c204 input: look at the modifier keys only when compiled on Linux
This fixes https://savannah.gnu.org/bugs/?48751 reported by Andrew Ho.

This also fixes compilation when configured with --enable-tiny.
2016-08-14 21:42:08 +02:00
Benno Schulenberg 290d278f68 input: make the Ctrl+Arrow keys work on a Linux console
If this breaks your build, please send report or instructions or patch.
2016-08-07 18:20:34 +02:00
Benno Schulenberg 8edb096821 input: after an Esc, don't discard starter byte of a multibyte sequence
This fixes https://savannah.gnu.org/bugs/?48711.
2016-08-07 17:40:38 +02:00
Benno Schulenberg faa46a3c71 screen: remove redundant redrawings of the entire edit window
(It may have been necessary in the past; there is no need for it now.)

This fixes https://savannah.gnu.org/bugs/?48633.
2016-08-01 19:41:13 +02:00
Benno Schulenberg 2f6647687a tweaks: rename a function, and adjust some comments 2016-08-01 19:41:13 +02:00
Benno Schulenberg c9e9964207 screen: don't look at placewewant but at where we actually were and are
For horizontal scrolling, it is not the /desired/ column position that
is relevant for determining whether a line needs to be redrawn after a
cursor movement, but the /actual/ column positions before and after.

This fixes https://savannah.gnu.org/bugs/?48627,
and fixes https://savannah.gnu.org/bugs/?48629.
2016-08-01 19:41:13 +02:00
Benno Schulenberg 08c51cfd45 input: ingest as verbatim just one control code or one or two escapes
Leave the rest of any escape sequence to be processed normally, which
should be possible because those characters are all in ASCII range.

This fixes https://savannah.gnu.org/bugs/?48318.
2016-08-01 14:47:02 +02:00
Benno Schulenberg b472f5a633 tweaks: remove some unnecessary keycodes from a switch statement
These codes are the basic codes that get assigned for the movement keys
in the list of shortcuts -- they don't need any translation.
2016-08-01 14:07:21 +02:00
Benno Schulenberg 5806bf5249 tweaks: normalize some whitespace and adjust several comments 2016-08-01 14:05:42 +02:00
Benno Schulenberg 90a90365a8 tweaks: rename three constants, for clarity, and hardcode two others 2016-08-01 12:56:05 +02:00
Benno Schulenberg f33d8cae30 tweaks: don't use a function call when reference to the variable will do 2016-07-31 18:30:53 +02:00
Benno Schulenberg e471e2d462 tweaks: move the modified editing keys again 2016-07-31 18:29:57 +02:00
Benno Schulenberg fe38b78486 tweaks: adjust indentation after the previous changes 2016-07-31 18:22:07 +02:00
Benno Schulenberg 1af1f5c9f4 tweaks: return quicker from the key parsing routine 2016-07-31 18:19:17 +02:00
Benno Schulenberg b9e83fe9f8 tweaks: move some debugging stuff, and move modified editing keys too
Again, just for preapring an easier return from the parsing routine.
2016-07-31 18:17:06 +02:00
Benno Schulenberg cb10b2b908 tweaks: elide the global variable 'func_key'
There is no need to specially flag a function key or editing key --
the keycode is indication enough in itself: outside of byte range.
2016-07-31 18:13:05 +02:00
Benno Schulenberg 19dfd20a88 tweaks: add a variable, in preparation for making returning easier 2016-07-31 18:10:31 +02:00