From 006106094d3b9f8c02578844a3eb911cc0ace4c4 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Tue, 3 Oct 2006 19:49:57 +0000 Subject: [PATCH] Parse optional arguments of aligned, gathered and alignedat * src/mathed/math_splitinset.[Ch] (MathSplitInset): Add valignment argument to constructor * src/mathed/math_splitinset.C (MathSplitInset::write): write vertical alignment if needed * src/mathed/math_parser.C (Parser::parse1): parse optional arguments of aligned, gathered and alignedat git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@15225 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_parser.C | 13 ++++++++++--- src/mathed/math_splitinset.C | 7 ++++--- src/mathed/math_splitinset.h | 2 +- status.14x | 2 ++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 27ac62a226..65b4f661ec 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -54,6 +54,7 @@ following hack as starting point to write some macros: #include "math_parinset.h" #include "math_rootinset.h" #include "math_scriptinset.h" +#include "math_splitinset.h" #include "math_sqrtinset.h" #include "math_support.h" #include "math_tabularinset.h" @@ -1097,16 +1098,22 @@ void Parser::parse1(MathGridInset & grid, unsigned flags, parse2(cell->back(), FLAG_END, MathInset::TEXT_MODE, false); } - else if (name == "split" || name == "cases" || - name == "gathered" || name == "aligned") { + else if (name == "split" || name == "cases") { cell->push_back(createMathInset(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 MathSplitInset(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(createMathInset(name)); + cell->push_back(MathAtom(new MathSplitInset(name, valign[0]))); parse2(cell->back(), FLAG_END, mode, false); } diff --git a/src/mathed/math_splitinset.C b/src/mathed/math_splitinset.C index 0d2a4f7f07..44938c79df 100644 --- a/src/mathed/math_splitinset.C +++ b/src/mathed/math_splitinset.C @@ -29,10 +29,9 @@ using std::string; using std::auto_ptr; -MathSplitInset::MathSplitInset(string const & name) - : MathGridInset(1, 1), name_(name) +MathSplitInset::MathSplitInset(string const & name, char valign) + : MathGridInset(1, 1, valign, string()), name_(name) { - setDefaults(); } @@ -89,6 +88,8 @@ void MathSplitInset::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) << '}'; MathGridInset::write(ws); diff --git a/src/mathed/math_splitinset.h b/src/mathed/math_splitinset.h index db980147d1..2ffbcbb379 100644 --- a/src/mathed/math_splitinset.h +++ b/src/mathed/math_splitinset.h @@ -18,7 +18,7 @@ class MathSplitInset : public MathGridInset { public: /// - explicit MathSplitInset(std::string const & name); + explicit MathSplitInset(std::string const & name, char valign = 'c'); /// void draw(PainterInfo & pi, int x, int y) const; diff --git a/status.14x b/status.14x index 49ecec73ee..0fe422c492 100644 --- a/status.14x +++ b/status.14x @@ -33,6 +33,8 @@ What's new * Document Input/Output +- Parse the optional argument of the AMS math environments aligned, gathered + and alignedat. * User Interface: