Commit Graph

1207 Commits (7303f0c7b494c1a75758f6d353aed77894aa63d1)

Author SHA1 Message Date
Benno Schulenberg eb3cc3a32d minibar: stay out of sight when the terminal has just one row
When there is just one row, the user wants to see text on this row,
not a bar with some meta info.

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

Bug existed since version 5.5, since the minibar was introduced
with commit d31cc373.
2021-05-03 15:52:15 +02:00
Benno Schulenberg 6283557d2f memory: prevent a use-after-free when the user respects a lock file
This fixes https://savannah.gnu.org/bugs/?60447.

Bug existed since commit 2f718e11 from a month ago.
2021-04-23 12:20:45 +02:00
Benno Schulenberg 2cdff6c32c tweaks: adjust two comments, and reshuffle two fragments
Also rename two variables, to be more fitting.
2021-04-21 16:52:35 +02:00
Benno Schulenberg 49d8b99e4f softwrap: avoid time-consuming computations, to burden large files less
Whenever softwrap was toggled on or line numbers were toggled on/off or
the window was resized, the extra rows per line needed to be recomputed
for ALL the lines.  For large files with many long lines this was too
costly.

(This change causes the indicator to have an incorrect size when there
are many softwrapped chunks onscreen, but that will be addressed later.)

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

Problem existed since version 5.0, since the indicator was introduced.
2021-04-21 16:40:20 +02:00
Benno Schulenberg eb7181b35e tweaks: adjust and improve one comment, and frob another 2021-04-12 15:14:05 +02:00
Benno Schulenberg 8db42023bb files: when Mac format has been detected, stay with it
This fixes https://savannah.gnu.org/bugs/?60382.

Bug existed since commit 09b919a6 from three weeks ago.
2021-04-12 14:50:04 +02:00
Benno Schulenberg e3f46b066a build: fix compilation when configured with --disable-multibuffer 2021-03-26 12:21:44 +01:00
Benno Schulenberg 74fcc3be79 tweaks: normalize the indentation after an earlier change
(Should have been done yesterday, right after commit 2f718e11.)
2021-03-24 12:29:50 +01:00
Benno Schulenberg 823d79b36c tweaks: shorten a comment and trim an #ifdef 2021-03-24 12:16:10 +01:00
Benno Schulenberg 735757b0c1 tweaks: set the file format only when unset, so it doesn't need saving
When inserting a file into the current buffer, the 'fmt' element will
already be set.  When we avoid overwriting the current value of 'fmt'
(when it's other than UNSPECIFIED), we don't need to save and restore
the value when inserting a file.
2021-03-24 12:00:34 +01:00
Benno Schulenberg 09b919a68f files: always register the format, also when the file is unwritable
When saving the buffer under a different name, it should by default
have the same format as the original file.

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

Bug existed since version 2.6.0, commit 0293eac1.
2021-03-24 11:53:56 +01:00
Benno Schulenberg 2f718e11a7 files: create a new buffer earlier, so that error messages can be stored
This improves the fix for https://savannah.gnu.org/bugs/?60269,
by not dropping error messages that happen before a buffer is opened.

This basically reverts commit b63c90bf from a year ago, except that
it now always deletes the created buffer when the user does not want
to override the lock file, also when it is the only buffer.
2021-03-23 16:46:37 +01:00
Benno Schulenberg 77da54c6c6 startup: do not store an error message in the record of another buffer
Set the 'format' of a file only when it has been fully read in,
so that this field can be used to indicate that any later error
message cannot be meant for this buffer.

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

Bug existed since commit 6bf52dcc from yesterday.
2021-03-23 16:19:07 +01:00
Benno Schulenberg ede64d7ea0 feedback: upon first switch to a buffer, show its error message (if any)
When opening multiple files and some of them had an error, only the
first message was shown and the others were lost -- indicated only
by three dots.  Improve upon this by storing the first error message
for each buffer and showing this message when the buffer is first
switched to.

Requested-by: Mike Frysinger <vapier@gentoo.org>
2021-03-21 16:52:29 +01:00
Benno Schulenberg be9b1a1887 tweaks: avoid a warning on newer compilers, by writing an extra byte
When the version number is a trio, the version string will occupy
ten bytes and the terminating NUL byte would not be written (which
was not a problem as byte 12 of the lock data is zero anyway).
But it's better to not have the compiler complain, so allow writing
the terminating NUL byte outside of the ten bytes reserved for the
version string.
2021-03-03 10:47:41 +01:00
Benno Schulenberg 1fdd23d347 display: for a large paste or insertion, recalculate the multiline cache
When a large piece of text or code is pasted or inserted, it could
contain matches for start= and end= regexes, and backtracking from
the current screen could mistake an end for a start and could thus
miscolor things.  Avoid this by recalculating the multiline cache
for pastes and insertions that cover more than a screenful.

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

Bug existed since version 2.6.0, but existed also before 2.4.3.
2021-02-03 17:00:28 +01:00
Benno Schulenberg 6360e4170a copyright: update the years for the FSF 2021-01-11 14:22:51 +01:00
Benno Schulenberg a102e45e90 tweaks: elide a variable, by using a reallocation instead
Also unwrap a line.
2021-01-03 11:35:11 +01:00
Benno Schulenberg 86c9b9b54e files: when truncating a file name, give an indication of this
Show leading dots for the truncated part, or (if there is no room
at all) show just an underscore instead of the file name.

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

Bug existed since version 2.9.3, commit 97cbbb0c.
2021-01-03 11:32:14 +01:00
Benno Schulenberg ba4f4bdc64 minibar: show the line count in the bar (at startup and when saving)
Show the line count too when switching between buffers.
2020-12-23 12:17:06 +01:00
Benno Schulenberg b86f7868d1 feedback: differentiate between remarks, mistakes, and information
Remarks are about unsurprising things but it's good to give feedback
on them; "mistakes" are unexpected things, and get colored like an
error; and information is something that the user requested and thus
needs to stay on the status bar until the next keystroke.
2020-12-23 12:17:06 +01:00
Benno Schulenberg 96e4fec31c tweaks: use a boolean instead of an enumeration of two values 2020-12-19 16:40:21 +01:00
Benno Schulenberg e1601d2eb5 tweaks: use the standard symbols for the three standard file descriptors
Also, take into account (as elsewhere) that dup2() could fail,
and harmonize their error checks.
2020-10-10 12:32:02 +02:00
Benno Schulenberg bc14fc35d7 tweaks: reshuffle a line, elide two braces, and adjust the indentation
And improve a comment.
2020-10-08 15:07:03 +02:00
Benno Schulenberg f660f22623 tweaks: slightly shorten a loop, to place the actual action outside of it
And in the bargain elide a variable, and make it clearer
what the return value is at two early exit points.

[This change makes use of the fact that TRUE (successful write) == 1
and FALSE (failed write) == 0.  But this is already used twenty lines
earlier, for the other call of write_file().]
2020-10-08 15:07:03 +02:00
Benno Schulenberg e8abbc7045 build: stop using an obsolete macro, and use 'void' for signal handlers
The Autoconf manual says that 'AC_TYPE_SIGNAL' is obsolete and
that it is fine to simply use 'void' instead of 'RETSIGTYPE'.
2020-09-16 16:27:32 +02:00
Benno Schulenberg f883465263 build: exclude reading a file from standard input from the tiny version
The tiny version is about being small, not about convenience features
that hardly anyone uses anyway.

Also exclude the description of the "+line[,column]" feature -- it is
unneeded verbosity.

This addresses https://savannah.gnu.org/bugs/?59101.
2020-09-12 11:44:22 +02:00
Benno Schulenberg ba049fcaf8 tweaks: avoid a compiler warning when compiling with more than -O1 2020-09-11 18:59:04 +02:00
Benno Schulenberg b9a1a586c0 display: force the cursor to reappear in a better way (when using Slang)
The cursor would disappear after any message on the status bar --
for example, also when M-W is typed and nothing is found -- so the
mitigation trick needs to be performed in statusline() itself.

This addresses https://savannah.gnu.org/bugs/?59091.
2020-09-11 18:54:49 +02:00
Benno Schulenberg d2d0c665b1 display: force the cursor to reappear after a message (when using Slang)
For some reason, when running a tiny nano built with Slang on the bterm
of a Debian installer image, the cursor disappears when certain things
are written to the status bar.  Make the cursor reappear by rewriting
the two help lines with dummy items (and then rewriting it again with
the normal menu in the central loop).  Of course, this does not help
when the user uses -x or --nohelp to suppress the help lines, but at
least in the default setup the cursor doesn't get hidden now and then.

This mitigates https://savannah.gnu.org/bugs/?59091.

Bug existed since before version 2.2.4.
2020-09-10 18:46:48 +02:00
Benno Schulenberg bbc7c59563 browser: sort names that differ only in case with uppercase first
This is the opposite of what 'ls' does in a UTF-8 locale, but nano
has never followed the collating rules of Unicode (uppercase after
lowercase, ignoring punctuation, and so on) -- it would be strange
to change that now.

Until now, nano left such equivalent names unsorted, in a seemingly
random order.

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

Bug existed since before version 2.0.6.
2020-09-03 16:28:47 +02:00
Hussam al-Homsi c87bc1d55f tweaks: stop casting the return of malloc() and friends
Those casts are redundant, and sometimes ugly.  And as the types of
variables are extremely unlikely to change any more at this point,
the protection they offer against miscompilations is moot.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-08-31 12:17:27 +02:00
Benno Schulenberg 6469e9668b tweaks: condense two declarations 2020-08-19 16:52:28 +02:00
Benno Schulenberg d7c2b98ead feedback: when creating a pipe fails, report also the reason
After commit 59bbc0b8 from five days ago (that made a divergent pipe
failure to be treated in the same way as the other two), this became
possible without having two different pipe-failure messages.
2020-08-06 08:47:52 +02:00
Benno Schulenberg 312bcebf44 files: do not try writing to the status bar while not in curses mode
Between an endwin() and a doupdate() there should be no calls of
statusline() or statusbar() -- these two functions may be called
only when in curses mode.

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

Bug existed since version 4.3, commit 57390cff.
2020-08-02 10:29:29 +02:00
Benno Schulenberg 731fd935ff feedback: add the reason to the error message when forking fails
This makes all the "Could not fork" messages the same again
after the change in commit 3eff34b0 from yesterday.
2020-08-01 11:34:23 +02:00
Michalis Kokologiannakis d0ad1e42d9 files: ignore only EPERM when fchmod() or fchown() fails
While ignoring permission errors from fchmod() and fchown() is okay
(since normal users are not always privileged to make such changes),
ignoring also more serious errors (like EIO) is not ideal.

Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-07-30 09:48:12 +02:00
Benno Schulenberg 7475b4d3bf tweaks: reshuffle a few lines, and remove a few unneeded comments 2020-07-28 19:12:02 +02:00
Benno Schulenberg fd667b5191 tweaks: add four more translator hints 2020-07-27 10:33:42 +02:00
Benno Schulenberg 7157f5a3ce tabbing: properly terminate the answer when the sole match is a folder
When there is just one match when <Tab> is pressed, and this match
is a directory, then a slash is added to 'shared', overwriting the
terminating NUL character.  So, strcpy() cannot be used for copying
this 'shared' string, but strncpy() is needed, and the result needs
to be NUL terminated afterward.

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

Bug existed since commit b0f56398 from eleven days ago.
2020-07-25 13:25:48 +02:00
Benno Schulenberg d0501d0ebd tweaks: update a translator hint, and add another 2020-07-22 11:38:29 +02:00
Benno Schulenberg 180a53cc0c files: warn the root user when all the write bits are missing
Root has carte blanche to both read unreadable files and write
unwritable files -- the file system does not prevent this.  So,
alert root when opening a file that is intended to be read-only.

This fulfills https://savannah.gnu.org/bugs/?58685.
Requested-by: Marius Bakke <mbakke@fastmail.com>
2020-07-20 10:26:45 +02:00
Benno Schulenberg dcd34b246a tweaks: move a function to the file where it is used the most
Also, fully exclude the function from the tiny version.
2020-07-19 10:43:26 +02:00
Benno Schulenberg b0dcb15f94 tweaks: elide a function that is too sparse
The two calls of the function can be replaced with two lines each.
2020-07-17 18:40:34 +02:00
Benno Schulenberg 7dbfbbb8d6 tweaks: reshuffle a few lines, for conciseness 2020-07-17 17:13:43 +02:00
Benno Schulenberg 4cefd699ca tweaks: shorten an error message, to be appropriate in all situations
Saying "Cannot write backup %s" is misleading when it is the original
file that cannot be reread.
2020-07-17 17:10:46 +02:00
Benno Schulenberg 8eddf7bc26 tweaks: reshuffle a condition, to avoid a repetition of code 2020-07-17 16:53:48 +02:00
Benno Schulenberg 2623f39c7b backup: when rereading the original file fails, ask the user what to do
Rereading is unlikely to fail, but *if* it fails, maybe there is a
serious problem and the user wants to try and fix it before saving
the buffer and thus overwriting the original file.
2020-07-17 16:50:25 +02:00
Benno Schulenberg da71322000 tweaks: rename two labels, for brevity 2020-07-17 16:24:53 +02:00
Benno Schulenberg 292e505e01 tweaks: rename two variables, to avoid a repetitive prefix
Also, fold a condition into an assignment, for conciseness.
2020-07-17 16:23:22 +02:00