Commit Graph

3521 Commits

Author SHA1 Message Date
Jean-Marc Lasgouttes
a42f7ea7cd Rename eolString() to eol() and pass a MathTeXStream parameter
This is completely equivalent, but will allow in eol() to determine
whether one is preparing a preview.

Related to bug #11535.
2022-07-26 22:21:44 +02:00
Jean-Marc Lasgouttes
1fc08f57e1 Revert "Rename eolString() to eol() ans pass a MathTeXStream parameter"
This reverts commit 2db682b97e.
2022-07-26 00:46:13 +02:00
Jean-Marc Lasgouttes
7261fa9448 Revert "Reimplement support for numbering of equation previews"
This reverts commit f4da29306f.
2022-07-26 00:45:57 +02:00
Jean-Marc Lasgouttes
f4da29306f Reimplement support for numbering of equation previews
This patch simplifies and fixes the generation of previews with
numbering. Instead of saving the counter values (which is complicated
and error prone), the \thequation macro is set to the numbers_ string
which has been computed by updateBuffer for screen display.

Harcoding the number in the formula means that two equations with
different numbers have different previews, which is the subject of the
bug.

The special code for saving counters in updateBuffer and putputing
them in preparePreview from 645f9fdf (ticket #6894) is removed and
replaced by this simpler approach.

This fixes ticket #11535.
2022-07-26 00:19:20 +02:00
Jean-Marc Lasgouttes
2db682b97e Rename eolString() to eol() ans pass a MathTeXStream parameter
This is completely equivalent, but will allow in eol() to determine
whether one is preparing a preview.

Related to bug #11535.
2022-07-26 00:19:07 +02:00
Jean-Marc Lasgouttes
2203078111 Fix flicker due to changing metrics while selecting with the mouse
This patch has been backported from the lyx-unstable branch
https://gitlab.com/gadmm/lyx-unstable/-/commit/9d7ed42389ba

Actual author is Guillaume Munch.

Fixes bug #8951.
2022-07-25 23:04:08 +02:00
Enrico Forestieri
4a7a19352c Fix bug #12561
In mathed it is assumed that a labeled line is also implicitly numbered.
However, latex allows to label an equation without numbering it.
The label is then assigned the value of a nearby numbered one.
This commit drops the above mathed assumption in order to allow to import
valid latex code with a labeled but not numbered equation line.

The screen representation omits the line number and encloses the label
in square brackets for further differentiation. However, it is still not
possible to label an equation without numbering it using the GUI.
2022-07-13 19:11:03 +02:00
Jean-Marc Lasgouttes
c75522bbb7 Fix crash when dissolving a top level math inset
This should be disabled not only for math hull, but also macro template.

Fixes bug #12562.
2022-06-29 22:52:16 +02:00
Enrico Forestieri
0aad230154 Always validate a macro definition
If a user-defined macro appears only in the argument of another
macro its definition is not validated and this leads to errors.

Fixes bug #12524.
2022-05-31 22:17:14 +02:00
Kornel Benko
62ab563c25 FindAdv: Use private variable for_search
Using the new inline statements
	find_effective(), find_with_non_output(), find_with_deleted(),
	find_set_feature(), find_add_feature() and find_clean_features()
makes the code a slightly better readable.
2022-05-09 22:11:38 +02:00
Kornel Benko
c2229d388b Find: Renamend for_searchAdv to for_serach in src/OutputParams.h
Since this variable is used by quick find too, the naming was misleading
2022-04-12 18:02:12 +02:00
Thibaut Cuvelier
26300c565f MathML: fix validity for fractions with units.
https://www.lyx.org/trac/ticket/12513

Contributed by lynx.
2022-04-03 03:00:03 +02:00
Thibaut Cuvelier
7b6afb23ec MathML: fix underbraces to be stretchable.
Ticket: https://www.lyx.org/trac/ticket/12502

Contributed by lynx
2022-04-01 00:01:42 +02:00
Kornel Benko
e6d998d33c FindAdv: If possible use unicode instead of math command when searching
Wrong behaviour before this commit:
Open new lyx-file
insert
	unicode-insert 0x025c 0x1d08
Open adv-find dialog
search for unicode 0x025c OK
search for unicode 0x1d08 OK
search with regex for unicode 0x025c OK
search with regex for unicode 0x1d08 ==> NOT OK (because we are searching for \textrevepsilon
	and this was mapped to 0x025c
2022-03-20 11:33:12 +01:00
Jean-Marc Lasgouttes
307a2f91ad Revert part of 503c7c16: InsetMathNest:edit resets anchor.
Fixes bug reported here:
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg217265.html

1. Start a new document.
2. Start a math inset and inside put "1+2".
3. Put the cursor to the right of "+".
4. Press <Shift> + L three times. This will select the entire math inset
   (as expected).
5. Press <Shift> + R.

Before 503c7c16, the selection inside the math inset was preserved.
After 503c7c16, it is lost.

The problem is that InsetMathNest does too much for our needs and
resets the anchor (why, I do not know). Therefore, it is better to
duplicate the code.
2022-03-17 17:02:23 +01:00
Jean-Marc Lasgouttes
e263fe8e03 Fix unintialized variables spotted by coverity
The InsetWrap case happens in decodeInsetParaps (InsetCommand.cpp),
where the default constructor is invoked. In this case, lines was not
initialized.
2022-02-20 17:03:33 +01:00
Juergen Spitzmueller
d1761d7652 Style 2021-12-28 09:42:31 +01:00
Juergen Spitzmueller
a7905c5b96 Do not protect \\ as of LaTeX 2021/06/01 2021-12-27 16:32:12 +01:00
Juergen Spitzmueller
6ac60832e5 Add FIXME 2021-12-27 12:09:02 +01:00
Juergen Spitzmueller
582fe0990f \protect xymatrix in fragile context
(\cprotect'ion not needed then).
2021-12-27 11:42:30 +01:00
Juergen Spitzmueller
596b2d16ee \protect substack in fragile context
(\cprotect'ion not needed then).
2021-12-27 11:37:59 +01:00
Thibaut Cuvelier
7513d88350 MathML: remove redundant mrow in InsetMathScript.
https://www.lyx.org/trac/attachment/ticket/12221/0006-amends-to-a579128c-a68e9793-a68e9793.patch by lynx
2021-12-08 02:11:48 +01:00
Thibaut Cuvelier
d1daa092f6 MathML: share some code for XArrow. 2021-12-08 02:02:46 +01:00
Thibaut Cuvelier
e5eef14414 MathML: refactor the XArrow mappings as maps. 2021-12-08 02:02:46 +01:00
Thibaut Cuvelier
f0bf41f574 MathML: allow XArrow to stretch.
Based on https://www.lyx.org/trac/ticket/12221#comment:10
by lynx
2021-12-08 02:02:46 +01:00
Jean-Marc Lasgouttes
963a0aa466 Implement Row::Element::row_flags
Move the enum definition RowFlags in its own include file, to avoid
loading Inset.h. Document it more thoroughly.

Rename RowAfter to AlwaysBreakAfter.

Add CanBreakInside (rows that can be themselves broken). This allow to
differentiate elements before bodyPos() and allows to remove a
parameter to shortenIfNeeded().

Make the Inset::rowFlags() method return int instead of RowFlags, as
should be done for all the bitwise flags. Remove the hand-made bitwise
operators.

Set R::E::row_flags when creating elements.
* INSET elements use the inset's rowFLags();
* virtual element forbid breaking before them, and inherit the *After
  flags from the previous element of the row;
* STRING elements usr CanBreakInside, except before bodyPos.

More stuff may be added later.
2021-12-07 17:04:47 +01:00
Thibaut Cuvelier
bea2abf6eb InsetMathHull: fix column alignment for MathML.
https://www.lyx.org/trac/attachment/ticket/12221/0005-mathmlize-mathhull-checks-for-alignment.patch by lynx
2021-12-05 20:11:47 +01:00
Thibaut Cuvelier
a81dd6518a MathStream: better order for the calls to tab() and cr().
Part of https://www.lyx.org/trac/attachment/ticket/12221/0006-amends-to-a579128c-a68e9793-a68e9793.patch by lynx.
2021-12-05 19:15:06 +01:00
Thibaut Cuvelier
115ff2fa3c Similar fixes as 946ba7781c 2021-12-05 18:54:05 +01:00
Thibaut Cuvelier
946ba7781c Amend a68e9793: duplicate tag delimiter end. 2021-12-05 18:48:27 +01:00
Jean-Marc Lasgouttes
5eecfa3e04 When inserting text character in mathed, group in same \text when possible.
When inserting € in a math cell, it is put in a text inset and the
cursor leaves the inset. However, inserting ¤ then leads to
\text{€}\text{¤}.

Therefore, try to see if there is a previous \text inset that can be
recycled and insert the new inset there in this case, leading to
\text{€¤}.

Fixes bug #11979.
2021-11-28 14:33:45 +01:00
Jean-Marc Lasgouttes
85f030a031 Let Tab go out of inset when no cycling is possible
Adapted patch from Enrico by adding S-Tab handling.

Fixes bug #11085
2021-10-21 22:42:40 +02:00
Jean-Marc Lasgouttes
c242b25364 Work around compilation warning
Clang 12 (at least) misses the fact that tag is always initialized,
because the if/else sequence does cover all cases.

Initialize the variable although it is not required. It does not hurt
at least.
2021-10-11 14:51:28 +02:00
Jean-Marc Lasgouttes
e5bb491e2e Reduce the number of accesses to coord cache when drawing a math row
Each of these accesses is somewhat costly when using large branches
with lots of maths

Related to bug #12297.
2021-10-08 18:17:19 +02:00
Yuriy Skalko
d3c335a5d5 Remove useless casts reported by GCC with -Wuseless-cast option 2021-09-30 10:37:24 +03:00
Yuriy Skalko
325c405541 Remove redundant semicolons reported by GCC with -Wextra-semi option 2021-09-28 11:28:43 +03:00
Jean-Marc Lasgouttes
73865ce999 Whitespace 2021-09-27 11:53:59 +02:00
Enrico Forestieri
9ae002b69f Fix bug #12373
Do not perform any autocorrection in the presence of a selection.
2021-09-24 10:17:32 +02:00
Jean-Marc Lasgouttes
da57154f94 Rework display of numbers in margins of hull insets
This requires the introduction of the booleans selected_left and
selected_right in PainterInfo. These tell whether the selection
continues at the left/right of the inset.

This information allows to

1/ paint equation number in the right color: either current text color
   or selection text color.

2/ before that, paint a small background rectangle of the correct color.

This allows to avoid painting a large rectangle of an arbitrary color
that was the cause of the bug.

Fixes bug #12319.
2021-07-09 23:46:16 +02:00
Eugene Chornyi
e9d5fc0190 prevent Qt6 from defining UNICODE (Qt6.1.1 and upwards) 2021-06-19 10:48:49 +02:00
Jean-Marc Lasgouttes
7e17d1a1b7 Fixup 7e7f9eba: we only need one hasLimits() method
Related to bug #12295.
2021-06-01 16:12:46 +02:00
Thibaut Cuvelier
7e7f9ebae8 MathML: use the right has_limits_ in InsetMathScripts.
Fixes #12295. Details in the ticket.
2021-05-31 23:26:25 +02:00
Thibaut Cuvelier
2805452229 MathML: InsetMathHull now distinguishes between hull types to present display/inline math and adjust the alignment of the cells
By lynx: https://www.lyx.org/trac/attachment/ticket/12221/0004-mathml-display-changes.patch
2021-05-25 03:56:24 +02:00
Thibaut Cuvelier
dd1a85a2ba MathML: more consistency between DocBook and XHTML.
By lynx: https://www.lyx.org/trac/attachment/ticket/12221/0004-mathml-display-changes.patch
2021-05-25 03:54:42 +02:00
Thibaut Cuvelier
a68e979350 MathML: use M/ETagInline.
By lynx: https://www.lyx.org/trac/attachment/ticket/12221/0003-tag-insertion-unification-for-bold-char-delim-dots-exfunc-.patch
2021-05-25 03:51:29 +02:00
Thibaut Cuvelier
3ab6633b86 MathML: add M/ETagInline.
By lynx: https://www.lyx.org/trac/attachment/ticket/12221/0003-tag-insertion-unification-for-bold-char-delim-dots-exfunc-.patch
2021-05-25 03:34:52 +02:00
Thibaut Cuvelier
a579128c06 DocBook: for MathML, mrow removal for more cases
By lynx: https://www.lyx.org/trac/attachment/ticket/12221/0003-tag-insertion-unification-for-bold-char-delim-dots-exfunc-.patch
2021-05-25 03:29:20 +02:00
Thibaut Cuvelier
5eddfe509b DocBook: for MathML, refactor InsetMathScript::mathmlize to improve readability and lower redundancy. 2021-05-25 03:21:21 +02:00
Thibaut Cuvelier
1cbac6fcb4 DocBook: for MathML, mrow removal from decoration, script, frac
By lynx: https://www.lyx.org/trac/attachment/ticket/12221/0002-mrow-removal-from-decoration-script-frac.patch
2021-05-25 03:15:48 +02:00
Thibaut Cuvelier
e4996026b7 DocBook: for MathML, use display="block" for non-inline formulae.
By lynx:
https://www.lyx.org/trac/attachment/ticket/12221/0001-docbook-display-equation.patch
2021-05-25 02:34:04 +02:00
Enrico Forestieri
7a6ad48495 Use font metrics for computing the size of math decorations
It was an error using an absolute size instead of one relative to the
size of the used font. It was requiring using the physical dpi of the
screen and caused #12222. Now everything is computed with respect to
the metrics of the font and should be automatically correct.

Fixes #12222.
2021-04-03 18:37:10 +02:00
Thibaut Cuvelier
0f782b0ded DocBook: add a parameter to change the namespace prefix for MathML. 2021-03-23 00:32:45 +01:00
Enrico Forestieri
7545698380 Fix bug #12181
The context menu for InsetMathRef is now usable.
InsetMathRef still misses support for RefStyle and thus the
corresponding entries are omitted from the menu. But this would
be a different bug.
2021-03-06 23:36:58 +01:00
Enrico Forestieri
5a43b86141 Allow context menus in mathed
It is now possible to get a context menu for math insets.
InsetMathSpace was already providing a specific context menu,
but it was never triggered because the math hull inset is not
descendable. It is still so, but now when a context menu is
requested all the insets inside the math hull are examined.
If the inset under the cursor provides a context menu, it
is shown instead of the general math one.

Fixes #12100.
2021-03-05 21:21:41 +01:00
Jean-Marc Lasgouttes
f5340fd6d9 Fix missing initialization
Spotted by Coverity.
2021-03-05 13:06:10 +01:00
Enrico Forestieri
52ce0ff49a Fix bug #11007
The math color inset inherits the mode of the containing inset.
This mode is inferred by the kind of font in effect. Setting the
right mode allows to insert spaces where these should be allowed.
Another small glitch was that the selection was always parsed in
math mode, so that any space was swallowed, even if the inset would
allow them.
2021-02-28 22:32:11 +01:00
Enrico Forestieri
61db164302 Fix bug #11444 2021-02-28 14:56:42 +01:00
Enrico Forestieri
7b526d6461 Fix bug #3751
We lack the necessary font (cmb10) for drawing bold uppercase greek
letters. It would be overkill adding it for this sole purpose, so
adopt the same poor man's bold strategy used with \boldsymbol.
2021-02-27 21:40:28 +01:00
Enrico Forestieri
195b928f92 Fix bug #3294 2021-02-27 14:49:55 +01:00
Enrico Forestieri
3cf5a064db Amend 368e983a 2021-02-23 21:48:54 +01:00
Enrico Forestieri
368e983abb Fix bug #12165 2021-02-23 20:00:50 +01:00
Enrico Forestieri
2629bd6dfb Improve fix for #12153
Use a WYSIWYM approach instead of a WYSIWYG one.
2021-02-23 17:34:19 +01:00
Jean-Marc Lasgouttes
a5fd5d3cd2 "12 pixels ought to be enough for anyone"
Fixes bug #12153.
2021-02-22 19:35:08 +01:00
Jean-Marc Lasgouttes
41d29ce387 Reduce the value of (above|below)displayskip
The value of 10pt is too large, use a 'mean' value of 8.5pt.

Tentative fix to bug #12153.
2021-02-21 20:40:09 +01:00
Enrico Forestieri
4e0d7f753b Draw real dots
A new method for drawing ellipses has been added to the painter
and used for drawing real dots for math decorations and the various
\cdots, \ddots, \vdots, etc., latex commands.
2021-02-21 00:39:12 +01:00
Enrico Forestieri
11392b7b33 Fix arrows at ends of math decorations
For math decorations with arrows at both ends the code was simply
stretching a prototype symbol, thus distorting the arrows.

Another drawing mode is introduced allowing to draw an element by
maintaining its aspect ratio also when it has to be drawn at the
other end of a decoration. An element drawn using this mode is simply
shifted to the other side by adding either the width or the height,
and a finer adjustment can be obtained by specifying an additional
horizontal or vertical shift.
2021-02-14 01:25:07 +01:00
Enrico Forestieri
400cb1b80f Fix small glitch with \underXXXarrow and \overXXXarrow
When the argument is long enough, the arrow in the on-screen representation
was not covering the first or the last glyphs. For example, using
\overrightarrow{abcdefghijklmnopqrstuvwxyz}
the 'a' was drawn outside the covering arrow.
2021-02-12 23:56:27 +01:00
Enrico Forestieri
2ba8ebab67 Slightly increase size of math decorations
Correspondingly tweak some shapes for better results.

Part of #12132.
2021-02-12 23:16:03 +01:00
Juergen Spitzmueller
e35574b3ce Store the AuthorList in the cut stack
Otherwise we crash when we paste text with markup into a different buffer
that has change tracking disabled (in this case, markup is now kept).
2021-02-09 16:54:21 +01:00
Jean-Marc Lasgouttes
c311451518 Fix math class code in InsetMathColor
The current code is too naïve and asserts on MC_UNKNOWN class.

See discussion here:
https://marc.info/?l=lyx-devel&m=161267112524889&w=2
2021-02-08 13:13:21 +01:00
Enrico Forestieri
3cf5a71463 Amend [5ed01cd6/lyxgit]
This commit takes into account also the case in which a prime follows
a superscript, a case not explicitly mentioned in bug 1633.
This case has to be accounted for in a different way. We cannot look
ahead when exporting, so we simply tell TeXMathStream to output an
empty group if we just output a superscript and a prime comes next.
2021-02-06 20:07:31 +01:00
Jean-Marc Lasgouttes
720f439868 Fix default limits value for (under|over)brace
Fixes bug #12107.
2021-02-05 14:37:26 +01:00
Enrico Forestieri
5ed01cd616 Avoid double superscript errors
Fixes #1633
2021-02-05 01:03:09 +01:00
Enrico Forestieri
8202e4e571 Disable direct insertion of multiple spaces in mathed text
Fixes #1311
2021-02-04 21:20:45 +01:00
Enrico Forestieri
b475cf8707 Amend [bc806084/lyxgit]
Rise a bit \dot, \ddots & co., as with some fonts they might
be drawn too close to the symbol they decorate.
2021-02-03 11:45:52 +01:00
Enrico Forestieri
d999d8e8d9 Improve alignment of math decorations
This patch takes into account the skewness of a character for properly
align a decoration. Unfortunately, the required amount of shift depends
on single chars, so that the recently introduced FontMetrics::italicSlope()
method cannot be used with all characters. A heuristics that produces
satisfactory results is using the italic slope only with characters whose
italic correction (kerning) is zero.

Part of #11491
2021-02-02 19:39:52 +01:00
Enrico Forestieri
bc806084cd Improve appearance of dots at higher zoom levels
Make \dot, \ddot and friends more round when increasing zoom

Part of #11491
2021-02-01 20:02:37 +01:00
Enrico Forestieri
9f3920447e Make math decorations scalable with zoom level
Fixes #11491
2021-02-01 02:53:00 +01:00
Enrico Forestieri
22ee249c3e Allow pasting references to mathed
A reference can be directly inserted into mathed but cannot be pasted
because the pasted material is returned in plain text format. This patch
allows getting a string from the cut stack in a suitable format allowing
the math parser to actually create an InsetRef.

Fixes #11539
2021-01-30 01:32:40 +01:00
Kornel Benko
ea5e16d075 Replace calls from make_unique to lyx::make_unique
After advice from Yuriy Skalko to satisfy compilation with clang8
2021-01-15 11:36:14 +01:00
Jean-Marc Lasgouttes
86191314cb Record undo properly when inserting math script
The current code did not always record undo at the right level.

Fixes bug #10843.
2021-01-13 11:41:29 +01:00
Richard Kimberly Heck
e438c0f90b Fix bug #11010.
Handle LFUN_PHANTOM_INSERT in math.
2021-01-09 19:17:47 -05:00
Jean-Marc Lasgouttes
9e1db65932 Move handling of LFUN_COPY to BufferView
It turns out that the code is the same in texted ans mathed and that
whatever is done in InsetTabular is not useful.

This means that we do not need to deal Text::dispatch idiosyncrasies
(in particular forcing the cursor to be visible).

Fix bug #11225.
2021-01-08 19:31:42 +01:00
Enrico Forestieri
fece5d4f37 Correctly terminate a user math macro in certain circumstances
If a macro has only optionals and none is specified and a [ immediately
follows, we have to terminate the macro with {}, otherwise what follows
is taken to be an optional argument.

Fixes #11665.
2021-01-07 00:57:36 +01:00
Thibaut Cuvelier
e3c1fc2ad5 Implement \case for AASTeX. 2021-01-06 14:08:00 +01:00
Jean-Marc Lasgouttes
28bca59dec Fix unused paramaters warnings 2021-01-06 11:57:22 +01:00
Enrico Forestieri
d85710d32e Make paste in ensuremath work as in simple math hulls
The ensuremath math inset derives from InsetMathNest, so that only the
first cell of a grid gets pasted. This patch makes it a fixed 1x1 grid
inset so that pasting works as in normal simple math hulls, i.e., all
cells are pasted, one after the other.

Fixes #11617.
2021-01-06 02:07:25 +01:00
Richard Kimberly Heck
59096c9265 Move assignment where needed 2021-01-05 18:22:09 -05:00
Richard Kimberly Heck
cf07d4825f Fix bug #11104. Activate refstyle support for InsetMathRef.
At the moment, there is no support for plurals and capitalization.
A long comment explains why. Support could be added for that without
a format change.
2021-01-05 18:17:53 -05:00
Richard Kimberly Heck
79a21be5c3 Micro optimization and constness 2021-01-05 17:45:50 -05:00
Richard Kimberly Heck
0786b80828 Fix MathML delimiters again.
Patch from lynx.
2021-01-03 19:29:04 -05:00
Thibaut Cuvelier
649755f481 Rename WriteStream to TeXMathStream. 2021-01-02 19:52:23 +01:00
Thibaut Cuvelier
ecafea8227 Rename MathStream to MathMLStream. 2021-01-02 19:52:23 +01:00
Yuriy Skalko
cafa1d4ae4 Fix C++20 compilation on systems where char_type is wchar_t 2020-12-30 09:42:50 +02:00
Thibaut Cuvelier
372b32c0a6 Fix MathML output of InsetMathDelim
Patch by lynx (https://www.lyx.org/trac/ticket/12050).
2020-12-20 00:21:10 +01:00
Jean-Marc Lasgouttes
405b5c04a7 Fixup 005f69de: code cleanup.
Since we are not sure of where the cursor ends up after invoking
Cursor::handleNest it is safer to reset the cursor at each cell,
rather than reuse the same one over and over.

Related to bug #12035.
2020-12-19 17:12:28 +01:00
Jean-Marc Lasgouttes
005f69de23 Fix crash after b0937fb9.
Now the cursor is not left inside color inset, so it is not needed to
pop_back.

Fix bug #12035.
2020-12-17 22:04:46 +01:00
Jean-Marc Lasgouttes
99fb1c7003 Overhaul (no)limits support
- Add limits support to InsetMathScript
- Add limits support to InsetMathClass
- Fix bug where limits changing is disabled in inline math

Now the MathData objects remember whether they are in diaply mode.

Fixes bug #12045.
2020-12-09 14:10:17 +01:00
Yuriy Skalko
e292dd70bf More enums & includes refactoring 2020-12-06 18:26:41 +02:00
Yuriy Skalko
9cb98136ce Cleanup headers 2020-12-03 00:38:27 +02:00