This arguments are shared_ptr objects, so they are not expensive to
copy. However, it makes sense to pass such pointers by const reference
when they are just intended for reading.
Some reading about this issue is here:
https://www.internalpointers.com/post/move-smart-pointers-and-out-functions-modern-c
Fixes some Coverity scan defects.
The situation of the convert<>() template was a mess: the header
announced that template specializations passed strings by address (my
doing long ago), but the code would just define versions that upass
strings by value.
The solution is to pass all values by address. This works very well,
_except_ when the value is a string litteral.
Defining the templates thus requires a bit of work.
Spotted by Coverity scan.
This function is used a lot to initialize static docstrings. This is
an issue in theory because lyxerr may not have been initialized in
time.
In practice of course, lyxerr will only be used when there is a
non-ascii character in the parameter, which is really not supposed to
happen.
This gets rid of 75 coverity reports.
BOTTOM shows the paragraph containing the cursor at the bottom of the
work area.
TOGGLE does CENTER, then TOP, BOTTOM and finally cycles to CENTER.
This is a feature copied from emacs's C-l binding.
Add new argument "caret" to lfun "scroll" that can be used like
scroll caret center
Change the keys (either C-l, M-l or F5) bound to screen-recenter to
"scroll caret toggle".
As an experiment, change paragraph-goto to use this scrolling method.
This can be tested when going to a heading in the outline pane.
Since BufferView::scroll() does not correct scrolling amount at
top/bottom anymore, remove its return value and add a new one to
BufferView::updateMetrics(bool) that returns this correction.
Rely on updateMetrics(false) to set the metrics straight after moving
the anchor y position.
Use assert_in_view = false when calling TextMetrics::editXY() because
this parameter does not work as advertised: if an inset not totally
visible, the code will not try to go inside it to look for a smaller
row that is totally visible.
Two small (hopfully useful) modifications:
- take into account the cursor X target instead of its screen position
- adapt the cursor position depending on
lyxrc.mac_like_cursor_movement when hitting start or end of
document.
LFUN_SCROLL was the last user, change it to use only scroll(). Take
this opportunity to improve a bit this dispatch code.
Also improve somewhat the methods documentation.
There are two parts in this patch :
1/ in the part where the cursor is already visible, replace calls to
scroll/scrollUp/scrollDown by direct manipulation of the anchor
vertical position. Reasoning in terms of new position rather than
amount of pixels to scroll makes work easier.
2/ in the part where the cursor is set to a new TOP or CENTER
position, move the code around in order to prepare for new ScrollType
enums.
No change intended, except that CENTER now relies on the contents
dimension of the row that holds the iterator, that is without spacing
and labels.
The code there that checks whether we scroll beyond the top/bottom of
document is not needed anymore, this is handled later by
BufferView::update(bool).
Note that this methods may disappear with time.
No change intended.
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.
This code is not necessary anymore after the fix to #13069.
Remove the first QString argument to createView(). Set the autoShow
parameter to false by default and rename createView(id) to
createAndShowView(id) to avoid member function overloading issues.
Remove optional <GEOMETRY> argument of window-new lfun.
Document the removal of the argument in release notes.
Since the platform is selected at run time (e.g. xcb vs. Wayland), it
is not a good idea to decide at compile time what code is run. Another
example is on macOS, where having xcb libraries available will lead to
lauching the Xquartz whenever LyX is running.
With this patch, things are separated:
- the code is run when run-time platform is "xcb".
- the support code is compiled in when xcb header and libraries are
available.
Fixes ticket #13086.
Instead of baking our own support for -geometry command line option on
Windows (Qt only does that for Xcb), use the fact that Qt 5 provides
the equivalent -qwindowgeometry flag.
All we need to do is to replace the -geometry option with -qwindowgeometry.
This is part of the effort in ticket #13086 to get rid of the
compile-time QPA_XCB define.
This is the new(er) babel mechanism to load languages via babel *.ini
files.
Some languages (or varieties) are only supported this way, some work
better with unicode engines this way (for the latter case, we have
BabelProvide 2)
Use raw strings to avoid the following syntax warnings that show up
in LastTest.log after running tex2lyx ctests:
src/tex2lyx/test/runtests.py:135: SyntaxWarning: invalid escape sequence '\o'
if linex[:-1] == '\origin ' + inputdir + '/':
src/tex2lyx/test/runtests.py:136: SyntaxWarning: invalid escape sequence '\o'
lines1[i1] = '\origin ' + outputdir + '/' + "\n"
It turns out that Qt font selection via style name is broken on
Windows (QTBUG-101436). As we use our own style name for discriminating
our math fonts and applying proper kerning, we need a fallback method.
With this commit we check for the family name when the style name does
not match. In computing the kerning we also consider the right bearing
reported by the font instead of the width of the enclosing bounding box,
as this produces better results (see bug 13087).
Fixes#13087.
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
We now have the functionality via sub-insets, and unexperienced users
are surprised when they don't get a literal !.
The unescaped chars can still be used via ERT.
There are several reasons to do it this way, among which is odd
behavior of the TOC filter if we put anything else there. This also
allows for filtering of the references themsevles in a natural way.
The change, I think, was really an unintended consequence of other
changes connected to showing formatted references in the work area.
The movement to the caption is now done in the LFUN function itself,
as we need the DocIterator in the caption
This greatly simplifies the code in the TocWidget and shifts all the
complexity to the LFUN itself
* par id actually can be 0
* properly move on in the buffer list if paragraph is not found
in the current buffer
* use dit to get label (as this might be in a different buffer)
This allows to insert a cross-reference to headings, figures or tables
by right-clicking on the outliner item.
If the item in question does not have a label yet, it is inserted.
This function checks whether a paragraph (specified by ID) has a label.
If so, it simply inserts a reference to this at cursor position, if
not it inserts a label to that paragraph (pos 0) and then inserts
a reference at cursor position.
Needed to implement #1624 (insert cross references to items that do not
have yet a label)
As with almost everything, this class bakes its own cake also with
multiple indexes. So we need to account for this to produce
compilable output.
Not very nice, but there you go!
Rely on the newly-introduced Buffer::id() to skip statistics
computation if the id is the same as last time. This will reduce the
annoyance of updates triggering at random times.
Take this occasion to clean code up:
- add 'skip' parameter (true by default) to Statistics::update to indicate
that the insets that do not produce output should be skipped.
- use a trailing underscrore for private members
Each buffer now has an id which is increased when it is marked dirty
(or when one of its relatives is marked dirty).
This can be a big win since updateMacros is very expensive.
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.
\boxed{} is the only box in LaTeX that contains math. It is amusing
that the example file that we had for ticket #13609 should not have
been a problem since there is no reason to force <mtext> there.
This commit addresses two issues:
1/ the embarassing one: the member SetMode::old_text_level_ was
declared as bool instead of int. This means that is was definitely
not a proper backup variable!
2/ a robustness issue: replace two consecutive test for isTest() by a
boolean veriable that is used twice. This makes sure that <mrow>
cannot be output without the corresponding </mrow>.
Part of bug #13069.
This trivial patch makes scrolling-by-selection smoother by dividing
the step size and the time between steps by 8 when generating
synthetic events in work area.
The scrolling speed is unchanged, but the result is visually better.
Instead of generating code and parsing it to add <mtext>...</mtext> at
the right spots, this commit honors the text mode setting that was
already present in the codebase to generate it automatically.
This is the work of two helper methods in MathMLStream:
* beforeText() notices when the stream is in text mode and that a
<mtext> has not yet been generated. In this case it inserts it, so
that raw text can be emitted afterwards.
* beforeTag() checks whether a <mtext> needs to be closed at this
point, and does it if needed.
To make this work, the code now tracks the nesting level in the
stream, and compares it the what the level was when text mode has been
enabled using the SetMode helper function.
In order to avoid later bugs, member os() that allows to access the
underlying stream of MathMLStream is removed. This required many <<
operators to become friends of MathMLStream.
In InsetMathBox, rename splitAndWrapInMText() to mathmlizeHelper(),
which is not just a method that sets text mode inside a <mrow>
element.
In InsetMathFont and InsetMathHull, the explicit generation of nesting
in <mtext>...</mtext> can be removed now.
Fixes bug #13069.
This is preparatory work for fixing ticket #13069.
Remove direct accesses to the underlying stream of MathMLStream in
InsetMathChar, InsetMathSpecialChar, and in all << operators other
than MathMLStream << docstring. This will allow to add a hook later in
this operator.
Move default values of MathMLStream private members to their definition.
Get rid of line_ member, which is not used.
When using system colors it may happen (on windows 11 in particular)
that the background color is actually translucid. This is not
something we are prepared to handle and it creates ghosts on screen.
The fix is easy: the alpha channel of the colors is set to 255.
Fixes bug #13084.