Commit Graph

294 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
282fe102f3 Fix getStatus for math-mutate and math-display
Those two functions used two different hackish and buggy
implementation to know when the function is disabled. Replace that by
asking the containing inset whether it accepts inserting display math
inset.

Fixes bug #10033.
2016-05-29 17:55:45 -04:00
Guillaume Munch
9a09fe38bd getInnerText() 2016-05-29 17:55:42 -04:00
Jean-Marc Lasgouttes
d48d426c72 Rename InsetMathHull::isTable to allowsTabularFeatures
The old name conflicted with the newly introduced Inset::isTable.

Now the meaning is as follows.
* Inset::isTable() is true when the inset is composed of lines and columns
* InsetMathHull::allowsTabularFeatures is true when the current type of hull allows for tabular-like functions.
2016-05-29 17:55:42 -04:00
Guillaume Munch
935588f2de Sanitize InsetMathHull and add a check for mutability in LFUN_MATH_MUTATE
Remove in particular all comparisons < and >= involving HullType.

Add a guard to make sure that mutate() only operates on types it has been
designed for. Then I figured I could use this new knowledge to give feedback
when math-mutate is not implemented via getStatus(). (To test this, insert a
regexp in Advanced Search & Replace and try to change it into a standard
equation via the contextual menu.)
2016-05-28 17:42:31 -04:00
Guillaume Munch
d4b56646b4 Fix the display of column spacing in AMS environments
AMS align environment should have some spacing between odd and even columns.

Add a new virtual method displayColSpace() to InsetMathGrid, InsetMathHull and
InsetMathSplit.
2016-05-28 17:42:31 -04:00
Guillaume Munch
f3b70fd2cd Display the correct horizontal alignment in AMS environments
A longstanding problem... (related: #1861)

The columns in AMS math environments have a fixed alignment (colAlign() in
InsetMathGrid.cpp). We set this alignment for display (Georg's
displayColAlign()) in InsetMathHull and InsetMathSplit. This is done according
to tests and documentation for the various environments.

There is also some mechanical code factoring via colAlign().

Finally, I disable setting the horizontal alignment in InsetMathSplit, which has
no impact on the LaTeX output, and has no longer any impact on the screen. (As
for vertical alignment I discovered that it was in fact customisable for
\aligned & friends! I hope that the more faithful interface will let other
users discover that too.)
2016-05-28 17:42:31 -04:00
Jean-Marc Lasgouttes
2804011957 Get rid of use_preview_ in various insets
This concerns InsetPreview, InsetIPA and InsetMathHull.

Caching such a value is bad when opening the same buffer in two views.
In this case, it is not necessary to remember use_preview_ at all,
actually.

Also remove private member dim_ which is not used and remove some trailing whitespace.

Fixes bugs #9085 abd #9957.
2016-02-09 09:54:14 +01:00
Guillaume Munch
2c08848700 Let tabular-feature commands fall through non-table math insets. (#4189) 2016-01-27 18:36:07 +01:00
Guillaume Munch
c9f7ce0a7a New LFUN tabular-feature (#9794)
The tabular-features LFUN was merged with "inset-modify tabular" when
simplifying the tabular dialog at b5049e7. This choice later indirectly caused a
few regressions (#7308, #9794).

I reintroduce tabular-feature to allow more flexibility for user
commands, whereas "inset-modify tabular" is now reserved for the tabular
dialog. In particular, inset-modify tabular is no longer caught by math grid
insets. The name tabular-feature is kept to avoid renaming icons.

Known issues:

* After successfully applying a tabular command, the cursor is truncated to the
  table.

* Note that the tabular dialog still has similar issues that are inherited from
  the achitecture of the dialog menu. For instance the pref change can be
  mis-dispatched to an inset inside a cell and cause an error, for instance:

    Lexer.cpp (934): Missing 'Note'-tag in InsetNote::string2params. Got
    tabular instead. Line: 0

  Maybe the inset-modify LFUN should be modified to treat commands coming from
  the wrong dialog (by checking the type) as unknown and undispatched so that
  the parent can get it. In that case a non AtPoint variant of inset-modify
  could be reintroduced in order to generalise tabular-feature. See:
  http://mid.gmane.org/n4rdk1$efj$1@ger.gmane.org
2016-01-27 18:20:37 +01:00
Uwe Stöhr
764a2163bb Revert "Revert "Fix the display of column spacing in AMS environments""
This reverts commit f1a388584f.

# Conflicts:
#	src/mathed/InsetMathGrid.cpp
#	src/mathed/InsetMathSplit.cpp
2016-01-19 23:20:53 +01:00
Uwe Stöhr
641a1cc1a2 Revert "Fix the display of column spacing in AMS environments"
This reverts commit 1676b69cf7.
2016-01-19 23:01:44 +01:00
Guillaume Munch
1676b69cf7 Fix the display of column spacing in AMS environments
AMS align environment should have some spacing between odd and even columns.

Add a new virtual method displayColSpace() to InsetMathGrid, InsetMathHull and
InsetMathSplit.
2016-01-19 22:45:04 +01:00
Uwe Stöhr
f1a388584f Revert "Fix the display of column spacing in AMS environments"
I have no clue why this was automatically committed, I just applied the path, nothing more.

This reverts commit bb5470b5d1.

# Conflicts:
#	src/mathed/InsetMathGrid.cpp
#	src/mathed/InsetMathSplit.cpp
2016-01-19 22:35:24 +01:00
Guillaume Munch
bb5470b5d1 Fix the display of column spacing in AMS environments
AMS align environment should have some spacing between odd and even columns.

Add a new virtual method displayColSpace() to InsetMathGrid, InsetMathHull and
InsetMathSplit.
2016-01-19 22:22:23 +01:00
Guillaume Munch
0b733507da Display the correct horizontal alignment in AMS environments
A longstanding problem... (related: #1861)

The columns in AMS math environments have a fixed alignment (colAlign() in
InsetMathGrid.cpp). We set this alignment for display (Georg's
displayColAlign()) in InsetMathHull and InsetMathSplit. This is done according
to tests and documentation for the various environments.

There is also some mechanical code factoring via colAlign().

Finally, I disable setting the horizontal alignment in InsetMathSplit, which has
no impact on the LaTeX output, and has no longer any impact on the screen. (As
for vertical alignment I discovered that it was in fact customisable for
\aligned & friends! I hope that the more faithful interface will let other
users discover that too.)
2016-01-19 22:22:22 +01:00
Guillaume Munch
87861bc6d5 Use AMS align instead of eqnarray on newline-insert by default (#2543) 2015-12-11 19:28:32 +00:00
Guillaume Munch
789745df7a TexRow info in source panel and gotoCursor() for debugging
These features are active in DEVEL_VERSION when Debug is set to LATEX.

1. The TexRow information is prepended to the source panel.

2. Clicking on any line in the source triggers reverse search. (This would be an
interesting feature to implement on the user side, but we need a proper LFUN.)
2015-10-19 06:55:17 +01:00
Guillaume Munch
460a764b7f Adding TexRow information on math latex output (#4725)
WriteStream is now built from an otexstream instead of an odocstream, and
therefore counts lines in a TexRow. Calls to TexRow are added in relevant places
in math insets.

This finishes adding line tracking for math in the source panel and for forward
search.
2015-10-19 06:55:17 +01:00
Guillaume Munch
bb344452c8 Consistency of ellipses across the UI
Use the function support:truncateWithEllipsis() to shorten a docstring with
... at the end. Actually we use U+2026 HORIZONTAL ELLIPSIS instead of "..." when
automatically shortening strings. This is to be consistent with Qt's own
truncation and is much nicer on the screen.

This includes the bugs #9575 and #9572 regarding broken text elision in the
outliner.

Known issues (non-regressions):

* TocBackend::updateItem() should be rewritten to update all TOCs. (#8386)

* "..." should be replaced with … everywhere else on the interface (including
  translation strings).

* We should prefer to rely on QFontMetrics::elidedText() to truncate strings
  with an ellipsis whenever possible, or an equivalent for the buffer view
  dependent on the font metrics. See the warning in src/support/lstrings.h.
2015-10-05 21:16:16 +01:00
Enrico Forestieri
8a909b0fa3 Fix #9726: Preview does not have correct font size 2015-10-03 18:13:20 +02:00
Guillaume Munch
d5a5fbb8ee Enhancements and bugfixes to the TOCs
* New TOC "math-macro". This means that math macros can now be accessed in the
  outline pane in their order of appearance or in alphabetical order, and can be
  searched using the filter.

* Lists of floats now show subfloats deeper in the navigation menu

* The arbitrary 30 element cut-off after which nothing is shown except "Open
  Navigator..." is removed. Menus now have no limit in size, so Qt may display
  them scrollable. In exchange, we always show "Open outliner..." at the
  beginning. I tested for performance issues with a rather complex document and
  it is fine; but this does not exclude corner cases with lots of TOC entries of
  a certain kind. If necessary, populating the navigation sub-menu should be
  delayed like the main menu.

* Elements that do not contribute to the output (e.g. in a note, a disabled
  branch) are now preceded with a symbol indicating this status. (The machinery
  was already there; I wonder why it was not implemented already.) I have chosen
  U+274E NEGATIVE SQUARED CROSS MARK.

* Fix the contextual menus in the outliner (bug introduced at 94e992c5).

* Toc item now move to the caption when present, but first center on the float,
  to prevent the situation where the caption is at the top of the screen and the
  contents of the float is off-screen above the caption.
  (Internally, the action of the toc items can now be customised)

* Fix the LyXHTML output. Disabled captions no longer appear in the list of
  figures.
2015-10-01 21:44:22 +01:00
Guillaume Munch
94e992c5ed Better construction of the TOC for floats and captions
We introduce TocBuilder for building TOCs that take into account both float
insets and their captions.

* Floats without caption are shown with their content.

* Floats with a caption are shown with their caption, but clicking the entry now
  correctly moves to the float and not to the caption.

* Subsequent captions produce additional entries in the TOC.

* Figures and subfigures are correctly ordered in the outliner.

* New TOC "senseless" for captions appearing alone (a bit like broken references
are still displayed in the menu and outliner).

* Disable LFUN_CAPTION_INSERT if there is already a caption in a listing

Known issues:

* Inconsistent output for includes located inside floats

* We should record the end of the float in addition of the beginning for a more
  accurate cursor -> outliner entry conversion
2015-09-15 15:25:33 +01:00
Jean-Marc Lasgouttes
7d018853fc Position better the cursor after math-display
When the cursor had idx > 0 (since math-display does merging anyways),
reset cursor to the start of the inset. This looks less strange than
setting it at the end.

Now at least the basic case of a displayed equation with cursor
somewhere at top-level is handled correctly.

The math-display lfun operates at top level in the math inset.
Therefore, when the cursor is in an inner inset, it will after the
lfun be moved at top level. Unfortunately, there is no way that I know
f to detect this in Inset::doDispatch.

Even if we could, as things stand, it is difficult to keep the cursor in the
inner inset, especially if the inner inset moves : this happens for
example when moving from eqnarray to inline maths.

Therefore this fix is the best I can think of now.

Fixes part of bug #9664.
2015-07-09 12:00:25 +02:00
Enrico Forestieri
cabc7c4be1 Fix another couple of issues spotted by Guillaume
* Take into account macro redefinitions in the legacy route
* Take into account macros inside nested macro definitions
2015-06-20 16:37:12 +02:00
Enrico Forestieri
b610c13f67 Amend 98a5072a
We only look once for the definition of the same macro, but we have
to always check its arguments when the same macro appears more than
once in a math inset. So, move earlier this check.
2015-06-20 03:05:50 +02:00
Enrico Forestieri
98a5072a58 Fix a couple of issues with macros and previews
* Fix typo causing to only account for the first char of a macro name
* Also check for macros as arguments of other macros
2015-06-20 01:44:22 +02:00
Enrico Forestieri
11c2b7792c Replacement for commits bc47054b and ad0d0f6d
The strategy adopted in bc47054b had some drawbacks related to the way
instant preview snippets are generated. See the subthread starting at
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg187916.html
for details.

The strategy adopted in this commit is that of adding macro definitions
only for the macros actually used in a preview snippet, independently
of whether some macro was already used in a previous snippet. In this way
the snippets don't need to be changed according to whether they are
compiled as a whole or separately from each other. This fact was causing
the regeneration of a preview snippet whenever the cursor entered the
corresponding inset, even if the generated image would have not changed.
The problem of defining or redefining a macro is taken care by the
python scripts.
2015-06-14 18:10:29 +02:00
Enrico Forestieri
bdec44d614 Revert bc47054b and the related commit ad0d0f6d
As discussed on the devel list. See the subthread starting at
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg187916.html
Soon to be replaced with the same strategy adopted in the stable branch.
2015-06-14 18:05:39 +02:00
Juergen Spitzmueller
83a9ed4e62 Fix remaining preview issue with math macros (#6369) 2015-06-01 10:29:48 +02:00
Georg Baum
84cca2dd94 Fix indentation 2015-05-17 17:27:27 +02:00
Georg Baum
39329935f3 Parse \multicolumn in math (bug 396)
The math parser could not handle multicolumn grids. This is a problem because
there is no true ERT in math (everything is parsed).
Now multicolumn cells are parsed correctly. The display is also somewhat OK,
but apart from that any multicolumn related UI is missing. Since the file
format change is now done the UI can be added at any later point. The most
important part of bug 396 is now fixed: tex2lyx does not create invalid .lyx
files anymore for formulas containing \multicolumn.

I updated the tex2lyx test cases that produce correct output. tex2lyx does
still produce invalid output for the test cases which are not updated because
of the previous format change.
2015-05-17 13:43:37 +02:00
Juergen Spitzmueller
bc47054be8 Properly fix #6369
Avoid that \newcommand[x] definitions of math macros are pushed multiple
times to the preview loader.

Redefinitions (via \renewcommand[x]) are properly handled.
2015-04-30 16:48:55 +02:00
Jean-Marc Lasgouttes
af4548cd6b Toggle properly the math-display icon 2015-04-16 18:51:29 +02:00
Uwe Stöhr
ff85a4902e mathed: bformat infoize messages
- should fix bug #1908
2014-11-14 18:18:30 +01:00
Enrico Forestieri
29cebc7fb0 Fix CAS computation of a selected subformula.
Invoking a computer algebra system program for computing a selected
subformula has never worked (checked with all LyX versions back to 1.3)
and, moreover, in the presence of a selection things go awry.
This commit allows this computation by replacing the selected
subformula with the result of the computation.
2014-11-09 21:57:29 +01:00
Enrico Forestieri
9f613a5f7e Fix issue with CAS.
See http://thread.gmane.org/gmane.editors.lyx.devel/153516
This regression was due to a thinko in [43f6b167/lyxgit].
2014-11-09 02:19:00 +01:00
Scott Kostyshak
3b96c6e901 Remove line in text export of inline math (#9282)
If there is only one row, a new line should not be appended. If
there is more than one row, the new line should not be appended for
the last row.

For example, if in LyX there was "as you can see in $x$ there..." a
copy/paste would lead to a newline after "x".
2014-10-15 19:18:46 -04:00
Alfredo Braunstein
866fc2afcc mathed/InsetMathHull.cpp (InsetMathHull::doDispatch): do not declare LFUN_FINISHED_* lfuns as undispatched after handling them
Fixes #9289, and an unreported cousin of #3900
2014-10-12 11:07:28 +02:00
Georg Baum
4cea2efe21 Native support for \notag
This is mainly needed to reduce the amount of ERT if you convert AMS example
documents with tex2lyx. No GUI support is needed, since \notag is equivalent
to \nonumber.
2014-05-27 22:17:35 +02:00
Jean-Marc Lasgouttes
275b7af75e Code cleanup: get rid of RenderPreview::status()
This method is a proxy for LyXRC::preview that forces to forward
declare some wrapper around an enum...

Instead, two simple static methods previewMath() and previewText() are
introduced, that make the code much easier to follow.
2014-05-20 12:19:26 +02:00
Enrico Forestieri
3e681bea4f Fix problem with drawing of math backround with selections. 2014-05-07 14:18:14 -04:00
Richard Heck
065db68067 Fix a bunch of minor issues discovered by the cppcheck script. 2014-04-21 11:52:00 -04:00
Richard Heck
8b00b355ca Change forToc() to forOutliner(), to avoid confusion. The old name
is left over from when the outliner really did just display a TOC.
2014-04-21 11:51:59 -04:00
Richard Heck
7765b1c9a8 Draw a small red frame around preview images that are too small. 2014-04-21 11:51:57 -04:00
Georg Baum
bd79001387 whitespace 2014-02-25 21:21:47 +01:00
Jean-Marc Lasgouttes
e7a1cce551 Rename some LFUN names to match their text name
Also, rename copy-label-as-reference to label-copy-as-reference and update LFUNs.lyx accordingly.
2014-02-13 13:50:33 +01:00
Tommaso Cucinotta
0b6edb0b2f Revert "Let non-ASCII chars within regexp insets match their occurrence within TEXT, rather than MATHS (seems the most recurrently needed scenario)."
This reverts commit 6a3792bdbb.
2013-08-24 17:42:14 +01:00
Tommaso Cucinotta
203dab97c3 Now the regexp insets entered in Advanced F&R search/replace boxes do not preview anymore independently, unless embedded/nested within other math elements.
Fixing crash as described in #7805.
2013-08-24 13:06:05 +01:00
Richard Heck
30d3fcd640 Fix bug #8746: Images have to have alt tags. 2013-06-12 17:25:39 -04:00
Richard Heck
1b1f8dd235 Audit all the LASSERT calls, and try to do something sensible at
each failure.

There are several places I was not sure what to do. These are marked
by comments beginning "LASSERT:" so they can be found easily. At the
moment, they are at:

Author.cpp:105: // LASSERT: What should we do here?
Author.cpp:121: // LASSERT: What should we do here?
Buffer.cpp:4525:        // LASSERT: Is it safe to continue here, or should we just return?
Cursor.cpp:345:         // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:403:         // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:1143:                // LASSERT: There have been several bugs around this code, that seem
CursorSlice.cpp:83:     // LASSERT: This should only ever be called from an InsetMath.
CursorSlice.cpp:92:     // LASSERT: This should only ever be called from an InsetMath.
LayoutFile.cpp:303:                     // LASSERT: Why would this fail?
Text.cpp:995:           // LASSERT: Is it safe to continue here?
2013-04-25 17:27:10 -04:00