Commit Graph

368 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
507e21f84e Rename word-togglecase to word-invertcase.
As suggested by Jürgen.
2024-10-15 17:36:19 +02:00
Jean-Marc Lasgouttes
afc524da3f Add LFUN_WORD_TOGGLECASE (word-togglecase)
The new function word-togglecase is a companion of word-upcase and
word-lowcase: it toggles each character between lowcase and upcase,
which is useful when one FORGOT THE cAPS lOCK KEY.

Add bindings (except for emacs) and a menu entry.
2024-10-14 18:19:09 +02:00
Jean-Marc Lasgouttes
3d2ffc5b53 remove spurious comment 2024-10-14 17:30:32 +02:00
Jean-Marc Lasgouttes
3f5b836aa9 Make some code that handle authors more readable
Create accssors authodmap() in BufferParams.

Use [] operator instead of find().

Hopefully this will avoid to confuse Coverity scan.
2024-09-10 15:32:49 +02:00
Jean-Marc Lasgouttes
16be88ca18 Fix update of cursor in tab-delete when there is a selection
The position of the cursor should not be decreased if it is already at
the start of the paragraph. This can lead to a crash when trying to
display the caret.
2024-08-30 16:56:16 +02:00
Juergen Spitzmueller
0659af15fb Add InsertCotext tag to InsetLayout
Avoids hardcoding of insets, and this behavior is possibly useful to
other insets than index and nomencl

We take this on yesterday's layout format change
2024-08-13 07:29:14 +02:00
Juergen Spitzmueller
a5841b3312 Transform InsetNomenclature to a collapsible
Fixes: #10460, #12595, #6353
2024-08-12 12:33:16 +02:00
Juergen Spitzmueller
181c8ce7c1 re-implement LFUN_REFERENCE_INSERT
this is in preparation of another feature
2024-07-28 10:37:30 +02:00
Jean-Marc Lasgouttes
6e81f31722 Rewrite statistics code
The statistics code is known to be very slow, because it relies on
DocIterator to go through the buffer.

This commit introduces a new Statistics class that encapsulates the
main code, along a virtual method Inset::updateStatistics() that
allows to fine-tune how counting is done inset by inset.

This is a faithful bug-for-bug reimplementation.

The new code appears to be 3x faster than the old one.

See bug #12929 for a discussion about statistics update woes.
2024-07-24 18:07:04 +02:00
Jean-Marc Lasgouttes
485f5afc21 Fixup 2bdd691130: remove two more Update::SinglePar instances
They do not do what the author(s) of these lines thought it would do,
and can create crashes.
2024-07-20 17:13:40 +02:00
Jean-Marc Lasgouttes
82f387dabc Fix faulty undo recording
The recordUndo() call is very wrong, since we may be inserting over a
selection covering several paragraphs (undo itself works at paragraph
granularity).

recordUndoSelection() is the right operation in this case. It is
equivalent to recordUndo() when there is no selection.
2024-07-16 15:43:11 +02:00
Jean-Marc Lasgouttes
2bdd691130 Remove useless SinglePar update when scrolling in text
Using SinglePar does not majke sense here since the paragraph is not
modified and it might even not have a position yet.

This fixes a crash in BufferView::singleParUpdate, which is not
prepared (yet) to such situations.
2024-07-03 17:31:38 +02:00
Pavel Sanda
fe9573ee8b Let the middle button pasting respect newlines by default.
This makes it in sync with the new default for Edit > Paste operation.
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg222233.html
2024-06-24 22:35:01 +02:00
Juergen Spitzmueller
2a9648fc4c Return false on invalid input in Font::fromString()
Fixes crash with invalid font-update lfun
2024-06-09 08:09:01 +02:00
Jean-Marc Lasgouttes
a185642746 Text::dispatch: ignore single par update when there is a full update
Reorder the tests so that, when the flag Update::SinglePar has been
specified, it does not take precedence over Update::Force flag.

This fixes the crash with inset-split.
2024-06-07 16:52:04 +02:00
Juergen Spitzmueller
fe4f0dbf0b Consider CT in dash mechanism (#13062) 2024-05-11 13:07:32 +02:00
Jean-Marc Lasgouttes
9f33db8f53 Fix up 5577e877: remove logic error
Commit 5577e877 introduces forceUpdateBuffer() to delay actual
updatBuffer() calls to a central place.

In Cursor::upDownInText, the updateNeeded flag (which triggers
Update::Force update flag) is set to true when Cursor::checkDepm
returns true. This is fine, except that checkDepm also leads to a
forceBufferUpdate() call.

The logic in the method was such that, when updateNeeded is already
true when entering, forceBufferUpdate() will be called even though
checkDepm did not request it.

Fixes a slight delay with selecting in MergedManual (the manual of
manuals).
2024-05-03 14:38:32 +02:00
Jean-Marc Lasgouttes
2660df9b99 Move Lexer to support/ directory (and lyx::support namespace)
This requires quite a bit of trivial code shuffling.
2024-04-28 12:23:13 +02:00
Jean-Marc Lasgouttes
c7f53afd31 Fix compilation with msvc 2019
'uint' is not defined, 'unsigned int' is better.
2024-04-07 20:43:00 +02:00
Jean-Marc Lasgouttes
73678dcde9 Avoid full metrics computation when entering/leaving inset
Annotate function LFUN_FINISHED_xxx to indicate that they do not
require a full metrics computation.

Remove an "optimization" that meant that when the cursor changed
inset, a full metrics computation was requested.

Part of bug #12297
2024-04-05 13:06:26 +02:00
Jean-Marc Lasgouttes
5e8578837f Avoid some full metrics computations related to math previews
When entering/leaving a math hull inset, a Update::Force flag was set,
in case the metrics of the inset would change because of a switch
between normal and preview representation.

When entering the inset, this code is now used only when the inset was
in preview mode.

In both cases, Update::Force is replaced with Update::SinglePar.

This requites in Text::dispatch to honor Update::SinglePar when it has
been set by some lfun, even when singleparupdate is false.

Part of bug #12297.
2024-04-05 13:06:26 +02:00
Juergen Spitzmueller
698f922d19 Do not enter page break in heading (#13040)
Rather than that, put it before or after, or disallow,
depending on the position.
2024-03-28 18:03:54 +01:00
Jean-Marc Lasgouttes
789a886af8 fixup 97cf2b6a: avoid leak 2024-02-27 18:37:07 +01:00
Jean-Marc Lasgouttes
97cf2b6aef Avoid crash when inserting macro template in tabular inset
The issue here is that macro templates are forbidden in InsetTabular
(why? I do not know) and Text::getStatus does not enforce that
properly. Text::insertInset is called and does nothing (because
insertion is forbidden) and yet the cursor is changed to point into
this non existent inset.

Solution:

1/ block insertion of macro templates when not allowed

2/ (additional safety) when insertion of a math macro inset failed, do
   not try to set cursor inside the non-existing inset.

Additionally clarify comments.
2024-02-27 18:21:57 +01:00
Jean-Marc Lasgouttes
04a24211a6 Fix word selection expansion when going to the left
The proper way to do word-wise selection is to compute the words
around both the cursor and the anchor.

Note that code is uglier than it should because CursorData::normalAnchor()
returns a CursorSlice instead of a DocIterator.

Fixes bug #12533.
2023-11-06 11:53:03 +01:00
Juergen Spitzmueller
e9998fb1cc Enter table after insertion (#12101)
posForward() jumped over the inset, which is not what is wanted here,
I think (cf. other inset insertion methods)
2023-10-22 10:19:50 +02:00
Juergen Spitzmueller
8e619462e1 Disable OUTLINE functions when min or max toclevel is reached 2023-10-21 13:49:50 +02:00
Juergen Spitzmueller
2b33da5944 Let OUTLINE functions jump from section to part if there is no chapter
Fixes #12938
2023-10-21 13:48:50 +02:00
Juergen Spitzmueller
d9af7a0fff Fix change tracking glitch (#12912) 2023-09-16 13:31:00 +02:00
Juergen Spitzmueller
91186013ba Fix result of deleteSpaces()
With change tracking on, spaces that are marked as ADDED are really
removed (and not marked deleted) if the changeAuthor is the current
author; see Paragraph::eraseChar().

The function tried to account for that but had the logic upside down.

Consequently actually deleted spaces haven't been counted and the
result was off.

This fixes an assertion when pasting in CT parts with deleted stuff
(#12901)
2023-09-13 13:50:40 +02:00
Jean-Marc Lasgouttes
0912f7c356 Update caret if needed when changing depth
Fixes bug #12856.
2023-08-30 13:45:00 +02:00
Juergen Spitzmueller
effd65a586 Amend 101363352c
Instead of just disabling MOUSE_MOTION on inset buttons, we now register
the coordinates where the latest mouse press happens, and if that's on
the inset button we are on when releasing, we toggle the inset.

Thus, minimal unintentional mouse movements don't lead to the button not
to respond.
2023-08-24 09:56:09 +02:00
Pavel Sanda
05276c5bea Our default for paste operation should preserve newlines.
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg220061.html
2023-08-06 17:05:55 +02:00
Juergen Spitzmueller
0b463bfe0f Add AllowedInInsets and AllowedInLayouts InsetLayout tags
This allows to restrict the use of flex insets to specific contexts.

Note that this is currently very basis. It only considers immediately
containing insets/layouts and can be surpassed via cut and paste.

The use case that made me finally implement this are macros in covington
that make sense only in specific environments (but also consider \inst
in some article classes)
2023-07-25 13:37:07 +02:00
Pavel Sanda
fe953000ed Fix application of PARAGRAPH_PARAMS* in selection.
- Setting in the last paragraph of selection was not applied
  at certain conditions (i.e. relative cursor position in first
  paragraph > rel.c.pos. in last paragraph).

Getting back + fixing typo from e2b42b1726.

https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg220019.html
2023-07-22 18:17:46 +02:00
Jean-Marc Lasgouttes
13d24c711e When breaking a paragraph, do not reset depth
Remove some logic that would reset depth when editing non-environment
stuff (e.g. Standard layout) at non-zero depth. The current way of
decreasing depth is to use paragraph-break in an empty paragraph.

See discussion in ticket #2445 for why this code happened.

Fixes bug #12750.
2023-07-16 17:16:02 +02:00
Jean-Marc Lasgouttes
7cc431bd55 Add optional parameter 'local' to outline-in/out
When this parameter is given, only the current paragraph is affected
by the section promoting/demoting.

Note that the new argument is not used yet.

Update release notes and LFUNS documentation.

Part of ticket #12417.
2023-07-06 17:47:08 +02:00
Jean-Marc Lasgouttes
8aea6af6a0 Make outline function work in an inset
The function outline is modified to operate only in the inset that
contains the cursor. This means that the function can be enabled in
insets (this had been forbidden to fix #5004).

Of course, there may be cases where the user expects something to
happen outside of the inset. I am sorry to announce that this is not
going to happen ;)

Fixes bug #12809.
2023-06-27 14:58:27 +02:00
Daniel Ramoeller
c0d7ac5b71 Split-inset fix
- Remember whether something has to be pasted

Fix for bug #12747
2023-05-31 00:05:23 +02:00
Richard Kimberly Heck
9a4e44e7df Fix indentation 2023-05-27 11:38:19 -04:00
Richard Kimberly Heck
04fe6c89dc Fix typo 2023-05-27 11:37:00 -04:00
Daniel Ramoeller
4ed0312c51 Fix bug #12772 2023-05-26 23:39:28 -04:00
Juergen Spitzmueller
25ecd919fe Use proper (inset) font for normalizing purposes
Not all insets have a proper layout, but we have Inset::getFont()

Fixes #12729
2023-05-19 12:35:03 +02:00
Jean-Marc Lasgouttes
43b24085fb Merge files Text{,2,3}.cpp
This is done at the end of the release cycle to avoid backporting issues.

The goal is to simplify development, since it was difficult to guess
in which file a given method could be found.

There is some effect on compilation time, but it is not too bad:

* before merge

  lapinot: time make Text.o Text3.o Text2.o
    CXX      Text.o
    CXX      Text3.o
    CXX      Text2.o

  real	0m32,504s
  user	0m31,027s
  sys	0m1,446s
  lapinot: rm Text*.o
  lapinot: time make -j8 Text.o Text3.o Text2.o
    CXX      Text.o
    CXX      Text3.o
    CXX      Text2.o

  real	0m21,282s
  user	0m32,661s
  sys	0m1,424s

* after merge

  lapinot: time make Text.o
    CXX      Text.o

  real	0m26,731s
  user	0m25,706s
  sys	0m1,020s
2023-05-04 16:28:09 +02:00
Jean-Marc Lasgouttes
786a6edb54 Disable completion when document is read-only.
Being able to insert completion in a read-only document is definitely
a bad idea.

This patch acts both on indication of completion and on insertion
itself.

Fixes bug #12582.
2022-10-08 12:52:05 +02:00
Jean-Marc Lasgouttes
8508c3fe04 Completion: handle undo in insets' insertCompletion methods
I mathed, undo should record the underlying inset on completion,
whereas in test recording the paragraph is enough.

Therefore the recordUndo() in GuiCompleter::tab is removed, and the
relevant recordUndo/recordUndoInset are used at the right places.

As a further cleanup, the parameter `finished' of
Text::insertCompletion is removed as it is useless.

Fixes bug #12581.
2022-10-05 09:48:01 +02:00
Daniel Ramoeller
2b493ff70f Word selection on mouse motion
Partial fix for bug #9160.
2022-05-17 18:45:31 +02:00
Jean-Marc Lasgouttes
5f4890721b Improve display of META_INSET in status bar. 2021-10-15 11:11:57 +02:00
Yuriy Skalko
6a7c9d12f9 Amend d3c335a5d5 2021-10-05 17:10:51 +03:00
Juergen Spitzmueller
e2f3dd5f6a Consider selection scope when DEPM after CT acceptance/rejection (#2166)
This fixes a crash and DEPM overshooting.
2021-03-02 09:15:33 +01:00