From e71bea78ca687336f17f1070493414fcc8b27241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 5 Dec 2001 18:00:36 +0000 Subject: [PATCH] brute force does not need much code... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3154 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_cursor.C | 57 ----------------------------------- src/mathed/math_cursor.h | 2 -- src/mathed/math_inset.C | 7 ----- src/mathed/math_inset.h | 3 -- src/mathed/math_nestinset.C | 21 ------------- src/mathed/math_nestinset.h | 2 -- src/mathed/math_scriptinset.C | 9 ------ src/mathed/math_scriptinset.h | 2 -- src/mathed/math_xdata.C | 10 ------ src/mathed/math_xdata.h | 2 -- 10 files changed, 115 deletions(-) diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 6c11fca0bc..876ac4a592 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -235,22 +235,6 @@ bool MathCursor::openable(MathAtom const & t, bool sel) const } -bool MathCursor::positionable(MathAtom const & t, int x, int y) const -{ - if (selection_) { - // we can't move into anything new during selection - if (Cursor_.size() >= Anchor_.size()) - return false; - if (t.nucleus() != Anchor_[Cursor_.size()].par_) - return false; - } - - //lyxerr << " positionable: 1 " << t->nargs() << "\n"; - //lyxerr << " positionable: 2 " << t->covers(x, y) << "\n"; - return t->nargs() && t->covers(x, y); -} - - bool MathCursor::posLeft() { if (pos() == 0) @@ -332,44 +316,6 @@ void MathCursor::last() } -#if 0 -void MathCursor::setPos(int x, int y) -{ - //dump("setPos 1"); - //lyxerr << "MathCursor::setPos x: " << x << " y: " << y << "\n"; - - macroModeClose(); - lastcode_ = LM_TC_VAR; - first(); - - cursor().par_ = &formula_->par(); - - while (1) { - idx() = 0; - cursor().pos_ = 0; - //lyxerr << "found idx: " << idx() << " cursor: " << pos() << "\n"; - int distmin = 1 << 30; // large enough - for (unsigned int i = 0; i < par()->nargs(); ++i) { - MathXArray const & ar = par()->xcell(i); - int d = ar.dist(x, y); - if (d <= distmin) { - distmin = d; - idx() = i; - pos() = ar.x2pos(x - ar.xo()); - } - } - //lyxerr << "found idx: " << idx() << " cursor: " << pos() << "\n"; - if (hasNextAtom() && positionable(nextAtom(), x, y)) - pushLeft(nextAtom()); - else if (hasPrevAtom() && positionable(prevAtom(), x, y)) - pushRight(prevAtom()); - else - break; - } - //dump("setPos 2"); -} - -#else void MathCursor::setPos(int x, int y) { @@ -406,9 +352,6 @@ void MathCursor::setPos(int x, int y) dump("setPos 2"); } -#endif - - void MathCursor::home(bool sel) diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 5053356309..50f5e95d29 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -301,8 +301,6 @@ private: void insert(char, MathTextCodes t); /// can we enter the inset? bool openable(MathAtom const &, bool selection) const; - /// can the setPos routine enter that inset? - bool positionable(MathAtom const &, int x, int y) const; /// write access to cursor cell position pos_type & pos(); /// write access to cursor cell index diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index ee98f69901..f13b3124b8 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -195,13 +195,6 @@ void MathInset::dump() const } -bool MathInset::covers(int, int) const -{ - lyxerr << "MathInset::covers() called directly!\n"; - return false; -} - - void MathInset::validate(LaTeXFeatures &) const {} diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 3acdd53a3b..1d56323a7d 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -188,9 +188,6 @@ public: /// delete a given row virtual void delCol(col_type) {} - /// does this inset cover the pixel at (x,y)? - virtual bool covers(int x, int y) const; - /// identifies certain types of insets virtual MathArrayInset * asArrayInset() { return 0; } virtual MathBoxInset * asBoxInset() { return 0; } diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index f7264827e0..6113621b43 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -153,27 +153,6 @@ void MathNestInset::validate(LaTeXFeatures & features) const } -bool MathNestInset::covers(int x, int y) const -{ - if (!nargs()) - return false; - int x0 = xcell(0).xo(); - int y0 = xcell(0).yo() - xcell(0).ascent(); - int x1 = xcell(0).xo() + xcell(0).width(); - int y1 = xcell(0).yo() + xcell(0).descent(); - for (idx_type i = 1; i < nargs(); ++i) { - x0 = std::min(x0, xcell(i).xo()); - y0 = std::min(y0, xcell(i).yo() - xcell(i).ascent()); - x1 = std::max(x1, xcell(i).xo() + xcell(i).width()); - y1 = std::max(y1, xcell(i).yo() + xcell(i).descent()); - } - //lyxerr << "xO: " << x0 << " x1: " << x1 << " " - // << "yO: " << y0 << " y1: " << y1 << " " - // << "x: " << x << " y: " << y << '\n'; - return x >= x0 && x <= x1 && y >= y0 && y <= y1; -} - - bool MathNestInset::match(MathInset * p) const { if (nargs() != p->nargs()) diff --git a/src/mathed/math_nestinset.h b/src/mathed/math_nestinset.h index 755198a847..f194e1662f 100644 --- a/src/mathed/math_nestinset.h +++ b/src/mathed/math_nestinset.h @@ -65,8 +65,6 @@ public: bool isActive() const { return nargs() > 0; } /// request "external features" void validate(LaTeXFeatures & features) const; - /// do we cover the point (x,y)? - bool covers(int x, int y) const; /// match in all cells bool match(MathInset *) const; diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index ac4b098e78..f05ed54b6d 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -74,15 +74,6 @@ void MathScriptInset::ensure(bool up) } -bool MathScriptInset::covers(int x, int y) const -{ - for (idx_type i = 0; i < 2; ++i) - if (has(i) && xcell(i).covers(x, y)) - return true; - return false; -} - - int MathScriptInset::dy0(MathInset const * nuc) const { int nd = ndes(nuc); diff --git a/src/mathed/math_scriptinset.h b/src/mathed/math_scriptinset.h index f11c600250..669e0e9bfd 100644 --- a/src/mathed/math_scriptinset.h +++ b/src/mathed/math_scriptinset.h @@ -82,8 +82,6 @@ public: void removeEmptyScripts(); /// make sure a script is accessible void ensure(bool up); - /// only true if we are _in_ sub- or superscript, not in the convex hull - bool covers(int x, int y) const; // call these methods ...2 to make compaq cxx in anal mode happy... /// suppresses empty braces if necessary diff --git a/src/mathed/math_xdata.C b/src/mathed/math_xdata.C index 37786bbc74..28f5d5c32e 100644 --- a/src/mathed/math_xdata.C +++ b/src/mathed/math_xdata.C @@ -143,16 +143,6 @@ int MathXArray::dist(int x, int y) const } -bool MathXArray::covers(int x, int y) const -{ - int const x0 = xo_; - int const y0 = yo_ - ascent_; - int const x1 = xo_ + width_; - int const y1 = yo_ + descent_; - return x >= x0 && x <= x1 && y >= y0 && y <= y1; -} - - void MathXArray::boundingBox(int & x1, int & x2, int & y1, int & y2) { x1 = xo_; diff --git a/src/mathed/math_xdata.h b/src/mathed/math_xdata.h index dd059aaefb..e4005c6316 100644 --- a/src/mathed/math_xdata.h +++ b/src/mathed/math_xdata.h @@ -53,8 +53,6 @@ public: int height() const { return ascent_ + descent_; } /// width of this cell int width() const { return width_; } - /// do we cover point(x, y)? - bool covers(int x, int y) const; /// bounding box of this cell void boundingBox(int & xlow, int & xhigh, int & ylow, int & yhigh); /// find best position to do things