centralize the insetUpdate() a bit

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6540 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-03-19 15:47:29 +00:00
parent 893114ea1a
commit b95f08ad8f

View File

@ -125,17 +125,11 @@ void InsetFormulaBase::handleFont
// this whole function is a hack and won't work for incremental font // this whole function is a hack and won't work for incremental font
// changes... // changes...
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
if (mathcursor->par()->name() == font) { if (mathcursor->par()->name() == font)
mathcursor->handleFont(font); mathcursor->handleFont(font);
bv->updateInset(this); else {
} else {
bool sel = mathcursor->selection();
if (sel)
bv->updateInset(this);
mathcursor->handleNest(createMathInset(font)); mathcursor->handleNest(createMathInset(font));
mathcursor->insert(arg); mathcursor->insert(arg);
if (!sel)
bv->updateInset(this);
} }
} }
@ -466,7 +460,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_MATH_LIMITS: case LFUN_MATH_LIMITS:
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->dispatch(cmd); mathcursor->dispatch(cmd);
bv->updateInset(this);
break; break;
case LFUN_RIGHTSEL: case LFUN_RIGHTSEL:
@ -475,7 +468,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
result = mathcursor->right(sel) ? DISPATCHED : FINISHED_RIGHT; result = mathcursor->right(sel) ? DISPATCHED : FINISHED_RIGHT;
//lyxerr << "calling scroll 20\n"; //lyxerr << "calling scroll 20\n";
//scroll(bv, 20); //scroll(bv, 20);
bv->updateInset(this);
// write something to the minibuffer // write something to the minibuffer
//bv->owner()->message(mathcursor->info()); //bv->owner()->message(mathcursor->info());
break; break;
@ -484,27 +476,23 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
sel = true; // fall through sel = true; // fall through
case LFUN_LEFT: case LFUN_LEFT:
result = mathcursor->left(sel) ? DISPATCHED : FINISHED; result = mathcursor->left(sel) ? DISPATCHED : FINISHED;
bv->updateInset(this);
break; break;
case LFUN_UPSEL: case LFUN_UPSEL:
sel = true; // fall through sel = true; // fall through
case LFUN_UP: case LFUN_UP:
result = mathcursor->up(sel) ? DISPATCHED : FINISHED_UP; result = mathcursor->up(sel) ? DISPATCHED : FINISHED_UP;
bv->updateInset(this);
break; break;
case LFUN_DOWNSEL: case LFUN_DOWNSEL:
sel = true; // fall through sel = true; // fall through
case LFUN_DOWN: case LFUN_DOWN:
result = mathcursor->down(sel) ? DISPATCHED : FINISHED_DOWN; result = mathcursor->down(sel) ? DISPATCHED : FINISHED_DOWN;
bv->updateInset(this);
break; break;
case LFUN_WORDSEL: case LFUN_WORDSEL:
mathcursor->home(false); mathcursor->home(false);
mathcursor->end(true); mathcursor->end(true);
bv->updateInset(this);
break; break;
case LFUN_UP_PARAGRAPHSEL: case LFUN_UP_PARAGRAPHSEL:
@ -512,7 +500,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_DOWN_PARAGRAPHSEL: case LFUN_DOWN_PARAGRAPHSEL:
case LFUN_DOWN_PARAGRAPH: case LFUN_DOWN_PARAGRAPH:
result = FINISHED; result = FINISHED;
bv->updateInset(this);
break; break;
case LFUN_HOMESEL: case LFUN_HOMESEL:
@ -521,7 +508,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_HOME: case LFUN_HOME:
case LFUN_WORDLEFT: case LFUN_WORDLEFT:
result = mathcursor->home(sel) ? DISPATCHED : FINISHED; result = mathcursor->home(sel) ? DISPATCHED : FINISHED;
bv->updateInset(this);
break; break;
case LFUN_ENDSEL: case LFUN_ENDSEL:
@ -530,7 +516,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_END: case LFUN_END:
case LFUN_WORDRIGHT: case LFUN_WORDRIGHT:
result = mathcursor->end(sel) ? DISPATCHED : FINISHED_RIGHT; result = mathcursor->end(sel) ? DISPATCHED : FINISHED_RIGHT;
bv->updateInset(this);
break; break;
case LFUN_PRIORSEL: case LFUN_PRIORSEL:
@ -538,7 +523,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_BEGINNINGBUFSEL: case LFUN_BEGINNINGBUFSEL:
case LFUN_BEGINNINGBUF: case LFUN_BEGINNINGBUF:
result = FINISHED; result = FINISHED;
bv->updateInset(this);
break; break;
case LFUN_NEXTSEL: case LFUN_NEXTSEL:
@ -546,41 +530,32 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_ENDBUFSEL: case LFUN_ENDBUFSEL:
case LFUN_ENDBUF: case LFUN_ENDBUF:
result = FINISHED_RIGHT; result = FINISHED_RIGHT;
bv->updateInset(this);
break; break;
case LFUN_TAB: case LFUN_TAB:
mathcursor->idxNext(); mathcursor->idxNext();
bv->updateInset(this);
break; break;
case LFUN_SHIFT_TAB: case LFUN_SHIFT_TAB:
mathcursor->idxPrev(); mathcursor->idxPrev();
bv->updateInset(this);
break; break;
case LFUN_DELETE_WORD_BACKWARD: case LFUN_DELETE_WORD_BACKWARD:
case LFUN_BACKSPACE: case LFUN_BACKSPACE:
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
if (mathcursor->backspace()) { if (!mathcursor->backspace()) {
result = DISPATCHED;
} else {
result = FINISHED; result = FINISHED;
remove_inset = true; remove_inset = true;
} }
bv->updateInset(this);
break; break;
case LFUN_DELETE_WORD_FORWARD: case LFUN_DELETE_WORD_FORWARD:
case LFUN_DELETE: case LFUN_DELETE:
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
if (mathcursor->erase()) { if (!mathcursor->erase()) {
result = DISPATCHED;
} else {
result = FINISHED; result = FINISHED;
remove_inset = true; remove_inset = true;
} }
bv->updateInset(this);
break; break;
// case LFUN_GETXY: // case LFUN_GETXY:
@ -594,7 +569,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
istringstream is(cmd.argument.c_str()); istringstream is(cmd.argument.c_str());
is >> x >> y; is >> x >> y;
mathcursor->setPos(x, y); mathcursor->setPos(x, y);
bv->updateInset(this);
break; break;
} }
@ -603,13 +577,11 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
mathcursor->macroModeClose(); mathcursor->macroModeClose();
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->selPaste(); mathcursor->selPaste();
bv->updateInset(this);
break; break;
case LFUN_CUT: case LFUN_CUT:
bv->lockedInsetStoreUndo(Undo::DELETE); bv->lockedInsetStoreUndo(Undo::DELETE);
mathcursor->selCut(); mathcursor->selCut();
bv->updateInset(this);
break; break;
case LFUN_COPY: case LFUN_COPY:
@ -625,7 +597,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
// deadkeys // deadkeys
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->script(true); mathcursor->script(true);
bv->updateInset(this);
} }
break; break;
@ -646,7 +617,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
break; break;
// Math fonts // Math fonts
//case LFUN_GREEK_TOGGLE: handleFont(bv, cmd.argument, "lyxgreek"); break;
case LFUN_BOLD: handleFont(bv, cmd.argument, "mathbf"); break; case LFUN_BOLD: handleFont(bv, cmd.argument, "mathbf"); break;
case LFUN_SANS: handleFont(bv, cmd.argument, "mathsf"); break; case LFUN_SANS: handleFont(bv, cmd.argument, "mathsf"); break;
case LFUN_EMPH: handleFont(bv, cmd.argument, "mathcal"); break; case LFUN_EMPH: handleFont(bv, cmd.argument, "mathcal"); break;
@ -658,19 +628,11 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_FREEFONT_APPLY: handleFont(bv, cmd.argument, "textrm"); break; case LFUN_FREEFONT_APPLY: handleFont(bv, cmd.argument, "textrm"); break;
case LFUN_DEFAULT: handleFont(bv, cmd.argument, "textnormal"); break; case LFUN_DEFAULT: handleFont(bv, cmd.argument, "textnormal"); break;
//case LFUN_GREEK:
// handleFont(bv, cmd.argument, "lyxgreek1");
// if (cmd.argument.size())
// mathcursor->insert(asArray(cmd.argument));
// break;
case LFUN_MATH_MODE: case LFUN_MATH_MODE:
if (mathcursor->currentMode() == MathInset::TEXT_MODE) { if (mathcursor->currentMode() == MathInset::TEXT_MODE)
mathcursor->niceInsert(MathAtom(new MathHullInset("simple"))); mathcursor->niceInsert(MathAtom(new MathHullInset("simple")));
bv->updateInset(this); else
} else {
handleFont(bv, cmd.argument, "textrm"); handleFont(bv, cmd.argument, "textrm");
}
//bv->owner()->message(_("math text mode toggled")); //bv->owner()->message(_("math text mode toggled"));
break; break;
@ -679,7 +641,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
if (!arg.empty()) { if (!arg.empty()) {
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->setSize(arg); mathcursor->setSize(arg);
bv->updateInset(this);
} }
#endif #endif
break; break;
@ -697,7 +658,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
v_align += 'c'; v_align += 'c';
mathcursor->niceInsert( mathcursor->niceInsert(
MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align))); MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
bv->updateInset(this);
break; break;
} }
@ -706,7 +666,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
{ {
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->script(cmd.action == LFUN_SUPERSCRIPT); mathcursor->script(cmd.action == LFUN_SUPERSCRIPT);
bv->updateInset(this);
break; break;
} }
@ -723,7 +682,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->handleNest(MathAtom(new MathDelimInset(ls, rs))); mathcursor->handleNest(MathAtom(new MathDelimInset(ls, rs)));
bv->updateInset(this);
break; break;
} }
@ -731,7 +689,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_MATH_SPACE: case LFUN_MATH_SPACE:
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->insert(MathAtom(new MathSpaceInset(","))); mathcursor->insert(MathAtom(new MathSpaceInset(",")));
bv->updateInset(this);
break; break;
case LFUN_UNDO: case LFUN_UNDO:
@ -747,7 +704,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
// interpret this as if a backslash was typed // interpret this as if a backslash was typed
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->interpret('\\'); mathcursor->interpret('\\');
bv->updateInset(this);
break; break;
case LFUN_BREAKPARAGRAPH: case LFUN_BREAKPARAGRAPH:
@ -762,7 +718,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_INSERT_MATH: case LFUN_INSERT_MATH:
bv->lockedInsetStoreUndo(Undo::EDIT); bv->lockedInsetStoreUndo(Undo::EDIT);
mathcursor->niceInsert(argument); mathcursor->niceInsert(argument);
bv->updateInset(this);
break; break;
case -1: case -1:
@ -773,7 +728,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
result = mathcursor->interpret(argument[0]) ? DISPATCHED : FINISHED_RIGHT; result = mathcursor->interpret(argument[0]) ? DISPATCHED : FINISHED_RIGHT;
else else
mathcursor->insert(asArray(argument)); mathcursor->insert(asArray(argument));
bv->updateInset(this);
} }
break; break;
@ -790,7 +744,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
case LFUN_INSET_TOGGLE: case LFUN_INSET_TOGGLE:
mathcursor->insetToggle(); mathcursor->insetToggle();
bv->updateInset(this);
break; break;
case LFUN_DIALOG_SHOW_NEW_INSET: { case LFUN_DIALOG_SHOW_NEW_INSET: {
@ -826,8 +779,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
result = UNDISPATCHED; result = UNDISPATCHED;
} }
} }
if (result == DISPATCHED)
bv->updateInset(this);
} }
break; break;
@ -835,6 +786,9 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
result = UNDISPATCHED; result = UNDISPATCHED;
} }
if (result == DISPATCHED)
bv->updateInset(this);
mathcursor->normalize(); mathcursor->normalize();
mathcursor->touch(); mathcursor->touch();
@ -1079,6 +1033,7 @@ void mathDispatch(FuncRequest const & cmd)
} }
break; break;
} }
default: default:
break; break;
} }