mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 11:08:41 +00:00
brute force does not need much code...
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3154 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ebe6d25126
commit
e71bea78ca
@ -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()
|
bool MathCursor::posLeft()
|
||||||
{
|
{
|
||||||
if (pos() == 0)
|
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)
|
void MathCursor::setPos(int x, int y)
|
||||||
{
|
{
|
||||||
@ -406,9 +352,6 @@ void MathCursor::setPos(int x, int y)
|
|||||||
dump("setPos 2");
|
dump("setPos 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MathCursor::home(bool sel)
|
void MathCursor::home(bool sel)
|
||||||
|
@ -301,8 +301,6 @@ private:
|
|||||||
void insert(char, MathTextCodes t);
|
void insert(char, MathTextCodes t);
|
||||||
/// can we enter the inset?
|
/// can we enter the inset?
|
||||||
bool openable(MathAtom const &, bool selection) const;
|
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
|
/// write access to cursor cell position
|
||||||
pos_type & pos();
|
pos_type & pos();
|
||||||
/// write access to cursor cell index
|
/// write access to cursor cell index
|
||||||
|
@ -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
|
void MathInset::validate(LaTeXFeatures &) const
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -188,9 +188,6 @@ public:
|
|||||||
/// delete a given row
|
/// delete a given row
|
||||||
virtual void delCol(col_type) {}
|
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
|
/// identifies certain types of insets
|
||||||
virtual MathArrayInset * asArrayInset() { return 0; }
|
virtual MathArrayInset * asArrayInset() { return 0; }
|
||||||
virtual MathBoxInset * asBoxInset() { return 0; }
|
virtual MathBoxInset * asBoxInset() { return 0; }
|
||||||
|
@ -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
|
bool MathNestInset::match(MathInset * p) const
|
||||||
{
|
{
|
||||||
if (nargs() != p->nargs())
|
if (nargs() != p->nargs())
|
||||||
|
@ -65,8 +65,6 @@ public:
|
|||||||
bool isActive() const { return nargs() > 0; }
|
bool isActive() const { return nargs() > 0; }
|
||||||
/// request "external features"
|
/// request "external features"
|
||||||
void validate(LaTeXFeatures & features) const;
|
void validate(LaTeXFeatures & features) const;
|
||||||
/// do we cover the point (x,y)?
|
|
||||||
bool covers(int x, int y) const;
|
|
||||||
|
|
||||||
/// match in all cells
|
/// match in all cells
|
||||||
bool match(MathInset *) const;
|
bool match(MathInset *) const;
|
||||||
|
@ -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 MathScriptInset::dy0(MathInset const * nuc) const
|
||||||
{
|
{
|
||||||
int nd = ndes(nuc);
|
int nd = ndes(nuc);
|
||||||
|
@ -82,8 +82,6 @@ public:
|
|||||||
void removeEmptyScripts();
|
void removeEmptyScripts();
|
||||||
/// make sure a script is accessible
|
/// make sure a script is accessible
|
||||||
void ensure(bool up);
|
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...
|
// call these methods ...2 to make compaq cxx in anal mode happy...
|
||||||
/// suppresses empty braces if necessary
|
/// suppresses empty braces if necessary
|
||||||
|
@ -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)
|
void MathXArray::boundingBox(int & x1, int & x2, int & y1, int & y2)
|
||||||
{
|
{
|
||||||
x1 = xo_;
|
x1 = xo_;
|
||||||
|
@ -53,8 +53,6 @@ public:
|
|||||||
int height() const { return ascent_ + descent_; }
|
int height() const { return ascent_ + descent_; }
|
||||||
/// width of this cell
|
/// width of this cell
|
||||||
int width() const { return width_; }
|
int width() const { return width_; }
|
||||||
/// do we cover point(x, y)?
|
|
||||||
bool covers(int x, int y) const;
|
|
||||||
/// bounding box of this cell
|
/// bounding box of this cell
|
||||||
void boundingBox(int & xlow, int & xhigh, int & ylow, int & yhigh);
|
void boundingBox(int & xlow, int & xhigh, int & ylow, int & yhigh);
|
||||||
/// find best position to do things
|
/// find best position to do things
|
||||||
|
Loading…
Reference in New Issue
Block a user