From 05894b48627821b7d32d79d477fae6e90a255c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Tue, 4 Nov 2003 08:33:23 +0000 Subject: [PATCH] some InsetText::priv_dispatch progress. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8028 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/cursor.C | 6 ++-- src/dispatchresult.h | 3 ++ src/insets/ChangeLog | 8 ++++- src/insets/insettext.C | 71 +++++++++++++++++++++++++----------------- 4 files changed, 56 insertions(+), 32 deletions(-) diff --git a/src/cursor.C b/src/cursor.C index e6e59eae0e..3e27a80541 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -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()) diff --git a/src/dispatchresult.h b/src/dispatchresult.h index 1e4d801eef..0cad88a85a 100644 --- a/src/dispatchresult.h +++ b/src/dispatchresult.h @@ -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_; } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 5a881ff1cb..fcecf2190a 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,7 +1,13 @@ +2003-11-04 Lars Gullik Bjønnes + + * 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 * Inset::dispatch's: adjust for new DispatchResult semantics. - + 2003-11-03 Lars Gullik Bjønnes * render_base.h: make clone return an auto_ptr diff --git a/src/insets/insettext.C b/src/insets/insettext.C index ea03e0d76f..ad28fc028c 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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 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; }