Commit Graph

24083 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
af45bfaee1 Initialize class members to please coverity 2017-03-01 16:28:30 +01:00
Jean-Marc Lasgouttes
ea8f0d2076 Initialize properly a class member
This was forgotten at 0552563c99, and it only meant to keep coverity happy.
2017-03-01 16:21:45 +01:00
Enrico Forestieri
17ab47b3e6 Allow Input of local includes from local layout files
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.
2017-03-01 09:19:18 +01:00
Guillaume Munch
a1faa41c83 buffer-export without argument exports the default format
buffer-export is proposed as a default binding in the preferences so now it does
what a user expects when binding it to a key.
2017-02-28 00:46:33 +01:00
Guillaume Munch
887722dbfa Remove LyXToolBox
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.
2017-02-26 22:16:10 +01:00
Guillaume Munch
06416763ac Give focus to the filter in GuiRef
This is now consistent with GuiCitation. Compared to the previous behaviour
there is only one down key press difference.
2017-02-26 22:16:10 +01:00
Guillaume Munch
750c48eda3 Fix focus events in GuiCitation 2017-02-26 22:16:10 +01:00
Guillaume Munch
d50b66fc88 Whitespace and remove obsolete #ifdef. 2017-02-26 22:16:10 +01:00
Guillaume Munch
eab83ec678 Implement down key press in FancyLineEdit 2017-02-26 22:16:10 +01:00
Guillaume Munch
e6180e9914 Implement left-right navigation in GuiCitation 2017-02-26 22:16:10 +01:00
Guillaume Munch
26b2cc89d3 Fix 18 memory leaks
Also whitespace.
2017-02-26 22:16:10 +01:00
Enrico Forestieri
3c329db0a5 Allow inserting consecutive dashes
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.
2017-02-25 14:13:02 +01:00
Juergen Spitzmueller
73ccee113e rename BufferParams::font_encoding() to ::main_font_encoding()
Because that's what's actually returned.
2017-02-25 12:49:49 +01:00
Jean-Marc Lasgouttes
83cf59cf94 Remove unreachable return statement
ALso re-indent a bit.

Fixes coverity issue 134137
2017-02-25 00:32:58 +01:00
Jean-Marc Lasgouttes
8a9ea4d264 Initialize properly pointer
Fixes coverity issue 23411
2017-02-25 00:20:51 +01:00
Juergen Spitzmueller
e68afbe671 Plain quote fixes
\textquote... commands are only available in t1.
2017-02-23 10:39:50 +01:00
Juergen Spitzmueller
cf82bcadfb Use proper font encoding in InsetQuotes 2017-02-23 10:39:31 +01:00
Juergen Spitzmueller
7d54edbf94 \textquotedbl and \textquotesingle are now covered by TU encoding
Generally, TU is on par with T1 now. Thus introduce a new latexSpecialTU
method that currently just links to latexSpecialT1.
2017-02-23 10:17:52 +01:00
Guillaume Munch
0a7ba185a3 GuiCitation: set instant search as the default
It was already supposed to be the default after 7d429291, but one has to set the
default value at the level of the QSettings.
2017-02-22 16:58:38 +01:00
Guillaume Munch
8353a53cc3 Clarify comment 2017-02-22 16:57:13 +01:00
Juergen Spitzmueller
b6a7530ba2 xunicode (only) needs to be loaded for tipa emulation.
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.
2017-02-22 11:27:51 +01:00
Jean-Marc Lasgouttes
d2ad9ae6e2 Rewrite selection code in mathed
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.
2017-02-22 11:00:30 +01:00
Jean-Marc Lasgouttes
1c1b3519f9 Use a plain font in macro edit box
Without this, the font would be mathcal in a mathcal environment.
Additionally, set the font size to tiny when computing metrics too.
2017-02-21 11:49:12 +01:00
Jean-Marc Lasgouttes
b9d45e5ef6 Set the cursor a bit on the left in empty cells 2017-02-21 09:53:52 +01:00
Jean-Marc Lasgouttes
5211ca52ca Move comment
It is slightly more useful here.
2017-02-21 06:52:34 +01:00
Jean-Marc Lasgouttes
e04079aa52 Fixup to 33b696c8: fix compilation with gcc 4.6 2017-02-21 06:21:49 +01:00
Jean-Marc Lasgouttes
fc02744119 Revert "Linearize macros in box edit mode too."
Guillaume tells me that there are problems. We'll return to it later.

This reverts commit 0140348118.
2017-02-21 05:43:38 +01:00
Guillaume Munch
33b696c8ac Introduce support/Cache.h
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.
2017-02-21 00:06:07 +01:00
Jean-Marc Lasgouttes
9a54376aef Better handling for negative position in pos2x
This code is already in stable actually. The old one does not work
well in RtL text.
2017-02-20 15:39:28 +01:00
Guillaume Munch
591b311984 Amend 71623b88
Fix loop of word-delete-backward at the start of a paragraph.
2017-02-19 14:54:44 +01:00
Guillaume Munch
7337c968b3 Fix InsetMathRef mouse behaviour (#10568)
Fix mouse-selection behaviour.

Don't open dialog when releasing if it was not a real click.
2017-02-18 23:03:54 +01:00
Guillaume Munch
63be456c8d When pressing math with the mouse, move to the closest edge (#9748)
Unless it has some dialog that we want to activate.
2017-02-18 23:03:54 +01:00
Guillaume Munch
bac8a95871 Improve mouse selection over InsetCollapsable button. 2017-02-18 23:03:54 +01:00
Guillaume Munch
faeb199793 When selecting math with the mouse, selection happens in the middle (#9748) 2017-02-18 23:03:54 +01:00
Guillaume Munch
eb4a2a190f When selecting text with the mouse, inset selection happens in the middle 2017-02-18 23:03:53 +01:00
Guillaume Munch
86d9abeea7 Move cursor in front of InsetMathSpace before opening the dialog (#7749) 2017-02-18 23:03:53 +01:00
Guillaume Munch
71623b88b2 Generalise the deletion protection mechanism from math to text (#9540)
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.
2017-02-18 23:03:23 +01:00
Juergen Spitzmueller
ffacdd8b46 Output Preamble code of InPreamble styles before the styles themselves.
This assures that macros are defined.

Fixes: #10215
2017-02-18 10:40:42 +01:00
Juergen Spitzmueller
e688b9876e Use ASCII number in \char definition
The backtick version breaks in some cases (footnotes in sections)
2017-02-18 10:18:36 +01:00
Juergen Spitzmueller
46e3885d19 \\textquotedbl and \\textquotesingl are unknown in TU encoding.
Use \\char` instead.
2017-02-15 08:37:02 +01:00
Juergen Spitzmueller
7ea6377066 Don't assume T1 font encoding for XeTeX/LuaTeX
They used OT1 internally, and the new TU encoding, which does not (yet?)
contain all macros of T1, as of the Jan 17 LaTeX release.
2017-02-15 08:35:46 +01:00
Jean-Marc Lasgouttes
0140348118 Linearize macros in box edit mode too.
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.
2017-02-14 01:02:00 +01:00
Juergen Spitzmueller
00417a1c80 Make openbtUnit raunparam mutable instead of using a copy of runparams
in latexParagraphs()

The latter results in output stream encoding errors.
2017-02-12 18:12:38 +01:00
Guillaume Munch
527cc8ca9c Disable InsetMathKern with invalid lengths (#10539)
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.
2017-02-11 21:52:09 +01:00
Juergen Spitzmueller
ff0d96c371 InsetHyperlink: Fix replacement of empty name with target 2017-02-08 09:17:14 +01:00
Jean-Marc Lasgouttes
ace5dc157c Compilation fix: missing header for std::max 2017-02-07 11:43:06 +01:00
Enrico Forestieri
5665209caa Ensure that QT_VERSION is defined
Otherwise checks such as "#if QT_VERSION >= 0x050600" will fail silently.
2017-02-07 11:16:05 +01:00
Jean-Marc Lasgouttes
6763301c05 Better fix for cursor in "blue box"
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.
2017-02-06 17:23:00 +01:00
Jean-Marc Lasgouttes
e12b27e16b Some clean-up to markers handling code.
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.
2017-02-06 17:17:56 +01:00
Juergen Spitzmueller
450344a9b7 Mention style-dependency of of features in the tooltips, part 2
Some amendments to c7126dc4f9.
2017-02-06 13:17:38 +01:00
Juergen Spitzmueller
c7126dc4f9 Mention style-dependency of some features in the tooltips. 2017-02-06 12:21:53 +01:00
Jean-Marc Lasgouttes
7917ebcc40 Fix cursor positionning in empty math arrays (blue box) 2017-02-06 11:59:39 +01:00
Jean-Marc Lasgouttes
ba8da35afd Fix monolithic build
I gave up understanding why operator==(docstring,char cont *) does not
work in this case.
2017-02-06 11:39:16 +01:00
Juergen Spitzmueller
95eecc8e4a Use localized item when calculating the panel stack's tree widget width.
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.
2017-02-05 18:02:34 +01:00
Juergen Spitzmueller
517ca4f1cc Disable literal cb if there is nothing to latexify. 2017-02-05 15:43:01 +01:00
Juergen Spitzmueller
06af852293 Correctly enable/disable citation dialog widgets on initialization.
Thanks Guillaume for pointing this out.

(candidate for stable)
2017-02-05 15:42:03 +01:00
Juergen Spitzmueller
2902028a38 update tex2lyx tests 2017-02-04 19:28:18 +01:00
Juergen Spitzmueller
bedebfc45a Support for multiple bibliographies setting "per child"
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.
2017-02-04 19:23:45 +01:00
Juergen Spitzmueller
401961d087 Only close btUnit at the end of the master. 2017-02-04 16:07:58 +01:00
Juergen Spitzmueller
199c3f8e22 update tex2lyx tests 2017-02-04 13:45:16 +01:00
Juergen Spitzmueller
7ca20b292c Support for multiple bibliographies
Using refsection=unit in biblatex, or bibtopic's btUnit environments
in BibTeX.

File format change.
2017-02-04 12:02:00 +01:00
Jean-Marc Lasgouttes
ad79ac406f Fixup 89662a68: remove markers that should not be there
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.
2017-02-03 10:52:53 +01:00
Jean-Marc Lasgouttes
0060227f27 Simplify TextMetrics::checkInsetHit
The main point is to use CoordCacheBase::covers to see whether a point
is inside a given isnet.
2017-02-02 16:14:23 +01:00
Jean-Marc Lasgouttes
1fca708c7f Move TextMetrics::findRowElement to Row class 2017-02-02 15:35:03 +01:00
Jean-Marc Lasgouttes
57c3a94730 Add RtL information to Row
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_.
2017-02-02 14:53:01 +01:00
Jean-Marc Lasgouttes
e0024231d3 Fix drawing of rectangle in old-style macro editing mode
The width was a bit to short.
2017-02-02 14:33:38 +01:00
Jean-Marc Lasgouttes
ec676a1dec Make MathRow tokens completely generic
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.
2017-02-01 17:46:53 +01:00
Jean-Marc Lasgouttes
6c13af3f29 Introduce hooks to encapsulate macro code of MathRow
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.
2017-02-01 15:20:06 +01:00
Jean-Marc Lasgouttes
f86dacc292 Linearize macros also when editing them
In the case of inline editing, this avoids unpleasant jumping issues.

This may requires to enter monochrome mode before painting the macro
elements.
2017-02-01 12:21:15 +01:00
Jean-Marc Lasgouttes
344f7f2e7d Make sanitize more robust to dangling pointers.
It is necessary to sanitize the new_word iterator too.
2017-02-01 10:11:55 +01:00
Jean-Marc Lasgouttes
2ea4b1dcdf Revert "Fix crash"
A better fix is forthcoming.

This reverts commit 177ad3d4a4.
2017-02-01 10:11:20 +01:00
Guillaume Munch
177ad3d4a4 Fix crash
Thanks Kornel for the report:
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg198630.html

Apparently sanitize can crash. Use the safer fixIfBroken even though it
truncates the cursor.
2017-01-31 22:55:00 +01:00
Guillaume Munch
03a4b8c932 Implement rule 17
* 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_).
2017-01-31 22:55:00 +01:00
Juergen Spitzmueller
580efe45ab Nomencl.ui: minor layout improvement. 2017-01-30 09:14:21 +01:00
Juergen Spitzmueller
48af150896 Update tex2lyx tests 2017-01-30 08:29:16 +01:00
Juergen Spitzmueller
caf72c07cd Check if literal param exists before querying value.
Otherwise LyX asserts.
2017-01-30 08:27:53 +01:00
Juergen Spitzmueller
e15a8f3551 Extend LATEXIFY command param handling and add literal param.
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.
2017-01-30 07:44:55 +01:00
Juergen Spitzmueller
c59375d679 Move protectArgument function to lstrings
This will be useful to other insets as well.
2017-01-29 12:08:29 +01:00
Juergen Spitzmueller
83074c431c Whitespace 2017-01-28 13:00:33 +01:00
Jean-Marc Lasgouttes
8e7d0c2002 Fix flushing of row that was cut after an hyphen
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.
2017-01-27 16:09:03 +01:00
Juergen Spitzmueller
ef387c81af Handle backslash in escape function.
Fixes: #4595.

Candidate for stable
2017-01-27 09:15:47 +01:00
Guillaume Munch
15f64f8413 Fix wrong DocIterator argument
Regression at 3391fed3.

The child's InsetText is the root, so we start with an empty DocIterator.

Thanks Scott for the report.
2017-01-27 00:42:37 +01:00
Guillaume Munch
5b2674c1db Update child's TocBackend as well
Before 3391fed3, this was done in InsetInclude::addToToc
2017-01-27 00:42:37 +01:00
Jean-Marc Lasgouttes
8491962c6b Fix wrong splitting of text row
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.
2017-01-26 14:16:24 +01:00
Enrico Forestieri
ebd96fadd5 Ignore QT_SCALE_FACTOR for Qt < 5.6
This environment variable was introduced in Qt 5.6.0
2017-01-25 20:00:54 +01:00
Tommaso Cucinotta
eaa3ddaf45 turned message about disabled converters from prefs from warning to error 2017-01-25 03:10:56 +01:00
Jean-Marc Lasgouttes
000832f9d9 Use Paragraph::getAlign in TextMetrics
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.
2017-01-24 19:33:03 +01:00
Jean-Marc Lasgouttes
1f352b390c Avoid markers for macros without arguments
An example was the \neq macro, which exhibited white markers when selecting.
2017-01-23 10:14:20 +01:00
Juergen Spitzmueller
fd8b4aebb0 Generalize the protection of brackets in citation arguments
Whenever an argument delimiter is used inside the argument, the argument
needs to be grouped, that is

\cites({text (text) text})

or

\cite[{text [text] text}]

This fixes the original case reported in #2751 which is independent
from the general issue that the pre- and postnote field take literal
code.
2017-01-22 10:27:06 +01:00
Enrico Forestieri
9e6cf6e05a Allow to properly scale the GUI with Qt5
Starting with Qt 5.6, setting the environment variable QT_SCALE_FACTOR
makes everything accordingly bigger. So, if QT_SCALE_FACTOR=1.2, all
text and GUI elements are rendered 20% bigger. However, if an application
does not account for this, everything will also look "blocky".
With this commit, all text and images will be scaled remaining sharp.
This works whether a HiDpi screen is used or not, but is mostly useful
with a HiDpi screen, as all GUI elements are more spaced apart and one
can use the mouse for selecting things without requiring a high precision.
2017-01-22 01:06:00 +01:00
Juergen Spitzmueller
9cad99c2b5 update tex2lyx tests 2017-01-21 14:46:43 +01:00
Juergen Spitzmueller
68ab4023cc Support for "qualified citation lists"
These are biblatex-specific multicite commands that allow for multiple
pre- and postnotes, as in:

\cites(pre)(post)[pre1][post1]{key1}[pre2][post2]{key2}...

with an optional general pre- and postnote, which applies to the whole
list (like [][] in normal cite commands) and an optional pre- and
postnotes for each item, so that pagination can actually be specified in
multi-cite references, as in:
(cf. Miller 2015, 2; furthermore Smith 2013, 23-23; Jenkins 2012, 103,
also refer to chapter 6 in this book)

See the biblatex manual, sec. 3.8.3., for details.

File format change.
2017-01-21 14:25:17 +01:00
Enrico Forestieri
633ad2032e Add clarifying comment 2017-01-20 20:30:06 +01:00
Jean-Marc Lasgouttes
4a935ed768 Fix metrics of math characters with 0 width
It seems that QTextLayout does not handle properly a single character
with 0 width. This breaks drawing of things like \not.

Actually the problem had been worked around already in lib/symbol. The
work around can therefore by removed now.
[additionally, remove extra spacing from \mapsto, \Mapsto]
2017-01-20 10:53:06 +01:00
Pavel Sanda
c9c2179c1f Fix make check. 2017-01-19 17:00:18 -08:00
Richard Heck
0d77a7e325 Allow LyX to open empty files (created, e.g., via "touch").
Patch from new contributor Jan Niklas Hasse.
2017-01-19 15:34:45 -05:00
Jean-Marc Lasgouttes
d712c67be9 BOX tweak
Add a pixel gap around boxes.

When a box is invisible, its width should be null (but keep the weight
to avoid drawing problems (think empty sqrt in a macro).
2017-01-19 17:07:21 +01:00
Jean-Marc Lasgouttes
5982d2abd7 Revert "BOX tweak"
This reverts commit 596c9065e6.
2017-01-17 16:31:34 +01:00
Jean-Marc Lasgouttes
f73bb3f16e Fix glitch in drawing fractions
This is a fixup to 89662a68.
2017-01-17 16:28:48 +01:00
Jean-Marc Lasgouttes
596c9065e6 BOX tweak 2017-01-16 15:35:45 +01:00