The new approach to line breaking introduced in 71d9f6e9 is correct,
but the newly introduced min_row_wid should not be updated when the
remaining line width after a break is larger than next_width.
Swapping the two tests fixes remaining issues.
Fixes (for good?) #12899.
The display was wrong when a backing store is in use (which is the case
with Wayland). To fix this in GuiWorkArea::Private::resetScreen(), the
pixelRatio is now stored as a double instead of an int.
Concerning support for QT_SCALE_FACTOR, the existing code was wrong
because this value is already taken into account in devicePixelRatioF
for Qt > 5.6 (no fractional scaling support before that). The
situation is as follows:
Qt < 5.6 5.6 <= Qt < 6 Qt 6
devicePixelRatio int(ratio) int(ratio) ratio
devicePixelRatioF N/A ratio ratio
So it is only between Qt 5.6 and Qt 6 that devicePixelRatioF() has to
be used instead of devicePixelRatio().
QGuiApplication::devicePixelRatio() does not have a 'F' version, it
always returns the real thing.
Fixes ticket #13039.
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.
Before this patch, all table cells had a semicolon at the beginning of their style:
<td style='; border-bottom:
This unwanted behaviour is only due to a typo in a condition when concatenating two styles: the previous code was checking the second part of the style once the first was output, instead of the first one.
In order to perform a conversion of graphic format LyX generates
a python script containing the path of the original file to convert.
While Python2 needs the file in the native encoding of the OS, in
Python3 the encoding has to strictly be how announced by the first
line of a script, in our case utf-8.
Note that there is also a vector parameter that is passed by value.
However it is modified as a local copy and I do not want to change
this now.
Spotted by coverity.
The problem is caused by removing temporary aux, etc, files while
we are in the process of exporting. As Jürgen suggested, we really
do not need to remove these files until we are preparing to export:
They are not used internally. So now we just schedule the removal
and do it then.
colswitch was checking for oldstyle instead of normalcolor
to see if we need \normalcolor, which lead to appearence
of \color{none} in some cases, but "none" is not a known
color.
Instead of displaying the complete path, display the file name
first and then the path enclosed in parenthesis.
In this way files with same name but different path can still be
distinguished and, at the same time, files with different names
but same path are more easily spotted in case the complete path
is truncated by file managers.
While it is not necessary to run validate() on insets that do not
produce output (yellow notes and disabled branches), it has to be done
for previewing, since a construct inside the inset may require some
support.
This is done in two steps:
1. in PreviewLoader::dumpPreamble, indicate that a preview is being
prepared. It is not clear why the `for_preview' boolean was not set
before.
2. in Inset(Branch|Note)::validate, always call the parent's validate
method when previewing.
It should have been possible to move the code from 2. to
InsetText::validate, but the weird code in handling
InsetNoteParams::Comment in html makes it difficult.
It is not clear whether this feature was once documented and used (it
would have been 20 years ago).
It is mostly disable now, but there was a remaining bit that is
annoying now.
I'll try to restore this later.
- Do not clear the initial selection to allow consecutive changes
(this is in line with the behavior in texted)
- Make the color changes last so that the underline is the right color
- Allow to operate on selections that span multiple cells in a grid
- Use \boldsymbol instead of \mathbf to make everything bold
This new warning in gcc 13 is annoying because it happens in certain
parts of our code where it is harmless to pass a temporary variable to
a function that returns a reference.
This patch introduces a new pair of macros,
LYX_BEGIN_MUTE_GCC_WARNING(warn) and LYX_END_MUTE_GCC_WARNING, which
can be used to define a block of code where a given GCC warning is disabled.
The macros are no-ops with compilers other than gcc, although some
compilers that pretend to be GCC make be mis-detected. The worse that
can happen AFAIU is a bunch of warnings.
The macro relies on an intimidating set of for nested macros. The goal
of these macros is to build a nested string bit by bit. Here is how it
works:
PRAGMA_IGNORE(dangling-reference)
=> PRAGMA_IGNORE_1(-Wdangling-reference)
=> PRAGMA_IGNORE_2("-Wdangling-reference")
=> PRAGMA_IGNORE_3(GCC diagnostic ignored "-Wdangling-reference")
=> _Pragma("GCC diagnostic ignored \""-Wdangling-reference\"")
The next question is: what is _Pragma() good for? Well, it is a
version of #pragma that can be used in a macro.
And finally, what are those pragmas good for? The 'push' and 'pop'
ones make changes to warnings local. The 'ignored' ones allow
to disable some warnings. And disabling -Wpragmas ensures that we do
not have a warning if we try to disable a warning that is not
supported by the compiler.
The \underbar macro is a text mode macro that can also be used
in math mode. However, when inserting it in mathed, LyX helpfully
wraps it in a \text inset. One can dissolve such text inset and
the macro would appear in math mode without any problem. But the
output routine thinks that the user is shooting itself in the
foot and tries to protect him by wrapping \underbar in the
\lyxmathsym macro, whose definition is normally added to the
preamble when an unicode character is used in math mode.
Of course, this is not the case for \underbar and a compile
error arises. The easier solution is to simply add lyxmathsym as
a requirement for \underbar in lib/symbols, but this means
that the definition of \lyxmathsym would be added even when not
necessary (because in the validation routine we miss the info
about the current mode). The correct solution is acknowledging
the dual nature of \underbar as a text-mode macro that can also
be used in math mode. Luckily the correct solution is almost as
easy as the easier one and is what is done in this commit.
Separate mangled-name tables for xhtml and latex exports.
LaTeX route should stay as it were (counter+mangled path within filenames in
temp directory)
xHTML route uses hash of path + filename only. We won't use counters because
(unlike in LaTeX export) they stay visible in final export directory and
generally change across LyX sessions.
Hash is short with collision handling because path-length limits of Windows.
cf https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg220582.html
This is only needed for very old versions of the nomencl package
(before March 2005)
No need to output compatibility code with newer versions
Furthermore, this breaks the use of the glossary package which also
has .glo extension (#12968)
If an element is underlined in mathed by using the text properties
dialog, the changes accumulate. So, for example, to change a single
underline to a double one, one would need removing the previous
underline first. This commit allows using the text properties
dialog and simply replace an underline type with another one.
However, this works only if the underlined element is not included
in some other inset. For example, given "\uline{\text{abc}}",
selecting the 'b' and choosing a double underline produces
"\uline{\text{a\uuline{b}c}}". But, given "\text{\uline{abc}}", and
operating as before produces "\text{\uline{a}\uuline{b}\uline{c}}".
This change forces metrics computation in all cases when cursor enters
a math inset from above/below, but I do not have a better idea right now.
Fixes bug #12952.
Until now only the color of the text could be changed by using
the text properties dialog. This commit allows changing all
other properties except for strikethrough. It is possible to
also add underlining with the limitation that the changes
accumulate. This requires other work but I think that underlining
and strikethrough are not so important in mathed and can be
refined at a later time.
Fixes#12958
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.
Some text-in-math environments such as \text, \mbox, \fbox, and
\makebox, inherit the outer text font. This commit reflects this
in the on-screen representation.
Fixes#12950.
This reverts commit d72b9b0238.
Unfortunately, the font taken into account is the font at the
current cursor position rather than the font of the corresponding
math inset.
The text-in-math environments such as \text, \mbox, \fbox, \makebox
and so on, inherit the outer text font. This commit reflects this
in the on-screen representation.
Fixes#12950.
When setting halfline parskip with parskip provided, we still need
to set this explicitly, as we don't know the current \parskip value.
Also improve code readability.
Error handling issues (CHECKED_RETURN)
Calling "translateString" without checking return value
(as is done elsewhere 15 out of 18 times).
AFAICS we do not need the boolean return value in these two cases.
It might happen that the selection goes away without recomputing
metrics (for example with char-forward). The added test is a bit of a
band-aid for this situation. A better solution would be to understand
better when metrics computation is triggered in mathed.
Fixes three similar warnings. One of them is the following:
src/insets/InsetInfo.cpp:1583:20: error: comparison of integers of different signs: 'int' and 'std::basic_string<wchar_t>::size_type' (aka 'unsigned long') [-Werror,-Wsign-compare]
for (int i = 0; i < sequence.length(); ++i) {
~ ^ ~~~~~~~~~~~~~~~~~
When having the code preview pane open with examples/Language_Support/Mixing_Japanese_with_other_Languages_(with_CJKutf8), clicking at random on paragraphs sometimes yielded a crash: *par when par is the end of the iterator. LyX could output the whole document as DocBook without this patch and still generates the same output with it (i.e. no text is missing).
Previously, when closing font tags, only the previous character's font was used. However, if that character is deleted, it had no change of having the right font tags opened/closed. Hence, look further to compare the font of the current character to output with the font of the previously output character.
A similar patch would be required for LyXHTML, but it will come later. The main impact is that some text isn't output in XHTML (like DocBook before this patch).
The code isn't as clean as it could be. I avoided touching anything not related to DocBook, as the release of 2.4 is nearing, while leaving comments for parts to improve for the next release cycle. Given that the code compiles, there are no risks for TeX or XHTML outputs; for DocBook, less content is skipped, which is a net improvement for users.
To have a distinctive color for selected math which works in both modes
Also, link color_selectionmath with QPalette::HighlightedText, so we
won't need to special-case on lyxrc.use_system_colors any longer
Currently, selected math hull insets use Color_selectiontext when
system colors are in use. This commit implements the same behavior
for partial selection.
This is done by introducing two element types (BEGIN_SEL and END_SEL)
to MathRow.
Explanation from Udi:
There is a missing validation for the requirement of xcolor in
InsetBox::validate, the case we use Boxed with non-default color.
Patch from Udi.
When it turns out that breaking a STRING row element was not
sufficient in Row::shortenIfNeeded, we still remember the shortest
width that one can obtain. Later, when we try to split a previous
element of the row, we have a better idea of how much of the row
remains after it.
To this end, change the signature of Element::splitAt to use an enum:
FIT (was: force=false), FORCE (was: force= true) and BEST_EFFORT
(split at max_width, but do not return an error if the string is too
large).
Fixes bug #12660.
Add a Direction parameter to the Painter::text methods that take a
FontInfo parameter.
In drawStrRed and drawStrBlack, force the direction to LtR.
Fixes bug #12905.
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)
Without this patch, when a file has to be loaded (for example,
after "Document->Settings->Local Class" or "Insert->Graphics")
and the file dialog is canceled, both Qt5 and Qt6 assert:
ASSERT failure in QList::at: "index out of range"
The old code only worked for toplevel cursors and did not show current cursor.
Note that the two windows do not have exactly the same offset.
Fixes bug #12689.
* The lyxpaperview script now only provides the paths and let us do the opening
* We use our own viewers for local files rather than QDesktopServices
Plus several minor improvements and code cleanup
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.
- code reorganization to move the file name chooser methods in GuiDialog class
- on Mac add explicit raise of the current dialog window on close of the file browser to work around the bug 12576