From: Georg Baum Date: Mon, 2 Oct 2006 20:01:30 +0000 (+0000) Subject: Parse optional arguments of aligned, gathered and alignedat X-Git-Tag: 1.6.10~12481 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8a9d0934e96c91fcb117a877e6579e32502d8cc0;p=features.git Parse optional arguments of aligned, gathered and alignedat * src/mathed/InsetMathSplit.[Ch] (InsetMathSplit): Add valignment argument to constructor * src/mathed/InsetMathSplit.C (InsetMathSplit::write): write vertical alignment if needed * src/mathed/MathParser.C (Parser::parse1): parse optional arguments of aligned, gathered and alignedat git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15202 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/InsetMathSplit.C b/src/mathed/InsetMathSplit.C index b78c5708f3..606191e1fd 100644 --- a/src/mathed/InsetMathSplit.C +++ b/src/mathed/InsetMathSplit.C @@ -30,10 +30,9 @@ using std::string; using std::auto_ptr; -InsetMathSplit::InsetMathSplit(string const & name) - : InsetMathGrid(1, 1), name_(name) +InsetMathSplit::InsetMathSplit(string const & name, char valign) + : InsetMathGrid(1, 1, valign, string()), name_(name) { - setDefaults(); } @@ -90,6 +89,8 @@ void InsetMathSplit::write(WriteStream & ws) const if (ws.fragile()) ws << "\\protect"; ws << "\\begin{" << name_ << '}'; + if (name_ != "split" && valign() != 'c') + ws << '[' << valign() << ']'; if (name_ == "alignedat") ws << '{' << static_cast((ncols() + 1)/2) << '}'; InsetMathGrid::write(ws); diff --git a/src/mathed/InsetMathSplit.h b/src/mathed/InsetMathSplit.h index b77b0db3f1..327b3010d6 100644 --- a/src/mathed/InsetMathSplit.h +++ b/src/mathed/InsetMathSplit.h @@ -18,7 +18,7 @@ class InsetMathSplit : public InsetMathGrid { public: /// - explicit InsetMathSplit(std::string const & name); + explicit InsetMathSplit(std::string const & name, char valign = 'c'); /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/src/mathed/MathParser.C b/src/mathed/MathParser.C index f71fccab46..f2196d2175 100644 --- a/src/mathed/MathParser.C +++ b/src/mathed/MathParser.C @@ -54,6 +54,7 @@ following hack as starting point to write some macros: #include "InsetMathRef.h" #include "InsetMathRoot.h" #include "InsetMathScript.h" +#include "InsetMathSplit.h" #include "InsetMathSqrt.h" #include "InsetMathTabular.h" #include "MathMacroTemplate.h" @@ -1099,16 +1100,22 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags, parse2(cell->back(), FLAG_END, InsetMath::TEXT_MODE, false); } - else if (name == "split" || name == "cases" || - name == "gathered" || name == "aligned") { + else if (name == "split" || name == "cases") { cell->push_back(createInsetMath(name)); parse2(cell->back(), FLAG_END, mode, false); } + else if (name == "gathered" || name == "aligned") { + string const valign = parse_verbatim_option() + 'c'; + cell->push_back(MathAtom(new InsetMathSplit(name, valign[0]))); + parse2(cell->back(), FLAG_END, mode, false); + } + else if (name == "alignedat") { + string const valign = parse_verbatim_option() + 'c'; // ignore this for a while getArg('{', '}'); - cell->push_back(createInsetMath(name)); + cell->push_back(MathAtom(new InsetMathSplit(name, valign[0]))); parse2(cell->back(), FLAG_END, mode, false); }