From: Jean-Marc Lasgouttes Date: Wed, 5 Jul 2017 12:31:28 +0000 (+0200) Subject: Rename some macro-related insets X-Git-Tag: 2.3.0beta1~204 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=29378af4;p=features.git Rename some macro-related insets These classes should have names that start with "Inset". Renaming done: MathMacro => InsetMathMacro MathMacroTemplate => InsetMathMacroTemplate MathMacroArgument => InsetMathMacroArgument ArgumentProxy => InsetArgumentProxy DisplayLabelBox => InsetDisplayLabelBox CommandInset => InsetMathCommand --- diff --git a/po/ar.po b/po/ar.po index f55211397b..07f97939b6 100644 --- a/po/ar.po +++ b/po/ar.po @@ -6686,7 +6686,7 @@ msgstr "خيارات الصورة في السيرة" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "الاسم" @@ -14954,7 +14954,7 @@ msgstr "قطرة" msgid "Drop up" msgstr "قطرة مقلوبة" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "تيك" @@ -24640,7 +24640,7 @@ msgid "Table (CSV)" msgstr "جدول (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "ليك" @@ -32586,25 +32586,25 @@ msgstr "الحجم: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "تعذر اضافة خطوط أفقية للشبكة في '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "ماكرو : %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "أختياري" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "مختصر رياضي" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "ماكرو رياضيات: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "ماكرو غير صالح! \\%1$s" diff --git a/po/bg.po b/po/bg.po index 71d229e412..a86667c158 100644 --- a/po/bg.po +++ b/po/bg.po @@ -8201,7 +8201,7 @@ msgstr "" #: lib/layouts/pdfcomment.module:57 lib/layouts/scrlettr.layout:116 #: lib/layouts/scrlttr2.layout:149 lib/layouts/sigplanconf.layout:84 #: lib/layouts/sigplanconf.layout:161 lib/layouts/tcolorbox.module:134 -#: src/frontends/qt4/GuiIndices.cpp:52 src/mathed/MathMacroTemplate.cpp:481 +#: src/frontends/qt4/GuiIndices.cpp:52 src/mathed/InsetMathMacroTemplate.cpp:481 msgid "Name" msgstr "Име" @@ -18459,7 +18459,7 @@ msgstr "" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:532 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:532 msgid "TeX" msgstr "TeX" @@ -30494,7 +30494,7 @@ msgstr "Дълга таблица" # src/frontends/kde/FormPrint.C:118 #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1326 -#: src/mathed/MathMacroTemplate.cpp:537 +#: src/mathed/InsetMathMacroTemplate.cpp:537 msgid "LyX" msgstr "LyX" @@ -39958,30 +39958,30 @@ msgid "Can't change horizontal alignment in '%1$s'" msgstr "Хориз. Подравняване(H)|#H" # src/mathed/formulamacro.C:144 src/mathed/formulamacro.C:171 -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr "Макрос: " # src/mathed/math_forms.C:152 -#: src/mathed/MathMacroTemplate.cpp:489 +#: src/mathed/InsetMathMacroTemplate.cpp:489 #, fuzzy msgid "optional" msgstr "Хориз. Подравняване(H)|#H" # src/LColor.C:81 -#: src/mathed/MathMacroTemplate.cpp:1270 +#: src/mathed/InsetMathMacroTemplate.cpp:1270 #, fuzzy msgid "math macro" msgstr "фон на математика" # src/LColor.C:81 -#: src/mathed/MathMacroTemplate.cpp:1377 +#: src/mathed/InsetMathMacroTemplate.cpp:1377 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "фон на математика" -#: src/mathed/MathMacroTemplate.cpp:1392 +#: src/mathed/InsetMathMacroTemplate.cpp:1392 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/ca.po b/po/ca.po index c105c39ad4..b9a0e47b13 100644 --- a/po/ca.po +++ b/po/ca.po @@ -7077,7 +7077,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nom" @@ -16013,7 +16013,7 @@ msgstr "" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -26372,7 +26372,7 @@ msgid "Table (CSV)" msgstr "Taula (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -34633,25 +34633,25 @@ msgstr "Comentari:" msgid "Can't change horizontal alignment in '%1$s'" msgstr "No es poden afegir línies horitzontals a %1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr "Paràmetre %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "opcional" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "macro matemàtica" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "macro matemàtica" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/cs.po b/po/cs.po index 28532e09f6..e994480f06 100644 --- a/po/cs.po +++ b/po/cs.po @@ -6813,7 +6813,7 @@ msgstr "Optional photo for biography" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Jméno" @@ -15336,7 +15336,7 @@ msgstr "Kapka (dolů)" msgid "Drop up" msgstr "Kapka (nahoru)" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25171,7 +25171,7 @@ msgid "Table (CSV)" msgstr "Tabulka (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33467,25 +33467,25 @@ msgstr "Prohlížet %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Nelze změnit horizontální zarovnání v '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Makro: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "volitelné" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "mat. makro" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Mat. makra" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/da.po b/po/da.po index 846855b022..5eadcafdec 100644 --- a/po/da.po +++ b/po/da.po @@ -6978,7 +6978,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Navn" @@ -16014,7 +16014,7 @@ msgstr "kasteskygge" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -26348,7 +26348,7 @@ msgid "Table (CSV)" msgstr "Tabel (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -34461,26 +34461,26 @@ msgstr "Vis %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Kan ikke ændre vandret justering i '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Makro: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 #, fuzzy msgid "optional" msgstr "valgfri" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "matematikmakro" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Matematikmakroer" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/de.po b/po/de.po index a6f26c53a6..ef3ac871ed 100644 --- a/po/de.po +++ b/po/de.po @@ -6918,7 +6918,7 @@ msgstr "Optionales Foto für die Biografie" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Name" @@ -15204,7 +15204,7 @@ msgstr "Tropfen abwärts" msgid "Drop up" msgstr "Tropfen aufwärts" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -24920,7 +24920,7 @@ msgid "Table (CSV)" msgstr "Tabelle (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33371,25 +33371,25 @@ msgstr "Größe: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Die horizontale Ausrichtung kann in '%1$s' nicht geändert werden" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "Makro: %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "optional" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "Mathe-Makro" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "Mathe-Makro: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "Ungültiges Makro! \\%1$s" diff --git a/po/el.po b/po/el.po index 033fcaaabf..cdf8c9adaf 100644 --- a/po/el.po +++ b/po/el.po @@ -6952,7 +6952,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Όνομα" @@ -15731,7 +15731,7 @@ msgstr "Ρίψη σκιάς" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "" @@ -25674,7 +25674,7 @@ msgid "Table (CSV)" msgstr "Πίνακας (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "" @@ -33938,25 +33938,25 @@ msgstr "Προβολή %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Δεν είναι δυνατή η προσθήκη οριζόντιων γραμμών πλέγματος στο '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Μακροεντολή: %1$s:" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "προαιρετικό" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "μακροεντολή μαθηματικών" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Μαθηματικές Μακροεντολές" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/en.po b/po/en.po index 8722b0b7f7..60b889c0c9 100644 --- a/po/en.po +++ b/po/en.po @@ -6575,7 +6575,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "" @@ -14734,7 +14734,7 @@ msgstr "" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "" @@ -24303,7 +24303,7 @@ msgid "Table (CSV)" msgstr "" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "" @@ -31941,25 +31941,25 @@ msgstr "" msgid "Can't change horizontal alignment in '%1$s'" msgstr "" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/es.po b/po/es.po index ea96ea3de2..396e63bb04 100644 --- a/po/es.po +++ b/po/es.po @@ -6806,7 +6806,7 @@ msgstr "Optional photo for biography" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nombre" @@ -15160,7 +15160,7 @@ msgstr "Gota" msgid "Drop up" msgstr "Gota invertida" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -24929,7 +24929,7 @@ msgid "Table (CSV)" msgstr "Cuadro (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33286,25 +33286,25 @@ msgstr "Tamaño: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "No se puede cambiar la alineación horizontal en '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr " Macro: %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "opcional" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "macro de ecuación" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "Macro de ecuación: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "¡Macro no válida! \\%1$s" diff --git a/po/eu.po b/po/eu.po index aa879d37b0..98e0ccda6b 100644 --- a/po/eu.po +++ b/po/eu.po @@ -6893,7 +6893,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Izena" @@ -15671,7 +15671,7 @@ msgstr "Jaregin itzala" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25775,7 +25775,7 @@ msgid "Table (CSV)" msgstr "Taula (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -34158,25 +34158,25 @@ msgstr "Ikusi %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Ezin da lerrokadura horizontalik aldatu '%1$s'(e)n" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Makroa: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "aukerakoa" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "mat. makroa" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Mat. makroak" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/fi.po b/po/fi.po index fc535bc907..4bd16d1eaf 100644 --- a/po/fi.po +++ b/po/fi.po @@ -6792,7 +6792,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nimi" @@ -15434,7 +15434,7 @@ msgstr "" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25371,7 +25371,7 @@ msgid "Table (CSV)" msgstr "Taulukko (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33446,25 +33446,25 @@ msgstr "Koko: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "En voi lisätä vaakaviivat kohteeseen '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "Makro: %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "valinnainen" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "matematiikamakro" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "Matematiikkamakro: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "Virheellinen makro! \\%1$s" diff --git a/po/fr.po b/po/fr.po index 4a1ccc3e85..48f2bd966a 100644 --- a/po/fr.po +++ b/po/fr.po @@ -7148,7 +7148,7 @@ msgstr "Photo facultative pour la biographie" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nom" @@ -15509,7 +15509,7 @@ msgstr "Goutte d'eau" msgid "Drop up" msgstr "Goutte inversée" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25233,7 +25233,7 @@ msgid "Table (CSV)" msgstr "Tableau (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33615,25 +33615,25 @@ msgstr "Taille : %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Impossible de modifier l'alignement horizontal dans « %1$s »" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "Macro : %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "optionnel" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "macro mathématique" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "Macros mathématique : \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "Macro mathématique invalide ! \\%1$s" diff --git a/po/gl.po b/po/gl.po index 4d080d8465..781b6d763c 100644 --- a/po/gl.po +++ b/po/gl.po @@ -7101,7 +7101,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nome" @@ -16040,7 +16040,7 @@ msgstr "" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -26456,7 +26456,7 @@ msgid "Table (CSV)" msgstr "Táboa" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -34935,26 +34935,26 @@ msgstr "Fonte: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Non é posíbel engadir liñas de cuadrícula horizontal en '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Macro: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 #, fuzzy msgid "optional" msgstr "Horizontal" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "macro matemática" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "macro matemática" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/he.po b/po/he.po index cfd1a3e23c..bc34747d2c 100644 --- a/po/he.po +++ b/po/he.po @@ -6835,7 +6835,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "שם" @@ -15723,7 +15723,7 @@ msgstr "הפל צל" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25705,7 +25705,7 @@ msgid "Table (CSV)" msgstr "טבלה (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33865,25 +33865,25 @@ msgstr "גופן: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "לא יכול לשנות יישור אופקי בתוך '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr "מאקרו: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "אופציונלי" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "מאקרו מתמטיקה" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "מקרו מתמטיים" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, fuzzy, c-format msgid "Invalid macro! \\%1$s" msgstr "מקרו מתמטיים" diff --git a/po/hu.po b/po/hu.po index 43f28d4b23..c73ac39f8b 100644 --- a/po/hu.po +++ b/po/hu.po @@ -6905,7 +6905,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Név" @@ -15700,7 +15700,7 @@ msgstr "Árnyék megszüntetése" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25906,7 +25906,7 @@ msgid "Table (CSV)" msgstr "Táblázat (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -34323,25 +34323,25 @@ msgstr "Betűkészlet: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Nem tudok vízszintes rácsvonalat adni '%1$s'-hoz" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Makró: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "opcionális" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "képlet makró" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Képlet makrók" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/ia.po b/po/ia.po index 19415872ab..6d3457709c 100644 --- a/po/ia.po +++ b/po/ia.po @@ -6807,7 +6807,7 @@ msgstr "Photo optional pro biographia" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nomine" @@ -15164,7 +15164,7 @@ msgstr "Disrola" msgid "Drop up" msgstr "Rola in alto" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -24931,7 +24931,7 @@ msgid "Table (CSV)" msgstr "Tabella (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33301,25 +33301,25 @@ msgstr "Grandor: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Non pote modificar le alineamento horizontal in '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "Macro: %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "optional" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "macro mathematic" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "Macro mat.: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "Macro non valide! \\%1$s" diff --git a/po/id.po b/po/id.po index 992543f7ea..5ca1799100 100644 --- a/po/id.po +++ b/po/id.po @@ -6863,7 +6863,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nama" @@ -15636,7 +15636,7 @@ msgstr "Bingkai bayangan" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25583,7 +25583,7 @@ msgid "Table (CSV)" msgstr "Tabel (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33957,25 +33957,25 @@ msgstr "Tampilkan %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Tidak bisa merubah perataan horisontal di '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Makro: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "tambahan" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "makro matematika" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Makro Matematika" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/it.po b/po/it.po index 86a73070e0..8bb3e0da79 100644 --- a/po/it.po +++ b/po/it.po @@ -6733,7 +6733,7 @@ msgstr "Foto opzionale per la biografia" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nome" @@ -15003,7 +15003,7 @@ msgstr "Drop down" msgid "Drop up" msgstr "Drop up" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -24705,7 +24705,7 @@ msgid "Table (CSV)" msgstr "Tabella (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33023,25 +33023,25 @@ msgstr "Dimensione: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Non si può modificare l'allineamento orizzontale in '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "Macro: %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "opzionale" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "macro matematica" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "Macro mat.: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "Macro non valida! \\%1$s" diff --git a/po/ja.po b/po/ja.po index 59acc50b83..bae4d1504e 100644 --- a/po/ja.po +++ b/po/ja.po @@ -6725,7 +6725,7 @@ msgstr "経歴用の非必須写真" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "名前" @@ -15032,7 +15032,7 @@ msgstr "雫形" msgid "Drop up" msgstr "逆雫形" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -24723,7 +24723,7 @@ msgid "Table (CSV)" msgstr "表(CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33014,25 +33014,25 @@ msgstr "寸法: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "「%1$s」の水平揃えを変更することができません." -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "マクロ: %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "非必須" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "数式マクロ" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "数式マクロ: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "無効なマクロ!\\%1$s" diff --git a/po/ko.po b/po/ko.po index febc114ed2..f88b52c7cd 100644 --- a/po/ko.po +++ b/po/ko.po @@ -6569,7 +6569,7 @@ msgstr "" #: lib/layouts/pdfcomment.module:57 lib/layouts/scrlettr.layout:116 #: lib/layouts/scrlttr2.layout:149 lib/layouts/sigplanconf.layout:84 #: lib/layouts/sigplanconf.layout:161 lib/layouts/tcolorbox.module:134 -#: src/frontends/qt4/GuiIndices.cpp:52 src/mathed/MathMacroTemplate.cpp:481 +#: src/frontends/qt4/GuiIndices.cpp:52 src/mathed/InsetMathMacroTemplate.cpp:481 msgid "Name" msgstr "" @@ -14783,7 +14783,7 @@ msgstr "" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:532 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:532 msgid "TeX" msgstr "TeX" @@ -24771,7 +24771,7 @@ msgid "Table (CSV)" msgstr "" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1326 -#: src/mathed/MathMacroTemplate.cpp:537 +#: src/mathed/InsetMathMacroTemplate.cpp:537 msgid "LyX" msgstr "LyX" @@ -32582,25 +32582,25 @@ msgstr "%1$s 보기" msgid "Can't change horizontal alignment in '%1$s'" msgstr "" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr "글꼴: %1$s" -#: src/mathed/MathMacroTemplate.cpp:489 +#: src/mathed/InsetMathMacroTemplate.cpp:489 msgid "optional" msgstr "" -#: src/mathed/MathMacroTemplate.cpp:1270 +#: src/mathed/InsetMathMacroTemplate.cpp:1270 msgid "math macro" msgstr "수식 매크로" -#: src/mathed/MathMacroTemplate.cpp:1377 +#: src/mathed/InsetMathMacroTemplate.cpp:1377 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "수식 매크로" -#: src/mathed/MathMacroTemplate.cpp:1392 +#: src/mathed/InsetMathMacroTemplate.cpp:1392 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/nb.po b/po/nb.po index aaab2fc834..cbc8429153 100644 --- a/po/nb.po +++ b/po/nb.po @@ -6741,7 +6741,7 @@ msgstr "Frivillig foto for biografi" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Navn" @@ -15137,7 +15137,7 @@ msgstr "DrÃ¥pe ned" msgid "Drop up" msgstr "DrÃ¥pe opp" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -24910,7 +24910,7 @@ msgid "Table (CSV)" msgstr "Tabell (kommaseparert)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33194,25 +33194,25 @@ msgstr "Størrelse: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Kan ikke endre vannrett justering i '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "Makro: %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "valgfri" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "mattemakro" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "Mattemakro: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "Ugyldig makro! \\%1$s" diff --git a/po/nl.po b/po/nl.po index 9a57e2bfbb..8de137986a 100644 --- a/po/nl.po +++ b/po/nl.po @@ -6927,7 +6927,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "" @@ -15642,7 +15642,7 @@ msgstr "Schaduw" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25717,7 +25717,7 @@ msgid "Table (CSV)" msgstr "Tabel (komma-gescheiden)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33609,25 +33609,25 @@ msgstr "%1$s weergeven" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Kan horizontale uitlijning van '%1$s' niet veranderen" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Macro: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "optioneel" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "math macro" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Formule-macros" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/nn.po b/po/nn.po index e0c6ed2e29..1790a25aee 100644 --- a/po/nn.po +++ b/po/nn.po @@ -6807,7 +6807,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Namn" @@ -15508,7 +15508,7 @@ msgstr "Kastar skugge" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25538,7 +25538,7 @@ msgid "Table (CSV)" msgstr "Tabell (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33820,25 +33820,25 @@ msgstr "SjÃ¥ %1$s." msgid "Can't change horizontal alignment in '%1$s'" msgstr "Kan ikkje endre vassrettjustering i '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr "Makro: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "valfritt" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "mattemakroar" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Mattemakroar" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/pl.po b/po/pl.po index c6aa6d35c8..6672dbc606 100644 --- a/po/pl.po +++ b/po/pl.po @@ -6879,7 +6879,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nazwa" @@ -15655,7 +15655,7 @@ msgstr "Rzuca cień" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25703,7 +25703,7 @@ msgid "Table (CSV)" msgstr "Tabela (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -34045,25 +34045,25 @@ msgstr "Podgląd %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Nie można zmienić poziomego wyrównania w '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr "Makro: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "opcjonalne" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "makro matematyczne" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Makra matematyczne" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/pt_BR.po b/po/pt_BR.po index 8fd4f07647..73f5876c91 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -6811,7 +6811,7 @@ msgstr "Foto opcional para a biografia" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nome" @@ -15157,7 +15157,7 @@ msgstr "Gota" msgid "Drop up" msgstr "Gota Invertida" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -24897,7 +24897,7 @@ msgid "Table (CSV)" msgstr "Tabela (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33252,25 +33252,25 @@ msgstr "Tamanho: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Não é possível alterar alinhamento horizontal em '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "Macro: %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "opcional" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "macro de matemática" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "Macro de Matemática: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "Macro inválida! \\%1$s" diff --git a/po/pt_PT.po b/po/pt_PT.po index 2bbf297b60..4f35b26f7c 100644 --- a/po/pt_PT.po +++ b/po/pt_PT.po @@ -6871,7 +6871,7 @@ msgstr "Foto opcional para a biografia" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nome" @@ -15415,7 +15415,7 @@ msgstr "Gota" msgid "Drop up" msgstr "Gota Invertida" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25224,7 +25224,7 @@ msgid "Table (CSV)" msgstr "Tabela (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33568,25 +33568,25 @@ msgstr "View %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Não é possível alterar alinhamento horizontal em '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Macro: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "Opcional" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "macro mat." -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Macros Mat." -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/ro.po b/po/ro.po index d31d188c9e..754c8f67e0 100644 --- a/po/ro.po +++ b/po/ro.po @@ -7044,7 +7044,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Nume" @@ -15906,7 +15906,7 @@ msgstr "" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -26277,7 +26277,7 @@ msgid "Table (CSV)" msgstr "Tabel (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -34679,27 +34679,27 @@ msgstr "Mărime font" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Aliniere orizontală în coloană" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Macro: %s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 #, fuzzy msgid "optional" msgstr "&Orizontal:" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 #, fuzzy msgid "math macro" msgstr "fundal mod matematic" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Macrouri matematice" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/ru.po b/po/ru.po index 3337eca43e..c881fb6eed 100644 --- a/po/ru.po +++ b/po/ru.po @@ -7047,7 +7047,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Название" @@ -16183,7 +16183,7 @@ msgstr "Отбрасывать тень" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -26512,7 +26512,7 @@ msgid "Table (CSV)" msgstr "Таблица (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -35016,25 +35016,25 @@ msgstr "Шрифт: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Невозможно добавить горизонтальные линии в '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Макрокоманда: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "необязательное" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "матемематическая макрокоманда" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Математические макрокоманды" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/sk.po b/po/sk.po index 682e01b266..40cae678a1 100644 --- a/po/sk.po +++ b/po/sk.po @@ -6754,7 +6754,7 @@ msgstr "Voliteľná fotka do životopisu" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:481 +#: src/mathed/InsetMathMacroTemplate.cpp:481 msgid "Name" msgstr "Meno" @@ -15015,7 +15015,7 @@ msgstr "Kvapka nadol" msgid "Drop up" msgstr "Kvapka nahor" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:532 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:532 msgid "TeX" msgstr "TeX" @@ -24722,7 +24722,7 @@ msgid "Table (CSV)" msgstr "Tabuľka (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1326 -#: src/mathed/MathMacroTemplate.cpp:537 +#: src/mathed/InsetMathMacroTemplate.cpp:537 msgid "LyX" msgstr "LyX" @@ -32998,25 +32998,25 @@ msgstr "VeľkosÅ¥: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Nedá sa zmeniÅ¥ horizontálna adjustácia v '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "Makro: %1$s" -#: src/mathed/MathMacroTemplate.cpp:489 +#: src/mathed/InsetMathMacroTemplate.cpp:489 msgid "optional" msgstr "voliteľné" -#: src/mathed/MathMacroTemplate.cpp:1270 +#: src/mathed/InsetMathMacroTemplate.cpp:1270 msgid "math macro" msgstr "mat. makro" -#: src/mathed/MathMacroTemplate.cpp:1377 +#: src/mathed/InsetMathMacroTemplate.cpp:1377 #, c-format msgid "Math Macro: \\%1$s" msgstr "Mat. Makro: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1392 +#: src/mathed/InsetMathMacroTemplate.cpp:1392 #, c-format msgid "Invalid macro! \\%1$s" msgstr "Neplatné makro! \\%1$s" diff --git a/po/sl.po b/po/sl.po index 3f35cc5eec..858a2de6a6 100644 --- a/po/sl.po +++ b/po/sl.po @@ -7074,7 +7074,7 @@ msgstr "" #: lib/layouts/pdfcomment.module:57 lib/layouts/scrlettr.layout:116 #: lib/layouts/scrlttr2.layout:149 lib/layouts/sigplanconf.layout:84 #: lib/layouts/sigplanconf.layout:161 lib/layouts/tcolorbox.module:134 -#: src/frontends/qt4/GuiIndices.cpp:52 src/mathed/MathMacroTemplate.cpp:481 +#: src/frontends/qt4/GuiIndices.cpp:52 src/mathed/InsetMathMacroTemplate.cpp:481 msgid "Name" msgstr "Ime" @@ -15900,7 +15900,7 @@ msgstr "" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:532 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:532 #, fuzzy msgid "TeX" msgstr "LaTeX" @@ -26528,7 +26528,7 @@ msgid "Table (CSV)" msgstr "Tabela" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1326 -#: src/mathed/MathMacroTemplate.cpp:537 +#: src/mathed/InsetMathMacroTemplate.cpp:537 msgid "LyX" msgstr "LyX" @@ -34825,27 +34825,27 @@ msgstr "Pisava: " msgid "Can't change horizontal alignment in '%1$s'" msgstr "Vodoravna poravnava v stolpcu" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Makroukaz: %s: " -#: src/mathed/MathMacroTemplate.cpp:489 +#: src/mathed/InsetMathMacroTemplate.cpp:489 #, fuzzy msgid "optional" msgstr "&Vodoravno:" -#: src/mathed/MathMacroTemplate.cpp:1270 +#: src/mathed/InsetMathMacroTemplate.cpp:1270 #, fuzzy msgid "math macro" msgstr "ozadje matematike" -#: src/mathed/MathMacroTemplate.cpp:1377 +#: src/mathed/InsetMathMacroTemplate.cpp:1377 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "ozadje matematike" -#: src/mathed/MathMacroTemplate.cpp:1392 +#: src/mathed/InsetMathMacroTemplate.cpp:1392 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/sr.po b/po/sr.po index e901b2b99f..6b132599bb 100644 --- a/po/sr.po +++ b/po/sr.po @@ -6926,7 +6926,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Ime" @@ -15673,7 +15673,7 @@ msgstr "" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25827,7 +25827,7 @@ msgid "Table (CSV)" msgstr "" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33770,25 +33770,25 @@ msgstr "Font: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Ne mogu da promenim broj kolona u '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Makro: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "mat makro" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Matematički Makroi" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/sv.po b/po/sv.po index 96a86a4ec9..d57cef6096 100644 --- a/po/sv.po +++ b/po/sv.po @@ -6968,7 +6968,7 @@ msgstr "Valfritt foto för biografi" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Namn" @@ -15292,7 +15292,7 @@ msgstr "Droppe ned" msgid "Drop up" msgstr "Droppe upp" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -24997,7 +24997,7 @@ msgid "Table (CSV)" msgstr "Tabell (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33290,25 +33290,25 @@ msgstr "Storlek: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Kan inte ändra horisontell justering i '%1$s'" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "Makro: %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "valfri" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "matematikmakro" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "Matematikmakro: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "Ogiltigt makro! \\%1$s" diff --git a/po/tr.po b/po/tr.po index cfe1f2ee0e..555be928ae 100644 --- a/po/tr.po +++ b/po/tr.po @@ -6988,7 +6988,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Ad" @@ -15818,7 +15818,7 @@ msgstr "Gölgeyi Bırak|G" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -26061,7 +26061,7 @@ msgid "Table (CSV)" msgstr "Tablo (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -34299,25 +34299,25 @@ msgstr "Font: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "'%1$s' e yatay ızgara çizgileri eklenemiyor" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " Makro: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "seçimlik" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "matematik makrosu" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Matematik Makroları" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/uk.po b/po/uk.po index ca357985f5..1c00b17b48 100644 --- a/po/uk.po +++ b/po/uk.po @@ -6805,7 +6805,7 @@ msgstr "Необов’язкова фотографія до біографії #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "Назва" @@ -15147,7 +15147,7 @@ msgstr "Крапля вниз" msgid "Drop up" msgstr "Крапля вгору" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -24863,7 +24863,7 @@ msgid "Table (CSV)" msgstr "Таблиця (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33199,25 +33199,25 @@ msgstr "Розмір: %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "Не вдалося змінити горизонтальне вирівнювання у «%1$s»" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, c-format msgid "Macro: %1$s" msgstr "Макрос: %1$s" -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "необов'язковий" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "математичний макрос" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, c-format msgid "Math Macro: \\%1$s" msgstr "Математичний макрос: \\%1$s" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "Некоректний макрос! \\%1$s" diff --git a/po/wa.po b/po/wa.po index 09d32554ad..c0f1935558 100644 --- a/po/wa.po +++ b/po/wa.po @@ -7241,7 +7241,7 @@ msgstr "" #: lib/layouts/pdfcomment.module:57 lib/layouts/scrlettr.layout:116 #: lib/layouts/scrlttr2.layout:149 lib/layouts/sigplanconf.layout:84 #: lib/layouts/sigplanconf.layout:161 lib/layouts/tcolorbox.module:134 -#: src/frontends/qt4/GuiIndices.cpp:52 src/mathed/MathMacroTemplate.cpp:481 +#: src/frontends/qt4/GuiIndices.cpp:52 src/mathed/InsetMathMacroTemplate.cpp:481 #, fuzzy msgid "Name" msgstr "No:|#N" @@ -16120,7 +16120,7 @@ msgstr "" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:532 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:532 #, fuzzy msgid "TeX" msgstr "LaTeX|#L" @@ -26766,7 +26766,7 @@ msgid "Table (CSV)" msgstr "TÃ¥vlea%t" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1326 -#: src/mathed/MathMacroTemplate.cpp:537 +#: src/mathed/InsetMathMacroTemplate.cpp:537 msgid "LyX" msgstr "LyX" @@ -35083,27 +35083,27 @@ msgstr "Fonte: " msgid "Can't change horizontal alignment in '%1$s'" msgstr "Aroymint di coûtchî|#c" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr "Fonte: " -#: src/mathed/MathMacroTemplate.cpp:489 +#: src/mathed/InsetMathMacroTemplate.cpp:489 #, fuzzy msgid "optional" msgstr "Aroymint di coûtchî|#c" -#: src/mathed/MathMacroTemplate.cpp:1270 +#: src/mathed/InsetMathMacroTemplate.cpp:1270 #, fuzzy msgid "math macro" msgstr "Sititchî ene etikete" -#: src/mathed/MathMacroTemplate.cpp:1377 +#: src/mathed/InsetMathMacroTemplate.cpp:1377 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "Sititchî ene etikete" -#: src/mathed/MathMacroTemplate.cpp:1392 +#: src/mathed/InsetMathMacroTemplate.cpp:1392 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/zh_CN.po b/po/zh_CN.po index d626a220b5..4b3fd690f5 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -6896,7 +6896,7 @@ msgstr "" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "名字" @@ -15761,7 +15761,7 @@ msgstr "阴影" msgid "Drop up" msgstr "" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX" @@ -25963,7 +25963,7 @@ msgid "Table (CSV)" msgstr "表格 (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -34251,25 +34251,25 @@ msgstr "查看 %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "无法改变 '%1$s' 的水平对齐" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr "宏:%1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "可选" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "数学宏" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "数学宏" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/po/zh_TW.po b/po/zh_TW.po index 1d31416ed0..ca395d04b9 100644 --- a/po/zh_TW.po +++ b/po/zh_TW.po @@ -6866,7 +6866,7 @@ msgstr "傳記用的選項照片" #: lib/layouts/scrlettr.layout:116 lib/layouts/scrlttr2.layout:149 #: lib/layouts/sigplanconf.layout:84 lib/layouts/sigplanconf.layout:161 #: lib/layouts/tcolorbox.module:134 src/frontends/qt4/GuiIndices.cpp:52 -#: src/mathed/MathMacroTemplate.cpp:493 +#: src/mathed/InsetMathMacroTemplate.cpp:493 msgid "Name" msgstr "名稱" @@ -15374,7 +15374,7 @@ msgstr "Drop down 下滴形水滴" msgid "Drop up" msgstr "Drop up 上滴形水滴" -#: lib/layouts/shapepar.module:91 src/mathed/MathMacroTemplate.cpp:544 +#: lib/layouts/shapepar.module:91 src/mathed/InsetMathMacroTemplate.cpp:544 msgid "TeX" msgstr "TeX 符號" @@ -25174,7 +25174,7 @@ msgid "Table (CSV)" msgstr "Table (CSV)" #: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327 -#: src/mathed/MathMacroTemplate.cpp:549 +#: src/mathed/InsetMathMacroTemplate.cpp:549 msgid "LyX" msgstr "LyX" @@ -33344,25 +33344,25 @@ msgstr "檢視 %1$s" msgid "Can't change horizontal alignment in '%1$s'" msgstr "無法在「%1$s」中變更水平對齊" -#: src/mathed/MathMacro.cpp:1212 src/mathed/MathMacro.cpp:1218 +#: src/mathed/InsetMathMacro.cpp:1212 src/mathed/InsetMathMacro.cpp:1218 #, fuzzy, c-format msgid "Macro: %1$s" msgstr " 巨集: %1$s: " -#: src/mathed/MathMacroTemplate.cpp:501 +#: src/mathed/InsetMathMacroTemplate.cpp:501 msgid "optional" msgstr "選項" -#: src/mathed/MathMacroTemplate.cpp:1282 +#: src/mathed/InsetMathMacroTemplate.cpp:1282 msgid "math macro" msgstr "數學巨集" -#: src/mathed/MathMacroTemplate.cpp:1389 +#: src/mathed/InsetMathMacroTemplate.cpp:1389 #, fuzzy, c-format msgid "Math Macro: \\%1$s" msgstr "數學巨集" -#: src/mathed/MathMacroTemplate.cpp:1404 +#: src/mathed/InsetMathMacroTemplate.cpp:1404 #, c-format msgid "Invalid macro! \\%1$s" msgstr "" diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 5e2057ac5b..df7efa8f0c 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -76,7 +76,7 @@ #include "mathed/InsetMathHull.h" #include "mathed/MacroTable.h" -#include "mathed/MathMacroTemplate.h" +#include "mathed/InsetMathMacroTemplate.h" #include "mathed/MathSupport.h" #include "graphics/GraphicsCache.h" @@ -3598,7 +3598,7 @@ void Buffer::Impl::updateMacros(DocIterator & it, DocIterator & scope) continue; // get macro data - MathMacroTemplate & macroTemplate = + InsetMathMacroTemplate & macroTemplate = *iit->inset->asInsetMath()->asMacroTemplate(); MacroContext mc(owner_, it); macroTemplate.updateToContext(mc); @@ -3748,7 +3748,7 @@ void Buffer::listParentMacros(MacroSet & macros, LaTeXFeatures & features) const if (data) { macros.insert(data); - // we cannot access the original MathMacroTemplate anymore + // we cannot access the original InsetMathMacroTemplate anymore // here to calls validate method. So we do its work here manually. // FIXME: somehow make the template accessible here. if (data->optionals() > 0) diff --git a/src/Cursor.cpp b/src/Cursor.cpp index eff32d0576..1223782c35 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -53,7 +53,7 @@ #include "mathed/MacroTable.h" #include "mathed/MathData.h" #include "mathed/MathFactory.h" -#include "mathed/MathMacro.h" +#include "mathed/InsetMathMacro.h" #include #include @@ -1431,12 +1431,12 @@ bool Cursor::macroModeClose() if (in && in->interpretString(*this, s)) return true; bool const user_macro = buffer()->getMacro(name, *this, false); - MathAtom atom = user_macro ? MathAtom(new MathMacro(buffer(), name)) + MathAtom atom = user_macro ? MathAtom(new InsetMathMacro(buffer(), name)) : createInsetMath(name, buffer()); // try to put argument into macro, if we just inserted a macro bool macroArg = false; - MathMacro * atomAsMacro = atom.nucleus()->asMacro(); + InsetMathMacro * atomAsMacro = atom.nucleus()->asMacro(); if (atomAsMacro) { // macros here are still unfolded (in init mode in fact). So // we have to resolve the macro here manually and check its arity @@ -1444,10 +1444,10 @@ bool Cursor::macroModeClose() MacroData const * data = buffer()->getMacro(atomAsMacro->name()); if (!selection.empty() && data && data->numargs() - data->optionals() > 0) { macroArg = true; - atomAsMacro->setDisplayMode(MathMacro::DISPLAY_INTERACTIVE_INIT, 1); + atomAsMacro->setDisplayMode(InsetMathMacro::DISPLAY_INTERACTIVE_INIT, 1); } else // non-greedy case. Do not touch the arguments behind - atomAsMacro->setDisplayMode(MathMacro::DISPLAY_INTERACTIVE_INIT, 0); + atomAsMacro->setDisplayMode(InsetMathMacro::DISPLAY_INTERACTIVE_INIT, 0); } // insert remembered selection into first argument of a non-macro diff --git a/src/CursorSlice.cpp b/src/CursorSlice.cpp index 76049a0541..c5be12f500 100644 --- a/src/CursorSlice.cpp +++ b/src/CursorSlice.cpp @@ -23,7 +23,7 @@ #include "insets/Inset.h" #include "mathed/InsetMath.h" -#include "mathed/MathMacro.h" +#include "mathed/InsetMathMacro.h" #include "support/ExceptionMessage.h" #include "support/gettext.h" diff --git a/src/Makefile.am b/src/Makefile.am index 5bf8f3bd5e..9bc6b19770 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -393,7 +393,6 @@ liblyxgraphics_a_SOURCES = \ noinst_LIBRARIES += liblyxmathed.a SOURCEFILESMATHED = \ - mathed/CommandInset.cpp \ mathed/InsetMathAMSArray.cpp \ mathed/InsetMathArray.cpp \ mathed/InsetMathBig.cpp \ @@ -407,6 +406,7 @@ SOURCEFILESMATHED = \ mathed/InsetMathChar.cpp \ mathed/InsetMathClass.cpp \ mathed/InsetMathColor.cpp \ + mathed/InsetMathCommand.cpp \ mathed/InsetMathComment.cpp \ mathed/InsetMathDecoration.cpp \ mathed/InsetMathDecoration.h \ @@ -425,6 +425,9 @@ SOURCEFILESMATHED = \ mathed/InsetMathKern.cpp \ mathed/InsetMathLefteqn.cpp \ mathed/InsetMathLim.cpp \ + mathed/InsetMathMacro.cpp \ + mathed/InsetMathMacroArgument.cpp \ + mathed/InsetMathMacroTemplate.cpp \ mathed/InsetMathMatrix.cpp \ mathed/InsetMathNest.cpp \ mathed/InsetMathNumber.cpp \ @@ -457,9 +460,6 @@ SOURCEFILESMATHED = \ mathed/MathData.cpp \ mathed/MathExtern.cpp \ mathed/MathFactory.cpp \ - mathed/MathMacro.cpp \ - mathed/MathMacroArgument.cpp \ - mathed/MathMacroTemplate.cpp \ mathed/MathParser.cpp \ mathed/MathRow.cpp \ mathed/MathStream.cpp \ @@ -467,7 +467,6 @@ SOURCEFILESMATHED = \ mathed/TextPainter.cpp HEADERFILESMATHED = \ - mathed/CommandInset.h \ mathed/InsetMathAMSArray.h \ mathed/InsetMathArray.h \ mathed/InsetMathBig.h \ @@ -480,6 +479,7 @@ HEADERFILESMATHED = \ mathed/InsetMathChar.h \ mathed/InsetMathClass.h \ mathed/InsetMathColor.h \ + mathed/InsetMathCommand.h \ mathed/InsetMathComment.h \ mathed/InsetMathDelim.h \ mathed/InsetMathDiff.h \ @@ -497,6 +497,9 @@ HEADERFILESMATHED = \ mathed/InsetMathKern.h \ mathed/InsetMathLefteqn.h \ mathed/InsetMathLim.h \ + mathed/InsetMathMacro.h \ + mathed/InsetMathMacroArgument.h \ + mathed/InsetMathMacroTemplate.h \ mathed/InsetMathMatrix.h \ mathed/InsetMathNest.h \ mathed/InsetMathNumber.h \ @@ -529,10 +532,7 @@ HEADERFILESMATHED = \ mathed/MathCompletionList.h \ mathed/MathExtern.h \ mathed/MathFactory.h \ - mathed/MathMacro.h \ - mathed/MathMacroArgument.h \ mathed/MacroTable.h \ - mathed/MathMacroTemplate.h \ mathed/MathParser.h \ mathed/MathParser_flags.h \ mathed/MathRow.h \ diff --git a/src/Text3.cpp b/src/Text3.cpp index e8e433587f..364e91c1dc 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -78,7 +78,7 @@ #include "support/regex.h" #include "mathed/InsetMathHull.h" -#include "mathed/MathMacroTemplate.h" +#include "mathed/InsetMathMacroTemplate.h" #include #include @@ -2044,7 +2044,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) // don't pass "on" as argument // (it would appear literally in the first cell) docstring sel = cur.selectionAsString(false); - MathMacroTemplate * macro = new MathMacroTemplate(cur.buffer()); + InsetMathMacroTemplate * macro = new InsetMathMacroTemplate(cur.buffer()); // create a macro template if we see "\\newcommand" somewhere, and // an ordinary formula otherwise if (!sel.empty() @@ -2080,7 +2080,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) MacroType type = MacroTypeNewcommand; if (s2 == "def") type = MacroTypeDef; - MathMacroTemplate * inset = new MathMacroTemplate(cur.buffer(), + InsetMathMacroTemplate * inset = new InsetMathMacroTemplate(cur.buffer(), from_utf8(token(s, ' ', 0)), nargs, false, type); inset->setBuffer(bv->buffer()); insertInset(cur, inset); diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index f38c78d3ea..0967dacfd2 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -39,7 +39,7 @@ #include "insets/InsetText.h" -#include "mathed/MathMacroTemplate.h" +#include "mathed/InsetMathMacroTemplate.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" diff --git a/src/factory.cpp b/src/factory.cpp index 7ec34fc8e3..72019cd6f7 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -59,7 +59,7 @@ #include "insets/InsetVSpace.h" #include "insets/InsetWrap.h" -#include "mathed/MathMacroTemplate.h" +#include "mathed/InsetMathMacroTemplate.h" #include "mathed/InsetMathHull.h" #include "frontends/alert.h" @@ -606,7 +606,7 @@ Inset * readInset(Lexer & lex, Buffer * buf) } else if (tmptok == "External") { inset.reset(new InsetExternal(buf)); } else if (tmptok == "FormulaMacro") { - inset.reset(new MathMacroTemplate(buf)); + inset.reset(new InsetMathMacroTemplate(buf)); } else if (tmptok == "Formula") { inset.reset(new InsetMathHull(buf)); } else if (tmptok == "Graphics") { diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index 2190be7056..b458c8181b 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -414,7 +414,7 @@ bool Inset::getStatus(Cursor &, FuncRequest const & cmd, } case LFUN_IN_MATHMACROTEMPLATE: - // By default we're not in a MathMacroTemplate inset + // By default we're not in a InsetMathMacroTemplate inset flag.setEnabled(false); return true; diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index a426db034a..bb4f234b9d 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -178,7 +178,7 @@ private: /// a substatus of the Open status, determined automatically in metrics bool openinlined_; /// the inset will automatically open when the cursor is inside. This is - /// dependent on the bufferview, compare with MathMacro::editing_. + /// dependent on the bufferview, compare with InsetMathMacro::editing_. bool auto_open_; /// changes color when mouse enters/leaves this inset bool mouse_hover_; diff --git a/src/mathed/CommandInset.cpp b/src/mathed/CommandInset.cpp deleted file mode 100644 index 344c570323..0000000000 --- a/src/mathed/CommandInset.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/** - * \file CommandInset.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author André Pönitz - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "CommandInset.h" -#include "MathData.h" -#include "MathStream.h" -#include "DispatchResult.h" - -#include - -using namespace std; - -namespace lyx { - - -CommandInset::CommandInset(Buffer * buf, docstring const & name, bool needs_math_mode) - : InsetMathNest(buf, 2), name_(name), needs_math_mode_(needs_math_mode), - set_label_(false) -{ - lock_ = true; -} - - -Inset * CommandInset::clone() const -{ - return new CommandInset(*this); -} - - -void CommandInset::metrics(MetricsInfo & mi, Dimension & dim) const -{ - if (!set_label_) { - set_label_ = true; - button_.update(screenLabel(), true, false); - } - button_.metrics(mi, dim); -} - - -Inset * CommandInset::editXY(Cursor & cur, int /*x*/, int /*y*/) -{ - edit(cur, true); - return this; -} - - -void CommandInset::draw(PainterInfo & pi, int x, int y) const -{ - button_.draw(pi, x, y); -} - - -void CommandInset::write(WriteStream & os) const -{ - ModeSpecifier specifier(os, currentMode(), lockedMode(), asciiOnly()); - MathEnsurer ensurer(os, needs_math_mode_); - os << '\\' << name_; - if (!cell(1).empty()) - os << '[' << cell(1) << ']'; - os << '{' << cell(0) << '}'; -} - - -docstring const CommandInset::screenLabel() const -{ - return name_; -} - -} // namespace lyx diff --git a/src/mathed/CommandInset.h b/src/mathed/CommandInset.h deleted file mode 100644 index b820d72602..0000000000 --- a/src/mathed/CommandInset.h +++ /dev/null @@ -1,65 +0,0 @@ -// -*- C++ -*- -/** - * \file CommandInset.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author André Pönitz - * - * Full author contact details are available in file CREDITS. - */ - - -#ifndef COMMAND_INSET_H -#define COMMAND_INSET_H - -#include "InsetMathNest.h" - -#include "insets/RenderButton.h" - - -namespace lyx { - - -/// Inset for things like \name[options]{contents} -class CommandInset : public InsetMathNest { -public: - /// - explicit CommandInset(Buffer * buf, docstring const & name, - bool needs_math_mode = true); - /// - marker_type marker(BufferView const *) const { return NO_MARKER; } - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// - void draw(PainterInfo & pi, int x, int y) const; - /// - Inset * editXY(Cursor &, int, int); - /// - void write(WriteStream & os) const; - // - // void infoize(odocstream & os) const; - /// - virtual docstring const screenLabel() const; - /// - docstring const & commandname() const { return name_; } - /// - bool isActive() const { return false; } - -private: - virtual Inset * clone() const; - - /// - docstring name_; - /// - bool needs_math_mode_; - /// - mutable bool set_label_; - /// - mutable RenderButton button_; -}; - - -} // namespace lyx - -#endif diff --git a/src/mathed/InsetMath.h b/src/mathed/InsetMath.h index 81cad09b48..578b29fdcf 100644 --- a/src/mathed/InsetMath.h +++ b/src/mathed/InsetMath.h @@ -87,8 +87,8 @@ class MathStream; class WriteStream; class MathData; -class MathMacroTemplate; -class MathMacro; +class InsetMathMacroTemplate; +class InsetMathMacro; class MathRow; class TextPainter; class TextMetricsInfo; @@ -150,10 +150,10 @@ public: virtual InsetMathGrid const * asGridInset() const { return 0; } virtual InsetMathHull * asHullInset() { return 0; } virtual InsetMathHull const * asHullInset() const { return 0; } - virtual MathMacro * asMacro() { return 0; } - virtual MathMacro const * asMacro() const { return 0; } - virtual MathMacroTemplate * asMacroTemplate() { return 0; } - virtual MathMacroTemplate const * asMacroTemplate() const { return 0; } + virtual InsetMathMacro * asMacro() { return 0; } + virtual InsetMathMacro const * asMacro() const { return 0; } + virtual InsetMathMacroTemplate * asMacroTemplate() { return 0; } + virtual InsetMathMacroTemplate const * asMacroTemplate() const { return 0; } virtual InsetMathMatrix const * asMatrixInset() const { return 0; } virtual InsetMathNest * asNestInset() { return 0; } virtual InsetMathNest const * asNestInset() const { return 0; } diff --git a/src/mathed/InsetMathCommand.cpp b/src/mathed/InsetMathCommand.cpp new file mode 100644 index 0000000000..deac6c3711 --- /dev/null +++ b/src/mathed/InsetMathCommand.cpp @@ -0,0 +1,78 @@ +/** + * \file InsetMathCommand.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author André Pönitz + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "InsetMathCommand.h" +#include "MathData.h" +#include "MathStream.h" +#include "DispatchResult.h" + +#include + +using namespace std; + +namespace lyx { + + +InsetMathCommand::InsetMathCommand(Buffer * buf, docstring const & name, bool needs_math_mode) + : InsetMathNest(buf, 2), name_(name), needs_math_mode_(needs_math_mode), + set_label_(false) +{ + lock_ = true; +} + + +Inset * InsetMathCommand::clone() const +{ + return new InsetMathCommand(*this); +} + + +void InsetMathCommand::metrics(MetricsInfo & mi, Dimension & dim) const +{ + if (!set_label_) { + set_label_ = true; + button_.update(screenLabel(), true, false); + } + button_.metrics(mi, dim); +} + + +Inset * InsetMathCommand::editXY(Cursor & cur, int /*x*/, int /*y*/) +{ + edit(cur, true); + return this; +} + + +void InsetMathCommand::draw(PainterInfo & pi, int x, int y) const +{ + button_.draw(pi, x, y); +} + + +void InsetMathCommand::write(WriteStream & os) const +{ + ModeSpecifier specifier(os, currentMode(), lockedMode(), asciiOnly()); + MathEnsurer ensurer(os, needs_math_mode_); + os << '\\' << name_; + if (!cell(1).empty()) + os << '[' << cell(1) << ']'; + os << '{' << cell(0) << '}'; +} + + +docstring const InsetMathCommand::screenLabel() const +{ + return name_; +} + +} // namespace lyx diff --git a/src/mathed/InsetMathCommand.h b/src/mathed/InsetMathCommand.h new file mode 100644 index 0000000000..da4269c9ef --- /dev/null +++ b/src/mathed/InsetMathCommand.h @@ -0,0 +1,65 @@ +// -*- C++ -*- +/** + * \file InsetMathCommand.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author André Pönitz + * + * Full author contact details are available in file CREDITS. + */ + + +#ifndef COMMAND_INSET_H +#define COMMAND_INSET_H + +#include "InsetMathNest.h" + +#include "insets/RenderButton.h" + + +namespace lyx { + + +/// Inset for things like \name[options]{contents} +class InsetMathCommand : public InsetMathNest { +public: + /// + explicit InsetMathCommand(Buffer * buf, docstring const & name, + bool needs_math_mode = true); + /// + marker_type marker(BufferView const *) const { return NO_MARKER; } + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo & pi, int x, int y) const; + /// + Inset * editXY(Cursor &, int, int); + /// + void write(WriteStream & os) const; + // + // void infoize(odocstream & os) const; + /// + virtual docstring const screenLabel() const; + /// + docstring const & commandname() const { return name_; } + /// + bool isActive() const { return false; } + +private: + virtual Inset * clone() const; + + /// + docstring name_; + /// + bool needs_math_mode_; + /// + mutable bool set_label_; + /// + mutable RenderButton button_; +}; + + +} // namespace lyx + +#endif diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index 3c72f4d6bd..f4005d9124 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -35,8 +35,8 @@ #include "LaTeXFeatures.h" #include "LyXRC.h" #include "MacroTable.h" -#include "MathMacro.h" -#include "MathMacroTemplate.h" +#include "InsetMathMacro.h" +#include "InsetMathMacroTemplate.h" #include "MetricsInfo.h" #include "output_xhtml.h" #include "Paragraph.h" @@ -752,8 +752,8 @@ void InsetMathHull::usedMacros(MathData const & md, DocIterator const & pos, MacroNameSet::iterator const end = macros.end(); for (size_t i = 0; i < md.size(); ++i) { - MathMacro const * mi = md[i].nucleus()->asMacro(); - MathMacroTemplate const * mt = md[i].nucleus()->asMacroTemplate(); + InsetMathMacro const * mi = md[i].nucleus()->asMacro(); + InsetMathMacroTemplate const * mt = md[i].nucleus()->asMacroTemplate(); InsetMathScript const * si = md[i].nucleus()->asScriptInset(); InsetMathFracBase const * fi = md[i].nucleus()->asFracBaseInset(); InsetMathGrid const * gi = md[i].nucleus()->asGridInset(); diff --git a/src/mathed/InsetMathMacro.cpp b/src/mathed/InsetMathMacro.cpp new file mode 100644 index 0000000000..d2d4a8bc5d --- /dev/null +++ b/src/mathed/InsetMathMacro.cpp @@ -0,0 +1,1331 @@ +/** + * \file InsetMathMacro.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Alejandro Aguilar Sierra + * \author André Pönitz + * \author Stefan Schimanski + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "InsetMathMacro.h" + +#include "InsetMathChar.h" +#include "MathCompletionList.h" +#include "MathExtern.h" +#include "MathFactory.h" +#include "MathStream.h" +#include "MathSupport.h" + +#include "Buffer.h" +#include "BufferView.h" +#include "CoordCache.h" +#include "Cursor.h" +#include "FuncStatus.h" +#include "FuncRequest.h" +#include "LaTeXFeatures.h" +#include "LyX.h" +#include "LyXRC.h" +#include "MetricsInfo.h" + +#include "frontends/Painter.h" + +#include "support/debug.h" +#include "support/gettext.h" +#include "support/lassert.h" +#include "support/lstrings.h" +#include "support/RefChanger.h" +#include "support/textutils.h" + +#include +#include + +using namespace lyx::support; +using namespace std; + +namespace lyx { + + +/// A proxy for the macro values +class InsetArgumentProxy : public InsetMath { +public: + /// + InsetArgumentProxy(InsetMathMacro * mathMacro, size_t idx) + : mathMacro_(mathMacro), idx_(idx) {} + /// + InsetArgumentProxy(InsetMathMacro * mathMacro, size_t idx, docstring const & def) + : mathMacro_(mathMacro), idx_(idx) + { + asArray(def, def_); + } + /// + void setOwner(InsetMathMacro * mathMacro) { mathMacro_ = mathMacro; } + /// + InsetMathMacro const * owner() { return mathMacro_; } + /// + marker_type marker(BufferView const *) const { return NO_MARKER; } + /// + InsetCode lyxCode() const { return ARGUMENT_PROXY_CODE; } + /// The math data to use for display + MathData const & displayCell(BufferView const * bv) const + { + // handle default macro arguments + bool use_def_arg = !mathMacro_->editMetrics(bv) + && mathMacro_->cell(idx_).empty(); + return use_def_arg ? def_ : mathMacro_->cell(idx_); + } + /// + bool addToMathRow(MathRow & mrow, MetricsInfo & mi) const + { + // macro arguments are in macros + LATTEST(mathMacro_->nesting() > 0); + /// The macro nesting can change display of insets. Change it locally. + Changer chg = make_change(mi.base.macro_nesting, + mathMacro_->nesting() == 1 ? 0 : mathMacro_->nesting()); + + MathRow::Element e_beg(mi, MathRow::BEGIN); + e_beg.inset = this; + e_beg.ar = &mathMacro_->cell(idx_); + mrow.push_back(e_beg); + + mathMacro_->macro()->unlock(); + bool has_contents = displayCell(mi.base.bv).addToMathRow(mrow, mi); + mathMacro_->macro()->lock(); + + // if there was no contents, and the contents is editable, + // then we insert a box instead. + if (!has_contents && mathMacro_->nesting() == 1) { + // mathclass is ord because it should be spaced as a normal atom + MathRow::Element e(mi, MathRow::BOX, MC_ORD); + e.color = Color_mathline; + mrow.push_back(e); + has_contents = true; + } + + MathRow::Element e_end(mi, MathRow::END); + e_end.inset = this; + e_end.ar = &mathMacro_->cell(idx_); + mrow.push_back(e_end); + + return has_contents; + } + /// + void beforeMetrics() const + { + mathMacro_->macro()->unlock(); + } + /// + void afterMetrics() const + { + mathMacro_->macro()->lock(); + } + /// + void beforeDraw(PainterInfo const & pi) const + { + // if the macro is being edited, then the painter is in + // monochrome mode. + if (mathMacro_->editMetrics(pi.base.bv)) + pi.pain.leaveMonochromeMode(); + } + /// + void afterDraw(PainterInfo const & pi) const + { + if (mathMacro_->editMetrics(pi.base.bv)) + pi.pain.enterMonochromeMode(Color_mathbg, Color_mathmacroblend); + } + /// + void metrics(MetricsInfo &, Dimension &) const { + // This should never be invoked, since InsetArgumentProxy insets are linearized + LATTEST(false); + } + /// + void draw(PainterInfo &, int, int) const { + // This should never be invoked, since InsetArgumentProxy insets are linearized + LATTEST(false); + } + /// + int kerning(BufferView const * bv) const + { + return displayCell(bv).kerning(bv); + } + // write(), normalize(), infoize() and infoize2() are not needed since + // InsetMathMacro uses the definition and not the expanded cells. + /// + void maple(MapleStream & ms) const { ms << mathMacro_->cell(idx_); } + /// + void maxima(MaximaStream & ms) const { ms << mathMacro_->cell(idx_); } + /// + void mathematica(MathematicaStream & ms) const { ms << mathMacro_->cell(idx_); } + /// + void mathmlize(MathStream & ms) const { ms << mathMacro_->cell(idx_); } + /// + void htmlize(HtmlStream & ms) const { ms << mathMacro_->cell(idx_); } + /// + void octave(OctaveStream & os) const { os << mathMacro_->cell(idx_); } + /// + MathClass mathClass() const + { + return MC_UNKNOWN; + // This can be refined once the pointer issues are fixed. I did not + // notice any immediate crash with the following code, but it is risky + // nevertheless: + //return mathMacro_->cell(idx_).mathClass(); + } + +private: + /// + Inset * clone() const + { + return new InsetArgumentProxy(*this); + } + /// + InsetMathMacro * mathMacro_; + /// + size_t idx_; + /// + MathData def_; +}; + + +/// Private implementation of InsetMathMacro +class InsetMathMacro::Private { +public: + Private(Buffer * buf, docstring const & name) + : name_(name), displayMode_(DISPLAY_INIT), + expanded_(buf), definition_(buf), attachedArgsNum_(0), + optionals_(0), nextFoldMode_(true), macroBackup_(buf), + macro_(0), needsUpdate_(false), isUpdating_(false), + appetite_(9), nesting_(0) + { + } + /// Update the pointers to our owner of all expanded macros. + /// This needs to be called every time a copy of the owner is created + /// (bug 9418). + void updateChildren(InsetMathMacro * owner); + /// Recursively update the pointers of all expanded macros + /// appearing in the arguments of the current macro + void updateNestedChildren(InsetMathMacro * owner, InsetMathNest * ni); + /// name of macro + docstring name_; + /// current display mode + DisplayMode displayMode_; + /// expanded macro with ArgumentProxies + MathData expanded_; + /// macro definition with #1,#2,.. insets + MathData definition_; + /// number of arguments that were really attached + size_t attachedArgsNum_; + /// optional argument attached? (only in DISPLAY_NORMAL mode) + size_t optionals_; + /// fold mode to be set in next metrics call? + bool nextFoldMode_; + /// if macro_ == true, then here is a copy of the macro + /// don't use it for locking + MacroData macroBackup_; + /// if macroNotFound_ == false, then here is a reference to the macro + /// this might invalidate after metrics was called + MacroData const * macro_; + /// + mutable std::map editing_; + /// + std::string requires_; + /// update macro representation + bool needsUpdate_; + /// + bool isUpdating_; + /// maximal number of arguments the macro is greedy for + size_t appetite_; + /// Level of nesting in macros (including this one) + int nesting_; +}; + + +void InsetMathMacro::Private::updateChildren(InsetMathMacro * owner) +{ + for (size_t i = 0; i < expanded_.size(); ++i) { + InsetArgumentProxy * p = dynamic_cast(expanded_[i].nucleus()); + if (p) + p->setOwner(owner); + + InsetMathNest * ni = expanded_[i].nucleus()->asNestInset(); + if (ni) + updateNestedChildren(owner, ni); + } + + if (macro_) { + // The macro_ pointer is updated when MathData::metrics() is + // called. However, when instant preview is on or the macro is + // not on screen, MathData::metrics() is not called and we may + // have a dangling pointer. As a safety measure, when a macro + // is copied, always let macro_ point to the backup copy of the + // MacroData structure. This backup is updated every time the + // macro is changed, so it will not become stale. + macro_ = ¯oBackup_; + } +} + + +void InsetMathMacro::Private::updateNestedChildren(InsetMathMacro * owner, InsetMathNest * ni) +{ + for (size_t i = 0; i < ni->nargs(); ++i) { + MathData & ar = ni->cell(i); + for (size_t j = 0; j < ar.size(); ++j) { + InsetArgumentProxy * ap = dynamic_cast + (ar[j].nucleus()); + if (ap) { + InsetMathMacro::Private * md = ap->owner()->d; + if (md->macro_) + md->macro_ = &md->macroBackup_; + ap->setOwner(owner); + } + InsetMathNest * imn = ar[j].nucleus()->asNestInset(); + if (imn) + updateNestedChildren(owner, imn); + } + } +} + + +InsetMathMacro::InsetMathMacro(Buffer * buf, docstring const & name) + : InsetMathNest(buf, 0), d(new Private(buf, name)) +{} + + +InsetMathMacro::InsetMathMacro(InsetMathMacro const & that) + : InsetMathNest(that), d(new Private(*that.d)) +{ + setBuffer(*that.buffer_); + d->updateChildren(this); +} + + +InsetMathMacro & InsetMathMacro::operator=(InsetMathMacro const & that) +{ + if (&that == this) + return *this; + InsetMathNest::operator=(that); + *d = *that.d; + d->updateChildren(this); + return *this; +} + + +InsetMathMacro::~InsetMathMacro() +{ + delete d; +} + + +bool InsetMathMacro::addToMathRow(MathRow & mrow, MetricsInfo & mi) const +{ + // set edit mode for which we will have calculated row. + // This is the same as what is done in metrics(). + d->editing_[mi.base.bv] = editMode(mi.base.bv); + + // For now we do not linearize in the following cases (can be improved) + // - display mode different from normal + // - editing with parameter list + // - editing with box around macro + if (displayMode() != InsetMathMacro::DISPLAY_NORMAL + || (d->editing_[mi.base.bv] && lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST)) + return InsetMath::addToMathRow(mrow, mi); + + /// The macro nesting can change display of insets. Change it locally. + Changer chg = make_change(mi.base.macro_nesting, d->nesting_); + + MathRow::Element e_beg(mi, MathRow::BEGIN); + e_beg.inset = this; + e_beg.marker = (d->nesting_ == 1) ? marker(mi.base.bv) : NO_MARKER; + mrow.push_back(e_beg); + + d->macro_->lock(); + bool has_contents = d->expanded_.addToMathRow(mrow, mi); + d->macro_->unlock(); + + // if there was no contents and the array is editable, then we + // insert a grey box instead. + if (!has_contents && mi.base.macro_nesting == 1) { + // mathclass is unknown because it is irrelevant for spacing + MathRow::Element e(mi, MathRow::BOX); + e.color = Color_mathmacroblend; + mrow.push_back(e); + has_contents = true; + } + + MathRow::Element e_end(mi, MathRow::END); + e_end.inset = this; + e_end.marker = (d->nesting_ == 1) ? marker(mi.base.bv) : NO_MARKER; + mrow.push_back(e_end); + + return has_contents; +} + +void InsetMathMacro::beforeMetrics() const +{ + d->macro_->lock(); +} + + +void InsetMathMacro::afterMetrics() const +{ + d->macro_->unlock(); +} + + +void InsetMathMacro::beforeDraw(PainterInfo const & pi) const +{ + if (d->editing_[pi.base.bv]) + pi.pain.enterMonochromeMode(Color_mathbg, Color_mathmacroblend); +} + + +void InsetMathMacro::afterDraw(PainterInfo const & pi) const +{ + if (d->editing_[pi.base.bv]) + pi.pain.leaveMonochromeMode(); +} + + +Inset * InsetMathMacro::clone() const +{ + InsetMathMacro * copy = new InsetMathMacro(*this); + copy->d->needsUpdate_ = true; + //copy->d->expanded_.clear(); + return copy; +} + + +void InsetMathMacro::normalize(NormalStream & os) const +{ + os << "[macro " << name(); + for (size_t i = 0; i < nargs(); ++i) + os << ' ' << cell(i); + os << ']'; +} + + +InsetMathMacro::DisplayMode InsetMathMacro::displayMode() const +{ + return d->displayMode_; +} + + +bool InsetMathMacro::extraBraces() const +{ + return d->displayMode_ == DISPLAY_NORMAL && arity() > 0; +} + + +docstring InsetMathMacro::name() const +{ + if (d->displayMode_ == DISPLAY_UNFOLDED) + return asString(cell(0)); + + return d->name_; +} + + +docstring InsetMathMacro::macroName() const +{ + return d->name_; +} + + +int InsetMathMacro::nesting() const +{ + return d->nesting_; +} + + +void InsetMathMacro::cursorPos(BufferView const & bv, + CursorSlice const & sl, bool boundary, int & x, int & y) const +{ + // We may have 0 arguments, but InsetMathNest requires at least one. + if (nargs() > 0) + InsetMathNest::cursorPos(bv, sl, boundary, x, y); +} + + +bool InsetMathMacro::editMode(BufferView const * bv) const { + // find this in cursor trace + Cursor const & cur = bv->cursor(); + for (size_t i = 0; i != cur.depth(); ++i) + if (&cur[i].inset() == this) { + // look if there is no other macro in edit mode above + ++i; + for (; i != cur.depth(); ++i) { + InsetMath * im = cur[i].asInsetMath(); + if (im) { + InsetMathMacro const * macro = im->asMacro(); + if (macro && macro->displayMode() == DISPLAY_NORMAL) + return false; + } + } + + // ok, none found, I am the highest one + return true; + } + + return false; +} + + +MacroData const * InsetMathMacro::macro() const +{ + return d->macro_; +} + + +bool InsetMathMacro::editMetrics(BufferView const * bv) const +{ + return d->editing_[bv]; +} + + +InsetMath::marker_type InsetMathMacro::marker(BufferView const * bv) const +{ + if (nargs() == 0) + return NO_MARKER; + + switch (d->displayMode_) { + case DISPLAY_INIT: + case DISPLAY_INTERACTIVE_INIT: + return NO_MARKER; + case DISPLAY_UNFOLDED: + return MARKER; + case DISPLAY_NORMAL: + switch (lyxrc.macro_edit_style) { + case LyXRC::MACRO_EDIT_INLINE: + return MARKER2; + case LyXRC::MACRO_EDIT_INLINE_BOX: + return d->editing_[bv] ? BOX_MARKER : MARKER2; + case LyXRC::MACRO_EDIT_LIST: + return MARKER2; + } + } + // please gcc 4.6 + return NO_MARKER; +} + + +void InsetMathMacro::metrics(MetricsInfo & mi, Dimension & dim) const +{ + /// The macro nesting can change display of insets. Change it locally. + Changer chg = make_change(mi.base.macro_nesting, d->nesting_); + + // set edit mode for which we will have calculated metrics. But only + d->editing_[mi.base.bv] = editMode(mi.base.bv); + + // calculate new metrics according to display mode + if (d->displayMode_ == DISPLAY_INIT || d->displayMode_ == DISPLAY_INTERACTIVE_INIT) { + Changer dummy = mi.base.changeFontSet("lyxtex"); + mathed_string_dim(mi.base.font, from_ascii("\\") + name(), dim); + } else if (d->displayMode_ == DISPLAY_UNFOLDED) { + Changer dummy = mi.base.changeFontSet("lyxtex"); + cell(0).metrics(mi, dim); + Dimension bsdim; + mathed_string_dim(mi.base.font, from_ascii("\\"), bsdim); + dim.wid += bsdim.width() + 1; + dim.asc = max(bsdim.ascent(), dim.ascent()); + dim.des = max(bsdim.descent(), dim.descent()); + } else if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST + && d->editing_[mi.base.bv]) { + // Macro will be edited in a old-style list mode here: + + LBUFERR(d->macro_); + Dimension fontDim; + FontInfo labelFont = sane_font; + math_font_max_dim(labelFont, fontDim.asc, fontDim.des); + + // get dimension of components of list view + Dimension nameDim; + nameDim.wid = mathed_string_width(mi.base.font, from_ascii("Macro \\") + name() + ": "); + nameDim.asc = fontDim.asc; + nameDim.des = fontDim.des; + + Dimension argDim; + argDim.wid = mathed_string_width(labelFont, from_ascii("#9: ")); + argDim.asc = fontDim.asc; + argDim.des = fontDim.des; + + Dimension defDim; + d->definition_.metrics(mi, defDim); + + // add them up + dim.wid = nameDim.wid + defDim.wid; + dim.asc = max(nameDim.asc, defDim.asc); + dim.des = max(nameDim.des, defDim.des); + + for (idx_type i = 0; i < nargs(); ++i) { + Dimension cdim; + cell(i).metrics(mi, cdim); + dim.des += max(argDim.height(), cdim.height()) + 1; + dim.wid = max(dim.wid, argDim.wid + cdim.wid); + } + + // make space for box and markers, 2 pixels + dim.asc += 1; + dim.des += 1; + dim.wid += 2; + } else { + // We should not be here, since the macro is linearized in this case. + LBUFERR(false); + } +} + + +int InsetMathMacro::kerning(BufferView const * bv) const { + if (d->displayMode_ == DISPLAY_NORMAL && !d->editing_[bv]) + return d->expanded_.kerning(bv); + else + return 0; +} + + +void InsetMathMacro::updateMacro(MacroContext const & mc) +{ + if (validName()) { + d->macro_ = mc.get(name()); + if (d->macro_ && d->macroBackup_ != *d->macro_) { + d->macroBackup_ = *d->macro_; + d->needsUpdate_ = true; + } + } else { + d->macro_ = 0; + } +} + + +class InsetMathMacro::UpdateLocker +{ +public: + explicit UpdateLocker(InsetMathMacro & mm) : mac(mm) + { + mac.d->isUpdating_ = true; + } + ~UpdateLocker() { mac.d->isUpdating_ = false; } +private: + InsetMathMacro & mac; +}; +/** Avoid wrong usage of UpdateLocker. + To avoid wrong usage: + UpdateLocker(...); // wrong + UpdateLocker locker(...); // right +*/ +#define UpdateLocker(x) unnamed_UpdateLocker; +// Tip gotten from Bobby Schmidt's column in C/C++ Users Journal + + +void InsetMathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc, + UpdateType utype, int nesting) +{ + // block recursive calls (bug 8999) + if (d->isUpdating_) + return; + + UpdateLocker locker(*this); + + // known macro? + if (d->macro_ == 0) + return; + + // remember nesting level of this macro + d->nesting_ = nesting; + + // update requires + d->requires_ = d->macro_->requires(); + + if (!d->needsUpdate_ + // non-normal mode? We are done! + || (d->displayMode_ != DISPLAY_NORMAL)) + return; + + d->needsUpdate_ = false; + + // get default values of macro + vector const & defaults = d->macro_->defaults(); + + // create MathMacroArgumentValue objects pointing to the cells of the macro + vector values(nargs()); + for (size_t i = 0; i < nargs(); ++i) { + InsetArgumentProxy * proxy; + if (i < defaults.size()) + proxy = new InsetArgumentProxy(this, i, defaults[i]); + else + proxy = new InsetArgumentProxy(this, i); + values[i].insert(0, MathAtom(proxy)); + } + // expanding macro with the values + // Only update the argument macros if anything was expanded, otherwise + // we would get an endless loop (bug 9140). UpdateLocker does not work + // in this case, since MacroData::expand() creates new InsetMathMacro + // objects, so this would be a different recursion path than the one + // protected by UpdateLocker. + if (d->macro_->expand(values, d->expanded_)) { + if (utype == OutputUpdate && !d->expanded_.empty()) + d->expanded_.updateMacros(cur, mc, utype, nesting); + } + // get definition for list edit mode + docstring const & display = d->macro_->display(); + asArray(display.empty() ? d->macro_->definition() : display, + d->definition_, Parse::QUIET | Parse::MACRODEF); +} + + +void InsetMathMacro::draw(PainterInfo & pi, int x, int y) const +{ + Dimension const dim = dimension(*pi.base.bv); + + int expx = x; + int expy = y; + + if (d->displayMode_ == DISPLAY_INIT || d->displayMode_ == DISPLAY_INTERACTIVE_INIT) { + Changer dummy = pi.base.changeFontSet("lyxtex"); + pi.pain.text(x, y, from_ascii("\\") + name(), pi.base.font); + } else if (d->displayMode_ == DISPLAY_UNFOLDED) { + Changer dummy = pi.base.changeFontSet("lyxtex"); + pi.pain.text(x, y, from_ascii("\\"), pi.base.font); + x += mathed_string_width(pi.base.font, from_ascii("\\")) + 1; + cell(0).draw(pi, x, y); + } else if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST + && d->editing_[pi.base.bv]) { + // Macro will be edited in a old-style list mode here: + + CoordCache const & coords = pi.base.bv->coordCache(); + FontInfo const & labelFont = sane_font; + + // box needs one pixel + x += 1; + + // get maximal font height + Dimension fontDim; + math_font_max_dim(pi.base.font, fontDim.asc, fontDim.des); + + // draw label + docstring label = from_ascii("Macro \\") + name() + from_ascii(": "); + pi.pain.text(x, y, label, labelFont); + x += mathed_string_width(labelFont, label); + + // draw definition + d->definition_.draw(pi, x, y); + Dimension const & defDim = coords.getArrays().dim(&d->definition_); + y += max(fontDim.des, defDim.des); + + // draw parameters + docstring str = from_ascii("#9"); + int strw1 = mathed_string_width(labelFont, from_ascii("#9")); + int strw2 = mathed_string_width(labelFont, from_ascii(": ")); + + for (idx_type i = 0; i < nargs(); ++i) { + // position of label + Dimension const & cdim = coords.getArrays().dim(&cell(i)); + x = expx + 1; + y += max(fontDim.asc, cdim.asc) + 1; + + // draw label + str[1] = '1' + i; + pi.pain.text(x, y, str, labelFont); + x += strw1; + pi.pain.text(x, y, from_ascii(":"), labelFont); + x += strw2; + + // draw paramter + cell(i).draw(pi, x, y); + + // next line + y += max(fontDim.des, cdim.des); + } + + pi.pain.rectangle(expx, expy - dim.asc + 1, dim.wid - 1, + dim.height() - 2, Color_mathmacroframe); + } else { + // We should not be here, since the macro is linearized in this case. + LBUFERR(false); + } + + // edit mode changed? + if (d->editing_[pi.base.bv] != editMode(pi.base.bv)) + pi.base.bv->cursor().screenUpdateFlags(Update::SinglePar); +} + + +void InsetMathMacro::setDisplayMode(InsetMathMacro::DisplayMode mode, int appetite) +{ + if (d->displayMode_ != mode) { + // transfer name if changing from or to DISPLAY_UNFOLDED + if (mode == DISPLAY_UNFOLDED) { + cells_.resize(1); + asArray(d->name_, cell(0)); + } else if (d->displayMode_ == DISPLAY_UNFOLDED) { + d->name_ = asString(cell(0)); + cells_.resize(0); + } + + d->displayMode_ = mode; + d->needsUpdate_ = true; + } + + // the interactive init mode is non-greedy by default + if (appetite == -1) + d->appetite_ = (mode == DISPLAY_INTERACTIVE_INIT) ? 0 : 9; + else + d->appetite_ = size_t(appetite); +} + + +InsetMathMacro::DisplayMode InsetMathMacro::computeDisplayMode() const +{ + if (d->nextFoldMode_ == true && d->macro_ && !d->macro_->locked()) + return DISPLAY_NORMAL; + else + return DISPLAY_UNFOLDED; +} + + +bool InsetMathMacro::validName() const +{ + docstring n = name(); + + if (n.empty()) + return false; + + // converting back and force doesn't swallow anything? + /*MathData ma; + asArray(n, ma); + if (asString(ma) != n) + return false;*/ + + // valid characters? + for (size_t i = 0; i= 'a' && n[i] <= 'z') + && !(n[i] >= 'A' && n[i] <= 'Z') + && n[i] != '*') + return false; + } + + return true; +} + + +size_t InsetMathMacro::arity() const +{ + if (d->displayMode_ == DISPLAY_NORMAL ) + return cells_.size(); + else + return 0; +} + + +size_t InsetMathMacro::optionals() const +{ + return d->optionals_; +} + + +void InsetMathMacro::setOptionals(int n) +{ + if (n <= int(nargs())) + d->optionals_ = n; +} + + +size_t InsetMathMacro::appetite() const +{ + return d->appetite_; +} + + +MathClass InsetMathMacro::mathClass() const +{ + // This can be just a heuristic, since it is only considered for display + // when the macro is not linearised. Therefore it affects: + // * The spacing of the inset while being edited, + // * Intelligent splitting + // * Cursor word movement (Ctrl-Arrow). + if (MacroData const * m = macroBackup()) { + // If it is a global macro and is defined explicitly + if (m->symbol()) { + MathClass mc = string_to_class(m->symbol()->extra); + if (mc != MC_UNKNOWN) + return mc; + } + } + // Otherwise guess from the expanded macro + return d->expanded_.mathClass(); +} + + +InsetMath::mode_type InsetMathMacro::currentMode() const +{ + // There is no way to guess the mode of user defined macros, so they are + // always assumed to be mathmode. Only the global macros defined in + // lib/symbols may be textmode. + mode_type mode = modeToEnsure(); + return (mode == UNDECIDED_MODE) ? MATH_MODE : mode; +} + + +InsetMath::mode_type InsetMathMacro::modeToEnsure() const +{ + // User defined macros can be either text mode or math mode for output and + // display. There is no way to guess. For global macros defined in + // lib/symbols, we ensure textmode if flagged as such, otherwise we ensure + // math mode. + if (MacroData const * m = macroBackup()) + if (m->symbol()) + return (m->symbol()->extra == "textmode") ? TEXT_MODE : MATH_MODE; + return UNDECIDED_MODE; +} + + +MacroData const * InsetMathMacro::macroBackup() const +{ + if (macro()) + return &d->macroBackup_; + if (MacroData const * data = MacroTable::globalMacros().get(name())) + return data; + return nullptr; +} + + +void InsetMathMacro::validate(LaTeXFeatures & features) const +{ + // Immediately after a document is loaded, in some cases the MacroData + // of the global macros defined in the lib/symbols file may still not + // be known to the macro machinery because it will be set only after + // the first call to updateMacros(). This is not a problem unless + // instant preview is on for math, in which case we will be missing + // the corresponding requirements. + // In this case, we get the required info from the global macro table. + if (!d->requires_.empty()) + features.require(d->requires_); + else if (!d->macro_) { + // Update requires for known global macros. + MacroData const * data = MacroTable::globalMacros().get(name()); + if (data && !data->requires().empty()) + features.require(data->requires()); + } + + if (name() == "binom") + features.require("binom"); + + // validate the cells and the definition + if (displayMode() == DISPLAY_NORMAL) { + d->definition_.validate(features); + InsetMathNest::validate(features); + } +} + + +void InsetMathMacro::edit(Cursor & cur, bool front, EntryDirection entry_from) +{ + cur.screenUpdateFlags(Update::SinglePar); + InsetMathNest::edit(cur, front, entry_from); +} + + +Inset * InsetMathMacro::editXY(Cursor & cur, int x, int y) +{ + // We may have 0 arguments, but InsetMathNest requires at least one. + if (nargs() > 0) { + cur.screenUpdateFlags(Update::SinglePar); + return InsetMathNest::editXY(cur, x, y); + } else + return this; +} + + +void InsetMathMacro::removeArgument(Inset::pos_type pos) { + if (d->displayMode_ == DISPLAY_NORMAL) { + LASSERT(size_t(pos) < cells_.size(), return); + cells_.erase(cells_.begin() + pos); + if (size_t(pos) < d->attachedArgsNum_) + --d->attachedArgsNum_; + if (size_t(pos) < d->optionals_) { + --d->optionals_; + } + + d->needsUpdate_ = true; + } +} + + +void InsetMathMacro::insertArgument(Inset::pos_type pos) { + if (d->displayMode_ == DISPLAY_NORMAL) { + LASSERT(size_t(pos) <= cells_.size(), return); + cells_.insert(cells_.begin() + pos, MathData()); + if (size_t(pos) < d->attachedArgsNum_) + ++d->attachedArgsNum_; + if (size_t(pos) < d->optionals_) + ++d->optionals_; + + d->needsUpdate_ = true; + } +} + + +void InsetMathMacro::detachArguments(vector & args, bool strip) +{ + LASSERT(d->displayMode_ == DISPLAY_NORMAL, return); + args = cells_; + + // strip off empty cells, but not more than arity-attachedArgsNum_ + if (strip) { + size_t i; + for (i = cells_.size(); i > d->attachedArgsNum_; --i) + if (!cell(i - 1).empty()) break; + args.resize(i); + } + + d->attachedArgsNum_ = 0; + d->expanded_ = MathData(); + cells_.resize(0); + + d->needsUpdate_ = true; +} + + +void InsetMathMacro::attachArguments(vector const & args, size_t arity, int optionals) +{ + LASSERT(d->displayMode_ == DISPLAY_NORMAL, return); + cells_ = args; + d->attachedArgsNum_ = args.size(); + cells_.resize(arity); + d->expanded_ = MathData(); + d->optionals_ = optionals; + + d->needsUpdate_ = true; +} + + +bool InsetMathMacro::idxFirst(Cursor & cur) const +{ + cur.screenUpdateFlags(Update::SinglePar); + return InsetMathNest::idxFirst(cur); +} + + +bool InsetMathMacro::idxLast(Cursor & cur) const +{ + cur.screenUpdateFlags(Update::SinglePar); + return InsetMathNest::idxLast(cur); +} + + +bool InsetMathMacro::notifyCursorLeaves(Cursor const & old, Cursor & cur) +{ + if (d->displayMode_ == DISPLAY_UNFOLDED) { + docstring const & unfolded_name = name(); + if (unfolded_name != d->name_) { + // The macro name was changed + Cursor inset_cursor = old; + int macroSlice = inset_cursor.find(this); + // returning true means the cursor is "now" invalid, + // which it was. + LASSERT(macroSlice != -1, return true); + inset_cursor.cutOff(macroSlice); + inset_cursor.recordUndoInset(); + inset_cursor.pop(); + inset_cursor.cell().erase(inset_cursor.pos()); + inset_cursor.cell().insert(inset_cursor.pos(), + createInsetMath(unfolded_name, cur.buffer())); + cur.resetAnchor(); + cur.screenUpdateFlags(cur.result().screenUpdate() | Update::SinglePar); + return true; + } + } + cur.screenUpdateFlags(Update::Force); + return InsetMathNest::notifyCursorLeaves(old, cur); +} + + +void InsetMathMacro::fold(Cursor & cur) +{ + if (!d->nextFoldMode_) { + d->nextFoldMode_ = true; + cur.screenUpdateFlags(Update::SinglePar); + } +} + + +void InsetMathMacro::unfold(Cursor & cur) +{ + if (d->nextFoldMode_) { + d->nextFoldMode_ = false; + cur.screenUpdateFlags(Update::SinglePar); + } +} + + +bool InsetMathMacro::folded() const +{ + return d->nextFoldMode_; +} + + +void InsetMathMacro::write(WriteStream & os) const +{ + mode_type mode = modeToEnsure(); + bool textmode_macro = mode == TEXT_MODE; + bool needs_mathmode = mode == MATH_MODE; + MathEnsurer ensurer(os, needs_mathmode, true, textmode_macro); + + // non-normal mode + if (d->displayMode_ != DISPLAY_NORMAL) { + os << "\\" << name(); + if (name().size() != 1 || isAlphaASCII(name()[0])) + os.pendingSpace(true); + return; + } + + // normal mode + // we should be ok to continue even if this fails. + LATTEST(d->macro_); + + // We may already be in the argument of a macro + bool const inside_macro = os.insideMacro(); + os.insideMacro(true); + + // Enclose in braces to avoid latex errors with xargs if we have + // optional arguments and are in the optional argument of a macro + if (d->optionals_ && inside_macro) + os << '{'; + + // Always protect macros in a fragile environment + if (os.fragile()) + os << "\\protect"; + + os << "\\" << name(); + bool first = true; + + // Optional arguments: + // First find last non-empty optional argument + idx_type emptyOptFrom = 0; + idx_type i = 0; + for (; i < cells_.size() && i < d->optionals_; ++i) { + if (!cell(i).empty()) + emptyOptFrom = i + 1; + } + + // print out optionals + for (i=0; i < cells_.size() && i < emptyOptFrom; ++i) { + first = false; + os << "[" << cell(i) << "]"; + } + + // skip the tailing empty optionals + i = d->optionals_; + + // Print remaining arguments + for (; i < cells_.size(); ++i) { + if (cell(i).size() == 1 + && cell(i)[0].nucleus()->asCharInset() + && isASCII(cell(i)[0].nucleus()->asCharInset()->getChar())) { + if (first) + os << " "; + os << cell(i); + } else + os << "{" << cell(i) << "}"; + first = false; + } + + // Close the opened brace or add space if there was no argument + if (d->optionals_ && inside_macro) + os << '}'; + else if (first) + os.pendingSpace(true); + + os.insideMacro(inside_macro); +} + + +void InsetMathMacro::maple(MapleStream & os) const +{ + lyx::maple(d->expanded_, os); +} + + +void InsetMathMacro::maxima(MaximaStream & os) const +{ + lyx::maxima(d->expanded_, os); +} + + +void InsetMathMacro::mathematica(MathematicaStream & os) const +{ + lyx::mathematica(d->expanded_, os); +} + + +void InsetMathMacro::mathmlize(MathStream & os) const +{ + // macro_ is 0 if this is an unknown macro + LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL); + if (d->macro_) { + docstring const xmlname = d->macro_->xmlname(); + if (!xmlname.empty()) { + char const * type = d->macro_->MathMLtype(); + os << '<' << type << "> " << xmlname << " '; + return; + } + } + if (d->expanded_.empty()) { + // this means that we do not recognize the macro + throw MathExportException(); + } + os << d->expanded_; +} + + +void InsetMathMacro::htmlize(HtmlStream & os) const +{ + // macro_ is 0 if this is an unknown macro + LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL); + if (d->macro_) { + docstring const xmlname = d->macro_->xmlname(); + if (!xmlname.empty()) { + os << ' ' << xmlname << ' '; + return; + } + } + if (d->expanded_.empty()) { + // this means that we do not recognize the macro + throw MathExportException(); + } + os << d->expanded_; +} + + +void InsetMathMacro::octave(OctaveStream & os) const +{ + lyx::octave(d->expanded_, os); +} + + +void InsetMathMacro::infoize(odocstream & os) const +{ + os << bformat(_("Macro: %1$s"), name()); +} + + +void InsetMathMacro::infoize2(odocstream & os) const +{ + os << bformat(_("Macro: %1$s"), name()); +} + + +bool InsetMathMacro::completionSupported(Cursor const & cur) const +{ + if (displayMode() != DISPLAY_UNFOLDED) + return InsetMathNest::completionSupported(cur); + + return lyxrc.completion_popup_math + && displayMode() == DISPLAY_UNFOLDED + && cur.bv().cursor().pos() == int(name().size()); +} + + +bool InsetMathMacro::inlineCompletionSupported(Cursor const & cur) const +{ + if (displayMode() != DISPLAY_UNFOLDED) + return InsetMathNest::inlineCompletionSupported(cur); + + return lyxrc.completion_inline_math + && displayMode() == DISPLAY_UNFOLDED + && cur.bv().cursor().pos() == int(name().size()); +} + + +bool InsetMathMacro::automaticInlineCompletion() const +{ + if (displayMode() != DISPLAY_UNFOLDED) + return InsetMathNest::automaticInlineCompletion(); + + return lyxrc.completion_inline_math; +} + + +bool InsetMathMacro::automaticPopupCompletion() const +{ + if (displayMode() != DISPLAY_UNFOLDED) + return InsetMathNest::automaticPopupCompletion(); + + return lyxrc.completion_popup_math; +} + + +CompletionList const * +InsetMathMacro::createCompletionList(Cursor const & cur) const +{ + if (displayMode() != DISPLAY_UNFOLDED) + return InsetMathNest::createCompletionList(cur); + + return new MathCompletionList(cur.bv().cursor()); +} + + +docstring InsetMathMacro::completionPrefix(Cursor const & cur) const +{ + if (displayMode() != DISPLAY_UNFOLDED) + return InsetMathNest::completionPrefix(cur); + + if (!completionSupported(cur)) + return docstring(); + + return "\\" + name(); +} + + +bool InsetMathMacro::insertCompletion(Cursor & cur, docstring const & s, + bool finished) +{ + if (displayMode() != DISPLAY_UNFOLDED) + return InsetMathNest::insertCompletion(cur, s, finished); + + if (!completionSupported(cur)) + return false; + + // append completion + docstring newName = name() + s; + asArray(newName, cell(0)); + cur.bv().cursor().pos() = name().size(); + cur.screenUpdateFlags(Update::SinglePar); + + // finish macro + if (finished) { + cur.bv().cursor().pop(); + ++cur.bv().cursor().pos(); + cur.screenUpdateFlags(Update::SinglePar); + } + + return true; +} + + +void InsetMathMacro::completionPosAndDim(Cursor const & cur, int & x, int & y, + Dimension & dim) const +{ + if (displayMode() != DISPLAY_UNFOLDED) + InsetMathNest::completionPosAndDim(cur, x, y, dim); + + // get inset dimensions + dim = cur.bv().coordCache().insets().dim(this); + // FIXME: these 3 are no accurate, but should depend on the font. + // Now the popup jumps down if you enter a char with descent > 0. + dim.des += 3; + dim.asc += 3; + + // and position + Point xy + = cur.bv().coordCache().insets().xy(this); + x = xy.x_; + y = xy.y_; +} + + +} // namespace lyx diff --git a/src/mathed/InsetMathMacro.h b/src/mathed/InsetMathMacro.h new file mode 100644 index 0000000000..4267a2b1e0 --- /dev/null +++ b/src/mathed/InsetMathMacro.h @@ -0,0 +1,216 @@ +// -*- C++ -*- +/** + * \file InsetMathMacro.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Alejandro Aguilar Sierra + * \author André Pönitz + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef MATH_MACRO_H +#define MATH_MACRO_H + +#include "InsetMathNest.h" +#include "MacroTable.h" +#include "MathData.h" + +#include + +namespace lyx { + +/// This class contains the data for a macro. +class InsetMathMacro : public InsetMathNest { +public: + /// A macro can be built from an existing template + InsetMathMacro(Buffer * buf, docstring const & name); + /// + InsetMathMacro(InsetMathMacro const &); + /// + InsetMathMacro & operator=(InsetMathMacro const &); + /// + ~InsetMathMacro(); + /// + virtual InsetMathMacro * asMacro() { return this; } + /// + virtual InsetMathMacro const * asMacro() const { return this; } + /// + marker_type marker(BufferView const *) const; + /// If the macro is in normal edit mode, dissolve its contents in + /// the row. Otherwise, just insert the inset. + bool addToMathRow(MathRow &, MetricsInfo & mi) const; + /// + void beforeMetrics() const; + /// + void afterMetrics() const; + /// + void beforeDraw(PainterInfo const &) const; + /// + void afterDraw(PainterInfo const &) const; + + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// was the macro in edit mode when computing metrics? + bool editMetrics(BufferView const * bv) const; + /// + void draw(PainterInfo & pi, int x, int y) const; + /// + int kerning(BufferView const * bv) const; + /// get cursor position + void cursorPos(BufferView const & bv, CursorSlice const & sl, + bool boundary, int & x, int & y) const; + /// + void edit(Cursor & cur, bool front, EntryDirection entry_from); + /// + Inset * editXY(Cursor & cur, int x, int y); + + /// target pos when we enter the inset while moving forward + bool idxFirst(Cursor &) const; + /// target pos when we enter the inset while moving backwards + bool idxLast(Cursor &) const; + + /// + virtual bool notifyCursorLeaves(Cursor const & old, Cursor & cur); + + /// Remove cell (starting from 0) + void removeArgument(pos_type pos); + /// Insert empty cell (starting from 0) + void insertArgument(pos_type pos); + + /// + void validate(LaTeXFeatures &) const; + /// + mode_type currentMode() const; + + /// + void write(WriteStream & os) const; + /// + void normalize(NormalStream & os) const; + /// + void maple(MapleStream &) const; + /// + void maxima(MaximaStream &) const; + /// + void mathematica(MathematicaStream &) const; + /// + void mathmlize(MathStream &) const; + /// + void htmlize(HtmlStream &) const; + /// + void octave(OctaveStream &) const; + /// + void infoize(odocstream &) const; + /// + void infoize2(odocstream &) const; + + /// fold the macro in the next metrics call + void fold(Cursor & cur); + /// unfold the macro in the next metrics call + void unfold(Cursor & cur); + /// will it be folded or unfolded in the next metric call? + bool folded() const; + + enum DisplayMode { + DISPLAY_INIT, + DISPLAY_INTERACTIVE_INIT, + DISPLAY_UNFOLDED, + DISPLAY_NORMAL + }; + + /// + DisplayMode displayMode() const; + + /// + bool extraBraces() const; + + /// + docstring name() const; + /// FIXME: Often dangling. + MacroData const * macro() const; + /// + docstring macroName() const; + /// Level of nesting in macros (including this one) + int nesting() const; + /// + bool validName() const; + /// + size_t arity() const; + + /// + size_t optionals() const; + /// + void setOptionals(int n); + /// Return the maximal number of arguments the macro is greedy for. + size_t appetite() const; + /// + InsetCode lyxCode() const { return MATH_MACRO_CODE; } + /// This is not used for display; however whether it is mathrel determines + /// how to split equations intelligently. + MathClass mathClass() const; //override + +protected: + friend class MathData; + friend class ArgumentProxy; + friend class Cursor; + + /// update the display mode (should only be called after detaching arguments) + void setDisplayMode(DisplayMode mode, int appetite = -1); + /// compute the next display mode + DisplayMode computeDisplayMode() const; + /// update macro definition + void updateMacro(MacroContext const & mc); + /// check if macro definition changed, argument changed etc. and adapt + void updateRepresentation(Cursor * cur, MacroContext const & mc, + UpdateType, int nesting); + /// empty macro, put arguments into args, possibly strip arity-attachedArgsNum_ empty ones. + /// Includes the optional arguments. + void detachArguments(std::vector & args, bool strip); + /// attach arguments (maybe less than arity at the end of an MathData), + /// including the optional ones (even if it can be empty here) + void attachArguments(std::vector const & args, size_t arity, int optionals); + +private: + /// Math mode for output and display. UNDECIDED for user macros: they could + /// be either. + mode_type modeToEnsure() const; + /// This function is needed for now because of two shortfalls of the current + /// implementation: the macro() pointer is often dangling, in which case we + /// fall back to a backup copy, and the macro is not known at inset + /// creation, in which case we fall back to the global macro with this name. + MacroData const * macroBackup() const; + /// + virtual Inset * clone() const; + /// + bool editMode(BufferView const * bv) const; + + /// + class Private; + /// + Private * d; + /// update lock to avoid loops + class UpdateLocker; + friend class UpdateLocker; + +public: + /// + bool completionSupported(Cursor const &) const; + /// + bool inlineCompletionSupported(Cursor const & cur) const; + /// + bool automaticInlineCompletion() const; + /// + bool automaticPopupCompletion() const; + /// + CompletionList const * createCompletionList(Cursor const & cur) const; + /// + docstring completionPrefix(Cursor const & cur) const; + /// + bool insertCompletion(Cursor & cur, docstring const & s, bool finished); + /// + void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const; +}; + +} // namespace lyx +#endif diff --git a/src/mathed/InsetMathMacroArgument.cpp b/src/mathed/InsetMathMacroArgument.cpp new file mode 100644 index 0000000000..7fca256d01 --- /dev/null +++ b/src/mathed/InsetMathMacroArgument.cpp @@ -0,0 +1,97 @@ +/** + * \file InsetMathMacroArgument.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Alejandro Aguilar Sierra + * \author André Pönitz + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "InsetMathMacroArgument.h" +#include "MathStream.h" +#include "MathSupport.h" + +#include "support/debug.h" +#include "support/lassert.h" + + +namespace lyx { + + +Inset * InsetMathHash::clone() const +{ + return new InsetMathHash(*this); +} + + +void InsetMathHash::write(WriteStream & os) const +{ + os << str_; +} + + +void InsetMathHash::metrics(MetricsInfo & mi, Dimension & dim) const +{ + metricsStrRedBlack(mi, dim, str_); +} + + +void InsetMathHash::draw(PainterInfo & pi, int x, int y) const +{ + drawStrRed(pi, x, y, str_); +} + + +void InsetMathHash::normalize(NormalStream & os) const +{ + os << "[hash " << str_ << "] "; +} + + +InsetMathMacroArgument::InsetMathMacroArgument(int n) + : number_(n) +{ + if (n < 1 || n > 9) { + LYXERR0("InsetMathMacroArgument::InsetMathMacroArgument: wrong Argument id: " + << n); + LASSERT(false, n = 1); + } + + // The profiler tells us not to use + // str_ = '#' + convert(n); + // so we do the conversion of n to ASCII manually. + // This works because 1 <= n <= 9. + str_.resize(2); + str_[1] = '0' + n; +} + + +Inset * InsetMathMacroArgument::clone() const +{ + return new InsetMathMacroArgument(*this); +} + + +void InsetMathMacroArgument::setNumber(int n) +{ + if (n < 1 || n > 9) { + LYXERR0("InsetMathMacroArgument::setNumber: wrong Argument id: " << n); + LASSERT(false, return); + } + + number_ = n; + str_[1] = '0' + n; +} + + +void InsetMathMacroArgument::normalize(NormalStream & os) const +{ + os << "[macroarg " << str_ << "] "; +} + + +} // namespace lyx diff --git a/src/mathed/InsetMathMacroArgument.h b/src/mathed/InsetMathMacroArgument.h new file mode 100644 index 0000000000..178c89818d --- /dev/null +++ b/src/mathed/InsetMathMacroArgument.h @@ -0,0 +1,70 @@ +// -*- C++ -*- +/** + * \file InsetMathMacroArgument.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Alejandro Aguilar Sierra + * \author André Pönitz + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef MATHMACROARGUMENT_H +#define MATHMACROARGUMENT_H + +#include "InsetMath.h" + +#include "support/docstring.h" + + +namespace lyx { + + +// A # that failed to parse +class InsetMathHash : public InsetMath { +public: + InsetMathHash(docstring const & str = docstring()) : str_('#' + str) {}; + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo &, int x, int y) const; + /// + void normalize(NormalStream &) const; + /// + void write(WriteStream & os) const; + +private: + Inset * clone() const; + +protected: + /// + docstring str_; +}; + + +/// A macro argument. +class InsetMathMacroArgument : public InsetMathHash { +public: + /// Assumes 0 < number <= 9 + explicit InsetMathMacroArgument(int number); + /// + int number() const { return number_; } + /// Assumes 0 < n <= 9 + void setNumber(int n); + /// + InsetCode lyxCode() const { return MATH_MACROARG_CODE; } + + /// + void normalize(NormalStream &) const; + +private: + Inset * clone() const; + /// A number between 1 and 9 + int number_; +}; + + +} // namespace lyx + +#endif diff --git a/src/mathed/InsetMathMacroTemplate.cpp b/src/mathed/InsetMathMacroTemplate.cpp new file mode 100644 index 0000000000..17fc2d04a2 --- /dev/null +++ b/src/mathed/InsetMathMacroTemplate.cpp @@ -0,0 +1,1413 @@ +/** + * \file InsetMathMacroTemplate.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author André Pönitz + * \author Stefan Schimanski + * + * Full author contact details are available in file CREDITS. + */ + +#include + +#include "InsetMathMacroTemplate.h" + +#include "InsetMathBrace.h" +#include "InsetMathChar.h" +#include "InsetMathHull.h" +#include "InsetMathSqrt.h" +#include "InsetMathMacro.h" +#include "InsetMathMacroArgument.h" +#include "MathStream.h" +#include "MathParser.h" +#include "MathSupport.h" +#include "InsetMathMacroArgument.h" + +#include "Buffer.h" +#include "BufferView.h" +#include "Color.h" +#include "Cursor.h" +#include "DispatchResult.h" +#include "DocIterator.h" +#include "FuncRequest.h" +#include "FuncStatus.h" +#include "LaTeXFeatures.h" +#include "Lexer.h" +#include "MetricsInfo.h" +#include "TocBackend.h" + +#include "frontends/Painter.h" + +#include "insets/RenderPreview.h" + +#include "support/lassert.h" +#include "support/convert.h" +#include "support/debug.h" +#include "support/gettext.h" +#include "support/docstream.h" +#include "support/lstrings.h" + +#include +#include + +using namespace std; + +namespace lyx { + +using support::bformat; + +////////////////////////////////////////////////////////////////////// + +class InsetLabelBox : public InsetMathNest { +public: + /// + InsetLabelBox(Buffer * buf, MathAtom const & atom, docstring label, + InsetMathMacroTemplate const & parent, bool frame = false); + InsetLabelBox(Buffer * buf, docstring label, InsetMathMacroTemplate const & parent, + bool frame = false); + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo &, int x, int y) const; + +protected: + /// + InsetMathMacroTemplate const & parent_; + /// + Inset * clone() const; + /// + docstring const label_; + /// + bool frame_; +}; + + +InsetLabelBox::InsetLabelBox(Buffer * buf, MathAtom const & atom, docstring label, + InsetMathMacroTemplate const & parent, bool frame) + : InsetMathNest(buf, 1), parent_(parent), label_(label), frame_(frame) +{ + cell(0).insert(0, atom); +} + + +InsetLabelBox::InsetLabelBox(Buffer * buf, docstring label, + InsetMathMacroTemplate const & parent, bool frame) + : InsetMathNest(buf, 1), parent_(parent), label_(label), frame_(frame) +{ +} + + +Inset * InsetLabelBox::clone() const +{ + return new InsetLabelBox(*this); +} + + +void InsetLabelBox::metrics(MetricsInfo & mi, Dimension & dim) const +{ + // kernel + cell(0).metrics(mi, dim); + + // frame + if (frame_) { + dim.wid += 6; + dim.asc += 5; + dim.des += 5; + } + + // adjust to common height in main metrics phase + if (!parent_.premetrics()) { + dim.asc = max(dim.asc, parent_.commonLabelBoxAscent()); + dim.des = max(dim.des, parent_.commonLabelBoxDescent()); + } + + // label + if (parent_.editing(mi.base.bv) && label_.length() > 0) { + // grey + FontInfo font = sane_font; + font.setSize(FONT_SIZE_TINY); + font.setColor(Color_mathmacrolabel); + + // make space for label and box + int lwid = mathed_string_width(font, label_); + int maxasc; + int maxdes; + math_font_max_dim(font, maxasc, maxdes); + + dim.wid = max(dim.wid, lwid + 2); + + // space for the label + if (!parent_.premetrics()) + dim.des += maxasc + maxdes + 1; + } +} + + +void InsetLabelBox::draw(PainterInfo & pi, int x, int y) const +{ + Dimension const dim = dimension(*pi.base.bv); + Dimension const cdim = cell(0).dimension(*pi.base.bv); + + // kernel + cell(0).draw(pi, x + (dim.wid - cdim.wid) / 2, y); + + // label + if (parent_.editing(pi.base.bv) && label_.length() > 0) { + // grey + FontInfo font = sane_font; + font.setSize(FONT_SIZE_TINY); + font.setColor(Color_mathmacrolabel); + + // make space for label and box + int lwid = mathed_string_width(font, label_); + int maxasc; + int maxdes; + math_font_max_dim(font, maxasc, maxdes); + + if (lwid < dim.wid) + pi.pain.text(x + (dim.wid - lwid) / 2, y + dim.des - maxdes, label_, font); + else + pi.pain.text(x, y + dim.des - maxdes, label_, font); + } + + // draw frame + int boxHeight = parent_.commonLabelBoxAscent() + parent_.commonLabelBoxDescent(); + if (frame_) { + pi.pain.rectangle(x + 1, y - dim.ascent() + 1, + dim.wid - 2, boxHeight - 2, + Color_mathline); + } +} + + +////////////////////////////////////////////////////////////////////// + +class InsetDisplayLabelBox : public InsetLabelBox { +public: + /// + InsetDisplayLabelBox(Buffer * buf, MathAtom const & atom, docstring label, + InsetMathMacroTemplate const & parent); + + /// + marker_type marker(BufferView const *) const; + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo &, int x, int y) const; + +protected: + /// + Inset * clone() const; +}; + + +InsetDisplayLabelBox::InsetDisplayLabelBox(Buffer * buf, MathAtom const & atom, + docstring label, + InsetMathMacroTemplate const & parent) + : InsetLabelBox(buf, atom, label, parent, true) +{ +} + + + +Inset * InsetDisplayLabelBox::clone() const +{ + return new InsetDisplayLabelBox(*this); +} + + +InsetMath::marker_type InsetDisplayLabelBox::marker(BufferView const * bv) const +{ + if (parent_.editing(bv) + || !parent_.cell(parent_.displayIdx()).empty()) + return MARKER; + else + return NO_MARKER; +} + + +void InsetDisplayLabelBox::metrics(MetricsInfo & mi, Dimension & dim) const +{ + InsetLabelBox::metrics(mi, dim); + if (!parent_.editing(mi.base.bv) + && parent_.cell(parent_.displayIdx()).empty()) { + dim.wid = 0; + dim.asc = 0; + dim.des = 0; + } +} + + +void InsetDisplayLabelBox::draw(PainterInfo & pi, int x, int y) const +{ + if (parent_.editing(pi.base.bv) + || !parent_.cell(parent_.displayIdx()).empty()) { + InsetLabelBox::draw(pi, x, y); + } else { + bool enabled = pi.pain.isDrawingEnabled(); + pi.pain.setDrawingEnabled(false); + InsetLabelBox::draw(pi, x, y); + pi.pain.setDrawingEnabled(enabled); + } +} + + +////////////////////////////////////////////////////////////////////// + +class InsetMathWrapper : public InsetMath { +public: + /// + InsetMathWrapper(MathData const * value) : value_(value) {} + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo &, int x, int y) const; + +private: + /// + Inset * clone() const; + /// + MathData const * value_; +}; + + +Inset * InsetMathWrapper::clone() const +{ + return new InsetMathWrapper(*this); +} + + +void InsetMathWrapper::metrics(MetricsInfo & mi, Dimension & dim) const +{ + value_->metrics(mi, dim); +} + + +void InsetMathWrapper::draw(PainterInfo & pi, int x, int y) const +{ + value_->draw(pi, x, y); +} + + +/////////////////////////////////////////////////////////////////////// +class InsetColoredCell : public InsetMathNest { +public: + /// + InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max); + /// + InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max, MathAtom const & atom); + /// + void draw(PainterInfo &, int x, int y) const; + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + +protected: + /// + Inset * clone() const; + /// + ColorCode min_; + /// + ColorCode max_; +}; + + +InsetColoredCell::InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max) + : InsetMathNest(buf, 1), min_(min), max_(max) +{ +} + + +InsetColoredCell::InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max, MathAtom const & atom) + : InsetMathNest(buf, 1), min_(min), max_(max) +{ + cell(0).insert(0, atom); +} + + +Inset * InsetColoredCell::clone() const +{ + return new InsetColoredCell(*this); +} + + +void InsetColoredCell::metrics(MetricsInfo & mi, Dimension & dim) const +{ + cell(0).metrics(mi, dim); +} + + +void InsetColoredCell::draw(PainterInfo & pi, int x, int y) const +{ + pi.pain.enterMonochromeMode(min_, max_); + cell(0).draw(pi, x, y); + pi.pain.leaveMonochromeMode(); +} + + +/////////////////////////////////////////////////////////////////////// + +class InsetNameWrapper : public InsetMathWrapper { +public: + /// + InsetNameWrapper(MathData const * value, InsetMathMacroTemplate const & parent); + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo &, int x, int y) const; + +private: + /// + InsetMathMacroTemplate const & parent_; + /// + Inset * clone() const; +}; + + +InsetNameWrapper::InsetNameWrapper(MathData const * value, + InsetMathMacroTemplate const & parent) + : InsetMathWrapper(value), parent_(parent) +{ +} + + +Inset * InsetNameWrapper::clone() const +{ + return new InsetNameWrapper(*this); +} + + +void InsetNameWrapper::metrics(MetricsInfo & mi, Dimension & dim) const +{ + Changer dummy = mi.base.changeFontSet("textit"); + InsetMathWrapper::metrics(mi, dim); + dim.wid += mathed_string_width(mi.base.font, from_ascii("\\")); +} + + +void InsetNameWrapper::draw(PainterInfo & pi, int x, int y) const +{ + ColorCode const color = parent_.validMacro() ? Color_latex : Color_error; + + Changer dummy = pi.base.changeFontSet("textit"); + Changer dummy2 = pi.base.font.changeColor(color); + + // draw backslash + pi.pain.text(x, y, from_ascii("\\"), pi.base.font); + x += mathed_string_width(pi.base.font, from_ascii("\\")); + + // draw name + InsetMathWrapper::draw(pi, x, y); +} + + +/////////////////////////////////////////////////////////////////////// + + +InsetMathMacroTemplate::InsetMathMacroTemplate(Buffer * buf) + : InsetMathNest(buf, 3), numargs_(0), argsInLook_(0), optionals_(0), + type_(MacroTypeNewcommand), redefinition_(false), lookOutdated_(true), + premetrics_(false), labelBoxAscent_(0), labelBoxDescent_(0) +{ + initMath(); +} + + +InsetMathMacroTemplate::InsetMathMacroTemplate(Buffer * buf, docstring const & name, int numargs, + int optionals, MacroType type, vector const & optionalValues, + MathData const & def, MathData const & display) + : InsetMathNest(buf, optionals + 3), numargs_(numargs), argsInLook_(numargs), + optionals_(optionals), optionalValues_(optionalValues), + type_(type), redefinition_(false), lookOutdated_(true), + premetrics_(false), labelBoxAscent_(0), labelBoxDescent_(0) +{ + initMath(); + + if (numargs_ > 9) + lyxerr << "InsetMathMacroTemplate::InsetMathMacroTemplate: wrong # of arguments: " + << numargs_ << endl; + + asArray(name, cell(0)); + optionalValues_.resize(9); + for (int i = 0; i < optionals_; ++i) + cell(optIdx(i)) = optionalValues_[i]; + cell(defIdx()) = def; + cell(displayIdx()) = display; + + updateLook(); +} + + +bool InsetMathMacroTemplate::fromString(docstring const & str) +{ + MathData ar(buffer_); + mathed_parse_cell(ar, str, Parse::NORMAL); + if (ar.size() != 1 || !ar[0]->asMacroTemplate()) { + lyxerr << "Cannot read macro from '" << ar << "'" << endl; + asArray(from_ascii("invalidmacro"), cell(0)); + // The macro template does not make sense after this. + return false; + } + operator=( *(ar[0]->asMacroTemplate()) ); + + updateLook(); + return true; +} + + +Inset * InsetMathMacroTemplate::clone() const +{ + InsetMathMacroTemplate * inset = new InsetMathMacroTemplate(*this); + // the parent pointers of the proxy insets above will point to + // to the old template. Hence, the look must be updated. + inset->updateLook(); + return inset; +} + + +docstring InsetMathMacroTemplate::name() const +{ + return asString(cell(0)); +} + + +void InsetMathMacroTemplate::updateToContext(MacroContext const & mc) +{ + redefinition_ = mc.get(name()) != 0; +} + + +void InsetMathMacroTemplate::updateLook() const +{ + lookOutdated_ = true; +} + + +void InsetMathMacroTemplate::createLook(int args) const +{ + look_.clear(); + argsInLook_ = args; + + // \foo + look_.push_back(MathAtom( + new InsetLabelBox(buffer_, _("Name"), *this, false))); + MathData & nameData = look_[look_.size() - 1].nucleus()->cell(0); + nameData.push_back(MathAtom(new InsetNameWrapper(&cell(0), *this))); + + // [#1][#2] + int i = 0; + if (optionals_ > 0) { + look_.push_back(MathAtom( + new InsetLabelBox(buffer_, _("optional"), *this, false))); + + MathData * optData = &look_[look_.size() - 1].nucleus()->cell(0); + for (; i < optionals_; ++i) { + // color it light grey, if it is to be removed when the cursor leaves + if (i == argsInLook_) { + optData->push_back(MathAtom( + new InsetColoredCell(buffer_, Color_mathbg, Color_mathmacrooldarg))); + optData = &(*optData)[optData->size() - 1].nucleus()->cell(0); + } + + optData->push_back(MathAtom(new InsetMathChar('['))); + optData->push_back(MathAtom(new InsetMathWrapper(&cell(1 + i)))); + optData->push_back(MathAtom(new InsetMathChar(']'))); + } + } + + // {#3}{#4} + for (; i < numargs_; ++i) { + MathData arg; + arg.push_back(MathAtom(new InsetMathMacroArgument(i + 1))); + if (i >= argsInLook_) { + look_.push_back(MathAtom(new InsetColoredCell(buffer_, + Color_mathbg, Color_mathmacrooldarg, + MathAtom(new InsetMathBrace(arg))))); + } else + look_.push_back(MathAtom(new InsetMathBrace(arg))); + } + for (; i < argsInLook_; ++i) { + MathData arg; + arg.push_back(MathAtom(new InsetMathMacroArgument(i + 1))); + look_.push_back(MathAtom(new InsetColoredCell(buffer_, + Color_mathbg, Color_mathmacronewarg, + MathAtom(new InsetMathBrace(arg))))); + } + + // := + look_.push_back(MathAtom(new InsetMathChar(':'))); + look_.push_back(MathAtom(new InsetMathChar('='))); + + // definition + look_.push_back(MathAtom( + new InsetLabelBox(buffer_, MathAtom( + new InsetMathWrapper(&cell(defIdx()))), _("TeX"), *this, true))); + + // display + look_.push_back(MathAtom( + new InsetDisplayLabelBox(buffer_, MathAtom( + new InsetMathWrapper(&cell(displayIdx()))), _("LyX"), *this))); +} + + +void InsetMathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const +{ + Changer dummy1 = mi.base.changeFontSet("mathnormal"); + Changer dummy2 = mi.base.font.changeStyle(LM_ST_TEXT); + + // valid macro? + MacroData const * macro = 0; + if (validName()) + macro = mi.macrocontext.get(name()); + + // update look? + int argsInDef = maxArgumentInDefinition(); + if (lookOutdated_ || argsInDef != argsInLook_) { + lookOutdated_ = false; + createLook(argsInDef); + } + + /// metrics for inset contents + if (macro) + macro->lock(); + + // first phase, premetric: + premetrics_ = true; + look_.metrics(mi, dim); + labelBoxAscent_ = dim.asc; + labelBoxDescent_ = dim.des; + + // second phase, main metric: + premetrics_ = false; + look_.metrics(mi, dim); + + if (macro) + macro->unlock(); + + dim.wid += 6; + dim.des += 2; + dim.asc += 2; +} + + +void InsetMathMacroTemplate::draw(PainterInfo & pi, int x, int y) const +{ + // FIXME: Calling Changer on the same object repeatedly is inefficient. + Changer dummy0 = pi.base.font.changeColor(Color_math); + Changer dummy1 = pi.base.changeFontSet("mathnormal"); + Changer dummy2 = pi.base.font.changeStyle(LM_ST_TEXT); + + Dimension const dim = dimension(*pi.base.bv); + + // draw outer frame + int const a = y - dim.asc + 1; + int const w = dim.wid - 2; + int const h = dim.height() - 2; + pi.pain.rectangle(x + 1, a, w, h, Color_mathframe); + + // just to be sure: set some dummy values for coord cache + for (idx_type i = 0; i < nargs(); ++i) + cell(i).setXY(*pi.base.bv, x, y); + + // draw contents + look_.draw(pi, x + 3, y); +} + + +void InsetMathMacroTemplate::edit(Cursor & cur, bool front, EntryDirection entry_from) +{ + updateLook(); + cur.screenUpdateFlags(Update::SinglePar); + InsetMathNest::edit(cur, front, entry_from); +} + + +bool InsetMathMacroTemplate::notifyCursorLeaves(Cursor const & old, Cursor & cur) +{ + unsigned int const nargs_before = nargs(); + commitEditChanges(cur, old); + updateLook(); + cur.screenUpdateFlags(Update::Force); + // If we have removed a cell, we might have invalidated the cursor + return InsetMathNest::notifyCursorLeaves(old, cur) + || nargs() < nargs_before; +} + + +void InsetMathMacroTemplate::removeArguments(Cursor & cur, + DocIterator const & /*inset_pos*/, int from, int to) +{ + DocIterator it = doc_iterator_begin(&buffer(), this); + for (; it; it.forwardChar()) { + if (!it.nextInset()) + continue; + if (it.nextInset()->lyxCode() != MATH_MACROARG_CODE) + continue; + InsetMathMacroArgument * arg = static_cast(it.nextInset()); + int n = arg->number() - 1; + if (from <= n && n <= to) { + int cellSlice = cur.find(it.cell()); + if (cellSlice != -1 && cur[cellSlice].pos() > it.pos()) + --cur[cellSlice].pos(); + + it.cell().erase(it.pos()); + } + } + + updateLook(); +} + + +void InsetMathMacroTemplate::shiftArguments(size_t from, int by) +{ + for (DocIterator it = doc_iterator_begin(&buffer(), this); it; it.forwardChar()) { + if (!it.nextInset()) + continue; + if (it.nextInset()->lyxCode() != MATH_MACROARG_CODE) + continue; + InsetMathMacroArgument * arg = static_cast(it.nextInset()); + if (arg->number() >= int(from) + 1) + arg->setNumber(arg->number() + by); + } + + updateLook(); +} + + +int InsetMathMacroTemplate::maxArgumentInDefinition() const +{ + // We don't have a buffer when pasting from the clipboard (bug 6014). + Buffer const * macro_buffer = isBufferLoaded() ? &buffer() : 0; + int maxArg = 0; + DocIterator it = doc_iterator_begin(macro_buffer, this); + it.idx() = defIdx(); + for (; it; it.forwardChar()) { + if (!it.nextInset()) + continue; + if (it.nextInset()->lyxCode() != MATH_MACROARG_CODE) + continue; + InsetMathMacroArgument * arg = static_cast(it.nextInset()); + maxArg = std::max(int(arg->number()), maxArg); + } + return maxArg; +} + + +void InsetMathMacroTemplate::insertMissingArguments(int maxArg) +{ + bool found[9] = { false, false, false, false, false, false, false, false, false }; + idx_type idx = cell(displayIdx()).empty() ? defIdx() : displayIdx(); + + // search for #n macros arguments + DocIterator it = doc_iterator_begin(&buffer(), this); + it.idx() = idx; + for (; it && it[0].idx() == idx; it.forwardChar()) { + if (!it.nextInset()) + continue; + if (it.nextInset()->lyxCode() != MATH_MACROARG_CODE) + continue; + InsetMathMacroArgument * arg = static_cast(it.nextInset()); + found[arg->number() - 1] = true; + } + + // add missing ones + for (int i = 0; i < maxArg; ++i) { + if (found[i]) + continue; + + cell(idx).push_back(MathAtom(new InsetMathMacroArgument(i + 1))); + } +} + + +void InsetMathMacroTemplate::changeArity(Cursor & cur, + DocIterator const & inset_pos, int newNumArg) +{ + // remove parameter which do not appear anymore in the definition + for (int i = numargs_; i > newNumArg; --i) + removeParameter(cur, inset_pos, numargs_ - 1, true); + + // add missing parameter + for (int i = numargs_; i < newNumArg; ++i) + insertParameter(cur, inset_pos, numargs_, true, false); +} + + +/// +class AddRemoveMacroInstanceFix +{ +public: + /// + AddRemoveMacroInstanceFix(int n, bool insert) : n_(n), insert_(insert) {} + /// + void operator()(InsetMathMacro * macro) + { + if (macro->folded()) { + if (insert_) + macro->insertArgument(n_); + else + macro->removeArgument(n_); + } + } + +private: + /// + int n_; + /// + bool insert_; +}; + + +/// +class OptionalsMacroInstanceFix +{ +public: + /// + OptionalsMacroInstanceFix(int optionals) : optionals_(optionals) {} + /// + void operator()(InsetMathMacro * macro) + { + macro->setOptionals(optionals_); + } + +private: + /// + int optionals_; +}; + + +/// +class NullMacroInstanceFix +{ +public: + /// + void operator()(InsetMathMacro * ) {} +}; + + +template +void fixMacroInstances(Cursor & cur, DocIterator const & inset_pos, + docstring const & name, F & fix) +{ + // goto position behind macro template + DocIterator dit = inset_pos; + dit.pop_back(); + dit.top().forwardPos(); + + // remember hull to trigger preview reload + DocIterator hull(dit.buffer()); + bool preview_reload_needed = false; + set preview_hulls; + + // iterate over all positions until macro is redefined + for (; dit; dit.forwardPos()) { + // left the outer hull? + if (!hull.empty() && dit.depth() == hull.depth()) { + // schedule reload of the preview if necessary + if (preview_reload_needed) { + preview_hulls.insert(hull); + preview_reload_needed = false; + } + hull.clear(); + } + + // only until a macro is redefined + if (dit.inset().lyxCode() == MATHMACRO_CODE) { + InsetMathMacroTemplate const & macroTemplate + = static_cast(dit.inset()); + if (macroTemplate.name() == name) + break; + } + + // in front of macro instance? + Inset * inset = dit.nextInset(); + if (!inset) + continue; + InsetMath * insetMath = inset->asInsetMath(); + if (!insetMath) + continue; + + // in front of outer hull? + InsetMathHull * inset_hull = insetMath->asHullInset(); + if (inset_hull && hull.empty()) { + // remember this for later preview reload + hull = dit; + } + + InsetMathMacro * macro = insetMath->asMacro(); + if (macro && macro->name() == name && macro->folded()) { + fix(macro); + if (RenderPreview::previewMath()) + preview_reload_needed = true; + } + } + + if (!preview_hulls.empty()) { + // reload the scheduled previews + set::const_iterator sit = preview_hulls.begin(); + set::const_iterator end = preview_hulls.end(); + for (; sit != end; ++sit) { + InsetMathHull * inset_hull = + sit->nextInset()->asInsetMath()->asHullInset(); + LBUFERR(inset_hull); + inset_hull->reloadPreview(*sit); + } + cur.screenUpdateFlags(Update::Force); + } +} + + +void InsetMathMacroTemplate::commitEditChanges(Cursor & cur, + DocIterator const & inset_pos) +{ + int args_in_def = maxArgumentInDefinition(); + if (args_in_def != numargs_) { + // FIXME: implement precise undo handling (only a few places + // need undo) + cur.recordUndoFullBuffer(); + changeArity(cur, inset_pos, args_in_def); + } + insertMissingArguments(args_in_def); + + // make sure the preview are up to date + NullMacroInstanceFix fix; + fixMacroInstances(cur, inset_pos, name(), fix); +} + + +void InsetMathMacroTemplate::insertParameter(Cursor & cur, + DocIterator const & inset_pos, int pos, bool greedy, bool addarg) +{ + if (pos <= numargs_ && pos >= optionals_ && numargs_ < 9) { + ++numargs_; + + // append example #n + if (addarg) { + shiftArguments(pos, 1); + + cell(defIdx()).push_back(MathAtom(new InsetMathMacroArgument(pos + 1))); + if (!cell(displayIdx()).empty()) + cell(displayIdx()).push_back(MathAtom(new InsetMathMacroArgument(pos + 1))); + } + + if (!greedy) { + // fix macro instances + AddRemoveMacroInstanceFix fix(pos, true); + fixMacroInstances(cur, inset_pos, name(), fix); + } + } + + updateLook(); +} + + +void InsetMathMacroTemplate::removeParameter(Cursor & cur, + DocIterator const & inset_pos, int pos, bool greedy) +{ + if (pos < numargs_ && pos >= 0) { + --numargs_; + removeArguments(cur, inset_pos, pos, pos); + shiftArguments(pos + 1, -1); + + // removed optional parameter? + if (pos < optionals_) { + --optionals_; + optionalValues_[pos] = cell(optIdx(pos)); + cells_.erase(cells_.begin() + optIdx(pos)); + + // fix cursor + int macroSlice = cur.find(this); + if (macroSlice != -1) { + if (cur[macroSlice].idx() == optIdx(pos)) { + cur.cutOff(macroSlice); + cur[macroSlice].idx() = 1; + cur[macroSlice].pos() = 0; + } else if (cur[macroSlice].idx() > optIdx(pos)) + --cur[macroSlice].idx(); + } + } + + if (!greedy) { + // fix macro instances + AddRemoveMacroInstanceFix fix(pos, false); + fixMacroInstances(cur, inset_pos, name(), fix); + } + } + + updateLook(); +} + + +void InsetMathMacroTemplate::makeOptional(Cursor & cur, + DocIterator const & inset_pos) +{ + if (numargs_ > 0 && optionals_ < numargs_) { + ++optionals_; + cells_.insert(cells_.begin() + optIdx(optionals_ - 1), optionalValues_[optionals_ - 1]); + // fix cursor + int macroSlice = cur.find(this); + if (macroSlice != -1 && cur[macroSlice].idx() >= optIdx(optionals_ - 1)) + ++cur[macroSlice].idx(); + + // fix macro instances + OptionalsMacroInstanceFix fix(optionals_); + fixMacroInstances(cur, inset_pos, name(), fix); + } + + updateLook(); +} + + +void InsetMathMacroTemplate::makeNonOptional(Cursor & cur, + DocIterator const & inset_pos) +{ + if (numargs_ > 0 && optionals_ > 0) { + --optionals_; + + // store default value for later if the user changes his mind + optionalValues_[optionals_] = cell(optIdx(optionals_)); + cells_.erase(cells_.begin() + optIdx(optionals_)); + + // fix cursor + int macroSlice = cur.find(this); + if (macroSlice != -1) { + if (cur[macroSlice].idx() > optIdx(optionals_)) + --cur[macroSlice].idx(); + else if (cur[macroSlice].idx() == optIdx(optionals_)) { + cur.cutOff(macroSlice); + cur[macroSlice].idx() = optIdx(optionals_); + cur[macroSlice].pos() = 0; + } + } + + // fix macro instances + OptionalsMacroInstanceFix fix(optionals_); + fixMacroInstances(cur, inset_pos, name(), fix); + } + + updateLook(); +} + + +void InsetMathMacroTemplate::doDispatch(Cursor & cur, FuncRequest & cmd) +{ + string const arg = to_utf8(cmd.argument()); + switch (cmd.action()) { + + case LFUN_MATH_MACRO_ADD_PARAM: + if (numargs_ < 9) { + commitEditChanges(cur, cur); + // FIXME: implement precise undo handling (only a few places + // need undo) + cur.recordUndoFullBuffer(); + size_t pos = numargs_; + if (!arg.empty()) + pos = (size_t)convert(arg) - 1; // it is checked for >=0 in getStatus + insertParameter(cur, cur, pos); + } + break; + + + case LFUN_MATH_MACRO_REMOVE_PARAM: + if (numargs_ > 0) { + commitEditChanges(cur, cur); + // FIXME: implement precise undo handling (only a few places + // need undo) + cur.recordUndoFullBuffer(); + size_t pos = numargs_ - 1; + if (!arg.empty()) + pos = (size_t)convert(arg) - 1; // it is checked for >=0 in getStatus + removeParameter(cur, cur, pos); + } + break; + + case LFUN_MATH_MACRO_APPEND_GREEDY_PARAM: + if (numargs_ < 9) { + commitEditChanges(cur, cur); + // FIXME: implement precise undo handling (only a few places + // need undo) + cur.recordUndoFullBuffer(); + insertParameter(cur, cur, numargs_, true); + } + break; + + case LFUN_MATH_MACRO_REMOVE_GREEDY_PARAM: + if (numargs_ > 0) { + commitEditChanges(cur, cur); + // FIXME: implement precise undo handling (only a few places + // need undo) + cur.recordUndoFullBuffer(); + removeParameter(cur, cur, numargs_ - 1, true); + } + break; + + case LFUN_MATH_MACRO_MAKE_OPTIONAL: + commitEditChanges(cur, cur); + // FIXME: implement precise undo handling (only a few places + // need undo) + cur.recordUndoFullBuffer(); + makeOptional(cur, cur); + break; + + case LFUN_MATH_MACRO_MAKE_NONOPTIONAL: + commitEditChanges(cur, cur); + // FIXME: implement precise undo handling (only a few places + // need undo) + cur.recordUndoFullBuffer(); + makeNonOptional(cur, cur); + break; + + case LFUN_MATH_MACRO_ADD_OPTIONAL_PARAM: + if (numargs_ < 9) { + commitEditChanges(cur, cur); + // FIXME: implement precise undo handling (only a few places + // need undo) + cur.recordUndoFullBuffer(); + insertParameter(cur, cur, optionals_); + makeOptional(cur, cur); + } + break; + + case LFUN_MATH_MACRO_REMOVE_OPTIONAL_PARAM: + if (optionals_ > 0) { + commitEditChanges(cur, cur); + // FIXME: implement precise undo handling (only a few places + // need undo) + cur.recordUndoFullBuffer(); + removeParameter(cur, cur, optionals_ - 1); + } break; + + case LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM: + if (numargs_ == optionals_) { + commitEditChanges(cur, cur); + // FIXME: implement precise undo handling (only a few places + // need undo) + cur.recordUndoFullBuffer(); + insertParameter(cur, cur, 0, true); + makeOptional(cur, cur); + } + break; + + default: + InsetMathNest::doDispatch(cur, cmd); + break; + } +} + + +bool InsetMathMacroTemplate::getStatus(Cursor & cur, FuncRequest const & cmd, + FuncStatus & flag) const +{ + bool ret = true; + string const arg = to_utf8(cmd.argument()); + switch (cmd.action()) { + case LFUN_MATH_MACRO_ADD_PARAM: { + int num = numargs_ + 1; + if (!arg.empty()) + num = convert(arg); + bool on = (num >= optionals_ + && numargs_ < 9 && num <= numargs_ + 1); + flag.setEnabled(on); + break; + } + + case LFUN_MATH_MACRO_APPEND_GREEDY_PARAM: + flag.setEnabled(numargs_ < 9); + break; + + case LFUN_MATH_MACRO_REMOVE_GREEDY_PARAM: + case LFUN_MATH_MACRO_REMOVE_PARAM: { + int num = numargs_; + if (!arg.empty()) + num = convert(arg); + flag.setEnabled(num >= 1 && num <= numargs_); + break; + } + + case LFUN_MATH_MACRO_MAKE_OPTIONAL: + flag.setEnabled(numargs_ > 0 + && optionals_ < numargs_ + && type_ != MacroTypeDef); + break; + + case LFUN_MATH_MACRO_MAKE_NONOPTIONAL: + flag.setEnabled(optionals_ > 0 + && type_ != MacroTypeDef); + break; + + case LFUN_MATH_MACRO_ADD_OPTIONAL_PARAM: + flag.setEnabled(numargs_ < 9); + break; + + case LFUN_MATH_MACRO_REMOVE_OPTIONAL_PARAM: + flag.setEnabled(optionals_ > 0); + break; + + case LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM: + flag.setEnabled(numargs_ == 0 + && type_ != MacroTypeDef); + break; + + case LFUN_IN_MATHMACROTEMPLATE: + flag.setEnabled(true); + break; + + default: + ret = InsetMathNest::getStatus(cur, cmd, flag); + break; + } + return ret; +} + + +void InsetMathMacroTemplate::read(Lexer & lex) +{ + MathData ar(buffer_); + mathed_parse_cell(ar, lex.getStream(), Parse::TRACKMACRO); + if (ar.size() != 1 || !ar[0]->asMacroTemplate()) { + lyxerr << "Cannot read macro from '" << ar << "'" << endl; + lyxerr << "Read: " << to_utf8(asString(ar)) << endl; + return; + } + operator=( *(ar[0]->asMacroTemplate()) ); + + updateLook(); +} + + +void InsetMathMacroTemplate::write(ostream & os) const +{ + odocstringstream oss; + otexrowstream ots(oss); + WriteStream wi(ots, false, false, WriteStream::wsDefault); + oss << "FormulaMacro\n"; + write(wi); + os << to_utf8(oss.str()); +} + + +void InsetMathMacroTemplate::write(WriteStream & os) const +{ + write(os, false); +} + + +int InsetMathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition) const +{ + int num_lines = 0; + + if (os.latex()) { + if (optionals_ > 0) { + // macros with optionals use the xargs package, e.g.: + // \newcommandx{\foo}[2][usedefault, addprefix=\global,1=default]{#1,#2} + // \long is implicit by xargs + if (redefinition_ && !overwriteRedefinition) + os << "\\renewcommandx"; + else + os << "\\newcommandx"; + + os << "\\" << name() + << "[" << numargs_ << "]" + << "[usedefault, addprefix=\\global"; + for (int i = 0; i < optionals_; ++i) { + docstring optValue = asString(cell(optIdx(i))); + if (optValue.find(']') != docstring::npos + || optValue.find(',') != docstring::npos) + os << ", " << i + 1 << "=" + << "{" << cell(optIdx(i)) << "}"; + else + os << ", " << i + 1 << "=" + << cell(optIdx(i)); + } + os << "]"; + } else { + // Macros without optionals use standard _global_ \def macros: + // \global\def\long\foo#1#2{#1,#2} + // We use the \long prefix as this is the equivalent to \newcommand. + // We cannot use \newcommand directly because \global does not work with it. + os << "\\global\\long\\def\\" << name(); + docstring param = from_ascii("#0"); + for (int i = 1; i <= numargs_; ++i) { + param[1] = '0' + i; + os << param; + } + } + } else { + // in LyX output we use some pseudo syntax which is implementation + // independent, e.g. + // \newcommand{\foo}[2][default]{#1,#2} + if (redefinition_ && !overwriteRedefinition) + os << "\\renewcommand"; + else + os << "\\newcommand"; + os << "{\\" << name() << '}'; + if (numargs_ > 0) + os << '[' << numargs_ << ']'; + + for (int i = 0; i < optionals_; ++i) { + docstring optValue = asString(cell(optIdx(i))); + if (optValue.find(']') != docstring::npos) + os << "[{" << cell(optIdx(i)) << "}]"; + else + os << "[" << cell(optIdx(i)) << "]"; + } + } + + os << "{" << cell(defIdx()) << "}"; + + if (os.latex()) { + // writing .tex. done. + os << "\n"; + ++num_lines; + } else { + // writing .lyx, write special .tex export only if necessary + if (!cell(displayIdx()).empty()) { + os << "\n{" << cell(displayIdx()) << '}'; + ++num_lines; + } + } + + return num_lines; +} + + +docstring InsetMathMacroTemplate::xhtml(XHTMLStream &, OutputParams const &) const +{ + return docstring(); +} + +int InsetMathMacroTemplate::plaintext(odocstringstream & os, + OutputParams const &, size_t) const +{ + docstring const str = '[' + buffer().B_("math macro") + ']'; + + os << str; + return str.size(); +} + + +bool InsetMathMacroTemplate::validName() const +{ + docstring n = name(); + + if (n.empty()) + return false; + + // converting back and force doesn't swallow anything? + /*MathData ma; + asArray(n, ma); + if (asString(ma) != n) + return false;*/ + + // valid characters? + for (size_t i = 0; i < n.size(); ++i) { + if (!(n[i] >= 'a' && n[i] <= 'z') + && !(n[i] >= 'A' && n[i] <= 'Z') + && n[i] != '*') + return false; + } + + return true; +} + + +bool InsetMathMacroTemplate::validMacro() const +{ + return validName(); +} + + +bool InsetMathMacroTemplate::fixNameAndCheckIfValid() +{ + // check all the characters/insets in the name cell + size_t i = 0; + MathData & data = cell(0); + while (i < data.size()) { + InsetMathChar const * cinset = data[i]->asCharInset(); + if (cinset) { + // valid character in [a-zA-Z]? + char_type c = cinset->getChar(); + if ((c >= 'a' && c <= 'z') + || (c >= 'A' && c <= 'Z')) { + ++i; + continue; + } + } + + // throw cell away + data.erase(i); + } + + // now it should be valid if anything in the name survived + return !data.empty(); +} + + +void InsetMathMacroTemplate::validate(LaTeXFeatures & features) const +{ + // we need global optional macro arguments. They are not available + // with \def, and \newcommand does not support global macros. So we + // are bound to xargs also for the single-optional-parameter case. + if (optionals_ > 0) + features.require("xargs"); +} + +void InsetMathMacroTemplate::getDefaults(vector & defaults) const +{ + defaults.resize(numargs_); + for (int i = 0; i < optionals_; ++i) + defaults[i] = asString(cell(optIdx(i))); +} + + +docstring InsetMathMacroTemplate::definition() const +{ + return asString(cell(defIdx())); +} + + +docstring InsetMathMacroTemplate::displayDefinition() const +{ + return asString(cell(displayIdx())); +} + + +size_t InsetMathMacroTemplate::numArgs() const +{ + return numargs_; +} + + +size_t InsetMathMacroTemplate::numOptionals() const +{ + return optionals_; +} + + +void InsetMathMacroTemplate::infoize(odocstream & os) const +{ + os << bformat(_("Math Macro: \\%1$s"), name()); +} + + +string InsetMathMacroTemplate::contextMenuName() const +{ + return "context-math-macro-definition"; +} + + +void InsetMathMacroTemplate::addToToc(DocIterator const & pit, bool output_active, + UpdateType, TocBackend & backend) const +{ + docstring str; + if (!validMacro()) + str = bformat(_("Invalid macro! \\%1$s"), name()); + else + str = "\\" + name(); + TocBuilder & b = backend.builder("math-macro"); + b.pushItem(pit, str, output_active); + b.pop(); +} + + +} // namespace lyx diff --git a/src/mathed/InsetMathMacroTemplate.h b/src/mathed/InsetMathMacroTemplate.h new file mode 100644 index 0000000000..ddcfe4df78 --- /dev/null +++ b/src/mathed/InsetMathMacroTemplate.h @@ -0,0 +1,192 @@ +// -*- C++ -*- +/** + * \file math_macrotemplate.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Alejandro Aguilar Sierra + * \author André Pönitz + * + * Full author contact details are available in file CREDITS. + */ + +#ifndef MATH_MACROTEMPLATE_H +#define MATH_MACROTEMPLATE_H + +#include "InsetMathNest.h" +#include "MacroTable.h" +#include "MathData.h" + + +namespace lyx { + +class OutputParams; +class XHTMLStream; + +/// This class contains the macro definition. +class InsetMathMacroTemplate : public InsetMathNest { +public: + /// + InsetMathMacroTemplate(Buffer * buf); + /// + InsetMathMacroTemplate(Buffer * buf, docstring const & name, int nargs, + int optional, MacroType type, + std::vector const & optionalValues = std::vector(), + MathData const & def = MathData(), + MathData const & display = MathData()); + /// parses from string, returns false if failed + bool fromString (const docstring & str); + /// + bool editable() const { return true; } + /// + void edit(Cursor & cur, bool front, EntryDirection entry_from); + /// + bool notifyCursorLeaves(Cursor const & old, Cursor & cur); + /// + void read(Lexer & lex); + /// + void write(std::ostream & os) const; + /// + void write(WriteStream & os) const; + /// Output LaTeX code, but assume that the macro is not definied yet + /// if overwriteRedefinition is true + int write(WriteStream & os, bool overwriteRedefinition) const; + /// Nothing happens. This is simply to suppress the default output. + docstring xhtml(XHTMLStream &, OutputParams const &) const; + /// + int plaintext(odocstringstream &, OutputParams const &, size_t) const; + /// + bool inheritFont() const { return false; } + + /// + docstring name() const; + /// + void getDefaults(std::vector & defaults) const; + /// + docstring definition() const; + /// + docstring displayDefinition() const; + /// + size_t numArgs() const; + /// + size_t numOptionals() const; + /// + bool redefinition() const { return redefinition_; } + /// + MacroType type() const { return type_; } + + /// check name and possible other formal properties + bool validMacro() const; + /// + bool validName() const; + /// Remove everything from the name which makes it invalid + /// and return true iff it is valid. + bool fixNameAndCheckIfValid(); + + /// request "external features" + virtual void validate(LaTeXFeatures &) const; + + /// decide whether its a redefinition + void updateToContext(MacroContext const & mc); + + /// + void draw(PainterInfo & pi, int x, int y) const; + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// identifies macro templates + InsetMathMacroTemplate * asMacroTemplate() { return this; } + /// identifies macro templates + InsetMathMacroTemplate const * asMacroTemplate() const { return this; } + /// + InsetCode lyxCode() const { return MATHMACRO_CODE; } + /// + void infoize(odocstream & os) const; + /// + std::string contextMenuName() const; + /// + void addToToc(DocIterator const & di, bool output_active, + UpdateType utype, TocBackend & backend) const; +protected: + /// + virtual void doDispatch(Cursor & cur, FuncRequest & cmd); + /// do we want to handle this event? + bool getStatus(Cursor & cur, FuncRequest const & cmd, + FuncStatus & status) const; + +private: + friend class InsetLabelBox; + friend class InsetDisplayLabelBox; + + /// + virtual Inset * clone() const; + + /// remove #n with from<=n<=to + void removeArguments(Cursor & cur, DocIterator const & inset_pos, + int from, int to); + /// shift every #n with from<=n, i.e. #n -> #(n-by) + void shiftArguments(size_t from, int by); + /// + void insertParameter(Cursor & cur, DocIterator const & inset_pos, + int pos, bool greedy = false, bool addarg = true); + /// + void removeParameter(Cursor & cur, DocIterator const & inset_pos, + int pos, bool greedy = false); + /// + void makeOptional(Cursor & cur, DocIterator const & inset_pos); + /// + void makeNonOptional(Cursor & cur, DocIterator const & inset_pos); + /// + idx_type defIdx() const { return optionals_ + 1; } + /// index of default value cell of optional parameter (#1 -> n=0) + idx_type optIdx(idx_type n) const { return n + 1; } + /// + idx_type displayIdx() const { return optionals_ + 2; } + /// + void updateLook() const; + /// look through the macro for #n arguments + int maxArgumentInDefinition() const; + /// add missing #n arguments up to \c maxArg + void insertMissingArguments(int maxArg); + /// change the arity + void changeArity(Cursor & cur, DocIterator const & inset_pos, + int newNumArg); + /// find arguments in definition and adapt the arity accordingly + void commitEditChanges(Cursor & cur, DocIterator const & inset_pos); + /// The representation of the macro template, with some holes to edit + mutable MathData look_; + /// + mutable int numargs_; + /// + mutable int argsInLook_; + /// + int optionals_; + /// keeps the old optional default value when an + /// optional argument is disabled + std::vector optionalValues_; + + /// (re)newcommand or def + mutable MacroType type_; + /// defined before already? + bool redefinition_; + /// + void createLook(int args) const; + /// + mutable bool lookOutdated_; + /// true if in pre-calculations of metrics to get height of boxes + mutable bool premetrics_; + /// + mutable int labelBoxAscent_; + /// + mutable int labelBoxDescent_; + /// + bool premetrics() const { return premetrics_; } + /// + int commonLabelBoxAscent() const { return labelBoxAscent_; } + /// + int commonLabelBoxDescent() const { return labelBoxDescent_; } +}; + + +} // namespace lyx + +#endif diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 993b6fc0fe..f9c8813a01 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -32,8 +32,8 @@ #include "MathCompletionList.h" #include "MathData.h" #include "MathFactory.h" -#include "MathMacro.h" -#include "MathMacroArgument.h" +#include "InsetMathMacro.h" +#include "InsetMathMacroArgument.h" #include "MathParser.h" #include "MathStream.h" #include "MathSupport.h" @@ -1206,7 +1206,7 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd) bool fold = act == LFUN_MATH_MACRO_FOLD; bool found = findMacroToFoldUnfold(it, fold); if (found) { - MathMacro * macro = it.nextInset()->asInsetMath()->asMacro(); + InsetMathMacro * macro = it.nextInset()->asInsetMath()->asMacro(); cur.recordUndoInset(); if (fold) macro->fold(cur); @@ -1302,7 +1302,7 @@ bool InsetMathNest::findMacroToFoldUnfold(Cursor & it, bool fold) const { // go backward through the current cell Inset * inset = it.nextInset(); while (inset && inset->asInsetMath()) { - MathMacro * macro = inset->asInsetMath()->asMacro(); + InsetMathMacro * macro = inset->asInsetMath()->asMacro(); if (macro) { // found the an macro to open/close? if (macro->folded() != fold) @@ -1637,7 +1637,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c) cur.backspace(); int n = c - '0'; if (n >= 1 && n <= 9) - cur.insert(new MathMacroArgument(n)); + cur.insert(new InsetMathMacroArgument(n)); return true; } diff --git a/src/mathed/InsetMathRef.cpp b/src/mathed/InsetMathRef.cpp index 22807f15b5..42151209e7 100644 --- a/src/mathed/InsetMathRef.cpp +++ b/src/mathed/InsetMathRef.cpp @@ -38,12 +38,12 @@ using namespace std; namespace lyx { InsetMathRef::InsetMathRef(Buffer * buf) - : CommandInset(buf, from_ascii("ref"), false) + : InsetMathCommand(buf, from_ascii("ref"), false) {} InsetMathRef::InsetMathRef(Buffer * buf, docstring const & data) - : CommandInset(buf, data, false) + : InsetMathCommand(buf, data, false) {} @@ -116,7 +116,7 @@ void InsetMathRef::doDispatch(Cursor & cur, FuncRequest & cmd) break; default: - CommandInset::doDispatch(cur, cmd); + InsetMathCommand::doDispatch(cur, cmd); break; } } @@ -136,7 +136,7 @@ bool InsetMathRef::getStatus(Cursor & cur, FuncRequest const & cmd, status.setEnabled(true); return true; default: - return CommandInset::getStatus(cur, cmd, status); + return InsetMathCommand::getStatus(cur, cmd, status); } } diff --git a/src/mathed/InsetMathRef.h b/src/mathed/InsetMathRef.h index 8011f9452c..d1046d9aba 100644 --- a/src/mathed/InsetMathRef.h +++ b/src/mathed/InsetMathRef.h @@ -13,14 +13,14 @@ #define REF_INSET_H -#include "CommandInset.h" +#include "InsetMathCommand.h" namespace lyx { class Buffer; // for \ref -class InsetMathRef : public CommandInset { +class InsetMathRef : public InsetMathCommand { public: /// InsetMathRef(Buffer * buf); diff --git a/src/mathed/MacroTable.cpp b/src/mathed/MacroTable.cpp index 2899e40c2e..d279bdb844 100644 --- a/src/mathed/MacroTable.cpp +++ b/src/mathed/MacroTable.cpp @@ -12,8 +12,8 @@ #include "InsetMathSqrt.h" #include "MacroTable.h" -#include "MathMacroTemplate.h" -#include "MathMacroArgument.h" +#include "InsetMathMacroTemplate.h" +#include "InsetMathMacroArgument.h" #include "MathParser.h" #include "MathStream.h" #include "MathSupport.h" @@ -55,7 +55,7 @@ MacroData::MacroData(Buffer * buf, DocIterator const & pos) } -MacroData::MacroData(Buffer * buf, MathMacroTemplate const & macro) +MacroData::MacroData(Buffer * buf, InsetMathMacroTemplate const & macro) : buffer_(buf), queried_(false), numargs_(0), sym_(0), optionals_(0), lockCount_(0), redefinition_(false), type_(MacroTypeNewcommand) { @@ -81,7 +81,7 @@ bool MacroData::expand(vector const & args, MathData & to) const continue; //it.cell().erase(it.pos()); //it.cell().insert(it.pos(), it.nextInset()->asInsetMath() - size_t n = static_cast(it.nextInset())->number(); + size_t n = static_cast(it.nextInset())->number(); if (n <= args.size()) { it.cell().erase(it.pos()); it.cell().insert(it.pos(), args[n - 1]); @@ -147,7 +147,7 @@ void MacroData::unlock() const } -void MacroData::queryData(MathMacroTemplate const & macro) const +void MacroData::queryData(InsetMathMacroTemplate const & macro) const { if (queried_) return; @@ -182,7 +182,7 @@ void MacroData::updateData() const } // query the data from the macro template - queryData(static_cast(*inset)); + queryData(static_cast(*inset)); } @@ -198,8 +198,8 @@ int MacroData::write(odocstream & os, bool overwriteRedefinition) const } // output template - MathMacroTemplate const & tmpl = - static_cast(*inset); + InsetMathMacroTemplate const & tmpl = + static_cast(*inset); otexrowstream ots(os); WriteStream wi(ots, false, true, WriteStream::wsDefault); return tmpl.write(wi, overwriteRedefinition); @@ -244,7 +244,7 @@ MacroTable::iterator MacroTable::insert(Buffer * buf, docstring const & def) { //lyxerr << "MacroTable::insert, def: " << to_utf8(def) << endl; - MathMacroTemplate mac(buf); + InsetMathMacroTemplate mac(buf); mac.fromString(def); MacroData data(buf, mac); return insert(mac.name(), data); diff --git a/src/mathed/MacroTable.h b/src/mathed/MacroTable.h index bc445d4397..eb613cae07 100644 --- a/src/mathed/MacroTable.h +++ b/src/mathed/MacroTable.h @@ -25,7 +25,7 @@ namespace lyx { class Buffer; class MathData; -class MathMacroTemplate; +class InsetMathMacroTemplate; class Paragraph; class latexkeys; @@ -43,7 +43,7 @@ public: /// Create lazy MacroData which only queries the macro template when needed MacroData(Buffer * buf, DocIterator const & pos); /// Create non-lazy MacroData which directly queries the macro template - MacroData(Buffer * buf, MathMacroTemplate const & macro); + MacroData(Buffer * buf, InsetMathMacroTemplate const & macro); /// docstring const & definition() const { updateData(); return definition_; } @@ -106,7 +106,7 @@ public: private: /// - void queryData(MathMacroTemplate const & macro) const; + void queryData(InsetMathMacroTemplate const & macro) const; /// void updateData() const; /// diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp index d6522ab3a3..beb1299b9a 100644 --- a/src/mathed/MathData.cpp +++ b/src/mathed/MathData.cpp @@ -17,7 +17,7 @@ #include "InsetMathFont.h" #include "InsetMathScript.h" #include "MacroTable.h" -#include "MathMacro.h" +#include "InsetMathMacro.h" #include "MathStream.h" #include "MathSupport.h" #include "MetricsInfo.h" @@ -373,18 +373,18 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc, // If we are editing a macro, we cannot update it immediately, // otherwise wrong undo steps will be recorded (bug 6208). InsetMath const * inmath = cur ? cur->inset().asInsetMath() : 0; - MathMacro const * inmacro = inmath ? inmath->asMacro() : 0; + InsetMathMacro const * inmacro = inmath ? inmath->asMacro() : 0; docstring const edited_name = inmacro ? inmacro->name() : docstring(); // go over the array and look for macros for (size_t i = 0; i < size(); ++i) { - MathMacro * macroInset = operator[](i).nucleus()->asMacro(); + InsetMathMacro * macroInset = operator[](i).nucleus()->asMacro(); if (!macroInset || macroInset->macroName().empty() || macroInset->macroName()[0] == '^' || macroInset->macroName()[0] == '_' || (macroInset->name() == edited_name && macroInset->displayMode() == - MathMacro::DISPLAY_UNFOLDED)) + InsetMathMacro::DISPLAY_UNFOLDED)) continue; // get macro @@ -398,23 +398,23 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc, } // store old and compute new display mode - MathMacro::DisplayMode newDisplayMode; - MathMacro::DisplayMode oldDisplayMode = macroInset->displayMode(); + InsetMathMacro::DisplayMode newDisplayMode; + InsetMathMacro::DisplayMode oldDisplayMode = macroInset->displayMode(); newDisplayMode = macroInset->computeDisplayMode(); // arity changed or other reason to detach? - if (oldDisplayMode == MathMacro::DISPLAY_NORMAL + if (oldDisplayMode == InsetMathMacro::DISPLAY_NORMAL && (macroInset->arity() != macroNumArgs || macroInset->optionals() != macroOptionals - || newDisplayMode == MathMacro::DISPLAY_UNFOLDED)) + || newDisplayMode == InsetMathMacro::DISPLAY_UNFOLDED)) detachMacroParameters(cur, i); // the macro could have been copied while resizing this macroInset = operator[](i).nucleus()->asMacro(); // Cursor in \label? - if (newDisplayMode != MathMacro::DISPLAY_UNFOLDED - && oldDisplayMode == MathMacro::DISPLAY_UNFOLDED) { + if (newDisplayMode != InsetMathMacro::DISPLAY_UNFOLDED + && oldDisplayMode == InsetMathMacro::DISPLAY_UNFOLDED) { // put cursor in front of macro if (cur) { int macroSlice = cur->find(macroInset); @@ -428,19 +428,19 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc, macroInset->setDisplayMode(newDisplayMode); // arity changed? - if (newDisplayMode == MathMacro::DISPLAY_NORMAL + if (newDisplayMode == InsetMathMacro::DISPLAY_NORMAL && (macroInset->arity() != macroNumArgs || macroInset->optionals() != macroOptionals)) { // is it a virgin macro which was never attached to parameters? bool fromInitToNormalMode - = (oldDisplayMode == MathMacro::DISPLAY_INIT - || oldDisplayMode == MathMacro::DISPLAY_INTERACTIVE_INIT) - && newDisplayMode == MathMacro::DISPLAY_NORMAL; + = (oldDisplayMode == InsetMathMacro::DISPLAY_INIT + || oldDisplayMode == InsetMathMacro::DISPLAY_INTERACTIVE_INIT) + && newDisplayMode == InsetMathMacro::DISPLAY_NORMAL; // if the macro was entered interactively (i.e. not by paste or during // loading), it should not be greedy, but the cursor should // automatically jump into the macro when behind - bool interactive = (oldDisplayMode == MathMacro::DISPLAY_INTERACTIVE_INIT); + bool interactive = (oldDisplayMode == InsetMathMacro::DISPLAY_INTERACTIVE_INIT); // attach parameters attachMacroParameters(cur, i, macroNumArgs, macroOptionals, @@ -464,7 +464,7 @@ void MathData::updateMacros(Cursor * cur, MacroContext const & mc, void MathData::detachMacroParameters(DocIterator * cur, const size_type macroPos) { - MathMacro * macroInset = operator[](macroPos).nucleus()->asMacro(); + InsetMathMacro * macroInset = operator[](macroPos).nucleus()->asMacro(); // We store this now, because the inset pointer will be invalidated in the scond loop below size_t const optionals = macroInset->optionals(); @@ -595,7 +595,7 @@ void MathData::attachMacroParameters(Cursor * cur, const int macroOptionals, const bool fromInitToNormalMode, const bool interactiveInit, const size_t appetite) { - MathMacro * macroInset = operator[](macroPos).nucleus()->asMacro(); + InsetMathMacro * macroInset = operator[](macroPos).nucleus()->asMacro(); // start at atom behind the macro again, maybe with some new arguments // from the detach phase above, to add them back into the macro inset diff --git a/src/mathed/MathData.h b/src/mathed/MathData.h index f29d1e59dc..2f6ab22acd 100644 --- a/src/mathed/MathData.h +++ b/src/mathed/MathData.h @@ -38,7 +38,7 @@ class DocIterator; class LaTeXFeatures; class ReplaceData; class MacroContext; -class MathMacro; +class InsetMathMacro; class MetricsInfo; class PainterInfo; class ParIterator; diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index 79ae676fc3..cebac7c9cc 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -50,8 +50,8 @@ #include "InsetMathXYMatrix.h" #include "InsetMathDiagram.h" #include "MacroTable.h" -#include "MathMacro.h" -#include "MathMacroArgument.h" +#include "InsetMathMacro.h" +#include "InsetMathMacroArgument.h" #include "MathParser.h" #include "MathStream.h" #include "MathSupport.h" @@ -394,7 +394,7 @@ bool ensureMath(WriteStream & os, bool needs_mathmode, bool macro, } os.textMode(true); } else if (macro && brace && !needs_mathmode && !textmode_macro) { - // This is a user defined macro, not a MathMacro, so we + // This is a user defined macro, not a InsetMathMacro, so we // cannot be sure what mode is needed. We leave it in the // same environment it was entered by closing either \lyxmathsym // or \ensuremath, whichever was opened. @@ -448,7 +448,7 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf) //lyxerr << "creating inset with name: '" << to_utf8(s) << '\'' << endl; if ((s == "ce" || s == "cf") && buf && buf->params().use_package("mhchem") == BufferParams::package_off) - return MathAtom(new MathMacro(buf, s)); + return MathAtom(new InsetMathMacro(buf, s)); latexkeys const * l = in_word_set(s); if (l) { @@ -490,10 +490,10 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf) } if (s.size() == 2 && s[0] == '#' && s[1] >= '1' && s[1] <= '9') - return MathAtom(new MathMacroArgument(s[1] - '0')); + return MathAtom(new InsetMathMacroArgument(s[1] - '0')); if (s.size() == 3 && s[0] == '\\' && s[1] == '#' && s[2] >= '1' && s[2] <= '9') - return MathAtom(new MathMacroArgument(s[2] - '0')); + return MathAtom(new InsetMathMacroArgument(s[2] - '0')); if (s == "boxed") return MathAtom(new InsetMathBoxed(buf)); if (s == "fbox") @@ -671,7 +671,7 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf) if (s == "regexp") return MathAtom(new InsetMathHull(buf, hullRegexp)); - return MathAtom(new MathMacro(buf, s)); + return MathAtom(new InsetMathMacro(buf, s)); } diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp deleted file mode 100644 index 63bb44f70b..0000000000 --- a/src/mathed/MathMacro.cpp +++ /dev/null @@ -1,1331 +0,0 @@ -/** - * \file MathMacro.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Alejandro Aguilar Sierra - * \author André Pönitz - * \author Stefan Schimanski - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "MathMacro.h" - -#include "InsetMathChar.h" -#include "MathCompletionList.h" -#include "MathExtern.h" -#include "MathFactory.h" -#include "MathStream.h" -#include "MathSupport.h" - -#include "Buffer.h" -#include "BufferView.h" -#include "CoordCache.h" -#include "Cursor.h" -#include "FuncStatus.h" -#include "FuncRequest.h" -#include "LaTeXFeatures.h" -#include "LyX.h" -#include "LyXRC.h" -#include "MetricsInfo.h" - -#include "frontends/Painter.h" - -#include "support/debug.h" -#include "support/gettext.h" -#include "support/lassert.h" -#include "support/lstrings.h" -#include "support/RefChanger.h" -#include "support/textutils.h" - -#include -#include - -using namespace lyx::support; -using namespace std; - -namespace lyx { - - -/// A proxy for the macro values -class ArgumentProxy : public InsetMath { -public: - /// - ArgumentProxy(MathMacro * mathMacro, size_t idx) - : mathMacro_(mathMacro), idx_(idx) {} - /// - ArgumentProxy(MathMacro * mathMacro, size_t idx, docstring const & def) - : mathMacro_(mathMacro), idx_(idx) - { - asArray(def, def_); - } - /// - void setOwner(MathMacro * mathMacro) { mathMacro_ = mathMacro; } - /// - MathMacro const * owner() { return mathMacro_; } - /// - marker_type marker(BufferView const *) const { return NO_MARKER; } - /// - InsetCode lyxCode() const { return ARGUMENT_PROXY_CODE; } - /// The math data to use for display - MathData const & displayCell(BufferView const * bv) const - { - // handle default macro arguments - bool use_def_arg = !mathMacro_->editMetrics(bv) - && mathMacro_->cell(idx_).empty(); - return use_def_arg ? def_ : mathMacro_->cell(idx_); - } - /// - bool addToMathRow(MathRow & mrow, MetricsInfo & mi) const - { - // macro arguments are in macros - LATTEST(mathMacro_->nesting() > 0); - /// The macro nesting can change display of insets. Change it locally. - Changer chg = make_change(mi.base.macro_nesting, - mathMacro_->nesting() == 1 ? 0 : mathMacro_->nesting()); - - MathRow::Element e_beg(mi, MathRow::BEGIN); - e_beg.inset = this; - e_beg.ar = &mathMacro_->cell(idx_); - mrow.push_back(e_beg); - - mathMacro_->macro()->unlock(); - bool has_contents = displayCell(mi.base.bv).addToMathRow(mrow, mi); - mathMacro_->macro()->lock(); - - // if there was no contents, and the contents is editable, - // then we insert a box instead. - if (!has_contents && mathMacro_->nesting() == 1) { - // mathclass is ord because it should be spaced as a normal atom - MathRow::Element e(mi, MathRow::BOX, MC_ORD); - e.color = Color_mathline; - mrow.push_back(e); - has_contents = true; - } - - MathRow::Element e_end(mi, MathRow::END); - e_end.inset = this; - e_end.ar = &mathMacro_->cell(idx_); - mrow.push_back(e_end); - - return has_contents; - } - /// - void beforeMetrics() const - { - mathMacro_->macro()->unlock(); - } - /// - void afterMetrics() const - { - mathMacro_->macro()->lock(); - } - /// - void beforeDraw(PainterInfo const & pi) const - { - // if the macro is being edited, then the painter is in - // monochrome mode. - if (mathMacro_->editMetrics(pi.base.bv)) - pi.pain.leaveMonochromeMode(); - } - /// - void afterDraw(PainterInfo const & pi) const - { - if (mathMacro_->editMetrics(pi.base.bv)) - pi.pain.enterMonochromeMode(Color_mathbg, Color_mathmacroblend); - } - /// - void metrics(MetricsInfo &, Dimension &) const { - // This should never be invoked, since ArgumentProxy insets are linearized - LATTEST(false); - } - /// - void draw(PainterInfo &, int, int) const { - // This should never be invoked, since ArgumentProxy insets are linearized - LATTEST(false); - } - /// - int kerning(BufferView const * bv) const - { - return displayCell(bv).kerning(bv); - } - // write(), normalize(), infoize() and infoize2() are not needed since - // MathMacro uses the definition and not the expanded cells. - /// - void maple(MapleStream & ms) const { ms << mathMacro_->cell(idx_); } - /// - void maxima(MaximaStream & ms) const { ms << mathMacro_->cell(idx_); } - /// - void mathematica(MathematicaStream & ms) const { ms << mathMacro_->cell(idx_); } - /// - void mathmlize(MathStream & ms) const { ms << mathMacro_->cell(idx_); } - /// - void htmlize(HtmlStream & ms) const { ms << mathMacro_->cell(idx_); } - /// - void octave(OctaveStream & os) const { os << mathMacro_->cell(idx_); } - /// - MathClass mathClass() const - { - return MC_UNKNOWN; - // This can be refined once the pointer issues are fixed. I did not - // notice any immediate crash with the following code, but it is risky - // nevertheless: - //return mathMacro_->cell(idx_).mathClass(); - } - -private: - /// - Inset * clone() const - { - return new ArgumentProxy(*this); - } - /// - MathMacro * mathMacro_; - /// - size_t idx_; - /// - MathData def_; -}; - - -/// Private implementation of MathMacro -class MathMacro::Private { -public: - Private(Buffer * buf, docstring const & name) - : name_(name), displayMode_(DISPLAY_INIT), - expanded_(buf), definition_(buf), attachedArgsNum_(0), - optionals_(0), nextFoldMode_(true), macroBackup_(buf), - macro_(0), needsUpdate_(false), isUpdating_(false), - appetite_(9), nesting_(0) - { - } - /// Update the pointers to our owner of all expanded macros. - /// This needs to be called every time a copy of the owner is created - /// (bug 9418). - void updateChildren(MathMacro * owner); - /// Recursively update the pointers of all expanded macros - /// appearing in the arguments of the current macro - void updateNestedChildren(MathMacro * owner, InsetMathNest * ni); - /// name of macro - docstring name_; - /// current display mode - DisplayMode displayMode_; - /// expanded macro with ArgumentProxies - MathData expanded_; - /// macro definition with #1,#2,.. insets - MathData definition_; - /// number of arguments that were really attached - size_t attachedArgsNum_; - /// optional argument attached? (only in DISPLAY_NORMAL mode) - size_t optionals_; - /// fold mode to be set in next metrics call? - bool nextFoldMode_; - /// if macro_ == true, then here is a copy of the macro - /// don't use it for locking - MacroData macroBackup_; - /// if macroNotFound_ == false, then here is a reference to the macro - /// this might invalidate after metrics was called - MacroData const * macro_; - /// - mutable std::map editing_; - /// - std::string requires_; - /// update macro representation - bool needsUpdate_; - /// - bool isUpdating_; - /// maximal number of arguments the macro is greedy for - size_t appetite_; - /// Level of nesting in macros (including this one) - int nesting_; -}; - - -void MathMacro::Private::updateChildren(MathMacro * owner) -{ - for (size_t i = 0; i < expanded_.size(); ++i) { - ArgumentProxy * p = dynamic_cast(expanded_[i].nucleus()); - if (p) - p->setOwner(owner); - - InsetMathNest * ni = expanded_[i].nucleus()->asNestInset(); - if (ni) - updateNestedChildren(owner, ni); - } - - if (macro_) { - // The macro_ pointer is updated when MathData::metrics() is - // called. However, when instant preview is on or the macro is - // not on screen, MathData::metrics() is not called and we may - // have a dangling pointer. As a safety measure, when a macro - // is copied, always let macro_ point to the backup copy of the - // MacroData structure. This backup is updated every time the - // macro is changed, so it will not become stale. - macro_ = ¯oBackup_; - } -} - - -void MathMacro::Private::updateNestedChildren(MathMacro * owner, InsetMathNest * ni) -{ - for (size_t i = 0; i < ni->nargs(); ++i) { - MathData & ar = ni->cell(i); - for (size_t j = 0; j < ar.size(); ++j) { - ArgumentProxy * ap = dynamic_cast - (ar[j].nucleus()); - if (ap) { - MathMacro::Private * md = ap->owner()->d; - if (md->macro_) - md->macro_ = &md->macroBackup_; - ap->setOwner(owner); - } - InsetMathNest * imn = ar[j].nucleus()->asNestInset(); - if (imn) - updateNestedChildren(owner, imn); - } - } -} - - -MathMacro::MathMacro(Buffer * buf, docstring const & name) - : InsetMathNest(buf, 0), d(new Private(buf, name)) -{} - - -MathMacro::MathMacro(MathMacro const & that) - : InsetMathNest(that), d(new Private(*that.d)) -{ - setBuffer(*that.buffer_); - d->updateChildren(this); -} - - -MathMacro & MathMacro::operator=(MathMacro const & that) -{ - if (&that == this) - return *this; - InsetMathNest::operator=(that); - *d = *that.d; - d->updateChildren(this); - return *this; -} - - -MathMacro::~MathMacro() -{ - delete d; -} - - -bool MathMacro::addToMathRow(MathRow & mrow, MetricsInfo & mi) const -{ - // set edit mode for which we will have calculated row. - // This is the same as what is done in metrics(). - d->editing_[mi.base.bv] = editMode(mi.base.bv); - - // For now we do not linearize in the following cases (can be improved) - // - display mode different from normal - // - editing with parameter list - // - editing with box around macro - if (displayMode() != MathMacro::DISPLAY_NORMAL - || (d->editing_[mi.base.bv] && lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST)) - return InsetMath::addToMathRow(mrow, mi); - - /// The macro nesting can change display of insets. Change it locally. - Changer chg = make_change(mi.base.macro_nesting, d->nesting_); - - MathRow::Element e_beg(mi, MathRow::BEGIN); - e_beg.inset = this; - e_beg.marker = (d->nesting_ == 1) ? marker(mi.base.bv) : NO_MARKER; - mrow.push_back(e_beg); - - d->macro_->lock(); - bool has_contents = d->expanded_.addToMathRow(mrow, mi); - d->macro_->unlock(); - - // if there was no contents and the array is editable, then we - // insert a grey box instead. - if (!has_contents && mi.base.macro_nesting == 1) { - // mathclass is unknown because it is irrelevant for spacing - MathRow::Element e(mi, MathRow::BOX); - e.color = Color_mathmacroblend; - mrow.push_back(e); - has_contents = true; - } - - MathRow::Element e_end(mi, MathRow::END); - e_end.inset = this; - e_end.marker = (d->nesting_ == 1) ? marker(mi.base.bv) : NO_MARKER; - mrow.push_back(e_end); - - return has_contents; -} - -void MathMacro::beforeMetrics() const -{ - d->macro_->lock(); -} - - -void MathMacro::afterMetrics() const -{ - d->macro_->unlock(); -} - - -void MathMacro::beforeDraw(PainterInfo const & pi) const -{ - if (d->editing_[pi.base.bv]) - pi.pain.enterMonochromeMode(Color_mathbg, Color_mathmacroblend); -} - - -void MathMacro::afterDraw(PainterInfo const & pi) const -{ - if (d->editing_[pi.base.bv]) - pi.pain.leaveMonochromeMode(); -} - - -Inset * MathMacro::clone() const -{ - MathMacro * copy = new MathMacro(*this); - copy->d->needsUpdate_ = true; - //copy->d->expanded_.clear(); - return copy; -} - - -void MathMacro::normalize(NormalStream & os) const -{ - os << "[macro " << name(); - for (size_t i = 0; i < nargs(); ++i) - os << ' ' << cell(i); - os << ']'; -} - - -MathMacro::DisplayMode MathMacro::displayMode() const -{ - return d->displayMode_; -} - - -bool MathMacro::extraBraces() const -{ - return d->displayMode_ == DISPLAY_NORMAL && arity() > 0; -} - - -docstring MathMacro::name() const -{ - if (d->displayMode_ == DISPLAY_UNFOLDED) - return asString(cell(0)); - - return d->name_; -} - - -docstring MathMacro::macroName() const -{ - return d->name_; -} - - -int MathMacro::nesting() const -{ - return d->nesting_; -} - - -void MathMacro::cursorPos(BufferView const & bv, - CursorSlice const & sl, bool boundary, int & x, int & y) const -{ - // We may have 0 arguments, but InsetMathNest requires at least one. - if (nargs() > 0) - InsetMathNest::cursorPos(bv, sl, boundary, x, y); -} - - -bool MathMacro::editMode(BufferView const * bv) const { - // find this in cursor trace - Cursor const & cur = bv->cursor(); - for (size_t i = 0; i != cur.depth(); ++i) - if (&cur[i].inset() == this) { - // look if there is no other macro in edit mode above - ++i; - for (; i != cur.depth(); ++i) { - InsetMath * im = cur[i].asInsetMath(); - if (im) { - MathMacro const * macro = im->asMacro(); - if (macro && macro->displayMode() == DISPLAY_NORMAL) - return false; - } - } - - // ok, none found, I am the highest one - return true; - } - - return false; -} - - -MacroData const * MathMacro::macro() const -{ - return d->macro_; -} - - -bool MathMacro::editMetrics(BufferView const * bv) const -{ - return d->editing_[bv]; -} - - -InsetMath::marker_type MathMacro::marker(BufferView const * bv) const -{ - if (nargs() == 0) - return NO_MARKER; - - switch (d->displayMode_) { - case DISPLAY_INIT: - case DISPLAY_INTERACTIVE_INIT: - return NO_MARKER; - case DISPLAY_UNFOLDED: - return MARKER; - case DISPLAY_NORMAL: - switch (lyxrc.macro_edit_style) { - case LyXRC::MACRO_EDIT_INLINE: - return MARKER2; - case LyXRC::MACRO_EDIT_INLINE_BOX: - return d->editing_[bv] ? BOX_MARKER : MARKER2; - case LyXRC::MACRO_EDIT_LIST: - return MARKER2; - } - } - // please gcc 4.6 - return NO_MARKER; -} - - -void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const -{ - /// The macro nesting can change display of insets. Change it locally. - Changer chg = make_change(mi.base.macro_nesting, d->nesting_); - - // set edit mode for which we will have calculated metrics. But only - d->editing_[mi.base.bv] = editMode(mi.base.bv); - - // calculate new metrics according to display mode - if (d->displayMode_ == DISPLAY_INIT || d->displayMode_ == DISPLAY_INTERACTIVE_INIT) { - Changer dummy = mi.base.changeFontSet("lyxtex"); - mathed_string_dim(mi.base.font, from_ascii("\\") + name(), dim); - } else if (d->displayMode_ == DISPLAY_UNFOLDED) { - Changer dummy = mi.base.changeFontSet("lyxtex"); - cell(0).metrics(mi, dim); - Dimension bsdim; - mathed_string_dim(mi.base.font, from_ascii("\\"), bsdim); - dim.wid += bsdim.width() + 1; - dim.asc = max(bsdim.ascent(), dim.ascent()); - dim.des = max(bsdim.descent(), dim.descent()); - } else if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST - && d->editing_[mi.base.bv]) { - // Macro will be edited in a old-style list mode here: - - LBUFERR(d->macro_); - Dimension fontDim; - FontInfo labelFont = sane_font; - math_font_max_dim(labelFont, fontDim.asc, fontDim.des); - - // get dimension of components of list view - Dimension nameDim; - nameDim.wid = mathed_string_width(mi.base.font, from_ascii("Macro \\") + name() + ": "); - nameDim.asc = fontDim.asc; - nameDim.des = fontDim.des; - - Dimension argDim; - argDim.wid = mathed_string_width(labelFont, from_ascii("#9: ")); - argDim.asc = fontDim.asc; - argDim.des = fontDim.des; - - Dimension defDim; - d->definition_.metrics(mi, defDim); - - // add them up - dim.wid = nameDim.wid + defDim.wid; - dim.asc = max(nameDim.asc, defDim.asc); - dim.des = max(nameDim.des, defDim.des); - - for (idx_type i = 0; i < nargs(); ++i) { - Dimension cdim; - cell(i).metrics(mi, cdim); - dim.des += max(argDim.height(), cdim.height()) + 1; - dim.wid = max(dim.wid, argDim.wid + cdim.wid); - } - - // make space for box and markers, 2 pixels - dim.asc += 1; - dim.des += 1; - dim.wid += 2; - } else { - // We should not be here, since the macro is linearized in this case. - LBUFERR(false); - } -} - - -int MathMacro::kerning(BufferView const * bv) const { - if (d->displayMode_ == DISPLAY_NORMAL && !d->editing_[bv]) - return d->expanded_.kerning(bv); - else - return 0; -} - - -void MathMacro::updateMacro(MacroContext const & mc) -{ - if (validName()) { - d->macro_ = mc.get(name()); - if (d->macro_ && d->macroBackup_ != *d->macro_) { - d->macroBackup_ = *d->macro_; - d->needsUpdate_ = true; - } - } else { - d->macro_ = 0; - } -} - - -class MathMacro::UpdateLocker -{ -public: - explicit UpdateLocker(MathMacro & mm) : mac(mm) - { - mac.d->isUpdating_ = true; - } - ~UpdateLocker() { mac.d->isUpdating_ = false; } -private: - MathMacro & mac; -}; -/** Avoid wrong usage of UpdateLocker. - To avoid wrong usage: - UpdateLocker(...); // wrong - UpdateLocker locker(...); // right -*/ -#define UpdateLocker(x) unnamed_UpdateLocker; -// Tip gotten from Bobby Schmidt's column in C/C++ Users Journal - - -void MathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc, - UpdateType utype, int nesting) -{ - // block recursive calls (bug 8999) - if (d->isUpdating_) - return; - - UpdateLocker locker(*this); - - // known macro? - if (d->macro_ == 0) - return; - - // remember nesting level of this macro - d->nesting_ = nesting; - - // update requires - d->requires_ = d->macro_->requires(); - - if (!d->needsUpdate_ - // non-normal mode? We are done! - || (d->displayMode_ != DISPLAY_NORMAL)) - return; - - d->needsUpdate_ = false; - - // get default values of macro - vector const & defaults = d->macro_->defaults(); - - // create MathMacroArgumentValue objects pointing to the cells of the macro - vector values(nargs()); - for (size_t i = 0; i < nargs(); ++i) { - ArgumentProxy * proxy; - if (i < defaults.size()) - proxy = new ArgumentProxy(this, i, defaults[i]); - else - proxy = new ArgumentProxy(this, i); - values[i].insert(0, MathAtom(proxy)); - } - // expanding macro with the values - // Only update the argument macros if anything was expanded, otherwise - // we would get an endless loop (bug 9140). UpdateLocker does not work - // in this case, since MacroData::expand() creates new MathMacro - // objects, so this would be a different recursion path than the one - // protected by UpdateLocker. - if (d->macro_->expand(values, d->expanded_)) { - if (utype == OutputUpdate && !d->expanded_.empty()) - d->expanded_.updateMacros(cur, mc, utype, nesting); - } - // get definition for list edit mode - docstring const & display = d->macro_->display(); - asArray(display.empty() ? d->macro_->definition() : display, - d->definition_, Parse::QUIET | Parse::MACRODEF); -} - - -void MathMacro::draw(PainterInfo & pi, int x, int y) const -{ - Dimension const dim = dimension(*pi.base.bv); - - int expx = x; - int expy = y; - - if (d->displayMode_ == DISPLAY_INIT || d->displayMode_ == DISPLAY_INTERACTIVE_INIT) { - Changer dummy = pi.base.changeFontSet("lyxtex"); - pi.pain.text(x, y, from_ascii("\\") + name(), pi.base.font); - } else if (d->displayMode_ == DISPLAY_UNFOLDED) { - Changer dummy = pi.base.changeFontSet("lyxtex"); - pi.pain.text(x, y, from_ascii("\\"), pi.base.font); - x += mathed_string_width(pi.base.font, from_ascii("\\")) + 1; - cell(0).draw(pi, x, y); - } else if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST - && d->editing_[pi.base.bv]) { - // Macro will be edited in a old-style list mode here: - - CoordCache const & coords = pi.base.bv->coordCache(); - FontInfo const & labelFont = sane_font; - - // box needs one pixel - x += 1; - - // get maximal font height - Dimension fontDim; - math_font_max_dim(pi.base.font, fontDim.asc, fontDim.des); - - // draw label - docstring label = from_ascii("Macro \\") + name() + from_ascii(": "); - pi.pain.text(x, y, label, labelFont); - x += mathed_string_width(labelFont, label); - - // draw definition - d->definition_.draw(pi, x, y); - Dimension const & defDim = coords.getArrays().dim(&d->definition_); - y += max(fontDim.des, defDim.des); - - // draw parameters - docstring str = from_ascii("#9"); - int strw1 = mathed_string_width(labelFont, from_ascii("#9")); - int strw2 = mathed_string_width(labelFont, from_ascii(": ")); - - for (idx_type i = 0; i < nargs(); ++i) { - // position of label - Dimension const & cdim = coords.getArrays().dim(&cell(i)); - x = expx + 1; - y += max(fontDim.asc, cdim.asc) + 1; - - // draw label - str[1] = '1' + i; - pi.pain.text(x, y, str, labelFont); - x += strw1; - pi.pain.text(x, y, from_ascii(":"), labelFont); - x += strw2; - - // draw paramter - cell(i).draw(pi, x, y); - - // next line - y += max(fontDim.des, cdim.des); - } - - pi.pain.rectangle(expx, expy - dim.asc + 1, dim.wid - 1, - dim.height() - 2, Color_mathmacroframe); - } else { - // We should not be here, since the macro is linearized in this case. - LBUFERR(false); - } - - // edit mode changed? - if (d->editing_[pi.base.bv] != editMode(pi.base.bv)) - pi.base.bv->cursor().screenUpdateFlags(Update::SinglePar); -} - - -void MathMacro::setDisplayMode(MathMacro::DisplayMode mode, int appetite) -{ - if (d->displayMode_ != mode) { - // transfer name if changing from or to DISPLAY_UNFOLDED - if (mode == DISPLAY_UNFOLDED) { - cells_.resize(1); - asArray(d->name_, cell(0)); - } else if (d->displayMode_ == DISPLAY_UNFOLDED) { - d->name_ = asString(cell(0)); - cells_.resize(0); - } - - d->displayMode_ = mode; - d->needsUpdate_ = true; - } - - // the interactive init mode is non-greedy by default - if (appetite == -1) - d->appetite_ = (mode == DISPLAY_INTERACTIVE_INIT) ? 0 : 9; - else - d->appetite_ = size_t(appetite); -} - - -MathMacro::DisplayMode MathMacro::computeDisplayMode() const -{ - if (d->nextFoldMode_ == true && d->macro_ && !d->macro_->locked()) - return DISPLAY_NORMAL; - else - return DISPLAY_UNFOLDED; -} - - -bool MathMacro::validName() const -{ - docstring n = name(); - - if (n.empty()) - return false; - - // converting back and force doesn't swallow anything? - /*MathData ma; - asArray(n, ma); - if (asString(ma) != n) - return false;*/ - - // valid characters? - for (size_t i = 0; i= 'a' && n[i] <= 'z') - && !(n[i] >= 'A' && n[i] <= 'Z') - && n[i] != '*') - return false; - } - - return true; -} - - -size_t MathMacro::arity() const -{ - if (d->displayMode_ == DISPLAY_NORMAL ) - return cells_.size(); - else - return 0; -} - - -size_t MathMacro::optionals() const -{ - return d->optionals_; -} - - -void MathMacro::setOptionals(int n) -{ - if (n <= int(nargs())) - d->optionals_ = n; -} - - -size_t MathMacro::appetite() const -{ - return d->appetite_; -} - - -MathClass MathMacro::mathClass() const -{ - // This can be just a heuristic, since it is only considered for display - // when the macro is not linearised. Therefore it affects: - // * The spacing of the inset while being edited, - // * Intelligent splitting - // * Cursor word movement (Ctrl-Arrow). - if (MacroData const * m = macroBackup()) { - // If it is a global macro and is defined explicitly - if (m->symbol()) { - MathClass mc = string_to_class(m->symbol()->extra); - if (mc != MC_UNKNOWN) - return mc; - } - } - // Otherwise guess from the expanded macro - return d->expanded_.mathClass(); -} - - -InsetMath::mode_type MathMacro::currentMode() const -{ - // There is no way to guess the mode of user defined macros, so they are - // always assumed to be mathmode. Only the global macros defined in - // lib/symbols may be textmode. - mode_type mode = modeToEnsure(); - return (mode == UNDECIDED_MODE) ? MATH_MODE : mode; -} - - -InsetMath::mode_type MathMacro::modeToEnsure() const -{ - // User defined macros can be either text mode or math mode for output and - // display. There is no way to guess. For global macros defined in - // lib/symbols, we ensure textmode if flagged as such, otherwise we ensure - // math mode. - if (MacroData const * m = macroBackup()) - if (m->symbol()) - return (m->symbol()->extra == "textmode") ? TEXT_MODE : MATH_MODE; - return UNDECIDED_MODE; -} - - -MacroData const * MathMacro::macroBackup() const -{ - if (macro()) - return &d->macroBackup_; - if (MacroData const * data = MacroTable::globalMacros().get(name())) - return data; - return nullptr; -} - - -void MathMacro::validate(LaTeXFeatures & features) const -{ - // Immediately after a document is loaded, in some cases the MacroData - // of the global macros defined in the lib/symbols file may still not - // be known to the macro machinery because it will be set only after - // the first call to updateMacros(). This is not a problem unless - // instant preview is on for math, in which case we will be missing - // the corresponding requirements. - // In this case, we get the required info from the global macro table. - if (!d->requires_.empty()) - features.require(d->requires_); - else if (!d->macro_) { - // Update requires for known global macros. - MacroData const * data = MacroTable::globalMacros().get(name()); - if (data && !data->requires().empty()) - features.require(data->requires()); - } - - if (name() == "binom") - features.require("binom"); - - // validate the cells and the definition - if (displayMode() == DISPLAY_NORMAL) { - d->definition_.validate(features); - InsetMathNest::validate(features); - } -} - - -void MathMacro::edit(Cursor & cur, bool front, EntryDirection entry_from) -{ - cur.screenUpdateFlags(Update::SinglePar); - InsetMathNest::edit(cur, front, entry_from); -} - - -Inset * MathMacro::editXY(Cursor & cur, int x, int y) -{ - // We may have 0 arguments, but InsetMathNest requires at least one. - if (nargs() > 0) { - cur.screenUpdateFlags(Update::SinglePar); - return InsetMathNest::editXY(cur, x, y); - } else - return this; -} - - -void MathMacro::removeArgument(Inset::pos_type pos) { - if (d->displayMode_ == DISPLAY_NORMAL) { - LASSERT(size_t(pos) < cells_.size(), return); - cells_.erase(cells_.begin() + pos); - if (size_t(pos) < d->attachedArgsNum_) - --d->attachedArgsNum_; - if (size_t(pos) < d->optionals_) { - --d->optionals_; - } - - d->needsUpdate_ = true; - } -} - - -void MathMacro::insertArgument(Inset::pos_type pos) { - if (d->displayMode_ == DISPLAY_NORMAL) { - LASSERT(size_t(pos) <= cells_.size(), return); - cells_.insert(cells_.begin() + pos, MathData()); - if (size_t(pos) < d->attachedArgsNum_) - ++d->attachedArgsNum_; - if (size_t(pos) < d->optionals_) - ++d->optionals_; - - d->needsUpdate_ = true; - } -} - - -void MathMacro::detachArguments(vector & args, bool strip) -{ - LASSERT(d->displayMode_ == DISPLAY_NORMAL, return); - args = cells_; - - // strip off empty cells, but not more than arity-attachedArgsNum_ - if (strip) { - size_t i; - for (i = cells_.size(); i > d->attachedArgsNum_; --i) - if (!cell(i - 1).empty()) break; - args.resize(i); - } - - d->attachedArgsNum_ = 0; - d->expanded_ = MathData(); - cells_.resize(0); - - d->needsUpdate_ = true; -} - - -void MathMacro::attachArguments(vector const & args, size_t arity, int optionals) -{ - LASSERT(d->displayMode_ == DISPLAY_NORMAL, return); - cells_ = args; - d->attachedArgsNum_ = args.size(); - cells_.resize(arity); - d->expanded_ = MathData(); - d->optionals_ = optionals; - - d->needsUpdate_ = true; -} - - -bool MathMacro::idxFirst(Cursor & cur) const -{ - cur.screenUpdateFlags(Update::SinglePar); - return InsetMathNest::idxFirst(cur); -} - - -bool MathMacro::idxLast(Cursor & cur) const -{ - cur.screenUpdateFlags(Update::SinglePar); - return InsetMathNest::idxLast(cur); -} - - -bool MathMacro::notifyCursorLeaves(Cursor const & old, Cursor & cur) -{ - if (d->displayMode_ == DISPLAY_UNFOLDED) { - docstring const & unfolded_name = name(); - if (unfolded_name != d->name_) { - // The macro name was changed - Cursor inset_cursor = old; - int macroSlice = inset_cursor.find(this); - // returning true means the cursor is "now" invalid, - // which it was. - LASSERT(macroSlice != -1, return true); - inset_cursor.cutOff(macroSlice); - inset_cursor.recordUndoInset(); - inset_cursor.pop(); - inset_cursor.cell().erase(inset_cursor.pos()); - inset_cursor.cell().insert(inset_cursor.pos(), - createInsetMath(unfolded_name, cur.buffer())); - cur.resetAnchor(); - cur.screenUpdateFlags(cur.result().screenUpdate() | Update::SinglePar); - return true; - } - } - cur.screenUpdateFlags(Update::Force); - return InsetMathNest::notifyCursorLeaves(old, cur); -} - - -void MathMacro::fold(Cursor & cur) -{ - if (!d->nextFoldMode_) { - d->nextFoldMode_ = true; - cur.screenUpdateFlags(Update::SinglePar); - } -} - - -void MathMacro::unfold(Cursor & cur) -{ - if (d->nextFoldMode_) { - d->nextFoldMode_ = false; - cur.screenUpdateFlags(Update::SinglePar); - } -} - - -bool MathMacro::folded() const -{ - return d->nextFoldMode_; -} - - -void MathMacro::write(WriteStream & os) const -{ - mode_type mode = modeToEnsure(); - bool textmode_macro = mode == TEXT_MODE; - bool needs_mathmode = mode == MATH_MODE; - MathEnsurer ensurer(os, needs_mathmode, true, textmode_macro); - - // non-normal mode - if (d->displayMode_ != DISPLAY_NORMAL) { - os << "\\" << name(); - if (name().size() != 1 || isAlphaASCII(name()[0])) - os.pendingSpace(true); - return; - } - - // normal mode - // we should be ok to continue even if this fails. - LATTEST(d->macro_); - - // We may already be in the argument of a macro - bool const inside_macro = os.insideMacro(); - os.insideMacro(true); - - // Enclose in braces to avoid latex errors with xargs if we have - // optional arguments and are in the optional argument of a macro - if (d->optionals_ && inside_macro) - os << '{'; - - // Always protect macros in a fragile environment - if (os.fragile()) - os << "\\protect"; - - os << "\\" << name(); - bool first = true; - - // Optional arguments: - // First find last non-empty optional argument - idx_type emptyOptFrom = 0; - idx_type i = 0; - for (; i < cells_.size() && i < d->optionals_; ++i) { - if (!cell(i).empty()) - emptyOptFrom = i + 1; - } - - // print out optionals - for (i=0; i < cells_.size() && i < emptyOptFrom; ++i) { - first = false; - os << "[" << cell(i) << "]"; - } - - // skip the tailing empty optionals - i = d->optionals_; - - // Print remaining arguments - for (; i < cells_.size(); ++i) { - if (cell(i).size() == 1 - && cell(i)[0].nucleus()->asCharInset() - && isASCII(cell(i)[0].nucleus()->asCharInset()->getChar())) { - if (first) - os << " "; - os << cell(i); - } else - os << "{" << cell(i) << "}"; - first = false; - } - - // Close the opened brace or add space if there was no argument - if (d->optionals_ && inside_macro) - os << '}'; - else if (first) - os.pendingSpace(true); - - os.insideMacro(inside_macro); -} - - -void MathMacro::maple(MapleStream & os) const -{ - lyx::maple(d->expanded_, os); -} - - -void MathMacro::maxima(MaximaStream & os) const -{ - lyx::maxima(d->expanded_, os); -} - - -void MathMacro::mathematica(MathematicaStream & os) const -{ - lyx::mathematica(d->expanded_, os); -} - - -void MathMacro::mathmlize(MathStream & os) const -{ - // macro_ is 0 if this is an unknown macro - LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL); - if (d->macro_) { - docstring const xmlname = d->macro_->xmlname(); - if (!xmlname.empty()) { - char const * type = d->macro_->MathMLtype(); - os << '<' << type << "> " << xmlname << " '; - return; - } - } - if (d->expanded_.empty()) { - // this means that we do not recognize the macro - throw MathExportException(); - } - os << d->expanded_; -} - - -void MathMacro::htmlize(HtmlStream & os) const -{ - // macro_ is 0 if this is an unknown macro - LATTEST(d->macro_ || d->displayMode_ != DISPLAY_NORMAL); - if (d->macro_) { - docstring const xmlname = d->macro_->xmlname(); - if (!xmlname.empty()) { - os << ' ' << xmlname << ' '; - return; - } - } - if (d->expanded_.empty()) { - // this means that we do not recognize the macro - throw MathExportException(); - } - os << d->expanded_; -} - - -void MathMacro::octave(OctaveStream & os) const -{ - lyx::octave(d->expanded_, os); -} - - -void MathMacro::infoize(odocstream & os) const -{ - os << bformat(_("Macro: %1$s"), name()); -} - - -void MathMacro::infoize2(odocstream & os) const -{ - os << bformat(_("Macro: %1$s"), name()); -} - - -bool MathMacro::completionSupported(Cursor const & cur) const -{ - if (displayMode() != DISPLAY_UNFOLDED) - return InsetMathNest::completionSupported(cur); - - return lyxrc.completion_popup_math - && displayMode() == DISPLAY_UNFOLDED - && cur.bv().cursor().pos() == int(name().size()); -} - - -bool MathMacro::inlineCompletionSupported(Cursor const & cur) const -{ - if (displayMode() != DISPLAY_UNFOLDED) - return InsetMathNest::inlineCompletionSupported(cur); - - return lyxrc.completion_inline_math - && displayMode() == DISPLAY_UNFOLDED - && cur.bv().cursor().pos() == int(name().size()); -} - - -bool MathMacro::automaticInlineCompletion() const -{ - if (displayMode() != DISPLAY_UNFOLDED) - return InsetMathNest::automaticInlineCompletion(); - - return lyxrc.completion_inline_math; -} - - -bool MathMacro::automaticPopupCompletion() const -{ - if (displayMode() != DISPLAY_UNFOLDED) - return InsetMathNest::automaticPopupCompletion(); - - return lyxrc.completion_popup_math; -} - - -CompletionList const * -MathMacro::createCompletionList(Cursor const & cur) const -{ - if (displayMode() != DISPLAY_UNFOLDED) - return InsetMathNest::createCompletionList(cur); - - return new MathCompletionList(cur.bv().cursor()); -} - - -docstring MathMacro::completionPrefix(Cursor const & cur) const -{ - if (displayMode() != DISPLAY_UNFOLDED) - return InsetMathNest::completionPrefix(cur); - - if (!completionSupported(cur)) - return docstring(); - - return "\\" + name(); -} - - -bool MathMacro::insertCompletion(Cursor & cur, docstring const & s, - bool finished) -{ - if (displayMode() != DISPLAY_UNFOLDED) - return InsetMathNest::insertCompletion(cur, s, finished); - - if (!completionSupported(cur)) - return false; - - // append completion - docstring newName = name() + s; - asArray(newName, cell(0)); - cur.bv().cursor().pos() = name().size(); - cur.screenUpdateFlags(Update::SinglePar); - - // finish macro - if (finished) { - cur.bv().cursor().pop(); - ++cur.bv().cursor().pos(); - cur.screenUpdateFlags(Update::SinglePar); - } - - return true; -} - - -void MathMacro::completionPosAndDim(Cursor const & cur, int & x, int & y, - Dimension & dim) const -{ - if (displayMode() != DISPLAY_UNFOLDED) - InsetMathNest::completionPosAndDim(cur, x, y, dim); - - // get inset dimensions - dim = cur.bv().coordCache().insets().dim(this); - // FIXME: these 3 are no accurate, but should depend on the font. - // Now the popup jumps down if you enter a char with descent > 0. - dim.des += 3; - dim.asc += 3; - - // and position - Point xy - = cur.bv().coordCache().insets().xy(this); - x = xy.x_; - y = xy.y_; -} - - -} // namespace lyx diff --git a/src/mathed/MathMacro.h b/src/mathed/MathMacro.h deleted file mode 100644 index 0d4ba34bf5..0000000000 --- a/src/mathed/MathMacro.h +++ /dev/null @@ -1,216 +0,0 @@ -// -*- C++ -*- -/** - * \file MathMacro.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Alejandro Aguilar Sierra - * \author André Pönitz - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef MATH_MACRO_H -#define MATH_MACRO_H - -#include "InsetMathNest.h" -#include "MacroTable.h" -#include "MathData.h" - -#include - -namespace lyx { - -/// This class contains the data for a macro. -class MathMacro : public InsetMathNest { -public: - /// A macro can be built from an existing template - MathMacro(Buffer * buf, docstring const & name); - /// - MathMacro(MathMacro const &); - /// - MathMacro & operator=(MathMacro const &); - /// - ~MathMacro(); - /// - virtual MathMacro * asMacro() { return this; } - /// - virtual MathMacro const * asMacro() const { return this; } - /// - marker_type marker(BufferView const *) const; - /// If the macro is in normal edit mode, dissolve its contents in - /// the row. Otherwise, just insert the inset. - bool addToMathRow(MathRow &, MetricsInfo & mi) const; - /// - void beforeMetrics() const; - /// - void afterMetrics() const; - /// - void beforeDraw(PainterInfo const &) const; - /// - void afterDraw(PainterInfo const &) const; - - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// was the macro in edit mode when computing metrics? - bool editMetrics(BufferView const * bv) const; - /// - void draw(PainterInfo & pi, int x, int y) const; - /// - int kerning(BufferView const * bv) const; - /// get cursor position - void cursorPos(BufferView const & bv, CursorSlice const & sl, - bool boundary, int & x, int & y) const; - /// - void edit(Cursor & cur, bool front, EntryDirection entry_from); - /// - Inset * editXY(Cursor & cur, int x, int y); - - /// target pos when we enter the inset while moving forward - bool idxFirst(Cursor &) const; - /// target pos when we enter the inset while moving backwards - bool idxLast(Cursor &) const; - - /// - virtual bool notifyCursorLeaves(Cursor const & old, Cursor & cur); - - /// Remove cell (starting from 0) - void removeArgument(pos_type pos); - /// Insert empty cell (starting from 0) - void insertArgument(pos_type pos); - - /// - void validate(LaTeXFeatures &) const; - /// - mode_type currentMode() const; - - /// - void write(WriteStream & os) const; - /// - void normalize(NormalStream & os) const; - /// - void maple(MapleStream &) const; - /// - void maxima(MaximaStream &) const; - /// - void mathematica(MathematicaStream &) const; - /// - void mathmlize(MathStream &) const; - /// - void htmlize(HtmlStream &) const; - /// - void octave(OctaveStream &) const; - /// - void infoize(odocstream &) const; - /// - void infoize2(odocstream &) const; - - /// fold the macro in the next metrics call - void fold(Cursor & cur); - /// unfold the macro in the next metrics call - void unfold(Cursor & cur); - /// will it be folded or unfolded in the next metric call? - bool folded() const; - - enum DisplayMode { - DISPLAY_INIT, - DISPLAY_INTERACTIVE_INIT, - DISPLAY_UNFOLDED, - DISPLAY_NORMAL - }; - - /// - DisplayMode displayMode() const; - - /// - bool extraBraces() const; - - /// - docstring name() const; - /// FIXME: Often dangling. - MacroData const * macro() const; - /// - docstring macroName() const; - /// Level of nesting in macros (including this one) - int nesting() const; - /// - bool validName() const; - /// - size_t arity() const; - - /// - size_t optionals() const; - /// - void setOptionals(int n); - /// Return the maximal number of arguments the macro is greedy for. - size_t appetite() const; - /// - InsetCode lyxCode() const { return MATH_MACRO_CODE; } - /// This is not used for display; however whether it is mathrel determines - /// how to split equations intelligently. - MathClass mathClass() const; //override - -protected: - friend class MathData; - friend class ArgumentProxy; - friend class Cursor; - - /// update the display mode (should only be called after detaching arguments) - void setDisplayMode(DisplayMode mode, int appetite = -1); - /// compute the next display mode - DisplayMode computeDisplayMode() const; - /// update macro definition - void updateMacro(MacroContext const & mc); - /// check if macro definition changed, argument changed etc. and adapt - void updateRepresentation(Cursor * cur, MacroContext const & mc, - UpdateType, int nesting); - /// empty macro, put arguments into args, possibly strip arity-attachedArgsNum_ empty ones. - /// Includes the optional arguments. - void detachArguments(std::vector & args, bool strip); - /// attach arguments (maybe less than arity at the end of an MathData), - /// including the optional ones (even if it can be empty here) - void attachArguments(std::vector const & args, size_t arity, int optionals); - -private: - /// Math mode for output and display. UNDECIDED for user macros: they could - /// be either. - mode_type modeToEnsure() const; - /// This function is needed for now because of two shortfalls of the current - /// implementation: the macro() pointer is often dangling, in which case we - /// fall back to a backup copy, and the macro is not known at inset - /// creation, in which case we fall back to the global macro with this name. - MacroData const * macroBackup() const; - /// - virtual Inset * clone() const; - /// - bool editMode(BufferView const * bv) const; - - /// - class Private; - /// - Private * d; - /// update lock to avoid loops - class UpdateLocker; - friend class UpdateLocker; - -public: - /// - bool completionSupported(Cursor const &) const; - /// - bool inlineCompletionSupported(Cursor const & cur) const; - /// - bool automaticInlineCompletion() const; - /// - bool automaticPopupCompletion() const; - /// - CompletionList const * createCompletionList(Cursor const & cur) const; - /// - docstring completionPrefix(Cursor const & cur) const; - /// - bool insertCompletion(Cursor & cur, docstring const & s, bool finished); - /// - void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const; -}; - -} // namespace lyx -#endif diff --git a/src/mathed/MathMacroArgument.cpp b/src/mathed/MathMacroArgument.cpp deleted file mode 100644 index d3a16ff8d9..0000000000 --- a/src/mathed/MathMacroArgument.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/** - * \file MathMacroArgument.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Alejandro Aguilar Sierra - * \author André Pönitz - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "MathMacroArgument.h" -#include "MathStream.h" -#include "MathSupport.h" - -#include "support/debug.h" -#include "support/lassert.h" - - -namespace lyx { - - -Inset * InsetMathHash::clone() const -{ - return new InsetMathHash(*this); -} - - -void InsetMathHash::write(WriteStream & os) const -{ - os << str_; -} - - -void InsetMathHash::metrics(MetricsInfo & mi, Dimension & dim) const -{ - metricsStrRedBlack(mi, dim, str_); -} - - -void InsetMathHash::draw(PainterInfo & pi, int x, int y) const -{ - drawStrRed(pi, x, y, str_); -} - - -void InsetMathHash::normalize(NormalStream & os) const -{ - os << "[hash " << str_ << "] "; -} - - -MathMacroArgument::MathMacroArgument(int n) - : number_(n) -{ - if (n < 1 || n > 9) { - LYXERR0("MathMacroArgument::MathMacroArgument: wrong Argument id: " - << n); - LASSERT(false, n = 1); - } - - // The profiler tells us not to use - // str_ = '#' + convert(n); - // so we do the conversion of n to ASCII manually. - // This works because 1 <= n <= 9. - str_.resize(2); - str_[1] = '0' + n; -} - - -Inset * MathMacroArgument::clone() const -{ - return new MathMacroArgument(*this); -} - - -void MathMacroArgument::setNumber(int n) -{ - if (n < 1 || n > 9) { - LYXERR0("MathMacroArgument::setNumber: wrong Argument id: " << n); - LASSERT(false, return); - } - - number_ = n; - str_[1] = '0' + n; -} - - -void MathMacroArgument::normalize(NormalStream & os) const -{ - os << "[macroarg " << str_ << "] "; -} - - -} // namespace lyx diff --git a/src/mathed/MathMacroArgument.h b/src/mathed/MathMacroArgument.h deleted file mode 100644 index bb9fa1dc30..0000000000 --- a/src/mathed/MathMacroArgument.h +++ /dev/null @@ -1,70 +0,0 @@ -// -*- C++ -*- -/** - * \file MathMacroArgument.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Alejandro Aguilar Sierra - * \author André Pönitz - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef MATHMACROARGUMENT_H -#define MATHMACROARGUMENT_H - -#include "InsetMath.h" - -#include "support/docstring.h" - - -namespace lyx { - - -// A # that failed to parse -class InsetMathHash : public InsetMath { -public: - InsetMathHash(docstring const & str = docstring()) : str_('#' + str) {}; - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// - void draw(PainterInfo &, int x, int y) const; - /// - void normalize(NormalStream &) const; - /// - void write(WriteStream & os) const; - -private: - Inset * clone() const; - -protected: - /// - docstring str_; -}; - - -/// A macro argument. -class MathMacroArgument : public InsetMathHash { -public: - /// Assumes 0 < number <= 9 - explicit MathMacroArgument(int number); - /// - int number() const { return number_; } - /// Assumes 0 < n <= 9 - void setNumber(int n); - /// - InsetCode lyxCode() const { return MATH_MACROARG_CODE; } - - /// - void normalize(NormalStream &) const; - -private: - Inset * clone() const; - /// A number between 1 and 9 - int number_; -}; - - -} // namespace lyx - -#endif diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp deleted file mode 100644 index 4aef5eb7b2..0000000000 --- a/src/mathed/MathMacroTemplate.cpp +++ /dev/null @@ -1,1413 +0,0 @@ -/** - * \file MathMacroTemplate.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author André Pönitz - * \author Stefan Schimanski - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "MathMacroTemplate.h" - -#include "InsetMathBrace.h" -#include "InsetMathChar.h" -#include "InsetMathHull.h" -#include "InsetMathSqrt.h" -#include "MathMacro.h" -#include "MathMacroArgument.h" -#include "MathStream.h" -#include "MathParser.h" -#include "MathSupport.h" -#include "MathMacroArgument.h" - -#include "Buffer.h" -#include "BufferView.h" -#include "Color.h" -#include "Cursor.h" -#include "DispatchResult.h" -#include "DocIterator.h" -#include "FuncRequest.h" -#include "FuncStatus.h" -#include "LaTeXFeatures.h" -#include "Lexer.h" -#include "MetricsInfo.h" -#include "TocBackend.h" - -#include "frontends/Painter.h" - -#include "insets/RenderPreview.h" - -#include "support/lassert.h" -#include "support/convert.h" -#include "support/debug.h" -#include "support/gettext.h" -#include "support/docstream.h" -#include "support/lstrings.h" - -#include -#include - -using namespace std; - -namespace lyx { - -using support::bformat; - -////////////////////////////////////////////////////////////////////// - -class InsetLabelBox : public InsetMathNest { -public: - /// - InsetLabelBox(Buffer * buf, MathAtom const & atom, docstring label, - MathMacroTemplate const & parent, bool frame = false); - InsetLabelBox(Buffer * buf, docstring label, MathMacroTemplate const & parent, - bool frame = false); - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// - void draw(PainterInfo &, int x, int y) const; - -protected: - /// - MathMacroTemplate const & parent_; - /// - Inset * clone() const; - /// - docstring const label_; - /// - bool frame_; -}; - - -InsetLabelBox::InsetLabelBox(Buffer * buf, MathAtom const & atom, docstring label, - MathMacroTemplate const & parent, bool frame) - : InsetMathNest(buf, 1), parent_(parent), label_(label), frame_(frame) -{ - cell(0).insert(0, atom); -} - - -InsetLabelBox::InsetLabelBox(Buffer * buf, docstring label, - MathMacroTemplate const & parent, bool frame) - : InsetMathNest(buf, 1), parent_(parent), label_(label), frame_(frame) -{ -} - - -Inset * InsetLabelBox::clone() const -{ - return new InsetLabelBox(*this); -} - - -void InsetLabelBox::metrics(MetricsInfo & mi, Dimension & dim) const -{ - // kernel - cell(0).metrics(mi, dim); - - // frame - if (frame_) { - dim.wid += 6; - dim.asc += 5; - dim.des += 5; - } - - // adjust to common height in main metrics phase - if (!parent_.premetrics()) { - dim.asc = max(dim.asc, parent_.commonLabelBoxAscent()); - dim.des = max(dim.des, parent_.commonLabelBoxDescent()); - } - - // label - if (parent_.editing(mi.base.bv) && label_.length() > 0) { - // grey - FontInfo font = sane_font; - font.setSize(FONT_SIZE_TINY); - font.setColor(Color_mathmacrolabel); - - // make space for label and box - int lwid = mathed_string_width(font, label_); - int maxasc; - int maxdes; - math_font_max_dim(font, maxasc, maxdes); - - dim.wid = max(dim.wid, lwid + 2); - - // space for the label - if (!parent_.premetrics()) - dim.des += maxasc + maxdes + 1; - } -} - - -void InsetLabelBox::draw(PainterInfo & pi, int x, int y) const -{ - Dimension const dim = dimension(*pi.base.bv); - Dimension const cdim = cell(0).dimension(*pi.base.bv); - - // kernel - cell(0).draw(pi, x + (dim.wid - cdim.wid) / 2, y); - - // label - if (parent_.editing(pi.base.bv) && label_.length() > 0) { - // grey - FontInfo font = sane_font; - font.setSize(FONT_SIZE_TINY); - font.setColor(Color_mathmacrolabel); - - // make space for label and box - int lwid = mathed_string_width(font, label_); - int maxasc; - int maxdes; - math_font_max_dim(font, maxasc, maxdes); - - if (lwid < dim.wid) - pi.pain.text(x + (dim.wid - lwid) / 2, y + dim.des - maxdes, label_, font); - else - pi.pain.text(x, y + dim.des - maxdes, label_, font); - } - - // draw frame - int boxHeight = parent_.commonLabelBoxAscent() + parent_.commonLabelBoxDescent(); - if (frame_) { - pi.pain.rectangle(x + 1, y - dim.ascent() + 1, - dim.wid - 2, boxHeight - 2, - Color_mathline); - } -} - - -////////////////////////////////////////////////////////////////////// - -class DisplayLabelBox : public InsetLabelBox { -public: - /// - DisplayLabelBox(Buffer * buf, MathAtom const & atom, docstring label, - MathMacroTemplate const & parent); - - /// - marker_type marker(BufferView const *) const; - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// - void draw(PainterInfo &, int x, int y) const; - -protected: - /// - Inset * clone() const; -}; - - -DisplayLabelBox::DisplayLabelBox(Buffer * buf, MathAtom const & atom, - docstring label, - MathMacroTemplate const & parent) - : InsetLabelBox(buf, atom, label, parent, true) -{ -} - - - -Inset * DisplayLabelBox::clone() const -{ - return new DisplayLabelBox(*this); -} - - -InsetMath::marker_type DisplayLabelBox::marker(BufferView const * bv) const -{ - if (parent_.editing(bv) - || !parent_.cell(parent_.displayIdx()).empty()) - return MARKER; - else - return NO_MARKER; -} - - -void DisplayLabelBox::metrics(MetricsInfo & mi, Dimension & dim) const -{ - InsetLabelBox::metrics(mi, dim); - if (!parent_.editing(mi.base.bv) - && parent_.cell(parent_.displayIdx()).empty()) { - dim.wid = 0; - dim.asc = 0; - dim.des = 0; - } -} - - -void DisplayLabelBox::draw(PainterInfo & pi, int x, int y) const -{ - if (parent_.editing(pi.base.bv) - || !parent_.cell(parent_.displayIdx()).empty()) { - InsetLabelBox::draw(pi, x, y); - } else { - bool enabled = pi.pain.isDrawingEnabled(); - pi.pain.setDrawingEnabled(false); - InsetLabelBox::draw(pi, x, y); - pi.pain.setDrawingEnabled(enabled); - } -} - - -////////////////////////////////////////////////////////////////////// - -class InsetMathWrapper : public InsetMath { -public: - /// - InsetMathWrapper(MathData const * value) : value_(value) {} - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// - void draw(PainterInfo &, int x, int y) const; - -private: - /// - Inset * clone() const; - /// - MathData const * value_; -}; - - -Inset * InsetMathWrapper::clone() const -{ - return new InsetMathWrapper(*this); -} - - -void InsetMathWrapper::metrics(MetricsInfo & mi, Dimension & dim) const -{ - value_->metrics(mi, dim); -} - - -void InsetMathWrapper::draw(PainterInfo & pi, int x, int y) const -{ - value_->draw(pi, x, y); -} - - -/////////////////////////////////////////////////////////////////////// -class InsetColoredCell : public InsetMathNest { -public: - /// - InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max); - /// - InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max, MathAtom const & atom); - /// - void draw(PainterInfo &, int x, int y) const; - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - -protected: - /// - Inset * clone() const; - /// - ColorCode min_; - /// - ColorCode max_; -}; - - -InsetColoredCell::InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max) - : InsetMathNest(buf, 1), min_(min), max_(max) -{ -} - - -InsetColoredCell::InsetColoredCell(Buffer * buf, ColorCode min, ColorCode max, MathAtom const & atom) - : InsetMathNest(buf, 1), min_(min), max_(max) -{ - cell(0).insert(0, atom); -} - - -Inset * InsetColoredCell::clone() const -{ - return new InsetColoredCell(*this); -} - - -void InsetColoredCell::metrics(MetricsInfo & mi, Dimension & dim) const -{ - cell(0).metrics(mi, dim); -} - - -void InsetColoredCell::draw(PainterInfo & pi, int x, int y) const -{ - pi.pain.enterMonochromeMode(min_, max_); - cell(0).draw(pi, x, y); - pi.pain.leaveMonochromeMode(); -} - - -/////////////////////////////////////////////////////////////////////// - -class InsetNameWrapper : public InsetMathWrapper { -public: - /// - InsetNameWrapper(MathData const * value, MathMacroTemplate const & parent); - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// - void draw(PainterInfo &, int x, int y) const; - -private: - /// - MathMacroTemplate const & parent_; - /// - Inset * clone() const; -}; - - -InsetNameWrapper::InsetNameWrapper(MathData const * value, - MathMacroTemplate const & parent) - : InsetMathWrapper(value), parent_(parent) -{ -} - - -Inset * InsetNameWrapper::clone() const -{ - return new InsetNameWrapper(*this); -} - - -void InsetNameWrapper::metrics(MetricsInfo & mi, Dimension & dim) const -{ - Changer dummy = mi.base.changeFontSet("textit"); - InsetMathWrapper::metrics(mi, dim); - dim.wid += mathed_string_width(mi.base.font, from_ascii("\\")); -} - - -void InsetNameWrapper::draw(PainterInfo & pi, int x, int y) const -{ - ColorCode const color = parent_.validMacro() ? Color_latex : Color_error; - - Changer dummy = pi.base.changeFontSet("textit"); - Changer dummy2 = pi.base.font.changeColor(color); - - // draw backslash - pi.pain.text(x, y, from_ascii("\\"), pi.base.font); - x += mathed_string_width(pi.base.font, from_ascii("\\")); - - // draw name - InsetMathWrapper::draw(pi, x, y); -} - - -/////////////////////////////////////////////////////////////////////// - - -MathMacroTemplate::MathMacroTemplate(Buffer * buf) - : InsetMathNest(buf, 3), numargs_(0), argsInLook_(0), optionals_(0), - type_(MacroTypeNewcommand), redefinition_(false), lookOutdated_(true), - premetrics_(false), labelBoxAscent_(0), labelBoxDescent_(0) -{ - initMath(); -} - - -MathMacroTemplate::MathMacroTemplate(Buffer * buf, docstring const & name, int numargs, - int optionals, MacroType type, vector const & optionalValues, - MathData const & def, MathData const & display) - : InsetMathNest(buf, optionals + 3), numargs_(numargs), argsInLook_(numargs), - optionals_(optionals), optionalValues_(optionalValues), - type_(type), redefinition_(false), lookOutdated_(true), - premetrics_(false), labelBoxAscent_(0), labelBoxDescent_(0) -{ - initMath(); - - if (numargs_ > 9) - lyxerr << "MathMacroTemplate::MathMacroTemplate: wrong # of arguments: " - << numargs_ << endl; - - asArray(name, cell(0)); - optionalValues_.resize(9); - for (int i = 0; i < optionals_; ++i) - cell(optIdx(i)) = optionalValues_[i]; - cell(defIdx()) = def; - cell(displayIdx()) = display; - - updateLook(); -} - - -bool MathMacroTemplate::fromString(docstring const & str) -{ - MathData ar(buffer_); - mathed_parse_cell(ar, str, Parse::NORMAL); - if (ar.size() != 1 || !ar[0]->asMacroTemplate()) { - lyxerr << "Cannot read macro from '" << ar << "'" << endl; - asArray(from_ascii("invalidmacro"), cell(0)); - // The macro template does not make sense after this. - return false; - } - operator=( *(ar[0]->asMacroTemplate()) ); - - updateLook(); - return true; -} - - -Inset * MathMacroTemplate::clone() const -{ - MathMacroTemplate * inset = new MathMacroTemplate(*this); - // the parent pointers of the proxy insets above will point to - // to the old template. Hence, the look must be updated. - inset->updateLook(); - return inset; -} - - -docstring MathMacroTemplate::name() const -{ - return asString(cell(0)); -} - - -void MathMacroTemplate::updateToContext(MacroContext const & mc) -{ - redefinition_ = mc.get(name()) != 0; -} - - -void MathMacroTemplate::updateLook() const -{ - lookOutdated_ = true; -} - - -void MathMacroTemplate::createLook(int args) const -{ - look_.clear(); - argsInLook_ = args; - - // \foo - look_.push_back(MathAtom( - new InsetLabelBox(buffer_, _("Name"), *this, false))); - MathData & nameData = look_[look_.size() - 1].nucleus()->cell(0); - nameData.push_back(MathAtom(new InsetNameWrapper(&cell(0), *this))); - - // [#1][#2] - int i = 0; - if (optionals_ > 0) { - look_.push_back(MathAtom( - new InsetLabelBox(buffer_, _("optional"), *this, false))); - - MathData * optData = &look_[look_.size() - 1].nucleus()->cell(0); - for (; i < optionals_; ++i) { - // color it light grey, if it is to be removed when the cursor leaves - if (i == argsInLook_) { - optData->push_back(MathAtom( - new InsetColoredCell(buffer_, Color_mathbg, Color_mathmacrooldarg))); - optData = &(*optData)[optData->size() - 1].nucleus()->cell(0); - } - - optData->push_back(MathAtom(new InsetMathChar('['))); - optData->push_back(MathAtom(new InsetMathWrapper(&cell(1 + i)))); - optData->push_back(MathAtom(new InsetMathChar(']'))); - } - } - - // {#3}{#4} - for (; i < numargs_; ++i) { - MathData arg; - arg.push_back(MathAtom(new MathMacroArgument(i + 1))); - if (i >= argsInLook_) { - look_.push_back(MathAtom(new InsetColoredCell(buffer_, - Color_mathbg, Color_mathmacrooldarg, - MathAtom(new InsetMathBrace(arg))))); - } else - look_.push_back(MathAtom(new InsetMathBrace(arg))); - } - for (; i < argsInLook_; ++i) { - MathData arg; - arg.push_back(MathAtom(new MathMacroArgument(i + 1))); - look_.push_back(MathAtom(new InsetColoredCell(buffer_, - Color_mathbg, Color_mathmacronewarg, - MathAtom(new InsetMathBrace(arg))))); - } - - // := - look_.push_back(MathAtom(new InsetMathChar(':'))); - look_.push_back(MathAtom(new InsetMathChar('='))); - - // definition - look_.push_back(MathAtom( - new InsetLabelBox(buffer_, MathAtom( - new InsetMathWrapper(&cell(defIdx()))), _("TeX"), *this, true))); - - // display - look_.push_back(MathAtom( - new DisplayLabelBox(buffer_, MathAtom( - new InsetMathWrapper(&cell(displayIdx()))), _("LyX"), *this))); -} - - -void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const -{ - Changer dummy1 = mi.base.changeFontSet("mathnormal"); - Changer dummy2 = mi.base.font.changeStyle(LM_ST_TEXT); - - // valid macro? - MacroData const * macro = 0; - if (validName()) - macro = mi.macrocontext.get(name()); - - // update look? - int argsInDef = maxArgumentInDefinition(); - if (lookOutdated_ || argsInDef != argsInLook_) { - lookOutdated_ = false; - createLook(argsInDef); - } - - /// metrics for inset contents - if (macro) - macro->lock(); - - // first phase, premetric: - premetrics_ = true; - look_.metrics(mi, dim); - labelBoxAscent_ = dim.asc; - labelBoxDescent_ = dim.des; - - // second phase, main metric: - premetrics_ = false; - look_.metrics(mi, dim); - - if (macro) - macro->unlock(); - - dim.wid += 6; - dim.des += 2; - dim.asc += 2; -} - - -void MathMacroTemplate::draw(PainterInfo & pi, int x, int y) const -{ - // FIXME: Calling Changer on the same object repeatedly is inefficient. - Changer dummy0 = pi.base.font.changeColor(Color_math); - Changer dummy1 = pi.base.changeFontSet("mathnormal"); - Changer dummy2 = pi.base.font.changeStyle(LM_ST_TEXT); - - Dimension const dim = dimension(*pi.base.bv); - - // draw outer frame - int const a = y - dim.asc + 1; - int const w = dim.wid - 2; - int const h = dim.height() - 2; - pi.pain.rectangle(x + 1, a, w, h, Color_mathframe); - - // just to be sure: set some dummy values for coord cache - for (idx_type i = 0; i < nargs(); ++i) - cell(i).setXY(*pi.base.bv, x, y); - - // draw contents - look_.draw(pi, x + 3, y); -} - - -void MathMacroTemplate::edit(Cursor & cur, bool front, EntryDirection entry_from) -{ - updateLook(); - cur.screenUpdateFlags(Update::SinglePar); - InsetMathNest::edit(cur, front, entry_from); -} - - -bool MathMacroTemplate::notifyCursorLeaves(Cursor const & old, Cursor & cur) -{ - unsigned int const nargs_before = nargs(); - commitEditChanges(cur, old); - updateLook(); - cur.screenUpdateFlags(Update::Force); - // If we have removed a cell, we might have invalidated the cursor - return InsetMathNest::notifyCursorLeaves(old, cur) - || nargs() < nargs_before; -} - - -void MathMacroTemplate::removeArguments(Cursor & cur, - DocIterator const & /*inset_pos*/, int from, int to) -{ - DocIterator it = doc_iterator_begin(&buffer(), this); - for (; it; it.forwardChar()) { - if (!it.nextInset()) - continue; - if (it.nextInset()->lyxCode() != MATH_MACROARG_CODE) - continue; - MathMacroArgument * arg = static_cast(it.nextInset()); - int n = arg->number() - 1; - if (from <= n && n <= to) { - int cellSlice = cur.find(it.cell()); - if (cellSlice != -1 && cur[cellSlice].pos() > it.pos()) - --cur[cellSlice].pos(); - - it.cell().erase(it.pos()); - } - } - - updateLook(); -} - - -void MathMacroTemplate::shiftArguments(size_t from, int by) -{ - for (DocIterator it = doc_iterator_begin(&buffer(), this); it; it.forwardChar()) { - if (!it.nextInset()) - continue; - if (it.nextInset()->lyxCode() != MATH_MACROARG_CODE) - continue; - MathMacroArgument * arg = static_cast(it.nextInset()); - if (arg->number() >= int(from) + 1) - arg->setNumber(arg->number() + by); - } - - updateLook(); -} - - -int MathMacroTemplate::maxArgumentInDefinition() const -{ - // We don't have a buffer when pasting from the clipboard (bug 6014). - Buffer const * macro_buffer = isBufferLoaded() ? &buffer() : 0; - int maxArg = 0; - DocIterator it = doc_iterator_begin(macro_buffer, this); - it.idx() = defIdx(); - for (; it; it.forwardChar()) { - if (!it.nextInset()) - continue; - if (it.nextInset()->lyxCode() != MATH_MACROARG_CODE) - continue; - MathMacroArgument * arg = static_cast(it.nextInset()); - maxArg = std::max(int(arg->number()), maxArg); - } - return maxArg; -} - - -void MathMacroTemplate::insertMissingArguments(int maxArg) -{ - bool found[9] = { false, false, false, false, false, false, false, false, false }; - idx_type idx = cell(displayIdx()).empty() ? defIdx() : displayIdx(); - - // search for #n macros arguments - DocIterator it = doc_iterator_begin(&buffer(), this); - it.idx() = idx; - for (; it && it[0].idx() == idx; it.forwardChar()) { - if (!it.nextInset()) - continue; - if (it.nextInset()->lyxCode() != MATH_MACROARG_CODE) - continue; - MathMacroArgument * arg = static_cast(it.nextInset()); - found[arg->number() - 1] = true; - } - - // add missing ones - for (int i = 0; i < maxArg; ++i) { - if (found[i]) - continue; - - cell(idx).push_back(MathAtom(new MathMacroArgument(i + 1))); - } -} - - -void MathMacroTemplate::changeArity(Cursor & cur, - DocIterator const & inset_pos, int newNumArg) -{ - // remove parameter which do not appear anymore in the definition - for (int i = numargs_; i > newNumArg; --i) - removeParameter(cur, inset_pos, numargs_ - 1, true); - - // add missing parameter - for (int i = numargs_; i < newNumArg; ++i) - insertParameter(cur, inset_pos, numargs_, true, false); -} - - -/// -class AddRemoveMacroInstanceFix -{ -public: - /// - AddRemoveMacroInstanceFix(int n, bool insert) : n_(n), insert_(insert) {} - /// - void operator()(MathMacro * macro) - { - if (macro->folded()) { - if (insert_) - macro->insertArgument(n_); - else - macro->removeArgument(n_); - } - } - -private: - /// - int n_; - /// - bool insert_; -}; - - -/// -class OptionalsMacroInstanceFix -{ -public: - /// - OptionalsMacroInstanceFix(int optionals) : optionals_(optionals) {} - /// - void operator()(MathMacro * macro) - { - macro->setOptionals(optionals_); - } - -private: - /// - int optionals_; -}; - - -/// -class NullMacroInstanceFix -{ -public: - /// - void operator()(MathMacro * ) {} -}; - - -template -void fixMacroInstances(Cursor & cur, DocIterator const & inset_pos, - docstring const & name, F & fix) -{ - // goto position behind macro template - DocIterator dit = inset_pos; - dit.pop_back(); - dit.top().forwardPos(); - - // remember hull to trigger preview reload - DocIterator hull(dit.buffer()); - bool preview_reload_needed = false; - set preview_hulls; - - // iterate over all positions until macro is redefined - for (; dit; dit.forwardPos()) { - // left the outer hull? - if (!hull.empty() && dit.depth() == hull.depth()) { - // schedule reload of the preview if necessary - if (preview_reload_needed) { - preview_hulls.insert(hull); - preview_reload_needed = false; - } - hull.clear(); - } - - // only until a macro is redefined - if (dit.inset().lyxCode() == MATHMACRO_CODE) { - MathMacroTemplate const & macroTemplate - = static_cast(dit.inset()); - if (macroTemplate.name() == name) - break; - } - - // in front of macro instance? - Inset * inset = dit.nextInset(); - if (!inset) - continue; - InsetMath * insetMath = inset->asInsetMath(); - if (!insetMath) - continue; - - // in front of outer hull? - InsetMathHull * inset_hull = insetMath->asHullInset(); - if (inset_hull && hull.empty()) { - // remember this for later preview reload - hull = dit; - } - - MathMacro * macro = insetMath->asMacro(); - if (macro && macro->name() == name && macro->folded()) { - fix(macro); - if (RenderPreview::previewMath()) - preview_reload_needed = true; - } - } - - if (!preview_hulls.empty()) { - // reload the scheduled previews - set::const_iterator sit = preview_hulls.begin(); - set::const_iterator end = preview_hulls.end(); - for (; sit != end; ++sit) { - InsetMathHull * inset_hull = - sit->nextInset()->asInsetMath()->asHullInset(); - LBUFERR(inset_hull); - inset_hull->reloadPreview(*sit); - } - cur.screenUpdateFlags(Update::Force); - } -} - - -void MathMacroTemplate::commitEditChanges(Cursor & cur, - DocIterator const & inset_pos) -{ - int args_in_def = maxArgumentInDefinition(); - if (args_in_def != numargs_) { - // FIXME: implement precise undo handling (only a few places - // need undo) - cur.recordUndoFullBuffer(); - changeArity(cur, inset_pos, args_in_def); - } - insertMissingArguments(args_in_def); - - // make sure the preview are up to date - NullMacroInstanceFix fix; - fixMacroInstances(cur, inset_pos, name(), fix); -} - - -void MathMacroTemplate::insertParameter(Cursor & cur, - DocIterator const & inset_pos, int pos, bool greedy, bool addarg) -{ - if (pos <= numargs_ && pos >= optionals_ && numargs_ < 9) { - ++numargs_; - - // append example #n - if (addarg) { - shiftArguments(pos, 1); - - cell(defIdx()).push_back(MathAtom(new MathMacroArgument(pos + 1))); - if (!cell(displayIdx()).empty()) - cell(displayIdx()).push_back(MathAtom(new MathMacroArgument(pos + 1))); - } - - if (!greedy) { - // fix macro instances - AddRemoveMacroInstanceFix fix(pos, true); - fixMacroInstances(cur, inset_pos, name(), fix); - } - } - - updateLook(); -} - - -void MathMacroTemplate::removeParameter(Cursor & cur, - DocIterator const & inset_pos, int pos, bool greedy) -{ - if (pos < numargs_ && pos >= 0) { - --numargs_; - removeArguments(cur, inset_pos, pos, pos); - shiftArguments(pos + 1, -1); - - // removed optional parameter? - if (pos < optionals_) { - --optionals_; - optionalValues_[pos] = cell(optIdx(pos)); - cells_.erase(cells_.begin() + optIdx(pos)); - - // fix cursor - int macroSlice = cur.find(this); - if (macroSlice != -1) { - if (cur[macroSlice].idx() == optIdx(pos)) { - cur.cutOff(macroSlice); - cur[macroSlice].idx() = 1; - cur[macroSlice].pos() = 0; - } else if (cur[macroSlice].idx() > optIdx(pos)) - --cur[macroSlice].idx(); - } - } - - if (!greedy) { - // fix macro instances - AddRemoveMacroInstanceFix fix(pos, false); - fixMacroInstances(cur, inset_pos, name(), fix); - } - } - - updateLook(); -} - - -void MathMacroTemplate::makeOptional(Cursor & cur, - DocIterator const & inset_pos) -{ - if (numargs_ > 0 && optionals_ < numargs_) { - ++optionals_; - cells_.insert(cells_.begin() + optIdx(optionals_ - 1), optionalValues_[optionals_ - 1]); - // fix cursor - int macroSlice = cur.find(this); - if (macroSlice != -1 && cur[macroSlice].idx() >= optIdx(optionals_ - 1)) - ++cur[macroSlice].idx(); - - // fix macro instances - OptionalsMacroInstanceFix fix(optionals_); - fixMacroInstances(cur, inset_pos, name(), fix); - } - - updateLook(); -} - - -void MathMacroTemplate::makeNonOptional(Cursor & cur, - DocIterator const & inset_pos) -{ - if (numargs_ > 0 && optionals_ > 0) { - --optionals_; - - // store default value for later if the user changes his mind - optionalValues_[optionals_] = cell(optIdx(optionals_)); - cells_.erase(cells_.begin() + optIdx(optionals_)); - - // fix cursor - int macroSlice = cur.find(this); - if (macroSlice != -1) { - if (cur[macroSlice].idx() > optIdx(optionals_)) - --cur[macroSlice].idx(); - else if (cur[macroSlice].idx() == optIdx(optionals_)) { - cur.cutOff(macroSlice); - cur[macroSlice].idx() = optIdx(optionals_); - cur[macroSlice].pos() = 0; - } - } - - // fix macro instances - OptionalsMacroInstanceFix fix(optionals_); - fixMacroInstances(cur, inset_pos, name(), fix); - } - - updateLook(); -} - - -void MathMacroTemplate::doDispatch(Cursor & cur, FuncRequest & cmd) -{ - string const arg = to_utf8(cmd.argument()); - switch (cmd.action()) { - - case LFUN_MATH_MACRO_ADD_PARAM: - if (numargs_ < 9) { - commitEditChanges(cur, cur); - // FIXME: implement precise undo handling (only a few places - // need undo) - cur.recordUndoFullBuffer(); - size_t pos = numargs_; - if (!arg.empty()) - pos = (size_t)convert(arg) - 1; // it is checked for >=0 in getStatus - insertParameter(cur, cur, pos); - } - break; - - - case LFUN_MATH_MACRO_REMOVE_PARAM: - if (numargs_ > 0) { - commitEditChanges(cur, cur); - // FIXME: implement precise undo handling (only a few places - // need undo) - cur.recordUndoFullBuffer(); - size_t pos = numargs_ - 1; - if (!arg.empty()) - pos = (size_t)convert(arg) - 1; // it is checked for >=0 in getStatus - removeParameter(cur, cur, pos); - } - break; - - case LFUN_MATH_MACRO_APPEND_GREEDY_PARAM: - if (numargs_ < 9) { - commitEditChanges(cur, cur); - // FIXME: implement precise undo handling (only a few places - // need undo) - cur.recordUndoFullBuffer(); - insertParameter(cur, cur, numargs_, true); - } - break; - - case LFUN_MATH_MACRO_REMOVE_GREEDY_PARAM: - if (numargs_ > 0) { - commitEditChanges(cur, cur); - // FIXME: implement precise undo handling (only a few places - // need undo) - cur.recordUndoFullBuffer(); - removeParameter(cur, cur, numargs_ - 1, true); - } - break; - - case LFUN_MATH_MACRO_MAKE_OPTIONAL: - commitEditChanges(cur, cur); - // FIXME: implement precise undo handling (only a few places - // need undo) - cur.recordUndoFullBuffer(); - makeOptional(cur, cur); - break; - - case LFUN_MATH_MACRO_MAKE_NONOPTIONAL: - commitEditChanges(cur, cur); - // FIXME: implement precise undo handling (only a few places - // need undo) - cur.recordUndoFullBuffer(); - makeNonOptional(cur, cur); - break; - - case LFUN_MATH_MACRO_ADD_OPTIONAL_PARAM: - if (numargs_ < 9) { - commitEditChanges(cur, cur); - // FIXME: implement precise undo handling (only a few places - // need undo) - cur.recordUndoFullBuffer(); - insertParameter(cur, cur, optionals_); - makeOptional(cur, cur); - } - break; - - case LFUN_MATH_MACRO_REMOVE_OPTIONAL_PARAM: - if (optionals_ > 0) { - commitEditChanges(cur, cur); - // FIXME: implement precise undo handling (only a few places - // need undo) - cur.recordUndoFullBuffer(); - removeParameter(cur, cur, optionals_ - 1); - } break; - - case LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM: - if (numargs_ == optionals_) { - commitEditChanges(cur, cur); - // FIXME: implement precise undo handling (only a few places - // need undo) - cur.recordUndoFullBuffer(); - insertParameter(cur, cur, 0, true); - makeOptional(cur, cur); - } - break; - - default: - InsetMathNest::doDispatch(cur, cmd); - break; - } -} - - -bool MathMacroTemplate::getStatus(Cursor & cur, FuncRequest const & cmd, - FuncStatus & flag) const -{ - bool ret = true; - string const arg = to_utf8(cmd.argument()); - switch (cmd.action()) { - case LFUN_MATH_MACRO_ADD_PARAM: { - int num = numargs_ + 1; - if (!arg.empty()) - num = convert(arg); - bool on = (num >= optionals_ - && numargs_ < 9 && num <= numargs_ + 1); - flag.setEnabled(on); - break; - } - - case LFUN_MATH_MACRO_APPEND_GREEDY_PARAM: - flag.setEnabled(numargs_ < 9); - break; - - case LFUN_MATH_MACRO_REMOVE_GREEDY_PARAM: - case LFUN_MATH_MACRO_REMOVE_PARAM: { - int num = numargs_; - if (!arg.empty()) - num = convert(arg); - flag.setEnabled(num >= 1 && num <= numargs_); - break; - } - - case LFUN_MATH_MACRO_MAKE_OPTIONAL: - flag.setEnabled(numargs_ > 0 - && optionals_ < numargs_ - && type_ != MacroTypeDef); - break; - - case LFUN_MATH_MACRO_MAKE_NONOPTIONAL: - flag.setEnabled(optionals_ > 0 - && type_ != MacroTypeDef); - break; - - case LFUN_MATH_MACRO_ADD_OPTIONAL_PARAM: - flag.setEnabled(numargs_ < 9); - break; - - case LFUN_MATH_MACRO_REMOVE_OPTIONAL_PARAM: - flag.setEnabled(optionals_ > 0); - break; - - case LFUN_MATH_MACRO_ADD_GREEDY_OPTIONAL_PARAM: - flag.setEnabled(numargs_ == 0 - && type_ != MacroTypeDef); - break; - - case LFUN_IN_MATHMACROTEMPLATE: - flag.setEnabled(true); - break; - - default: - ret = InsetMathNest::getStatus(cur, cmd, flag); - break; - } - return ret; -} - - -void MathMacroTemplate::read(Lexer & lex) -{ - MathData ar(buffer_); - mathed_parse_cell(ar, lex.getStream(), Parse::TRACKMACRO); - if (ar.size() != 1 || !ar[0]->asMacroTemplate()) { - lyxerr << "Cannot read macro from '" << ar << "'" << endl; - lyxerr << "Read: " << to_utf8(asString(ar)) << endl; - return; - } - operator=( *(ar[0]->asMacroTemplate()) ); - - updateLook(); -} - - -void MathMacroTemplate::write(ostream & os) const -{ - odocstringstream oss; - otexrowstream ots(oss); - WriteStream wi(ots, false, false, WriteStream::wsDefault); - oss << "FormulaMacro\n"; - write(wi); - os << to_utf8(oss.str()); -} - - -void MathMacroTemplate::write(WriteStream & os) const -{ - write(os, false); -} - - -int MathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition) const -{ - int num_lines = 0; - - if (os.latex()) { - if (optionals_ > 0) { - // macros with optionals use the xargs package, e.g.: - // \newcommandx{\foo}[2][usedefault, addprefix=\global,1=default]{#1,#2} - // \long is implicit by xargs - if (redefinition_ && !overwriteRedefinition) - os << "\\renewcommandx"; - else - os << "\\newcommandx"; - - os << "\\" << name() - << "[" << numargs_ << "]" - << "[usedefault, addprefix=\\global"; - for (int i = 0; i < optionals_; ++i) { - docstring optValue = asString(cell(optIdx(i))); - if (optValue.find(']') != docstring::npos - || optValue.find(',') != docstring::npos) - os << ", " << i + 1 << "=" - << "{" << cell(optIdx(i)) << "}"; - else - os << ", " << i + 1 << "=" - << cell(optIdx(i)); - } - os << "]"; - } else { - // Macros without optionals use standard _global_ \def macros: - // \global\def\long\foo#1#2{#1,#2} - // We use the \long prefix as this is the equivalent to \newcommand. - // We cannot use \newcommand directly because \global does not work with it. - os << "\\global\\long\\def\\" << name(); - docstring param = from_ascii("#0"); - for (int i = 1; i <= numargs_; ++i) { - param[1] = '0' + i; - os << param; - } - } - } else { - // in LyX output we use some pseudo syntax which is implementation - // independent, e.g. - // \newcommand{\foo}[2][default]{#1,#2} - if (redefinition_ && !overwriteRedefinition) - os << "\\renewcommand"; - else - os << "\\newcommand"; - os << "{\\" << name() << '}'; - if (numargs_ > 0) - os << '[' << numargs_ << ']'; - - for (int i = 0; i < optionals_; ++i) { - docstring optValue = asString(cell(optIdx(i))); - if (optValue.find(']') != docstring::npos) - os << "[{" << cell(optIdx(i)) << "}]"; - else - os << "[" << cell(optIdx(i)) << "]"; - } - } - - os << "{" << cell(defIdx()) << "}"; - - if (os.latex()) { - // writing .tex. done. - os << "\n"; - ++num_lines; - } else { - // writing .lyx, write special .tex export only if necessary - if (!cell(displayIdx()).empty()) { - os << "\n{" << cell(displayIdx()) << '}'; - ++num_lines; - } - } - - return num_lines; -} - - -docstring MathMacroTemplate::xhtml(XHTMLStream &, OutputParams const &) const -{ - return docstring(); -} - -int MathMacroTemplate::plaintext(odocstringstream & os, - OutputParams const &, size_t) const -{ - docstring const str = '[' + buffer().B_("math macro") + ']'; - - os << str; - return str.size(); -} - - -bool MathMacroTemplate::validName() const -{ - docstring n = name(); - - if (n.empty()) - return false; - - // converting back and force doesn't swallow anything? - /*MathData ma; - asArray(n, ma); - if (asString(ma) != n) - return false;*/ - - // valid characters? - for (size_t i = 0; i < n.size(); ++i) { - if (!(n[i] >= 'a' && n[i] <= 'z') - && !(n[i] >= 'A' && n[i] <= 'Z') - && n[i] != '*') - return false; - } - - return true; -} - - -bool MathMacroTemplate::validMacro() const -{ - return validName(); -} - - -bool MathMacroTemplate::fixNameAndCheckIfValid() -{ - // check all the characters/insets in the name cell - size_t i = 0; - MathData & data = cell(0); - while (i < data.size()) { - InsetMathChar const * cinset = data[i]->asCharInset(); - if (cinset) { - // valid character in [a-zA-Z]? - char_type c = cinset->getChar(); - if ((c >= 'a' && c <= 'z') - || (c >= 'A' && c <= 'Z')) { - ++i; - continue; - } - } - - // throw cell away - data.erase(i); - } - - // now it should be valid if anything in the name survived - return !data.empty(); -} - - -void MathMacroTemplate::validate(LaTeXFeatures & features) const -{ - // we need global optional macro arguments. They are not available - // with \def, and \newcommand does not support global macros. So we - // are bound to xargs also for the single-optional-parameter case. - if (optionals_ > 0) - features.require("xargs"); -} - -void MathMacroTemplate::getDefaults(vector & defaults) const -{ - defaults.resize(numargs_); - for (int i = 0; i < optionals_; ++i) - defaults[i] = asString(cell(optIdx(i))); -} - - -docstring MathMacroTemplate::definition() const -{ - return asString(cell(defIdx())); -} - - -docstring MathMacroTemplate::displayDefinition() const -{ - return asString(cell(displayIdx())); -} - - -size_t MathMacroTemplate::numArgs() const -{ - return numargs_; -} - - -size_t MathMacroTemplate::numOptionals() const -{ - return optionals_; -} - - -void MathMacroTemplate::infoize(odocstream & os) const -{ - os << bformat(_("Math Macro: \\%1$s"), name()); -} - - -string MathMacroTemplate::contextMenuName() const -{ - return "context-math-macro-definition"; -} - - -void MathMacroTemplate::addToToc(DocIterator const & pit, bool output_active, - UpdateType, TocBackend & backend) const -{ - docstring str; - if (!validMacro()) - str = bformat(_("Invalid macro! \\%1$s"), name()); - else - str = "\\" + name(); - TocBuilder & b = backend.builder("math-macro"); - b.pushItem(pit, str, output_active); - b.pop(); -} - - -} // namespace lyx diff --git a/src/mathed/MathMacroTemplate.h b/src/mathed/MathMacroTemplate.h deleted file mode 100644 index d67b8a27c7..0000000000 --- a/src/mathed/MathMacroTemplate.h +++ /dev/null @@ -1,192 +0,0 @@ -// -*- C++ -*- -/** - * \file math_macrotemplate.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Alejandro Aguilar Sierra - * \author André Pönitz - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef MATH_MACROTEMPLATE_H -#define MATH_MACROTEMPLATE_H - -#include "InsetMathNest.h" -#include "MacroTable.h" -#include "MathData.h" - - -namespace lyx { - -class OutputParams; -class XHTMLStream; - -/// This class contains the macro definition. -class MathMacroTemplate : public InsetMathNest { -public: - /// - MathMacroTemplate(Buffer * buf); - /// - MathMacroTemplate(Buffer * buf, docstring const & name, int nargs, - int optional, MacroType type, - std::vector const & optionalValues = std::vector(), - MathData const & def = MathData(), - MathData const & display = MathData()); - /// parses from string, returns false if failed - bool fromString (const docstring & str); - /// - bool editable() const { return true; } - /// - void edit(Cursor & cur, bool front, EntryDirection entry_from); - /// - bool notifyCursorLeaves(Cursor const & old, Cursor & cur); - /// - void read(Lexer & lex); - /// - void write(std::ostream & os) const; - /// - void write(WriteStream & os) const; - /// Output LaTeX code, but assume that the macro is not definied yet - /// if overwriteRedefinition is true - int write(WriteStream & os, bool overwriteRedefinition) const; - /// Nothing happens. This is simply to suppress the default output. - docstring xhtml(XHTMLStream &, OutputParams const &) const; - /// - int plaintext(odocstringstream &, OutputParams const &, size_t) const; - /// - bool inheritFont() const { return false; } - - /// - docstring name() const; - /// - void getDefaults(std::vector & defaults) const; - /// - docstring definition() const; - /// - docstring displayDefinition() const; - /// - size_t numArgs() const; - /// - size_t numOptionals() const; - /// - bool redefinition() const { return redefinition_; } - /// - MacroType type() const { return type_; } - - /// check name and possible other formal properties - bool validMacro() const; - /// - bool validName() const; - /// Remove everything from the name which makes it invalid - /// and return true iff it is valid. - bool fixNameAndCheckIfValid(); - - /// request "external features" - virtual void validate(LaTeXFeatures &) const; - - /// decide whether its a redefinition - void updateToContext(MacroContext const & mc); - - /// - void draw(PainterInfo & pi, int x, int y) const; - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// identifies macro templates - MathMacroTemplate * asMacroTemplate() { return this; } - /// identifies macro templates - MathMacroTemplate const * asMacroTemplate() const { return this; } - /// - InsetCode lyxCode() const { return MATHMACRO_CODE; } - /// - void infoize(odocstream & os) const; - /// - std::string contextMenuName() const; - /// - void addToToc(DocIterator const & di, bool output_active, - UpdateType utype, TocBackend & backend) const; -protected: - /// - virtual void doDispatch(Cursor & cur, FuncRequest & cmd); - /// do we want to handle this event? - bool getStatus(Cursor & cur, FuncRequest const & cmd, - FuncStatus & status) const; - -private: - friend class InsetLabelBox; - friend class DisplayLabelBox; - - /// - virtual Inset * clone() const; - - /// remove #n with from<=n<=to - void removeArguments(Cursor & cur, DocIterator const & inset_pos, - int from, int to); - /// shift every #n with from<=n, i.e. #n -> #(n-by) - void shiftArguments(size_t from, int by); - /// - void insertParameter(Cursor & cur, DocIterator const & inset_pos, - int pos, bool greedy = false, bool addarg = true); - /// - void removeParameter(Cursor & cur, DocIterator const & inset_pos, - int pos, bool greedy = false); - /// - void makeOptional(Cursor & cur, DocIterator const & inset_pos); - /// - void makeNonOptional(Cursor & cur, DocIterator const & inset_pos); - /// - idx_type defIdx() const { return optionals_ + 1; } - /// index of default value cell of optional parameter (#1 -> n=0) - idx_type optIdx(idx_type n) const { return n + 1; } - /// - idx_type displayIdx() const { return optionals_ + 2; } - /// - void updateLook() const; - /// look through the macro for #n arguments - int maxArgumentInDefinition() const; - /// add missing #n arguments up to \c maxArg - void insertMissingArguments(int maxArg); - /// change the arity - void changeArity(Cursor & cur, DocIterator const & inset_pos, - int newNumArg); - /// find arguments in definition and adapt the arity accordingly - void commitEditChanges(Cursor & cur, DocIterator const & inset_pos); - /// The representation of the macro template, with some holes to edit - mutable MathData look_; - /// - mutable int numargs_; - /// - mutable int argsInLook_; - /// - int optionals_; - /// keeps the old optional default value when an - /// optional argument is disabled - std::vector optionalValues_; - - /// (re)newcommand or def - mutable MacroType type_; - /// defined before already? - bool redefinition_; - /// - void createLook(int args) const; - /// - mutable bool lookOutdated_; - /// true if in pre-calculations of metrics to get height of boxes - mutable bool premetrics_; - /// - mutable int labelBoxAscent_; - /// - mutable int labelBoxDescent_; - /// - bool premetrics() const { return premetrics_; } - /// - int commonLabelBoxAscent() const { return labelBoxAscent_; } - /// - int commonLabelBoxDescent() const { return labelBoxDescent_; } -}; - - -} // namespace lyx - -#endif diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp index b39f172fb7..35062caefe 100644 --- a/src/mathed/MathParser.cpp +++ b/src/mathed/MathParser.cpp @@ -51,7 +51,7 @@ following hack as starting point to write some macros: #include "InsetMathEnv.h" #include "InsetMathFrac.h" #include "InsetMathKern.h" -#include "MathMacro.h" +#include "InsetMathMacro.h" #include "InsetMathPar.h" #include "InsetMathRef.h" #include "InsetMathRoot.h" @@ -63,10 +63,10 @@ following hack as starting point to write some macros: #include "InsetMathStackrel.h" #include "InsetMathString.h" #include "InsetMathTabular.h" -#include "MathMacroTemplate.h" +#include "InsetMathMacroTemplate.h" #include "MathExtern.h" #include "MathFactory.h" -#include "MathMacroArgument.h" +#include "InsetMathMacroArgument.h" #include "MathSupport.h" #include "Buffer.h" @@ -932,7 +932,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, Token const & n = nextToken(); char_type c = n.character(); if (c && '0' < c && c <= '9') { - cell->push_back(MathAtom(new MathMacroArgument(c - '0'))); + cell->push_back(MathAtom(new InsetMathMacroArgument(c - '0'))); getToken(); } else cell->push_back(MathAtom(new InsetMathHash())); @@ -1082,7 +1082,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, if (nextToken().cat() == catBegin) parse(display, FLAG_ITEM, InsetMath::MATH_MODE); - cell->push_back(MathAtom(new MathMacroTemplate(buf, + cell->push_back(MathAtom(new InsetMathMacroTemplate(buf, name, nargs, 0, MacroTypeDef, vector(), def, display))); @@ -1130,7 +1130,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, if (nextToken().cat() == catBegin) parse(display, FLAG_ITEM, InsetMath::MATH_MODE); - cell->push_back(MathAtom(new MathMacroTemplate(buf, + cell->push_back(MathAtom(new InsetMathMacroTemplate(buf, name, nargs, optionals, MacroTypeNewcommand, optionalValues, def, display))); @@ -1251,7 +1251,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, if (nextToken().cat() == catBegin) parse(display, FLAG_ITEM, InsetMath::MATH_MODE); - cell->push_back(MathAtom(new MathMacroTemplate(buf, + cell->push_back(MathAtom(new InsetMathMacroTemplate(buf, name, nargs, optionals, MacroTypeNewcommandx, optionalValues, def, display))); @@ -1399,7 +1399,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, // parse the remaining contents into the "real" cell parse(*cell, FLAG_ITEM, mode); } else { - MathAtom at = MathAtom(new MathMacro(buf, t.cs())); + MathAtom at = MathAtom(new InsetMathMacro(buf, t.cs())); cell->push_back(at); cell->push_back(MathAtom(new InsetMathBrace(count))); } @@ -1787,7 +1787,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, break; } if (s.empty()) - cell->push_back(MathAtom(new MathMacro(buf, t.cs()))); + cell->push_back(MathAtom(new InsetMathMacro(buf, t.cs()))); else cell->push_back(MathAtom(new InsetMathKern(s))); } @@ -1897,7 +1897,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, else { // Since the Length class cannot use length variables // we must not create an InsetMathSpace. - cell->push_back(MathAtom(new MathMacro(buf, name))); + cell->push_back(MathAtom(new InsetMathMacro(buf, name))); MathData ar; mathed_parse_cell(ar, '{' + arg + '}', mode_); cell->append(ar); @@ -1916,7 +1916,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, parse(cell->back().nucleus()->cell(0), FLAG_ITEM, mode); } else { docstring const arg = parse_verbatim_item(); - cell->push_back(MathAtom(new MathMacro(buf, t.cs()))); + cell->push_back(MathAtom(new InsetMathMacro(buf, t.cs()))); MathData ar; mathed_parse_cell(ar, '[' + opt + ']', mode_); cell->append(ar); @@ -2098,7 +2098,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags, } if (!is_unicode_symbol) { MathAtom at = is_user_macro ? - MathAtom(new MathMacro(buf, t.cs())) + MathAtom(new InsetMathMacro(buf, t.cs())) : createInsetMath(t.cs(), buf); InsetMath::mode_type m = mode; //if (m == InsetMath::UNDECIDED_MODE) diff --git a/src/mathed/MathStream.h b/src/mathed/MathStream.h index 262fc6e8d6..19da27640a 100644 --- a/src/mathed/MathStream.h +++ b/src/mathed/MathStream.h @@ -178,7 +178,7 @@ int ensureMode(WriteStream & os, InsetMath::mode_type mode, bool locked, bool as * * A local variable of this type can be used to either ensure math mode * or delay the writing of a pending brace when outputting LaTeX. - * A LyX MathMacro is always assumed needing a math mode environment, while + * A LyX InsetMathMacro is always assumed needing a math mode environment, while * no assumption is made for macros defined through \newcommand or \def. * * Example 1: @@ -208,7 +208,7 @@ int ensureMode(WriteStream & os, InsetMath::mode_type mode, bool locked, bool as * to be specified. Only the following 3 different cases are handled. * * When the needs_mathmode parameter is true the behavior is as in Example 1. - * This is the case for a LyX MathMacro or a macro not tagged as textmode. + * This is the case for a LyX InsetMathMacro or a macro not tagged as textmode. * * When the needs_mathmode and textmode_macro parameters are both false the * macro is left in the same (text or math mode) environment it was entered.