Commit Graph

44439 Commits

Author SHA1 Message Date
Scott Kostyshak
4b8bb00573 Reg test for cprotect: comment in figure caption
File from #9313.
2021-12-22 22:45:39 -05:00
Scott Kostyshak
87bea67863 Regression test for cprotect, #7116
Start a new directory of cprotect tests. There are many situations
where cprotect is needed so we can add files covering various
situations as we find them.

This particular test covers the case of special characters in URL
insets in footnotes.
2021-12-22 22:03:02 -05:00
Kornel Benko
942121f4b6 FindAdv: Added handling of some missing Hebrew characters 2021-12-21 14:16:49 +01:00
Juergen Spitzmueller
c2f2ba57f1 Do not repeatedly call main_font_encoding()
This method impacts on performance and we store the value anyway in
the output params.
2021-12-20 12:09:12 +01:00
Juergen Spitzmueller
61b8afd893 Paragraph::needsCProtection(): use inset list
rather than checking each pos whether it's an inset or not.

This was a significant performance bottleneck (particularly getInset()
itself seems slow).
2021-12-19 15:39:49 +01:00
Jean-Marc Lasgouttes
a3fd3a09f1 Add UI for selecting backing store drawing strategy
The checkbox is hidden when backing store is enforced (wayland,
macOS). In practice, only X11 and Windows users will see it ; I only
have evidence of X11 people needing it, I can hide it for Windows
users too if necessary.

Fixes bug #12119.
2021-12-17 15:16:35 +01:00
Jean-Marc Lasgouttes
c213eb7f75 Add lyxrc option to force the use of backing store
LyX relies on a a backing store to draw when running under macOS or
Wayland, because Qt arbitrarily overwrites parts of the workarea
before we paint (and we paint only the parts that need to be painted).
However it seems that this is also necessary on X11 when the WM theme
is translucid. Since there is no way that I know of to detect this
situation, this patch adds a LyXRC setting to manually select this
drawing strategy.

Note that using a backing store is not always a good solution, since
this disables subpixel aliasing.

At this point there is no UI for the variable.

Fixes bug #12119
2021-12-17 10:38:28 +01:00
Scott Kostyshak
056ab33f48 Amend bea7ef04e (find's auto-wrap by default)
The default in the .ui is not considered in
GuiSearchWidget::restoreSession(), which sets a hard-coded default
if the stored setting is not found in the session file.

I'll start an ML discussion for whether the code in restoreSession()
should use the ui's default if the setting is not found in the
session.
2021-12-15 20:51:50 -05:00
Jean-Marc Lasgouttes
62ad205dbf Avoid duplication of words on screen
When giving up splitting a word sequence because it is not enough to
make the row short enough, make sure to clean up properly.
2021-12-15 11:19:18 +01:00
Stephan Witt
cb4715d739 Improved Qt framework configuration detection on macOS, add QtCore5Compat headers to configure based includes 2021-12-12 22:24:23 +01:00
Stephan Witt
4665baac46 Fix an overloaded-virtual warning for type mismatch of event parameter (Qt6) 2021-12-09 21:59:23 +01:00
Scott Kostyshak
80a901506b languages test file: Use new Tibetan font name
Noto Sans Tibetan was not actually a sans font. On newer systems the
font is now Noto Serif Tibetan.

See, e.g., the package 'fonts-noto-core' in Ubuntu 21.04.

This change also fixes compilation of
supported-languages_polyglossia-XeTeX.lyx on Ubuntu 21.10.
2021-12-09 15:17:14 -05:00
Jean-Marc Lasgouttes
dcef1a9cad Fix endless loop when breaking text
For some reason, Qt can break strings before the first character
(although we try to prevent that). The code was not prepared to that,
now it is.

Remove a forgotten debug statement.
2021-12-09 16:56:09 +01:00
Scott Kostyshak
b461d07b5b ctests: log a fixed issue (fr Linguistics.lyx) 2021-12-08 23:04:24 -05:00
Juergen Spitzmueller
2eaf30c57e fr/Linguistics.lyx: fixes
* Fix up markup in and localize examples
* Remove local layout from lyx2lyx conversion
2021-12-08 09:49:23 +01:00
Thibaut Cuvelier
7513d88350 MathML: remove redundant mrow in InsetMathScript.
https://www.lyx.org/trac/attachment/ticket/12221/0006-amends-to-a579128c-a68e9793-a68e9793.patch by lynx
2021-12-08 02:11:48 +01:00
Thibaut Cuvelier
d1daa092f6 MathML: share some code for XArrow. 2021-12-08 02:02:46 +01:00
Thibaut Cuvelier
e5eef14414 MathML: refactor the XArrow mappings as maps. 2021-12-08 02:02:46 +01:00
Thibaut Cuvelier
f0bf41f574 MathML: allow XArrow to stretch.
Based on https://www.lyx.org/trac/ticket/12221#comment:10
by lynx
2021-12-08 02:02:46 +01:00
Thibaut Cuvelier
68ff3436c9 symbols: update HTML entities and Unicode encodings for Greek letter variations. 2021-12-08 02:02:46 +01:00
Thibaut Cuvelier
5b62d43835 symbols: don't encode vertical bars as nonexistent HTML entities.
Excerpt from https://www.lyx.org/trac/ticket/12221#comment:11

Created by lynx
2021-12-08 02:02:46 +01:00
Stephan Witt
0e0b76a76e Restore correct version check for AA_UseHighDpiPixmaps - amend change ae56fb6171 2021-12-07 23:01:47 +01:00
Scott Kostyshak
fb4a485c19 ctests: uninvert Seminar tests
These exports now succeed on an updated TL21 installation.
2021-12-07 13:25:39 -05:00
Scott Kostyshak
2713ea5189 ctests: log fixed upstream polyglossia issues
Thanks to Jürgen for fixing these upstream Polyglossia regressions.
2021-12-07 13:05:52 -05:00
Jean-Marc Lasgouttes
2fd8b6fc2a Fix the way the top and bottom selection are drawn
When a selection extends on more than a row, the space between the two
rows should always be painted in full. Otherwise, with layouts like
Chapter, the "Chapter" label may seem selected in part.
2021-12-07 18:15:01 +01:00
Jean-Marc Lasgouttes
bf9b4a0836 Merge branch 'breakrows'
With this merge, the way paragraphs are typeset changes. Paragraphs
are first tolenized as row elements, and these elements are then
broken into separate rows as needed to fit the margins. This allows to
reduce the amount of metrics computation and make LyX much faster in
the case of large insets.

Moreover, the code relies more on RofFlags enum, which desribes how an
inset or a row element should be typset. This aspect will be extended
in the future.

Some user for whom performance is very bad (which I cannot reproduce
unfortunately) have reported a 4-fold speedup. In general cases, the
speedup will be less impressive but still noticeable.

Related to bugs #12297 and #5861.
2021-12-07 17:06:21 +01:00
Jean-Marc Lasgouttes
2f8ea7ba05 One less thing to do in PAINTING_ANALYSIS 2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
572b06d640 Increase metrics cache maximal size
Increase the maximal size of the breakString cache (to compute where
to break lines) from 512kB to 10MB. This has a big impact of cache
hits on large file like the example in #12297, which is now 99%. On
this example the time taken by breakString decreases from 33.5us to
2.4us.

The string width cache has been increased fro 512kB to 1MB, but this
does not make such a big difference.

Additionally, comments and variable names have been improved.

Related to bug #12297.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
5966d4fb8d Improve row flushing
Add new row flags Flush and FlushBefore to let insets indicate whether
they cause flushing of current row (eg. newline) or of previous row
(e.g. display insets).
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
a06f0e48ec Simplify setting of RTL in rows
Set RTL status at row creation, which allows to remove a parameter from
cleanupRow.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
d723b90344 Break multi-row strings in one pass
Replace FontMetrics::breakAt, which returned the next break point,
with FontMetrics::breakString, which returns a vector of break points.
To this end, an additional parameter gives the available width for
next rows.

Rename various variables and methods accordingly. Factor the code in
breakString_helper to be more manageable.

Adapt Row::Element::splitAt to return a bool on sucess and provide
remaining row elements in a vector. The width noted above has been
added as parameters.

Rename the helper function splitFrom to moveElements and rewrite the
code to be more efficient.

Remove type of row element INVALID, which is not needed anymore.

The code in TextMetrics::breakParagraph is now much simpler.

In Row::finalize, remove the code that computed inconditionnally the
current element size, and make sure that this width will be computed
in all code paths of Row::Element::splitAt.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
71c2e2fda6 Add operator<< for Row::Elements
This is useful for debugging.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
4b69f5efa7 Fix setting of row pos/endpos (overlapping rows)
In TextMetrics::breakParagraph, get rid of the fragile `pos' local
variable, which was not correctly updated. Rely on the endpos of the
last element in row instead.

Rewrite cleanupRow to rely on the endpos of last the row element to
set row endpos, instead of a `pos' parameter.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
4120635185 Get rid of need_new_row boolean in breakParagraph
Instead of having breakParagraph decide when breaking a row is
necessary, let Row::shortenIfNeeded set the row_flag of the last
element to request a row break. This was already done in splitAt.

This is in preparation of splitAt splitting in more than two elements.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
ef6dfe18c2 Centralize the code that removes trailing spaces from end row element.
Move to Row::Element::rtrim the code in Row::shortenIfNeeded that
removes trailing spaces from last element in row, so that it can be
called when actually breaking a row.

Fixes bug found by Kornel.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
6e6976fbc5 Handle the case where breakAt cuts after trailing space
In this case, the extra element returned should empty but valid. The
row flag BreakAfter is set to indicate that we have a break there
(this principle will be used more generally in a forthcoming commit).

To detect that we cut at the trailing space, it is necessary to rely
on the difference between QTextLine::horizontalAdvance() and
QTextLine::naturalTextWidth() when the flag
QTextOption::IncludeTrailingSpaces is used: the trailing space is
taken into account in the later, but not in the former.

Somme comments have been added to make code intent clearer.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
6bc50fea3a Workaround for Qt 4
At least with Qt 4.8.7 on Ubuntu 16.04, QTextLine::lineWidth() can
return a bogus value, at least with Courier font. One hypothesis is
that the invisible characters that we use in breakAt_helper are given
a non-null width.

Work around it, although the exact bug has not been pinpointed.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
d694701315 Last step of transition: use sortenIfNeeded again.
Change semantics of Row::shortenIfNeeded: instead of breaking the row
and returning a boolean, it returns the list of row elements that have
been removed (or broken) from the row. The logic of the method remains
the same.

Use shortenIfNeeded in breakParagraph. This was the last missing block.

Remove Row::breakAt and the old breakRow. Only bugs remain now :)
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
0ea1807a52 Implement handling of row_flags for row breaking
To this end, add the helper function needsRowBreak which computes the
effect of two consecutive row flags. This function implements the
priorities described in RowFlags.h.

This function is called with the relevant flags, or NoBreak* when at
boundaries and updates need_new_row.

Some common code is factored in a new cleanupRow() helper.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
890fcc0872 Change the way the element's width is updated.
Remove the code that computed the width every 30 characters (yay!).
Make sure that finalizeLast() is called after inserting a row element in
a row in breakParagraph.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
49115315ea Introduce helper template to simplify breakParagraph code
This is a semi-generic iterator for iterating over a container and
pretend that we add elements to it along the way.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
df688126ca A set of easy fixes and missing features
* show changebar when end of paragraph is changed.

* when row is finished, set endpos and right_boundary

* handle bidi.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
0a18a4e763 Use the new tokenizing and breaking code instead of breakRow. 2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
ef88e31a1f Break the paragraph's big row according to margins
Still many features missing:
- handle insets that break rows (display math, newline, ...)
- handle rows that are too long by replacing the single call to
  breakAt with a call to a reworked Row::shortenIfNeeded.
- some easy things at the end of breakRow (bidi text, etc.).
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
963a0aa466 Implement Row::Element::row_flags
Move the enum definition RowFlags in its own include file, to avoid
loading Inset.h. Document it more thoroughly.

Rename RowAfter to AlwaysBreakAfter.

Add CanBreakInside (rows that can be themselves broken). This allow to
differentiate elements before bodyPos() and allows to remove a
parameter to shortenIfNeeded().

Make the Inset::rowFlags() method return int instead of RowFlags, as
should be done for all the bitwise flags. Remove the hand-made bitwise
operators.

Set R::E::row_flags when creating elements.
* INSET elements use the inset's rowFLags();
* virtual element forbid breaking before them, and inherit the *After
  flags from the previous element of the row;
* STRING elements usr CanBreakInside, except before bodyPos.

More stuff may be added later.
2021-12-07 17:04:47 +01:00
Jean-Marc Lasgouttes
f4d3702d4d Create new method TM::tokenizeParagraph
This contains large parts of breakRow, but creates a unique row for the paragraph.

The parts taken or not in redoParagraph are annotated.

The new method is not used yet.
2021-12-07 17:04:46 +01:00
Jean-Marc Lasgouttes
a558f78aa5 Small Row cleanups
Move declaration of RowList to Row.h

Move initialization of POD members of Row and Row::Element to declaration.

Make method isVirtual() depend on type.

Add new row element type INVALID and method isValid()

Make methods R::E::left/right_pos inline.

Add method R::E::splitAt() that returns an element containing the
remaining stuff, or an invalid element if nothing was split. breakAt
is now a simple wrapper around this function.

Add method R::push_back().
2021-12-07 17:04:46 +01:00
Jean-Marc Lasgouttes
1831f6caac Change FontMetrics::breakAt to return a position
Since we intend to break the row element in two, it is not good to
truncate the string too early.

Moreover, the row element width is now set at this point, even if no
breaking occurs.
2021-12-07 17:04:46 +01:00
Stephan Witt
ae56fb6171 Qt6 pixmaps are always HiDPI - avoid deprecate warning for setAttribute 2021-12-07 10:02:05 +01:00
Stephan Witt
53ed3dc062 Automate Qt major version detection in macOS build script 2021-12-06 07:51:42 +01:00