getPosNearX, which is the only user of x2pos, should always return the
nearest position.
In editXY, there is a need to return the position where the inset
stands, but it is done using checkInsetHit.
This is a simplification of commit eb4a2a19, which has been reverted
at 01f0ab64a.
Fixes part of bug #10569.
Instead of using complicated (and wrong) code, it is better to use
getPosNearX here.
Also simplify the code by removing temporary variables.
Fixes part of #10569.
The code that looks whether neighbor block has a different direction
should look to the left or to the right depending on the direction of
the current block.
Fixes part of bug #10569
This allows to fix distclean properly, since we know that
subdir-objects is used. When it is the case, it is not a good idea for
a Makefile to use a source file which is under the control of another
one. This could not be made to work work with old automake versions
(<1.14).
Therefore we refer directly to object files in Makefile.am instead of
source files. The actually leads to less compilation in tex2lyx.
Update the code here and there to remove compatibility hacks. Update
documentation.
Re-enable the layout test and fix the Length test, which was ovewriting
memory in test_inPixels() because lyxrc did not had a correct layout.
As it was, the comparison buffer was sharing a DocumentClass with
one of the compared buffers. I don't fully understand why this was
causing a problem, since we use a shared_ptr. But this patch creates
a new DocumentClass for the new buffer.
This is preliminary work to make roots look more like in TeX output:
* correct font size for root order
* set minimum size of the root from the max ascent descent of the
font. This is what TeX does.
* fix drawing, and in particular horizontal size.
More needs to be done, in particular:
* handle zooming and dpi correctly by removing hardcoded pixel values.
* factor the code for the two types of roots in one.
With RtL text, the method can be non-monotonic wrt x value (which is a
Qt bug). To work around this, we check whether positions adjacent to
those returned by xToCursor look better. Depending on whether the new
x position is too small or too large, we look backward or forward for
a better solution.
The performance is probably not great, but this is only needed for
user interactions, so the performance penalty should not be a problem.
Fixes#10569.
Coverity flags this code as not handling exception that may happen in buffer().
My own analysis is that this can never happen because isBufferValid()
does check whether buffer_ is null.
Any insght appreciated. The commit should be expeanded to more cases, actually.
The RenderButton object now has this property. It is set depending on
the value of inheritFont() method that is currently only set for
InsetRef, InsetBibtex and InsetCitation.
Fixes bug #10258
There a some exceptions related to the fact that BOOST_ASSERT throws
an unhandled exception, which is fait enough. This is handled by
uploading a modeling file to coverity.
The second batch of issues are related to the use of lexical_cast in
convert.cpp. We use now a wrapper around boost::lexical_cast that does
not throw but return empty strings instead. I am not sure actually of
when lexical_cast could fail.
The special mode used by macros where the macro name is displayed as
grey text in a box is now one of the possible marker types for any
inset. The new code puts the macro name below the text, which means
that only the text below the current line will be moved. This makes
edition much more comfortable. The grey border around the contents has
been removed too.
The marker_type enum has been moved from Inset to InsetMath. A
markerMargin() function returns the horizontal margin required on each
side for the marker. Only the corner-type markers MARKER and MARKER2
need some.
A new BOX_MARKER enum value has been added and is taken care of in
afterMetricsMarkers (renamed from metricsMarkerVertical) and
drawMarkers.
The InsetMath::marker() macro now takes a BufferView pointer as
argument, so that the marker type can depend on editing state.
MathRow::metrics now makes changes to the MathRow object when needed.
The specific metrics/draw code in MathMacro has been removed and
replaced by assertions. Code in addToMathRow and marker is adapted to
reflect the cases where linearization is possible.
Rephrase positively the check box for the output of en- and em-dashes
and disable it when using non-TeX fonts. The state of the check box
is remembered, so that toggling the non-TeX fonts check box does not
cause information loss.
This commit fixes the regression introduced in 2.2 about the
output of en- and em-dashes. In 2.2 en- and em-dashes are output as
the \textendash and \textemdash macros when using TeX fonts, causing
changed output in old documents and also bugs (for example, #10490).
Now documents produced with older versions work again as intended,
while documents produced with 2.2 can be made to produce the exact
same output by simply checking "Don't use ligatures for en-and
em-dashes" in Document->Settings->Fonts.
When exporting documents using TeX fonts to earlier versions, in order
to avoid changed output, a zero-width space character is inserted after
each en/em-dash if dash ligatures are allowed. These characters are
removed when reloading documents with 2.3, so that they don't accumulate.
Handle name prefix (aka "von" part) as a separate entity, just like
BibTeX and Biblatex do. This allows to omit or reposition it in
accordance to the current style ("Goethe, Johann Wolfgang" or
"von Goethe, Johann Wolfgang" or "Goethe, Johann Wolfgang von" are all
valid and used).
LyX's name parser should now be on par with BibTeX's.
This patch removes explicit calls to stat() in the DepTable code. The
original motivation was to get read of a stat() invokation where the
error condition was not checked (spotted by coverity).
It is not clear that the optimization is a gain, but it is clear that
it has a cost: some elements of formulas will not be present in the
position cache.
Fixes bug #10520.
Using this global variable in the class is clearly a bug. If we wanted
to avoid doing it by mistake, the variable should be moved to the LyX
singleton.
Also add an underscore to the private variable formatlist_.
When we have a name with more than two parts, but no "von",
it was coming out as, e.g.:
Obama, Barack Hussain Obama
i.e., with the last name appearing twice.
Also adds a check for names without spaces, which would have given:
Pele, Pele
This was not the original issue at #10582, so that bug is still
open (though I cannot reproduce it).
The error is reported in the GUI, but for the terminal we must write
explicitly to STDERR.
For a specific example of this type of exception, see the previous
commit, 72c3dbd.
If an included file is not found, it seems impossible that the final
output would be correct. Before this commit, when exporting on the
command line, LyX would create the PDF and exit with a zero error
code so unless the user was monitoring the terminal output, they
would not know there is a problem.
This change is consistent with 1a374a93.
Introduce a distinction between being read-only and having the read-only flag. A
buffer is read-only if either it has been externally modified or if it has the
read-only flag.
Coverity complains that we might read strings that are arbitrary
large, and that this can be a security issue. This is a problem in
particular, when we feed these strings to from_utf8(), which coverity
flags as dangerous for some reason.
The best solution would be IMO to model from_utf8() properly, but I do
not know how to do that. Here I try a different solution, where I
cannot read a string larger than 64k from the file.
Let's see whether this removes part of coverity warnings.
Coverity does not find it obvious that p is never negative. Normally
it is the case (because the items have been filtered), but it is
better to play safe.
The added cmake-parameter is:
-DLYX_EXTERNAL_MYTHES=<value>
where <value> is one of
AUTO (Default) Search first on system for mythes (lib and include)
ON Use installed only (errors if not installed)
OFF Compile the provided source in 3rdparty
Instead of using a coverity annotation (that does not work) it is
better to really iinitialize the members of the object, just in case
somebody decides to actually use the DisplayPath() constructor.
Coverity correctly spotted that the existing code creates a temporary
map and returns a value from it. It is not possible to make the map
const& directly because operator[] may change the map.
Therefore, we use map::find instead.
When including files, LyX always searches the user and the system
directory, in that order. This means that when using local layout
files broken down into multiple includes, the various includes should
be specified with a path relative to the user layouts directory
(typically ~/.lyx/layouts), making this very impractical.
This commit allows including local files by specifying their path
as explicitly relative to the main layout file position, i.e., by
specifying their path with either "./" or "../". If the main layout
is not loaded from a local file, the usual search order is used,
even if the path are explicitly relative. So, for system layouts,
both "Input ./name.inc" and "Input name.inc" are equivalent.
It extended QToolBox with size calculation to fix UI issues with the previous
design of GuiCitation. Since it always needed some kind of hack and since
QToolBoxes do not appear so popular, it probably won't be used anymore.
Because latex allows to do so, and there is no easy way to achieve this.
This was apparently implemented to allow cycling between the various dash
types, but it was a bad idea bringing no benefit and causing griefs.
Previous fontspec loaded xunicode internally, for recent version, this
is no longer desired. However, we still need it for tipa emulation.
We use fontspec's trick to bypass XeTeX test with LuaTeX.
Now the selection is not done by the inset, but by the MathData
itself. This allows for some code simplification and avoids an
extra redraw.
Additionally, this fixes the selection inside macros, which was broken
by the new MathRow code.
Useful to cache copies of objects, including shared_ptrs. No risks of dangling
pointer, and avoid naked pointers in the source.
Fix memory leak when compiling with Qt5.
Now backspace and delete in text will select non-empty math and text insets
before deleting them. This is consistent with what happens in math already.
This is implemented for InsetText as well but can be disabled in case of
negative feedback.
This can be set for any sort of inset with the new virtual method
Inset::confirmDeletion.
New option "force" for the LFUN_*_DELETE_* commands, that bypasses the
confirmDeletion check.
The special mode used by macros where the macro name is displayed as
grey text in a box is now one of the possible marker types for any
inset. The new code puts the macro name below the text, which means
that only the text below the current line will be moved. This makes
edition much more comfortable.
The marker_type enum has been moved from Inset to InsetMath.
A new BOX_MARKER enum value has been added and is taken care of in
afterMetricsMarkers (renamed from metricsMarkerVertical) and
drawMarkers.
The InsetMath::marker() macro now takes a BufferView pointer as
argument, so that the marker type can depend on editing state.
MathRow::metrics now makes changes to the MathRow object when needed.
The specific metrics/draw code in MathMacro has been removed and
replaced by assertions. Code in addToMathRow and marker is adapted to
reflect the cases where linearization is possible.
From now on \kern and \mkern remain as ERT as long as the length is invalid.
Fixes#10539 (regression at 10c8d51b).
The only way to produce an InsetMathKern now is via parsing (i.e. file opening
or copy-paste). This is because there has never been any sensible way to input a
valid InsetMathKern, but this is another issue.
Since in InsetMathNest::cursorPos we do not know what is the value of
the row element before value of a given BOX, it does not make sense to
set the cursor at a given offset from the start of the MathData
object.
Therefore here we set the cursor in the middle of the MathData object,
which unfortunately may or may not be visually centered wrt the BOX.
The best solution would be to use the MathRow data here, but
unfortunately this is not completely trivial.
This patch replaces 7917ebcc4.
Horizontal space is now added for linearized macros too.
Vertical space handling is done in a separate method.
This is in preparation for handling of 'box' macro editing mode in
MathRow.
The current version was wrong for non-English dialogs, and even for
the English one, due to the translator commands that were not removed
for calculation (as in "Formats[[output]]").
Candidate for stable.
This adds support for the chapterbib package, but also adds ways to
produce this sort of multibib with biblatex and bibtopic (which are
both incompatible with chapterbib).
File format change.
InsetMathDelim does not need markers because the delimiters are
visually enough.
CommandInset (like InsetMathRef) does have cells, but they are hidden
(only for storage). Therefore the default InsetMath::markers() method
mistakenly added markers. In practice, the markers were never active
(since the cursor cannot go into the inset), but some space was
reserved for them.
This allows to somewhat simplify the text and avoid some uses of
Paragraph (in the long term, RowPainter should not have to access
these things).
At the same time do a small cleanup to RowPainter: rename
text_metrics_ to tm_, remove pm_ and width_.
The enum values BEG_MACRO/END_MACRO and BEG_AR/END_AR are replaced by a
single BEGIN/END pair.
The MathRow code now only knows about insets and math arrays.
New hooks (before|after)(Metrics|Draw) are run by the MathRow code
as needed. They are actually also used internally by the MathMacro
code.
The gain is that most traces of explicit macro handling (and
the MathRow::Element::macro member) have been removed from MathRw.cpp.
The next step will be to extend the tokenizing process to allow for
linearizing insets other than macros.
* Convert the kerning into a proper right margin for mathnormal, mathscr and
mathcal (fonts with \fontdimen2 == 0 as per rule 17 from TeXBook).
* Simulate the fact that characters in mathnormal fonts have a 0-width left
bearing.
* Implement subscript positioning in the case of rule 17 using negative italic
correction (kerning_).
File format change.
This allows for the relevant InsetCommand-based dialogs (such as
citation text before/after, Bibitem label, hyperlink name etc.)
to provide both the input of verbatim code or text that is transformed
to proper LaTeX code.
Some dialogs (Nomencl, Href) already had some methods (although they
could not be toggled), which are now centralized and streamlined.
The initial work of this patch has been done by Georg Baum (see
http://www.lyx.org/trac/attachment/ticket/2751/x.diff)
Fixes: #2751, #8227.
When using Qt stuff in breakAt, it may happen that the row is broken
after an hyphen (whereas the old code would only consider spaces).
The fact that we abuse the Row::right_boundary() property to detect when
a row should be flushed broke justification when a row is cut at an
hyphen.
Fix this by introducing a new Row::flushed() property and set it as needed.
The code that tries to decide whether it is worth splitting a given
text row element had a shortcoming: it did not take into account the
left margin of the new row that would be created.
The problem is that this left margin is not the same as the left
margin of the current row, because there can be for example
indentation effects.
To fix this problem, we pass the amount of available space on the
next row as a parameter of Row::shortenIfNeeded.
Note that there is no need to care about RtL row elements at this
point, since the bidi algorithm will be applied to the row
subsequently.
This avoids some duplicate code. Note that the return value of
Paragraph::getAlign had to be changed. I suspect it was set to char to
avoid reading one header file in Paragraph.h.