Commit Graph

1192 Commits (7c6d3942c495461a9f22a4c4552b338c41b57dfc)

Author SHA1 Message Date
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
Benno Schulenberg 654d694e39 tweaks: simplify the counting of characters in a section
The line after the given section is always NULL (or when it is not,
it is intended to be NULL), so always subtract 1 at the end.
2020-04-09 12:58:41 +02:00
Benno Schulenberg 19a6120dc8 tweaks: rename a function, to be more general and clearer 2020-04-09 12:27:07 +02:00
Benno Schulenberg 845a5973c9 counting: count words and characters without partitioning the file 2020-04-05 17:29:54 +02:00
Benno Schulenberg 9a67d7958f undo: choose the proper x positions to place the cursor and rejoin lines
Normally, when undoing an <Enter> that created automatic indentation,
the created whitespace should be skipped when rejoining the two lines.
In other words: take the data starting from tail_x in the second line.
But when the <Enter> occurred at the end of leading whitespace, then
that whitespace has disappeared from the original line and it should
be copied back in from the second line.  That is: from x is zero.

This fixes https://savannah.gnu.org/bugs/?58108.
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since version 4.9, commit 1961c052.
2020-04-03 11:21:24 +02:00
Benno Schulenberg d1521c584d tweaks: elide a now-unused parameter -- it is always FALSE 2020-03-30 16:55:30 +02:00
Benno Schulenberg 59040169ed tweaks: get rid of a bunch of annoying casts, and thus condense the code 2020-03-29 20:17:32 +02:00
Benno Schulenberg 619962ee18 undo: when undoing a line cut, place the cursor back where it was
This fixes https://savannah.gnu.org/bugs/?58074.

Bug existed since version 4.9, commit ac612545.
2020-03-29 14:25:15 +02:00
Benno Schulenberg 7ebe44ac25 tweaks: rename a symbol, to be more accurate, and reshuffle two lines 2020-03-29 14:24:16 +02:00
Benno Schulenberg 0cc2104257 tweaks: elide a parameter, by calling the relevant function beforehand
This means that in most cases mark_is_before_cursor() is called twice:
once before get_region() is called, and once by get_region() itself.
This small duplication of effort is acceptable: the affected functions
are not time critical, and it makes the code shorter.
2020-03-29 13:22:17 +02:00
Benno Schulenberg 6866ea0d0e justify: skip over in-line whitespace only, not over leading whitespace
This fixes https://savannah.gnu.org/bugs/?58028.

Bug existed since commit 107abd26 from yesterday.
2020-03-23 11:00:17 +01:00
Benno Schulenberg 34d38fe1c6 undo: treat a cut-until-end-of-buffer like a backward marked region
This fixes https://savannah.gnu.org/bugs/?58024.

Bug existed since commit ac612545 from two weeks go.
2020-03-22 19:16:22 +01:00
Benno Schulenberg b17309b652 tweaks: when extending the marked region, include also exotic blanks
Just in case someone uses multibyte whitespace characters.
2020-03-22 18:45:46 +01:00
Benno Schulenberg 107abd2654 justify: skip over blanks after the region, to not skew the indentation
This fixes https://savannah.gnu.org/bugs/?58023.

Bug existed since commit 3225c71e from six days ago.
2020-03-22 17:48:39 +01:00
Benno Schulenberg 71628ad0b8 build: fix compilation for --enable-tiny --enable-justify 2020-03-22 13:41:28 +01:00
Benno Schulenberg bc6645f753 tweaks: move two functions to before the ones that call them 2020-03-19 15:12:40 +01:00
Benno Schulenberg 01d8b0e15d help: increase the minimum help-text width from 32 to 40 columns
Getting long words like "Rechtschreibprüfung" broken somewhere in
the middle doesn't look nice.
2020-03-15 14:04:57 +01:00
Benno Schulenberg 16f17f3f1b help: do not break a line inside the 17-column keystrokes area
When the description of a keystroke starts with a very long word,
or when it does not contain any spaces at all (like for Chinese
and Japanese), do not break in the blanks before the description
but instead break IN the description, at the edge of the screen.

In other words: when wrapping a help text, do not consider blanks in
the first 17 columns to be blanks (unless it is a continuation line).

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

Bug existed since version 4.8, commit 1486f32d,
when the wrapping of help texts was improved.
2020-03-15 13:59:04 +01:00
Benno Schulenberg 6d720bf7b2 tweaks: improve two comments, and remove an unneeded one 2020-03-12 17:18:10 +01:00
Benno Schulenberg f3b030c8e5 tweaks: condense a fragment of code
Leave the skipping of subsequent blanks to the succeeding code.
2020-03-12 16:59:27 +01:00
Benno Schulenberg 6b8b7c9d55 tweaks: elide a supporting variable, to make four loops slightly faster
At the cost of making the return statements slower.  But, all-in-all,
this should be slightly quicker.
2020-03-12 16:47:39 +01:00
Benno Schulenberg f6dedf3598 tweaks: rename another function, to remove the obscuring abbreviation 2020-03-12 15:54:19 +01:00
Benno Schulenberg 8003842e5c tweaks: rename a function, to remove an obscuring abbreviation
The "mb" made the name harder to read.  Also, the function is
not only for multibyte characters but for any character.
2020-03-12 15:53:49 +01:00
Benno Schulenberg 01477d3b81 justify: never break a line in leading whitespace
This fixes https://savannah.gnu.org/bugs/?57984.

The bug was old -- it existed since at least version 2.0.6.
2020-03-12 10:15:57 +01:00
Benno Schulenberg 304548ef82 tweaks: rename two functions, to match the style of others 2020-03-11 19:45:06 +01:00
Benno Schulenberg c2f007afc5 tweaks: trim an unnecessary detail from an error message 2020-03-11 14:23:22 +01:00
Benno Schulenberg 8dc83951ee tweaks: normalize a translator hint, update one, and add another 2020-03-11 14:21:08 +01:00
Benno Schulenberg b7dc5abca7 tweaks: rename two more variables, to harmonize with two others 2020-03-11 12:53:39 +01:00
Benno Schulenberg 8b784785ec tweaks: rename two variables, for distinctiveness 2020-03-11 12:23:07 +01:00
Benno Schulenberg 750b51c343 copyright: update to the current year for significantly changed files 2020-03-11 11:52:15 +01:00
Benno Schulenberg 70a765e387 feedback: give a clearer message when trying to justify an empty region
Also, increase the level of the message, as trying to justify an empty
selection is a user error.
2020-03-10 15:58:30 +01:00
Benno Schulenberg 9d499c769b justify: do not take an empty line as template for first-line indentation
This fixes https://savannah.gnu.org/bugs/?57437.
2020-03-10 10:56:05 +01:00
Benno Schulenberg dad2b5541e tweaks: rename a variable, for aptness 2020-03-10 10:50:27 +01:00
Benno Schulenberg 56960ce05e tweaks: reshuffle some stuff, to have related things together
Also for compactness, and not to use 'lead_len' for two purposes.
2020-03-10 10:45:46 +01:00
Benno Schulenberg e247be69bf justify: when the cursor is at the left edge, keep it there
Only when the endpoint of the selection is actually IN a leading part,
then it should be advanced to include the whole leading part, so that
the succeeding paragraph will get the proper first-line indentation.
2020-03-10 10:32:21 +01:00
Benno Schulenberg e209686835 justify: give the first line of a marked region its proper indentation
When justifying a selection from the middle of a paragraph, the first
line of both that selection and of the new paragraph after it should
get the same indentation as the first line of the original paragraph.

This fulfills https://savannah.gnu.org/bugs/?56308.
2020-03-10 10:29:49 +01:00
Benno Schulenberg 047936c338 tweaks: reshuffle an assignment and a free() 2020-03-09 14:28:57 +01:00
Benno Schulenberg ca0571ea52 tweaks: remove an unneeded indirection
The concatenating function does not change the passed linestruct.
The data yes, but not the linestruct itself.
2020-03-09 14:25:41 +01:00
Benno Schulenberg 655cf9573f tweaks: always determine the second lead, to simplify the rewrap call
Also rename some variables.
2020-03-09 14:11:47 +01:00
Benno Schulenberg c457f744ef justify: trim the leading blanks of a marked region at the right moment
This fixes https://savannah.gnu.org/bugs/?57977.

Bug existed since commit 5310a355 from three hours ago.
2020-03-09 14:05:18 +01:00
Benno Schulenberg 8f3ea23ece tweaks: rename a variable, to not be a substring of a function name 2020-03-09 12:31:10 +01:00
Benno Schulenberg 3225c71ecd justify: when appropriate, move end point of marked region forward
So that also the line after the newly made paragraph gets the
leading part that belongs to the start of a new paragraph.

This https://savannah.gnu.org/bugs/?57974.

Bug existed since version 4.0, since the justifying
of a marked region was introduced.
2020-03-09 12:15:01 +01:00
Benno Schulenberg 5310a355ef tweaks: reshuffle the trimming of leading whitespace, for compactness 2020-03-09 11:43:50 +01:00
Benno Schulenberg d7875cdf4f tweaks: when appropriate, move starting point of justified region back
This makes things simpler, so that I can understand them.
2020-03-09 11:33:16 +01:00
Benno Schulenberg dc05defb8a tweaks: rename four variables, to be a bit more telling 2020-03-09 11:10:07 +01:00
Benno Schulenberg 98c11d0a82 tweaks: reshuffle some code, in preparation for improving it 2020-03-09 11:09:56 +01:00
Benno Schulenberg 14f1652842 tweaks: move a function to its proper place in the order of things 2020-03-09 09:44:43 +01:00
Benno Schulenberg d4b97a08cd tweaks: elide a variable and an unneeded iteration 2020-03-08 16:55:02 +01:00
Benno Schulenberg c934c1d71b justify: trim prefixed whitespace when justifying a marked region
This fixes https://savannah.gnu.org/bugs/?56307.

Bug existed since version 4.0, when the justifying
of a marked region was introduced.
2020-03-08 16:18:34 +01:00
Benno Schulenberg a16315a65f tweaks: remove a redundant statement, a spurious reference to 'cutbottom'
This assignment should have been removed in commit f5ac8c1e from
six years ago, as it became superfluous then.  Later changes made
'cutbottom' become valid only when something had actually been cut.
2020-03-08 15:50:55 +01:00
Benno Schulenberg d6beca5dcf justify: do not copy too many bytes when trimming leading whitespace
This fixes https://savannah.gnu.org/bugs/?57972.

Bug existed since version 4.0, commit 877a6498.
2020-03-08 15:09:40 +01:00
Benno Schulenberg 9d7e62be1a tweaks: rename two variables, to be different or for more contrast
Also, invert the logic of the second.
2020-03-08 14:12:45 +01:00
Benno Schulenberg 5c008726f0 tweaks: rename two variables, to harmonize with two others 2020-03-08 14:04:29 +01:00
Benno Schulenberg 8c506d86af tweaks: rename two variables, to suit both the marked and unmarked case 2020-03-08 13:57:04 +01:00
Benno Schulenberg db7a49edc6 tweaks: create an undo item earlier, and discard it when needed
This avoids having to temporariyly store and then later fill in
the original cursor position.
2020-03-08 13:40:38 +01:00
Benno Schulenberg 2428c5cbe6 tweaks: strip a parameter that is equivalent to 'openfile' for both calls 2020-03-08 12:54:47 +01:00
Benno Schulenberg 01bc0148c0 tweaks: strip a parameter that is TRUE for both calls
The parameter has been redundant since version 4.0, commit d54840c1,
when the last call with FALSE was removed.
2020-03-08 12:48:41 +01:00
Benno Schulenberg a92511ceaf tweaks: move another function to where it is used 2020-03-06 18:52:42 +01:00