From df36a96f80358e3c274fadf7317bf898e13cd92f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 15 Feb 2002 14:50:40 +0000 Subject: [PATCH] support for 'gathered', 'aligned', 'matrix', \overleftrightarrow, \underleftrightarrow git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3546 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_amsarrayinset.C | 8 ++++++-- src/mathed/math_factory.C | 7 ++++--- src/mathed/math_hash.C | 2 ++ src/mathed/math_parser.C | 5 +++-- src/mathed/math_splitinset.C | 21 +++++++++++++++++---- src/mathed/math_splitinset.h | 8 ++++++-- src/mathed/math_support.C | 2 ++ 7 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/mathed/math_amsarrayinset.C b/src/mathed/math_amsarrayinset.C index 4e395791db..ad53ae2c15 100644 --- a/src/mathed/math_amsarrayinset.C +++ b/src/mathed/math_amsarrayinset.C @@ -36,7 +36,9 @@ char const * MathAMSArrayInset::name_left() const return "|"; if (name_ == "Vmatrix") return "Vert"; - return "("; + if (name_ == "pmatrix") + return "("; + return "."; } @@ -48,7 +50,9 @@ char const * MathAMSArrayInset::name_right() const return "|"; if (name_ == "Vmatrix") return "Vert"; - return ")"; + if (name_ == "pmatrix") + return ")"; + return "."; } diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index bd9c997a66..11d931a713 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -104,8 +104,8 @@ MathAtom createMathInset(string const & s) if (s == "xrightarrow") return MathAtom(new MathXArrowInset(s)); - if (s == "split") - return MathAtom(new MathSplitInset(1)); + if (s == "split" || s == "gathered" || s == "aligned") + return MathAtom(new MathSplitInset(s)); if (s == "cases") return MathAtom(new MathCasesInset); @@ -116,7 +116,8 @@ MathAtom createMathInset(string const & s) if (s == "subarray" || s == "array") return MathAtom(new MathArrayInset(s, 1, 1)); - if (s == "pmatrix" || s == "bmatrix" || s == "vmatrix" || s == "Vmatrix") + if (s == "pmatrix" || s == "bmatrix" || s == "vmatrix" || s == "Vmatrix" || + s == "matrix") return MathAtom(new MathAMSArrayInset(s)); latexkeys const * l = in_word_set(s); diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index af928434ff..5878967be6 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -116,6 +116,7 @@ key_type wordlist_array[] = {"overleftarrow", LM_TK_DECORATION, 0}, {"overline", LM_TK_DECORATION, 0}, {"overrightarrow", LM_TK_DECORATION, 0}, + {"overleftrightarrow", LM_TK_DECORATION, 0}, {"protect", LM_TK_PROTECT, 0}, {"qquad", LM_TK_SPACE, 5}, {"quad", LM_TK_SPACE, 4}, @@ -141,6 +142,7 @@ key_type wordlist_array[] = {"underleftarrow", LM_TK_DECORATION, 0}, {"underline", LM_TK_DECORATION, 0}, {"underrightarrow", LM_TK_DECORATION, 0}, + {"underleftrightarrow", LM_TK_DECORATION, 0}, {"underset", LM_TK_UNDERSET, 0}, {"vdots", LM_TK_DOTS, 0}, {"vec", LM_TK_DECORATION, 0}, diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index c6d24218aa..5804afc3d0 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -1093,10 +1093,11 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code) string const halign = getArg('{', '}'); array.push_back(MathAtom(new MathArrayInset(name, valign[0], halign))); parse_lines(array.back(), false, false); - } else if (name == "split" || name == "cases") { + } else if (name == "split" || name == "cases" || + name == "gathered" || name == "aligned") { array.push_back(createMathInset(name)); parse_lines(array.back(), false, false); - } else if (name == "pmatrix" || name == "bmatrix" || + } else if (name == "matrix" || name == "pmatrix" || name == "bmatrix" || name == "vmatrix" || name == "Vmatrix") { array.push_back(createMathInset(name)); parse_lines2(array.back(), false); diff --git a/src/mathed/math_splitinset.C b/src/mathed/math_splitinset.C index 1a37210d78..e7d9389cc7 100644 --- a/src/mathed/math_splitinset.C +++ b/src/mathed/math_splitinset.C @@ -4,10 +4,11 @@ #include "math_splitinset.h" #include "math_mathmlstream.h" +#include "math_streamstr.h" -MathSplitInset::MathSplitInset(int n) - : MathGridInset(2, n) +MathSplitInset::MathSplitInset(string const & name) + : MathGridInset(1, 1), name_(name) { setDefaults(); } @@ -19,13 +20,25 @@ MathInset * MathSplitInset::clone() const } +char MathSplitInset::defaultColAlign(col_type col) +{ + if (name_ == "split") + return 'l'; + if (name_ == "gathered") + return 'c'; + if (name_ == "aligned") + return (col & 1) ? 'l' : 'r'; + return 'l'; +} + + void MathSplitInset::write(WriteStream & ws) const { if (ws.fragile()) ws << "\\protect"; - ws << "\\begin{split}"; + ws << "\\begin{" << name_ << "}"; MathGridInset::write(ws); if (ws.fragile()) ws << "\\protect"; - ws << "\\end{split}\n"; + ws << "\\end{" << name_ << "}\n"; } diff --git a/src/mathed/math_splitinset.h b/src/mathed/math_splitinset.h index 56f452d663..540efaf2a8 100644 --- a/src/mathed/math_splitinset.h +++ b/src/mathed/math_splitinset.h @@ -3,6 +3,7 @@ #define MATH_SPLITINSET_H #include "math_gridinset.h" +#include "LString.h" #ifdef __GNUG__ #pragma interface @@ -12,7 +13,7 @@ class MathSplitInset : public MathGridInset { public: /// - explicit MathSplitInset(int n); + explicit MathSplitInset(string const & name); /// MathInset * clone() const; /// @@ -20,7 +21,10 @@ public: /// int defaultColSpace(col_type) { return 0; } /// - char defaultColAlign(col_type) { return 'l'; } + char defaultColAlign(col_type); +private: + /// + string name_; }; #endif diff --git a/src/mathed/math_support.C b/src/mathed/math_support.C index b19eeab53a..ad794593ee 100644 --- a/src/mathed/math_support.C +++ b/src/mathed/math_support.C @@ -473,10 +473,12 @@ named_deco_struct deco_table[] = { {"overbrace", brace, 3 }, {"overleftarrow", arrow, 1 }, {"overrightarrow", arrow, 3 }, + {"overleftrightarrow", udarrow, 1 }, {"xleftarrow", arrow, 1 }, {"xrightarrow", arrow, 3 }, {"underleftarrow", arrow, 1 }, {"underrightarrow", arrow, 3 }, + {"underleftrightarrow",udarrow, 1 }, // Delimiters {"(", parenth, 0 }, -- 2.39.5