Commit Graph

187 Commits (97c8140ceab05f4ddc620632774abe40833774d9)

Author SHA1 Message Date
Benno Schulenberg d12191db5a tweaks: pass any special undo/redo messages to the add_undo() function
For the three operations (justification, spell checking, and filtering)
that need to undo or redo two suboperations (cutting and then pasting)
in one go, pass the message that describes the operation to add_undo(),
so that the undo item does not need to be modified after the call.

This looks better, but does add some twenty NULL parameters elsewhere.
2019-10-09 19:21:27 +02:00
Benno Schulenberg 53d4224be9 cutting: do nothing when trying to chop a word leftward at start of file
Instead of marking the buffer as modified, provide the feedback that
"nothing was cut", like when trying to chop a word rightward at the
end of the buffer.

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

Bug existed since version 4.4, commit 4314b8de.
2019-10-07 17:24:18 +02:00
Benno Schulenberg ab6390cad0 tweaks: remove two superfluous macros, as sizeof(char) is always 1 2019-09-18 15:20:08 +02:00
Benno Schulenberg 63e04ac31e tweaks: make a function name unique, to not overlap with others 2019-08-09 19:34:03 +02:00
Benno Schulenberg 4314b8ded3 display: blank the status bar on a successful cut or paste
But don't blank it when using the word-deletion functions.

This addresses https://savannah.gnu.org/bugs/?56564.

Original-patch-by: Bill Hager <prog00@protonmail.com>
2019-08-03 19:32:54 +02:00
Benno Schulenberg a578d2706c copying: do not prevent M-6 from copying emptiness into the cutbuffer
The check mistakenly prevented the user from copying a region that
ended at EOF.  Removing the check also gives the user a way to clear
the cutbuffer (with M-A M-6 or ^6 M-6, for example).

This fixes https://savannah.gnu.org/bugs/?56563.
Reported-by: Liu Hao <lh_mouse@126.com>
2019-07-29 19:00:22 +02:00
Benno Schulenberg 967f581860 tweaks: adjust some whitespace and rewrap a few lines
And remove two unneeded casts.
2019-06-09 20:03:44 +02:00
Benno Schulenberg 781c7a7a5f chars: create a dedicated function for getting the length of a character
Instead of calling in twenty places parse_mbchar(pointer, NULL, NULL),
use a simpler and faster char_length(pointer).  This saves pushing two
unneeded parameters onto the stack, avoids two needless ifs, and elides
an intermediate variable.

Its main purpose will follow in a later commit: to speed up searching.
2019-06-09 18:38:46 +02:00
Benno Schulenberg aa205f58ca tweaks: rename a bunch of variables, to become identical to others 2019-06-09 17:07:02 +02:00
Benno Schulenberg fb17929fab tweaks: use FALSE for booleans instead of zero
Also adjust some indentation and reduce the scope of a variable.
2019-06-09 10:41:14 +02:00
Benno Schulenberg 93edd12099 tweaks: rename a function, to be clearer and to stop using an old abbrev 2019-05-24 18:56:34 +02:00
Benno Schulenberg 8720cfcce9 tweaks: rename two more functions, to be simpler too 2019-05-04 11:21:45 +02:00
Benno Schulenberg 954c4d03ac tweaks: rename two functions, to be simpler 2019-05-04 11:21:45 +02:00
Benno Schulenberg edf6995be4 zapping: use the 'keep_cutbuffer' logic to keep undo items apart
The 'keep_cutbuffer' variable becomes FALSE whenever there is cursor
movement or there was a marked region.  Use this variable to simplify
the condition for creating a new ZAP undo item.  But then typing the
'zap' shortcut should not cause the variable to be set to FALSE.

This fixes the first part of https://savannah.gnu.org/bugs/?56261.

Bug existed since zapping was introduced, in version 3.2.
2019-05-04 11:18:51 +02:00
Benno Schulenberg b50d5758ef zapping: disjoin a zap command from earlier ones when the mark is set
This fixes the third part of https://savannah.gnu.org/bugs/?56261.

Bug existed since zapping was introduced, in version 3.2.
2019-05-03 12:58:17 +02:00
Benno Schulenberg 6c4d0d87f0 tweaks: remove a condition that has become superfluous
After the previous change, a copy command will break a chain of cut
commands, so there is no need any more to verify that the line number
hasn't changed.
2019-05-03 12:41:49 +02:00
Benno Schulenberg a962bceca6 copying: let a copy command break a chain of cut or zap commands
This fixes the second part of https://savannah.gnu.org/bugs/?56261.

Bug existed since zapping was introduced, in version 3.2.
2019-05-03 12:33:42 +02:00
Benno Schulenberg e0c5c589ad tweaks: remove a superfluous condition, in three places
When 'last_action' has a specific value, then necessarily there must
exist a corresponding current undo item.

(The condition is already absent in do_deletion(), for the BACK and DEL
undo items, and it works fine there.)
2019-05-03 12:18:04 +02:00
Benno Schulenberg 3346c5395e tweaks: place a function better, and reduce some comments to a single one 2019-05-02 10:17:10 +02:00
Benno Schulenberg 083218aca5 tweaks: rename two parameters, to differentiate them from function names 2019-05-02 10:17:04 +02:00
Benno Schulenberg fd3b3bc1d6 cutting: clear the cutbuffer when the previous operation was copying
The cut and copy operations (^K and M-6) are different operations and
one should not add to the cutbuffer created by the other.

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

Bug existed since version 3.0, commit 71f85937.
2019-05-02 09:27:37 +02:00
Benno Schulenberg 85fc41470b tweaks: stop passing 'cutbuffer' and 'cutbottom' back and forth
All extractions are done into the cutbuffer, so it is pointless to pass
'cutbuffer' and 'cutbottom' in and back out as parameters all the time.
Just use those global variables directly.

Also, rename the function as there is no longer a buffer among its
parameters.
2019-05-01 11:33:37 +02:00
Benno Schulenberg 2b9dd6c574 tweaks: don't bother saving and restoring 'cutbottom' all the time
The 'cutbottom' variable is only ever used when cutting or copying
consecutive lines: for appending the current line to the already
existing lines in the cutbuffer.  As soon as some other operation
is performed, 'cutbottom' becomes irrelevant, it could be set to
anything, it doesn't matter: the pasting of the cutbuffer does not
use the value of 'cutbottom', nor does any other operation.
2019-05-01 11:19:14 +02:00
Benno Schulenberg 9e44a53be7 copying: scroll just one line when M-6 is pressed on the bottom row
This fixes https://savannah.gnu.org/bugs/?56249.

Bug existed since version 2.6.0, commit 318ed6b1.
2019-04-30 19:31:44 +02:00
Benno Schulenberg 0c561f0325 copying: make M-6 do nothing when at end of buffer 2019-04-30 19:03:18 +02:00
Benno Schulenberg e5831f81bb tweaks: rename two variables, to be less cryptic 2019-04-30 18:41:05 +02:00
Benno Schulenberg 17aa9371b5 tweaks: rename a function, to better indicate what it does 2019-04-30 10:27:10 +02:00
Benno Schulenberg 7c08e8ea69 cutting: ignore the mark when a word is deleted
Just like for deleting a word to the left, the mark should be ignored
also when deleting a word to the right.

This fixes https://savannah.gnu.org/bugs/?56241.
2019-04-30 09:53:10 +02:00
Benno Schulenberg 37eccd3117 tweaks: rename a function, to be more fitting
Also, adjust some whitespace, for esthetics.
2019-04-28 11:01:51 +02:00
Benno Schulenberg 5601b9a66b tweaks: switch back from checking FINAL_NEWLINE to checking NO_NEWLINES
This effectively reverts commit b6a76223 from a good two months ago.
2019-04-07 08:50:35 +02:00
Benno Schulenberg f585403b36 build: add src/cut.c to the list of files with translatable strings
(Also, adjust the style of one of the messages.)

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

Bug existed since version 4.0, commit 50e8f8aa.
2019-04-06 09:40:53 +02:00
Benno Schulenberg cddfcb1b9d tweaks: rename a struct element, to make sense 2019-03-21 17:23:49 +01:00
Benno Schulenberg 6755b7c0a0 tweaks: rename four functions, to make more sense 2019-03-21 17:18:50 +01:00
Benno Schulenberg aac4fc46e9 tweaks: rename a type, to make more sense 2019-03-21 17:08:52 +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
Benno Schulenberg a20340b5a8 copyright: update the years for significantly changed files 2019-03-10 17:03:42 +01:00
Benno Schulenberg 79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg b5ca8a00af tweaks: rename three functions and two symbols, to match the new wording 2019-02-24 17:32:17 +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 e7557a9293 tweaks: condense a handful of comments 2019-02-12 17:32:56 +01:00
Benno Schulenberg 0c42c51aa4 tweaks: rename two variables, to indicate better what they mean 2019-01-06 15:46:23 +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 911eb0cf2a tweaks: rename and invert a function, to avoid double negatives 2019-01-06 13:12:44 +01:00
Benno Schulenberg 67873e961b cutting: cover the corner cases where cut commands do not cut anything
Give the correct feedback in those cases and do not add an undo item.

This fixes both parts of https://savannah.gnu.org/bugs/?55396.
2019-01-06 13:07:20 +01:00
Benno Schulenberg 50e8f8aab9 cutting: give feedback when otherwise nothing happens
This makes the cutting and pasting keystrokes somewhat discoverable.
2019-01-05 17:39:05 +01:00
Benno Schulenberg ce6f320947 cutting: when ^K does not actually cut anything, do not add an undo item
Act the same way for M-T and for zapping.

This addresses https://savannah.gnu.org/bugs/?55330.
2019-01-05 17:36:34 +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 125cc0cd74 tweaks: elide a tiny function by making a variable global
And in the bargain it makes things clearer, because the name
cutbuffer_reset() is misleading.
2018-12-30 13:36:29 +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 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