mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
waste cycles for simpler InsetText::localUpdate
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7497 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7f87533060
commit
b68574ab86
@ -386,12 +386,6 @@ void InsetText::drawFrame(Painter & pain, int x) const
|
||||
void InsetText::setUpdateStatus(int what) const
|
||||
{
|
||||
need_update |= what;
|
||||
// this to not draw a selection when we redraw all of it!
|
||||
if (need_update & CURSOR && !(need_update & SELECTION)) {
|
||||
if (text_.selection.set())
|
||||
need_update = FULL;
|
||||
text_.clearSelection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -405,9 +399,7 @@ void InsetText::updateLocal(BufferView * bv, bool mark_dirty)
|
||||
|
||||
text_.partialRebreak();
|
||||
setUpdateStatus(FULL);
|
||||
bool flag = mark_dirty ||
|
||||
(need_update != CURSOR && need_update != NONE) ||
|
||||
text_.selection.set();
|
||||
bool flag = mark_dirty || need_update != NONE || text_.selection.set();
|
||||
if (!text_.selection.set())
|
||||
text_.selection.cursor = text_.cursor;
|
||||
|
||||
@ -416,8 +408,6 @@ void InsetText::updateLocal(BufferView * bv, bool mark_dirty)
|
||||
if (flag)
|
||||
bv->updateInset(const_cast<InsetText *>(this));
|
||||
|
||||
if (need_update == CURSOR)
|
||||
need_update = NONE;
|
||||
bv->owner()->view_state_changed();
|
||||
bv->owner()->updateMenubar();
|
||||
bv->owner()->updateToolbar();
|
||||
@ -484,10 +474,7 @@ void InsetText::lockInset(BufferView * bv)
|
||||
font.setLanguage(bv->getParentLanguage(this));
|
||||
setFont(bv, font, false);
|
||||
}
|
||||
int code = CURSOR;
|
||||
if (drawFrame_ == LOCKED)
|
||||
code = CURSOR|DRAW_FRAME;
|
||||
setUpdateStatus(code);
|
||||
setUpdateStatus(FULL);
|
||||
}
|
||||
|
||||
|
||||
@ -591,7 +578,6 @@ bool InsetText::updateInsetInInset(BufferView * bv, InsetOld * inset)
|
||||
return true;
|
||||
|
||||
if (inset->owner() != this) {
|
||||
int ustat = CURSOR_PAR;
|
||||
bool found = false;
|
||||
UpdatableInset * tl_inset = the_locking_inset;
|
||||
if (tl_inset)
|
||||
@ -603,16 +589,15 @@ bool InsetText::updateInsetInInset(BufferView * bv, InsetOld * inset)
|
||||
if (!tl_inset->owner())
|
||||
return false;
|
||||
found = tl_inset->updateInsetInInset(bv, inset);
|
||||
ustat = FULL;
|
||||
} else {
|
||||
text_.updateInset(tl_inset);
|
||||
setUpdateStatus(ustat);
|
||||
setUpdateStatus(FULL);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
bool found = text_.updateInset(inset);
|
||||
if (found) {
|
||||
setUpdateStatus(CURSOR_PAR);
|
||||
setUpdateStatus(FULL);
|
||||
if (the_locking_inset &&
|
||||
cpar() == inset_par && cpos() == inset_pos)
|
||||
{
|
||||
@ -832,10 +817,6 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
setFont(bv, font, false);
|
||||
}
|
||||
|
||||
int code = CURSOR;
|
||||
if (drawFrame_ == LOCKED)
|
||||
code = CURSOR | DRAW_FRAME;
|
||||
|
||||
updateLocal(bv, false);
|
||||
// Tell the paragraph dialog that we've entered an insettext.
|
||||
bv->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
|
||||
@ -873,23 +854,26 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
result = the_locking_inset->localDispatch(cmd);
|
||||
if (result == DISPATCHED_NOUPDATE)
|
||||
return result;
|
||||
else if (result == DISPATCHED) {
|
||||
if (result == DISPATCHED) {
|
||||
updateLocal(bv, false);
|
||||
return result;
|
||||
} else if (result >= FINISHED) {
|
||||
}
|
||||
if (result >= FINISHED) {
|
||||
switch (result) {
|
||||
case FINISHED_RIGHT:
|
||||
moveRightIntern(bv, false, false);
|
||||
result = DISPATCHED;
|
||||
break;
|
||||
case FINISHED_UP:
|
||||
if ((result = moveUp(bv)) >= FINISHED) {
|
||||
result = moveUp(bv);
|
||||
if (result >= FINISHED) {
|
||||
updateLocal(bv, false);
|
||||
bv->unlockInset(this);
|
||||
}
|
||||
break;
|
||||
case FINISHED_DOWN:
|
||||
if ((result = moveDown(bv)) >= FINISHED) {
|
||||
result = moveDown(bv);
|
||||
if (result >= FINISHED) {
|
||||
updateLocal(bv, false);
|
||||
bv->unlockInset(this);
|
||||
}
|
||||
@ -905,14 +889,8 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
int updwhat = 0;
|
||||
int updflag = false;
|
||||
|
||||
// what type of update to do on a cursor movement
|
||||
int cursor_update = CURSOR;
|
||||
|
||||
if (text_.selection.set())
|
||||
cursor_update = SELECTION;
|
||||
bool updwhat = false;
|
||||
bool updflag = false;
|
||||
|
||||
switch (cmd.action) {
|
||||
|
||||
@ -945,7 +923,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
}
|
||||
}
|
||||
text_.selection.cursor = text_.cursor;
|
||||
updwhat = CURSOR | CURSOR_PAR;
|
||||
updwhat = true;
|
||||
updflag = true;
|
||||
result = DISPATCHED_NOUPDATE;
|
||||
break;
|
||||
@ -955,22 +933,22 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
case LFUN_RIGHT:
|
||||
result = moveRight(bv);
|
||||
finishUndo();
|
||||
updwhat = cursor_update;
|
||||
updwhat = true;
|
||||
break;
|
||||
case LFUN_LEFT:
|
||||
finishUndo();
|
||||
result = moveLeft(bv);
|
||||
updwhat = cursor_update;
|
||||
updwhat = true;
|
||||
break;
|
||||
case LFUN_DOWN:
|
||||
finishUndo();
|
||||
result = moveDown(bv);
|
||||
updwhat = cursor_update;
|
||||
updwhat = true;
|
||||
break;
|
||||
case LFUN_UP:
|
||||
finishUndo();
|
||||
result = moveUp(bv);
|
||||
updwhat = cursor_update;
|
||||
updwhat = true;
|
||||
break;
|
||||
|
||||
case LFUN_PRIOR:
|
||||
@ -981,7 +959,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
text_.clearSelection();
|
||||
result = DISPATCHED_NOUPDATE;
|
||||
}
|
||||
updwhat = cursor_update;
|
||||
updwhat = true;
|
||||
break;
|
||||
|
||||
case LFUN_NEXT:
|
||||
@ -992,7 +970,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
text_.clearSelection();
|
||||
result = DISPATCHED_NOUPDATE;
|
||||
}
|
||||
updwhat = cursor_update;
|
||||
updwhat = true;
|
||||
break;
|
||||
|
||||
case LFUN_BACKSPACE: {
|
||||
@ -1000,7 +978,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
text_.cutSelection(true, false);
|
||||
else
|
||||
text_.backspace();
|
||||
updwhat = CURSOR_PAR;
|
||||
updwhat = true;
|
||||
updflag = true;
|
||||
break;
|
||||
}
|
||||
@ -1011,14 +989,14 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
} else {
|
||||
text_.Delete();
|
||||
}
|
||||
updwhat = CURSOR_PAR;
|
||||
updwhat = true;
|
||||
updflag = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_CUT: {
|
||||
text_.cutSelection(true, true);
|
||||
updwhat = CURSOR_PAR;
|
||||
updwhat = true;
|
||||
updflag = true;
|
||||
break;
|
||||
}
|
||||
@ -1026,7 +1004,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
case LFUN_COPY:
|
||||
finishUndo();
|
||||
text_.copySelection();
|
||||
updwhat = CURSOR_PAR;
|
||||
updwhat = true;
|
||||
break;
|
||||
|
||||
case LFUN_PASTESELECTION:
|
||||
@ -1043,7 +1021,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
// bug 393
|
||||
text_.clearSelection();
|
||||
|
||||
updwhat = CURSOR_PAR;
|
||||
updwhat = true;
|
||||
updflag = true;
|
||||
break;
|
||||
}
|
||||
@ -1070,7 +1048,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
text_.pasteSelection(sel_index);
|
||||
// bug 393
|
||||
text_.clearSelection();
|
||||
updwhat = CURSOR_PAR;
|
||||
updwhat = true;
|
||||
updflag = true;
|
||||
break;
|
||||
}
|
||||
@ -1082,7 +1060,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
}
|
||||
replaceSelection(bv->getLyXText());
|
||||
text_.breakParagraph(paragraphs, 0);
|
||||
updwhat = CURSOR | FULL;
|
||||
updwhat = true;
|
||||
updflag = true;
|
||||
break;
|
||||
|
||||
@ -1093,7 +1071,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
}
|
||||
replaceSelection(bv->getLyXText());
|
||||
text_.breakParagraph(paragraphs, 1);
|
||||
updwhat = CURSOR | FULL;
|
||||
updwhat = true;
|
||||
updflag = true;
|
||||
break;
|
||||
|
||||
@ -1105,7 +1083,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
|
||||
replaceSelection(bv->getLyXText());
|
||||
text_.insertInset(new InsetNewline);
|
||||
updwhat = CURSOR | CURSOR_PAR;
|
||||
updwhat = true;
|
||||
updflag = true;
|
||||
break;
|
||||
}
|
||||
@ -1141,7 +1119,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
cur_layout = layout;
|
||||
text_.setLayout(layout);
|
||||
bv->owner()->setLayout(cpar()->layout()->name());
|
||||
updwhat = CURSOR_PAR;
|
||||
updwhat = true;
|
||||
updflag = true;
|
||||
}
|
||||
} else {
|
||||
@ -1191,7 +1169,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
}
|
||||
if (cur_spacing != new_spacing || cur_value != new_value) {
|
||||
pit->params().spacing(Spacing(new_spacing, new_value));
|
||||
updwhat = CURSOR_PAR;
|
||||
updwhat = true;
|
||||
updflag = true;
|
||||
}
|
||||
}
|
||||
@ -1208,7 +1186,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
// these two are really unhandled ...
|
||||
case LFUN_ENDBUF:
|
||||
case LFUN_BEGINNINGBUF:
|
||||
updwhat = cursor_update;
|
||||
updwhat = true;
|
||||
if (!bv->dispatch(cmd))
|
||||
result = UNDISPATCHED;
|
||||
break;
|
||||
@ -1221,7 +1199,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
case LFUN_ENDSEL:
|
||||
case LFUN_WORDLEFTSEL:
|
||||
case LFUN_WORDRIGHTSEL:
|
||||
updwhat = SELECTION;
|
||||
updwhat = true;
|
||||
|
||||
// fallthrough
|
||||
|
||||
@ -1231,7 +1209,7 @@ InsetOld::RESULT InsetText::localDispatch(FuncRequest const & cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
if (updwhat > 0)
|
||||
if (updwhat)
|
||||
updateLocal(bv, updflag);
|
||||
/// If the action has deleted all text in the inset, we need to change the
|
||||
// language to the language of the surronding text.
|
||||
|
@ -50,14 +50,6 @@ public:
|
||||
///
|
||||
NONE = 0,
|
||||
///
|
||||
CURSOR = 1,
|
||||
///
|
||||
DRAW_FRAME = 2,
|
||||
///
|
||||
SELECTION = 4,
|
||||
///
|
||||
CURSOR_PAR = 8,
|
||||
///
|
||||
FULL = 16,
|
||||
///
|
||||
INIT = 32
|
||||
|
Loading…
Reference in New Issue
Block a user