From c50bd2b5730a8a8211be844e32360a890e476afc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 12 Sep 2001 12:51:55 +0000 Subject: [PATCH] fix delimiter handling for \, |, and / git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2740 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/formulabase.C | 6 ++---- src/mathed/math_cursor.C | 2 +- src/mathed/math_cursor.h | 2 +- src/mathed/math_deliminset.C | 12 +++++------- src/mathed/math_deliminset.h | 12 +++++------- src/mathed/math_parser.C | 14 ++------------ src/mathed/support.C | 3 ++- 7 files changed, 18 insertions(+), 33 deletions(-) diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index ab62ccb72c..2436eda6a7 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -575,14 +575,12 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, string rs; istringstream is(arg.c_str()); is >> ls >> rs; - latexkeys const * l = in_word_set(ls); - latexkeys const * r = in_word_set(rs); - if (!is || !l || !r) { + if (!is) { lyxerr << "can't parse delimeters from '" << arg << "'\n"; break; } bv->lockedInsetStoreUndo(Undo::EDIT); - mathcursor->handleDelim(l, r); + mathcursor->handleDelim(ls, rs); updateLocal(bv, true); break; } diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index e334f75eba..f33924586c 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -752,7 +752,7 @@ void MathCursor::handleFont(MathTextCodes t) } -void MathCursor::handleDelim(latexkeys const * l, latexkeys const * r) +void MathCursor::handleDelim(string const & l, string const & r) { handleNest(new MathDelimInset(l, r)); } diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 34f9333789..09b98ec2fd 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -163,7 +163,7 @@ public: /// void handleFont(MathTextCodes t); /// - void handleDelim(latexkeys const * l, latexkeys const * r); + void handleDelim(string const & l, string const & r); /// void handleNest(MathInset * p); /// Splits cells and shifts right part to the next cell diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index d42bbf79d3..6bb3abb1a7 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -11,7 +11,7 @@ using std::max; -MathDelimInset::MathDelimInset(latexkeys const * l, latexkeys const * r) +MathDelimInset::MathDelimInset(string const & l, string const & r) : MathNestInset(1), left_(l), right_(r) {} @@ -22,10 +22,8 @@ MathInset * MathDelimInset::clone() const } -string MathDelimInset::latexName(latexkeys const * l) +string MathDelimInset::latexName(string const & name) { - //static const string vdelim("(){}[]./|"); - string name = l->name; if (name == "(") return name; if (name == "[") @@ -46,7 +44,7 @@ string MathDelimInset::latexName(latexkeys const * l) void MathDelimInset::write(std::ostream & os, bool fragile) const { - os << "\\left" << latexName(left_); + os << "\\left" << latexName(left_); cell(0).write(os, fragile); os << "\\right" << latexName(right_); } @@ -86,6 +84,6 @@ void MathDelimInset::draw(Painter & pain, int x, int y) const int const w = dw(); int const b = y - ascent_ - 2; xcell(0).draw(pain, x + w + 2, y); - mathed_draw_deco(pain, x + 1, b, w, height() + 4, left_->name); - mathed_draw_deco(pain, x + width() - w - 1, b, w, height() + 4, right_->name); + mathed_draw_deco(pain, x + 1, b, w, height() + 4, left_); + mathed_draw_deco(pain, x + width() - w - 1, b, w, height() + 4, right_); } diff --git a/src/mathed/math_deliminset.h b/src/mathed/math_deliminset.h index 81b9432d43..23cf45e376 100644 --- a/src/mathed/math_deliminset.h +++ b/src/mathed/math_deliminset.h @@ -13,12 +13,10 @@ \author Alejandro Aguilar Sierra */ -class latexkeys; - class MathDelimInset : public MathNestInset { public: /// - MathDelimInset(latexkeys const *, latexkeys const *); + MathDelimInset(string const &, string const &); /// MathInset * clone() const; /// @@ -28,13 +26,13 @@ public: /// void metrics(MathStyles st) const; private: - /// - static string latexName(latexkeys const *); /// int dw() const; /// - latexkeys const * left_; + string left_; + /// + string right_; /// - latexkeys const * right_; + static string latexName(string const & name); }; #endif diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 185120b5d7..10f2c46b1a 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -218,8 +218,6 @@ private: void error(string const & msg); /// void parse_lines(MathGridInset * p, bool numbered, bool outmost); - /// - latexkeys const * read_delim(); private: /// @@ -607,14 +605,6 @@ MathMatrixInset * Parser::parse_normal() } -latexkeys const * Parser::read_delim() -{ - Token const & t = getToken(); - latexkeys const * l = in_word_set(t.asString()); - return l ? l : in_word_set("."); -} - - void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) { MathTextCodes yyvarcode = LM_TC_MIN; @@ -758,10 +748,10 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) } else if (t.cs() == "left") { - latexkeys const * l = read_delim(); + string l = getToken().asString(); MathArray ar; parse_into(ar, FLAG_RIGHT); - latexkeys const * r = read_delim(); + string r = getToken().asString(); MathDelimInset * dl = new MathDelimInset(l, r); dl->cell(0) = ar; array.push_back(dl); diff --git a/src/mathed/support.C b/src/mathed/support.C index db4ab147ec..e568e925ca 100644 --- a/src/mathed/support.C +++ b/src/mathed/support.C @@ -485,6 +485,7 @@ named_deco_struct deco_table[] = { {"/", slash, 0 }, {"Vert", Vert, 0 }, {"'", slash, 1 }, + {"backslash", slash, 1 }, {"langle", angle, 0 }, {"lceil", corner, 0 }, {"lfloor", corner, 1 }, @@ -644,7 +645,7 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, deco_struct const * mds = search_deco(name); if (!mds) { lyxerr << "Deco was not found. Programming error?\n"; - lyxerr << "name: '" << name << "\n"; + lyxerr << "name: '" << name << "'\n"; return; } -- 2.39.2