-// extern char *dispatch_result;
- MathedTextCodes varcode = LM_TC_MIN;
- bool was_macro = mathcursor->InMacroMode();
- bool sel= false;
- bool space_on = false;
- bool was_selection = mathcursor->Selection();
- bool result = true;
- static MathSpaceInset * sp= 0;
-
- HideInsetCursor();
- if (mathcursor->Selection() && (fast_selection || mono_video))
- ToggleInsetSelection();
-
- if (mathcursor->getLastCode() == LM_TC_TEX) {
- varcode = LM_TC_TEX;
- }
- switch (action) {
-
- // --- Cursor Movements ---------------------------------------------
- case LFUN_RIGHTSEL: sel = true;
- case LFUN_RIGHT:
- {
- result = mathcursor->Right(sel);
- break;
- }
- case LFUN_LEFTSEL: sel = true;
- case LFUN_LEFT:
- {
- result = mathcursor->Left(sel);
- break;
- }
- case LFUN_UPSEL: sel = true;
- case LFUN_UP:
- result = mathcursor->Up(sel);
- break;
-
- case LFUN_DOWNSEL: sel = true;
- case LFUN_DOWN:
- result = mathcursor->Down(sel);
- break;
- case LFUN_HOME:
- mathcursor->Home();
- break;
- case LFUN_END:
- mathcursor->End();
- break;
- case LFUN_DELETE_LINE_FORWARD:
- //LockedInsetStoreUndo(Undo::INSERT);
- LockedInsetStoreUndo(Undo::DELETE);
- mathcursor->DelLine();
- UpdateLocal();
- break;
- case LFUN_BREAKLINE:
- LockedInsetStoreUndo(Undo::INSERT);
- mathcursor->Insert(' ', LM_TC_CR);
- par = mathcursor->GetPar();
- UpdateLocal();
- break;
- case LFUN_TAB:
- LockedInsetStoreUndo(Undo::INSERT);
- mathcursor->Insert(0, LM_TC_TAB);
- //UpdateInset(this);
- break;
- case LFUN_TABINSERT:
- LockedInsetStoreUndo(Undo::INSERT);
- mathcursor->Insert('T', LM_TC_TAB);
- UpdateLocal();
- break;
- case LFUN_BACKSPACE:
- if (!mathcursor->Left())
- break;
-
- if (!mathcursor->InMacroMode() && mathcursor->pullArg()) {
- UpdateInset(this);
- break;
- }
-
- case LFUN_DELETE:
- //LockedInsetStoreUndo(Undo::INSERT);
- LockedInsetStoreUndo(Undo::DELETE);
- mathcursor->Delete();
- UpdateInset(this);
- break;
-// case LFUN_GETXY:
-// sprintf(dispatch_buffer, "%d %d",);
-// dispatch_result = dispatch_buffer;
-// break;
- case LFUN_SETXY:
- {
- int x, y, x1, y1;
- sscanf(arg, "%d %d", &x, &y);
- par->GetXY(x1, y1);
- mathcursor->SetPos(x1+x, y1+y);
- }
- break;
-
- /* cursor selection ---------------------------- */
-
- case LFUN_PASTE:
- if (was_macro)
- mathcursor->MacroModeClose();
- LockedInsetStoreUndo(Undo::INSERT);
- mathcursor->SelPaste(); UpdateLocal(); break;
- case LFUN_CUT:
- LockedInsetStoreUndo(Undo::DELETE);
- mathcursor->SelCut(); UpdateLocal(); break;
- case LFUN_COPY: mathcursor->SelCopy(); break;
- case LFUN_HOMESEL:
- case LFUN_ENDSEL:
- case LFUN_WORDRIGHTSEL:
- case LFUN_WORDLEFTSEL:
- break;
-
- // --- accented characters ------------------------------
-
- case LFUN_UMLAUT: mathcursor->setAccent(LM_ddot); break;
- case LFUN_CIRCUMFLEX: mathcursor->setAccent(LM_hat); break;
- case LFUN_GRAVE: mathcursor->setAccent(LM_grave); break;
- case LFUN_ACUTE: mathcursor->setAccent(LM_acute); break;
- case LFUN_TILDE: mathcursor->setAccent(LM_tilde); break;
- case LFUN_MACRON: mathcursor->setAccent(LM_bar); break;
- case LFUN_DOT: mathcursor->setAccent(LM_dot); break;
- case LFUN_CARON: mathcursor->setAccent(LM_check); break;
- case LFUN_BREVE: mathcursor->setAccent(LM_breve); break;
- case LFUN_VECTOR: mathcursor->setAccent(LM_vec); break;
-
- // Greek mode
- case LFUN_GREEK:
- {
- if (!greek_kb_flag) {
- greek_kb_flag = 1;
- minibuffer->Set(_("Math greek mode on"));
- } else
- greek_kb_flag = 0;
- break;
- }
-
- // Greek keyboard
- case LFUN_GREEK_TOGGLE:
- {
- greek_kb_flag = (greek_kb_flag) ? 0 : 2;
- if (greek_kb_flag)
- minibuffer->Set(_("Math greek keyboard on"));
- else
- minibuffer->Set(_("Math greek keyboard off"));
- break;
- }
-
- // Math fonts
- case LFUN_BOLD: mathcursor->setLastCode(LM_TC_BF); break;
- case LFUN_SANS: mathcursor->setLastCode( LM_TC_SF); break;
- case LFUN_EMPH: mathcursor->setLastCode(LM_TC_CAL); break;
- case LFUN_ROMAN: mathcursor->setLastCode(LM_TC_RM); break;
- case LFUN_CODE: mathcursor->setLastCode(LM_TC_TT); break;
- case LFUN_DEFAULT: mathcursor->setLastCode(LM_TC_VAR ) ; break;
- case LFUN_TEX:
- {
-// varcode = LM_TC_TEX;
- mathcursor->setLastCode(LM_TC_TEX);
- minibuffer->Set(_("TeX mode"));
- break;
- }
-
- case LFUN_MATH_NUMBER:
- {
- LockedInsetStoreUndo(Undo::INSERT);
- if (disp_flag) {
- short type = par->GetType();
- bool oldf = (type == LM_OT_PARN || type == LM_OT_MPARN);
- if (oldf) {
- type--;
- if (!label.empty()) {
- label.clear();
- }
- minibuffer->Set(_("No number"));
- } else {
- type++;
- minibuffer->Set(_("Number"));
- }
- par->SetType(type);
- UpdateLocal();
- }
- break;
- }
-
- case LFUN_MATH_NONUMBER:
- {
- if (par->GetType() == LM_OT_MPARN) {
-// MathMatrixInset *mt = (MathMatrixInset*)par;
- //BUG
-// mt->SetNumbered(!mt->IsNumbered());
-
- mathcursor->setNumbered();
- UpdateLocal();
+ // extern char *dispatch_result;
+ MathedTextCodes varcode = LM_TC_MIN;
+ bool was_macro = mathcursor->InMacroMode();
+ bool sel = false;
+ bool space_on = false;
+ bool was_selection = mathcursor->Selection();
+ RESULT result = DISPATCHED;
+ static MathSpaceInset * sp= 0;
+
+ HideInsetCursor(bv);
+
+ if (mathcursor->getLastCode() == LM_TC_TEX) {
+ varcode = LM_TC_TEX;
+ }
+
+ switch (action) {
+ // --- Cursor Movements ---------------------------------------------
+ case LFUN_RIGHTSEL:
+ sel = true; // fall through...
+
+ case LFUN_RIGHT:
+ result = DISPATCH_RESULT(mathcursor->Right(sel));
+ if (!sel && (result == DISPATCHED))
+ result = DISPATCHED_NOUPDATE;
+ break;
+
+
+ case LFUN_LEFTSEL:
+ sel = true; // fall through
+
+ case LFUN_LEFT:
+ result = DISPATCH_RESULT(mathcursor->Left(sel));
+ if (!sel && (result == DISPATCHED))
+ result = DISPATCHED_NOUPDATE;
+ break;
+
+
+ case LFUN_UPSEL:
+ sel = true;
+
+ case LFUN_UP:
+ result = DISPATCH_RESULT(mathcursor->Up(sel));
+ if (!sel && (result == DISPATCHED))
+ result = DISPATCHED_NOUPDATE;
+ break;
+
+
+ case LFUN_DOWNSEL:
+ sel = true;
+
+ case LFUN_DOWN:
+ result = DISPATCH_RESULT(mathcursor->Down(sel));
+ if (!sel && (result == DISPATCHED))
+ result = DISPATCHED_NOUPDATE;
+ break;
+
+
+ case LFUN_HOME:
+ mathcursor->Home();
+ result = DISPATCHED_NOUPDATE;
+ break;
+
+ case LFUN_END:
+ mathcursor->End();
+ result = DISPATCHED_NOUPDATE;
+ break;
+
+ case LFUN_DELETE_LINE_FORWARD:
+ bv->lockedInsetStoreUndo(Undo::DELETE);
+ mathcursor->DelLine();
+ UpdateLocal(bv);
+ break;
+
+ case LFUN_BREAKLINE:
+ {
+ bv->lockedInsetStoreUndo(Undo::INSERT);
+ byte c = arg.empty() ? '1' : arg[0];
+ mathcursor->Insert(c, LM_TC_CR);
+ if (!label.empty()) {
+ mathcursor->setLabel(label);
+ label.erase();
+ }
+ par = mathcursor->GetPar();
+ UpdateLocal(bv);