Commit Graph

3488 Commits

Author SHA1 Message Date
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
Yuriy Skalko
efaffb897d Simplify InsetMathGrid structs 2020-12-03 00:38:18 +02:00
Yuriy Skalko
ecf62a8f21 Refactor OutputParams
Now all Inset hierarchy uses OutputParams.h included in Inset.h.
Forward declare some enums to reduce header dependencies.
2020-11-30 13:05:03 +02:00
Yuriy Skalko
813eb0f9f7 Cleanup included headers 2020-11-29 00:25:14 +02:00
Yuriy Skalko
8793c2eed9 Replace ;; 2020-11-27 12:16:54 +02:00
Yuriy Skalko
6a21ec854b Move several common types to support/types.h 2020-11-27 12:16:22 +02:00
Yuriy Skalko
43b16548b4 Cleanup headers 2020-11-25 02:43:16 +02:00
Richard Kimberly Heck
2ae77d5091 Only set buffer if it is not null.
Yuriy found these specific problems. They do not cause a crash, but
they are not good.
2020-11-24 17:07:16 -05:00
Richard Kimberly Heck
5691b89858 nullptr 2020-11-24 17:07:16 -05:00
Yuriy Skalko
7ca2f2b58d Use range-based loops 2020-11-21 20:32:16 +02:00
Yuriy Skalko
09eba40418 Remove unused header 2020-11-21 00:32:35 +02:00
Thibaut Cuvelier
0fe3d05344 XML: add tag-type information in XML tags. It is not yet used. 2020-11-20 18:41:03 +01:00
Yuriy Skalko
b56a64a8ef Typo 2020-11-20 15:57:34 +02:00
Yuriy Skalko
f953d88c88 Simplify constructors 2020-11-20 15:57:26 +02:00
Yuriy Skalko
9b1dc338b2 Simplify Changers 2020-11-12 14:22:00 +02:00
Richard Kimberly Heck
fdd0a6f849 Revert "Improve structure of updateMacros"
The problem here is that the check against TEXT_CODE only
catches InsetText, and not its subclasses. Same for the check
against MATH_HULL_CODE. So there is reason not to check codes
here.

This reverts commit 5a54ccfa87.
2020-11-11 11:26:11 -05:00
Yuriy Skalko
01e673635b MacroData refactoring 2020-11-06 21:33:56 +02:00
Yuriy Skalko
5a54ccfa87 Improve structure of updateMacros 2020-11-06 21:33:41 +02:00
Thibaut Cuvelier
85a8664ba5 MathML: make InsetMathXArrow generate valid XML entities when required.
Before this, it only supported HTML entities.
2020-11-05 02:18:47 +01:00
Yuriy Skalko
d38eddb397 Match header/source function argument naming 2020-11-01 22:23:44 +02:00
Yuriy Skalko
5061db891c Use const references 2020-11-01 22:23:26 +02:00
Yuriy Skalko
524073d09f Move HullType functions declared in InsetMath.h into InsetMath.cpp 2020-10-29 15:52:28 +02:00
Yuriy Skalko
10272e4747 Move include of own header to the top. Fix dependencies 2020-10-25 19:58:57 +02:00
Yuriy Skalko
a7018252b7 Constify 2020-10-25 09:28:34 +02:00
Yuriy Skalko
d25c10ed81 Remove duplicate and unused header includes in .cpp files 2020-10-19 18:01:11 +03:00
Yuriy Skalko
a3eeb8a4b5 Clean math headers 2020-10-16 23:05:46 +03:00
Yuriy Skalko
fbefdb10a5 Move Cursor.h from Clipboard.h 2020-10-16 08:02:51 +03:00
Pavel Sanda
560ff6d40d Move MetricsInfo.h from InsetMathSize.h 2020-10-14 14:58:18 +02:00
Jean-Marc Lasgouttes
c516c86d19 Make cursor width depend on current font
This makes the cursor more visible wrt current font.

Moreover make the cursor width scalable by default.
2020-10-13 17:27:52 +02:00
Yuriy Skalko
2a594d3e90 Remove unused forward declarations 2020-10-13 09:57:36 +03:00
Yuriy Skalko
238fd9ac50 Right exception rethrowing 2020-10-12 15:14:55 +02:00
Yuriy Skalko
919a06718a Constify 2020-10-12 15:06:16 +02:00
Yuriy Skalko
7d38a4d126 Loop refactoring 2020-10-09 09:04:20 +03:00
Yuriy Skalko
fe85162a29 Refactoring 2020-10-05 14:55:00 +02:00