Commit Graph

8680 Commits

Author SHA1 Message Date
Benno Schulenberg
132ed5c8f0 tweaks: instead of swapping the end points later, assign them correctly
(This also makes it clear that the naming of 'head' and 'tail'
is the wrong way around for CUT too.)
2020-02-28 15:25:23 +01:00
Benno Schulenberg
bd88b8b5a6 undo: do not mark the buffer as modified when pasting back nothing
This completes the fix for https://savannah.gnu.org/bugs/?57915.
2020-02-28 13:40:35 +01:00
Benno Schulenberg
0568f7a2b6 undo: do not try to paste back an empty cutbuffer
Trying to do so would dereference a NULL pointer in copy_node().

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

Bug existed since before version 2.2.0.
2020-02-28 13:40:06 +01:00
Benno Schulenberg
1a28b08694 tweaks: frob two statements, condense another, and add a comment
Also, remove two superfluous closings of file descriptors.  The second
one has most likely already been closed by send_data(), by closing the
tube, and the first one will be closed by exiting from the process.
2020-02-28 12:41:27 +01:00
Benno Schulenberg
3b3a6b12a7 tweaks: remove two superfluous checks
The single check when creating any CUT undo item is enough.
2020-02-28 10:28:23 +01:00
Benno Schulenberg
50213eee81 tweaks: reorder a case item, to have SPLIT_BEGIN always before SPLIT_END
Also, avoid two superfluous assignments of a message, as they get
overwritten immediately by other ones, and later with the same.

Furthermore, remove two pointless placements of the cursor.  Any
necessary placements are handled by the actual adding of data and
the breaking of lines in the ADD and ENTER items.
2020-02-27 16:38:52 +01:00
Benno Schulenberg
7cd2a7da7c tweaks: remove a superfluous assignment, and reshuffle a call 2020-02-27 15:09:36 +01:00
Benno Schulenberg
4f67f364bc tweaks: when undoing an addition or redoing a deletion, do not reallocate
Especially when undoing an addition, reallocating the line data is a
waste of time, because most likely other text will be added instead.

(This also removes a coding error in the redo code for a deletion:
it allocated too many bytes for the new line data: twice the amount
of the deletion too much.)
2020-02-27 14:16:49 +01:00
Benno Schulenberg
7cf08b93ff tweaks: don't bother reallocating the line data when undoing a line join 2020-02-27 13:51:56 +01:00
Benno Schulenberg
474a1f0447 tweaks: rename to the same name two variables that have the same role 2020-02-27 13:46:57 +01:00
Benno Schulenberg
76d7fbd5ee tweaks: rename a variable, away from a single letter 2020-02-27 13:28:01 +01:00
Benno Schulenberg
8d87410c94 tweaks: rearrange a case item, so that PASTE is always after CUT
Also, for a REPLACE, the 'head' point does not need to be updated,
because a replacement does not change the cursor position.
2020-02-27 12:13:24 +01:00
Benno Schulenberg
1961c052c8 tweaks: simplify the undoing and redoing of an <Enter>
I don't know what I was thinking three years ago with this convoluted
'from_x' and 'to_x'.  When undoing an <Enter>, the cursor always needs
to be placed back at the 'head' point.  And the data always needs to be
copied starting from 'tail_x' (skipping any whitespace that autoindent
might have added).

When redoing an <Enter>, there is no need to reallocate and copy the
data of the line, it is enough to just clip it at the original cursor
position.  (This wastes some memory, but... how often does one redo
an <Enter>?  So, conciseness of the code is preferable.)
2020-02-27 12:11:58 +01:00
Benno Schulenberg
843dbd56ef tweaks: rename two more elements of an undo record, for symmetry
(Note that for a PASTE and a COUPLE_END the variables seem to be used
the wrong way around.  Maybe this can be improved.)
2020-02-27 10:08:48 +01:00
Benno Schulenberg
be3c54c670 tweaks: rename two elements of an undo record, to be more telling 2020-02-27 10:08:48 +01:00
Benno Schulenberg
01afcb243c tweaks: rename a variable, to get out of the way of a later rename 2020-02-27 09:35:23 +01:00
Benno Schulenberg
b0eb73f7b3 feedback: make sure that a later message can overwrite a short warning
This fixes https://savannah.gnu.org/bugs/?57901.

Bug existed since version 3.0, commit 25e98776.
2020-02-26 16:41:09 +01:00
Benno Schulenberg
1907174c5f tweaks: drop a check for something that will not occur
The check has been there for a few months, and will be there for
five more years in the next Ubuntu LTS.
2020-02-26 14:01:25 +01:00
Benno Schulenberg
4da604be5a tweaks: relocate a function to before its callers 2020-02-26 13:27:22 +01:00
Benno Schulenberg
43754bd11d cutting: let M-T cut a trailing empty line, but not nothing at all
This fixes https://savannah.gnu.org/bugs/?57900.

Bug existed since version 4.0, commit 67873e96.
2020-02-26 12:38:00 +01:00
Benno Schulenberg
acd9046093 tweaks: rearrange some conditions, for compactness 2020-02-26 12:10:28 +01:00
Benno Schulenberg
2fd6181873 cutting: with --cutfromcursor, allow ^K to cut the penultimate empty line
This fixes https://savannah.gnu.org/bugs/?57897.

Bug existed since version 4.0, commit 67873e96.
2020-02-26 11:55:19 +01:00
Benno Schulenberg
b15c5a7eaf tweaks: abort in three situations that should never occur
Since is_cuttable() was added just over a year ago, ^K will
not add an undo item when it doesn't actually cut anything.
2020-02-26 11:53:27 +01:00
Benno Schulenberg
1b1d60b9d7 tweaks: drop two comments that contain variable names
Grepping for those names shouldn't find comments.  Also, the name
of the relevant boolean is clear enough to not need a comment.
2020-02-25 16:59:27 +01:00
Benno Schulenberg
9c70fdaef9 syntax: spec: drop invalid parentheses after "Summary"
Also, add the missing "RemovePathPostfixes", add extra word boundaries,
and reshuffle and regroup some things.
2020-02-25 11:47:11 +01:00
Benno Schulenberg
fcbe5aedbd tweaks: use spaces when aligning things, not tabs
Also, remove a reference to the French man page that no longer exists.
2020-02-24 19:43:19 +01:00
Benno Schulenberg
6c6a3f6bd3 syntax: spec: colorize the date and author of changelog items differently
Also, remove superfluous parentheses, add missing edge-of-word markers,
correct the "ppciseries" keyword, and fold some regexes (or elements of
them) together.
2020-02-23 20:02:48 +01:00
Benno Schulenberg
e873121372 syntax: spec: add two missing % signs, and colorize also "%triggerprein"
Furthermore, actually colorize the header line of a %changelog entry,
and remove two redundant fragments and simplify their overrides.
2020-02-23 19:38:54 +01:00
Neal Gompa
ad52830fb8 syntax: spec: add some keywords that were added in RPM 4.15 and 4.13
In RPM 4.15, a number of new spec section features were introduced:

* %dnl                       - macro-engine level comments
* %elif, %elifos, %elifarch  - 'else if' stanzas for conditionals
* %sourcelist                - section for listing sources line by line
* %patchlist                 - section for listing patches line by line
* %generate_buildrequires    - script section after %prep for
                               generating build dependencies

(Reference: https://rpm.org/wiki/Releases/4.15.0.html.)

An enhancement added in RPM 4.13:

* Sections for file trigger stanzas

(Reference: https://rpm.org/user_doc/file_triggers.html.)

As these are being increasingly used in Fedora and other distributions,
it's quite helpful to have syntax highlighting be up to date on handling
them.

Signed-off-by: Neal Gompa <ngompa13@gmail.com>
2020-02-23 15:12:04 +01:00
Benno Schulenberg
c802f91f4e tweaks: remove some unneeded braces, not used elsewhere either 2020-02-21 17:07:11 +01:00
Benno Schulenberg
51913542f4 tweaks: rename a variable, and reshuffle a declaration 2020-02-21 17:02:24 +01:00
Benno Schulenberg
be7e000389 tweaks: pull the NUL-terminating of a string into a function
Also, avoid copying one byte too many that afterward gets
overwritten with '\0'.
2020-02-20 17:08:32 +01:00
Benno Schulenberg
1d4411a474 tweaks: elide a function call, by copying a byte directly
Now all remaining calls of measured_copy() have a "+ 1" in their
second argument, and can thus be simplified.  And each of those
calls is followed by terminating the string with a NUL byte, so
thát can be pulled into the function.
2020-02-20 16:38:14 +01:00
Benno Schulenberg
76f1a4af4f tweaks: add a different helping variable 2020-02-19 19:06:04 +01:00
Benno Schulenberg
bb1a0bd86c input: after reallocating a string, do not write to its old address
The old address has become invalid, and probably does not have enough
room for the write, thus causing a crash.

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

Bug existed since commit 8625609c from two days ago.
2020-02-19 18:54:01 +01:00
Benno Schulenberg
8b2b9654ab tweaks: condense a comment, reshuffle conditions, and remove unwanted one 2020-02-18 16:26:56 +01:00
Benno Schulenberg
60ae71bf3a softwrap: when typing goes beyond the bottom row, scroll just one row
This fixes https://savannah.gnu.org/bugs/?57851.

Bug existed since version 2.8.0, when scrolling per soft-wrapped chunk
was made possible.
2020-02-18 15:42:20 +01:00
Benno Schulenberg
8625609c2d tweaks: rename a variable, and add a helping one 2020-02-18 15:00:27 +01:00
Benno Schulenberg
3c4a4b04ce tweaks: normalize the indentation after the previous change
Also rewrap two lines, reshuffle three, and improve three comments.
2020-02-18 14:58:06 +01:00
Benno Schulenberg
b3faf353c9 tweaks: inject the entire burst of bytes at once into the edit buffer
Not doing it characterwise saves a reallocation, a memmove(), several
checks, and an update_undo() for each character over one.

This has been tested by temporarily setting 'bracketed_paste = FALSE'
instead of 'bracketed_paste = TRUE' in convert_sequence() in winio.c,
and then pasting stuff into nano.
2020-02-18 14:54:19 +01:00
Benno Schulenberg
f700b422be tweaks: call add_undo() before the character is actually added
And before the buffer size is adjusted, so that the add_undo()
doesn't need to correct the stored former size of the buffer.

This will allow the injection of multiple characters at once,
in the next commit.
2020-02-18 14:40:15 +01:00
Saagar Jha
1b2a2e6737 rcfile: fix an out-of-bounds read on empty lines
Signed-off-by: Saagar Jha <saagar@saagarjha.com>

Bug existed since commit 98f038ad from a week ago.
2020-02-17 12:11:40 +01:00
Benno Schulenberg
12e5c2f07d undo: for an automatic hard-wrap, store the correct previous buffer size
The SPLIT_BEGIN item gets tucked underneath the ADD item on the top of
the undo stack.  Thus: that SPLIT_BEGIN item should copy the 'wassize'
of the ADD item instead of storing the current buffer size.

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

Bug existed since the undo functionality was added, and existed
in this form since version 2.3.5, commit be10c2a4.
2020-02-17 11:41:52 +01:00
Benno Schulenberg
5c07a747bb tweaks: adjust some whitespace, reshuffle two ifs, and remove two braces 2020-02-17 11:29:13 +01:00
Benno Schulenberg
a9f7277b1b tweaks: remove a now-unused helper function 2020-02-16 12:33:29 +01:00
Benno Schulenberg
d13b6d6896 tweaks: elide an intermediate copy of an added character
In theory this would allow injecting more than one character at a time
into the edit buffer.  But the creation and updating of an undo item for
the addition or the deletion of a character are a bit strange.  For all
other operations and add_undo() is called before the operation, and an
update_undo() afterward.  But for an ADD, the add_undo() is called after
the operation, and for a DEL/BACK, the update_undo() is called before
the operation.  There is some logic to that, but things would be easier
to understand if all operations were handled the same: an add_undo()
beforehand (when needed), and an update_undo() afterward.
2020-02-16 12:32:10 +01:00
Benno Schulenberg
819066c5d5 tweaks: extend the undo data for deleting and backspacing more directly
To get rid of an intermediate copy of the deleted character.
2020-02-16 11:06:45 +01:00
Benno Schulenberg
a65982bffb tweaks: relocate eleven functions to before they are called 2020-02-14 19:10:21 +01:00
Benno Schulenberg
6b8f446b52 tweaks: rename a constant, and rename and relocate a function 2020-02-14 19:00:16 +01:00
Benno Schulenberg
2b97d6563d tweaks: correct a typo, improve two indentations, and rewrap a line 2020-02-14 16:03:15 +01:00