]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formulabase.C
more trivial tweaks to mathed bindings
[lyx.git] / src / mathed / formulabase.C
index 1a767ee4a8996878293e2f22441b111289f76d44..c6ee02b92debbe8db20a7e66c3cd3f77a32b35ca 100644 (file)
@@ -173,9 +173,7 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int y, mouse_button::state)
        releaseMathCursor(bv);
        mathcursor = new MathCursor(this, true);
        metrics(bv);
-       mathcursor->setPos(x, y);
-       //lyxerr << "setting pos to " << x << "," << y << "\n";
-
+       mathcursor->setPos(x + xo_, y + yo_);
        // if that is removed, we won't get the magenta box when entering an
        // inset for the first time
        bv->updateInset(this, false);
@@ -218,7 +216,8 @@ void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
                return;
        }
        mathcursor->getPos(x, y);
-       //x -= xo_;
+       x = mathcursor->targetX();
+       x -= xo_;
        y -= yo_;
        //lyxerr << "getCursorPos: " << x << " " << y << "\n";
 }
@@ -240,9 +239,9 @@ void InsetFormulaBase::showInsetCursor(BufferView * bv, bool)
                return;
        fitInsetCursor(bv);
        int x, y, asc, des;
-       getCursorPos(bv, x, y);
+       mathcursor->getPos(x, y);
        math_font_max_dim(font_, asc, des);
-       bv->showLockedInsetCursor(x, y, asc, des);
+       bv->showLockedInsetCursor(x, y - yo_, asc, des);
        setCursorVisible(true);
        //lyxerr << "showInsetCursor: " << x << " " << y << "\n";
 }
@@ -392,6 +391,9 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
                        return lfunMouseMotion(cmd);
                case LFUN_MOUSE_RELEASE:
                        return lfunMouseRelease(cmd);
+               case LFUN_MOUSE_DOUBLE:
+                       //lyxerr << "Mouse double\n";
+                       return localDispatch(FuncRequest(LFUN_WORDSEL));
                default:
                        break;
        }
@@ -424,12 +426,12 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
        case LFUN_MATH_EXTERN:
        case LFUN_TABULAR_FEATURE:
        case LFUN_PASTESELECTION:
+       case LFUN_MATH_LIMITS:
                bv->lockedInsetStoreUndo(Undo::EDIT);
                mathcursor->dispatch(cmd);
                updateLocal(bv, true);
                break;
 
-       case LFUN_WORDRIGHTSEL:
        case LFUN_RIGHTSEL:
                sel = true; // fall through...
        case LFUN_RIGHT:
@@ -441,7 +443,6 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
                //bv->owner()->message(mathcursor->info());
                break;
 
-       case LFUN_WORDLEFTSEL:
        case LFUN_LEFTSEL:
                sel = true; // fall through
        case LFUN_LEFT:
@@ -463,28 +464,42 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
                updateLocal(bv, false);
                break;
 
+       case LFUN_WORDSEL:
+               mathcursor->home(false);
+               mathcursor->end(true);
+               updateLocal(bv, false);
+               break;
+
        case LFUN_HOMESEL:
+       case LFUN_WORDLEFTSEL:
                sel = true; // fall through
        case LFUN_HOME:
+       case LFUN_WORDLEFT:
                result = mathcursor->home(sel) ? DISPATCHED : FINISHED;
                updateLocal(bv, false);
                break;
 
        case LFUN_ENDSEL:
+       case LFUN_WORDRIGHTSEL:
                sel = true; // fall through
        case LFUN_END:
+       case LFUN_WORDRIGHT:
                result = mathcursor->end(sel) ? DISPATCHED : FINISHED_RIGHT;
                updateLocal(bv, false);
                break;
 
        case LFUN_PRIORSEL:
        case LFUN_PRIOR:
+       case LFUN_BEGINNINGBUFSEL:
+       case LFUN_BEGINNINGBUF:
                result = FINISHED_UP;
                updateLocal(bv, false);
                break;
 
        case LFUN_NEXTSEL:
        case LFUN_NEXT:
+       case LFUN_ENDBUFSEL:
+       case LFUN_ENDBUF:
                result = FINISHED_DOWN;
                updateLocal(bv, false);
                break;
@@ -585,8 +600,8 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
        case LFUN_FRAK:         handleFont(bv, cmd.argument, "mathfrak"); break;
        case LFUN_ITAL:         handleFont(bv, cmd.argument, "mathit"); break;
        case LFUN_NOUN:         handleFont(bv, cmd.argument, "mathbb"); break;
-       case LFUN_DEFAULT:      handleFont(bv, cmd.argument, "textnormal"); break;
        case LFUN_FREE:         handleFont(bv, cmd.argument, "textrm"); break;
+       case LFUN_DEFAULT:      handleFont(bv, cmd.argument, "textnormal"); break;
 
        case LFUN_GREEK:
                handleFont(bv, cmd.argument, "lyxgreek1");
@@ -604,12 +619,6 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
                //bv->owner()->message(_("math text mode toggled"));
                break;
 
-       case LFUN_MATH_LIMITS:
-               bv->lockedInsetStoreUndo(Undo::EDIT);
-               if (mathcursor->toggleLimits())
-                       updateLocal(bv, true);
-               break;
-
        case LFUN_MATH_SIZE:
 #if 0
                if (!arg.empty()) {