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.
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.
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.
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.
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 :)
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.
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.
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.).
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.
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.
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().
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.
When inserting € in a math cell, it is put in a text inset and the
cursor leaves the inset. However, inserting ¤ then leads to
\text{€}\text{¤}.
Therefore, try to see if there is a previous \text inset that can be
recycled and insert the new inset there in this case, leading to
\text{€¤}.
Fixes bug #11979.
This allows to simplify the code in Lexer and to remove the dependency
on Formats class.
As a consequence, a pair of dummy definitions of isZippedFile can be removed.
Some new parskip possibilities had been added, but the check for
custom length index had not bee updated.
This code is very fragile.
Related to bug #10968.
The code that determine whether an InsetArgument is passThru is
complex and lives in updateBuffer.
This patch factors out the code in a new init method and calls it also
in doInsetInsert when inserting a InsetArgument.
Fixes bug #12143.
Rather than that, keep it with a warning that it is not available.
Fallback procedure (which maintains security measures) is done in
the conversion step.
This prevents document properties being silently changed on sharing.
The QWinMime class has been removed in Qt6 but the functionality
is still present. However, one has to allow inclusion of private
headers and register the mime handling to the QWindowsApplication
native interface.
Those checks might not be needed, but it's not self obvious from
the surrounding code. Because we already experienced crash from
similar change (cf 1c1c83eced), let's be prudent here.
If you know that these pointers can't be null from broader context
feel free to remove the guards.
Introduced by 24926b2e23, fix 104fdcc9be not backported
but now fixed by 1c1c83eced in 2.3.
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg216414.html
Clang 12 (at least) misses the fact that tag is always initialized,
because the if/else sequence does cover all cases.
Initialize the variable although it is not required. It does not hurt
at least.
The code is written in such a way that the elements are searched
several times. This can be expensive when there are a lots of insets
in the document.
Concerning the sanity checks, they are now conditionned on the
presence of assertion.
Related to bug #12297.
Add parameter 'force' to scrollToCursor(...) to avoid the case where the
cursor is not set to top because it is already visible on screen.
Change screen offset in this method so that the paragraph is really at
the top of the screen. This part may cause unforeseen issues and needs care.
gotoInset: use the new force flag and do not trigger a redraw.
Instead, return a boolean telling whether redraw is needed.
In the code that use it, set an update flag instead of the extra redraw.
In the handling of paragraph-goto, also set the update flag instead of
triggering a repaint.
Remove Bufferview::scrollToCursor(), which was equivalent to showCursor().
Fixes bug #10425.
Lyx crashes on export to pdf if used with sanitizer set to 'unspecified'.
Crash found by Scott.
Given that if we export without GUI, there is some weirdness here though.
1.) Why does lyx not crash if not using '-fsanitize' compile-option
2.) Why is export to pdf dependent on the screen-resolution
This fixes two performance issues and improves the performance of
TextMetrics::redoParagraph by 15% in a workload that uses the cache a
lot. The difference will be much less when the cache is not used much.
1/ repetion of the hash code computation
The code
if (cache.contains(key))
result = cache[key]:
is not efficient, since qHash(key) has to be computed twice.
To fix this a new Cache::object_str() method is added, which allows
if (auto * obj = cache.object(key))
result = *obj;
2/ code of has code computation
Instead of using a verbose string that is complicated to build as
key, new key structs BreakAtKey and TextLayoutKey are introduced,
along with the relevant qHash() implementation.
IGNORE is a typical placeholder for tags that should not be output, along with NONE. At some point, we should check if both are required, or if NONE is enough…
Initially Qt5 modifier handling was broken. Therefore a workaround was introduced.
This workaround broke the LyX modifier handling with swap of Command-Control-key disabled.
The change disables the hack to get the correct behavior in LyX.
We now use a new variable, "wrap", to track if a wrap should be
done, which is true either if "auto_wrap" is true or if the user
chooses to wrap in the dialog.
This preserves the meaning of the "auto_wrap" variable and also
removes the confusion of why the previous code of
if (!auto_wrap) {
...
}
if (auto_wrap) {
did not use an "else" instead of the second "if".
No change in functionality.
Does not change much, but Coverity complains about it. Let's see if
this allows Inset's child classes to grow their own move constructor.
Also some whitespace.
This requires the introduction of the booleans selected_left and
selected_right in PainterInfo. These tell whether the selection
continues at the left/right of the inset.
This information allows to
1/ paint equation number in the right color: either current text color
or selection text color.
2/ before that, paint a small background rectangle of the correct color.
This allows to avoid painting a large rectangle of an arbitrary color
that was the cause of the bug.
Fixes bug #12319.
When the cursor cannot move on cursor up/down, at least the selection
should be cleared (when not selecting).
To detect this, the method Cursor::upDownInText has been modified to
return true when cursor is at top/bottom of inset, but there is some
room above/below.
Moreover, introduce the functions LFUN_FINISHED_UP/DOWN, which is
dispatched at upper cursor level as long as no local movement is
possible. This allows to handle differently the original char moving
action and its consequences.
Fixes part of bug #12310.
Example: when a selection is set, a `Left' cursor movement would not
reset selection when the cursor was at the beginning of buffer.
To fix this, it is necessary, when cursor is in top-level text, to
avoid the mechnanism (undispatched cursor) that sends the action to the
upper level (necessary when the cursor leaves an inset).
The change is mechanical and is done for : char-backward,
char-forward, char-left, char-right, word-left, word-right, word-left,
word-right. It might be possible to factor this code a bit, but there
is no evident solution.
char-up/down are *not* handled at this point.
Fixes part of bug #12310.