Commit Graph

252 Commits (bec0cdcb5456bc1e6fd40745f7af78a7f1f31c69)

Author SHA1 Message Date
Benno Schulenberg fdc0b0ac24 tweaks: rename three variables, to follow the general scheme
Also rewrap a line, reshuffle two others, and remove two redundant
comments.
2021-09-20 10:08:56 +02:00
Benno Schulenberg 189960c467 cutting: copy anchors into the cutbuffer, so that undo can restore them
When a segment of text is extracted, copy any anchors that it has
into the cutbuffer, so that they get saved in the undo item, so that
an undo will put these anchors back on the lines where they were,
instead of leaving an inherited anchor at the top of the segment.

And when text is pasted, clear any anchors in it, so that they will
not travel nor multiply.

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

Bug existed since version 5.0, since anchors were introduced.
2021-09-19 11:29:39 +02:00
Benno Schulenberg 802a20b222 tweaks: rename a variable, to be more grammatical 2021-09-16 12:32:19 +02:00
Benno Schulenberg cf0820549b tweaks: avoid calling extra_chunks_in() when not softwrapping
The function is somewhat costly; better avoid it whenever possible.
2021-04-22 12:19:09 +02:00
Benno Schulenberg 2cdff6c32c tweaks: adjust two comments, and reshuffle two fragments
Also rename two variables, to be more fitting.
2021-04-21 16:52:35 +02:00
Benno Schulenberg 49d8b99e4f softwrap: avoid time-consuming computations, to burden large files less
Whenever softwrap was toggled on or line numbers were toggled on/off or
the window was resized, the extra rows per line needed to be recomputed
for ALL the lines.  For large files with many long lines this was too
costly.

(This change causes the indicator to have an incorrect size when there
are many softwrapped chunks onscreen, but that will be addressed later.)

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

Problem existed since version 5.0, since the indicator was introduced.
2021-04-21 16:40:20 +02:00
Benno Schulenberg 1fdd23d347 display: for a large paste or insertion, recalculate the multiline cache
When a large piece of text or code is pasted or inserted, it could
contain matches for start= and end= regexes, and backtracking from
the current screen could mistake an end for a start and could thus
miscolor things.  Avoid this by recalculating the multiline cache
for pastes and insertions that cover more than a screenful.

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

Bug existed since version 2.6.0, but existed also before 2.4.3.
2021-02-03 17:00:28 +01:00
Benno Schulenberg 6360e4170a copyright: update the years for the FSF 2021-01-11 14:22:51 +01:00
Benno Schulenberg b86f7868d1 feedback: differentiate between remarks, mistakes, and information
Remarks are about unsurprising things but it's good to give feedback
on them; "mistakes" are unexpected things, and get colored like an
error; and information is something that the user requested and thus
needs to stay on the status bar until the next keystroke.
2020-12-23 12:17:06 +01:00
Benno Schulenberg a4675acdba copyright: update to the current year for significantly changed files 2020-11-30 12:01:47 +01:00
Benno Schulenberg 687efd210c moving: skip combining characters and other zero-width characters
This makes the cursor move smoothly left and right -- instead of
"stuttering" when passing over a zero-width character.

Pressing <Delete> on a normal (spacing) character also deletes
any zero-width characters after it.  But pressing <Backspace>
while the cursor is placed after a zero-width character, just
deletes that zero-width character.  The latter behavior allows
deleting and retyping just the combining diacritic of a character
instead of the whole character.

This addresses https://savannah.gnu.org/bugs/?50773.
Requested-by: Mike Frysinger <vapier@gentoo.org>
2020-11-17 10:21:50 +01:00
Benno Schulenberg 89f8d71001 feedback: don't give a hint for <Bsp>, and not after an Alt+key was used 2020-09-19 12:15:07 +02:00
Benno Schulenberg 34cfa55f58 feedback: show helpful message for the first ^H at the top of the file
Typing ^H (by default equivalent to Backspace) at the start of the file
is not useful.  When it happens, assume that the user is new and tried
to ask for Help.  So... explain what the caret and the "M-" in the help
lines mean.
2020-09-18 16:29:34 +02:00
Hussam al-Homsi c87bc1d55f tweaks: stop casting the return of malloc() and friends
Those casts are redundant, and sometimes ugly.  And as the types of
variables are extremely unlikely to change any more at this point,
the protection they offer against miscompilations is moot.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-08-31 12:17:27 +02:00
Benno Schulenberg dcd34b246a tweaks: move a function to the file where it is used the most
Also, fully exclude the function from the tiny version.
2020-07-19 10:43:26 +02:00
Benno Schulenberg 90f6342fd1 tweaks: rename two header files, to be distinct and not an abbreviation 2020-06-20 12:09:31 +02:00
Benno Schulenberg a2b85e0c12 indicator: recompute the extra rows also when justifying and resizing
And when the margin changes (when line numbers are switched on or off,
or when the buffer grows or shrinks), and when a piece of text from a
different buffer with a different margin is pasted.

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

Bug existed since commit 9a9f36fc from yesterday.
2020-06-07 12:16:15 +02:00
Benno Schulenberg 786d2221e1 indicator: recompute the extra rows also for cut/paste/split/join
This fixes https://savannah.gnu.org/bugs/?58511.

Bug existed since commit 9a9f36fc from yesterday.
2020-06-07 11:05:14 +02:00
Benno Schulenberg 9a9f36fca7 indicator: rework how the "scrollbar" is computed when softwrapping
Instead of storing for each line the ordinal number of the first chunk
in that line, simply store the number of extra chunks in the line.

It now takes some more computation to actually draw the scrollbar, but
it saves a lot of computation when just inserting or deleting characters
(when using --softwrap and causing a change in chunk count).

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

Bug existed since commit 6bccedb3 from two days ago.
2020-06-06 19:21:23 +02:00
Marco Diego Aurélio Mesquita 6bccedb319 display: support the position indicator also when --softwrap is used
A new member ('chunk_nr') is added to each 'linestruct', to store
the serial number of the first chunk of that line, so that, when
softwrap is on, the scroll-bar thing can be computed relative to
chunks instead of relative to actual lines.

To guarantee that 'chunk_nr' is correctly synced, the buffer is
renumbered whenever the number of chunks in a line changes, and
also when softwrap is toggled on, and when buffers are switched.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-06-04 18:52:28 +02:00
Benno Schulenberg cd594b85f4 general: make five tools accessible through the "Execute Command" menu
Instead of creating a special Tools menu, add the five functions that
affect the whole buffer to the "Execute Command" menu.  There is room
for these five functions there, and they kind of fit in because three
of them (Speller, Linter, and Formatter) actually invoke an external
command, and Full Justify could have been implemented externally, and
the destructive Cut Till End ought to have required a double keystroke
since the beginning.
2020-05-30 18:56:51 +02:00
Benno Schulenberg 40a0463250 tweaks: reshuffle an assignment, for conciseness, and rename a variable 2020-05-17 11:34:22 +02:00
Benno Schulenberg 821fbf713d tweaks: reshuffle a bit of code, to elide an #ifndef 2020-05-14 11:44:21 +02:00
Benno Schulenberg ebc2364742 tweaks: move a fragment of code to the one branch that needs it
When two lines are joined, 'refresh_needed' is already set to TRUE,
so only when a midline character is deleted the check for a changed
number of chunks is needed.
2020-05-14 11:43:30 +02:00
Benno Schulenberg 15fadd700a tweaks: rename a function, to be more precise, and reshuffle it 2020-05-13 12:43:22 +02:00
Benno Schulenberg 5755ecdbfc options: let --afterends affect also the deleting of words (Ctrl+Delete)
It makes more sense that <Ctrl+Delete> deletes the same thing as what
<Shift+Ctrl+Right> would select.

Suggested-by: Liu Hao <lh_mouse@126.com>
2020-04-14 12:14:49 +02:00
Benno Schulenberg 40053593a8 general: rename "bookmark" to "anchor", to sound less permanent 2020-04-13 11:25:29 +02:00
Benno Schulenberg 732cf88786 text: retain a bookmark when two lines are joined or something is cut
Also, do not copy the bookmark into the cutbuffer, so it will not get
pasted elsewhere.
2020-04-13 11:10:23 +02:00
Benno Schulenberg 19a6120dc8 tweaks: rename a function, to be more general and clearer 2020-04-09 12:27:07 +02:00
Benno Schulenberg cd3db5fcc4 cutting: change the implementation of cutting to not use partitioning
This has the pleasing effect of not changing the linestruct of the
succeeding line when a line is cut.

This addresses https://savannah.gnu.org/bugs/?56226.
2020-04-09 11:45:10 +02:00
Benno Schulenberg ae5a4ecee2 cutting: overhaul the pasting routine, to not make use of partitioning
This has the pleasing effect of not changing the linestructs of the
current line nor of the line after it (if any).
2020-04-09 11:29:44 +02:00
Benno Schulenberg a0119b83ca tweaks: add two comments, and improve another 2020-04-08 11:25:02 +02:00
Benno Schulenberg dba7a8a70a copying: do not forget to update the screen when M-6 is pressed
This fixes https://savannah.gnu.org/bugs/?58140.

Bug existed since commit f52b6cf1 from one week ago.
2020-04-08 11:04:35 +02:00
Benno Schulenberg f3624b1b87 build: fix compilation when configured with --enable-tiny 2020-04-03 17:12:28 +02:00
Benno Schulenberg 1a2c9044d7 display: blank the status bar for a copy operation, like for cut & paste
This way an earlier "Copied nothing" or other message cannot confuse
the user.
2020-04-03 16:34:27 +02:00
Benno Schulenberg 958e3ec201 feedback: show a message also when trying to copy an empty region 2020-03-31 19:44:32 +02:00
Benno Schulenberg ce9cfdaa45 tweaks: normalize the indentation after the previous change
Also improve a comment.
2020-03-31 19:44:32 +02:00
Benno Schulenberg 56a111afa3 tweaks: fold two blocks into each other, to elide three overlapping cases 2020-03-31 19:42:22 +02:00
Benno Schulenberg 38bbdf8fc3 tweaks: change a helping variable, to make two blocks still more similar 2020-03-31 19:27:07 +02:00
Benno Schulenberg a0e523cd4b tweaks: add a helping variable, to slightly condense the code
And to prepare for folding two blocks together.
2020-03-31 19:21:38 +02:00
Benno Schulenberg 7660849b8f tweaks: invert a condition, to see the similarity between the two modes
The two modes being: the normal full-line cutting, and --cutfromcursor.
2020-03-31 19:17:17 +02:00
Benno Schulenberg 4b814698bd copying: with --nonewlines, don't add a final newline to the cutbuffer
This fixes https://savannah.gnu.org/bugs/?58086.

Bug existed since commit f52b6cf1 from yesterday.
2020-03-31 19:12:46 +02:00
Benno Schulenberg 96046f1e82 copying: when using M-6, copy the final line in the buffer just once
When using --nonewlines and the cursor has arrived at the end of the
final line, each press of M-6 would add another copy of that line to
the cutbuffer.  That is clearly not the right behavior.

Also, give feedback when a press of M-6 does not actually copy anything.

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

The bug was old -- it existed since before version 2.2.0.
2020-03-31 17:59:21 +02:00
Benno Schulenberg d9943120ed tweaks: move two functions, to have them in a more logical order
The logical order being: cut, copy, paste.
2020-03-30 19:20:18 +02:00
Benno Schulenberg a1907d77f8 tweaks: add a helping variable, in order to unwrap three lines
Also, move an administrative thing to after the actual operations.
2020-03-30 19:13:50 +02:00
Benno Schulenberg f25a3f8a36 tweaks: elide three functions that are called just once
The function that they were called from has shrunk a lot,
so there is now room to write their content out in full.
2020-03-30 19:05:57 +02:00
Benno Schulenberg d1521c584d tweaks: elide a now-unused parameter -- it is always FALSE 2020-03-30 16:55:30 +02:00
Benno Schulenberg f52b6cf19f copying: change the implementation, away from cutting plus copying back
First cutting the text to be copied (before copying it back into the
buffer) had unwanted side effects: it moved the cursor, and changed
the linestructs of the current line and the line where the mark was.

[This takes thirty more lines, but the idea is to later get rid of
the partitioning routines entirely.]
2020-03-30 16:55:17 +02:00
Benno Schulenberg 59040169ed tweaks: get rid of a bunch of annoying casts, and thus condense the code 2020-03-29 20:17:32 +02:00
Benno Schulenberg 0cc2104257 tweaks: elide a parameter, by calling the relevant function beforehand
This means that in most cases mark_is_before_cursor() is called twice:
once before get_region() is called, and once by get_region() itself.
This small duplication of effort is acceptable: the affected functions
are not time critical, and it makes the code shorter.
2020-03-29 13:22:17 +02:00