Commit Graph

3368 Commits

Author SHA1 Message Date
Juergen Spitzmueller
957b615b1f Fix another crash with Grid pasting (follow-up to #11906) 2020-08-16 17:24:13 +02:00
Stephan Witt
0fa4b7e736 #9376 prepare use of Length in lyxrc - move the class Length to support 2020-08-07 09:24:31 +02:00
Juergen Spitzmueller
8415041b1f Use hexnames only for x11 colors
This prevents wrong color allocation with ambiguous names.

Fixes #11828

Patch by D. Ramöller with extensions by me.
2020-08-03 14:10:46 +02:00
Enrico Forestieri
7441172d4d Assure correct spacing of colored items in mathed
When coloring a non-ordinary math atom, explicitly apply its
math class, so that to leave unchanged the spacing around it.
Fixes #11827.
2020-08-02 18:58:40 +02:00
Thibaut Cuvelier
c1ec3394c6 DocBook: improve new lines around maths. 2020-08-01 22:45:56 +02:00
Juergen Spitzmueller
53e872455a Revert "Fix #11827"
This reverts commit b521d36bfb.

Not ready yet
2020-07-31 09:18:37 +02:00
Daniel Ramoeller
b521d36bfb Fix #11827
Keep spacing of math intact.
2020-07-30 16:24:17 +02:00
Thibaut Cuvelier
d75ff9931d Revert "Support the mathbbm font."
This reverts commit e709a6626e.
2020-07-28 18:01:38 +02:00
Thibaut Cuvelier
e709a6626e Support the mathbbm font.
Should just be able to read formulae, not add it from the GUI, as it's mostly redundant with mathds and mathbb.
2020-07-27 03:15:00 +02:00
Thibaut Cuvelier
8dd2e7e681 DocBook: solve issue with formulae within font tags.
This is not valid DocBook either!
2020-07-26 23:23:02 +02:00
Enrico Forestieri
0b3e69167c Fix placement of limits with integral signs
Since be836909c5 the positioning of super- and subscripts
for symbol fonts has been broken because the metrics of the
font of the environment (rather than those of the symbol itself)
were used.
2020-07-24 12:32:24 +02:00
Jean-Marc Lasgouttes
f96b99dcb3 Implement properly \limits and \nolimits
These are now properties of insets that can be operators :
InsetMathSymbols, InsetMathDecoration (for over/underbrace) and
InsetMathMacro (for its contents).

Each of these has a limit_ member that allows to remember a limit
forcing and a member defaultLimits() that indicates what to do in the
absence of such forcing. Moreover the write() method calls
writeLimits().

This allows to simplify the definitions of integrals in lib/symbols by
defining the integrals as macros of their "op" version, as it is done in
the style files.

Also, many hardcoded assumptions can now be removed.

The handling of LFUN_MATH_LIMITS is now done in InsetNest, which tries
successively to apply the limit change to (1) the character after
cursor, (2) the character before cursor and (3) the character at the
end of the inset (useful for script insets?)

The new code allows to define
  \newcommand\int{\intop\limits}
but not
  \newcommand\makelimits#1{#1\limits}

It is also possible to type explicitly \limits or \nolimits to modify
a symbol.
2020-07-20 23:20:26 +02:00
Jean-Marc Lasgouttes
e8ee0100fc Implement variable size bigops
The goal is to reproduce the change of size of operators like \sum wen they
are in display style.

The syntax of the symbols file has been extended to allow for two code
points (like 80|88 for \sum). In this case, the second one will be
used in display style.

Update the symbols file to handle all bigops from cmex, esint, wasy and
stmaryrd.

Let the code for math symbol inset handle symbols which can change size,
using the information from the symbols file.
2020-07-17 22:25:18 +02:00
Jean-Marc Lasgouttes
8d54457dbf Improve metrics for \limits in display mode 2020-07-17 22:18:43 +02:00
Juergen Spitzmueller
61cf165521 Consider single-cell insets when pasting multiple cells (#11906) 2020-07-14 10:39:49 +02:00
Juergen Spitzmueller
4884476eb6 Do not blindly disable inset-modify in MathNest
Fixes #11784
2020-07-13 16:50:11 +02:00
Jean-Marc Lasgouttes
1c956cdc16 Improve drawing of macro template frame
Use Inset::xxxOffset as offsets and draw the frame in the middle of
the empty space.

Fixes bug #9657.
2020-07-12 15:39:37 +02:00
Jean-Marc Lasgouttes
77036f5434 Fix and simplify computation of painter monochrome mode
The old code in GuiPainter::filterColor did not work. Tricks with
colors should take place in HSV space, not RGB IMO.

Replace the code with a simpler one which maps the grayscale value
of the original color on the blend color. It works nin the case where
original color is red, but might not work as well when blend color is
not black. Time will tell.

Fixes bug #11904.
2020-07-12 00:01:46 +02:00
Richard Kimberly Heck
8ae0841826 Whitespace 2020-07-08 12:38:05 -04:00
Thibaut Cuvelier
3883b85f49 New DocBook support 2020-07-08 08:42:16 +02:00
Pavel Sanda
28968b1f0d Add required elements in the layouts to support DocBook.
Slightly modified patch from Thibaut Cuvelier.
2020-07-07 09:49:48 +02:00
Juergen Spitzmueller
d0cbcda3b9 Fix yet another thinko in the math grid paste code
This is a Hydra!
2020-06-30 17:23:58 +02:00
Juergen Spitzmueller
b84e497ab6 Fix cursor positioning with specific matrix pastings 2020-06-30 09:25:59 +02:00
Juergen Spitzmueller
7869960888 Fix math matrix column insertion on paste 2020-06-29 18:05:46 +02:00
Juergen Spitzmueller
5c663849d1 Update cursor idx after grid paste if columns are appended 2020-06-29 17:57:18 +02:00
Juergen Spitzmueller
3b895bb47a Fix math grid paste when needing more cells 2020-06-29 16:30:49 +02:00
Juergen Spitzmueller
16d0785e67 Fix pasting of math grid with more rows in source than target (#11897) 2020-06-29 09:48:05 +02:00
Jean-Marc Lasgouttes
3c4e567d44 Run codespell on src/mathed
codespell -w -i 3 -S Makefile.in -L mathed,afe,tthe,ue,fro,uint,larg,alph,te,thes,alle,Claus,wit,nd,numer  src/mathed/
2020-06-25 23:31:42 +02:00
Jean-Marc Lasgouttes
ba738d0167 Use new rowFlags() values to remove some inset hardcoding.
The enum DisplayType is replaced with the flags RowFlags that can be
combined. Here is the correspondence between the old DisplayType and
the new Inset::RowFlags:

DisplayType   RowFLags             Meaning
 Inline        Inline               plain inline inset
  --           BreakBefore          row ends before this inset
  --           BreakAfter           the row ends after this inset
 AlignCenter   Display	            the inset is centered on its own row
 AlignLeft     Display | AlignLeft  the inset is left-aligned on its row
 AlignRight    Display | AlignRight the inset is right-aligned on its row
  --           RowAfter             an extra row is needed after this inset

Display is just a shortcut for BreakBefore | BreakAfter.

The flags for the newline inset will be BreakAfter | RowAfter,
while the separator inset will just use BreakAfter.

This groundwork does not introduce any new feature at this point. It
aims to remve the numerous isNewLine and isSeparator all over the
code, and to eventually optional break after some insets like spaces
(see #11621).

Most display() methods are renamed to rowFlags(). Some are removed
because they returned Inline.

Now display() is only a helper function for hull insets.
2020-06-22 23:11:40 +02:00
Thibaut Cuvelier
8f89768211 Fix in symbols handling: parse the XML entity with \def. 2020-06-19 08:22:56 +02:00
Thibaut Cuvelier
718eede94b MathML: Convert HTML entities to XML entities. 2020-06-18 19:37:08 +02:00
Thibaut Cuvelier
054bdc5d18 MathML stream allows for name spaces. 2020-06-18 19:32:51 +02:00
Thibaut Cuvelier
a6b07608d8 Rename XHTMLStream to XMLStream, move it to another file, and prepare for DocBook adoption.
xml.cpp/h also merges functionalities from sgml.cpp/h.
2020-06-15 13:01:56 +02:00
Thibaut Cuvelier
c8d0492194 MathML: generate only a mathvariant for double-struck font, no redundant class 2020-06-11 23:22:48 +02:00
Enrico Forestieri
5a80f7bb6a Add support for the doublestroke package
This commit adds the mathed command \mathds that selects a
font more appropriate than \mathbb for typesetting the
mathematical symbols for the natural (N), whole numbers (Z),
rational numbers (Q), real numbers (R), complex numbers (C),
and some others.

As in the \mathbb case, only capital letters are supported,
but in addition one can also typeset a symbol often used for
representing the indicator function (\mathds{1}) and the
letters a, h, k.

Fixes bug #11887.
2020-06-11 16:42:31 +02:00
Thibaut Cuvelier
716e3dc1a8 Output double-struck fonts as such in MathML, not in bold 2020-06-11 10:30:48 +02:00
Jean-Marc Lasgouttes
2d48072e66 Get rid of Qt resources
It turns out that the resources were mostly not used anyway. Removing
them shrinks LyX binary by ~6MB.

Only autotools have been adapted. cmake will require the same
simplification.
2020-06-07 01:15:28 +02:00
Richard Kimberly Heck
acc3f2cef8 Forgot this part. 2020-06-01 12:27:32 -04:00
Kornel Benko
38ec7471e7 Amend 44816adce6: Be careful before using buffer parameters in colAlign
The LASSERT(isBufferValid()..) leads to crash in find-adv dialog
2020-06-01 10:20:38 +02:00
Jean-Marc Lasgouttes
e06e2e24e7 Revert part of 56e012be: hardcode again "too small" preview size
It seems that the use of zoom in determining the size of the minimal
value was a bad idea.

It still think that the situation is not very satisfying, we need a new idea.
2020-05-28 20:43:01 +02:00
Richard Kimberly Heck
91265c1f46 Missing include according to VC19 2020-05-04 14:19:29 -04:00
Richard Kimberly Heck
d6a7ec506e s/requires_/required_/ for code consistency 2020-05-04 14:05:44 -04:00
Richard Kimberly Heck
3b09ef61a6 Fix remaining (I think) requires keyword issues. 2020-05-04 13:46:01 -04:00
Richard Kimberly Heck
c94a97e36c Fix declaration 2020-04-26 03:37:20 -04:00
Juergen Spitzmueller
ed137ee435 Disable append-column with gathered
Fixes #11812
2020-04-04 09:27:24 +02:00
Richard Kimberly Heck
2d0ad7d308 Remove code disabled since 2005.
No one knew then what it was supposed to do.
2020-03-28 23:52:55 -04:00
Stephan Witt
0885098bd3 #11747 follow-up of change d94b708a0f to fix a compiler warning 2020-03-08 13:33:30 +01:00
Juergen Spitzmueller
d94b708a0f Tell updateBuffer whether an inset is deleted.
Fixes #11747
2020-03-06 13:23:01 +01:00
Richard Kimberly Heck
62af7ee772 More requires --> required, for C++2a. 2020-02-28 00:36:55 -05:00
Stephan Witt
3ee1bcad04 Remove another unnecessary assignment 2020-02-12 12:28:18 +01:00
Enrico Forestieri
926c846abb Remove unnecessary assignments 2020-02-10 21:59:52 +01:00
Enrico Forestieri
536d476d38 Make sure to not dereference a null pointer. 2020-02-10 21:54:07 +01:00
Stephan Witt
59fa0b2592 Fix a crash with uninitialized buffer member of MathData
See the details here: https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg210294.html
2020-02-07 10:17:33 +01:00
Jean-Marc Lasgouttes
a187cbeb64 Rename PainterMetrics::change_ to change
This is not a private variable.
2020-01-14 11:50:44 +01:00
Juergen Spitzmueller
a450797b2a Rest in peace, dvipost! 2020-01-13 08:59:26 +01:00
Jean-Marc Lasgouttes
bf7f4d716c Avoid blinking change tracking cur for math inset.
Since there is a margin above and below the inset, there is no problem
for putting it higher.

Fixes bug #11684.
2020-01-11 13:39:20 +01:00
Juergen Spitzmueller
affc006bae Honor change tracking when automatically renaming refs to labels
Fixes rest of #11556
2019-12-31 12:29:53 +01:00
Juergen Spitzmueller
89b5607e0a Centralize code to markup deleted complex objects (with tikz) in output
This fixes #9293
2019-12-28 13:43:17 +01:00
Juergen Spitzmueller
e5a9d09870 Mark deleted graphics in output
Fixes #11687
2019-12-26 07:15:37 +01:00
Jean-Marc Lasgouttes
49ed5b4626 Add a setBuffer method to InsetArgumentProxy
This is needed to set the buffer of default values of optional arguments.

Fixes bug #11695.
2019-11-15 20:43:00 +01:00
Jean-Marc Lasgouttes
067d6dc759 Mark insets with invalid buffer() in red in devel-mode.
We tend to have insets which buffer() member is invalid. To help
debugging, this commit paints their background in red when devel-mode
is on.

To this end, a new method develMode() is added to the Painter class.

With this commit, it is easy to see that macro template do not have a
proper buffer set!
2019-10-21 17:24:24 +02:00
Jean-Marc Lasgouttes
44816adce6 Be careful before using buffer parameters in colAlign
Make InsetGrid::colAlign a normal method and make it check whether
buffer is valid before using it. This avoids crashes as we have seen
in 2.3.3 (see e.g. #11686).

There is still an assertion so that failure is noticeable before release.
2019-10-21 17:02:39 +02:00
Jean-Marc Lasgouttes
19abf29ea0 Set buffer when expanding macro
This avoids a crash in InsetMathSplit which uses the buffer() value.

Fixes bug #11686.
2019-10-20 12:54:59 +02:00
Enrico Forestieri
0573bf92e0 Fix bug 11667
When automatic command termination was added to texstream it was
forgotten to reset its status after a math inset.
2019-09-28 16:08:06 +02:00
Jean-Marc Lasgouttes
8d080364d2 Clarify calculation precedence for '&' and '?'
Spotted by cppcheck
2019-09-15 23:57:57 +02:00
Jean-Marc Lasgouttes
decd2c74f1 Mark constructors with only one parameter as explicit
Spotted by cppcheck
2019-09-15 23:56:17 +02:00
Jean-Marc Lasgouttes
19fb4db71e Make code more obvious
- use propoer parenthesis
- do not store in variable something we do not use

Spotted by cppcheck.
2019-09-15 23:31:32 +02:00
Jean-Marc Lasgouttes
02d55ab0b3 Avoid useless test
Spotted by cppcheck
2019-09-15 23:30:29 +02:00
Jean-Marc Lasgouttes
b42e6e96d8 Pass variable by reference
Spotted by cppcheck
2019-09-15 23:29:47 +02:00
Jean-Marc Lasgouttes
714113655a Follow some of the performance advice from cppcheck
Most of that is changing string to string const &.
2019-09-13 16:23:49 +02:00
Jean-Marc Lasgouttes
5915d69eaf Set buffer correctly when deleting column in math grid
This is a followup to 837bcbb0.

Fixes bug #11623.
2019-08-28 18:21:17 +02:00
Juergen Spitzmueller
231b36d950 Fix text direction of references with XeTeX/bidi
Fixes: #11626
2019-08-05 16:30:01 +02:00
Jean-Marc Lasgouttes
732395ef1e Add support for amsmath's smallmatrix
This is a tight matrix in script size that is suitable for using inline.

Patch from our own Martin Vermeer and myself.
2019-07-15 13:38:07 +02:00
Jean-Marc Lasgouttes
009e7a61bb Fixup ee0bd36a86: only clear margins when needed
The old code would erase text around inline math.

Related to #11333.
2019-07-15 13:06:09 +02:00
Jean-Marc Lasgouttes
ca5cac2b51 When pasting several cells in mathed, take cursor position in account
Related to bug #11390
2019-07-15 01:20:08 +02:00
Jean-Marc Lasgouttes
ee0bd36a86 Add empty rows to grid insets when numbers are too wide
This is done to ensure that numbering never overlaps equations. The
result can be different according to the bufferview, which is why
RowInfo::offset is now a std:map.

Remaing issues (how bad are theese ?):

- the numbering is considered too large when it overlaps the inset
  rect, whereas one could consider the width if the current row
  instead.

- previews may need to be adapted similarly to fit the whole screen width
2019-07-14 23:27:44 +02:00
Jean-Marc Lasgouttes
dea245d540 Draw display math numbering outside of inset
This is the first (easiest) step in fixing bugs 10668 and 11333.

The numbering is now drawn outside of the insets, which solves the
alignment problems and make editing easier.

What does not work yet:

- long labels will overwrite equations. To fix this, we need to
  implement the same algorithm as LaTeX and put labels on their own
  row when required.

- previews may need to be adapted similarly to fit the whole screen width
2019-07-14 23:27:44 +02:00
Jean-Marc Lasgouttes
ed856c9f4d Make some InsetMathGrid members private
Also remove the trailing underscore of XXXInfo members, since they are
not private in essence.

No intended behavior change.
2019-07-14 17:45:03 +02:00
Jean-Marc Lasgouttes
4cc4663262 Replace MathData::kerning_ member by a function
This allows to make kerning depend on the BufferView? This is not
useful right now, but may become useful for multimonotor setting with
different dpi.
2019-07-14 14:45:36 +02:00
Jean-Marc Lasgouttes
5a22b2e391 Fixup 17571104: really avoid empty numbers in toc
For some reason, I missed this one when trying to fix the bug.

Fixes bug #11423.
2019-07-01 12:05:31 +02:00
Isaac Oscar Gariano
4c587fb9da Make autocorrect have priority.
Place autocorrect at the top of `InsetMathNest::interpretChar`,
ensuring that any autocorrections that trigger on special characters
(such as '^' or '~') work. In particular, you can now make an
autocorrection from "<~" to "\preceq"!
2019-06-25 12:27:28 +02:00
Jean-Marc Lasgouttes
2b1515a936 Rename LM_ST_* to *_STYLE and FONT_SIZE_* to *_SIZE
This makes code more uniform. This is typically something that is done
at end of cycle to limit backport issues later.
2019-06-14 17:05:49 +02:00
Jean-Marc Lasgouttes
f12e796999 Revert "Rename LM_TC_* to FONT_STYLE_*"
Got it wrong, revert for now.

This reverts commit 67215833a1.
2019-06-14 17:05:00 +02:00
Jean-Marc Lasgouttes
67215833a1 Rename LM_TC_* to FONT_STYLE_*
This makes code more uniform. This is typically something that is done
at end of cycle to limit backport issues later.
2019-06-14 16:42:02 +02:00
Enrico Forestieri
1cb2a443b5 Fix bug #11595
Avoid an endless loop when in the definition of a macro the macro
itself is used in the LyX representation part.
2019-06-09 22:36:59 +02:00
Jean-Marc Lasgouttes
d02244c8fb Make caret visible inside math macros arguments
The first step is to move the MathRow cache to BufferView, alongside
coordCache. This was on the todo list anyway, since it allows to let
go the math row information when the math equation is not on the
screen anymore. With the old scheme, it would always remain in memory.

Then, when computing caret size in MathData::metrics, make sure that
the mathrow of the elements that are linearized in the MathRow object
get their caret size information initialized too.

Fixes bug #11587.
2019-06-03 16:28:16 +02:00
Isaac
3519be2292 Removed shortcuts to toggle autocorrect.
They are not really needed now that autocorrection can be undone. This
increases autocorrect usability.
2019-06-03 11:09:09 +02:00
Jean-Marc Lasgouttes
64396717db Allow to undo partly math autocorrect
To this end, introduce Undo::splitUndoGroup, which ends currently
group and creates a new one with same nesting level.
2019-06-02 21:17:26 +02:00
Isaac
bed546d6f6 Make math autocorrrect work with more than 2 chars
Currently, math autocorrect allows to transform a couple of characters
to a new one. This patch allows to transform a couple (sequence,
character) to a new character.

No example are implemented right now. One possible idea would be
"--" + ">" => \longrightarrow
2019-06-02 21:12:12 +02:00
Enrico Forestieri
b3db2325ed Prefer mathmode commands over textmode ones
Translating → to \rightarrow in a \ce inset produces the right
glyph. Instead, translating it to \textrightarrow produces a
different glyph (β).
2019-05-26 13:06:44 +02:00
Enrico Forestieri
c8f056417f Use ranges 2019-05-26 12:31:02 +02:00
Enrico Forestieri
15f4fa452d Supplement the fix for bug #11586
The mhchem \ce inset is a text mode environment but allows entering
spaces and mathmode commands. However, even if it doesn't allow unicode
symbols, LyX allows entering them (by copy/paste, for example), causing
latex errors. As a unicode symbol may have a proper latex representation
from the unicodesymbols file, use it instead of the bare symbol. Here, we
don't care about the mode because both text and math mode should be allowed.
For example, the ⟶ symbol is not recognized but its latex representation
(\longrightarrow) is fine. Of course, there may be symbols that are
not recognized anyway, but this is better because they cause explicit
errors from mhchem instead of cryptic iconv errors in case they cannot
be represented in the document encoding.
2019-05-26 09:56:34 +02:00
Enrico Forestieri
bda3b799c5 Partial fix for bug #11586
Do not replace a latex command with the corresponding symbol
in the unicodesymbols file unless it can be encoded in the
document encoding.
2019-05-26 09:27:46 +02:00
Jean-Marc Lasgouttes
4da19ef833 Cell in delimiter inset should not be tight
Fixes bug #11337.
2019-05-25 14:11:39 +02:00
Enrico Forestieri
1a286c7910 Fix bug #10499
The array environment has to be explicitly parsed in math mode.
2019-05-18 11:36:07 +02:00
Jean-Marc Lasgouttes
175711046d Newly created inline math is not numbered
The bad initialisation created phantom entries in equation ToC

Fixes bug #11423.
2019-05-11 23:18:10 +02:00
Enrico Forestieri
2731c5dc55 Correctly protect macros with optionals inserted in an optional argument
The trick turns out to be inserting in braces the whole optional
argument, rather than the single macro.

See #11552 for the long history.
2019-04-26 15:30:08 +02:00
Enrico Forestieri
e763f90244 Revert [60ac25a4/lyxgit], [30f16463/lyxgit], and part of [e8f480e7/lyxgit]
As evidenced in #11552, at loading time there is no way to tell
whether braces were added by LyX with certainty. However, after
[503f7db2/lyxgit], LyX does not automatically removes brace insets.
So, in case one faces the problems mentioned in [e8f480e7/lyxgit],
the workaround of adding a brace inset now will not be frustrated.
In essence, after [503f7db2/lyxgit], the real fix for #11552 would
have been reverting the part in [e8f480e7/lyxgit] that was adding
the braces on output.
2019-04-26 12:34:29 +02:00
Enrico Forestieri
30f1646369 Write braces around macros only when actually needed
When a macro with optionals appeared inside the optional argument of
another one, the onscreen display and latex output were wrong. This
issue was addressed at [e8f480e7/lyxgit] by enclosing in braces macros
with optional arguments. However, this was done even when the macro
with optionals was in a non-optional argument of another macro.
This commit limits the bracing to the cases where it is really needed
and allows to address some particular issues evidenced in #11552.
2019-04-25 11:11:51 +02:00
Enrico Forestieri
60ac25a435 Yet another attempt at properly fixing #11552
This commit supercedes [54147a71/lyxgit] and [acba8476/lyxgit].
2019-04-24 17:28:53 +02:00