]> git.lyx.org Git - features.git/commitdiff
Rename some macro-related insets
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 5 Jul 2017 12:31:28 +0000 (14:31 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 5 Jul 2017 12:46:34 +0000 (14:46 +0200)
These classes should have names that start with "Inset". Renaming done:
MathMacro => InsetMathMacro
MathMacroTemplate => InsetMathMacroTemplate
MathMacroArgument => InsetMathMacroArgument
ArgumentProxy => InsetArgumentProxy
DisplayLabelBox => InsetDisplayLabelBox
CommandInset => InsetMathCommand

74 files changed:
po/ar.po
po/bg.po
po/ca.po
po/cs.po
po/da.po
po/de.po
po/el.po
po/en.po
po/es.po
po/eu.po
po/fi.po
po/fr.po
po/gl.po
po/he.po
po/hu.po
po/ia.po
po/id.po
po/it.po
po/ja.po
po/ko.po
po/nb.po
po/nl.po
po/nn.po
po/pl.po
po/pt_BR.po
po/pt_PT.po
po/ro.po
po/ru.po
po/sk.po
po/sl.po
po/sr.po
po/sv.po
po/tr.po
po/uk.po
po/wa.po
po/zh_CN.po
po/zh_TW.po
src/Buffer.cpp
src/Cursor.cpp
src/CursorSlice.cpp
src/Makefile.am
src/Text3.cpp
src/TextMetrics.cpp
src/factory.cpp
src/insets/Inset.cpp
src/insets/InsetCollapsable.h
src/mathed/CommandInset.cpp [deleted file]
src/mathed/CommandInset.h [deleted file]
src/mathed/InsetMath.h
src/mathed/InsetMathCommand.cpp [new file with mode: 0644]
src/mathed/InsetMathCommand.h [new file with mode: 0644]
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathMacro.cpp [new file with mode: 0644]
src/mathed/InsetMathMacro.h [new file with mode: 0644]
src/mathed/InsetMathMacroArgument.cpp [new file with mode: 0644]
src/mathed/InsetMathMacroArgument.h [new file with mode: 0644]
src/mathed/InsetMathMacroTemplate.cpp [new file with mode: 0644]
src/mathed/InsetMathMacroTemplate.h [new file with mode: 0644]
src/mathed/InsetMathNest.cpp
src/mathed/InsetMathRef.cpp
src/mathed/InsetMathRef.h
src/mathed/MacroTable.cpp
src/mathed/MacroTable.h
src/mathed/MathData.cpp
src/mathed/MathData.h
src/mathed/MathFactory.cpp
src/mathed/MathMacro.cpp [deleted file]
src/mathed/MathMacro.h [deleted file]
src/mathed/MathMacroArgument.cpp [deleted file]
src/mathed/MathMacroArgument.h [deleted file]
src/mathed/MathMacroTemplate.cpp [deleted file]
src/mathed/MathMacroTemplate.h [deleted file]
src/mathed/MathParser.cpp
src/mathed/MathStream.h

index f55211397b130fba338ba3eb93145a27b7a058e9..07f97939b678d44c17a80a82b75210b65fb74590 100644 (file)
--- 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"
index 71d229e41216076821dbb9c81c53f24da9224461..a86667c158575f2cfd26597fdb38ac3d70623608 100644 (file)
--- 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 ""
index c105c39ad4779a72dd6e021a5d238b05b848f561..b9a0e47b13993d00774c6d1317e3c13ed84e53f8 100644 (file)
--- 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 ""
index 28532e09f650c3be1a2df6c7dff210867a295cdd..e994480f0680003f777714ae3854408e40898e54 100644 (file)
--- 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 ""
index 846855b022a799013bd4b846eb35038579e945e9..5eadcafdecfa8d7c0b2026e74e715ed82774ae19 100644 (file)
--- 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 ""
index a6f26c53a608611bdc5439a0f9396248fb1e48c4..ef3ac871ed6c44e3ee2a88fa4475776b7b3f4da2 100644 (file)
--- 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"
index 033fcaaabf378a33c846d2909bc5501ed4daaa4c..cdf8c9adaf3813411835ecf4808105506bdbe344 100644 (file)
--- 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 ""
index 8722b0b7f7527f2658bc8e7465e82285b8fa737a..60b889c0c9476764fef4ecbf5b23f659e7043360 100644 (file)
--- 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 ""
index ea96ea3de249c2db6cd87e448ba8e88956dca320..396e63bb04c4c884420c40142fa478afb5d51b37 100644 (file)
--- 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"
index aa879d37b05538ad7ac86d8099aeb2a4a46a5944..98e0ccda6b8a02177408aac3acba908d4a66c4e4 100644 (file)
--- 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 ""
index fc535bc907fae03c5f599545c9ca8555b8f75c04..4bd16d1eaf5a8308b046ecb910e5b6e4f3b41695 100644 (file)
--- 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"
index 4a1ccc3e8522c767b97c42e93ca03f0baa957e6b..48f2bd966ac9de322d5e92afbeadc323bd8f0373 100644 (file)
--- 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"
index 4d080d8465152cacd645beb5f7ce4482f47a2c12..781b6d763c07496e47dfbc657babc65c0da1ed65 100644 (file)
--- 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 ""
index cfd1a3e23c8b425a5c09459d0a0e10fa1a429a87..bc34747d2c397125d49f5ce44e7473677e89f280 100644 (file)
--- 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 "מקרו מתמטיים"
index 43f28d4b23adafa7e8d3c7d910bab58fe7f087b8..c73ac39f8b8cc0bf6f18c773bec8e98644b2a30f 100644 (file)
--- 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 ""
index 19415872ab321baadb0e38657193b9963f6c087e..6d3457709cf9899a5cae088eb447656636d4ab86 100644 (file)
--- 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"
index 992543f7ea42c087c40e792b642bef4868eb4dc2..5ca1799100a95d911bec317b11e7985a204e6a9d 100644 (file)
--- 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 ""
index 86a73070e093d058ea1c4d2f97aafa7fe9bc5d85..8bb3e0da79578e06af97e3d5c157e029a8b28852 100644 (file)
--- 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"
index 59acc50b839db9dbedc8d9052e6919f2579ef4ef..bae4d1504ec580f20bb7f798109026c16a5830b7 100644 (file)
--- 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"
index febc114ed2b0c981711f1e11393e119c13c8a08e..f88b52c7cd73ca14ccb2850494e1c96a318b22bf 100644 (file)
--- 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 ""
index aaab2fc834ceae8a6d11da1d3f35711101124578..cbc8429153424e8875c6b7dda10a9c2bd117fa82 100644 (file)
--- 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"
index 9a57e2bfbb039fa49ff74c1c02839afdf5941848..8de137986ae14a7e37e2577675e67a280599c202 100644 (file)
--- 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 ""
index e0c6ed2e29c81de5935ec454674a82dc04ff3832..1790a25aee638a360155bcc2fd45fff37314b25e 100644 (file)
--- 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 ""
index c6aa6d35c8dfb1030697977021e421a883282b29..6672dbc606599d8e14798bc9947a0001a9b0db9a 100644 (file)
--- 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 ""
index 8fd4f07647b13095bdfcb45048f52bda1c8ede21..73f5876c915ea1708886a88ef75eba2ceddc9339 100644 (file)
@@ -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"
index 2bbf297b60e86440c8c0f8d490ab4be2f566f38d..4f35b26f7c393402dcb4adb9a3c331fb3687542d 100644 (file)
@@ -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 ""
index d31d188c9ea2dec5a898d9df5dee16dd48edcb86..754c8f67e0c7dd8521d556c5ac217acf24791327 100644 (file)
--- 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 ""
index 3337eca43e4eb516481792df332cea3fbda91b2e..c881fb6eed0e01b4aad438a07017adbd9693a485 100644 (file)
--- 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 ""
index 682e01b26696390cf321eb8decf380d0e2faa242..40cae678a15e95b770ee73bee44bc3d38f3b47cf 100644 (file)
--- 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"
index 3f35cc5eec8c6d06305009f8ae3a33c54d8fcbdc..858a2de6a62fe04c3f71294beae6cd8a141bcf53 100644 (file)
--- 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 ""
index e901b2b99f00c6420fdd71154d67baa99235eefd..6b132599bb65e033d2e809d3a9f3ed9791fd6ed2 100644 (file)
--- 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 ""
index 96a86a4ec90a5463b87f5f7d2377e1fe50c46e88..d57cef6096fcf175f40ab68f0f75c2efa370cca3 100644 (file)
--- 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"
index cfe1f2ee0e2a6c99bf8779e18654546ca2e7f7d2..555be928aebb23b6dbcff8ed9b8eb67ce8d3c46a 100644 (file)
--- 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 ""
index ca357985f5390a6ab90af7c0c3547478eacaaade..1c00b17b48938633f2bf564ceff6fe06bc219407 100644 (file)
--- 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"
index 09d32554ada188576994c4795acd3b9df80c8cbd..c0f1935558d4bb465ea786889aca21bd021ea368 100644 (file)
--- 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 ""
index d626a220b5c7ef6daca86c419a99af33a578d48e..4b3fd690f5fa461758685a09eecade27f5c0c0cc 100644 (file)
@@ -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 ""
index 1d31416ed09038ecb3880ca3b1408b95f5d80f68..ca395d04b9dc9a36cf11bd83d14c3f9ece1ed330 100644 (file)
@@ -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 ""
index 5e2057ac5b764b45d110b934e2c5a356f08185be..df7efa8f0c0c3e398630f462c77d4669f8ef1172 100644 (file)
@@ -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)
index eff32d05769bf650b7f6846c586efdaf19fa5267..1223782c358a16d72b1341f5073045cbabeed9d1 100644 (file)
@@ -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 <sstream>
 #include <limits>
@@ -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
index 76049a05419e2f77bd2f019918e984a8d2b57940..c5be12f5000a6c6b6dc771036b5228609837a078 100644 (file)
@@ -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"
index 5bf8f3bd5e3f19f4c0c18b208fc4a5327425f3a4..9bc6b197708506a46baf1b9ea0e6070bc020dd78 100644 (file)
@@ -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 \
index e8e433587fc14c07b221974a075c3d7d7aebd6b0..364e91c1dc1a2d87608ad04b9d72b8f1cc1de9e5 100644 (file)
@@ -78,7 +78,7 @@
 #include "support/regex.h"
 
 #include "mathed/InsetMathHull.h"
-#include "mathed/MathMacroTemplate.h"
+#include "mathed/InsetMathMacroTemplate.h"
 
 #include <clocale>
 #include <sstream>
@@ -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);
index f38c78d3ea7d98e6799d17a41898eafe8bba1049..0967dacfd25161b5bf612308b3dc6619623b95f3 100644 (file)
@@ -39,7 +39,7 @@
 
 #include "insets/InsetText.h"
 
-#include "mathed/MathMacroTemplate.h"
+#include "mathed/InsetMathMacroTemplate.h"
 
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
index 7ec34fc8e3dc600b3fbc6b5cf24d5da760e68be5..72019cd6f72bc1dae92f8feef321384db357c47f 100644 (file)
@@ -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") {
index 2190be70567a257f417220d1dec7efa2a232927a..b458c8181bfe74f50c049c6e3017c6f12f96f33b 100644 (file)
@@ -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;
 
index a426db034ab12903057c96fd01fce67b0bb5d2af..bb4f234b9dd818ef1c7dbf8dbe7f07fb54c671fd 100644 (file)
@@ -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 (file)
index 344c570..0000000
+++ /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 <config.h>
-
-#include "CommandInset.h"
-#include "MathData.h"
-#include "MathStream.h"
-#include "DispatchResult.h"
-
-#include <sstream>
-
-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 (file)
index b820d72..0000000
+++ /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
index 81cad09b486fd692b2643064b77273760de46d45..578b29fdcfd671926789bf3036b3859003c21941 100644 (file)
@@ -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 (file)
index 0000000..deac6c3
--- /dev/null
@@ -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 <config.h>
+
+#include "InsetMathCommand.h"
+#include "MathData.h"
+#include "MathStream.h"
+#include "DispatchResult.h"
+
+#include <sstream>
+
+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 (file)
index 0000000..da4269c
--- /dev/null
@@ -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
index 3c72f4d6bda52e5e25a939cc658159f3165d4e04..f4005d91242e640d4907136dae53243829052034 100644 (file)
@@ -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 (file)
index 0000000..d2d4a8b
--- /dev/null
@@ -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 <config.h>
+
+#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 <ostream>
+#include <vector>
+
+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<BufferView const *, bool> 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<InsetArgumentProxy *>(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_ = &macroBackup_;
+       }
+}
+
+
+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
+                               <InsetArgumentProxy *>(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<docstring> const & defaults = d->macro_->defaults();
+
+       // create MathMacroArgumentValue objects pointing to the cells of the macro
+       vector<MathData> 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<n.size(); ++i) {
+               if (!(n[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<MathData> & 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<MathData> 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 << " </"
+                          << type << '>';
+                       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 (file)
index 0000000..4267a2b
--- /dev/null
@@ -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 <map>
+
+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<MathData> & 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<MathData> 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 (file)
index 0000000..7fca256
--- /dev/null
@@ -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 <config.h>
+
+#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<docstring>(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 (file)
index 0000000..178c898
--- /dev/null
@@ -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 (file)
index 0000000..17fc2d0
--- /dev/null
@@ -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 <config.h>
+
+#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 <set>
+#include <sstream>
+
+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<MathData> 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<InsetMathMacroArgument*>(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<InsetMathMacroArgument*>(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<InsetMathMacroArgument*>(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<InsetMathMacroArgument*>(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<class F>
+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<DocIterator> 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<InsetMathMacroTemplate const &>(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<DocIterator>::const_iterator sit = preview_hulls.begin();
+               set<DocIterator>::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<int>(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<int>(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<int>(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<int>(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<docstring> & 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 (file)
index 0000000..ddcfe4d
--- /dev/null
@@ -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<MathData> const & optionalValues = std::vector<MathData>(),
+               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<docstring> & 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<MathData> 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
index 993b6fc0fe1fb44aa773c3385d1362169b905077..f9c8813a01249ec1328b5e5b7428940f0fe25aae 100644 (file)
@@ -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;
                }
 
index 22807f15b533a5be5eb829e192d0089ff0a125ad..42151209e733d43ca222b926c2a58d078f8ad37f 100644 (file)
@@ -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);
        }
 }
 
index 8011f9452cafed71cc3afe435891d573f5b18541..d1046d9aba8b1d1ba3545c73a47019c8d3e7dee8 100644 (file)
 #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);
index 2899e40c2e7e75b76d55d5ef040ecd83a6b9fab5..d279bdb84490c0c0efe4214905f117316babb610 100644 (file)
@@ -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<MathData> const & args, MathData & to) const
                        continue;
                //it.cell().erase(it.pos());
                //it.cell().insert(it.pos(), it.nextInset()->asInsetMath()
-               size_t n = static_cast<MathMacroArgument*>(it.nextInset())->number();
+               size_t n = static_cast<InsetMathMacroArgument*>(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<MathMacroTemplate const &>(*inset));
+       queryData(static_cast<InsetMathMacroTemplate const &>(*inset));
 }
 
 
@@ -198,8 +198,8 @@ int MacroData::write(odocstream & os, bool overwriteRedefinition) const
        }
 
        // output template
-       MathMacroTemplate const & tmpl =
-               static_cast<MathMacroTemplate const &>(*inset);
+       InsetMathMacroTemplate const & tmpl =
+               static_cast<InsetMathMacroTemplate const &>(*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);
index bc445d43974fef7f7314160a5a8f1f43ad2d4dd3..eb613cae073c1987b272f62893324dab9fd1ccc3 100644 (file)
@@ -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;
        ///
index d6522ab3a35ae38a6974ae0f554c24fdfb3f51fc..beb1299b9afa565a3f63a1cb9f3d00683fd87218 100644 (file)
@@ -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
index f29d1e59dc62fb6ef42290d916b3db1772bf01a8..2f6ab22acd3967d76fad2b55b1405422343251a6 100644 (file)
@@ -38,7 +38,7 @@ class DocIterator;
 class LaTeXFeatures;
 class ReplaceData;
 class MacroContext;
-class MathMacro;
+class InsetMathMacro;
 class MetricsInfo;
 class PainterInfo;
 class ParIterator;
index 79ae676fc39b3ddc3d583149fd7d306f41e6d568..cebac7c9ccb40cc04ec70191d2098b88b1e882bd 100644 (file)
@@ -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 (file)
index 63bb44f..0000000
+++ /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 <config.h>
-
-#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 <ostream>
-#include <vector>
-
-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<BufferView const *, bool> 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<ArgumentProxy *>(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_ = &macroBackup_;
-       }
-}
-
-
-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
-                               <ArgumentProxy *>(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<docstring> const & defaults = d->macro_->defaults();
-
-       // create MathMacroArgumentValue objects pointing to the cells of the macro
-       vector<MathData> 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<n.size(); ++i) {
-               if (!(n[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<MathData> & 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<MathData> 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 << " </"
-                          << type << '>';
-                       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 (file)
index 0d4ba34..0000000
+++ /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 <map>
-
-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<MathData> & 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<MathData> 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 (file)
index d3a16ff..0000000
+++ /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 <config.h>
-
-#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<docstring>(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 (file)
index bb9fa1d..0000000
+++ /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 (file)
index 4aef5eb..0000000
+++ /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 <config.h>
-
-#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 <set>
-#include <sstream>
-
-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<MathData> 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<MathMacroArgument*>(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<MathMacroArgument*>(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<MathMacroArgument*>(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<MathMacroArgument*>(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<class F>
-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<DocIterator> 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<MathMacroTemplate const &>(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<DocIterator>::const_iterator sit = preview_hulls.begin();
-               set<DocIterator>::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<int>(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<int>(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<int>(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<int>(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<docstring> & 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 (file)
index d67b8a2..0000000
+++ /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<MathData> const & optionalValues = std::vector<MathData>(),
-               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<docstring> & 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<MathData> 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
index b39f172fb7a6983fe8c679bdff061c47cdeaf1cb..35062caefe3a3c69cbe75c5f522f64641ec499a7 100644 (file)
@@ -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<MathData>(), 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)
index 262fc6e8d61afd619f25c93af0f66b68bf425332..19da27640afd9e820c70d2f72c14d423a8ebfff1 100644 (file)
@@ -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.