Commit Graph

6038 Commits (99733666852c60f17dc94442e5bb74061359abb5)

Author SHA1 Message Date
Benno Schulenberg 9973366685 prompt: represent newlines as ^J instead of breaking the bar
Also at the yes-no prompt, a 0x0A byte should be displayed as a ^J
instead of splitting the prompt bar in two and spreading it over
two lines.

This fixes https://savannah.gnu.org/bugs/?49934.
2016-12-26 19:59:51 +01:00
Benno Schulenberg e72db0e350 files: show newlines in filenames as ^J also in error messages
When a given file is, for example, unreadable or unwritable, the
error message should use ^J instead of ^@ in its name.
2016-12-26 12:35:50 +01:00
Benno Schulenberg 87b2df6dea utils: go on to parse the line number even if the column number is bad
This fixes https://savannah.gnu.org/bugs/?49933.
2016-12-26 11:45:38 +01:00
Benno Schulenberg c24caf5fb8 tweaks: rename four variables, for density and aptness 2016-12-26 11:01:40 +01:00
Benno Schulenberg 8db21b68d5 tweaks: use memory on the stack instead of calling malloc() and free() 2016-12-26 10:39:48 +01:00
Benno Schulenberg cb31e45f6c tweaks: remove pointless or obscuring asserts 2016-12-26 10:29:57 +01:00
Benno Schulenberg 588daf949e tweaks: condense the setting of three flags 2016-12-25 13:11:17 +01:00
Benno Schulenberg d21a9c8fc3 text: discard the undo stack after formatting and after spell checking
After a call to the Formatter or the Alternate spell checker, the data
on the undo stack could refer to line positions that don't exist any
more -- the chance is small, but it is there.  So... throw the whole
undo stack away, to prevent undoing things wrongly or even crashing.

(Changes made with the internal spell checker can be undone and redone
without a problem -- nano keeps full track of those.  But the changes
made with a formatter or an external spell checker happen in another
process, so nano has no record of them.)

This fixes https://savannah.gnu.org/bugs/?49920.
2016-12-24 12:22:50 +01:00
Benno Schulenberg edbc1e5950 text: avoid a crash when a spell-checked line has gotten shorter
When using an external spell checker or formatter, the line with
the cursor might become shorter, which might result in the stored
cursor position being beyond the end-of-line.  So, when restoring
the x position, make sure to limit it to the length of the line.

This fixes https://savannah.gnu.org/bugs/?49923.
2016-12-24 12:22:17 +01:00
Benno Schulenberg dc18746cbd tweaks: retype, rename, and reshuffle a function 2016-12-23 13:51:58 +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 d49d4f7b56 history: search items *can* contain newlines -- encoded NUL bytes
Decode 0x0A bytes to 0x00 when saving the search history, and encode
them again when reading the file back in, to prevent nano from hanging
or aborting when encountering 0x00 on a line by itself.
2016-12-23 10:54:09 +01:00
Arturo Borrero González 2fbb71d555 syntax: nftables: add two new families, and add set references
Signed-off-by: Arturo Borrero González <arturo@debian.org>
2016-12-23 09:47:44 +01:00
Benno Schulenberg 66356ec7e2 screen: draw new content immediately, to prevent color flashes
After updating the color palette, the corresponding new window content
should be drawn immediately, before some other part of the code calls
doupdate(), to prevent the old content being shown in the new colors.

This fixes https://savannah.gnu.org/bugs/?49912.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2016-12-23 09:25:29 +01:00
Benno Schulenberg 4edc83c3c2 tweaks: move a setting to a better place -- it needs setting just once 2016-12-22 17:08:10 +01:00
Benno Schulenberg e6350aaba4 prompt: do not treat a leading newline in a filename specially
This fixes https://savannah.gnu.org/bugs/?49884.
2016-12-22 13:46:53 +01:00
Benno Schulenberg 8bf8682b17 binding: use the code for the Enter directly instead of a function call
And certainly don't return zero when the key wouldn't have been found,
because that would have meant jumping a word to the right.
2016-12-22 12:13:03 +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 90b959a677 history: avoid crashing when the positionlog file is malformed 2016-12-21 17:28:09 +01:00
Benno Schulenberg 116d9e6f01 chars: use memory on the stack instead of calling malloc() and free() 2016-12-20 10:05:09 +01:00
Benno Schulenberg 6620acbff4 tweaks: use a faster comparison 2016-12-20 10:03:53 +01:00
Benno Schulenberg 1cb6619d6a undo: there are just two forms of deletion: backspacing and deleting
A third method does not exist.
2016-12-19 21:18:43 +01:00
Benno Schulenberg 79a4bf81dc tweaks: rename five variables, for uniformity with a few others 2016-12-19 19:58: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 2bcc6d7f66 tweaks: start searching at a better place
Taking the terminating newline into account, and that there is
at least one digit per number.
2016-12-19 09:57:31 +01:00
Benno Schulenberg cd705a7c4c tweaks: elide a counter and a comparison
For clarity and a tiny bit more speed.  Also rename some variables.
2016-12-19 09:44:30 +01:00
Benno Schulenberg ecd18c1694 history: search for the two position numbers from EOL instead of BOL
A filename might contain spaces, so we can't look for the numbers
(the second and third elements) starting from the head of the line
-- we have to start at the tail and work backward.

This fixes https://savannah.gnu.org/bugs/?49879.
2016-12-18 19:57:33 +01:00
Benno Schulenberg bc8a3a50a4 tweaks: rename three variables, for visibility
(I don't /see/ single-letter variables -- they are too small.)
2016-12-18 19:31:11 +01:00
Benno Schulenberg 9b90ec877a tweaks: drive closer to the edge 2016-12-18 17:56:18 +01:00
Benno Schulenberg 8b483c10ba history: don't bother encoding search items -- they cannot contain newlines 2016-12-18 17:55:39 +01:00
Benno Schulenberg f915a28d30 tweaks: don't bother trimming the final newline from a position item
It is irrelevant -- the line is discarded as soon as the data has been
extracted.
2016-12-18 16:44:39 +01:00
Benno Schulenberg cb3fc8892a tweaks: rename a variable and rewrap two lines 2016-12-18 16:34:19 +01:00
Benno Schulenberg 06d9ee89e5 history: encode newlines in filenames as nulls
So they will not break a line in the positionlog file in two.

(Strangely, the reading in of such a log file already decodes
nulls back into newlines.)

This fixes https://savannah.gnu.org/bugs/?49877.
2016-12-18 12:27:55 +01:00
Benno Schulenberg 0b0b812206 files: don't change embedded newlines into nulls in filenames
Because changing anything to a null effectively means to truncate
the name.

This fixes https://savannah.gnu.org/bugs/?49868
and fixes https://savannah.gnu.org/bugs/?49874.
2016-12-18 11:37:57 +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 40acb8714c oops: forgot to add and amend this to the previous commit 2016-12-18 11:12:04 +01:00
Benno Schulenberg d7af590c6b memory: don't bother making a snug fit for things that will be freed soon
Most full paths are needed only temporarily and will be freed within
milliseconds.  Only 'full_operating_dir' and 'backup_dir' continue to
exist for the whole current session.  Any partition, too, will soon be
unpartitioned, so the extra reallocation is just a waste of time.
2016-12-18 10:33:30 +01:00
Benno Schulenberg 8c7e4f5108 tweaks: rename a function to describe what it does
It doesn't align anything -- any allocations are already aligned to
whatever multiple is required -- it just shrinks the allocated space.
2016-12-18 10:30:35 +01:00
Benno Schulenberg 1144d38316 tweaks: don't bother reallocating a string of which there is only one
And which normally is just some ten or twenty characters long, and
never gets wildly overallocated.
2016-12-18 10:28:30 +01:00
Benno Schulenberg 0562d27b9c tweaks: delete a bunch of unneeded asserts
Nano would crash straight afterward if any of these asserts would fail,
so they don't add anything.  A few others are simply superfluous.
2016-12-15 21:15:32 +01:00
Benno Schulenberg c5f49167ea tweaks: write two pieces of conditionalized code like all others
Also trim or improve a few comments.
2016-12-15 19:48:09 +01:00
Benno Schulenberg 9765c2faa0 tweaks: elide a function that is called just once 2016-12-15 19:28:43 +01:00
Benno Schulenberg 85ebe971e2 chars: optimize for the most common case
That is: elide a second test from the most travelled path: a valid
character.  This adds a second call of mblen() when parse_mbchar()
is called on a terminating zero, but that should never happen.
2016-12-15 17:44:18 +01:00
Benno Schulenberg fc101a6ded tweaks: rename a variable to be shorter and clearer 2016-12-15 15:50:07 +01:00
Benno Schulenberg eb88ad980a tweaks: use a slightly faster comparison 2016-12-15 13:15:46 +01:00