X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_nestinset.C;h=79d058907e3ce0f105bca9010f9d95b3ddebe3d4;hb=183239b7def8ca0e51432f2d88891d4b9f055953;hp=0f946e57246965526fe7197ada37b5181effeaf0;hpb=48aa5d66cf668932324ebd4d15656ce33a013d7d;p=lyx.git diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index 0f946e5724..79d058907e 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -196,8 +196,11 @@ void MathNestInset::draw(PainterInfo & pi, int x, int y) const } -void MathNestInset::drawSelection(PainterInfo & pi, int, int) const +void MathNestInset::drawSelection(PainterInfo & pi, int x, int y) const { + // FIXME: hack to get position cache warm + draw(pi, x, y); + // this should use the x/y values given, not the cached values LCursor & cur = pi.base.bv->cursor(); if (!cur.selection()) @@ -377,7 +380,7 @@ void MathNestInset::handleFont2(LCursor & cur, string const & arg) } -void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd) +void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd) { //lyxerr << "MathNestInset: request: " << cmd << std::endl; //CursorSlice sl = cur.current(); @@ -389,7 +392,7 @@ void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd) cur.message(_("Paste")); replaceSelection(cur); size_t n = 0; - istringstream is(cmd.argument.c_str()); + istringstream is(cmd.argument); is >> n; pasteSelection(cur, n); cur.clearSelection(); // bug 393 @@ -609,7 +612,7 @@ void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd) lyxerr << "LFUN_SETXY broken!" << endl; int x = 0; int y = 0; - istringstream is(cmd.argument.c_str()); + istringstream is(cmd.argument); is >> x >> y; cur.setScreenPos(x, y); break; @@ -681,6 +684,9 @@ void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd) case LFUN_MATH_MODE: #if 1 + // ignore math-mode on when already in math mode + if (currentMode() == InsetBase::MATH_MODE && cmd.argument == "on") + break; cur.macroModeClose(); selClearOrDel(cur); cur.plainInsert(MathAtom(new MathMBoxInset(cur.bv()))); @@ -788,7 +794,7 @@ void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest & cmd) } default: - MathDimInset::priv_dispatch(cur, cmd); + MathDimInset::doDispatch(cur, cmd); break; } } @@ -901,43 +907,12 @@ InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y) const } -void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & cmd) -{ - //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl; - - if (cmd.button() == mouse_button::button1) { - // try to dispatch to enclosed insets first - //cur.bv().stuffClipboard(cur.grabSelection()); - return; - } - - if (cmd.button() == mouse_button::button2) { - MathArray ar; - asArray(cur.bv().getClipboard(), ar); - cur.clearSelection(); - cur.setScreenPos(cmd.x, cmd.y); - cur.insert(ar); - cur.bv().update(); - return; - } - - if (cmd.button() == mouse_button::button3) { - // try to dispatch to enclosed insets first - cur.bv().owner()->getDialogs().show("mathpanel"); - return; - } - - cur.undispatched(); -} - - void MathNestInset::lfunMousePress(LCursor & cur, FuncRequest & cmd) { lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl; if (cmd.button() == mouse_button::button1) { first_x = cmd.x; first_y = cmd.y; - //cur.setScreenPos(cmd.x + xo_, cmd.y + yo_); lyxerr << "lfunMousePress: setting cursor to: " << cur << endl; cur.resetAnchor(); cur.bv().cursor() = cur; @@ -952,16 +927,46 @@ void MathNestInset::lfunMousePress(LCursor & cur, FuncRequest & cmd) void MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest & cmd) { // only select with button 1 - if (cmd.button() != mouse_button::button1) + if (cmd.button() == mouse_button::button1) { + LCursor & bvcur = cur.bv().cursor(); + if (abs(cmd.x - first_x) + abs(cmd.y - first_y) > 4 + && bvcur.anchor_.hasPart(cur)) { + first_x = cmd.x; + first_y = cmd.y; + + bvcur.setCursor(cur); + bvcur.selection() = true; + } + } +} + + +void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest & cmd) +{ + lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl; + + if (cmd.button() == mouse_button::button1) { + //cur.bv().stuffClipboard(cur.grabSelection()); return; + } - if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2) + if (cmd.button() == mouse_button::button2) { + MathArray ar; + asArray(cur.bv().getClipboard(), ar); + cur.clearSelection(); + cur.setScreenPos(cmd.x, cmd.y); + cur.insert(ar); + cur.bv().update(); return; + } - first_x = cmd.x; - first_y = cmd.y; + if (cmd.button() == mouse_button::button3) { + // try to dispatch to enclosed insets first + cur.bv().owner()->getDialogs().show("mathpanel"); + return; + } - cur.bv().cursor().setCursor(cur, true); + cur.undispatched(); }