#: 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 "الاسم"
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 "تيك"
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 "ليك"
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"
#: 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 "Име"
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"
# 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"
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 ""
#: 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"
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"
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"
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 ""
#: 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"
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"
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"
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 ""
#: 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"
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"
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"
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 ""
#: 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"
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"
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"
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"
#: 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 "Όνομα"
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 ""
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 ""
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 ""
#: 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 ""
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 ""
msgstr ""
#: lib/configure.py:731 src/frontends/qt4/GuiView.cpp:1327
-#: src/mathed/MathMacroTemplate.cpp:549
+#: src/mathed/InsetMathMacroTemplate.cpp:549
msgid "LyX"
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 ""
#: 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"
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"
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"
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"
#: 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"
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"
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"
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 ""
#: 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"
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"
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"
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"
#: 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"
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"
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"
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"
#: 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"
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"
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"
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 ""
#: 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 "שם"
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"
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"
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 "מקרו מתמטיים"
#: 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"
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"
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"
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 ""
#: 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"
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"
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"
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"
#: 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"
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"
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"
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 ""
#: 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"
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"
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"
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"
#: 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 "名前"
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"
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"
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"
#: 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 ""
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"
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"
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 ""
#: 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"
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"
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"
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"
#: 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 ""
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"
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"
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 ""
#: 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"
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"
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"
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 ""
#: 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"
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"
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"
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 ""
#: 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"
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"
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"
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"
#: 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"
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"
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"
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 ""
#: 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"
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"
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"
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 ""
#: 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 "Название"
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"
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"
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 ""
#: 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"
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"
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"
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"
#: 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"
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"
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"
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 ""
#: 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"
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"
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"
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 ""
#: 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"
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"
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"
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"
#: 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"
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"
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"
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 ""
#: 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 "Назва"
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"
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"
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"
#: 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"
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"
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"
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 ""
#: 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 "名字"
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"
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"
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 ""
#: 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 "名稱"
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 符號"
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"
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 ""
#include "mathed/InsetMathHull.h"
#include "mathed/MacroTable.h"
-#include "mathed/MathMacroTemplate.h"
+#include "mathed/InsetMathMacroTemplate.h"
#include "mathed/MathSupport.h"
#include "graphics/GraphicsCache.h"
continue;
// get macro data
- MathMacroTemplate & macroTemplate =
+ InsetMathMacroTemplate & macroTemplate =
*iit->inset->asInsetMath()->asMacroTemplate();
MacroContext mc(owner_, it);
macroTemplate.updateToContext(mc);
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)
#include "mathed/MacroTable.h"
#include "mathed/MathData.h"
#include "mathed/MathFactory.h"
-#include "mathed/MathMacro.h"
+#include "mathed/InsetMathMacro.h"
#include <sstream>
#include <limits>
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
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
#include "insets/Inset.h"
#include "mathed/InsetMath.h"
-#include "mathed/MathMacro.h"
+#include "mathed/InsetMathMacro.h"
#include "support/ExceptionMessage.h"
#include "support/gettext.h"
noinst_LIBRARIES += liblyxmathed.a
SOURCEFILESMATHED = \
- mathed/CommandInset.cpp \
mathed/InsetMathAMSArray.cpp \
mathed/InsetMathArray.cpp \
mathed/InsetMathBig.cpp \
mathed/InsetMathChar.cpp \
mathed/InsetMathClass.cpp \
mathed/InsetMathColor.cpp \
+ mathed/InsetMathCommand.cpp \
mathed/InsetMathComment.cpp \
mathed/InsetMathDecoration.cpp \
mathed/InsetMathDecoration.h \
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 \
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 \
mathed/TextPainter.cpp
HEADERFILESMATHED = \
- mathed/CommandInset.h \
mathed/InsetMathAMSArray.h \
mathed/InsetMathArray.h \
mathed/InsetMathBig.h \
mathed/InsetMathChar.h \
mathed/InsetMathClass.h \
mathed/InsetMathColor.h \
+ mathed/InsetMathCommand.h \
mathed/InsetMathComment.h \
mathed/InsetMathDelim.h \
mathed/InsetMathDiff.h \
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 \
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 \
#include "support/regex.h"
#include "mathed/InsetMathHull.h"
-#include "mathed/MathMacroTemplate.h"
+#include "mathed/InsetMathMacroTemplate.h"
#include <clocale>
#include <sstream>
// 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()
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);
#include "insets/InsetText.h"
-#include "mathed/MathMacroTemplate.h"
+#include "mathed/InsetMathMacroTemplate.h"
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
#include "insets/InsetVSpace.h"
#include "insets/InsetWrap.h"
-#include "mathed/MathMacroTemplate.h"
+#include "mathed/InsetMathMacroTemplate.h"
#include "mathed/InsetMathHull.h"
#include "frontends/alert.h"
} 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") {
}
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;
/// 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_;
+++ /dev/null
-/**
- * \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
+++ /dev/null
-// -*- 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
class WriteStream;
class MathData;
-class MathMacroTemplate;
-class MathMacro;
+class InsetMathMacroTemplate;
+class InsetMathMacro;
class MathRow;
class TextPainter;
class TextMetricsInfo;
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; }
--- /dev/null
+/**
+ * \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
--- /dev/null
+// -*- 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
#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"
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();
--- /dev/null
+/**
+ * \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_ = ¯oBackup_;
+ }
+}
+
+
+void InsetMathMacro::Private::updateNestedChildren(InsetMathMacro * owner, InsetMathNest * ni)
+{
+ for (size_t i = 0; i < ni->nargs(); ++i) {
+ MathData & ar = ni->cell(i);
+ for (size_t j = 0; j < ar.size(); ++j) {
+ InsetArgumentProxy * ap = dynamic_cast
+ <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
--- /dev/null
+// -*- 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
--- /dev/null
+/**
+ * \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
--- /dev/null
+// -*- 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
--- /dev/null
+/**
+ * \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
--- /dev/null
+// -*- 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
#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"
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);
// 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)
cur.backspace();
int n = c - '0';
if (n >= 1 && n <= 9)
- cur.insert(new MathMacroArgument(n));
+ cur.insert(new InsetMathMacroArgument(n));
return true;
}
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)
{}
break;
default:
- CommandInset::doDispatch(cur, cmd);
+ InsetMathCommand::doDispatch(cur, cmd);
break;
}
}
status.setEnabled(true);
return true;
default:
- return CommandInset::getStatus(cur, cmd, status);
+ return InsetMathCommand::getStatus(cur, cmd, status);
}
}
#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);
#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"
}
-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)
{
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]);
}
-void MacroData::queryData(MathMacroTemplate const & macro) const
+void MacroData::queryData(InsetMathMacroTemplate const & macro) const
{
if (queried_)
return;
}
// query the data from the macro template
- queryData(static_cast<MathMacroTemplate const &>(*inset));
+ queryData(static_cast<InsetMathMacroTemplate const &>(*inset));
}
}
// 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);
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);
class Buffer;
class MathData;
-class MathMacroTemplate;
+class InsetMathMacroTemplate;
class Paragraph;
class latexkeys;
/// 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_; }
private:
///
- void queryData(MathMacroTemplate const & macro) const;
+ void queryData(InsetMathMacroTemplate const & macro) const;
///
void updateData() const;
///
#include "InsetMathFont.h"
#include "InsetMathScript.h"
#include "MacroTable.h"
-#include "MathMacro.h"
+#include "InsetMathMacro.h"
#include "MathStream.h"
#include "MathSupport.h"
#include "MetricsInfo.h"
// 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
}
// 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);
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,
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();
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
class LaTeXFeatures;
class ReplaceData;
class MacroContext;
-class MathMacro;
+class InsetMathMacro;
class MetricsInfo;
class PainterInfo;
class ParIterator;
#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"
}
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.
//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) {
}
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")
if (s == "regexp")
return MathAtom(new InsetMathHull(buf, hullRegexp));
- return MathAtom(new MathMacro(buf, s));
+ return MathAtom(new InsetMathMacro(buf, s));
}
+++ /dev/null
-/**
- * \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_ = ¯oBackup_;
- }
-}
-
-
-void MathMacro::Private::updateNestedChildren(MathMacro * owner, InsetMathNest * ni)
-{
- for (size_t i = 0; i < ni->nargs(); ++i) {
- MathData & ar = ni->cell(i);
- for (size_t j = 0; j < ar.size(); ++j) {
- ArgumentProxy * ap = dynamic_cast
- <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
+++ /dev/null
-// -*- 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
+++ /dev/null
-/**
- * \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
+++ /dev/null
-// -*- 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
+++ /dev/null
-/**
- * \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
+++ /dev/null
-// -*- 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
#include "InsetMathEnv.h"
#include "InsetMathFrac.h"
#include "InsetMathKern.h"
-#include "MathMacro.h"
+#include "InsetMathMacro.h"
#include "InsetMathPar.h"
#include "InsetMathRef.h"
#include "InsetMathRoot.h"
#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"
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()));
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)));
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)));
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)));
// 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)));
}
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)));
}
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);
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);
}
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)
*
* 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:
* 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.