Commit Graph

29172 Commits

Author SHA1 Message Date
Kornel Benko
fca59304da FindAdv: sometimes a space is added on some math symbols
For example '\int '.
Should fix regression #13070
Spotted  by Alexander Dunlap

(cherry picked from commit 4730ec78f5)
(cherry picked from commit 6c3447c8a6)
2024-06-01 13:40:08 +02:00
Juergen Spitzmueller
712baff7b6 Address Qt 6.7 deprecation warning
(cherry picked from commit 44633c7f72)
2024-05-20 17:59:51 +02:00
Juergen Spitzmueller
26834b7a07 Initialize is_long_tabular before updateIndexes() (which employs it)
(cherry picked from commit 10b5f03d95)
2024-05-20 17:59:30 +02:00
Juergen Spitzmueller
576d3836cf Amend a716fb96b5
(cherry picked from commit af59551b1b)
2024-05-15 13:33:18 +02:00
Juergen Spitzmueller
176ecba630 NeedCProtect -1 also for InsetLayouts
(cherry picked from commit a716fb96b5)
2024-05-15 13:32:47 +02:00
Juergen Spitzmueller
0af7259025 Introduce NeedCProtect -1 layout option
It turns out beamer frame does not allow \cprotect and errors if it is
used. Hence we need to prevent it in this context entirely.

(cherry picked from commit 207eaeee90)
(cherry picked from commit f05fd78754)
2024-05-15 13:25:03 +02:00
Juergen Spitzmueller
8b0546dfe7 Consider CT in dash mechanism (#13062)
(cherry picked from commit fe4f0dbf0b)
2024-05-11 13:02:39 -04:00
Jean-Marc Lasgouttes
13a34d6cd1 Set buffer_ correctly when inseting a math macro over a selection
The code that handles this special macro insertion (in
Cursor::mathMacroClose())) is very weird: it inserts the contents of
the macro _after_ the macro and later, since the macro is 'greedy', it
will eat this contents and put it in its first macro cell.

Does it make sense to you? It does not ake sense to me either. Anyway,
this is the point where one should make sure that the buffer is set.

Fixes ticket #12682.

(cherry picked from commit b45a957929)
2024-04-25 20:27:36 +02:00
Jean-Marc Lasgouttes
21096f696a Sanitize cursors after a buffer has been reloaded
When a buffer is reloaded, its content may remain the same, but the
memory allocation is new, so that the inset pointers in cursors are
now wrong. This requires to sanitize the cursors held by the buffer
views.

Before the biginset branch, some full metrics computation call that is
now removed probably did that as a side effect. Now we have to be more
precise.

To this effect, introduce WorkAreaManager::sanitizeCursors() and use
it in Buffer::reload().

(cherry picked from commit c1fd622c51)
2024-04-22 11:35:15 +02:00
Jean-Marc Lasgouttes
c9f5f34fd7 Always repaint the gray area below main inset
Now that SingleParUpdate does not always lead to a full screen update
when the height of the paragraph changes (see new behavior of
updateMatrics(bool)), it is necessary to make sure that the grey area
below the main page is always repainted.

(cherry picked from commit 1a11abe439)
2024-04-18 16:46:38 +02:00
Jean-Marc Lasgouttes
15eef6a2c7 Do not compute metrics at each preview when loading file
With the branch-test.lyx file from #12297, loading takes forever when
previews are activated. This is because each preview element causes a
full screen metrics recomputation.

This commit just skips these calls and only does one when all previews
have been obtained. As a result, computing the previews takes 1 second
instead of 25 seconds on branch-test.lyx.

Part of bug #12297.

(cherry picked from commit 2449693301)
2024-04-18 16:45:58 +02:00
Jean-Marc Lasgouttes
e5aaa64b63 Improve the code that limits scrolling at top/bottom
The most visible part of this commit is the move of part of
BufferView::updateMetrics to a new TextMetrics::updateMetrics. This
new method makes sure that metrics are known for all visible paragraphs
(starting from anchor), and that the positions of the paragraphs have
been recorded.

This method is called up to 3 times in BufferView::updateMetrics:
* unconditionally, to update all visible metrics,
* then, if the bottom of the document is visible and too high, after
  updating the anchor ypos,
* and similarly if the top of the document is visible and too low.

This fixes for example the case where one jumps to Section 5.3 at the
end of Tutorial and 'scroll_below_document' is false.

Some now redundant code is removed from BufferView::scrollToCursor.

The anchor-setting code in BufferView::draw is not clearly useful, but
left here just in case. It generates a debug warning, though.

Part of bug #12297.

(cherry picked from commit f15d2ebf38)
2024-04-18 16:45:58 +02:00
Jean-Marc Lasgouttes
2434a3a288 Implement quick scroll
Replace flag parameter for updateMetrics() by a `force' boolean. When
it is false, the method keeps the metrics of paragraphs that are still
visible in WorkArea instead of computing everything afresh. All it has
to do is update their positions.

Add code to updateMetrics() to update the value of the anchor pit/ypos
(similar to the one in draw()).

Update processUpdateFlags() to use this when update flag is ForceDraw.

Modify scrollDocView() to just change the anchor paragraph position
when the scrolling operation would re-use some of the existing
paragraphs.

The time needed to update the metrics when scrolling with mouse in the
branch-test.lyx document is now divided by 20!

Part of bug #12297.

(cherry picked from commit 08010c6a5e)
2024-04-18 16:45:58 +02:00
Jean-Marc Lasgouttes
b1a0983570 Introduce new helpers ParagraphMetrics::top/bottom
This avoids code with position/ascent/descent that is difficult to follow.

No change in function intended.

(cherry picked from commit 0b6105b924)
2024-04-18 16:45:58 +02:00
Jean-Marc Lasgouttes
5e1c414a21 In the no-draw phase, do not cache the positions of not visible insets
This can make a big difference for a very large branch that contains
lots of equations.

This is complementary to the previous patch, since instead of reducing
the number of calls to updatePosCache, we make it faster.

In the same test of scrolling with mouse wheel through the
branch-test.lyx document, one finds a 23% improvement for
BufferView::updateMetrics().

Part of bug #12297.

(cherry picked from commit 7f85024f80)
2024-04-18 16:45:58 +02:00
Jean-Marc Lasgouttes
e51f9d9f88 Remove some redundant calls to updatePosCache
The setting of insets positions was done twice in updateMetrics.
When one of the paragraph is a huge branch, this can be very expensive.

This leads to a 17% improvement on updateMetrics time on a scrolling test.

Part of bug #12297

(cherry picked from commit d19ade9a61)
2024-04-18 16:45:58 +02:00
Jean-Marc Lasgouttes
13c7fd78c6 Enable Update::SinglePar in nested insets too
The idea of single par update is to try to re-break only the paragraph
containing the cursor (if this paragraph contains insets etc.,
re-breaking will recursively descend).

The existing single paragraph update mechanism was tailored to work
only at top level. Indeed changing a paragraph nested into an inset may
lead to larger changes.

This commit tries a rather naive approach that seems to work well: we
need a full redraw if either

1/ the height has changed
or
2/ the width has changed and it was equal to the text metrics width;
   the goal is to catch the case of a one-row inset that grows with
   its contents, but optimize the case of typing in a short paragraph
   part of a larger inset.

NOTE: if only the height has changed, then it should be
  possible to update all metrics at minimal cost. However,
  since this is risky, we do not try that right now.

Part of bug #12297.

(cherry picked from commit 9a96726bcd)
2024-04-18 16:45:58 +02:00
Richard Kimberly Heck
365ff71e23 Defer construction of temporary cursor.
We were doing this on every mouse movement. I.e., for every single
pixel the mouse traverses. It can be expensive if there are a lot
of math insets.

(cherry picked from commit 4e8aa89eb9)
2024-04-16 12:20:51 -04:00
Juergen Spitzmueller
d29baf59a4 Disable language package choice if the class preloads a package
(cherry picked from commit 5477451e36)
2024-04-14 08:13:55 +02:00
Juergen Spitzmueller
d21042299f Set cursor font after pasting to PassThru inset (#12592)
(cherry picked from commit 09c72d7c8d)
2024-04-14 08:09:56 +02:00
Koji Yokota
76dbb9dc40 Fix wrong position of conversion windows of the input method #11723, #13054 2024-04-12 21:17:04 +09:00
Pavel Sanda
7e2c1dca36 Improve stats update times for buffer switches and toolbar toggles. 2024-04-05 23:14:25 +02:00
Pavel Sanda
ae07763abf Allow relative statistics values in statusbar.
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg221311.html
2024-04-05 19:44:25 +02:00
Juergen Spitzmueller
3b4d9f8606 Dissolve some shortcut conflicts in the wake of f3a4602c4c
(cherry picked from commit 728175f9ac)
2024-04-03 09:15:46 +02:00
Juergen Spitzmueller
c92d14e8c9 Smarter menu length calculation
It is possible I have missed some shortcut conflicts, so please report
if you find any.

(cherry picked from commit f3a4602c4c)
2024-04-03 09:15:27 +02:00
Daniel Ramoeller
f957964e9b FindAdv: no paragraph indentation for more space in the search string
See #11555

(cherry picked from commit 638c04dd6a)
2024-04-02 11:52:43 +02:00
Kornel Benko
32a680e4fe FindAdv: Handle neg-spaces like normal space if searching without format
(cherry picked from commit 07cacef398)
2024-04-02 11:52:05 +02:00
Kornel Benko
1edbf565e4 Rename hasToString() to findUsesToString()
There are special cases where the toString() exist,
but still plaintext() is not to be used by find.

(cherry picked from commit 8de81e8dc1)
2024-04-02 11:51:15 +02:00
Juergen Spitzmueller
31ec96e01f Fix context menu of InsetMathRef 2024-04-01 17:59:56 +02:00
Juergen Spitzmueller
a020bbc4a8 Fix backslash LaTeXifying in InsetCommand
\ was transformed very early to \textbackslash{}, but then the following
routines escaped braces in the string, so we wrongly ended up in
\textbackslash\{\} and "\{} in the output
2024-04-01 10:57:27 +02:00
Juergen Spitzmueller
812e306dad Factor out shared method
Amends babb5b007b
2024-03-31 12:40:27 +02:00
Juergen Spitzmueller
babb5b007b Fix crash with quick search starting with mathed selection
setCursorSelection does not work with math. Copy the method from
spellchecker.
2024-03-30 10:14:34 +01: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
Juergen Spitzmueller
60cffcd9b7 Fix alignment of screen font preview in prefs (remaining part of #13046) 2024-03-24 09:00:41 +01:00
Jean-Marc Lasgouttes
4dfebbe9da Fix display of a math hull inset in a tight inset
This is a kind of hack. This allows InsetMathHull to state that it
needs some elbow room beyond its width, in order to fit the numbering
and/or the left margin (with left alignment), which are outside of the
inset itself.

To this end, InsetMathHull::metrics() sets a value in
MetricsInfo::extrawidth and this value is added later to the width of
the row that contains the inset (when this row is tight or shorter
than the max allowed width).

Fixes bug #12320.
2024-03-22 15:40:40 +01:00
Jean-Marc Lasgouttes
6d62d8009f Revert "Fix display of a math hull inset in a tight inset"
This commit will be replaed by a better solution.

Part of ticket #12320.

This reverts commit 4bbd4a45e7.
2024-03-22 15:08:26 +01:00
Thibaut Cuvelier
fd37845075 Amend 16660d12.
The previous commit introduced wrong behaviours for <>. The new code carefully escapes what needs to be escaped from LaTeX, using the now-standard XML tools (XMLStream).
2024-03-21 21:32:45 +01:00
Thibaut Cuvelier
16660d12b4 MathML in HTML: don't escape <> for a raw LaTeX output.
In some cases (I only found numbered equations), the LaTeX output still has a bit of HTML. For numbered equations, using \tag{X} (as suggested in https://www.lyx.org/trac/ticket/13048) would require fiddling with the output. KaTeX doesn't support \label. This patch is probably the easiest and most reliable fix.

Fixes https://www.lyx.org/trac/ticket/13048.
2024-03-21 00:29:23 +01:00
Patrick de Visschere
3f790725d9 Using the latest commit and building lyx with cmake on macos-sonoma with
xcode fails with multiple error messages like this one:

----------
CMake Error in po/CMakeLists.txt:
       The custom command generating

     <build-directory>/po/LyX2.4.cat.pot

       is attached to multiple targets:

     translations
     update-gmo

  but none of these is a common dependency of the other(s).  This is not
  allowed by the Xcode "new build system".
2024-03-20 11:44:22 +01:00
Jürgen Spitzmüller
0d3d91c055 Add $$OrigAbsName placeholder to external
This produces the absolute path to the original file.

Documentation will follow in die time (after documentation has been
unfrozen)
2024-03-20 07:57:43 +01:00
Pavel Sanda
f7e6086e67 TableUI - allow expading of TableAlignCO (part of #13046). 2024-03-19 19:23:22 +01:00
Juergen Spitzmueller
b1e2986df8 Use docstring for preview snippet all the way down
No need to convert back and forth
2024-03-16 11:57:48 +01:00
Juergen Spitzmueller
f9c60d477d Simplify b3fe9cb704 2024-03-16 05:01:53 +01:00
Juergen Spitzmueller
b3fe9cb704 Prevent iconv exception in previews (#13042)
The preview loader assumes all content is in the main document encoding.

As soon as content was not encodable, LyX crashed. We now check for that
and if non-encodable glyphs are found, we do not produce a preview snippet
and warn.

Ideally, the preview loader should be made aware of encoding changes, or
we should generally use utf8 for previews.
2024-03-16 04:52:51 +01:00
Thibaut Cuvelier
7e6597a5b4 MathML: don't let the processor stretch operators when they are single characters for LyX.
The main goal is to match TeX' behaviour. If you want stretchy operators, use InsetMathDelim / \left & \right. This patch will change the output in many files, but making the rendering much closer to that of TeX (which users should expect, due to LyX' roots in TeX).
2024-03-11 02:00:47 +01:00
Thibaut Cuvelier
8f820d7ccb MathML: stop stretching all delimiters.
No form? Reference: https://w3c.github.io/mathml-core/#dfn-form. The MathML processor is smart enough to determine whether the delimiter is prefix or postfix.

No stretchy/symmetric/fence in all cases? Reference: https://w3c.github.io/mathml-core/#algorithm-for-determining-the-properties-of-an-embellished-operator and https://w3c.github.io/mathml-core/#operator-dictionary-human (example entry: U+0028). Delimiters have the right properties by default.
2024-03-11 01:40:16 +01:00
Thibaut Cuvelier
be03d69946 MathML: don't output delimiters in InsetMathBinom and
InsetMathDelim if the delimiter is a space.
2024-03-11 01:30:48 +01:00
Thibaut Cuvelier
9e6b810b37 Extract vert, langle, rangle in MathExtern like parentheses and brackets.
This patch is part of a series that aims at solving https://www.lyx.org/trac/ticket/12891. It is an excerpt of the patch that lynx published at https://www.lyx.org/trac/ticket/12270.
2024-03-11 01:22:12 +01:00
Thibaut Cuvelier
b1a4eb118c Improve const correctness. 2024-03-11 01:15:53 +01:00
Thibaut Cuvelier
93444892c5 Memorise whether delims are extracted from MathExtern.
This patch is part of a series that aims at solving https://www.lyx.org/trac/ticket/12891. It should not change any output.
2024-03-11 01:10:15 +01:00