Commit Graph

24419 Commits

Author SHA1 Message Date
Enrico Forestieri
000b7f3f46 Correctly skip a bottom caption
The getArg() method stops at the first closing brace, whether it
matches the opening one or not, so properly parse the caption and
then throw it away.
2017-06-17 14:01:42 +02:00
Juergen Spitzmueller
cde5d60fcf Update parent buffer as soon as a child has been released
This prevents dangling pointers that might crash LyX.

Fixes: #9979.

Candidate for stable.
2017-06-17 09:43:01 +02:00
Enrico Forestieri
7a9bb85184 tex2lyx: import minted listings
This commit updates tex2lyx in order to also import minted listings.
For the floating version of a listing, minted uses the listing
environment, a concept that is not shared with the listings package,
towards which our listings inset is geared.
For this reason, a kludge is necessary when importing minted listings
not previously exported by LyX itself.
If the floating listing contains only a caption and a label (other
than the listing itself), everything is fine and the import is (or
aims to be) perfect. But, as in all other floating ebvironments,
one can also stick there other elements, which don't have a place
in the listings inset. So, in order to avoid a data loss, tex2lyx
sticks everything into the caption. In this way, things may be
rearranged in the GUI, if necessary. There is no other way, apart
from a complete redesign of the listings inset, of course. However,
I think that this is an acceptable compromise.
2017-06-17 02:23:00 +02:00
Jean-Marc Lasgouttes
62b06c64ed Use the same code for editable and non-editable buttons
This removes the use of rectText in RenderButton. The fact that this
gave different spacing than buttonText was a problem.

Now buttonText requires to specify
* the offset, so that INSET_TO_TEXT_OFFSET is not used anymore in
  src/frontends/, which will be useful later.
* the background and frame color, in replacement for the hover state.

Remove the methods button() and buttonFrame() from GuiPainter.

Remove some unused header files.

Fixes bug #10704.
2017-06-15 15:40:30 +02:00
Juergen Spitzmueller
530fec453f Also catch "! Incomplete \\if" 2017-06-15 15:29:40 +02:00
Juergen Spitzmueller
39f23ac66b Catch "! Incomplete \\ifx" error
Fixes: #10666
2017-06-15 15:07:03 +02:00
Jean-Marc Lasgouttes
522516d99e Make fixIfBroken() more robust
Chop slice when its inset is not editable.

Fixes bug #10667.
2017-06-15 11:53:33 +02:00
Jean-Marc Lasgouttes
9c92494e1a Avoid memory reuse problems with inset-dissolve
If
 1. the inset is deleted before pasting its contents in the outer text, and
 2. the inset contents begins with an inset, and
 3. the clone of this inner inset is allocated at the memory location just
    made free,
then bad things can happen.

To avoid this, we delete the inset only after its contents has been pasted.

Fixes bug #10667.
2017-06-15 11:53:33 +02:00
Jean-Marc Lasgouttes
939962869b Give 4 edit markers to all Frac-like insets
Part of bug #10688.
2017-06-14 15:38:47 +02:00
Jean-Marc Lasgouttes
2e84b8030e When entering an inset by cursor, reset boundary
This happesn when cursor-left/right enters an inset.

Fixes bug #10630.
2017-06-14 15:08:27 +02:00
Jean-Marc Lasgouttes
cc7917c55c Add lower corners for BOX_MARKER too
Let's see whether this helps Guillaume.

Part of bug #8883.
2017-06-13 12:18:26 +02:00
Enrico Forestieri
c86f9d81e7 Avoid a crash if an external template is not installed 2017-06-12 21:24:52 +02:00
Jean-Marc Lasgouttes
5d7dae9e38 Set cursor properly after double/triple click in mathed
Without this setCurrentFont() is not correctly called on the
BufferView cursor and the cursor could appear in L-form.

Fixes bug #10686.
2017-06-12 18:02:39 +02:00
Enrico Forestieri
ae56167718 Use a combo box instead of a check box for selecting the listings package 2017-06-12 17:24:26 +02:00
Jean-Marc Lasgouttes
95c6781112 Improvements to inset edit markers
Draw also upper markers when editing macros in MACRO_EDIT_INLINE_BOX mode.

Use MARKER2 for inline editing of macros.
2017-06-12 17:09:58 +02:00
Jean-Marc Lasgouttes
f6b0ccf99c Use proper markers for display version of the math macro template.
This avoids ghost white corners when the macro does not have a display
version.

Part of bug #8883.
2017-06-12 15:15:55 +02:00
Jean-Marc Lasgouttes
71563835c7 Avoid rounding issue when painting selection
This is the same issue that was addressed in the all_sel case at
695b0cc3. The rounding issue only happens at specific zoom and
jusification values.

Fixes part of #8883.
2017-06-12 14:39:03 +02:00
Jean-Marc Lasgouttes
c9fefd5a2c Fix bad cursor positioning when entering an inset
The test added at 359aef92 was incorrect. Actually, Inset::editXY
returns the inset when it is edited and also when it is not, which
can be confusing. So if we are unlucky and the slices positions in the
text area and in the inner inset match, the code below triggers and
many bad things can happen.

Also improve the documentation of Inset::editXY and TextMetrics::editXY.

Fixes #10691.
2017-06-12 13:51:24 +02:00
Enrico Forestieri
887445537a Switch parameters validation even before applying the changes
In the document settings allow to immediately switch from one
package to the other for parameters validation without the need
of first applying the changes.
2017-06-12 11:54:59 +02:00
Guillaume MM
5fda4e85c7 Unhide buffers that are marked dirty as a result of external modifications
Several comments in the code point to the fact that hidden buffers are assumed
to be clean.

The other solution was to adapt the closing & saving code to take into account
hidden dirty buffers. Experience shows that it is more useful to unhide the
buffers at the moment of the external modification, in the context of a git
workflow where one has to reload the modified children buffers one-by-one.

Fixes crash at #10603
2017-06-11 19:51:17 +02:00
Guillaume MM
fd6189b7e3 Remove FileMonitorBlocker which does not work reliably on all platforms 2017-06-11 19:51:17 +02:00
Guillaume MM
b30161b591 If the external modification is a deletion, do not ask for reloading.
The behavour when hitting "reload" on a deleted file was also confusing.
2017-06-11 19:51:17 +02:00
Guillaume MM
2058faaa3b Prevent false positives in external modifications
When the Buffer is notified to be externally modified, check that the
file contents have changed using the checksum.

Document the shortcoming of FileMonitorBlocker.

Fixes #10642.
2017-06-11 19:51:17 +02:00
Guillaume MM
db58111360 Properly track the lifetime of signals2::slots (#8261)
Starting at 61b2bd5e, boost::bind was progressively replaced with
std::bind. They are not interchangeable though. boost::bind implements
the tracking of boost::signals{,2}::trackable objects. Now that
std::bind has completely replaced boost::bind, tracking never occurred.

This commit replaces boost::signals2::trackable with the new preferred
boost::signals2 methods: scoped_connections or slot::track_foreign. The
support::Trackable class introduced is less safe but easier for transitioning
old code.

Fixes the crash at #8261.
2017-06-11 19:51:17 +02:00
Enrico Forestieri
3f61375bc3 Adjust minted options
- Remove "chapter" and "section" as this are to be passed as class
  options and are otherwise not recognized.

- Let onoff=false for all TRUEFALSE parameters, otherwise only the
  form option=true is accepted and option=false does not validate,
  generating a lot of confusion.
2017-06-11 17:51:24 +02:00
Enrico Forestieri
55223bdcaa Add accelerator 2017-06-11 13:58:34 +02:00
Enrico Forestieri
405d71c172 Unify translations
This entry is shared by both listings and minted, so no need to use
different strings.
2017-06-11 12:34:17 +02:00
Guillaume MM
48a73a9e05 Make a string translatable 2017-06-11 06:01:04 +02:00
Guillaume MM
40cfede2bf Clearer message when about to discard an unsaved document entirely. 2017-06-11 06:01:04 +02:00
Enrico Forestieri
6f12fe596c Quote backspace in string 2017-06-10 23:12:49 +02:00
Enrico Forestieri
c5c480bb3c Was forgetting to add the caption to the list of listings 2017-06-10 21:00:43 +02:00
Enrico Forestieri
3dfa1cb417 Allow captions also on non-floating minted listings
Minted provides for captions only with floating listings. However,
listings always allows captions, and our machinery is geared accordingly.
So, instead of discriminating the floating and non-floating cases,
always allow for captions with minted, too. When minted does not provide
for a caption, we will provide one.
In the child document case the caption will always be before the listing,
while for the inset case the caption will be before the listing if it
is entered as the first line, after the listing otherwise.
2017-06-10 18:43:23 +02:00
Juergen Spitzmueller
f34f0c1db4 Oops: currentData() is Qt 5 only. 2017-06-10 18:17:43 +02:00
Juergen Spitzmueller
5685080356 Correct restoration of citation style selection between engine switches
We stored the combo position index, but this changes on engine switch.

This also fixes a crash due to out-of-bound index at engine switch.

Fixes: #10692
2017-06-10 14:29:07 +02:00
Enrico Forestieri
ca2d972a36 Amend fd075614
Actually, only when using minted it is not possible to insert a
caption in a non-floating listing.
2017-06-09 12:37:05 +02:00
Jean-Marc Lasgouttes
183c97d8a8 Give a 2 pixels space for markers around math objects
This is necessary when markers are nested. Ideally this should only be
done when there is risk of nesting.

Fixes (part of?) bug #10688.
2017-06-09 11:58:26 +02:00
Enrico Forestieri
8fa0e539e5 Extend minted support to listings as child documents
This was slipping through the cracks, apparently...
2017-06-08 19:35:48 +02:00
Jean-Marc Lasgouttes
cb5464ea2b Revert "Fix drawing of collpsable insets"
This was definitely not meant to be pushed, especially since I
reverted it recently. Sorry folks.

This reverts commit 6fc72a1a1f.
2017-06-08 16:47:26 +02:00
Jean-Marc Lasgouttes
a33b633111 Revert "Fix bad cursor positioning when entering an inset"
This is not ready yet.

This reverts commit 7ca7873112.
2017-06-08 16:46:49 +02:00
Jean-Marc Lasgouttes
1538a8352c Revert "Give a 2 pixels space for markers around math objects"
This is not ready yet.

This reverts commit 5a3962958f.
2017-06-08 16:46:19 +02:00
Jean-Marc Lasgouttes
29fbd062cc Properly use top/bottom edit marker for grid inset
This was an oversight when marker() was introduced.

Fixes part of #10688.
2017-06-08 16:03:14 +02:00
Jean-Marc Lasgouttes
5a3962958f Give a 2 pixels space for markers around math objects 2017-06-08 15:22:03 +02:00
Jean-Marc Lasgouttes
7ca7873112 Fix bad cursor positioning when entering an inset
The test added at 359aef92 was incorrect. Actually, Inset::editXY
returns the inset when it is edited and also when it is not, which
can be confusing. So if we are unlucky and the slices positions in the
text area and in the inner inset match, the code below triggers and
many bad things can happen.

editXY() should probably have a documented way to indicate whether the
cursor has entered the inset, although the test used right now is
probably OK. The inset value is useful mainly for context menus or
tasks that need to know which inset the (x, y) coordinates
point to.

Note finally that the documentation of TextMetrics::editXY is
incorrect concerning the return value. It will return a non-null value
if the cursor is on a not editable inset.

Fixes #10691.
2017-06-08 13:48:51 +02:00
Jean-Marc Lasgouttes
6fc72a1a1f Fix drawing of collpsable insets
This is a follow-up to e194c9ce. There was actually no reason to let
InsetCollapsable and InsetText draw their own background. It is more
correct to remove the existing code and let the generic
Inset::drawBackground take command.

This allows to revert d207e85c.

Fixes bug #10587.
2017-06-08 10:11:27 +02:00
Enrico Forestieri
3cc3ff39a0 Simplify preamble code when using listings
Following an idea from Guillame.
2017-06-08 04:25:53 +02:00
Enrico Forestieri
fd0756141c Don't allow captions in non-floating listings
It was possible to insert a caption in a listing not marked as
floating. This didn't cause errors but the caption simply was
disappearing in the output.
2017-06-07 18:15:59 +02:00
Jean-Marc Lasgouttes
48144c474b Revert "Fix drawing of collpsable insets"
This patch cuses unintended issues (see #10587).

This reverts commit 18fb9cd7f9.
2017-06-07 16:01:58 +02:00
Enrico Forestieri
aae04d25b9 Fix a small glitch
When choosing a code language that has dialects in the languages
combo box, the dialects combo gets activated also when minted is
in use. However, minted does not support the concept of dialects
and the combo should not be enabled. This is harmless because the
dialects are simply ignored and the dialects status is restored
after apply, but it may fool the user in thinking that a dialect
can be actually selected. So, always disable it with minted.
2017-06-07 15:31:13 +02:00
Jean-Marc Lasgouttes
18fb9cd7f9 Fix drawing of collpsable insets
This is a follow-up to e194c9ce. There was actually no reason to let
InsetCollapsable and InsetText draw their own background. It is more
correct to remove the existing code and let the generic
Inset::drawBackground take command.

This allows to revert d207e85c.

Fixes bug #10587.
2017-06-07 12:20:33 +02:00
Jean-Marc Lasgouttes
a98df58537 Fix warning about signed/unsigned 2017-06-07 11:05:29 +02:00
Jean-Marc Lasgouttes
83cd3f4293 Output default mathindent value as "default"
This is like parindent now. The old code would avoid outputing the
value when it was empty (default indentation).

Fixes bug #10657.
2017-06-07 10:53:37 +02:00
Enrico Forestieri
8dab1cfe7e Fix bug #9101
Update the listings inset to optionally use the minted package
(instead of the listings one) for typesetting code listings.
Only one of the two packages can be used in a document, but it
is possible to switch packages without issues if the used options
are the same. If a switch is made and the options differ, one needs
to manually adjust them if they were entered in the advanced options
tab, or apply again the gui settings.
Note that minted requires the -shell-escape option for the latex
backend and the installation of additional software (python pygments).
2017-06-07 00:55:23 +02:00
Richard Heck
f9835d054d Fix bug #10295.
As it was, the comparison buffer was sharing a DocumentClass with
the buffer from which the document settings are taken.
2017-06-04 18:30:55 -04:00
Scott Kostyshak
b1ddae0514 Fix border when inserting column (#10538, #9306)
When inserting a column in tabular, the border of the new column
should be copied from the border of the (previously) right-most
column.

Also remove a redundant line. The line

    setRightLine(i, true);

was only reached if rightLine(i) was true.

Patch from Daniel Ramöller.
2017-06-04 15:24:10 -04:00
Enrico Forestieri
8ae652eb16 Fix up 0cf394dd 2017-06-04 03:28:49 +02:00
Enrico Forestieri
71f532db4b Do not output a \par inside a local language switch command 2017-06-04 03:14:14 +02:00
Enrico Forestieri
55bbd67cde Fix bugs #10650 and #9598 2017-06-03 17:26:05 +02:00
Enrico Forestieri
2a5bb7ab67 Fix bug #10685
Make sure to properly nest \begin{lang} and \end{lang} tags even
when no language package is selected. In this case, LyX assumes
that babel is being used, so the language names might be wrong
if the user arranged for using polyglossia in the preamble.
Nevertheless, we assure that the produced output is syntactically
correct, so that by adding proper preamble code a correct output
is still possible.
2017-05-30 17:57:37 +02:00
Richard Heck
60bd141f1b Keep track of the last manually set state of the literal
checkbox in the citation dialog. Use that information to
set it appropriately for new citations.
2017-05-29 22:53:11 -04:00
Enrico Forestieri
90c423a646 Revert a gratuitous change
This commit reverts a change made at 3bc08a76 that was causing
changed output. See:
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg200509.html
2017-05-29 23:22:14 +02:00
Enrico Forestieri
2dde90a8fe Revert 3ceb5034
This does not work when the footnote contains multiple paragraphs
and the font properties are changed outside the inset.
2017-05-25 19:09:50 +02:00
Guillaume MM
6d6a4d7e75 Fix coverity warning 2017-05-25 16:41:10 +02:00
Jean-Marc Lasgouttes
91f3b21e42 Take in account end of paragraph marker for inset width
When an inset wants to use the whole available width, it is necessary
to take into account that some of this width may already be taken by
the end-of-paragraph (pilcrow) marker.

Fixes bug #10537.
2017-05-24 14:05:06 +02:00
Jean-Marc Lasgouttes
b58dcff836 Let command inset honor inheritFont() on screen
The RenderButton object now has a inherit_font_ property. It is set
depending on the value of Inset::inheritFont().

This is a better fix than 55533804, which caused bugs #10682 and #10677.

Fixes bug #10258
2017-05-24 11:33:52 +02:00
Jean-Marc Lasgouttes
3f34ebbaf9 Revert "Add possibility for command inset to inherit enclosing font"
The new method was badly named, it was not supposed to override the
existing inheritFont.

Fixes bug #10682.

This reverts commit 555338048d.
2017-05-24 11:25:14 +02:00
Jean-Marc Lasgouttes
0516af0c99 Revert "InsetHyperlink: inherit font (#10677)"
This will be replaced with a better fix (see #10682).

This reverts commit c643da99d7.
2017-05-24 11:25:14 +02:00
Enrico Forestieri
3ceb503490 Fix bug #10263 2017-05-24 00:24:54 +02:00
Scott Kostyshak
c643da99d7 InsetHyperlink: inherit font (#10677)
This commit amends 55533804.
2017-05-19 05:23:28 -04:00
Enrico Forestieri
922d1ddc8c Fix bug #10469 2017-05-17 22:31:27 +02:00
Enrico Forestieri
ead148510b Amend bfe0d52e
Was forgetting to account for babel.
2017-05-16 22:02:42 +02:00
Enrico Forestieri
bfe0d52e97 Fix bug #10636
The code was not accounting for partial preview of the source code
and was trying to pop a language that was never pushed.
2017-05-16 20:20:32 +02:00
Guillaume MM
f365a65068 Fix the computation of broken InsetRef status between sibling documents 2017-05-16 12:15:27 +02:00
Guillaume MM
d7bcab5e27 Structure the broken InsetRef status 2017-05-16 12:15:27 +02:00
Guillaume MM
161f7b7f62 Improve wording (#10670) 2017-05-16 00:28:43 +02:00
Jean-Marc Lasgouttes
676ce147da Fix compilation failure 2017-05-15 10:29:09 +02:00
Jean-Marc Lasgouttes
5354c64b27 Cache QTextLayout objects with Qt/Mac
It seems that the internal Qt5 caching does not work well here,
especially in the case of Herbrew documents.
2017-05-15 10:14:42 +02:00
Guillaume MM
700225c26f Fix colours of buttons in notification frame 2017-05-15 02:28:48 +02:00
Guillaume MM
752a0a1e48 Correct debug message 2017-05-15 02:28:48 +02:00
Uwe Stöhr
0dd3311dd4 rename buffer parameter math_number_before to math_numbering_side
this is a fileformat change

also try to fix an UI issue that JMarc gets
2017-05-13 20:39:45 +02:00
Guillaume MM
1fb0a5f436 Fix computation of InsetLayout arguments for InsetText
Do not take the optional arguments from the first paragraph, but from the
paragraphs whose layout have no arguments, consistently with the code in
InsetArgument::updateBuffer (i.e. what was shown on screen).
2017-05-13 16:12:25 +02:00
Guillaume MM
ef19e114bd Clean-up before following bugfix
Add helper function and factor code
2017-05-13 16:12:25 +02:00
Guillaume MM
1ac48c7cba Simplify before clean-up before following bugfix 2017-05-13 16:12:25 +02:00
Guillaume MM
c76cbead59 Cosmetic 2017-05-13 16:12:25 +02:00
Jean-Marc Lasgouttes
f1dd80f464 Proper GUI feedback for leqno option
With these changes, equation numbers are shown properly on screen.
When setting is default, we guess the side using these two rules

* ams(art|book) and siamltex classes are leqno by default. This is
  signalled because the classes provide "leqno" (in amsdefs.inc). If
  there are other classes that do this in output, the relevant classes
  should be updated.

* the language arabic_arabi also sets leqno by default. This is
  currently hardcoded for lack of a better idea.

Besides, a few bugs are fixed:
* use mathrm instead of mathbf for numbers metrics
* set spacing between maths and labels in inches
2017-05-12 15:32:14 +02:00
Jean-Marc Lasgouttes
d4685f2806 Never, never use a string for something that has 3 values
This commit replaces the string math_number_before by a proper math_number enum.

Note that the _before naming was misleading. It was chosen at a time
when we were not sure whether leqno was always left or could be right
in RtL documents.

Note that the token in LyX document is still \math_number_before and
this should be changed.

Fixup for 19cc4a1f.
2017-05-12 12:00:43 +02:00
Uwe Stöhr
19cc4a1fcb GuiDocument: support also the class option reqno
as discussed our support for the formula numbering side should be complete. There are document classes that uses left numbering as default and with the class option "reqno" this can be changed to right numbering. reqno requires the loading of amsamth.
2017-05-12 01:06:05 +02:00
Günter Milde
ff6369d35e Fix fa0f142e (plain quotes fix).
Forgot the "break", sorry.
2017-05-11 21:41:12 +02:00
Günter Milde
fa0f142eee Fix #10583 - plain quote inset latex export in different font encodings.
Since [e68afbe671394a/lyxgit], plain quotes came out wrong if the document
contains text parts in languages setting a different font encoding.
2017-05-11 18:08:46 +02:00
Guillaume MM
5452c53e9b algorithm2e.module: Add Algorithm style to typeset algorithms
Do not output \begin and \end if there is not environment name. We only need the
nesting feature.
2017-05-10 00:03:04 +02:00
Guillaume MM
98bd27c0bf InTitle: ignore InPreamble styles for outputting \maketitle. 2017-05-09 23:38:55 +02:00
Guillaume MM
f3594cb3eb Smarter Ctrl+{Left,Right} in math.
Consider mathbin, mathrel and mathpunct as word separators. This makes
Ctrl+{Left,Right} more intuitive, quicker, and more different from {Left,Right}.

This takes into account all the feedback from the discussion on the general
list. Further feedback welcome.
2017-05-09 23:28:32 +02:00
Uwe Stöhr
f109206c05 GuiDocument: rename a function to follow the naming guideline 2017-05-09 21:02:03 +02:00
Jean-Marc Lasgouttes
4bbcc4c563 Change ordering of function codes
Fixup e575e7ee so that func code numbers are still correct.
2017-05-09 16:28:40 +02:00
Scott Kostyshak
638020ab10 Revert "Change default working directory from ~/ to ".""
Setting the default working directory to '.' is an invasive change
on Mac and Windows, where the current working directory of LyX when
LyX is started from the GUI is not a reasonable choice for the
default directory in e.g. the "save as" file dialog or the "open"
dialog. A similar situation could happen on Linux distributions (I'm
not aware of any, e.g., POSIX standard that defines that the working
directory of a binary started from GUI should be the home
directory). Thus, it is not clear this default is good on any
platform.

If the user wishes to have the behavior of '.', the description in
the "paths" preferences pane provides the information for making the
change.

For more information, see the discussion at:

  https://www.mail-archive.com/search?l=mid&q=635298DE-5028-4BB1-8D8F-A634BA68C420%40gmx.net

This reverts commit 892593fbdc.
2017-05-09 07:50:45 -04:00
Uwe Stöhr
902b5f368b GuiDocument: fix bug #10653
- also rename a function because we have the same function name in BufferParams
2017-05-09 01:00:36 +02:00
Uwe Stöhr
74f56e261a Color.cpp: fix bug #10656 2017-05-09 00:09:10 +02:00
Guillaume MM
1acb42911a Cosmetic 2017-05-07 14:18:17 +02:00
Daniel Ramöller
e2f864efe4 Lock toolbars (#10283)
- LFUNs to (un)lock toolbars positions (both individually and all at once)

- corresponding menu entry to "Lock Toolbars" menu.
2017-05-07 14:17:54 +02:00
Daniel Ramöller
4183a9f4dc Preferences shows current zoom instead of preference's default zoom (#10455)
- Adds a currentZoom variable which holds the current zoom level.

- The zoom stored in preferences is used as default zoom level (default binding:
  M+0).

- The currentZoom is saved and restored via QSettings.

- Adds LFUN buffer-zoom for (re)setting zoom.
2017-05-07 14:17:54 +02:00
Daniel Ramöller
9bf8ac4432 Color Preferences: Disable colors rather than hide them (#10483) 2017-05-07 14:17:54 +02:00