Commit Graph

1149 Commits (8f24ffaaef005b6d8e95b312fa575559d503be81)

Author SHA1 Message Date
Benno Schulenberg 96e4fec31c tweaks: use a boolean instead of an enumeration of two values 2020-12-19 16:40:21 +01:00
Benno Schulenberg a3a1391a51 tweaks: rename two variables, one for contrast, another for visibility
Also normalize two bits of whitespace.
2020-11-30 13:32:22 +01:00
Benno Schulenberg d3d2d324d2 statusbar: properly pluralize the line+word+character count report
This avoids poor wordings such as "Words: 1  Lines: 1  Chars: 1".

Also, display the numbers in a more logical, ascending order: lines
first, words second, characters third.  This is what 'wc' uses, too.
2020-11-21 15:25:23 +01:00
Benno Schulenberg 7f184ee2ba linting: avoid putting the cursor beyond the end of the line
Some linters report a column position (assuming a TAB to be 8 spaces)
instead of a byte index, so make sure that the cursor is not placed
out of bounds when interpreting such a column number as an index.

This fixes https://savannah.gnu.org/bugs/?59419.
Reported-by: Ava McWhorter <qwerty0s.e.m@gmail.com>

Bug existed since version 2.8.1, commit 2439e1e4.
2020-11-06 10:36:08 +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 620496f5cd build: avoid two compiler warnings when gnulib has been ripped out 2020-09-14 11:02:31 +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 5c63975097 tweaks: rename four variables, reshuffle them, and correct one type
Also, drop three unneeded comments.
2020-08-25 12:13:55 +02:00
Benno Schulenberg fee905a34a tweaks: drop the unneeded saving and restoring of a global variable
The two functions findnextstr() and do_replace_loop() do not change
or even touch 'last_search', so there is no need to save and then
restore its value when doing corrections of misspelled words.
2020-08-25 11:58:04 +02:00
Benno Schulenberg 0f8423eb4c tweaks: elide an unneeded variable
Storing the orientation of the marked region beforehand is not needed,
as this orientation is readily available also after the justification.

(By the way, cursor and mark need to be swapped after justifying
a backward-marked region because the rule is that the cursor gets
placed *after* the justified paragraph.  Maybe that should change?)
2020-08-22 19:35:48 +02:00
Benno Schulenberg b2ea7d29d0 build: fix compilation for --enable-tiny --enable-nanorc --enable-color 2020-08-11 20:10:40 +02:00
Benno Schulenberg d7b2b55bf5 display: show the cursor position also right after the screen is resized
Bug existed since commit 8e226a9f from half an hour ago.
2020-08-10 12:16:18 +02:00
Benno Schulenberg 8e226a9f28 verbatim: do not report "Invalid code" when the terminal is resized
During verbatim input at most four integers are produced (the longest
possible unicode sequence), so use the value 999 to indicate a special
condition (a screen resize) that should not enter anything into the
buffer AND should not produce any error message or beep.

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

Bug existed since version 5.0, commit 5899181a.
2020-08-10 11:42:09 +02:00
Benno Schulenberg 4ec96f9f2e tweaks: reshuffle a few lines, to condense the code, and improve comment 2020-08-10 07:53:41 +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 65da6341ba tweaks: avoid a maybe-uninitialized-variable warning from gcc 2020-08-04 17:08:02 +02:00
Benno Schulenberg 551a971e16 tweaks: reshuffle four lines, for esthetics 2020-08-03 11:36:35 +02:00
Benno Schulenberg c2b6eb01cd feedback: use three dots to indicate processing, like everywhere else
For all occurrences, run:  grep '\.\.\."))' src/*.c
2020-08-03 11:33:28 +02:00
Benno Schulenberg e9e26934ea speller: give startup feedback (relevant when running on a Linux console)
This fixes https://savannah.gnu.org/bugs/?58856.

Bug existed since version 4.8, commit 8b2f7bd5.
2020-08-03 11:21:19 +02:00
Benno Schulenberg 6fa81ca5b8 formatter: force the mark off, to not crash by accessing empty cutbuffer
More generally, after invoking the formatter, the entire buffer should
be cut (to be replaced with the reformatted text) and not just the part
before the mark, because then everything after it would be duplicated.

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

Bug existed since version 4.9, commit 19517fc5.
2020-08-02 19:29:31 +02:00
Benno Schulenberg 844f95e6df speller: give proper feedback when the user tries to check emptiness
(The wording is general, because it should cover also the formatter.)

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

Bug existed since version 4.6, commit d2fb371f.
2020-08-01 20:57:23 +02:00
Benno Schulenberg 67d22f4cce tweaks: simplify two functions, as they now return always NULL 2020-08-01 19:00:07 +02:00
Benno Schulenberg 59bbc0b858 tweaks: print error message directly instead of passing it to the caller
This will allow a simplification in the next commit.
2020-08-01 11:50:55 +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
Benno Schulenberg 0e1f7fe2ef tweaks: normalize the indentation, and regroup two lines 2020-07-31 20:39:28 +02:00
Benno Schulenberg 3eff34b075 speller: re-enter curses mode before trying to report an error
If forking fails, we must first return to curses mode before we can show
an error message on the status bar.  (This additionally requires storing
the error number, because doupdate() apparently sets it to zero.)

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

Bug existed since version 4.8, commit 61197563.
2020-07-31 20:28:10 +02:00
Benno Schulenberg 60d31d2ea6 tweaks: avoid a warning about an unused variable in the tiny version 2020-07-16 12:41:01 +02:00
Benno Schulenberg 727abceb0f tweaks: adjust comments and indentation after the previous change 2020-07-06 16:59:35 +02:00
Benno Schulenberg 5899181a31 verbatim: show an error message when an invalid Unicode code is entered
The codes from (for example) U+D800 to U+DFFF are invalid.  If any
such invalid code is entered at the Unicode Input prompt, nano should
not act as if the code was accepted and inserted into the buffer, and
should certainly not mark the buffer as Modified.

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

Bug existed since version 4.9, commit b3faf353.
2020-07-06 16:47:23 +02:00
Benno Schulenberg 940a17268b speller: take into account that statting a file can fail [coverity] 2020-07-05 17:21:56 +02:00
Benno Schulenberg abfde53945 tweaks: drop an unneeded assignment, and reshuffle a few lines
And reset the 'lastmessage' variable to a more fitting value.
2020-07-04 09:36:17 +02:00
Benno Schulenberg 2e6886406c tweaks: elide an unneeded global variable
The constant cursor display must be suppressed whenever a message
was printed to the status bar.  That is: whenever 'lastmessage' is
something other than 'VACUUM'.
2020-07-03 12:41:40 +02:00
Benno Schulenberg 712f68c697 options: add -O/--bookstyle to make leading whitespace mean new paragraph
Before version 2.9.8, nano would consider any line that started with
leading whitespace as the beginning of a new paragraph, and would thus
be unable to justify an indented piece of text (unless autoindent was
switched on).  I thought that this was too limiting and changed the
way nano detects and parses paragraphs.  It works fine in texts where
paragraphs occupy multiple lines, but breaks down for paragraphs of
a single line: nano merges those with adjoining lines.

Now, when -O or --bookstyle or 'set bookstyle' is used, nano will again
consider a line that begins with whitespace as the start of a paragraph
-- when 'autoindent' is OFF.

This addresses https://savannah.gnu.org/bugs/?57402.
Indirectly-reported-by: Sébastien Desreux <seb@h-k.fr>
Also-reported-by: Bill Kendrick <nbs@sonic.net>
2020-06-27 11:12:21 +02:00
Benno Schulenberg 8061a981b1 tweaks: correct two spelling mistakes [codespell] 2020-06-26 11:27:07 +02:00
Benno Schulenberg 096e36279f build: fix compilation for --enable-tiny --enable-color --enable-nanorc 2020-06-22 14:03:48 +02:00
Benno Schulenberg 0f0b620c65 build: fix compilation when configured with --disable-speller
Move two functions that are used by the formatter too
to between the proper #ifdef.

Problem existed since commit 8089f5ad from a month ago.
2020-06-22 08:42:49 +02:00
Benno Schulenberg b086d0bad0 tweaks: elide another parameter, relevant in just three menus
The parameter was referenced in just one place.  So, simply check for
the three relevant menus (and unrestricted mode) and be done with it.

This also has the pleasant effect that the menu name is now the first
parameter of do_prompt(), thus clearly indicating what prompt it is,
instead of having an opaque TRUE or FALSE value at the beginning.
2020-06-20 17:19:23 +02:00
Benno Schulenberg 90f6342fd1 tweaks: rename two header files, to be distinct and not an abbreviation 2020-06-20 12:09:31 +02:00
Benno Schulenberg 499b926b74 tweaks: elide a parameter that is relevant for only one menu (Goto Dir)
Instead of burdening seven other calls of do_prompt() with a useless
parameter, just check for MGOTODIR in the appropriate place.  It also
saves having to pass the parameter down through three more functions.
2020-06-19 10:55:28 +02:00
Benno Schulenberg 786d2221e1 indicator: recompute the extra rows also for cut/paste/split/join
This fixes https://savannah.gnu.org/bugs/?58511.

Bug existed since commit 9a9f36fc from yesterday.
2020-06-07 11:05:14 +02:00
Benno Schulenberg 9a9f36fca7 indicator: rework how the "scrollbar" is computed when softwrapping
Instead of storing for each line the ordinal number of the first chunk
in that line, simply store the number of extra chunks in the line.

It now takes some more computation to actually draw the scrollbar, but
it saves a lot of computation when just inserting or deleting characters
(when using --softwrap and causing a change in chunk count).

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

Bug existed since commit 6bccedb3 from two days ago.
2020-06-06 19:21:23 +02:00
Benno Schulenberg cd594b85f4 general: make five tools accessible through the "Execute Command" menu
Instead of creating a special Tools menu, add the five functions that
affect the whole buffer to the "Execute Command" menu.  There is room
for these five functions there, and they kind of fit in because three
of them (Speller, Linter, and Formatter) actually invoke an external
command, and Full Justify could have been implemented externally, and
the destructive Cut Till End ought to have required a double keystroke
since the beginning.
2020-05-30 18:56:51 +02:00
Benno Schulenberg 933dd567de tweaks: separate a symbol from its definition by two spaces
It's a little clearer, and new ones were like that already.
2020-05-29 18:45:14 +02:00
Benno Schulenberg 756b95748b tweaks: rename a struct element, to be shorter and preciser
And anyway, there are too many occurrences of 'current'.
2020-05-28 14:38:48 +02:00
Benno Schulenberg 8089f5ad54 build: do not let --disable-speller exclude also the formatter code
In the past, when Speller and Linter and Formatter were all bound
to ^T (later ones taking priority), it was easier to exclude also
the formatter code when --disable-speller was used.  But since the
formatter was reintroduced (in commit 34170611) and bound to its
own keystroke (M-F), this is no longer the case.
2020-05-24 12:08:50 +02:00
Benno Schulenberg 4bdd6013b0 anchor: do not let piping and spelling transfer an anchor to the top
Just let all anchors disappear when doing an external spell check or
formatting or piping the buffer through an external command, because
leaving just a single anchor on the top line is useless.

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

Bug existed since commit 732cf887 from one month ago.  That code
causes an anchor to persist at the point where lines are removed.
2020-04-30 16:51:22 +02:00
Benno Schulenberg 11f099e1da anchor: during full justification preserve anchors as during single ones
When a single paragraph is justified, any anchor on any of its lines
gets moved to its first line.  Let a full justification do the same
for each of the paragraphs.

This fixes https://savannah.gnu.org/bugs/?58272 in a better way.
2020-04-30 16:07:31 +02:00
Benno Schulenberg 703cebaaac anchor: do not let a full justification transfer an anchor to the top
This fixes https://savannah.gnu.org/bugs/?58272.

Bug existed since commit 732cf887 from one month ago.  That code
causes an anchor to persist at the point where lines are removed.
2020-04-29 19:34:48 +02:00
Benno Schulenberg 40053593a8 general: rename "bookmark" to "anchor", to sound less permanent 2020-04-13 11:25:29 +02:00
Benno Schulenberg 732cf88786 text: retain a bookmark when two lines are joined or something is cut
Also, do not copy the bookmark into the cutbuffer, so it will not get
pasted elsewhere.
2020-04-13 11:10:23 +02:00