From babee598f46a361242835c42871fa6534f8dff78 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 10 Aug 2001 11:51:06 +0000 Subject: [PATCH] store optional eol arg and write it back if necessary git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2480 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_gridinset.C | 24 ++++++++++++++++++++++++ src/mathed/math_gridinset.h | 7 +++++++ src/mathed/math_parser.C | 10 ++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index b07c576d5c..44fcc33ec8 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -45,6 +45,7 @@ int MathGridInset::index(int row, int col) const } + void MathGridInset::halign(string const & hh) { int n = hh.size(); @@ -54,26 +55,45 @@ void MathGridInset::halign(string const & hh) colinfo_[i].h_align_ = hh[i]; } + void MathGridInset::halign(char h, int col) { colinfo_[col].h_align_ = h; } + char MathGridInset::halign(int col) const { return colinfo_[col].h_align_; } + + void MathGridInset::valign(char c) { v_align_ = c; } + char MathGridInset::valign() const { return v_align_; } + + +void MathGridInset::vskip(LyXLength const & skip, int row) +{ + rowinfo_[row].skip_ = skip; +} + + +LyXLength MathGridInset::vskip(int row) const +{ + return rowinfo_[row].skip_; +} + + void MathGridInset::metrics(MathStyles st) const { // let the cells adjust themselves @@ -220,6 +240,9 @@ string MathGridInset::eolString(int row) const if (row == nrows() - 1) return ""; + if (rowinfo_[row].skip_ != LyXLength()) + return "\\\\[" + rowinfo_[row].skip_.asLatexString() + "]\n"; + // make sure an upcoming '[' does not break anything MathArray const & c = cell(index(row + 1, 0)); if (c.size() && (*c.begin())->getChar() == '[') @@ -243,6 +266,7 @@ void MathGridInset::addRow(int row) cells_.insert(cells_.begin() + (row + 1) * ncols(), ncols(), MathXArray()); } + void MathGridInset::appendRow() { rowinfo_.push_back(RowInfo()); diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index 45356556a6..af1ff7dfa2 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -3,6 +3,7 @@ #define MATH_GRID_H #include "math_nestinset.h" +#include "vspace.h" #include "LString.h" #ifdef __GNUG__ @@ -31,6 +32,8 @@ class MathGridInset : public MathNestInset { bool upperline_; /// hline below this row? bool lowerline_; + /// distance + LyXLength skip_; }; // additional per-row information @@ -71,6 +74,10 @@ public: /// char valign() const; /// + void vskip(LyXLength const &, int row); + /// + LyXLength vskip(int row) const; + /// void resize(short int type, int cols); /// const RowInfo & rowinfo(int row) const; diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index c6479cc273..bb7ef9c5be 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -237,8 +237,10 @@ private: /// bool curr_num_; - // + /// string curr_label_; + /// + string curr_skip_; }; @@ -410,6 +412,10 @@ void Parser::parse_lines(MathGridInset * p, int col, bool numbered, bool outmost MathMatrixInset * m = static_cast(p); m->numbered(row, curr_num_); m->label(row, curr_label_); + if (curr_skip_.size()) { + m->vskip(LyXLength(curr_skip_), row); + curr_skip_.erase(); + } } #ifdef WITH_WARNINGS @@ -673,7 +679,7 @@ void Parser::parse_into(MathArray & array, unsigned flags) case LM_TK_NEWLINE: { - lexArg('['); // ignore things like \\[5pt] for a while + curr_skip_ = lexArg('['); if (flags & FLAG_NEWLINE) { flags &= ~FLAG_NEWLINE; --plevel; -- 2.39.5