Commit Graph

1071 Commits (750b51c34337c54bf875881848dd0ef3c11cd469)

Author SHA1 Message Date
Benno Schulenberg 954cab81b4 tweaks: improve and condense some comments, and remove an unneeded one 2019-03-19 21:13:34 +01:00
Benno Schulenberg 43c6bc6619 tweaks: add a consistency check plus a corresponding warning
Since commit 4c6ec637 from about half a year ago, the 'action' parameter
of update_undo() is unused.  Verify that this parameter matches the type
of the item at the top of the undo stack, so that in another half year
the parameter can be safely removed.
2019-03-17 20:51:43 +01:00
Benno Schulenberg e0fab690cc tweaks: don't pass a pointer when a boolean is expected
For some reason, when configured with --with-slang, some extra compiler
warnings are enabled that are not enabled by --extra-warnings.  :|
2019-03-17 19:13:24 +01:00
David Lawrence Ramsey 37be9b54ca justify: initialize a variable before making use of its value
When the mark is off, initialize not just 'bot_x' but also 'top_x'.

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

Bug existed since the justifying of a marked region was introduced,
four days ago, with commit f7f5514e.
2019-03-14 11:48:07 +01:00
Benno Schulenberg a20340b5a8 copyright: update the years for significantly changed files 2019-03-10 17:03:42 +01:00
David Lawrence Ramsey 932a35c072 tweaks: normalize the indentation, and remove unneeded braces 2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 877a649819 justify: when justifying a marked region, strip whitespace after the lead
This matches Pico's behavior.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 5d7b723c16 justify: put a mid-line marked region onto separate lines
This matches Pico's behavior.  However, Pico doesn't add the quoting +
indentation to the line in which the selection ends, but this is wrong,
so nano does add it.  Also, Pico doesn't account for partial quoting +
indentation at the start or end of a selection, but this is wrong, so
nano does.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 053244db70 justify: handle the leading part when justifying a marked region
Unlike a regular paragraph, marked text may have different quotes and
more than two types of indentation.  Handle this by replacing deviant
quotes with the quote of the first line, and deviant indentation with
the indentation of the second line.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey f7f5514eef new feature: marked text gets justified into a single, new paragraph
This is modelled after Pico's behavior.  However, Pico won't do anything
if you do a full-justify while the mark is on.  But this is unnecessarily
limiting, so, when the mark is on, nano will handle a full-justify and a
plain justify the same.

This currently does not handle the lead (quoting + indentation) in
justified selections, does not put mid-line justified selections onto
separate lines, and does not strip whitespace after the lead in justified
selections, the latter two of which Pico does.  These behaviors are
forthcoming.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey afa0097ceb tweaks: rename a variable, to prepare for its new role 2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 6e960012c2 tweaks: split justify_paragraph() into three separate functions
concat_paragraph() concatenates a paragraph into a single line, and
rewrap_paragraph() rewraps that line into multiple lines again.

These two will be needed when the justifying of marked text is added.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 311a7138b2 tweaks: adapt find_paragraph()/justify_paragraph() for multiple quotes
Instead of passing 'quote_len' to these functions, calculate it directly
in them.

This will be needed when the justifying of marked text is added.  When
unmarked text is justified, it is a single paragraph and by definition
has a uniform quoting part.  But marked text may be a jumble of lines
that have different quoting parts.
2019-03-10 09:22:02 +01:00
David Lawrence Ramsey 0ac04347d5 tweaks: remove unnecessary variable initializations 2019-03-10 09:22:02 +01:00
David Lawrence Ramsey f13dd140eb display: correctly trim an overshooting character from a prompt answer
Tell display_string() explicitly when we're at a prompt, instead of
letting it glean this from the current menu not being MMAIN, which
fails in some circumstances.

This improves the fix for https://savannah.gnu.org/bugs/?55620,
fixes https://savannah.gnu.org/bugs/?55680 in a better way,
and fixes https://savannah.gnu.org/bugs/?55773.
2019-02-28 19:47:55 +01:00
Benno Schulenberg 70da1889ee feedback: complete the removal of some superfluous words
This should have been part of commit 1053a3c4.
2019-02-25 10:04:10 +01:00
Benno Schulenberg 79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg 1053a3c440 feedback: remove some superfluous words from Undid/Redid messages
Also, change some words to nouns, to fit the scheme.
2019-02-24 16:27:47 +01:00
Benno Schulenberg d3fdd20471 tweaks: rename an overlooked variable from a single letter to a word 2019-02-20 17:39:04 +01:00
Benno Schulenberg b6a762232e tweaks: switch from referencing NO_NEWLINES to referencing FINAL_NEWLINE 2019-02-19 19:45:55 +01:00
Benno Schulenberg 54055b6174 tweaks: switch from referencing NO_WRAP to referencing BREAK_LONG_LINES 2019-02-19 19:45:55 +01:00
Benno Schulenberg ebfe752841 tweaks: rename some variables from a single letter to meaningful word 2019-02-12 16:06:24 +01:00
Benno Schulenberg 14f32577ee display: ensure that spotlighted text is not treated as a prompt answer
When doing replacements or fixing misspelled words, and edit_refresh()
is called to highlight the relevant word, then the current menu can be
anything from MREPLACEWITH, MYESNO, MSPELL, or MMAIN.  Make sure it is
always set to the latter just before calling edit_refresh(), so that
display_string() will use the full length and the word gets properly
highlighted.

This fixes https://savannah.gnu.org/bugs/?55680.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>

Bug was introduced by the previous commit, 56181896.
2019-02-12 15:07:55 +01:00
Benno Schulenberg 0ae80ce362 tweaks: reduce two parameters to a single one by summing them
Also, rename the remaining parameter and rename a variable.
2019-01-06 17:56:46 +01:00
Benno Schulenberg f74a120803 tweaks: refer to the magic line as "magic line", not as "magicline" 2019-01-06 15:35:31 +01:00
Benno Schulenberg 4104376e7c tweaks: rename a variable, elide another, and adjust two comments
Also, adjust the type of a parameter to 'size_t', as it is a
character index.
2019-01-02 18:05:58 +01:00
Benno Schulenberg ffa0a9ef64 tweaks: calculate the length of a completion word in a more direct way 2019-01-02 17:44:15 +01:00
David Lawrence Ramsey eef6b2b442 tweaks: use proper variable types in the word-completion functions
Use 'size_t' for character indexes, and 'ssize_t' for the threshold.
2019-01-01 17:48:23 +01:00
Benno Schulenberg 16c20ad873 tweaks: move the character/word-deletion functions to a better location
Having all the cutting and deleting functions together in one file
kind of makes sense.
2019-01-01 17:48:02 +01:00
Benno Schulenberg f9bb5382aa tweaks: reshuffle and frob a couple of comments, and reindent two lines 2019-01-01 17:33:10 +01:00
Benno Schulenberg 329b82d284 undo: set the correct file size for a redo of a character deletion
The reduced file size should be stored not just when joining two lines
but also when simply a character in the middle of a line is deleted.

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

Bug existed since version 2.5.0, commit 66e21416.
2019-01-01 12:35:53 +01:00
David Lawrence Ramsey d0982536a7 undo: after undoing a cut, don't remove the magicline if we're on it
This fixes https://savannah.gnu.org/bugs/?55332.
2018-12-31 14:10:02 +01:00
Benno Schulenberg fb4ce71cfc tweaks: correct a comment typo, and trim a few other comments 2018-12-30 18:00:28 +01:00
David Lawrence Ramsey 7e152f2a48 undo: when undoing a cut, remove also the magicline if it added one
Reuse the WAS_FINAL_LINE flag to signal a cut that added a magicline,
for both a marked cut and cut-to-eof.

This fixes https://savannah.gnu.org/bugs/?55305.
2018-12-30 11:37:46 +01:00
David Lawrence Ramsey 8854ddb728 undo: set and check 'xflags' in a bitwise manner
This allows multiple flags to be set, which will be needed for the
next commit.
2018-12-30 11:36:49 +01:00
Benno Schulenberg b1b2369541 tweaks: rewrap a line and improve a few comments 2018-12-26 15:11:20 +01:00
Benno Schulenberg 8a88cea256 tweaks: elide a variable that is a copy of another 2018-12-26 14:56:29 +01:00
Benno Schulenberg 6f23d9c18c tweaks: rename a variable, because it also serves as "last line" 2018-12-26 14:37:36 +01:00
Benno Schulenberg dfbffff4b0 tweaks: remove a superfluous incrementing and decrementing of a variable 2018-12-26 14:28:54 +01:00
Benno Schulenberg ea73d7fd70 tweaks: condense a couple of comments and rewrap a few lines 2018-12-26 14:26:54 +01:00
David Lawrence Ramsey 77bd8c2630 tweaks: swap the names of the variables 'wrap_at' and 'fill'
Now 'fill' contains the original specified value,
and 'wrap_at' the column that 'fill' translates to.
2018-12-18 19:50:59 +01:00
David Lawrence Ramsey 6e3b9ac058 options: exit on a bad quoting regex, instead of crashing later
The paragraph-jumping functions used the regex unverified...

This fixes https://savannah.gnu.org/bugs/?55169.
2018-12-11 10:29:29 +01:00
Benno Schulenberg 41c561c5cf tweaks: schedule a call of edit_refresh() instead calling it directly
The direct call was a leftover of the old unjustify mechanism.

Also, move two statements to the end of the do_justify() routine,
since that is their place in comparable routines.

Suggested-by: David Lawrence Ramsey <pooka109@gmail.com>
2018-12-10 17:38:39 +01:00
Benno Schulenberg 6bead051d2 justify: move the check for a bad quoting regex to a better place
So that the cursor will not move when a justification is attempted.
2018-11-26 10:56:20 +01:00
Benno Schulenberg ac8bd2a227 tweaks: elide a parameter -- do the NULL checks in the caller
Determine more directly: the length of the last paragraph line,
and the exit condition for a full justify.
2018-11-26 10:38:04 +01:00
Benno Schulenberg 0d96df7a91 tweaks: condense and improve a couple of comments 2018-11-26 09:38:02 +01:00
Benno Schulenberg e2c61d83ef tweaks: change do_para_end() to not step beyond end of paragraph
Not stepping beyond the last line of the paragraph means that the
length of the paragraph is always the difference in line numbers
(between first and last line of the paragraph) plus one.
2018-11-26 09:16:09 +01:00
Benno Schulenberg 2c126b201f text: turn the mark off when justifying, to not confuse an undo
When leaving the mark on while justifying and then undoing the
justification, things are likely to get messed up.  My applying
David's patches only partially caused this breakage.

This fixes https://savannah.gnu.org/bugs/?55074.
2018-11-25 20:10:30 +01:00
Benno Schulenberg 2500debbd2 tweaks: don't bother zeroing the x position when doing a full justify
The x position of the cursor is irrelevant when doing justifications.
2018-11-25 15:23:24 +01:00
Benno Schulenberg 500c41b83b tweaks: move the check for beginning-of-paragraph to a better place
Only the first search for a paragraph needs to check whether we're
currently in the middle of a paragraph.  When the 'while' loop for
a full justify is executed, all calls of find_paragraph() start
either on the first line of a paragraph or between two paragraphs.
2018-11-25 15:20:48 +01:00
Benno Schulenberg 2c83047842 tweaks: condense the logic of find_paragraph()
To find a paragraph, what needs to be done is:

  a) When not in a paragraph, move forward until we find one, if any.
  b) When in a paragraph but not at its start, move back to its start.
  c) Move forward to the end of the paragraph, if any.
2018-11-25 13:22:45 +01:00
Benno Schulenberg 5f5682240a tweaks: remove a superfluous check for a special case
The case is handled fine by the rest of the code.  The unnecessary
check wastes some cycles for every call of find_paragraph().
2018-11-25 12:43:29 +01:00
Benno Schulenberg 66cd897dc4 justify: correctly detect when we've reached end of buffer
When, in the 'while' loop for a full justify, 'filebot_inpar' becomes
TRUE, it means that EOF has been reached and find_paragraph() should
not be called again.  To allow 'filebot_inpar' to convey this meaning,
it should not be set to TRUE elsewhere, so another boolean is needed
for setting the correct length of the final line of the cutbuffer.

This fixes https://savannah.gnu.org/bugs/?55086.
2018-11-25 11:57:10 +01:00
Benno Schulenberg 67e6eee26e tweaks: rename two parameters to be more descriptive
Also rename one variable, to be more general, as it does not always
point to a line in a paragraph.
2018-11-22 20:54:22 +01:00
Benno Schulenberg 7ccdb1970a tweaks: elide two unneeded intermediate variables 2018-11-22 20:43:40 +01:00
Benno Schulenberg 539a18e4c7 tweaks: condense and improve a handful of comments, and rewrap two lines 2018-11-22 20:02:29 +01:00
Benno Schulenberg a7083d632b tweaks: improve a comment, and add an intermediate variable for clarity 2018-11-21 19:49:09 +01:00
David Lawrence Ramsey d54840c152 text: hook the new justify mechanism up to the undo system
This fixes https://savannah.gnu.org/bugs/?46900.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 14c085898b text: make do_justify() use the cutbuffer
This is the last preparation for making justifications undoable in
the regular way.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey fb38995d36 tweaks: adjust some indentation after the previous change 2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 2cdb87ee62 text: remove the old unjustify mechanism, to prepare for the new justify
This leaves two variables unused, but they will be used again two commits
from now, when do_justify() is converted to use the cutbuffer.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey ba8462a458 text: properly check again for no paragraphs after the current line
The removal of the x-coordinate handling affected this.  Reshuffle things
so that we can check for it after we have moved (the same way we check for
it at the beginning of the function before we move) without having to set
'quote_len' and 'par_len' unnecessarily.

Also, adjust some comments accordingly.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 4af81823e2 text: make find_paragraph() work on any buffer
Move detecting the final line of the paragraph to find_paragraph(),
since a paragraph of which the final line is the last line of the
buffer will still be that way after being justified.

Also, move all x-coordinate handling to do_justify(), since it only
applies to the current buffer.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 2c28a22971 text: prepare to make find_paragraph() work on any buffer
Move a few references to the current buffer to do_justify().  Also,
the check for being at the end of the buffer needs to be done after the
first paragraph is found, so that the existing behavior of finding an
initial paragraph regardless of cursor position is preserved.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey c8e5c85113 moving: make the generic paragraph movement functions work on any buffer
The functions do_para_begin() and do_para_end() can now move through any
buffer, while the functions do_para_begin_void() and do_para_end_void()
operate on the current buffer.  The latter function also returns TRUE
if the last line in the buffer is part of the paragraph.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 4c0572a799 text: make justify_paragraph() work on any buffer
Remove the handling of 'edittop', 'totsize', and the mark, to make the
function more general, which is needed to make it undoable eventually.

This breaks the function somewhat.  Fixes for this are forthcoming.
2018-11-20 19:21:35 +01:00
David Lawrence Ramsey 9aa382e69e text: make justify_format() work on any buffer
The function assumes that it works on the current buffer by handling
'totsize' and the mark.  Remove this handling to make the function
more general, which is needed to make it undoable eventually.

This breaks the function somewhat.  Fixes for this are forthcoming.
2018-11-20 19:21:35 +01:00
Brand Huntsman ae3ec1784d options: add --zap, that makes <Bsp> and <Del> erase a marked region
Using --zap or -Z on the command line, or 'set zap' in a nanorc file,
makes the <Bsp> and <Del> keys erase selected text (a marked region)
as they do in some other editors, and without affecting the cutbuffer.

This fulfills https://savannah.gnu.org/bugs/?54837.
Requested-by: Liu Hao <lh_mouse@126.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-11-04 11:46:57 +01:00
Brand Huntsman 5662a38802 new feature: a bindable 'zap', to erase text without changing cutbuffer
This function allows the user to "make space": annihilating lines or
regions while keeping intact for pasting the stuff in the cutbuffer
that was cut or copied earlier.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-11-04 11:46:19 +01:00
Benno Schulenberg 477f63d8b5 linter: do not pause when there are no messages for unopened files
Return immediately to editing mode when there are no messages for
the original file and the user does not wish to open any of the
included files that do have messages.

Also, reword the message that the linter gives then, and leave it
on the status bar (just like when Cancel is pressed).
2018-10-24 17:14:02 +02:00
Benno Schulenberg 280ac81b31 display: ensure that the help lines are shown when in linting mode
The help lines will help differentiate this mode from normal editing
mode, and will tell the user how to jump to other messages.

This is a third step to address https://savannah.gnu.org/bugs/?54714.
2018-10-23 19:35:21 +02:00
Benno Schulenberg b7f53096fb display: use a different color when showing a linting message
This is a second step to address https://savannah.gnu.org/bugs/?54714.
2018-10-23 19:31:40 +02:00
Benno Schulenberg f7f7767e7d display: let the title bar show when nano is in linting mode
This is a first step to address https://savannah.gnu.org/bugs/?54714.
2018-10-23 19:30:22 +02:00
Brand Huntsman 71de0b9e2f linter: throttle "first"/"last" message on repeated key presses
To avoid stacking up pauses, which would make nano unresponsive
for too long.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-10-22 20:36:00 +02:00
Benno Schulenberg b8c51329f6 linter: for "first"/"last", reshow actual message after a short pause
This fixes https://savannah.gnu.org/bugs/?54754.
2018-10-21 17:57:28 +02:00
Benno Schulenberg bab5eeb808 bindings: allow using <Enter> to exit from the linter
Understand the key as: "Enter into editing mode on the current line".
2018-10-21 17:55:17 +02:00
David Lawrence Ramsey c2e4f77594 display: do spotlighting as part of drawing the screen
When something is spotlighted, it should survive a refresh of
the screen and an excursion to a help text, so the spotlight
should get painted whenever the edit window is drawn.

This fully fixes https://savannah.gnu.org/bugs/?54721.
2018-10-09 20:03:47 +02:00
Benno Schulenberg d245b07c25 tweaks: remove a now-unused parameter from four functions 2018-10-01 19:56:32 +02:00
David Lawrence Ramsey 13a4f3130d tweaks: normalize the indentation of the shuffled code
And remove some superfluous braces.
2018-09-30 20:47:08 +02:00
David Lawrence Ramsey b32deee382 tweaks: move the justifying of a single paragraph into its own function
The new function, justify_paragraph(), takes a quote length and a
paragraph length (which it should get from find_paragraph()), and
runs the paragraph at (current, current_x) through justify_format().
2018-09-30 20:47:08 +02:00
David Lawrence Ramsey 076bc31ce5 tweaks: simplify by using a 'do/while' loop instead of 'while (TRUE)'
The do/while loop will run once when doing a justify, and enough times
for the entire file when doing a full-justify.
2018-09-30 20:47:08 +02:00
David Lawrence Ramsey 22c8ef6c39 tweaks: reshuffle some code to avoid several checks for having justified
Move some fragments out of the justifying loop, and adjust/clarify comments
to account for the changes.  This will allow some of the code to be cleaned
up and simplified in the next commits.
2018-09-30 20:47:08 +02:00
Benno Schulenberg 4b32c62674 tweaks: reshuffle some lines to get standard order (first up, then down) 2018-09-29 09:46:05 +02:00
Benno Schulenberg b4b9e9b012 linter: allow using <Ctrl+Up> and <Ctrl+Down> to jump to other message
These are more "natural" keystrokes for jumping than <PgUp> and <PgDn>.
2018-09-29 09:42:25 +02:00
Benno Schulenberg 0b63de335e tweaks: elide a wrapper function that is no longer useful 2018-09-28 20:09:12 +02:00
David Lawrence Ramsey bed997171c speller: restore the mark coordinates slightly later
To avoid a confusing mishighlighting of just part of a marked region.

This partially addresses https://savannah.gnu.org/bugs/?54721.
2018-09-26 19:45:38 +02:00
Benno Schulenberg 8d0b7a490d undo: move another piece of checking to the two places that need it
And in the bargain get rid of a function that is used just once.
2018-09-26 19:25:21 +02:00
Benno Schulenberg efa323ec88 tweaks: improve two comments, and reshuffle a line for consistency
(Line number first, x position second.)
2018-09-25 20:26:26 +02:00
Benno Schulenberg 4c6ec6377f undo: move some special checking code to the one place that needs it
Only for BACK and DEL was the first call to update_undo() -- all other
types of action would call add_undo() first, so for them the action in
update_undo() would never be different, but the line number might have
changed (like for ENTER and INSERT), so for them exceptions needed to
be made, which was wasteful.

This addresses https://savannah.gnu.org/bugs/?54728.
2018-09-25 18:09:28 +02:00
Benno Schulenberg be69a7c299 tweaks: rename a variable, to be a bit more fitting 2018-09-23 14:51:40 +02:00
Benno Schulenberg 33b576c289 speller: remove a pointless message -- it is never seen
When using the internal spell checker, the message gets overwritten
immediately by "Creating misspelled word list...", and when using
the external spell checker, nano immediately exits from curses mode
and thus the message disappears (when in a terminal emulator) or it
soon gets wiped by the spell checker (when on a Linux console), thus
creating a little flash on the bottom row, which we can do without.
2018-09-23 14:41:25 +02:00
Benno Schulenberg 1f39f60b2f tweaks: there is no reason to block SIGWINCHes while waiting for speller
In the past, SIGWINCHes were responded to immediately (which was madness),
but since commit 75d64e67 all a SIGWINCH does is set a flag so that, when
the time comes to update the screen, nano knows the dimensions may have
changed.  The mentioned commit removed most blockings and unblockings of
SIGWINCH, but not this one.
2018-09-23 14:07:36 +02:00
Benno Schulenberg e21ce0db1f cutting: when deleting whole words, don't join lines unexpectedly
That is, wait with deleting words until they start under cursor,
so the user can see which word is goin to be eaten, and join lines
only when the cursor already sits at the edge of a line.
2018-09-07 19:35:01 +02:00
David Lawrence Ramsey 93c8e316a8 justify: verify being in a paragraph before trying to find its beginning
If find_paragraph() detects that we're not in a paragraph, it moves
forward a paragraph and then backward to that paragraph's beginning.
Make it check whether we're in a paragraph before moving backward
(since there might not *be* any more paragraphs), to prevent going
forth-and-back and never reaching the end of the buffer.

This fixes https://savannah.gnu.org/bugs/?54573.
2018-08-27 20:27:02 +02:00
David Lawrence Ramsey 03f9761c35 undo: store the correct cursor position after a paired cut+insert
And restore the cursor to this position when redoing the cut+insert.

Also remove two unneeded conditions.

This fully fixes https://savannah.gnu.org/bugs/?54466.
2018-08-21 19:21:14 +02:00
Benno Schulenberg ec339d3b08 filtering: wait for the data-sending process to terminate too
When piping the buffer (or the marked region) to an external command,
we should wait not only for the external command to terminate but also
for the data-sending process, so that it will release its resources.

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

With-help-from: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-08-20 19:46:38 +02:00
Benno Schulenberg 3218d8358a tweaks: remove a redundant "struct" word, and replace it in comments 2018-08-20 19:33:31 +02:00
David Lawrence Ramsey 07447f3278 undo: restore the cursor position when a cut and paste are paired
When undoing/redoing an alternate spell check (of the entire file
or of a backwards marked region), put the cursor back where it was
when the spell check was invoked/finished.

This fixes https://savannah.gnu.org/bugs/?54466.
2018-08-15 19:58:46 +02:00
David Lawrence Ramsey fd65f74428 undo: always initialize the 'newsize' element in the undo struct
So that do_redo() cannot set the file size to a "random" value.

This fixes https://savannah.gnu.org/bugs/?54478.
2018-08-11 10:07:20 +02:00
Benno Schulenberg 975b491235 dropping a feature: remove the ability to use the 'formatter' command
Since the last version, the user can filter an entire buffer through
an external command.  This external command can also be a formatting
program, so there is no longer any need for this specific and special
formatter command.
2018-08-09 20:29:30 +02:00
Benno Schulenberg 94b4f07281 tweaks: adjust indentation after the previous change
Also improve a couple of comments.
2018-08-08 19:53:05 +02:00
Benno Schulenberg 61b4eeda66 speller: do not replace the text when the temporary file did not change 2018-08-08 19:44:40 +02:00
Benno Schulenberg 667fcea65e undo: differentiate between general filtering and spell checking
With-help-from: David Lawrence Ramsey <pooka109@gmail.com>
2018-08-07 20:42:39 +02:00
David Lawrence Ramsey c39c9c241b undo: actually enable undoing/redoing an alternative spellcheck
Make sure the inserts of the spell-checked text are undoable, and no
longer discard the undo stack after running the alternate spell checker.
2018-08-07 20:41:05 +02:00
David Lawrence Ramsey bc6787826a speller: make replace_marked_buffer() use the cutting functions directly 2018-08-07 20:38:50 +02:00
Benno Schulenberg 60ee4408be signals: don't call a print routine in a signal handler
Print routines are not asynchronous-safe.

But... the only reason the call of kill() could return an error code
is when the relevant process has already terminated -- which is not
a problem, because that was the goal of calling kill().

This fixes https://savannah.gnu.org/bugs/?54409.
Reported-by: Daniel Kozovsky <dkozovsk@redhat.com>
2018-07-30 20:22:24 +02:00
Benno Schulenberg 72a590d60a tweaks: rename a variable and a function, for more clarity 2018-07-30 20:07:25 +02:00
Benno Schulenberg c4d09cc24b text: add auto-whitespace to the file size after creating the undo item
The undo item for ENTER should record the file size *before* the amount
of auto-indentation whitespace is added to it.

This fixes https://savannah.gnu.org/bugs/?54344.
Reported-by: Liu Hao <lh_mouse@126.com>
2018-07-23 17:57:47 +02:00
Benno Schulenberg 05592a84ec completion: when the cursor is not after a word fragment, say so
Instead of being entirely silent when ^] is hit after whitespace
or punctuation, report what is lacking -- similar to M-] saying
"Not a bracket" when the cursor is not sitting on a bracket.
This makes the ^] keystroke more discoverable.
2018-07-19 19:29:24 +02:00
Benno Schulenberg 6d3b16b761 tweaks: close a temp file only when descriptor is valid [coverity scan] 2018-07-14 21:33:46 +02:00
Benno Schulenberg 14b9a42f5b tweaks: move a call to where it will be executed [coverity scan] 2018-07-14 21:02:32 +02:00
Benno Schulenberg d994af0334 tweaks: avoid dereferencing a pointer when it is NULL [coverity scan] 2018-07-14 20:02:03 +02:00
Benno Schulenberg 3ac821ee0c build: fix compilation when configured with --enable-tiny 2018-07-10 15:31:04 +02:00
Benno Schulenberg f456794045 tweaks: adjust two comments, to be more accurate and general 2018-07-08 17:40:19 +02:00
David Lawrence Ramsey 20971e8392 undo: position the cursor properly when undoing/redoing magicline cuts
Take our cue from undoing/redoing line joins: when they take place on
the magicline without --nonewlines, they produce undo/redo items that
don't do anything to the text, but still position the cursor properly.
Reshuffle a bit of code so that we can do the same for magicline cuts.

This fixes https://savannah.gnu.org/bugs/?54032.
2018-07-08 17:29:28 +02:00
Benno Schulenberg fb372ed0a8 tweaks: remove two superfluous assignments
The variable 'last_action' is set at the end of these functions,
serving to prevent a fresh action from being merged with an older
action further down on the stack.  Setting 'last_action' before
exiting from undo()/redo() makes no sense.

Also adjust a sideways related old Changelog item.
2018-06-02 19:32:54 +02:00
Benno Schulenberg ed433f6af0 tweaks: drop a condition that has been made redundant two commits ago 2018-06-02 18:17:31 +02:00
Benno Schulenberg 44814055b5 tweaks: correct a comment, rewrap a line, and drop some debugging stuff
An add can be contiguous even when the cursor has moved around in the
meantime but has returned to the same spot before more characters are
typed.
2018-06-02 18:04:36 +02:00
Benno Schulenberg 71f859377d cut: concentrate the logic for clearing the cutbuffer mostly in one place
It should not be the task of the undo code to take care that the
cutbuffer will be cleared at the right moments.
2018-06-02 17:57:19 +02:00
Benno Schulenberg 5550d15418 tweaks: improve a couple of comments, and reshuffle a group of lines 2018-06-01 16:56:56 +02:00
Benno Schulenberg 6df30a634e docs: register Marco as the author of the filtering feature
The macro stuff, however, is basically my code: I told him exactly
how to do it, and I changed most of the patch before applying it.

Also, put myself in second place, as I've just about overtaken David
in the duration of maintainership.
2018-06-01 10:00:08 +02:00
Benno Schulenberg ad5d0f7530 wrapping: use "smart" autoindenting only when hard-wrapping is enabled
The paragraph-aware indenting is needed only when automatic long-line
wrapping is on (that is, when not using 'nowrap': when writing prose).
When writing code, the user most likely uses --nowrap, which will make
nano indent a new line always to the same amount as the preceding line
-- when --autoindent is in effect, of course.
2018-06-01 08:45:25 +02:00
David Lawrence Ramsey dc4146f077 tweaks: avoid an unused variable warning with --enable-tiny
This fixes https://savannah.gnu.org/bugs/?53998.
2018-05-29 09:00:08 +02:00
Benno Schulenberg 738487f13d tweaks: make better use of an existing variable 2018-05-28 10:39:47 +02:00
Benno Schulenberg c8a9a96578 build: fix compilation when configured with --disable-justify 2018-05-28 09:57:24 +02:00
David Lawrence Ramsey fce54a724d tweaks: fix some grammar plus a typo in the comments 2018-05-27 20:19:46 +02:00
Benno Schulenberg ebdb647450 tweaks: adjust a translator hint 2018-05-27 17:53:36 +02:00
Benno Schulenberg 0c2aac5ff8 tweaks: reshuffle a couple of assignments 2018-05-27 17:45:51 +02:00
Benno Schulenberg 7952d68830 tweaks: frob a couple of comments 2018-05-27 17:27:07 +02:00
Benno Schulenberg 5cb4485fa5 tweaks: remove a superfluous assignment -- the lead length never changes 2018-05-27 17:16:04 +02:00
Benno Schulenberg d7c1ab8e80 tweaks: rename two variables, to better fit their tasks 2018-05-27 17:11:18 +02:00
Benno Schulenberg 1881db099d tweaks: make better use of an intermediate variable 2018-05-27 16:41:55 +02:00
Benno Schulenberg 36c83d92dd tweaks: stop decreasing both the iterator and the limit of a loop 2018-05-27 16:34:20 +02:00
Benno Schulenberg 9021725d53 justification: limit the amount of recursion to prevent a stack overflow 2018-05-27 16:09:53 +02:00
Benno Schulenberg d00ab406bc wrapping: when autoindenting, use indentation of next line as example
When doing autoindentation, and the next line is not the start of
a new paragraph, then use the indentation of that line for the new
line, as it is more likely to have the desired indentation -- the
current line might be the start of the paragraph and thus could
have a deviant indentation.
2018-05-27 16:09:53 +02:00
Benno Schulenberg d63d79b067 tweaks: elide another function that is called just once 2018-05-27 16:09:53 +02:00
Benno Schulenberg 446c7d5fff tweaks: elide a function that is called just once 2018-05-27 16:09:53 +02:00
Benno Schulenberg 52efac535b tweaks: rename a variable, to give it some meaning 2018-05-27 16:09:53 +02:00
Benno Schulenberg 45c36f93e5 tweaks: simplify the determining of the prefix for justified lines 2018-05-27 16:09:53 +02:00
Benno Schulenberg 432a7d7729 justification: find the beginning of a paragraph in a better way
Any line whose indentation differs from that of a pair of adjacent lines
is the beginning of a paragraph, also when its indentation is smaller.

This fulfills https://savannah.gnu.org/bugs/?53932,
and fixes point 2) of https://savannah.gnu.org/bugs/?53933.
2018-05-27 16:09:53 +02:00
Benno Schulenberg d7fe5a7db3 justification: recognize indented paragraphs also without --autoindent
Pico does not require any option to do this, so nano should neither.

This fixes point 1) of https://savannah.gnu.org/bugs/?53933.
2018-05-27 16:09:53 +02:00
Benno Schulenberg a832f33291 justification: when leading whitespace exceeds fill width, wrap anyway
Pico wraps at the last blank character before or on the target column;
if there is no such blank, then it will wrap at the first blank *after*
the target column -- when it can wrap, it will wrap.  Nano should do
the same (and judging from the comments, it intended to do the same),
instead of turning the paragraph into a single unwrapped line.

This fixes https://savannah.gnu.org/bugs/?53986.
2018-05-27 10:24:02 +02:00
Benno Schulenberg b9f533a69e tweaks: rename a function, for more aptness and extra contrast 2018-05-25 20:09:24 +02:00
Benno Schulenberg ac31669ec3 linter: don't try to access absent stat info, as that gives a crash
This fixes https://savannah.gnu.org/bugs/?53981.
2018-05-25 19:25:11 +02:00
Benno Schulenberg 86c08560ad linter: make sure that the margin is updated before displaying a buffer
This fixes https://savannah.gnu.org/bugs/?53977.
Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-25 17:58:25 +02:00
Benno Schulenberg 3757683e3f build: fix compilation when configured with --disable-multibuffer 2018-05-24 21:09:14 +02:00
Benno Schulenberg 3e9ef3032f tweaks: use a more meaningful variable name, and avoid a distant 'else'
Also, indent a continuation line better.
2018-05-24 19:40:52 +02:00
Benno Schulenberg 6fb1509817 tweaks: condense two statements into one, and elide a 'break' 2018-05-24 18:17:58 +02:00
Benno Schulenberg 07ddf25cc0 tweaks: exclude an unneeded 'if' from the single-buffer version 2018-05-24 18:14:35 +02:00
Marco Diego Aurélio Mesquita 73d397c64b linter: check all open buffers, instead of just the next one
First step to the next buffer, and then iterate until we either
find a match or are back at the buffer where we started.

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

Signed-off-by: Marco Diego Aurélio Mesquita <address@hidden>
2018-05-24 18:10:52 +02:00
Benno Schulenberg e0c7ff2a7e linter: make sure the shortcuts bar will redrawn when exiting early
The two help lines will be redrawn in main() only when the current
menu is not MMAIN.  So, set it to MLINTER as soon as the help lines
are cleared, just before preparing to invoke the linter.

This fixes https://savannah.gnu.org/bugs/?53967.
Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-24 11:37:14 +02:00
Benno Schulenberg 5d02ee64b6 filtering: pair the cut and the insert, so they can be undone together
When executing a command in the current buffer and piping this buffer
(or marked region) to that command, then the cutting of the existing
text and the insertion of the new text should be undone and redone
together, as to the user they appear as a single operation.

With-help-from: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-22 19:36:21 +02:00
Benno Schulenberg 5ffd8d96ae tweaks: rename a variable, for contrast, and improve two comments 2018-05-22 19:36:21 +02:00
Marco Diego Aurélio Mesquita f304b9aee1 new feature: allow piping (selected) text to an external command
When executing a command, it is now possible to pipe the entire buffer
(or the marked region, if anything is marked) to the external command.
The output from the command replaces the buffer (or the marked region),
or goes to a new buffer.

This fulfills https://savannah.gnu.org/bugs/?28993,
and fulfills https://savannah.gnu.org/bugs/?53041.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-05-22 19:36:21 +02:00
Benno Schulenberg 9d6621afd0 tweaks: remove two superfluous checks, after making one of them so 2018-05-21 09:44:06 +02:00
Benno Schulenberg 4d232a4aef tweaks: frob some comments, and rename two parameters to make sense 2018-05-18 13:24:07 +02:00
Mark-Weston 858663444e new feature: an option to make the 'nextword' function stop at word ends
When 'afterends' is set and Ctrl+Right or Shift+Ctrl+Right is pressed,
nano will stop at the ends of words instead of their beginnings.

Signed-off-by: Mark-Weston <markweston@cock.li>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-05-10 11:32:01 +02:00
Benno Schulenberg 553940760e tweaks: set the correct flags just once for each spell-fixing session 2018-04-25 17:27:15 +02:00
Benno Schulenberg faa0eb991e speller: don't add an extra newline when saving the text to a tempfile
Set the NO_NEWLINES flag to achieve this.  And move the saving and
restoring of the global flags to the main speller routine, so the
flags aren't saved and restored for each internal spell fix.

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

Acked-by: David Lawrence Ramsey <pooka109@gmail.com>
2018-04-25 17:26:14 +02:00
Benno Schulenberg 4872f42cd2 tweaks: rename a function, to be more distinct from its caller 2018-04-25 12:21:40 +02:00
Benno Schulenberg 1ae90e205a command-execution: do not crash when opening the pipe would fail
This fixes https://savannah.gnu.org/bugs/?53723.
2018-04-23 18:04:25 +02:00
Benno Schulenberg d53086d38d completion: correctly do a signed comparison, to avoid a segfault
Bug existed since commit 30fc197b (a month ago) which changed the
type of 'i' from int to size_t, causing the comparison to do the
wrong thing when 'threshold' is negative.

This fixes https://savannah.gnu.org/bugs/?53722.
Reported-by: Devin Hussey <husseydevin@gmail.com>
2018-04-23 17:09:54 +02:00
Benno Schulenberg 0b6bb37c56 tweaks: improve some comments, and exit with nonzero status upon error 2018-04-23 14:04:08 +02:00
Benno Schulenberg c43a6fdcc1 tweaks: rename a variable, to match another and to be more visible 2018-04-23 13:04:31 +02:00
Benno Schulenberg 0c613cb1ac tweaks: rename a variable, to be more clear and to match another 2018-04-23 12:57:58 +02:00
Benno Schulenberg 1e5064ef84 tweaks: fix a typo, remove a blank line, and improve some comments 2018-04-23 12:19:25 +02:00
Benno Schulenberg 45f8fc77e0 tweaks: rename a variable, to be a bit more fitting 2018-04-22 12:05:19 +02:00
Benno Schulenberg 94347f0811 memory: use a reallocation to reduce the amount of leakage 2018-04-22 12:00:26 +02:00
Benno Schulenberg 1a4a3de68b formatting, linting: redetermine the argument list for every run
The formatter or linter might have changed in the meantime -- when
the filename was changed to have a different extension, for example.

This fixes https://savannah.gnu.org/bugs/?53716.
2018-04-22 11:44:07 +02:00
Benno Schulenberg 02d8da3bdd tweaks: rename a function, to be more fitting and descriptive
It is not an abort but simply a bit of cleaning up.
2018-04-13 10:32:29 +02:00
Benno Schulenberg 8965103a4d tweaks: remove the group handling for undoing/redoing (un)indents
Indenting/unindenting always happens in a single contiguous block.
Lines that cannot or should not be indented or unindented do not
need to remembered separately as it follows from their content.
2018-04-01 11:41:26 +02:00
Benno Schulenberg d0d293b8af tweaks: correct or improve a couple of comments 2018-04-01 11:24:44 +02:00
Benno Schulenberg 839743fd24 tweaks: move a function to its proper location 2018-04-01 10:54:14 +02:00
Benno Schulenberg 5726514869 linting: drop messages for other files when configured for one buffer
This fixes https://savannah.gnu.org/bugs/?53445.
2018-03-26 08:56:03 +02:00
Benno Schulenberg 88234c90bc tweaks: adjust the indentation after the previous changes 2018-03-26 08:53:06 +02:00
Benno Schulenberg 02719ec4bf tweaks: fuse two ifs into one 2018-03-26 08:52:51 +02:00
Benno Schulenberg 415bf82690 tweaks: move an 'if' and then remove an unneeded label 2018-03-26 08:52:04 +02:00
Benno Schulenberg bf1a080923 build: exclude more things when configured with --disable-multibuffer
This will make the tiny version slightly smaller.
2018-03-23 11:09:37 +01:00
Benno Schulenberg 30fc197b66 tweaks: adjust a couple of types, to reduce the number of warnings
This avoids eleven warnings of the kind "comparison between signed
and unsigned integer expressions [-Wsign-compare]".
2018-03-22 19:33:22 +01:00
Benno Schulenberg b9de5525c4 tweaks: elide a parameter, as it's always the inverse of another 2018-03-22 12:52:28 +01:00
Benno Schulenberg f4d1ef1c4e tweaks: remove unneeded settings and unsettings of MULTIBUFFER
In the preceding commit, open_buffer() was changed so that it gets
told whether to load into a new buffer or not, so it is no longer
needed to convey this information through a flag.
2018-03-22 12:50:48 +01:00
Benno Schulenberg dd157f1494 tweaks: change a parameter of open_buffer() and invert its logic 2018-03-22 12:35:50 +01:00
Benno Schulenberg dcda98fb73 tweaks: remove an inconsistent space from two pointer declarations
Reported-by: Brand Huntsman <alpha@qzx.com>
2018-03-17 15:53:22 +01:00
Benno Schulenberg e8505b2d3e memory: plug a leak, by actually freeing a discarded undo struct
This fixes https://savannah.gnu.org/bugs/?53269.
Reported-by: Ashish Kunwar <dorkerdevil280@gmail.com>

The leak was mistakenly introduced by commit dc3618a1
-- probably as a leftover of testing things.
2018-03-11 20:16:09 +01:00
Benno Schulenberg 95fffa99aa tweaks: adjust two comments, move two declarations, rewrap three lines 2018-03-05 10:43:05 +01:00
Benno Schulenberg 22f7861694 tweaks: reshuffle the undo types into mostly the same order everywhere
First the two that add something (ADD, ENTER), then the three that
delete something (BACK, DEL, JOIN), and then the one that changes
something (REPLACE).  Then the SPLITs, CUT, PASTE, and INSERT, and
then the INDENTs and COMMENTs, when they exist.
2018-03-05 10:05:07 +01:00
Benno Schulenberg ba96d507dd tweaks: drop some debugging stuff, and adjust what remains of it 2018-03-05 09:42:57 +01:00
Benno Schulenberg 9bf57e5ca0 tweaks: do not needlessly renumber the lines in the buffer
For cuts, pastes, and inserts, the lines have already been renumbered;
for indents, comments, and replacements, the line numbers cannot have
changed.  (And anyway, variable 'f' is not set for those cases.)

Only when lines get split (ENTER) or fused together (JOIN) do the later
lines need to be renumbered.  This mirrors what is done for do_redo().
2018-03-04 10:27:07 +01:00
Benno Schulenberg f9103a5cb5 tweaks: make the fsfromline() call only for the undo types that need it
The 'f' variable is used only in the ADD, BACK, DEL, ENTER, JOIN, and
REPLACE undo/redo cases.  So, avoid making a somewhat costly call when
it is entirely superfluous.  Rearrange the undo types to make checking
for the above six types easier.
2018-03-03 17:12:25 +01:00
Benno Schulenberg e9eabdcdcb undo: when redoing, don't try to find a line number that might not exist
This fixes https://savannah.gnu.org/bugs/?53272.
2018-03-03 16:41:33 +01:00
Benno Schulenberg dd9766c2e0 editing: when --smooth is used, make <Enter>-at-bottom scroll one row
When using --smooth or 'set smooth', the screen should scroll the
minimum amount needed to get the cursor back into view.  (The only
exceptions are search, undo, and redo -- when there the cursor goes
offscreen, the cursor line is centered.)

This change brings the behavior of pressing <Enter> on the bottom
row into line with, for example, pasting a single line.  See also
http://lists.gnu.org/archive/html/nano-devel/2018-02/msg00027.html.
2018-02-16 11:48:24 +01:00
Benno Schulenberg 4295baa5fe tweaks: transform a 'do' to a 'while', and reshuffle a comment 2018-02-04 18:14:28 +01:00
Benno Schulenberg f72fecee9b copyright: update the years for the FSF
And one for me, for the much changed keyboard stuff.
2018-01-24 10:14:43 +01:00
Benno Schulenberg a429dc4a76 tweaks: rename a variable, to better fit its usage 2018-01-23 13:09:12 +01:00
Benno Schulenberg 91073be49c wrapping: don't trim a blank character that the user just typed
Trimming trailing spaces is good, but we should not trim the space
(or tab or other blank) that the user just typed and that caused the
hard-wrapping to occur.

This fixes https://savannah.gnu.org/bugs/?52948.
Reported-by: Andreas Schamanek <schamane@fam.tuwien.ac.at>
2018-01-23 13:06:05 +01:00
Benno Schulenberg 7947d9d2a5 build: fix compilation when configured with --enable(tiny,color,nanorc}
This fixes https://savannah.gnu.org/bugs/?52834.
Reported-by: <akiko@mailbox.org>
2018-01-09 13:30:25 +01:00
Benno Schulenberg ada78dc89d build: fix compilation with --enable-tiny --enable-justify 2018-01-08 19:12:41 +01:00
Benno Schulenberg 17429d7f38 tweaks: fix some whitespace errors, and convert alignment tabs to spaces 2017-12-29 21:35:14 +01:00
Benno Schulenberg 87206c0607 tweaks: convert the indentation to use only tabs
Each leading tab is converted to two tabs, and any leading four spaces
is converted to one tab.  The intended tab size (for keeping most lines
within 80 columns) is now four.
2017-12-29 20:06:50 +01:00
Benno Schulenberg b574f73e60 tweaks: add a separate function that actually wipes the status bar 2017-12-29 17:40:41 +01:00
David Lawrence Ramsey 62ebd93579 tweaks: use printf's z modifier for (s)size_t, instead of casting 2017-12-26 14:11:18 +01:00
Benno Schulenberg 184bb11fd9 tweaks: factor out a piece of common code 2017-12-24 11:25:10 +01:00
Benno Schulenberg a70db34fc9 tweaks: remove two irrelevant conditions
They were mistakenly added by changeset fb85c055, four commits ago.
2017-12-24 11:10:41 +01:00
Benno Schulenberg fbde1b2d71 tweaks: reshuffle another bit of code, for conciseness 2017-12-24 10:56:16 +01:00
Benno Schulenberg c22fef18e4 tweaks: reshuffle a bit of common code, moving it to an existing function 2017-12-23 21:50:18 +01:00
Benno Schulenberg fb85c05594 text: keep cursor at left edge when it IS there when indenting/commenting
Suggested-by: Brand Huntsman <alpha@qzx.com>
2017-12-21 19:47:22 +01:00
Benno Schulenberg 25b1114e03 tweaks: elide two parameters from the get_region() function 2017-12-21 19:47:22 +01:00
Benno Schulenberg 4b8a387529 text: let indenting/commenting skip the last line if its x is zero
If the marked region ends at the start of a line, do not include that
line in the indenting/undenting or commenting/uncommenting.  This is
closer to what the eye would expect.
2017-12-21 19:47:22 +01:00
Benno Schulenberg dc3618a127 text: set and reset the Modified state correctly when undoing/redoing
Unset the "Modified" marker only at the point where the file was last
saved -- if there is such a point, because it can be missing when the
undo stack was discarded.

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

Original-idea-by: Brand Huntsman <alpha@qzx.com>
2017-12-19 19:22:52 +01:00
Benno Schulenberg e2843ede7e text: let a Shift-selection persist when indenting and commenting
To achieve that, fake the Shift key being held when indenting/
unindenting/commenting/uncommenting.

Reported-by: Brand Huntsman <alpha@qzx.com>
2017-12-12 21:09:28 +01:00
Benno Schulenberg bcd187d7d6 tweaks: rewrap some lines and some comments, and trim two others 2017-12-10 20:03:51 +01:00
Benno Schulenberg 03783a7d1b tweaks: trim another placing of a terminating nul byte
Make both preceding character moves include the terminating byte.
2017-12-10 19:56:36 +01:00
Benno Schulenberg f2fb8c01f4 tweaks: remove a superfluous placing of a terminating nul byte
The character move has already copied the terminating byte.
And a reallocation to save just one character of memory is
a waste of time.
2017-12-10 19:49:57 +01:00
Benno Schulenberg eb937f81fa text: allow unindenting when not all lines are indented
And also allow it when lines are only partially indented.

This makes it possible to equalize the indentations of (accidentally)
unevenly indented lines: by first fully unindenting a group of lines,
and then reindenting them to the desired amount.

Suggested-by: Liu Hao <lh_mouse@126.com>
2017-12-09 17:44:12 +01:00
Benno Schulenberg 66fd6a5ab1 options: rename 'justifytrim' to 'trimblanks', because it has morphed
The option now causes nano to trim trailing whitespace also when
hardwrapping occurs while the user is typing.
2017-12-06 20:38:13 +01:00
Benno Schulenberg c30d3d8010 wrapping: delete trailing blanks upon hardwrapping, when requested
This fulfills https://savannah.gnu.org/bugs/?52198.
2017-12-06 20:32:08 +01:00
Benno Schulenberg 0c40f87b55 tweaks: invert the logic of a variable, and rename it
To get rid of two double negatives.
2017-12-03 20:49:01 +01:00
Benno Schulenberg 0133d5cba8 tweaks: elide two variables that are used just once 2017-12-02 18:07:50 +01:00
Benno Schulenberg 9066a96dde tweaks: rename three variables, for more contrast and variety 2017-12-02 18:07:22 +01:00
Benno Schulenberg 6abb551fdd tweaks: avoid incrementing a variable that won't be used again later 2017-12-02 17:55:27 +01:00
Benno Schulenberg 97bdf13b59 tweaks: remove a redundant call of renumber()
The call of do_delete() four lines earlier already does a renumber.
2017-12-02 17:47:01 +01:00
Benno Schulenberg dae88f8dc7 tweaks: remove a superfluous condition
When the WAS_FINAL_LINE flag is relevant (when NO_NEWLINES isn't set),
the only way for 'current' to be equal to 'filebot' is when 'current_x'
is zero.
2017-12-02 17:40:16 +01:00
David Lawrence Ramsey b9638cb7cc undo: when adding text adds a magicline, an undo should remove both
This fixes http://savannah.gnu.org/bugs/?52523.
2017-11-30 21:20:38 +01:00
Benno Schulenberg c17a8a9836 undo: discarding the stack does not always lose information
When some or all edits have been undone, and the user starts to make
new edits, the old part of the undo stack is discarded, but this does
not mean that the undo stack doesn't go back to the very beginning.

This really fixes https://savannah.gnu.org/bugs/?52504.
2017-11-27 16:19:28 +01:00
Benno Schulenberg 0c9905dbd0 undo: clear the Modified state when the very first edit is undone
This also means that no question needs to be asked when exiting.

This fixes https://savannah.gnu.org/bugs/?52504.
Reported-by: Peter Passchier <peter@passchier.net>
2017-11-26 19:55:44 +01:00
Benno Schulenberg 2b314ed18f selecting: let a justification cancel a softmark
Otherwise a second justification will cancel it, which is weird.
2017-11-26 19:54:29 +01:00
Benno Schulenberg 77d24300f3 tweaks: reshuffle a couple of lines, and frob a comment or two 2017-11-22 19:36:33 +01:00
Benno Schulenberg d33b5f3dab tweaks: rename, rewrap, and reshuffle some stuff, and frob some comments 2017-11-21 21:17:08 +01:00
Benno Schulenberg c24e95e3d6 tweaks: elide the 'mark_set' boolean -- the 'mark' pointer is enough
The pointer not being NULL is enough indication that the mark is set.

Also, rename the pointer from 'mark_begin' to simply 'mark', since
the former is kind of pleonastic.
2017-11-21 21:14:33 +01:00
Benno Schulenberg c42489d946 linting: switch the mark off when the linter starts
Because the highlighting hinders the display of affected lines,
and, more importantly, only the highlighted part would be written
if the file was modified and the user answers yes to the "Save?"
prompt.

This fixes https://savannah.gnu.org/bugs/?52474.
2017-11-21 21:12:16 +01:00
Benno Schulenberg 5239e7c52b copyright: update some years, and standardize on the dashed format 2017-11-12 10:46:20 +01:00
Benno Schulenberg 2122a1a2b5 tweaks: constify the result strings of getenv(), as a reminder
Also, remove an unneeded pair of braces.
2017-11-10 20:03:07 +01:00
Benno Schulenberg 7e6bb91593 tweaks: add a translator hint, and adjust two others 2017-11-07 19:39:00 +01:00
Benno Schulenberg 7b133aa6f9 tweaks: change some mayday messages, to urge the user to report a bug
Also, diversify them, and no longer mark them for translation.
2017-11-07 19:14:33 +01:00
Benno Schulenberg d5ac1ed395 tweaks: transform the token DISABLE_COLOR to ENABLE_COLOR 2017-11-01 19:45:50 +01:00
Benno Schulenberg 2a4fc9591f tweaks: transform the token DISABLE_SPELLER to ENABLE_SPELLER 2017-10-31 19:32:42 +01:00
Benno Schulenberg f034992ed6 tweaks: transform the token DISABLE_WRAPJUSTIFY to ENABLED_WRAPORJUSTIFY 2017-10-31 17:40:54 +01:00
Benno Schulenberg db0b849f9b tweaks: transform the token DISABLE_JUSTIFY to ENABLE_JUSTIFY 2017-10-31 17:40:44 +01:00
Benno Schulenberg a5974bd1ec tweaks: transform the token DISABLE_WRAPPING to ENABLE_WRAPPING 2017-10-29 21:00:09 +01:00
Benno Schulenberg 3f27c312c4 tweaks: get rid of some cluttering conditional compilation
In the tiny version, do_prompt() will now have an extra NULL
parameter, which will cost maybe twenty extra bytes of code.
That is acceptable when it saves thirty lines in the source.
2017-10-29 11:39:27 +01:00
Benno Schulenberg ded02d858f search: suppress the "Search Wrapped" message when doing replacements
This completes the fix for https://savannah.gnu.org/bugs/?52282.
Reported-by: Chime Hart <chime@hubert-humphrey.com>
2017-10-26 21:07:06 +02:00
Viorel Bota 217cfbf362 files: check for a changed disk file also for 'savefile' and --tempfile
Before writing a file out, nano should check that the file on disk
hasn't been modified since it was read -- not only for the normal
"Write Out" action (^O), but also for "Save File" (future ^S) and
for "Save and Exit" (^X when --tempfile is used).

When writing fails and --tempfile is in effect, don't go on to prompt
for a file name; instead let the user decide what she wants to do.

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

Signed-off-by: Viorel Bota <botaviorel@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-10-13 20:24:10 +02:00
Benno Schulenberg 7c3c3cbb3b tweaks: discard some obsolete debugging stuff 2017-09-22 21:59:51 +02:00
Benno Schulenberg c74d2632bb tweaks: make the switching on and off of the cursor a bit more compact 2017-09-22 21:31:01 +02:00
Benno Schulenberg ae34825f58 display: rework the switching on and off of the cursor
The basic idea is that the cursor is always off, except when it needs
to be on: when waiting for text input, and in a few other cases: when
something was searched and found in the help viewer, and in the file
browser when option -g is in effect.

This fixes https://savannah.gnu.org/bugs/?51923.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-09-20 21:35:25 +02:00
Benno Schulenberg ac8eb42a4f tweaks: elide a superfluous allocation 2017-09-12 20:46:14 +02:00
David Lawrence Ramsey 19a1129698 text: hook up indenting and unindenting to the undo/redo code
This is modeled after the comment/uncomment code.  Each line's
individual indent is saved in the string array of the undo
group structure.

This fixes http://savannah.gnu.org/bugs/?46860.
2017-09-12 20:08:30 +02:00
David Lawrence Ramsey f722c53223 undo: generalize update_comment_undo() into update_multiline_undo()
The function does not contain any comment-specific code, so it can
be used to handle any kind of multiline undo item.

Also, extend the undo group structure to contain an array of strings,
one for each line in the group.  When indent/unindent is hooked up to
the undo/redo code, this will allow the latter to restore the exact
original indents.
2017-09-12 19:49:44 +02:00
Benno Schulenberg ffc550521c tweaks: chuck a bunch of asserts -- they have lost their usefulness 2017-09-10 14:08:24 +02:00
Benno Schulenberg 8d229cb712 tweaks: rename a variable, to make more sense
Also, remove an unneeded null_at() -- the null byte has been copied,
and reallocating the string would recover very little memory.

Also, call charmove() without using the & operator.
2017-09-10 13:28:13 +02:00
Benno Schulenberg abf7ac48a1 tweaks: rename three variables, for more contrast 2017-09-10 13:04:03 +02:00
David Lawrence Ramsey fc0e16f6bc text: move the unindenting of a single line into its own function 2017-09-10 12:59:04 +02:00
David Lawrence Ramsey 57d7f8852d text: move the indenting of a single line into its own function
This is modeled after the undo/redo code for commenting.  do_indent() now
calls indent_a_line() on each line it covers.  The latter function will
eventually be used by the undo/redo code.
2017-09-10 12:43:10 +02:00
Benno Schulenberg 807f5c2e69 tweaks: do not leak the indentation when all lines are empty 2017-08-16 17:16:18 +02:00
Benno Schulenberg 1b2a091de9 tweaks: condense or improve some comments
Also reshuffle an initialization and drop two useless asserts.
2017-08-16 17:10:40 +02:00
Benno Schulenberg bd770ea2e7 text: properly unindent lines that consist of only whitespace
The preceding 'for' loop has already established that all the lines are
either unindentable or composed of only blanks.  So if now a line cannot
be unindented, it means it is fully blank, so it can be simply skipped.

This fixes https://savannah.gnu.org/bugs/?51760.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-08-16 16:42:44 +02:00
Benno Schulenberg d8e5799e84 tweaks: adjust the indentation after the previous change
Also, trim or improve some comments.
2017-08-15 10:38:58 +02:00
David Lawrence Ramsey 0f4716e168 text: make unindenting remove from the beginning of the line
Also, only unindent when all selected lines can be unindented,
which means that the relative indentation will be preserved.
For this purpose, it ignores empty lines and lines consisting
of only whitespace.

When unindenting is not possible, a message is shown.

This fixes https://savannah.gnu.org/bugs/?47684.
2017-08-15 10:38:58 +02:00
David Lawrence Ramsey 749b1b3d79 text: make indenting add to the beginning of the line
Instead of inserting the extra whitespace after the current indentation
of a line, add it to the start of the line.  This causes a fixed amount
of visual whitespace to be added regardless of whether --tabstospaces
is used or not.

This fixes http://savannah.gnu.org/bugs/?51438,
and its ancestor https://savannah.gnu.org/bugs/?51408.
2017-08-15 10:38:58 +02:00
Benno Schulenberg 11072ed587 tweaks: sort the includes, so it's a little easier to see what is there 2017-08-06 19:40:30 +02:00
Benno Schulenberg 80686bb525 tweaks: remove includes that appear to be superfluous
Without them, nano still compiles for me, with everything enabled,
even when using --enable-debug, --enable-utf8, and --with-slang.
2017-08-06 09:08:30 +02:00
David Lawrence Ramsey ac2c81fad1 tweaks: correct a comment typo and an indentation error 2017-07-31 21:42:39 +02:00
Benno Schulenberg 5dcf375f33 linting: skip the introductory message produced by 'gcc -fshow-column'
Assume that a linter line that contains an actual error message or
warning includes a colon followed by a space -- something that that
opening message from a modern gcc lacks.
2017-07-29 13:15:22 +02:00
Benno Schulenberg 50379cc4ff tweaks: elide an unneeded pointer 2017-07-27 22:05:19 +02:00
David Lawrence Ramsey e2d3ee2364 tweaks: replace a misplaced tab with a space 2017-07-27 21:58:00 +02:00
Benno Schulenberg 79c836b11b tweaks: drop some debugging stuff, and frob two comments 2017-07-27 21:45:53 +02:00
Benno Schulenberg c24432edc4 linting: don't try to put the cursor at a negative x position
Human column numbers are one-based, whereas x positions are zero-based.
Converting from the one to the other involves subtracting one.  But when
the linter message does not provide a column number, the latter defaults
to zero.  Catch that case and change the number to one.

This fixes https://savannah.gnu.org/bugs/?51550.
2017-07-26 21:31:41 +02:00
David Lawrence Ramsey 85bffcfeb9 tweaks: use charalloc() instead of (char *)nmalloc() * sizeof(char)
The charalloc() macro does exactly this.
2017-07-25 21:50:13 +02:00
David Lawrence Ramsey 381a386b01 weeding: drop the forreal parameter from place_the_cursor()
Commit 28beb3f added the 'forreal' parameter to prevent spotlight() from
placing the cursor wrongly due to an invalid placewewant.  However, since
the variable-width softwrap overhaul (specifically, since commit 8490f4a),
place_the_cursor() no longer checks placewewant, so the parameter is no
longer needed.

Furthermore, dropping 'forreal' and thus always setting current_y won't
affect the operation of spotlight(), since the only functions that use
spotlight() (do_replace_loop() and do_int_spell_fix()) both call
edit_refresh() beforehand, which means that current_y will already
have been set to the value it will be set to again.
2017-07-24 21:07:42 +02:00
Benno Schulenberg 14c5f03e38 tweaks: rename another constant, to be more precise 2017-07-14 16:18:41 +02:00
Benno Schulenberg 1e2d9a697a tweaks: rename a constant, to match the corresponding option 2017-07-14 16:14:02 +02:00
Benno Schulenberg 5df47bfef6 display: avoid a jumpy cursor by redrawing bottom bars only when needed
The help lines need to be redrawn one step after a justification
(whether it has been undone or not, to replace "Unjustify" with
"Uncut" again for ^U), and after switching buffers (to update a
possibly changed tag for ^T).

This fixes https://savannah.gnu.org/bugs/?51455.
2017-07-13 11:10:51 +02:00
David Lawrence Ramsey fb51d617fd text: adjust the comments in do_indent() and do_unindent()
Make them reflect the split into two functions, the direct use of
tabsize, and the difference in behavior between indent and unindent.
2017-07-12 17:24:46 +02:00
David Lawrence Ramsey 7e9799d42b text: remove the last usage of cols in do_indent() and do_unindent()
Since all indentation and unindentation is by a tab, or by a tab's
worth of spaces, use tabsize directly.
2017-07-12 17:23:46 +02:00
David Lawrence Ramsey d02c1993d8 text: normalize the indentation in do_indent() and do_unindent()
Also remove one unneeded blank line.
2017-07-12 16:58:23 +02:00
David Lawrence Ramsey 42f5a84c6f text: remove indent-related code from do_unindent() 2017-07-12 16:57:20 +02:00
David Lawrence Ramsey 109ad0915d text: remove unindent-related code from do_indent() 2017-07-12 16:56:36 +02:00
David Lawrence Ramsey ee52f45b01 text: remove unneeded references to cols from the indentation routines
The parameter 'cols', that indicates how many columns to indent or
unindent, is changed to be always positive, so the check for being
negative can go.  And it could never be zero anyway.
2017-07-12 16:51:21 +02:00
David Lawrence Ramsey 2367f3d8e6 text: make do_unindent() an exact copy of do_indent()
This is the first step toward splitting them into two dedicated
functions, instead of letting do_indent() handle both cases.
2017-07-12 16:45:41 +02:00
Benno Schulenberg ecc7c26641 tweaks: rename a variable, to have more contrast 2017-07-09 21:11:01 +02:00
Benno Schulenberg fbbf501f8f tweaks: rename four functions, to be more distinct 2017-07-09 21:07:38 +02:00
David Lawrence Ramsey aa04ad4f83 replacing: make spotlight() account for varying chunk width
spotlight() now displays softwrapped lines chunk by chunk instead of all
at once.  Since softwrapped lines are no longer of constant width, the
latter approach would fail if softwrapping breaks the spotlighted text.

Instead of taking a string, spotlight() now takes the starting and ending
columns of that string.  Also, its handling of softwrapped lines is now
split off into a separate function, spotlight_softwrapped().
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey e375995d98 softwrap: add new functions for chunks of varying width
get_chunk_row() replaces the formula "column / editwincols".

get_chunk_leftedge() replaces "(column / editwincols) * editwincols".

get_last_chunk_row() replaces "strlenpt() / editwincols".

get_last_chunk_leftedge() replaces "(strlenpt() / editwincols) * editwincols".

This prepares us for any changes in those formulas, and for more such
functions later.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey 5bc4abeefe text: update placewewant properly when indenting/unindenting
If the position of the cursor changes horizontally,
placewewant should change with it.

This fixes https://savannah.gnu.org/bugs/?51407.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-07-07 12:09:14 +02:00
Benno Schulenberg 1439016c20 tweaks: recognize the empty string as comment inhibitor, instead of NULL 2017-07-07 10:15:17 +02:00
David Lawrence Ramsey 7c41c8641f tweaks: remove unneeded braces, and mark empty parameter list as void
This matches the style in the rest of the code.
2017-07-03 09:52:13 +02:00
Benno Schulenberg 14bd52ced8 display: wipe stale messages from the status bar straightaway
When blank_statusbar() has been called, make sure it is effective.

This fixes https://savannah.gnu.org/bugs/?51358.
2017-07-02 19:57:11 +02:00
Benno Schulenberg 7d46eff738 display: when back in the main loop, always redraw the help lines
(Well, redraw them when they're switched on, of course.)  Redraw
them so that they are shown correctly if their content changed.

This fixes https://savannah.gnu.org/bugs/?51356.
and fixes https://savannah.gnu.org/bugs/?51357.
2017-07-02 19:57:11 +02:00
David Lawrence Ramsey 2abe7c03fe text: make sure commenting is disabled when comment "" was specified
When the active syntax contains a comment command that specifies the
empty string, this should override the default comment of "#" and
should disable the Meta-3 keystroke.

To achieve this, the comment string is now set by default to "#" for
all syntaxes, so that it will be set when no comment command is given
(including for the "none" syntax), and is unset only by explicitly
specifying «comment ""» in a syntax file.

This fixes https://savannah.gnu.org/bugs/?51355.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-07-02 19:44:56 +02:00
Benno Schulenberg bf72cdd814 tweaks: rename two variables, to make a little sense
And rename a third variable, to match another in its style.
2017-07-02 12:05:12 +02:00
Benno Schulenberg 4239e5fe1a tweaks: put declarations always first, so it will compile on Haiku 2017-07-02 11:53:59 +02:00
Benno Schulenberg 6ad3d3d6c0 display: show the cursor position also when searching took a while
Achieve this by making the suppression flag global, so that we can
just reset it instead of making an improper call of do_cursorpos().

This fixes the secondary part of https://savannah.gnu.org/bugs/?51134.
2017-05-29 22:15:38 +02:00
Benno Schulenberg 5cdadc3eb1 tweaks: avoid an unused-variable warning when using --disable-comment 2017-05-19 11:55:37 +02:00
Benno Schulenberg 28beb3f9c5 replacing: don't let placewewant influence the placement of the cursor
When spotlighting the string to be replaced, placewewant isn't valid,
so tell place_the_cursor() to ignore its value to avoid the cursor
getting mistakenly placed at the beginning of the next row.

This fixes https://savannah.gnu.org/bugs/?50997.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-05-11 22:28:34 +02:00
Benno Schulenberg 46430999d5 build: make --enable-help properly depend on --enable-multibuffer
And in the process transform the token DISABLE_HELP to ENABLE_HELP.
2017-04-25 18:27:55 +02:00
Benno Schulenberg 040bd93cc4 tweaks: distinguish (in the comments) between buffers and linestructs
Call something a buffer when it refers to a linked list of linestructs,
and call something a linestruct when it is a struct that describes a
single line.
2017-04-19 17:48:52 +02:00
Benno Schulenberg a43eee6aec tweaks: fix compilation with --enable-tiny --enable-color --enable-speller
Also avoid an unused-variable warning, and trim a useless assert.
2017-04-19 14:30:36 +02:00
Benno Schulenberg 74f128859b tweaks: rename a constant, to match the corresponding option 2017-04-17 11:51:48 +02:00
Benno Schulenberg 3dc6ccbe86 tweaks: rename a function, to be more accurate
Because nothing gets reset to zero or to some initial value.
2017-04-17 11:29:29 +02:00
Benno Schulenberg 2439e1e451 linting: treat a tab as one "column", not eight
This fixes https://savannah.gnu.org/bugs/?47131.
2017-04-10 20:32:36 +02:00