better selection handling

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2440 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-08-07 13:23:16 +00:00
parent 089f4fca7d
commit 12c4c8233d

View File

@ -181,19 +181,23 @@ void MathCursor::dump(char const * what) const
} }
void MathCursor::seldump(char const *) const void MathCursor::seldump(char const * str) const
{ {
//lyxerr << "SEL: " << str << ": '" << theSelection << "'\n"; //lyxerr << "SEL: " << str << ": '" << theSelection << "'\n";
//dump(" Pos"); //dump(" Pos");
return; return;
//lyxerr << "\n\n\\n=================vvvvvvvvvvvvv======================= " lyxerr << "\n\n\n=================vvvvvvvvvvvvv======================= "
// << str << "\ntheSelection: " << theSelection; << str << "\ntheSelection: " << selection_
//for (unsigned int i = 0; i < Cursor_.size(); ++i) << " '" << theSelection.glue() << "'\n";
// lyxerr << Cursor_[i].par_ << "\n'" << Cursor_[i].cell() << "'\n"; for (unsigned int i = 0; i < Cursor_.size(); ++i)
lyxerr << Cursor_[i].par_ << "\n'" << Cursor_[i].cell() << "'\n";
lyxerr << "\n";
for (unsigned int i = 0; i < Anchor_.size(); ++i)
lyxerr << Anchor_[i].par_ << "\n'" << Anchor_[i].cell() << "'\n";
//lyxerr << "\ncursor.pos_: " << cursor().pos_; //lyxerr << "\ncursor.pos_: " << cursor().pos_;
//lyxerr << "\nanchor.pos_: " << anchor().pos_; //lyxerr << "\nanchor.pos_: " << anchor().pos_;
//lyxerr << "\n===================^^^^^^^^^^^^=====================\n\n\n"; lyxerr << "\n===================^^^^^^^^^^^^=====================\n\n\n";
} }
@ -412,7 +416,7 @@ void MathCursor::insert(char c, MathTextCodes t)
} }
array().insert(cursor().pos_, c, t); array().insert(cursor().pos_, c, t);
++cursor().pos_; plainRight();
} }
@ -428,7 +432,7 @@ void MathCursor::insert(MathInset * p)
} }
array().insert(cursor().pos_, p); array().insert(cursor().pos_, p);
++cursor().pos_; plainRight();
} }
@ -778,8 +782,10 @@ void MathCursor::selCut()
if (selection_) { if (selection_) {
theSelection.grab(*this); theSelection.grab(*this);
theSelection.erase(*this); theSelection.erase(*this);
selClear();
} else {
theSelection.clear();
} }
selClear();
} }
@ -803,10 +809,12 @@ void MathCursor::selPaste()
void MathCursor::selHandle(bool sel) void MathCursor::selHandle(bool sel)
{ {
if (sel && !selection_) if (sel == selection_)
selStart(); return;
if (!sel && selection_)
selClear(); theSelection.clear();
Anchor_ = Cursor_;
selection_ = sel;
} }
@ -816,6 +824,7 @@ void MathCursor::selStart()
if (selection_) if (selection_)
return; return;
theSelection.clear();
Anchor_ = Cursor_; Anchor_ = Cursor_;
selection_ = true; selection_ = true;
} }
@ -823,6 +832,7 @@ void MathCursor::selStart()
void MathCursor::selClear() void MathCursor::selClear()
{ {
seldump("selClear");
selection_ = false; selection_ = false;
} }