Commit Graph

910 Commits (aa205f58ca003eb4f73ae6b2770283f2a0c4663c)

Author SHA1 Message Date
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