From 87ca6fbbeb83fa95310789e6d692e43cbfcdb6f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Fri, 17 Oct 2003 18:01:15 +0000 Subject: [PATCH] the dispatch patch git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7931 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 1 + src/BufferView_pimpl.C | 2 +- src/ChangeLog | 8 +++ .../controllers/ControlCommandBuffer.C | 1 + src/frontends/screen.C | 3 + src/insets/ChangeLog | 7 ++ src/insets/insetbase.C | 20 ++++-- src/insets/insetbase.h | 13 ++-- src/insets/insetbibitem.C | 6 +- src/insets/insetbibitem.h | 8 ++- src/insets/insetbibtex.C | 6 +- src/insets/insetbibtex.h | 7 +- src/insets/insetbox.C | 6 +- src/insets/insetbox.h | 8 ++- src/insets/insetbranch.C | 8 ++- src/insets/insetbranch.h | 8 ++- src/insets/insetcite.C | 6 +- src/insets/insetcite.h | 5 ++ src/insets/insetcollapsable.C | 28 ++++---- src/insets/insetcollapsable.h | 6 +- src/insets/insetcommand.C | 5 +- src/insets/insetcommand.h | 6 +- src/insets/insetert.C | 32 +++++---- src/insets/insetert.h | 8 ++- src/insets/insetexternal.C | 3 +- src/insets/insetexternal.h | 9 +-- src/insets/insetfloat.C | 6 +- src/insets/insetfloat.h | 7 +- src/insets/insetfloatlist.C | 6 +- src/insets/insetfloatlist.h | 7 +- src/insets/insetgraphics.C | 3 +- src/insets/insetgraphics.h | 8 ++- src/insets/insetinclude.C | 3 +- src/insets/insetinclude.h | 9 +-- src/insets/insetindex.C | 6 +- src/insets/insetindex.h | 9 +-- src/insets/insetlabel.C | 6 +- src/insets/insetlabel.h | 7 +- src/insets/insetminipage.C | 6 +- src/insets/insetminipage.h | 7 +- src/insets/insetnote.C | 8 ++- src/insets/insetnote.h | 9 ++- src/insets/insetref.C | 5 +- src/insets/insetref.h | 7 +- src/insets/insettabular.C | 36 +++++----- src/insets/insettabular.h | 8 ++- src/insets/insettext.C | 30 ++++---- src/insets/insettext.h | 6 +- src/insets/insettoc.C | 6 +- src/insets/insettoc.h | 7 +- src/insets/inseturl.C | 6 +- src/insets/inseturl.h | 7 +- src/insets/insetwrap.C | 6 +- src/insets/insetwrap.h | 7 +- src/insets/updatableinset.C | 3 +- src/insets/updatableinset.h | 6 +- src/lyxfunc.C | 12 ++-- src/mathed/ChangeLog | 15 +++- src/mathed/command_inset.C | 2 +- src/mathed/formulabase.C | 20 +++--- src/mathed/formulabase.h | 8 ++- src/mathed/math_gridinset.C | 2 +- src/mathed/math_hullinset.C | 4 +- src/mathed/math_nestinset.C | 4 +- src/mathed/math_scriptinset.C | 2 +- src/mathed/ref_inset.C | 69 +++++++++---------- src/mathed/ref_inset.h | 7 +- src/text.C | 3 +- src/text2.C | 4 +- src/text3.C | 16 ++--- 70 files changed, 392 insertions(+), 243 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 5dedad2b27..ebefd26770 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -188,6 +188,7 @@ src/mathed/ref_inset.C src/paragraph.C src/paragraph_funcs.C src/rowpainter.C +src/support/path_defines.C src/text.C src/text2.C src/text3.C diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 0b56147b05..5fee43edf9 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1140,7 +1140,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in) // Note that the localDispatch performs updateInset // also. FuncRequest fr(bv_, LFUN_INSET_MODIFY, ev.argument); - inset->localDispatch(fr); + inset->dispatch(fr); } else { FuncRequest fr(bv_, LFUN_INSET_INSERT, ev.argument); dispatch(fr); diff --git a/src/ChangeLog b/src/ChangeLog index 519111b7d8..e5821211d4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-10-17 Lars Gullik Bjønnes + + * text3.C (doInsertInset, dispatch, dispatch): + * text2.C (cursorUp, cursorDown): + * text.C (selectNextWordToSpellcheck): + * BufferView_pimpl.C (dispatch): + * lyxfunc.C (dispatch): localDispatch -> dispatch + 2003-10-14 Jean-Marc Lasgouttes * lyxsocket.C: include diff --git a/src/frontends/controllers/ControlCommandBuffer.C b/src/frontends/controllers/ControlCommandBuffer.C index c64f1a731f..7c84fe9f15 100644 --- a/src/frontends/controllers/ControlCommandBuffer.C +++ b/src/frontends/controllers/ControlCommandBuffer.C @@ -17,6 +17,7 @@ #include "lyxfunc.h" #include "LyXAction.h" #include "funcrequest.h" + #include "frontends/LyXView.h" #include "support/lyxalgo.h" #include "support/lstrings.h" diff --git a/src/frontends/screen.C b/src/frontends/screen.C index ec07bc3b72..8d989decc0 100644 --- a/src/frontends/screen.C +++ b/src/frontends/screen.C @@ -45,6 +45,7 @@ using lyx::support::LibFileSearch; +using std::endl; using std::min; using std::max; using std::string; @@ -316,6 +317,8 @@ void LyXScreen::redraw(BufferView & bv) LColor::bottomarea); } + lyxerr << "Redraw screen" << endl; + expose(0, 0, workarea().workWidth(), workarea().workHeight()); workarea().getPainter().end(); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index f85ebb44fa..8010849776 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,10 @@ +2003-10-17 Lars Gullik Bjønnes + + * insetbase.C (dispatch): new func + (priv_dispatch): new func replaces... + (localDispatch): this, deleted. + + * all insets with dispatch modified for new code. 2003-10-15 André Pönitz diff --git a/src/insets/insetbase.C b/src/insets/insetbase.C index 7a3a411379..572ab221bd 100644 --- a/src/insets/insetbase.C +++ b/src/insets/insetbase.C @@ -13,15 +13,23 @@ #include "insetbase.h" -dispatch_result InsetBase::dispatch(FuncRequest const &, idx_type &, pos_type &) +dispatch_result +InsetBase::dispatch(FuncRequest const & f, idx_type & i, pos_type & p) { - return UNDISPATCHED; + return priv_dispatch(f, i, p); } +dispatch_result +InsetBase::dispatch(FuncRequest const & f) +{ + idx_type i = 0; + pos_type p = 0; + return priv_dispatch(f, i, p); +} -dispatch_result InsetBase::localDispatch(FuncRequest const & cmd) + +dispatch_result +InsetBase::priv_dispatch(FuncRequest const &, idx_type &, pos_type &) { - idx_type idx = 0; - pos_type pos = 0; - return dispatch(cmd, idx, pos); + return UNDISPATCHED; } diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index f261618f9b..587d1bdd17 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -85,11 +85,12 @@ public: virtual std::auto_ptr clone() const = 0; // the real dispatcher - virtual dispatch_result dispatch - (FuncRequest const & cmd, idx_type & idx, pos_type & pos); + dispatch_result + dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos); + // the real dispatcher + dispatch_result + dispatch(FuncRequest const & cmd); - /// small wrapper for the time being - virtual dispatch_result localDispatch(FuncRequest const & cmd); /// compute the size of the object returned in dim virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0; /// draw inset and update (xo, yo)-cache @@ -100,6 +101,10 @@ public: /// Appends \c list with all labels found within this inset. virtual void getLabelList(Buffer const &, std::vector & /* list */) const {} +protected: + // the real dispatcher + virtual dispatch_result priv_dispatch + (FuncRequest const & cmd, idx_type & idx, pos_type & pos); }; #endif diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index d794437d35..8f4274b95c 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -57,7 +57,9 @@ auto_ptr InsetBibitem::clone() const } -dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetBibitem::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { switch (cmd.action) { @@ -77,7 +79,7 @@ dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd) } default: - return InsetCommand::localDispatch(cmd); + return InsetCommand::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetbibitem.h b/src/insets/insetbibitem.h index 25d60f2523..ae3c6649a3 100644 --- a/src/insets/insetbibitem.h +++ b/src/insets/insetbibitem.h @@ -30,8 +30,6 @@ public: ~InsetBibitem(); /// std::auto_ptr clone() const; - /// - virtual dispatch_result localDispatch(FuncRequest const & cmd); /** Currently \bibitem is used as a LyX2.x command, so we need this method. */ @@ -52,7 +50,11 @@ public: int getCounter() const { return counter; } /// std::string const getBibLabel() const; - +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); private: /// int counter; diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index b0973ca0d4..4a7c043490 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -87,7 +87,9 @@ void InsetBibtex::draw(PainterInfo & pi, int x, int y) const } -dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetBibtex::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { switch (cmd.action) { @@ -109,7 +111,7 @@ dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd) } default: - return InsetCommand::localDispatch(cmd); + return InsetCommand::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetbibtex.h b/src/insets/insetbibtex.h index 30999d6a5e..a7fddf505d 100644 --- a/src/insets/insetbibtex.h +++ b/src/insets/insetbibtex.h @@ -30,8 +30,6 @@ public: void metrics(MetricsInfo &, Dimension &) const; /// void draw(PainterInfo & pi, int x, int y) const; - /// small wrapper for the time being - virtual dispatch_result localDispatch(FuncRequest const & cmd); /// std::string const getScreenLabel(Buffer const &) const; /// @@ -50,6 +48,11 @@ public: bool addDatabase(std::string const &); /// bool delDatabase(std::string const &); +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); }; #endif // INSET_BIBTEX_H diff --git a/src/insets/insetbox.C b/src/insets/insetbox.C index 62748c2274..9f867c502f 100644 --- a/src/insets/insetbox.C +++ b/src/insets/insetbox.C @@ -164,7 +164,9 @@ bool InsetBox::showInsetDialog(BufferView * bv) const } -dispatch_result InsetBox::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetBox::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { BufferView * bv = cmd.view(); @@ -188,7 +190,7 @@ dispatch_result InsetBox::localDispatch(FuncRequest const & cmd) // fallthrough: default: - return InsetCollapsable::localDispatch(cmd); + return InsetCollapsable::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetbox.h b/src/insets/insetbox.h index 4dcf775a61..4fcb7b513b 100644 --- a/src/insets/insetbox.h +++ b/src/insets/insetbox.h @@ -74,8 +74,6 @@ public: /// void setButtonLabel(); /// - dispatch_result localDispatch(FuncRequest const &); - /// void metrics(MetricsInfo &, Dimension &) const; /// show the Box dialog bool showInsetDialog(BufferView * bv) const; @@ -101,7 +99,11 @@ public: Shadowbox, Doublebox }; - +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const &, idx_type &, pos_type &); private: friend class InsetBoxParams; diff --git a/src/insets/insetbranch.C b/src/insets/insetbranch.C index 7db6c4a291..7b92208753 100644 --- a/src/insets/insetbranch.C +++ b/src/insets/insetbranch.C @@ -116,7 +116,9 @@ bool InsetBranch::showInsetDialog(BufferView * bv) const } -dispatch_result InsetBranch::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetBranch::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { BufferView * bv = cmd.view(); switch (cmd.action) { @@ -131,7 +133,7 @@ dispatch_result InsetBranch::localDispatch(FuncRequest const & cmd) } case LFUN_INSET_EDIT: if (cmd.button() != mouse_button::button3) - return InsetCollapsable::localDispatch(cmd); + return InsetCollapsable::priv_dispatch(cmd, idx, pos); return UNDISPATCHED; case LFUN_INSET_DIALOG_UPDATE: @@ -144,7 +146,7 @@ dispatch_result InsetBranch::localDispatch(FuncRequest const & cmd) } // fallthrough: default: - return InsetCollapsable::localDispatch(cmd); + return InsetCollapsable::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetbranch.h b/src/insets/insetbranch.h index 0ba0f0f634..d05e2e6a91 100644 --- a/src/insets/insetbranch.h +++ b/src/insets/insetbranch.h @@ -56,8 +56,6 @@ public: /// bool showInsetDialog(BufferView *) const; /// - dispatch_result localDispatch(FuncRequest const &); - /// int latex(Buffer const &, std::ostream &, LatexRunParams const &) const; /// @@ -72,7 +70,11 @@ public: InsetBranchParams const & params() const { return params_; } /// void setParams(InsetBranchParams const & params) { params_ = params; } - +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const &, idx_type &, pos_type &); private: friend class InsetBranchParams; diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index c6babf5c03..e696dd2f39 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -332,7 +332,9 @@ void InsetCitation::setLoadingBuffer(Buffer const & buffer, bool state) const } -dispatch_result InsetCitation::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetCitation::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { switch (cmd.action) { case LFUN_INSET_EDIT: @@ -343,7 +345,7 @@ dispatch_result InsetCitation::localDispatch(FuncRequest const & cmd) return DISPATCHED; default: - return InsetCommand::localDispatch(cmd); + return InsetCommand::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetcite.h b/src/insets/insetcite.h index 8547521d35..95dbf024b2 100644 --- a/src/insets/insetcite.h +++ b/src/insets/insetcite.h @@ -48,6 +48,11 @@ public: and that the cache of BibTeX keys should be reloaded in the future. */ void setLoadingBuffer(Buffer const & buffer, bool state) const; +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); private: struct Cache { /// diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index b010a160ff..febaa9ceed 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -233,7 +233,7 @@ void InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd) bv->updateInset(this); bv->buffer()->markDirty(); } else if (!collapsed_ && cmd.y > button_dim.y2) { - ret = inset.localDispatch(adjustCommand(cmd)) == DISPATCHED; + ret = inset.dispatch(adjustCommand(cmd)) == DISPATCHED; } if (cmd.button() == mouse_button::button3 && !ret) showInsetDialog(bv); @@ -276,12 +276,14 @@ void InsetCollapsable::edit(BufferView * bv, int index) lyxerr << "InsetCollapsable: edit" << endl; if (!bv->lockInset(this)) lyxerr << "InsetCollapsable: can't lock index " << index << endl; - inset.localDispatch(FuncRequest(bv, LFUN_INSET_EDIT, "left")); + inset.dispatch(FuncRequest(bv, LFUN_INSET_EDIT, "left")); first_after_edit = true; } -dispatch_result InsetCollapsable::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetCollapsable::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { //lyxerr << "InsetCollapsable::localDispatch: " // << cmd.action << " '" << cmd.argument << "'\n"; @@ -289,20 +291,20 @@ dispatch_result InsetCollapsable::localDispatch(FuncRequest const & cmd) switch (cmd.action) { case LFUN_INSET_EDIT: { if (!cmd.argument.empty()) { - UpdatableInset::localDispatch(cmd); + UpdatableInset::priv_dispatch(cmd, idx, pos); if (collapsed_) { lyxerr << "branch collapsed_" << endl; collapsed_ = false; if (bv->lockInset(this)) { bv->updateInset(this); bv->buffer()->markDirty(); - inset.localDispatch(cmd); + inset.dispatch(cmd); first_after_edit = true; } } else { lyxerr << "branch not collapsed_" << endl; if (bv->lockInset(this)) - inset.localDispatch(cmd); + inset.dispatch(cmd); } return DISPATCHED; } @@ -313,7 +315,7 @@ dispatch_result InsetCollapsable::localDispatch(FuncRequest const & cmd) if (cmd.button() == mouse_button::button3) return DISPATCHED; - UpdatableInset::localDispatch(cmd); + UpdatableInset::priv_dispatch(cmd, idx, pos); if (collapsed_) { collapsed_ = false; @@ -324,28 +326,28 @@ dispatch_result InsetCollapsable::localDispatch(FuncRequest const & cmd) return DISPATCHED; bv->updateInset(this); bv->buffer()->markDirty(); - inset.localDispatch(cmd); + inset.dispatch(cmd); } else { if (!bv->lockInset(this)) return DISPATCHED; if (cmd.y <= button_dim.y2) { FuncRequest cmd1 = cmd; cmd1.y = 0; - inset.localDispatch(cmd1); + inset.dispatch(cmd1); } else - inset.localDispatch(adjustCommand(cmd)); + inset.dispatch(adjustCommand(cmd)); } return DISPATCHED; } case LFUN_MOUSE_PRESS: if (!collapsed_ && cmd.y > button_dim.y2) - inset.localDispatch(adjustCommand(cmd)); + inset.dispatch(adjustCommand(cmd)); return DISPATCHED; case LFUN_MOUSE_MOTION: if (!collapsed_ && cmd.y > button_dim.y2) - inset.localDispatch(adjustCommand(cmd)); + inset.dispatch(adjustCommand(cmd)); return DISPATCHED; case LFUN_MOUSE_RELEASE: @@ -353,7 +355,7 @@ dispatch_result InsetCollapsable::localDispatch(FuncRequest const & cmd) return DISPATCHED; default: - dispatch_result result = inset.localDispatch(cmd); + dispatch_result result = inset.dispatch(cmd); if (result >= FINISHED) bv->unlockInset(this); first_after_edit = false; diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index e641701ca6..cd62a24956 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -68,8 +68,6 @@ public: /// int insetInInsetY() const; /// - dispatch_result localDispatch(FuncRequest const &); - /// int latex(Buffer const &, std::ostream &, LatexRunParams const &) const; /// @@ -149,6 +147,10 @@ public: void addPreview(lyx::graphics::PreviewLoader &) const; protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const &, idx_type &, pos_type &); /// void dimension_collapsed(Dimension &) const; /// diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 6eff3dc6a5..caa1c11ad2 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -84,7 +84,8 @@ int InsetCommand::docbook(Buffer const &, ostream &, bool) const } -dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetCommand::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &) { switch (cmd.action) { case LFUN_INSET_MODIFY: { @@ -103,7 +104,7 @@ dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd) return DISPATCHED; case LFUN_MOUSE_RELEASE: - return localDispatch(FuncRequest(cmd.view(), LFUN_INSET_EDIT)); + return dispatch(FuncRequest(cmd.view(), LFUN_INSET_EDIT)); default: return UNDISPATCHED; diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index 32129d039b..a12a2ceaad 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -59,8 +59,6 @@ public: /// InsetCommandParams const & params() const { return p_; } /// - virtual dispatch_result localDispatch(FuncRequest const & cmd); - /// std::string const & getContents() const { return p_.getContents(); } /// void setContents(std::string const & c) { p_.setContents(c); } @@ -70,6 +68,10 @@ public: RenderButton & button() const { return button_; } protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); /// std::string const getCommand() const { return p_.getCommand(); } /// diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 3c611f7f18..23722cf930 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -280,9 +280,12 @@ InsetOld::EDITABLE InsetERT::editable() const void InsetERT::lfunMousePress(FuncRequest const & cmd) { if (status_ == Inlined) - inset.localDispatch(cmd); - else - InsetCollapsable::localDispatch(cmd); + inset.dispatch(cmd); + else { + idx_type idx = 0; + pos_type pos = 0; + InsetCollapsable::priv_dispatch(cmd, idx, pos); + } } @@ -304,10 +307,10 @@ bool InsetERT::lfunMouseRelease(FuncRequest const & cmd) // inlined is special - the text appears above if (status_ == Inlined) - inset.localDispatch(cmd1); + inset.dispatch(cmd1); else if (isOpen() && (cmd.y > buttonDim().y2)) { cmd1.y -= height_collapsed(); - inset.localDispatch(cmd1); + inset.dispatch(cmd1); } } return false; @@ -317,9 +320,12 @@ bool InsetERT::lfunMouseRelease(FuncRequest const & cmd) void InsetERT::lfunMouseMotion(FuncRequest const & cmd) { if (status_ == Inlined) - inset.localDispatch(cmd); - else - InsetCollapsable::localDispatch(cmd); + inset.dispatch(cmd); + else { + idx_type idx = 0; + pos_type pos = 0; + InsetCollapsable::priv_dispatch(cmd, idx, pos); + } } @@ -415,7 +421,9 @@ int InsetERT::docbook(Buffer const &, ostream & os, bool) const } -dispatch_result InsetERT::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetERT::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { dispatch_result result = UNDISPATCHED; BufferView * bv = cmd.view(); @@ -432,9 +440,9 @@ dispatch_result InsetERT::localDispatch(FuncRequest const & cmd) if (status_ == Inlined) { if (!bv->lockInset(this)) break; - result = inset.localDispatch(cmd); + result = inset.dispatch(cmd); } else { - result = InsetCollapsable::localDispatch(cmd); + result = InsetCollapsable::priv_dispatch(cmd, idx, pos); } set_latex_font(bv); updateStatus(bv); @@ -479,7 +487,7 @@ dispatch_result InsetERT::localDispatch(FuncRequest const & cmd) break; default: - result = InsetCollapsable::localDispatch(cmd); + result = InsetCollapsable::priv_dispatch(cmd, idx, pos); } switch (cmd.action) { diff --git a/src/insets/insetert.h b/src/insets/insetert.h index d2fa963148..c886156c69 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -76,8 +76,6 @@ public: /// void validate(LaTeXFeatures &) const {} /// - dispatch_result localDispatch(FuncRequest const &); - /// bool checkInsertChar(LyXFont &); /// // these are needed here because of the label/inlined functionallity @@ -110,7 +108,11 @@ public: bool forceDefaultParagraphs(InsetOld const *) const { return true; } - +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const &, idx_type &, pos_type &); private: /// void lfunMousePress(FuncRequest const &); diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 479fa9e08b..f18fbc0a8a 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -387,7 +387,8 @@ void InsetExternal::statusChanged() const } -dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetExternal::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &) { switch (cmd.action) { diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index 93d0e678c0..fe35b5abbf 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -92,9 +92,6 @@ public: virtual ~InsetExternal(); /// virtual std::auto_ptr clone() const; - /// - virtual dispatch_result localDispatch(FuncRequest const & cmd); - /// virtual InsetOld::Code lyxCode() const { return EXTERNAL_CODE; } /// @@ -126,7 +123,11 @@ public: /// InsetExternalParams const & params() const; void setParams(InsetExternalParams const &, Buffer const &); - +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); private: /** This method is connected to the graphics loader, so we are * informed when the image has been loaded. diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index 0f0ba8a817..8f93e35d9a 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -159,7 +159,9 @@ InsetFloat::~InsetFloat() } -dispatch_result InsetFloat::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetFloat::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { switch (cmd.action) { @@ -181,7 +183,7 @@ dispatch_result InsetFloat::localDispatch(FuncRequest const & cmd) } default: - return InsetCollapsable::localDispatch(cmd); + return InsetCollapsable::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetfloat.h b/src/insets/insetfloat.h index 2c90b71535..5416845ac2 100644 --- a/src/insets/insetfloat.h +++ b/src/insets/insetfloat.h @@ -45,8 +45,6 @@ public: /// ~InsetFloat(); /// - virtual dispatch_result localDispatch(FuncRequest const & cmd); - /// void write(Buffer const & buf, std::ostream & os) const; /// void read(Buffer const & buf, LyXLex & lex); @@ -79,7 +77,10 @@ public: bool showInsetDialog(BufferView *) const; /// InsetFloatParams const & params() const { return params_; } - +protected: + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); private: /// InsetFloatParams params_; diff --git a/src/insets/insetfloatlist.C b/src/insets/insetfloatlist.C index ce9c632705..3926935e89 100644 --- a/src/insets/insetfloatlist.C +++ b/src/insets/insetfloatlist.C @@ -118,7 +118,9 @@ void InsetFloatList::draw(PainterInfo & pi, int x, int y) const } -dispatch_result InsetFloatList::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetFloatList::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { switch (cmd.action) { case LFUN_MOUSE_RELEASE: @@ -131,7 +133,7 @@ dispatch_result InsetFloatList::localDispatch(FuncRequest const & cmd) return DISPATCHED; default: - return InsetCommand::localDispatch(cmd); + return InsetCommand::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetfloatlist.h b/src/insets/insetfloatlist.h index 9052105ee1..42cd403f24 100644 --- a/src/insets/insetfloatlist.h +++ b/src/insets/insetfloatlist.h @@ -34,8 +34,6 @@ public: /// void draw(PainterInfo & pi, int x, int y) const; /// - dispatch_result localDispatch(FuncRequest const & cmd); - /// std::string const getScreenLabel(Buffer const &) const; /// EDITABLE editable() const { return IS_EDITABLE; } @@ -56,6 +54,11 @@ public: int ascii(Buffer const &, std::ostream &, int linelen) const; /// void validate(LaTeXFeatures & features) const; +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); }; #endif diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index a54703a921..754f6a6116 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -190,7 +190,8 @@ void InsetGraphics::statusChanged() const } -dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetGraphics::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &) { switch (cmd.action) { case LFUN_INSET_MODIFY: { diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 6559752142..79e37b2610 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -33,8 +33,6 @@ public: /// ~InsetGraphics(); /// - virtual dispatch_result localDispatch(FuncRequest const & cmd); - /// void metrics(MetricsInfo &, Dimension &) const; /// EDITABLE editable() const; @@ -76,7 +74,11 @@ public: InsetGraphicsParams const & params() const; /// void draw(PainterInfo & pi, int x, int y) const; - +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); private: /// friend class InsetGraphicsMailer; diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 3a5cbda597..5a02886a53 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -107,7 +107,8 @@ InsetInclude::~InsetInclude() } -dispatch_result InsetInclude::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetInclude::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &) { switch (cmd.action) { diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 5e96daea32..72dc2eed46 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -34,9 +34,6 @@ public: /// virtual std::auto_ptr clone() const; - /// - virtual dispatch_result localDispatch(FuncRequest const & cmd); - /// Override these InsetButton methods if Previewing void metrics(MetricsInfo & mi, Dimension & dim) const; /// @@ -78,7 +75,11 @@ public: void validate(LaTeXFeatures &) const; /// void addPreview(lyx::graphics::PreviewLoader &) const; - +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); private: /// Slot receiving a signal that the preview is ready to display. void statusChanged() const; diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index deaac12f60..b961d7d0ef 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -60,7 +60,9 @@ void InsetPrintIndex::draw(PainterInfo & pi, int x, int y) const } -dispatch_result InsetIndex::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetIndex::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { switch (cmd.action) { case LFUN_INSET_EDIT: @@ -68,7 +70,7 @@ dispatch_result InsetIndex::localDispatch(FuncRequest const & cmd) return DISPATCHED; default: - return InsetCommand::localDispatch(cmd); + return InsetCommand::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetindex.h b/src/insets/insetindex.h index ece2887b30..99ab39a448 100644 --- a/src/insets/insetindex.h +++ b/src/insets/insetindex.h @@ -30,8 +30,6 @@ public: return std::auto_ptr(new InsetIndex(params())); } /// - dispatch_result localDispatch(FuncRequest const & cmd); - /// std::string const getScreenLabel(Buffer const &) const; /// EDITABLE editable() const { return IS_EDITABLE; } @@ -39,6 +37,11 @@ public: InsetOld::Code lyxCode() const; /// int docbook(Buffer const &, std::ostream &, bool mixcont) const; +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); }; @@ -52,8 +55,6 @@ public: virtual std::auto_ptr clone() const { return std::auto_ptr(new InsetPrintIndex(params())); } - /// - //dispatch_result localDispatch(FuncRequest const & cmd); /// Updates needed features for this inset. void validate(LaTeXFeatures & features) const; /// diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index ac056649d7..3e9ca9ad8f 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -56,7 +56,9 @@ string const InsetLabel::getScreenLabel(Buffer const &) const } -dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetLabel::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { BOOST_ASSERT(cmd.view()); BufferView * const bv = cmd.view(); @@ -86,7 +88,7 @@ dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd) } default: - return InsetCommand::localDispatch(cmd); + return InsetCommand::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index d42255e93b..76ce67df84 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -23,8 +23,6 @@ public: /// std::auto_ptr clone() const; /// - virtual dispatch_result localDispatch(FuncRequest const & cmd); - /// std::string const getScreenLabel(Buffer const &) const; /// EDITABLE editable() const { return IS_EDITABLE; } @@ -41,6 +39,11 @@ public: int linuxdoc(Buffer const &, std::ostream &) const; /// int docbook(Buffer const &, std::ostream &, bool mixcont) const; +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); }; #endif diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index 5480c181ab..7c19ef39c3 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -95,7 +95,9 @@ InsetMinipage::~InsetMinipage() } -dispatch_result InsetMinipage::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetMinipage::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { switch (cmd.action) { case LFUN_INSET_MODIFY: { @@ -117,7 +119,7 @@ dispatch_result InsetMinipage::localDispatch(FuncRequest const & cmd) return DISPATCHED; default: - return InsetCollapsable::localDispatch(cmd); + return InsetCollapsable::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetminipage.h b/src/insets/insetminipage.h index e484b3bf44..b6a355b12b 100644 --- a/src/insets/insetminipage.h +++ b/src/insets/insetminipage.h @@ -60,8 +60,6 @@ public: /// ~InsetMinipage(); /// - virtual dispatch_result localDispatch(FuncRequest const & cmd); - /// void write(Buffer const & buf, std::ostream & os) const; /// void read(Buffer const & buf, LyXLex & lex); @@ -90,6 +88,11 @@ public: void params(Params const & p) { params_ = p; } /// Params const & params() const { return params_; } +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); private: /// Params params_; diff --git a/src/insets/insetnote.C b/src/insets/insetnote.C index 1e3630aa88..98b855b1da 100644 --- a/src/insets/insetnote.C +++ b/src/insets/insetnote.C @@ -129,7 +129,9 @@ bool InsetNote::showInsetDialog(BufferView * bv) const } -dispatch_result InsetNote::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetNote::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { BufferView * bv = cmd.view(); @@ -145,7 +147,7 @@ dispatch_result InsetNote::localDispatch(FuncRequest const & cmd) case LFUN_INSET_EDIT: if (cmd.button() == mouse_button::button3) return UNDISPATCHED; - return InsetCollapsable::localDispatch(cmd); + return InsetCollapsable::priv_dispatch(cmd, idx, pos); case LFUN_INSET_DIALOG_UPDATE: InsetNoteMailer("note", *this).updateDialog(bv); @@ -159,7 +161,7 @@ dispatch_result InsetNote::localDispatch(FuncRequest const & cmd) // fallthrough: default: - return InsetCollapsable::localDispatch(cmd); + return InsetCollapsable::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetnote.h b/src/insets/insetnote.h index 8b93cf0786..ec77573929 100644 --- a/src/insets/insetnote.h +++ b/src/insets/insetnote.h @@ -52,8 +52,6 @@ public: /// void setButtonLabel(); /// - dispatch_result localDispatch(FuncRequest const &); - /// void metrics(MetricsInfo &, Dimension &) const; /// show the note dialog bool showInsetDialog(BufferView * bv) const; @@ -70,7 +68,11 @@ public: void validate(LaTeXFeatures &) const; /// InsetNoteParams const & params() const { return params_; } - +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const &, idx_type &, pos_type &); private: friend class InsetNoteParams; @@ -80,6 +82,7 @@ private: InsetNoteParams params_; }; + #include "mailinset.h" class InsetNoteMailer : public MailInset { diff --git a/src/insets/insetref.C b/src/insets/insetref.C index d2c1dfacac..959f3e903c 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -45,7 +45,8 @@ InsetRef::~InsetRef() } -dispatch_result InsetRef::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetRef::priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos) { switch (cmd.action) { case LFUN_INSET_EDIT: @@ -58,7 +59,7 @@ dispatch_result InsetRef::localDispatch(FuncRequest const & cmd) return DISPATCHED; default: - return InsetCommand::localDispatch(cmd); + return InsetCommand::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetref.h b/src/insets/insetref.h index f0a641c4b2..95a506939c 100644 --- a/src/insets/insetref.h +++ b/src/insets/insetref.h @@ -46,8 +46,6 @@ public: return std::auto_ptr(new InsetRef(*this)); } /// - dispatch_result localDispatch(FuncRequest const & cmd); - /// std::string const getScreenLabel(Buffer const &) const; /// EDITABLE editable() const { return IS_EDITABLE; } @@ -66,6 +64,11 @@ public: int docbook(Buffer const &, std::ostream &, bool mixcont) const; /// void validate(LaTeXFeatures & features) const; +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); private: /// bool isLatex; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index bcc75647d0..350b9a6812 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -451,7 +451,7 @@ bool InsetTabular::lockInsetInInset(BufferView * bv, UpdatableInset * inset) } if (in->getInsetFromID(id)) { actcell = i; - in->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT)); + in->dispatch(FuncRequest(bv, LFUN_INSET_EDIT)); return the_locking_inset->lockInsetInInset(bv, inset); } } @@ -567,7 +567,7 @@ void InsetTabular::lfunMousePress(FuncRequest const & cmd) FuncRequest cmd1 = cmd; cmd1.x -= inset_x; cmd1.y -= inset_y; - the_locking_inset->localDispatch(cmd1); + the_locking_inset->dispatch(cmd1); return; } @@ -578,7 +578,7 @@ void InsetTabular::lfunMousePress(FuncRequest const & cmd) } if (cmd.button() == mouse_button::button2) { - localDispatch(FuncRequest(bv, LFUN_PASTESELECTION, "paragraph")); + dispatch(FuncRequest(bv, LFUN_PASTESELECTION, "paragraph")); return; } @@ -590,7 +590,7 @@ void InsetTabular::lfunMousePress(FuncRequest const & cmd) FuncRequest cmd1 = cmd; cmd1.x -= inset_x; cmd1.y -= inset_y; - the_locking_inset->localDispatch(cmd1); + the_locking_inset->dispatch(cmd1); } } @@ -602,7 +602,7 @@ bool InsetTabular::lfunMouseRelease(FuncRequest const & cmd) FuncRequest cmd1 = cmd; cmd1.x -= inset_x; cmd1.y -= inset_y; - ret = the_locking_inset->localDispatch(cmd1); + ret = the_locking_inset->dispatch(cmd1); } if (cmd.button() == mouse_button::button3 && !ret) { InsetTabularMailer(*this).showDialog(cmd.view()); @@ -618,7 +618,7 @@ void InsetTabular::lfunMouseMotion(FuncRequest const & cmd) FuncRequest cmd1 = cmd; cmd1.x -= inset_x; cmd1.y -= inset_y; - the_locking_inset->localDispatch(cmd1); + the_locking_inset->dispatch(cmd1); return; } @@ -654,18 +654,20 @@ void InsetTabular::edit(BufferView * bv, int index) bv->fitCursor(); UpdatableInset & inset = tabular.getCellInset(actcell); - inset.localDispatch(FuncRequest(bv, LFUN_INSET_EDIT, "left")); + inset.dispatch(FuncRequest(bv, LFUN_INSET_EDIT, "left")); if (the_locking_inset) updateLocal(bv); } -dispatch_result InsetTabular::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetTabular::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { // We need to save the value of the_locking_inset as the call to // the_locking_inset->localDispatch might unlock it. old_locking_inset = the_locking_inset; - dispatch_result result = UpdatableInset::localDispatch(cmd); + dispatch_result result = UpdatableInset::priv_dispatch(cmd, idx, pos); BufferView * bv = cmd.view(); if (cmd.action == LFUN_INSET_EDIT) { @@ -763,7 +765,7 @@ dispatch_result InsetTabular::localDispatch(FuncRequest const & cmd) kb_action action = cmd.action; string arg = cmd.argument; if (the_locking_inset) { - result = the_locking_inset->localDispatch(cmd); + result = the_locking_inset->dispatch(cmd); if (result == DISPATCHED_NOUPDATE) { int sc = scroll(); resetPos(bv); @@ -1094,7 +1096,7 @@ dispatch_result InsetTabular::localDispatch(FuncRequest const & cmd) if (result == DISPATCHED || the_locking_inset) break; if (activateCellInset(bv)) { - result = the_locking_inset->localDispatch(FuncRequest(bv, action, arg)); + result = the_locking_inset->dispatch(FuncRequest(bv, action, arg)); if (result == UNDISPATCHED || result >= FINISHED) { unlockInsetInInset(bv, the_locking_inset); // we need to update if this was requested before @@ -1599,7 +1601,7 @@ void checkLongtableSpecial(LyXTabular::ltType & ltt, } } -} +} // anon namespace void InsetTabular::tabularFeatures(BufferView * bv, @@ -1983,7 +1985,7 @@ bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, } //inset_x = cursorx_ - top_x + tabular.getBeginningOfTextInCell(actcell); //inset_y = cursory_; - inset.localDispatch(FuncRequest(bv, LFUN_INSET_EDIT, x, y, button)); + inset.dispatch(FuncRequest(bv, LFUN_INSET_EDIT, x, y, button)); if (!the_locking_inset) return false; updateLocal(bv); @@ -2416,7 +2418,7 @@ WordLangTuple const InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const { if (the_locking_inset) { - WordLangTuple word = + WordLangTuple word = the_locking_inset->selectNextWordToSpellcheck(bv, value); if (!word.word().empty()) return word; @@ -2428,7 +2430,7 @@ InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const } // otherwise we have to lock the next inset and ask for it's selecttion tabular.getCellInset(actcell) - .localDispatch(FuncRequest(bv, LFUN_INSET_EDIT)); + .dispatch(FuncRequest(bv, LFUN_INSET_EDIT)); WordLangTuple word = selectNextWordInt(bv, value); if (!word.word().empty()) resetPos(bv); @@ -2454,7 +2456,7 @@ WordLangTuple InsetTabular::selectNextWordInt(BufferView * bv, float & value) co // otherwise we have to lock the next inset and ask for it's selecttion ++actcell; tabular.getCellInset(actcell) - .localDispatch(FuncRequest(bv, LFUN_INSET_EDIT)); + .dispatch(FuncRequest(bv, LFUN_INSET_EDIT)); return selectNextWordInt(bv, value); } @@ -2575,7 +2577,7 @@ bool InsetTabular::forceDefaultParagraphs(InsetOld const * in) const // this is a workaround for a crash (New, Insert->Tabular, // Insert->FootNote) - if (!owner()) + if (!owner()) return false; // well we didn't obviously find it so maybe our owner knows more diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 4edfd18b12..33c4a9d6b8 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -105,8 +105,6 @@ public: /// bool display() const { return tabular.isLongTabular(); } /// - dispatch_result localDispatch(FuncRequest const &); - /// int latex(Buffer const &, std::ostream &, LatexRunParams const &) const; /// @@ -206,7 +204,11 @@ public: /// set the owning buffer void buffer(Buffer * buf); - +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const &, idx_type &, pos_type &); private: /// lock cell with given index void edit(BufferView * bv, int index); diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 2cbaaeca09..941877d16f 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -477,7 +477,7 @@ void InsetText::lfunMousePress(FuncRequest const & cmd) if (the_locking_inset) { if (the_locking_inset == inset) { - the_locking_inset->localDispatch(cmd1); + the_locking_inset->dispatch(cmd1); return; } // otherwise only unlock the_locking_inset @@ -495,7 +495,7 @@ void InsetText::lfunMousePress(FuncRequest const & cmd) if (!bv->lockInset(uinset)) { lyxerr[Debug::INSETS] << "Cannot lock inset" << endl; } - inset->localDispatch(cmd1); + inset->dispatch(cmd1); if (the_locking_inset) updateLocal(bv, false); return; @@ -504,7 +504,7 @@ void InsetText::lfunMousePress(FuncRequest const & cmd) if (!inset) { bool paste_internally = false; if (cmd.button() == mouse_button::button2 && getLyXText(bv)->selection.set()) { - localDispatch(FuncRequest(bv, LFUN_COPY)); + dispatch(FuncRequest(bv, LFUN_COPY)); paste_internally = true; } int old_top_y = bv->top_y(); @@ -528,9 +528,9 @@ void InsetText::lfunMousePress(FuncRequest const & cmd) // insert this if (cmd.button() == mouse_button::button2) { if (paste_internally) - localDispatch(FuncRequest(bv, LFUN_PASTE)); + dispatch(FuncRequest(bv, LFUN_PASTE)); else - localDispatch(FuncRequest(bv, LFUN_PASTESELECTION, "paragraph")); + dispatch(FuncRequest(bv, LFUN_PASTESELECTION, "paragraph")); } } else { getLyXText(bv)->clearSelection(); @@ -547,7 +547,7 @@ bool InsetText::lfunMouseRelease(FuncRequest const & cmd) no_selection = true; if (the_locking_inset) - return the_locking_inset->localDispatch(cmd1); + return the_locking_inset->dispatch(cmd1); int tmp_x = cmd.x; int tmp_y = cmd.y + dim_.asc - bv->top_y(); @@ -557,7 +557,7 @@ bool InsetText::lfunMouseRelease(FuncRequest const & cmd) // We still need to deal properly with the whole relative vs. // absolute mouse co-ords thing in a realiable, sensible way - bool ret = inset->localDispatch(cmd1); + bool ret = inset->dispatch(cmd1); updateLocal(bv, false); return ret; } @@ -570,7 +570,7 @@ void InsetText::lfunMouseMotion(FuncRequest const & cmd) cmd1.y -= inset_y; if (the_locking_inset) { - the_locking_inset->localDispatch(cmd1); + the_locking_inset->dispatch(cmd1); return; } @@ -588,14 +588,16 @@ void InsetText::lfunMouseMotion(FuncRequest const & cmd) } -dispatch_result InsetText::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetText::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { BufferView * bv = cmd.view(); setViewCache(bv); switch (cmd.action) { case LFUN_INSET_EDIT: { - UpdatableInset::localDispatch(cmd); + UpdatableInset::priv_dispatch(cmd, idx, pos); if (!bv->lockInset(this)) { lyxerr[Debug::INSETS] << "Cannot lock inset" << endl; @@ -668,7 +670,7 @@ dispatch_result InsetText::localDispatch(FuncRequest const & cmd) bool was_empty = paragraphs.begin()->empty() && paragraphs.size() == 1; no_selection = false; - dispatch_result result = UpdatableInset::localDispatch(cmd); + dispatch_result result = UpdatableInset::priv_dispatch(cmd, idx, pos); if (result != UNDISPATCHED) return DISPATCHED; @@ -677,7 +679,7 @@ dispatch_result InsetText::localDispatch(FuncRequest const & cmd) return FINISHED; if (the_locking_inset) { - result = the_locking_inset->localDispatch(cmd); + result = the_locking_inset->dispatch(cmd); if (result == DISPATCHED_NOUPDATE) return result; if (result == DISPATCHED) { @@ -1363,7 +1365,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, bool front) if (!isHighlyEditableInset(inset)) return false; FuncRequest cmd(bv, LFUN_INSET_EDIT, front ? "left" : "right"); - inset->localDispatch(cmd); + inset->dispatch(cmd); if (!the_locking_inset) return false; updateLocal(bv, false); @@ -1394,7 +1396,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y, inset_x = cx() - top_x; inset_y = cy(); FuncRequest cmd(bv, LFUN_INSET_EDIT, x - inset_x, y - inset_y, button); - inset->localDispatch(cmd); + inset->dispatch(cmd); if (!the_locking_inset) return false; updateLocal(bv, false); diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 85ab71abb0..578ccdacd5 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -80,8 +80,6 @@ public: bool unlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false); /// - dispatch_result localDispatch(FuncRequest const &); - /// int latex(Buffer const &, std::ostream &, LatexRunParams const &) const; /// @@ -202,6 +200,10 @@ public: /// mutable ParagraphList paragraphs; protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const &, idx_type &, pos_type &); /// void updateLocal(BufferView *, bool mark_dirty); /// set parameters for an initial lock of this inset diff --git a/src/insets/insettoc.C b/src/insets/insettoc.C index e9c584aea0..1c7fb4226b 100644 --- a/src/insets/insettoc.C +++ b/src/insets/insettoc.C @@ -71,7 +71,9 @@ void InsetTOC::draw(PainterInfo & pi, int x, int y) const } -dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetTOC::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { switch (cmd.action) { case LFUN_MOUSE_RELEASE: @@ -84,7 +86,7 @@ dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd) return DISPATCHED; default: - return InsetCommand::localDispatch(cmd); + return InsetCommand::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insettoc.h b/src/insets/insettoc.h index b41bc6110b..a7c30389d9 100644 --- a/src/insets/insettoc.h +++ b/src/insets/insettoc.h @@ -35,8 +35,6 @@ public: /// void draw(PainterInfo & pi, int x, int y) const; /// - dispatch_result localDispatch(FuncRequest const & cmd); - /// std::string const getScreenLabel(Buffer const &) const; /// EDITABLE editable() const { return IS_EDITABLE; } @@ -48,6 +46,11 @@ public: int linuxdoc(Buffer const &, std::ostream &) const; /// int docbook(Buffer const &, std::ostream &, bool mixcont) const; +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); }; #endif diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index 5fcd8ef1c1..13a25dd3fa 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -43,14 +43,16 @@ InsetUrl::~InsetUrl() } -dispatch_result InsetUrl::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetUrl::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { switch (cmd.action) { case LFUN_INSET_EDIT: InsetCommandMailer("url", *this).showDialog(cmd.view()); return DISPATCHED; default: - return InsetCommand::localDispatch(cmd); + return InsetCommand::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/inseturl.h b/src/insets/inseturl.h index af6bbf2e7d..716f7c4b21 100644 --- a/src/insets/inseturl.h +++ b/src/insets/inseturl.h @@ -31,8 +31,6 @@ public: return std::auto_ptr(new InsetUrl(params())); } /// - dispatch_result localDispatch(FuncRequest const & cmd); - /// InsetOld::Code lyxCode() const { return InsetOld::URL_CODE; } /// void validate(LaTeXFeatures &) const; @@ -51,6 +49,11 @@ public: int linuxdoc(Buffer const &, std::ostream &) const; /// int docbook(Buffer const &, std::ostream &, bool mixcont) const; +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); }; #endif diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index 9be7eb2e91..b070bd80bb 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -83,7 +83,9 @@ InsetWrap::~InsetWrap() } -dispatch_result InsetWrap::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetWrap::priv_dispatch(FuncRequest const & cmd, + idx_type & idx, pos_type & pos) { switch (cmd.action) { case LFUN_INSET_MODIFY: { @@ -102,7 +104,7 @@ dispatch_result InsetWrap::localDispatch(FuncRequest const & cmd) return DISPATCHED; default: - return InsetCollapsable::localDispatch(cmd); + return InsetCollapsable::priv_dispatch(cmd, idx, pos); } } diff --git a/src/insets/insetwrap.h b/src/insets/insetwrap.h index 2350b9b5d7..94adbb1c20 100644 --- a/src/insets/insetwrap.h +++ b/src/insets/insetwrap.h @@ -42,8 +42,6 @@ public: /// ~InsetWrap(); /// - virtual dispatch_result localDispatch(FuncRequest const & cmd); - /// void write(Buffer const & buf, std::ostream & os) const; /// void read(Buffer const & buf, LyXLex & lex); @@ -70,6 +68,11 @@ public: int latexTextWidth(BufferView *) const; /// InsetWrapParams const & params() const { return params_; } +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); private: /// InsetWrapParams params_; diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C index fd022a71b5..9ff4c08e0c 100644 --- a/src/insets/updatableinset.C +++ b/src/insets/updatableinset.C @@ -108,7 +108,8 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const /// An updatable inset could handle lyx editing commands -dispatch_result UpdatableInset::localDispatch(FuncRequest const & ev) +dispatch_result +UpdatableInset::priv_dispatch(FuncRequest const & ev, idx_type &, pos_type &) { if (ev.action == LFUN_MOUSE_RELEASE) return (editable() == IS_EDITABLE) ? DISPATCHED : UNDISPATCHED; diff --git a/src/insets/updatableinset.h b/src/insets/updatableinset.h index ba795e8759..608f7a24d4 100644 --- a/src/insets/updatableinset.h +++ b/src/insets/updatableinset.h @@ -81,8 +81,6 @@ public: virtual bool unlockInsetInInset(BufferView *, UpdatableInset *, bool /*lr*/ = false) { return false; } - /// An updatable inset could handle lyx editing commands - virtual dispatch_result localDispatch(FuncRequest const & cmd); // We need this method to not clobber the real method in Inset int scroll(bool recursive = true) const { return InsetOld::scroll(recursive); } @@ -113,6 +111,10 @@ public: bool = true, bool = false); protected: + /// An updatable inset could handle lyx editing commands + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &); /// scrolls to absolute position in bufferview-workwidth * sx units void scroll(BufferView *, float sx) const; /// scrolls offset pixels diff --git a/src/lyxfunc.C b/src/lyxfunc.C index ad7ddef297..d1b6a02da9 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -317,7 +317,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const } else { // no setStatusMessage(N_("Command not allowed with" - "out any document open")); + "out any document open")); return flag.disabled(true); } } @@ -931,7 +931,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose) } // Hand-over to inset's own dispatch: - result = inset->localDispatch(FuncRequest(view(), action, argument)); + result = inset->dispatch(FuncRequest(view(), action, argument)); if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) { goto exit_with_message; } @@ -1409,7 +1409,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose) view()->unlockInset(view()->theLockingInset()); if (par->inInset()) { FuncRequest cmd(view(), LFUN_INSET_EDIT, "left"); - par->inInset()->localDispatch(cmd); + par->inInset()->dispatch(cmd); } // Set the cursor view()->getLyXText()->setCursor(par.pit(), 0); @@ -1498,7 +1498,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose) InsetOld * inset = lt->getInset(); if (inset) { FuncRequest cmd(view(), LFUN_INSET_DIALOG_SHOW); - inset->localDispatch(cmd); + inset->dispatch(cmd); } } break; @@ -1510,7 +1510,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose) if (inset) { FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE, func.argument); - inset->localDispatch(fr); + inset->dispatch(fr); } else if (name == "paragraph") { dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE)); } @@ -1647,7 +1647,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose) break; case LFUN_EXTERNAL_EDIT: { - InsetExternal().localDispatch(FuncRequest(view(), action, argument)); + InsetExternal().dispatch(FuncRequest(view(), action, argument)); break; } diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index d2f91ba06a..514983b19f 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,16 @@ +2003-10-17 Lars Gullik Bjønnes + + * ref_inset.C (priv_dispatch): take the code from localDispatch + into this + (localDispatch): delete + + * math_nestinset.C (dispatch): + * math_hullinset.C (dispatch): + * math_gridinset.C (dispatch): + * formulabase.C (openNewInset, priv_dispatch, mathDispatch): + * command_inset.C (dispatch): adjust for localDispatch -> dispatch and + priv_dispatch + 2003-10-14 Angus Leeming * insetformulabase.[Ch] (view, cache, view_): remove the BufferView cache. @@ -11,7 +24,7 @@ 2003-10-13 Angus Leeming - * formula.C (editing_inset): pass a pointer rather than a reference. + * formula.C (editing_inset): pass a pointer rather than a reference. 2003-10-13 Angus Leeming diff --git a/src/mathed/command_inset.C b/src/mathed/command_inset.C index e8f97a5e00..811f2d17c1 100644 --- a/src/mathed/command_inset.C +++ b/src/mathed/command_inset.C @@ -57,7 +57,7 @@ CommandInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos) { switch (cmd.action) { default: - return MathNestInset::dispatch(cmd, idx, pos); + return MathNestInset::priv_dispatch(cmd, idx, pos); } return UNDISPATCHED; } diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 25c3bc8a26..495f412781 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -66,7 +66,7 @@ bool openNewInset(BufferView * bv, UpdatableInset * new_inset) delete new_inset; return false; } - new_inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT, "left")); + new_inset->dispatch(FuncRequest(bv, LFUN_INSET_EDIT, "left")); return true; } @@ -316,7 +316,9 @@ dispatch_result InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd) } -dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) +dispatch_result +InsetFormulaBase::priv_dispatch(FuncRequest const & cmd, + idx_type &, pos_type &) { //lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action // << " arg: '" << cmd.argument @@ -359,7 +361,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) return lfunMouseRelease(cmd); case LFUN_MOUSE_DOUBLE: //lyxerr << "Mouse double" << endl; - return localDispatch(FuncRequest(LFUN_WORDSEL)); + return dispatch(FuncRequest(LFUN_WORDSEL)); default: break; } @@ -710,7 +712,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) if (base) { FuncRequest fr(bv, LFUN_INSET_MODIFY, cmd.argument); - result = base->localDispatch(fr); + result = base->dispatch(fr); } else { MathArray ar; if (createMathInset_fromDialogStr(cmd.argument, ar)) { @@ -906,13 +908,13 @@ void mathDispatchCreation(FuncRequest const & cmd, bool display) InsetFormula * f = new InsetFormula(bv); if (openNewInset(bv, f)) { bv->theLockingInset()-> - localDispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple")); + dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple")); // don't do that also for LFUN_MATH_MODE unless you want end up with // always changing to mathrm when opening an inlined inset // -- I really hate "LyXfunc overloading"... if (display) - f->localDispatch(FuncRequest(bv, LFUN_MATH_DISPLAY)); - f->localDispatch(FuncRequest(bv, LFUN_INSERT_MATH, cmd.argument)); + f->dispatch(FuncRequest(bv, LFUN_MATH_DISPLAY)); + f->dispatch(FuncRequest(bv, LFUN_INSERT_MATH, cmd.argument)); } } else { // create a macro if we see "\\newcommand" somewhere, and an ordinary @@ -969,8 +971,8 @@ void mathDispatch(FuncRequest const & cmd) InsetFormula * f = new InsetFormula(bv); if (openNewInset(bv, f)) { bv->theLockingInset()-> - localDispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple")); - bv->theLockingInset()->localDispatch(cmd); + dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple")); + bv->theLockingInset()->dispatch(cmd); } break; } diff --git a/src/mathed/formulabase.h b/src/mathed/formulabase.h index 904f46e18b..885ba98da1 100644 --- a/src/mathed/formulabase.h +++ b/src/mathed/formulabase.h @@ -55,8 +55,6 @@ public: /// virtual void insetUnlock(BufferView *); - /// To allow transparent use of math editing functions - virtual dispatch_result localDispatch(FuncRequest const &); /// To allow transparent use of math editing functions //virtual void status(FuncRequest const &); @@ -83,7 +81,11 @@ public: bool display() const; // return the selection as std::string std::string selectionAsString() const; - +protected: + /// To allow transparent use of math editing functions + virtual + dispatch_result + priv_dispatch(FuncRequest const &, idx_type &, pos_type &); private: /// unimplemented void operator=(const InsetFormulaBase &); diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index 785995c4d3..7dd20d53f1 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -1187,6 +1187,6 @@ dispatch_result MathGridInset::dispatch } default: - return MathNestInset::dispatch(cmd, idx, pos); + return MathNestInset::priv_dispatch(cmd, idx, pos); } } diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 48f874db5f..4761fe6376 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -783,7 +783,7 @@ dispatch_result MathHullInset::dispatch pos = 0; return DISPATCHED_POP; } - return MathGridInset::dispatch(cmd, idx, pos); + return MathGridInset::priv_dispatch(cmd, idx, pos); case LFUN_MATH_NUMBER: //lyxerr << "toggling all numbers" << endl; @@ -858,7 +858,7 @@ dispatch_result MathHullInset::dispatch } default: - return MathGridInset::dispatch(cmd, idx, pos); + return MathGridInset::priv_dispatch(cmd, idx, pos); } } diff --git a/src/mathed/math_nestinset.C b/src/mathed/math_nestinset.C index 7962164594..a603b4d0f5 100644 --- a/src/mathed/math_nestinset.C +++ b/src/mathed/math_nestinset.C @@ -311,7 +311,7 @@ dispatch_result MathNestInset::dispatch return UNDISPATCHED; default: - return MathInset::dispatch(cmd, idx, pos); + return MathInset::priv_dispatch(cmd, idx, pos); } } @@ -355,5 +355,3 @@ void MathNestInset::drawMarkers2(PainterInfo & pi, int x, int y) const pi.pain.line(x, a, x + 3, a, LColor::mathframe); pi.pain.line(t - 3, a, t, a, LColor::mathframe); } - - diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index 89529c9cad..524a2d5801 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -529,5 +529,5 @@ dispatch_result MathScriptInset::dispatch return DISPATCHED; } - return MathNestInset::dispatch(cmd, idx, pos); + return MathNestInset::priv_dispatch(cmd, idx, pos); } diff --git a/src/mathed/ref_inset.C b/src/mathed/ref_inset.C index b502fedc67..d762e5060f 100644 --- a/src/mathed/ref_inset.C +++ b/src/mathed/ref_inset.C @@ -53,30 +53,41 @@ void RefInset::infoize(std::ostream & os) const dispatch_result -RefInset::dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos) +RefInset::priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos) { switch (cmd.action) { - case LFUN_MOUSE_RELEASE: - if (cmd.button() == mouse_button::button3) { - lyxerr << "trying to goto ref" << cell(0) << endl; - cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0)))); - return DISPATCHED; - } - if (cmd.button() == mouse_button::button1) { - // Eventually trigger dialog with button 3 - // not 1 - string const data = createDialogStr("ref"); - cmd.view()->owner()->getDialogs(). - show("ref", data, this); - return DISPATCHED; - } - break; - case LFUN_MOUSE_PRESS: - case LFUN_MOUSE_MOTION: - // eat other mouse commands + case LFUN_INSET_MODIFY: + if (cmd.getArg(0) == "ref") { + MathArray ar; + if (!createMathInset_fromDialogStr(cmd.argument, ar)) + return UNDISPATCHED; + + *this = *ar[0].nucleus()->asRefInset(); + + return DISPATCHED; + } + break; + case LFUN_MOUSE_RELEASE: + if (cmd.button() == mouse_button::button3) { + lyxerr << "trying to goto ref" << cell(0) << endl; + cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0)))); return DISPATCHED; - default: - return CommandInset::dispatch(cmd, idx, pos); + } + if (cmd.button() == mouse_button::button1) { + // Eventually trigger dialog with button 3 + // not 1 + string const data = createDialogStr("ref"); + cmd.view()->owner()->getDialogs(). + show("ref", data, this); + return DISPATCHED; + } + break; + case LFUN_MOUSE_PRESS: + case LFUN_MOUSE_MOTION: + // eat other mouse commands + return DISPATCHED; + default: + return CommandInset::priv_dispatch(cmd, idx, pos); } // not our business return UNDISPATCHED; @@ -138,22 +149,6 @@ int RefInset::docbook(std::ostream & os, bool) const } -dispatch_result RefInset::localDispatch(FuncRequest const & cmd) -{ - if (cmd.action != LFUN_INSET_MODIFY || cmd.getArg(0) != "ref") - return UNDISPATCHED; - - MathArray ar; - if (!createMathInset_fromDialogStr(cmd.argument, ar)) - return UNDISPATCHED; - - *this = *ar[0].nucleus()->asRefInset(); -// if (cmd.view()) -// // This does not compile because updateInset expects -// // an Inset* and 'this' isn't. -// cmd.view()->updateInset(this); - return DISPATCHED; -} RefInset::ref_type_info RefInset::types[] = { diff --git a/src/mathed/ref_inset.h b/src/mathed/ref_inset.h index a70f3f3c42..3a5d327ba2 100644 --- a/src/mathed/ref_inset.h +++ b/src/mathed/ref_inset.h @@ -29,8 +29,6 @@ public: /// void infoize(std::ostream & os) const; /// - dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos); - /// std::string const screenLabel() const; /// void validate(LaTeXFeatures & features) const; @@ -60,6 +58,11 @@ public: static int getType(std::string const & name); /// static std::string const & getName(int type); +protected: + /// + virtual + dispatch_result + priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos); }; #endif diff --git a/src/text.C b/src/text.C index 60f68e56db..6baf7f4b6c 100644 --- a/src/text.C +++ b/src/text.C @@ -1639,7 +1639,7 @@ WordLangTuple const LyXText::selectNextWordToSpellcheck(float & value) cursorPar()->isInset(cursor.pos())) { // lock the inset! FuncRequest cmd(bv(), LFUN_INSET_EDIT, "left"); - cursorPar()->getInset(cursor.pos())->localDispatch(cmd); + cursorPar()->getInset(cursor.pos())->dispatch(cmd); // now call us again to do the above trick // but obviously we have to start from down below ;) return bv()->text->selectNextWordToSpellcheck(value); @@ -2191,4 +2191,3 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim) dim.des = height - dim.asc; dim.wid = std::max(mi.base.textwidth, int(width)); } - diff --git a/src/text2.C b/src/text2.C index 3f6bd33901..3215791e64 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1624,7 +1624,7 @@ void LyXText::cursorUp(bool selecting) y -= topy; InsetOld * inset_hit = checkInsetHit(x, y1); if (inset_hit && isHighlyEditableInset(inset_hit)) { - inset_hit->localDispatch( + inset_hit->dispatch( FuncRequest(bv(), LFUN_INSET_EDIT, x, y - (y2 - y1), mouse_button::none)); } } @@ -1651,7 +1651,7 @@ void LyXText::cursorDown(bool selecting) InsetOld * inset_hit = checkInsetHit(x, y1); if (inset_hit && isHighlyEditableInset(inset_hit)) { FuncRequest cmd(bv(), LFUN_INSET_EDIT, x, y - (y2 - y1), mouse_button::none); - inset_hit->localDispatch(cmd); + inset_hit->dispatch(cmd); } } #else diff --git a/src/text3.C b/src/text3.C index de5a282b11..4b83a107e3 100644 --- a/src/text3.C +++ b/src/text3.C @@ -380,7 +380,7 @@ void doInsertInset(LyXText * lt, FuncRequest const & cmd, if (bv->insertInset(inset)) { if (edit) { FuncRequest cmd(bv, LFUN_INSET_EDIT, "left"); - inset->localDispatch(cmd); + inset->dispatch(cmd); } if (gotsel && pastesel) bv->owner()->dispatch(FuncRequest(LFUN_PASTE)); @@ -598,7 +598,7 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd) InsetOld * tmpinset = cursorPar()->getInset(cursor.pos()); cmd.message(tmpinset->editMessage()); FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "right" : "left"); - tmpinset->localDispatch(cmd1); + tmpinset->dispatch(cmd1); break; } if (!is_rtl) @@ -623,7 +623,7 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd) InsetOld * tmpinset = cursorPar()->getInset(cursor.pos()); cmd.message(tmpinset->editMessage()); FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "left" : "right"); - tmpinset->localDispatch(cmd1); + tmpinset->dispatch(cmd1); break; } if (is_rtl) @@ -1223,7 +1223,7 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd) FuncRequest cmd1 = cmd; cmd1.x = cmd.x - start_x; cmd1.y = cmd.y - cursor.y() + bv->top_y(); - tli->localDispatch(cmd1); + tli->dispatch(cmd1); break; } @@ -1302,7 +1302,7 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd) // otherwise give the event to the inset if (inset_hit == bv->theLockingInset()) { FuncRequest cmd1(bv, LFUN_MOUSE_PRESS, x, y, cmd.button()); - bv->theLockingInset()->localDispatch(cmd1); + bv->theLockingInset()->dispatch(cmd1); break; } bv->unlockInset(bv->theLockingInset()); @@ -1326,7 +1326,7 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd) if (!bv->lockInset(inset)) lyxerr[Debug::INSETS] << "Cannot lock inset" << endl; FuncRequest cmd1(bv, LFUN_MOUSE_PRESS, x, y, cmd.button()); - inset->localDispatch(cmd1); + inset->dispatch(cmd1); break; } // I'm not sure we should continue here if we hit an inset (Jug20020403) @@ -1383,7 +1383,7 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd) // Only a ButtonPress FuncRequest outside the inset will // force a insetUnlock. FuncRequest cmd1(bv, LFUN_MOUSE_RELEASE, x, y, cmd.button()); - bv->theLockingInset()->localDispatch(cmd1); + bv->theLockingInset()->dispatch(cmd1); break; } @@ -1440,7 +1440,7 @@ dispatch_result LyXText::dispatch(FuncRequest const & cmd) bv->owner()->message(inset_hit->editMessage()); FuncRequest cmd1(bv, LFUN_MOUSE_RELEASE, x, y, cmd.button()); - inset_hit->localDispatch(cmd1); + inset_hit->dispatch(cmd1); } break; -- 2.39.2