From aea21e8cacad73e0d5df58637994b87b3eabc30e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Mon, 20 Aug 2001 13:45:02 +0000 Subject: [PATCH] re-enable spaces and hyphens in labels; small stuff; git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2559 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_cursor.C | 31 +++++++++++++++++++++++++------ src/mathed/math_cursor.h | 10 ++++++---- src/mathed/math_parser.C | 12 ++++++------ src/mathed/math_scriptinset.C | 7 +++++++ src/mathed/math_scriptinset.h | 2 +- 5 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 7cfaa77b20..78c45a2d82 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -210,12 +210,31 @@ bool MathCursor::isInside(MathInset const * p) const } -bool MathCursor::openable(MathInset * p, bool sel, bool useupdown) const +bool MathCursor::openable(MathInset * p, bool sel) const { if (!p) return false; - if (!(p->isActive() || (useupdown && p->isScriptInset()))) + if (!p->isActive()) + return false; + + if (sel) { + // we can't move into anything new during selection + if (Cursor_.size() == Anchor_.size()) + return false; + if (p != Anchor_[Cursor_.size()].par_) + return false; + } + return true; +} + + +bool MathCursor::positionable(MathInset * p, bool sel) const +{ + if (!p) + return false; + + if (!p->nargs()) return false; if (sel) { @@ -259,7 +278,7 @@ bool MathCursor::left(bool sel) lastcode_ = LM_TC_VAR; MathInset * p = prevInset(); - if (openable(p, sel, false)) { + if (openable(p, sel)) { pushRight(p); return true; } @@ -280,7 +299,7 @@ bool MathCursor::right(bool sel) lastcode_ = LM_TC_VAR; MathInset * p = nextInset(); - if (openable(p, sel, false)) { + if (openable(p, sel)) { pushLeft(p); return true; } @@ -338,9 +357,9 @@ void MathCursor::setPos(int x, int y) // << pos() << "\n"; MathInset * n = nextInset(); MathInset * p = prevInset(); - if (openable(n, selection_, true) && n->covers(x, y)) + if (positionable(n, selection_) && n->covers(x, y)) pushLeft(n); - else if (openable(p, selection_, true) && p->covers(x, y)) + else if (positionable(p, selection_) && p->covers(x, y)) pushRight(p); else break; diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 523ec48dc7..90519bec17 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -209,8 +209,6 @@ public: void getSelection(MathCursorPos &, MathCursorPos &) const; /// returns the normalized anchor of the selection MathCursorPos normalAnchor() const; - /// returns the normalized anchor of the selection - bool openable(MathInset *, bool selection, bool useupdown) const; /// path of positions the cursor had to go if it were leving each inset std::vector Cursor_; @@ -249,9 +247,13 @@ private: string macroName() const; /// void insert(char, MathTextCodes t = LM_TC_MIN); - /// + /// can we enter the inset? + bool openable(MathInset *, bool selection) const; + /// can the setPos routine enter that inset? + bool positionable(MathInset *, bool selection) const; + /// write access to cursor cell position int & pos(); - /// + /// write access to cursor cell index int & idx(); /// x-offset of current cell relative to par xo int cellXOffset() const; diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index cb3eba1f7d..2010e43ad8 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -812,13 +812,13 @@ void Parser::parse_into(MathArray & array, unsigned flags) } else if (t.cs() == "label") { - MathArray ar; - parse_into(ar, FLAG_ITEM); - ostringstream os; - ar.write(os, true); - curr_label_ = os.str(); + //MathArray ar; + //parse_into(ar, FLAG_ITEM); + //ostringstream os; + //ar.write(os, true); + //curr_label_ = os.str(); // was: - //curr_label_ = getArg('{', '}'); + curr_label_ = getArg('{', '}'); } else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") { diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index 158c2b91c4..8ee73f85a1 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -176,6 +176,12 @@ void MathScriptInset::idxDelete(int & idx, bool & popit, bool & deleteit) } +bool MathScriptInset::isActive() const +{ + return false; +} + + int MathScriptInset::limits() const { return limits_; @@ -274,3 +280,4 @@ void MathScriptInset::draw(Painter & pain, int x, int y) const if (down()) xcell(1).draw(pain, x + dx1_, y + dy1_); } + diff --git a/src/mathed/math_scriptinset.h b/src/mathed/math_scriptinset.h index 7a95bf6018..e0d7e23222 100644 --- a/src/mathed/math_scriptinset.h +++ b/src/mathed/math_scriptinset.h @@ -70,7 +70,7 @@ public: /// int limits() const; /// - bool isActive() const { return false; } + bool isActive() const; /// Identifies ScriptInsets bool isScriptInset() const { return true; } /// -- 2.39.2