]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formulabase.C
more trivial tweaks to mathed bindings
[lyx.git] / src / mathed / formulabase.C
index 6914826429068c0df4a481be0004fe19ac02f4f1..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;
        }
@@ -415,12 +417,6 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
 
        case LFUN_MATH_MUTATE:
        case LFUN_MATH_DISPLAY:
-       case LFUN_MATH_HALIGN:
-       case LFUN_MATH_VALIGN:
-       case LFUN_MATH_ROW_INSERT:
-       case LFUN_MATH_ROW_DELETE:
-       case LFUN_MATH_COLUMN_INSERT:
-       case LFUN_MATH_COLUMN_DELETE:
        case LFUN_MATH_NUMBER:
        case LFUN_MATH_NONUMBER:
        case LFUN_TABINSERT:
@@ -428,12 +424,14 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
        case LFUN_DELETE_LINE_FORWARD:
        case LFUN_INSERT_LABEL:
        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:
@@ -445,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:
@@ -467,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;
@@ -532,15 +543,6 @@ Inset::RESULT InsetFormulaBase::localDispatch(FuncRequest const & cmd)
                break;
        }
 
-/*
-       case LFUN_PASTESELECTION: {
-               string const clip = bv->getClipboard();
-               if (!clip.empty())
-                       mathed_parse_normal(par_, clip);
-               break;
-       }
-*/
-
        case LFUN_PASTE:
                if (was_macro)
                        mathcursor->macroModeClose();
@@ -598,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");
@@ -617,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()) {