mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
some InsetText::priv_dispatch progress.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8028 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
be2db7308a
commit
05894b4862
@ -28,8 +28,10 @@ using std::endl;
|
||||
DispatchResult Cursor::dispatch(FuncRequest const & cmd)
|
||||
{
|
||||
for (int i = data_.size() - 1; i >= 0; --i) {
|
||||
lyxerr << "trying to dispatch to inset" << data_[i].inset_ << endl;
|
||||
DispatchResult res = data_[i].inset_->dispatch(cmd);
|
||||
CursorItem & citem = data_[i];
|
||||
|
||||
lyxerr << "trying to dispatch to inset" << citem.inset_ << endl;
|
||||
DispatchResult res = citem.inset_->dispatch(cmd);
|
||||
lyxerr << " result: " << res.val() << endl;
|
||||
|
||||
if (res.dispatched())
|
||||
|
@ -53,6 +53,9 @@ public:
|
||||
DispatchResult(bool dis, dispatch_result_t val)
|
||||
: dispatched_(dis), update_(false), val_(val) {}
|
||||
dispatch_result_t val() const { return val_; }
|
||||
void val(dispatch_result_t drt) {
|
||||
val_ = drt;
|
||||
}
|
||||
bool dispatched() const {
|
||||
return dispatched_;
|
||||
}
|
||||
|
@ -1,7 +1,13 @@
|
||||
2003-11-04 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* insettext.C (priv_dispatch): some DispatchResult type cleanup,
|
||||
don't handle LFUN_UNKNOWN_ACTION, don't call BufferView::dispatch
|
||||
from here. Be stricter on DispatchResult returned.
|
||||
|
||||
2003-11-03 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* Inset::dispatch's: adjust for new DispatchResult semantics.
|
||||
|
||||
|
||||
2003-11-03 Lars Gullik Bjønnes <larsbj@gullik.net>
|
||||
|
||||
* render_base.h: make clone return an auto_ptr
|
||||
|
@ -676,14 +676,16 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
|
||||
DispatchResult result = UpdatableInset::priv_dispatch(cmd, idx, pos);
|
||||
if (result.dispatched())
|
||||
return DispatchResult(true, true);
|
||||
return result;
|
||||
|
||||
result = DispatchResult(true, true);
|
||||
#if 0
|
||||
// This looks utterly strange. (Lgb)
|
||||
if (cmd.action == LFUN_UNKNOWN_ACTION && cmd.argument.empty())
|
||||
return DispatchResult(false, FINISHED);
|
||||
#endif
|
||||
|
||||
if (the_locking_inset) {
|
||||
result = the_locking_inset->dispatch(cmd);
|
||||
DispatchResult result = the_locking_inset->dispatch(cmd);
|
||||
|
||||
if (result.dispatched()) {
|
||||
if (result.update()) {
|
||||
@ -696,7 +698,8 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
switch (result.val()) {
|
||||
case FINISHED_RIGHT:
|
||||
moveRightIntern(bv, false, false);
|
||||
result = DispatchResult(true, true);
|
||||
result.dispatched(true);
|
||||
result.update(true);
|
||||
break;
|
||||
case FINISHED_UP:
|
||||
result = moveUp(bv);
|
||||
@ -713,7 +716,8 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = DispatchResult(true, true);
|
||||
result.dispatched(true);
|
||||
result.update(true);
|
||||
break;
|
||||
}
|
||||
the_locking_inset = 0;
|
||||
@ -722,10 +726,8 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
bv->owner()->clearMessage();
|
||||
return result;
|
||||
}
|
||||
bool updflag = false;
|
||||
|
||||
switch (cmd.action) {
|
||||
|
||||
// Normal chars
|
||||
case LFUN_SELFINSERT:
|
||||
if (bv->buffer()->isReadonly()) {
|
||||
@ -753,8 +755,8 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
TranslateAndInsert(cmd.argument[i], &text_);
|
||||
}
|
||||
text_.selection.cursor = text_.cursor;
|
||||
updflag = true;
|
||||
result = DispatchResult(true);
|
||||
result.dispatched(true);
|
||||
result.update(true);
|
||||
break;
|
||||
|
||||
// cursor movements that need special handling
|
||||
@ -778,21 +780,21 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
|
||||
case LFUN_PRIOR:
|
||||
if (crow() == text_.firstRow())
|
||||
result = DispatchResult(false, FINISHED_UP);
|
||||
result.val(FINISHED_UP);
|
||||
else {
|
||||
text_.cursorPrevious();
|
||||
text_.clearSelection();
|
||||
result = DispatchResult(true);
|
||||
result.dispatched(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_NEXT:
|
||||
if (crow() == text_.lastRow())
|
||||
result = DispatchResult(false, FINISHED_DOWN);
|
||||
result.val(FINISHED_DOWN);
|
||||
else {
|
||||
text_.cursorNext();
|
||||
text_.clearSelection();
|
||||
result = DispatchResult(true);
|
||||
result.dispatched(true);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -801,7 +803,8 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
text_.cutSelection(true, false);
|
||||
else
|
||||
text_.backspace();
|
||||
updflag = true;
|
||||
#warning should be also set dispatched here?
|
||||
result.update(true);
|
||||
break;
|
||||
|
||||
case LFUN_DELETE:
|
||||
@ -809,7 +812,8 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
text_.cutSelection(true, false);
|
||||
else
|
||||
text_.Delete();
|
||||
updflag = true;
|
||||
#warning should be also set dispatched here?
|
||||
result.update(true);
|
||||
break;
|
||||
|
||||
case LFUN_PASTE:
|
||||
@ -831,38 +835,45 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
text_.pasteSelection(sel_index);
|
||||
// bug 393
|
||||
text_.clearSelection();
|
||||
updflag = true;
|
||||
#warning should be also set dispatched here?
|
||||
result.update(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_BREAKPARAGRAPH:
|
||||
if (!autoBreakRows_) {
|
||||
result = DispatchResult(true, true);
|
||||
result.dispatched(true);
|
||||
result.update(true);
|
||||
} else {
|
||||
replaceSelection(bv->getLyXText());
|
||||
text_.breakParagraph(paragraphs, 0);
|
||||
updflag = true;
|
||||
#warning should be also set dispatched here?
|
||||
result.update(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
|
||||
if (!autoBreakRows_) {
|
||||
result = DispatchResult(true, true);
|
||||
result.dispatched(true);
|
||||
result.update(true);
|
||||
} else {
|
||||
replaceSelection(bv->getLyXText());
|
||||
text_.breakParagraph(paragraphs, 1);
|
||||
updflag = true;
|
||||
#warning should be also set dispatched here?
|
||||
result.update(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_BREAKLINE: {
|
||||
if (!autoBreakRows_) {
|
||||
result = DispatchResult(true, true);
|
||||
result.dispatched(true);
|
||||
result.update(true);
|
||||
} else {
|
||||
replaceSelection(bv->getLyXText());
|
||||
auto_ptr<InsetNewline> ins(new InsetNewline);
|
||||
text_.insertInset(ins.release());
|
||||
updflag = true;
|
||||
#warning should be also set dispatched here?
|
||||
result.update(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -897,7 +908,8 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
cur_layout = layout;
|
||||
text_.setLayout(layout);
|
||||
bv->owner()->setLayout(cpar()->layout()->name());
|
||||
updflag = true;
|
||||
#warning should be also set dispatched here?
|
||||
result.update(true);
|
||||
}
|
||||
} else {
|
||||
// reset the layout box
|
||||
@ -906,12 +918,13 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!bv->dispatch(cmd))
|
||||
result = DispatchResult(false);
|
||||
break;
|
||||
}
|
||||
|
||||
updateLocal(bv, updflag);
|
||||
if (result.update()) {
|
||||
result.update(false);
|
||||
updateLocal(bv, true);
|
||||
}
|
||||
|
||||
/// If the action has deleted all text in the inset, we need to change the
|
||||
// language to the language of the surronding text.
|
||||
@ -922,11 +935,11 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
|
||||
setFont(bv, font, false);
|
||||
}
|
||||
|
||||
if (result.val() >= FINISHED)
|
||||
if (result.val() >= FINISHED) {
|
||||
result.val(NONE);
|
||||
bv->unlockInset(this);
|
||||
}
|
||||
|
||||
if (result.val() == NONE)
|
||||
result = DispatchResult(true, true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user