From 12c4c8233d32c49630f8ee1001c7e553072513bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 7 Aug 2001 13:23:16 +0000 Subject: [PATCH] better selection handling git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2440 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_cursor.C | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index fccacf90b2..d9727c99a9 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -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"; //dump(" Pos"); return; - //lyxerr << "\n\n\\n=================vvvvvvvvvvvvv======================= " - // << str << "\ntheSelection: " << theSelection; - //for (unsigned int i = 0; i < Cursor_.size(); ++i) - // lyxerr << Cursor_[i].par_ << "\n'" << Cursor_[i].cell() << "'\n"; + lyxerr << "\n\n\n=================vvvvvvvvvvvvv======================= " + << str << "\ntheSelection: " << selection_ + << " '" << theSelection.glue() << "'\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 << "\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); - ++cursor().pos_; + plainRight(); } @@ -428,7 +432,7 @@ void MathCursor::insert(MathInset * p) } array().insert(cursor().pos_, p); - ++cursor().pos_; + plainRight(); } @@ -778,8 +782,10 @@ void MathCursor::selCut() if (selection_) { theSelection.grab(*this); theSelection.erase(*this); + selClear(); + } else { + theSelection.clear(); } - selClear(); } @@ -803,10 +809,12 @@ void MathCursor::selPaste() void MathCursor::selHandle(bool sel) { - if (sel && !selection_) - selStart(); - if (!sel && selection_) - selClear(); + if (sel == selection_) + return; + + theSelection.clear(); + Anchor_ = Cursor_; + selection_ = sel; } @@ -816,6 +824,7 @@ void MathCursor::selStart() if (selection_) return; + theSelection.clear(); Anchor_ = Cursor_; selection_ = true; } @@ -823,6 +832,7 @@ void MathCursor::selStart() void MathCursor::selClear() { + seldump("selClear"); selection_ = false; } -- 2.39.2