diff --git a/src/BufferView.C b/src/BufferView.C index e126352f4a..4d998fbc73 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -649,7 +649,8 @@ bool BufferView::lockInset(UpdatableInset * inset) } if (it.getInset()->getInsetFromID(id)) { text->setCursorIntern(pit, it.getPos()); - it.getInset()->edit(this); + FuncRequest cmd(this, LFUN_INSET_EDIT, "left"); + it.getInset()->localDispatch(cmd); return theLockingInset()->lockInsetInInset(this, inset); } } diff --git a/src/ChangeLog b/src/ChangeLog index cb2f9e8ecd..1357a0bb2d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,4 +1,13 @@ +2003-05-16 André Pönitz + + * BufferView.C: + * lyxfunc.C: + * text.C: + * text2.C: + * text3.C: + * undo_funcs.C: edit() -> LFUN_INSET_EDIT + 2003-05-14 Alfredo Braunstein * lyx_main.C (init): remove spurious static_cast diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index c7b59c7ab2..fffb773cf9 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,4 +1,31 @@ + +2003-05-16 André Pönitz + + * inset.[Ch]: + * insetbibitem.[Ch]: + * insetbibtex.[Ch]: + * insetbutton.[Ch]: + * insetcite.[Ch]: + * insetcollapsable.[Ch]: + * insetcommand.[Ch]: + * inseterror.[Ch]: + * insetert.[Ch]: + * insetexternal.[Ch]: + * insetfloatlist.[Ch]: + * insetgraphics.[Ch]: + * insetinclude.[Ch]: + * insetindex.[Ch]: + * insetlabel.[Ch]: + * insetlatexaccent.[Ch]: + * insetparent.[Ch]: + * insetref.[Ch]: + * insettabular.[Ch]: + * insettext.[Ch]: + * insettoc.[Ch]: + * inseturl.[Ch]: + * updatableinset.[Ch]: edit() -> LFUN_INSET_EDIT + 2003-05-13 André Pönitz * insetbibitem.C: diff --git a/src/insets/inset.C b/src/insets/inset.C index ff8d77a51f..5c89fc89f8 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -29,7 +29,6 @@ using std::endl; -// Insets default methods // Initialization of the counter for the inset id's, unsigned int Inset::inset_id = 0; @@ -66,10 +65,6 @@ Inset::EDITABLE Inset::editable() const } -void Inset::edit(BufferView *, int, int, mouse_button::state) -{} - - void Inset::validate(LaTeXFeatures &) const {} @@ -80,10 +75,6 @@ bool Inset::autoDelete() const } -void Inset::edit(BufferView *, bool) -{} - - #if 0 LyXFont const Inset::convertFont(LyXFont const & font) const { @@ -143,10 +134,10 @@ void Inset::setFont(BufferView *, LyXFont const &, bool, bool) {} -bool Inset::forceDefaultParagraphs(Inset const * in) const +bool Inset::forceDefaultParagraphs(Inset const * inset) const { if (owner()) - return owner()->forceDefaultParagraphs(in); + return owner()->forceDefaultParagraphs(inset); return false; } diff --git a/src/insets/inset.h b/src/insets/inset.h index a1e36f39c8..b306b35f2b 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -15,14 +15,14 @@ #ifndef INSET_H #define INSET_H - -#include #include "LString.h" #include "LColor.h" #include "insetbase.h" #include "frontends/mouse_state.h" #include "support/types.h" +#include + class LyXFont; class Buffer; class Painter; @@ -170,10 +170,6 @@ public: /// what appears in the minibuffer when opening virtual string const editMessage() const; /// - virtual void edit(BufferView *, int x, int y, mouse_button::state button); - /// - virtual void edit(BufferView *, bool front = true); - /// virtual EDITABLE editable() const; /// virtual bool isTextInset() const { return false; } diff --git a/src/insets/insetbibitem.C b/src/insets/insetbibitem.C index 71b49ac8d8..37372d1676 100644 --- a/src/insets/insetbibitem.C +++ b/src/insets/insetbibitem.C @@ -27,6 +27,7 @@ using std::max; int InsetBibitem::key_counter = 0; const string key_prefix = "key-"; + InsetBibitem::InsetBibitem(InsetCommandParams const & p) : InsetCommand(p), counter(1) { @@ -52,14 +53,17 @@ Inset * InsetBibitem::clone(Buffer const &, bool) const dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd) { - Inset::RESULT result = UNDISPATCHED; - switch (cmd.action) { + + case LFUN_INSET_EDIT: + InsetCommandMailer("bibitem", *this).showDialog(cmd.view()); + return DISPATCHED; + case LFUN_INSET_MODIFY: { InsetCommandParams p; InsetCommandMailer::string2params(cmd.argument, p); if (p.getCmdName().empty()) - break; + return DISPATCHED; if (view() && p.getContents() != params().getContents()) { view()->ChangeCitationsIfUnique(params().getContents(), @@ -75,15 +79,12 @@ dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd) #warning and whether the repaint() is needed at all cmd.view()->repaint(); cmd.view()->fitCursor(); - - result = DISPATCHED; + return DISPATCHED; } - break; + default: - result = InsetCommand::localDispatch(cmd); + return InsetCommand::localDispatch(cmd); } - - return result; } @@ -135,19 +136,6 @@ string const InsetBibitem::getScreenLabel(Buffer const *) const } -void InsetBibitem::edit(BufferView * bv, int, int, mouse_button::state) -{ - InsetCommandMailer mailer("bibitem", *this); - mailer.showDialog(bv); -} - - -void InsetBibitem::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); -} - - // ale070405 This function maybe shouldn't be here. We'll fix this at 0.13. int bibitemMaxWidth(BufferView * bv, LyXFont const & font) { diff --git a/src/insets/insetbibitem.h b/src/insets/insetbibitem.h index 8156b1ca7e..b1f15eae6f 100644 --- a/src/insets/insetbibitem.h +++ b/src/insets/insetbibitem.h @@ -41,10 +41,6 @@ public: /// virtual string const getScreenLabel(Buffer const *) const; /// - void edit(BufferView *, int x, int y, mouse_button::state button); - /// - void edit(BufferView * bv, bool front = true); - /// EDITABLE editable() const { return IS_EDITABLE; } /// Inset::Code lyxCode() const { return Inset::BIBITEM_CODE; } @@ -53,7 +49,7 @@ public: /// void setCounter(int); /// - int getCounter() const { return counter; } + int getCounter() const { return counter; } /// string const getBibLabel() const; /// diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index 8970efb576..21b54b9112 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -48,14 +48,17 @@ InsetBibtex::~InsetBibtex() dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd) { - Inset::RESULT result = UNDISPATCHED; - switch (cmd.action) { + + case LFUN_INSET_EDIT: + InsetCommandMailer("bibtex", *this).showDialog(cmd.view()); + return DISPATCHED; + case LFUN_INSET_MODIFY: { InsetCommandParams p; InsetCommandMailer::string2params(cmd.argument, p); if (p.getCmdName().empty()) - break; + return DISPATCHED; if (view() && p.getContents() != params().getContents()) { view()->ChangeCitationsIfUnique(params().getContents(), @@ -64,14 +67,13 @@ dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd) setParams(p); cmd.view()->updateInset(this); - result = DISPATCHED; - } - break; - default: - result = InsetCommand::localDispatch(cmd); + return DISPATCHED; + } + + default: + return InsetCommand::localDispatch(cmd); } - return result; } string const InsetBibtex::getScreenLabel(Buffer const *) const @@ -218,19 +220,6 @@ void InsetBibtex::fillWithBibKeys } -void InsetBibtex::edit(BufferView * bv, int, int, mouse_button::state) -{ - InsetCommandMailer mailer("bibtex", *this); - mailer.showDialog(bv); -} - - -void InsetBibtex::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); -} - - bool InsetBibtex::addDatabase(string const & db) { string contents(getContents()); diff --git a/src/insets/insetbibtex.h b/src/insets/insetbibtex.h index eaddf10fac..966e3afc9a 100644 --- a/src/insets/insetbibtex.h +++ b/src/insets/insetbibtex.h @@ -39,10 +39,6 @@ public: /// Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; } /// - void edit(BufferView *, int x, int y, mouse_button::state button); - /// - void edit(BufferView * bv, bool front = true); - /// int latex(Buffer const *, std::ostream &, bool fragile, bool freespace) const; /// diff --git a/src/insets/insetbutton.C b/src/insets/insetbutton.C index 9fa257d2e1..809f49cf77 100644 --- a/src/insets/insetbutton.C +++ b/src/insets/insetbutton.C @@ -132,7 +132,5 @@ BufferView * InsetButton::view() const dispatch_result InsetButton::localDispatch(FuncRequest const & cmd) { - FuncRequest cmd1(cmd); - edit(cmd1.view(), cmd1.x, cmd1.y, cmd1.button()); - return DISPATCHED; + return Inset::localDispatch(cmd); } diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index 8bd95bfdbe..419cf6f219 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -12,6 +12,7 @@ #include #include "insetcite.h" +#include "funcrequest.h" #include "buffer.h" #include "BufferView.h" #include "LaTeXFeatures.h" @@ -317,20 +318,20 @@ void InsetCitation::setLoadingBuffer(Buffer const * buffer, bool state) const } -void InsetCitation::edit(BufferView * bv, int, int, mouse_button::state) +dispatch_result InsetCitation::localDispatch(FuncRequest const & cmd) { - // A call to edit() indicates that we're no longer loading the - // buffer but doing some real work. - setLoadingBuffer(bv->buffer(), false); + switch (cmd.action) { + case LFUN_INSET_EDIT: + // A call to edit indicates that we're no longer loading the + // buffer but doing some real work. + setLoadingBuffer(cmd.view()->buffer(), false); + InsetCommandMailer("citation", *this).showDialog(cmd.view()); + break; - InsetCommandMailer mailer("citation", *this); - mailer.showDialog(bv); -} - - -void InsetCitation::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); + default: + return UNDISPATCHED; + } + return DISPATCHED; } diff --git a/src/insets/insetcite.h b/src/insets/insetcite.h index 3cec12c54d..587ba52564 100644 --- a/src/insets/insetcite.h +++ b/src/insets/insetcite.h @@ -35,14 +35,12 @@ public: /// Inset::Code lyxCode() const { return Inset::CITE_CODE; } /// - void edit(BufferView *, int, int, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); - /// int ascii(Buffer const *, std::ostream &, int linelen) const; /// int latex(Buffer const *, std::ostream &, bool, bool) const; /// + dispatch_result localDispatch(FuncRequest const & cmd); + /// void validate(LaTeXFeatures &) const; /** Invoked by BufferView::Pimpl::dispatch when a new citation key is inserted. Tells us that the buffer is no longer being loaded diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 07bb71e72f..ddac8d46c7 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -38,9 +38,6 @@ using std::endl; using std::max; -class LyXText; - - InsetCollapsable::InsetCollapsable(BufferParams const & bp, bool collapsed) : UpdatableInset(), collapsed_(collapsed), inset(bp), button_length(0), button_top_y(0), button_bottom_y(0), @@ -232,65 +229,6 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, } -void InsetCollapsable::edit(BufferView * bv, int xp, int yp, - mouse_button::state button) -{ -#ifdef WITH_WARNINGS -#warning Fix this properly in BufferView_pimpl::workAreaButtonRelease -#endif - if (button == mouse_button::button3) - return; - - UpdatableInset::edit(bv, xp, yp, button); - - if (collapsed_) { - collapsed_ = false; - // set this only here as it should be recollapsed only if - // it was already collapsed! - first_after_edit = true; - if (!bv->lockInset(this)) - return; - bv->updateInset(this); - bv->buffer()->markDirty(); - inset.edit(bv); - } else { - if (!bv->lockInset(this)) - return; - if (yp <= button_bottom_y) { - inset.edit(bv, xp, 0, button); - } else { - LyXFont font(LyXFont::ALL_SANE); - int yy = ascent(bv, font) + yp - - (ascent_collapsed() + - descent_collapsed() + - inset.ascent(bv, font)); - inset.edit(bv, xp, yy, button); - } - } -} - - -void InsetCollapsable::edit(BufferView * bv, bool front) -{ - UpdatableInset::edit(bv, front); - - if (collapsed_) { - collapsed_ = false; - if (!bv->lockInset(this)) - return; - inset.setUpdateStatus(bv, InsetText::FULL); - bv->updateInset(this); - bv->buffer()->markDirty(); - inset.edit(bv, front); - first_after_edit = true; - } else { - if (!bv->lockInset(this)) - return; - inset.edit(bv, front); - } -} - - Inset::EDITABLE InsetCollapsable::editable() const { if (collapsed_) @@ -425,7 +363,62 @@ void InsetCollapsable::update(BufferView * bv, bool reinit) Inset::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd) { + BufferView * bv = cmd.view(); switch (cmd.action) { + case LFUN_INSET_EDIT: { + if (!cmd.argument.empty()) { + UpdatableInset::localDispatch(cmd); + if (collapsed_) { + collapsed_ = false; + if (bv->lockInset(this)) { + inset.setUpdateStatus(bv, InsetText::FULL); + bv->updateInset(this); + bv->buffer()->markDirty(); + inset.localDispatch(cmd); + first_after_edit = true; + } + } else { + if (bv->lockInset(this)) + inset.localDispatch(cmd); + } + return DISPATCHED; + } + +#ifdef WITH_WARNINGS +#warning Fix this properly in BufferView_pimpl::workAreaButtonRelease +#endif + if (cmd.button() == mouse_button::button3) + return DISPATCHED; + + UpdatableInset::localDispatch(cmd); + + if (collapsed_) { + collapsed_ = false; + // set this only here as it should be recollapsed only if + // it was already collapsed! + first_after_edit = true; + if (!bv->lockInset(this)) + return DISPATCHED; + bv->updateInset(this); + bv->buffer()->markDirty(); + inset.localDispatch(cmd); + } else { + FuncRequest cmd1 = cmd; + if (!bv->lockInset(this)) + return DISPATCHED; + if (cmd.y <= button_bottom_y) { + cmd1.y = 0; + } else { + LyXFont font(LyXFont::ALL_SANE); + cmd1.y = ascent(bv, font) + cmd.y - + (ascent_collapsed() + + descent_collapsed() + + inset.ascent(bv, font)); + } + inset.localDispatch(cmd); + } + return DISPATCHED; + } case LFUN_MOUSE_PRESS: lfunMousePress(cmd); @@ -442,11 +435,10 @@ Inset::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd) default: UpdatableInset::RESULT result = inset.localDispatch(cmd); if (result >= FINISHED) - cmd.view()->unlockInset(this); + bv->unlockInset(this); first_after_edit = false; return result; } - return UNDISPATCHED; } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index b1d84ce018..d731060734 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -14,7 +14,6 @@ #ifndef INSETCOLLAPSABLE_H #define INSETCOLLAPSABLE_H - #include "inset.h" #include "insettext.h" #include "lyxfont.h" @@ -58,10 +57,6 @@ public: /// void update(BufferView *, bool =false); /// - void edit(BufferView *, int, int, mouse_button::state); - /// - void edit(BufferView *, bool front = true); - /// EDITABLE editable() const; /// bool insertInset(BufferView *, Inset * inset); diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 86203f397b..fda67c103b 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -67,38 +67,30 @@ int InsetCommand::docbook(Buffer const *, ostream &, bool) const dispatch_result InsetCommand::localDispatch(FuncRequest const & cmd) { - dispatch_result result = UNDISPATCHED; - + lyxerr << "insetCommand::localDispatch\n"; switch (cmd.action) { case LFUN_INSET_MODIFY: { InsetCommandParams p; InsetCommandMailer::string2params(cmd.argument, p); if (p.getCmdName().empty()) - break; + return UNDISPATCHED; setParams(p); cmd.view()->updateInset(this); - result = DISPATCHED; + return DISPATCHED; } - break; - case LFUN_INSET_DIALOG_UPDATE: { - InsetCommandMailer mailer(cmd.argument, *this); - mailer.updateDialog(cmd.view()); - result = DISPATCHED; - } - break; + case LFUN_INSET_DIALOG_UPDATE: + InsetCommandMailer(cmd.argument, *this).updateDialog(cmd.view()); + return DISPATCHED; case LFUN_MOUSE_RELEASE: - edit(cmd.view(), cmd.x, cmd.y, cmd.button()); - result = DISPATCHED; - break; + return localDispatch(FuncRequest(cmd.view(), LFUN_INSET_EDIT)); default: - break; + return UNDISPATCHED; } - return result; } diff --git a/src/insets/inseterror.C b/src/insets/inseterror.C index 38135356cd..1470506170 100644 --- a/src/insets/inseterror.C +++ b/src/insets/inseterror.C @@ -26,7 +26,6 @@ using std::ostream; -/* Error, used for the LaTeX-Error Messages */ InsetError::InsetError(string const & str, bool) : contents(str) @@ -44,15 +43,14 @@ dispatch_result InsetError::localDispatch(FuncRequest const & cmd) dispatch_result result = UNDISPATCHED; switch (cmd.action) { - case LFUN_MOUSE_RELEASE: - edit(cmd.view(), cmd.x, cmd.y, cmd.button()); - break; + case LFUN_MOUSE_RELEASE: + case LFUN_INSET_EDIT: + cmd.view()->owner()->getDialogs().show("error", getContents(), this); + return DISPATCHED; default: - break; + return Inset::localDispatch(cmd); } - - return result; } @@ -111,15 +109,3 @@ string const InsetError::editMessage() const { return _("Opened error"); } - - -void InsetError::edit(BufferView * bv, int, int, mouse_button::state) -{ - bv->owner()->getDialogs().show("error", getContents(), this); -} - - -void InsetError::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); -} diff --git a/src/insets/inseterror.h b/src/insets/inseterror.h index 8458186095..fa23e55fa4 100644 --- a/src/insets/inseterror.h +++ b/src/insets/inseterror.h @@ -12,7 +12,6 @@ #ifndef INSET_ERROR_H #define INSET_ERROR_H - #include "inset.h" #include "LString.h" @@ -55,10 +54,6 @@ public: /// what appears in the minibuffer when opening string const editMessage() const; /// - void edit(BufferView *, int, int, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); - /// EDITABLE editable() const { return IS_EDITABLE; } /// Inset * clone(Buffer const &, bool same_id = false) const { diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 62fedfe989..2c5db8d3ae 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -266,22 +266,6 @@ void InsetERT::updateStatus(BufferView * bv, bool swap) const } } -void InsetERT::edit(BufferView * bv, int x, int y, mouse_button::state button) -{ - if (button == mouse_button::button3) - return; - - if (status_ == Inlined) { - if (!bv->lockInset(this)) - return; - inset.edit(bv, x, y, button); - } else { - InsetCollapsable::edit(bv, x, y, button); - } - set_latex_font(bv); - updateStatus(bv); -} - Inset::EDITABLE InsetERT::editable() const { @@ -291,14 +275,6 @@ Inset::EDITABLE InsetERT::editable() const } -void InsetERT::edit(BufferView * bv, bool front) -{ - InsetCollapsable::edit(bv, front); - updateStatus(0); - set_latex_font(bv); -} - - void InsetERT::lfunMousePress(FuncRequest const & cmd) { if (status_ == Inlined) @@ -449,6 +425,21 @@ Inset::RESULT InsetERT::localDispatch(FuncRequest const & cmd) } switch (cmd.action) { + + case LFUN_INSET_EDIT: + if (cmd.button() == mouse_button::button3) + break; + if (status_ == Inlined) { + if (!bv->lockInset(this)) + break; + result = inset.localDispatch(cmd); + } else { + result = InsetCollapsable::localDispatch(cmd); + } + set_latex_font(bv); + updateStatus(bv); + break; + case LFUN_INSET_MODIFY: { InsetERT::ERTStatus status_; InsetERTMailer::string2params(cmd.argument, status_); diff --git a/src/insets/insetert.h b/src/insets/insetert.h index df6c19eb6b..e6cd89a1b7 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -62,10 +62,6 @@ public: void setFont(BufferView *, LyXFont const &, bool toggleall = false, bool selectall = false); /// - void edit(BufferView *, int, int, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); - /// EDITABLE editable() const; /// int latex(Buffer const *, std::ostream &, bool fragile, diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index aae22af7f8..fa27977806 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -34,7 +34,6 @@ #include #include - using std::ostream; using std::endl; @@ -64,37 +63,30 @@ InsetExternal::Params const & InsetExternal::params() const dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd) { - dispatch_result result = UNDISPATCHED; - switch (cmd.action) { + case LFUN_INSET_MODIFY: { InsetExternal::Params p; InsetExternalMailer::string2params(cmd.argument, p); - if (p.filename.empty()) - break; - - setFromParams(p); - cmd.view()->updateInset(this); - result = DISPATCHED; + if (!p.filename.empty()) { + setFromParams(p); + cmd.view()->updateInset(this); + } + return DISPATCHED; } - break; - case LFUN_INSET_DIALOG_UPDATE: { - InsetExternalMailer mailer(*this); - mailer.updateDialog(cmd.view()); - } - break; + case LFUN_INSET_DIALOG_UPDATE: + InsetExternalMailer(*this).updateDialog(cmd.view()); + return DISPATCHED; case LFUN_MOUSE_RELEASE: - edit(cmd.view(), cmd.x, cmd.y, cmd.button()); - result = DISPATCHED; - break; + case LFUN_INSET_EDIT: + InsetExternalMailer(*this).showDialog(cmd.view()); + return DISPATCHED; default: - break; + return UNDISPATCHED; } - - return result; } @@ -112,19 +104,6 @@ string const InsetExternal::editMessage() const } -void InsetExternal::edit(BufferView * bv, int, int, mouse_button::state) -{ - InsetExternalMailer mailer(*this); - mailer.showDialog(bv); -} - - -void InsetExternal::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); -} - - void InsetExternal::write(Buffer const *, ostream & os) const { os << "External " << params_.templ.lyxName << ",\"" diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index fe4f0eb622..930a9d904c 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -12,7 +12,6 @@ #ifndef INSET_EXTERNAL_H #define INSET_EXTERNAL_H - #include "insetbutton.h" #include "ExternalTemplate.h" #include "LString.h" @@ -42,10 +41,6 @@ public: /// what appears in the minibuffer when opening virtual string const editMessage() const; /// - virtual void edit(BufferView *, int x, int y, mouse_button::state button); - /// - virtual void edit(BufferView * bv, bool front = true); - /// virtual EDITABLE editable() const { return IS_EDITABLE; } /// virtual void write(Buffer const *, std::ostream &) const; diff --git a/src/insets/insetfloatlist.C b/src/insets/insetfloatlist.C index 32779cf771..0891b43cb4 100644 --- a/src/insets/insetfloatlist.C +++ b/src/insets/insetfloatlist.C @@ -15,6 +15,7 @@ #include "LaTeXFeatures.h" #include "lyxlex.h" #include "BufferView.h" +#include "funcrequest.h" #include "buffer.h" #include "toc.h" #include "gettext.h" @@ -23,9 +24,6 @@ #include "support/lstrings.h" -#include "frontends/Dialogs.h" -#include "frontends/LyXView.h" - using std::ostream; using std::endl; @@ -97,16 +95,15 @@ void InsetFloatList::read(Buffer const * buf, LyXLex & lex) } -void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state) +dispatch_result InsetFloatList::localDispatch(FuncRequest const & cmd) { - InsetCommandMailer mailer("toc", *this); - mailer.showDialog(bv); -} - - -void InsetFloatList::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); + switch (cmd.action) { + case LFUN_INSET_EDIT: + InsetCommandMailer("toc", *this).showDialog(cmd.view()); + return DISPATCHED; + default: + return InsetCommand::localDispatch(cmd); + } } diff --git a/src/insets/insetfloatlist.h b/src/insets/insetfloatlist.h index a5b7f68442..f5ec613dfc 100644 --- a/src/insets/insetfloatlist.h +++ b/src/insets/insetfloatlist.h @@ -30,12 +30,10 @@ public: return new InsetFloatList(getCmdName()); } /// + dispatch_result localDispatch(FuncRequest const & cmd); + /// string const getScreenLabel(Buffer const *) const; /// - void edit(BufferView * bv, int, int, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); - /// EDITABLE editable() const { return IS_EDITABLE; } /// bool display() const { return true; } diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 29c8dd28dc..f423210c58 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -68,6 +68,7 @@ TODO #include "funcrequest.h" #include "gettext.h" #include "LaTeXFeatures.h" +#include "Lsstream.h" #include "lyxlex.h" #include "lyxrc.h" #include "Lsstream.h" @@ -218,38 +219,30 @@ InsetGraphics::~InsetGraphics() dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd) { - dispatch_result result = UNDISPATCHED; - switch (cmd.action) { case LFUN_INSET_MODIFY: { InsetGraphicsParams p; InsetGraphicsMailer::string2params(cmd.argument, p); - if (p.filename.empty()) - break; - - string const filepath = cmd.view()->buffer()->filePath(); - setParams(p, filepath); - cmd.view()->updateInset(this); - result = DISPATCHED; + if (!p.filename.empty()) { + string const filepath = cmd.view()->buffer()->filePath(); + setParams(p, filepath); + cmd.view()->updateInset(this); + } + return DISPATCHED; } - break; - case LFUN_INSET_DIALOG_UPDATE: { - InsetGraphicsMailer mailer(*this); - mailer.updateDialog(cmd.view()); - } - break; + case LFUN_INSET_DIALOG_UPDATE: + InsetGraphicsMailer(*this).updateDialog(cmd.view()); + return DISPATCHED; + case LFUN_INSET_EDIT: case LFUN_MOUSE_RELEASE: - edit(cmd.view(), cmd.x, cmd.y, cmd.button()); - break; + InsetGraphicsMailer(*this).showDialog(cmd.view()); + return DISPATCHED; default: - result = DISPATCHED; - break; + return Inset::localDispatch(cmd); } - - return result; } @@ -420,19 +413,6 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font, } -void InsetGraphics::edit(BufferView * bv, int, int, mouse_button::state) -{ - InsetGraphicsMailer mailer(*this); - mailer.showDialog(bv); -} - - -void InsetGraphics::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); -} - - Inset::EDITABLE InsetGraphics::editable() const { return IS_EDITABLE; diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 868f6d623e..2acaa173d1 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -13,8 +13,6 @@ #ifndef INSET_GRAPHICS_H #define INSET_GRAPHICS_H - - #include "insets/inset.h" #include "insets/insetgraphicsParams.h" @@ -45,10 +43,6 @@ public: /// void draw(BufferView *, LyXFont const &, int, float &) const; /// - void edit(BufferView *, int, int, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); - /// EDITABLE editable() const; /// void write(Buffer const *, std::ostream &) const; diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 58c806bce1..1cb80029f3 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -112,38 +112,31 @@ InsetInclude::~InsetInclude() dispatch_result InsetInclude::localDispatch(FuncRequest const & cmd) { - dispatch_result result = UNDISPATCHED; - switch (cmd.action) { + case LFUN_INSET_MODIFY: { InsetInclude::Params p; InsetIncludeMailer::string2params(cmd.argument, p); - if (p.cparams.getCmdName().empty()) - break; - - set(p); - params_.masterFilename_ = cmd.view()->buffer()->fileName(); - - cmd.view()->updateInset(this); - result = DISPATCHED; + if (!p.cparams.getCmdName().empty()) { + set(p); + params_.masterFilename_ = cmd.view()->buffer()->fileName(); + cmd.view()->updateInset(this); + } + return DISPATCHED; } - break; - case LFUN_INSET_DIALOG_UPDATE: { - InsetIncludeMailer mailer(*this); - mailer.updateDialog(cmd.view()); - } - break; + case LFUN_INSET_DIALOG_UPDATE: + InsetIncludeMailer(*this).updateDialog(cmd.view()); + return DISPATCHED; case LFUN_MOUSE_RELEASE: - edit(cmd.view(), cmd.x, cmd.y, cmd.button()); - break; + case LFUN_INSET_EDIT: + InsetIncludeMailer(*this).showDialog(cmd.view()); + return DISPATCHED; default: - break; + return UNDISPATCHED; } - - return result; } @@ -155,11 +148,8 @@ InsetInclude::Params const & InsetInclude::params() const bool InsetInclude::Params::operator==(Params const & o) const { - if (cparams == o.cparams && flag == o.flag && - masterFilename_ == o.masterFilename_) - return true; - - return false; + return cparams == o.cparams && flag == o.flag && + masterFilename_ == o.masterFilename_; } @@ -209,19 +199,6 @@ Inset * InsetInclude::clone(Buffer const & buffer, bool) const } -void InsetInclude::edit(BufferView * bv, int, int, mouse_button::state) -{ - InsetIncludeMailer mailer(*this); - mailer.showDialog(bv); -} - - -void InsetInclude::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); -} - - void InsetInclude::write(Buffer const *, ostream & os) const { os << "Include " << params_.cparams.getCommand() << '\n' diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 6d04d8cd1f..99d930061e 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -12,7 +12,6 @@ #ifndef INSET_INCLUDE_H #define INSET_INCLUDE_H - #include "insetcommand.h" #include @@ -83,10 +82,6 @@ public: /// This returns the list of bibkeys on the child buffer void fillWithBibKeys(std::vector > & keys) const; /// - void edit(BufferView *, int x, int y, mouse_button::state button); - /// - void edit(BufferView * bv, bool front = true); - /// EDITABLE editable() const { return IS_EDITABLE; diff --git a/src/insets/insetindex.C b/src/insets/insetindex.C index c7f4b935eb..cbd6dd8495 100644 --- a/src/insets/insetindex.C +++ b/src/insets/insetindex.C @@ -12,6 +12,7 @@ #include "insetindex.h" #include "BufferView.h" +#include "funcrequest.h" #include "frontends/LyXView.h" #include "frontends/Dialogs.h" #include "LaTeXFeatures.h" @@ -38,16 +39,16 @@ string const InsetIndex::getScreenLabel(Buffer const *) const } -void InsetIndex::edit(BufferView * bv, int, int, mouse_button::state) +dispatch_result InsetIndex::localDispatch(FuncRequest const & cmd) { - InsetCommandMailer mailer("index", *this); - mailer.showDialog(bv); -} - - -void InsetIndex::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); + switch (cmd.action) { + case LFUN_INSET_EDIT: + InsetCommandMailer("index", *this).showDialog(cmd.view()); + return DISPATCHED; + + default: + return UNDISPATCHED; + } } @@ -65,11 +66,16 @@ Inset::Code InsetIndex::lyxCode() const } + InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool) : InsetCommand(p) {} +InsetPrintIndex::~InsetPrintIndex() +{} + + string const InsetPrintIndex::getScreenLabel(Buffer const *) const { return _("Index"); diff --git a/src/insets/insetindex.h b/src/insets/insetindex.h index 3f13751563..79ae38e58d 100644 --- a/src/insets/insetindex.h +++ b/src/insets/insetindex.h @@ -30,14 +30,12 @@ public: return new InsetIndex(params(), same_id); } /// + dispatch_result localDispatch(FuncRequest const & cmd); + /// string const getScreenLabel(Buffer const *) const; /// EDITABLE editable() const { return IS_EDITABLE; } /// - void edit(BufferView *, int, int, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); - /// Inset::Code lyxCode() const; /// int docbook(Buffer const *, std::ostream &, bool mixcont) const; @@ -49,16 +47,16 @@ public: /// InsetPrintIndex(InsetCommandParams const &, bool same_id = false); /// - virtual Inset * clone(Buffer const &, bool same_id = false) const { + ~InsetPrintIndex(); + /// + Inset * clone(Buffer const &, bool same_id = false) const { return new InsetPrintIndex(params(), same_id); } + /// + //dispatch_result localDispatch(FuncRequest const & cmd); /// Updates needed features for this inset. void validate(LaTeXFeatures & features) const; /// - void edit(BufferView *, int, int, mouse_button::state) {} - /// - void edit(BufferView *, bool = true) {} - /// EDITABLE editable() const { return NOT_EDITABLE; } /// bool display() const { return true; } diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 66963db350..128f4ac7f7 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -45,18 +45,17 @@ vector const InsetLabel::getLabelList() const } -void InsetLabel::edit(BufferView * bv, int, int, mouse_button::state) -{ - InsetCommandMailer mailer("label", *this); - mailer.showDialog(bv); -} - - dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd) { Inset::RESULT result = UNDISPATCHED; switch (cmd.action) { + + case LFUN_INSET_EDIT: + InsetCommandMailer("label", *this).showDialog(cmd.view()); + result = DISPATCHED; + break; + case LFUN_INSET_MODIFY: { InsetCommandParams p; InsetCommandMailer::string2params(cmd.argument, p); @@ -83,12 +82,6 @@ dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd) } -void InsetLabel::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); -} - - int InsetLabel::latex(Buffer const *, ostream & os, bool /*fragile*/, bool /*fs*/) const { diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index b4478c3d82..db4272070e 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -34,10 +34,6 @@ public: /// Inset::Code lyxCode() const { return Inset::LABEL_CODE; } /// - void edit(BufferView *, int, int, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); - /// std::vector const getLabelList() const; /// int latex(Buffer const *, std::ostream &, diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 50df0dd6f3..da4bbe4375 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -10,8 +10,8 @@ #include - #include "insetlatexaccent.h" + #include "debug.h" #include "lyxrc.h" #include "support/lstrings.h" @@ -24,6 +24,7 @@ using std::ostream; using std::endl; + /* LatexAccent. Proper handling of accented characters */ /* This part is done by Ivan Schreter, schreter@ccsun.tuke.sk */ /* Later modified by Lars G. Bjřnnes, larsbj@lyx.org */ @@ -95,7 +96,9 @@ void InsetLatexAccent::checkContents() lyxerr[Debug::KEY] << "Decode: " << contents << endl; - remdot = false; plusasc = false; plusdesc = false; + remdot = false; + plusasc = false; + plusdesc = false; switch (contents[1]) { // second char should be one of these case '\'': // acute diff --git a/src/insets/insetparent.C b/src/insets/insetparent.C index 556fdca8dc..7f1097ba6f 100644 --- a/src/insets/insetparent.C +++ b/src/insets/insetparent.C @@ -13,10 +13,7 @@ #include - - #include "insetparent.h" -#include "support/filetools.h" #include "BufferView.h" #include "frontends/LyXView.h" #include "support/LOstream.h" @@ -24,7 +21,8 @@ #include "buffer.h" #include "gettext.h" -#include "support/BoostFormat.h" +#include "support/filetools.h" +#include "support/lstrings.h" using std::ostream; @@ -39,24 +37,19 @@ InsetParent::InsetParent(InsetCommandParams const & p, Buffer const & bf, bool) string const InsetParent::getScreenLabel(Buffer const *) const { -#if USE_BOOST_FORMAT - return STRCONV(boost::io::str(boost::format(_("Parent: %s")) - % STRCONV(getContents()))); -#else - return _("Parent: ") + getContents(); -#endif + return bformat(_("Parent: %1$s"), getContents()); } -void InsetParent::edit(BufferView * bv, int, int, mouse_button::state) +dispatch_result InsetParent::localDispatch(FuncRequest const & cmd) { - bv->owner()->dispatch(FuncRequest(LFUN_CHILDOPEN, getContents())); -} - - -void InsetParent::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); + switch (cmd.action) { + case LFUN_INSET_EDIT: + cmd.view()->owner()->dispatch(FuncRequest(LFUN_CHILDOPEN, getContents())); + return DISPATCHED; + default: + return UNDISPATCHED; + } } diff --git a/src/insets/insetparent.h b/src/insets/insetparent.h index b47a2be3a3..1dc44baa7e 100644 --- a/src/insets/insetparent.h +++ b/src/insets/insetparent.h @@ -31,19 +31,17 @@ public: return new InsetParent(params(), buffer, same_id); } /// + dispatch_result localDispatch(FuncRequest const & cmd); + /// string const getScreenLabel(Buffer const *) const; /// EDITABLE editable() const { return IS_EDITABLE; } /// Inset::Code lyxCode() const { return Inset::PARENT_CODE; } /// - void edit(BufferView *, int, int, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); - /// int latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const; /// - void setParent(string fn) { setContents(fn); } + void setParent(string const & fn) { setContents(fn); } }; #endif diff --git a/src/insets/insetref.C b/src/insets/insetref.C index 42f57792f0..0231e58d7b 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -30,27 +30,28 @@ InsetRef::InsetRef(InsetCommandParams const & p, Buffer const & buf, bool) InsetRef::~InsetRef() { - InsetCommandMailer mailer("ref", *this); - mailer.hideDialog(); + InsetCommandMailer("ref", *this).hideDialog(); } -void InsetRef::edit(BufferView * bv, int, int, mouse_button::state button) +dispatch_result InsetRef::localDispatch(FuncRequest const & cmd) { - // FuncRequestually trigger dialog with button 3 not 1 - if (button == mouse_button::button3) - bv->owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents())); - else if (button == mouse_button::button1) { - InsetCommandMailer mailer("ref", *this); - mailer.showDialog(bv); + switch (cmd.action) { + case LFUN_INSET_EDIT: + // Eventually trigger dialog with button 3 not 1 + if (cmd.button() == mouse_button::button3) + cmd.view()->owner()-> + dispatch(FuncRequest(LFUN_REF_GOTO, getContents())); + if (cmd.button() == mouse_button::button1) + InsetCommandMailer("ref", *this).showDialog(cmd.view()); + return DISPATCHED; + + default: + return UNDISPATCHED; } } -void InsetRef::edit(BufferView *, bool) -{} - - string const InsetRef::getScreenLabel(Buffer const *) const { string temp; diff --git a/src/insets/insetref.h b/src/insets/insetref.h index 9a5dac30df..a54ea0313c 100644 --- a/src/insets/insetref.h +++ b/src/insets/insetref.h @@ -44,16 +44,14 @@ public: return new InsetRef(params(), buffer, same_id); } /// + dispatch_result localDispatch(FuncRequest const & cmd); + /// string const getScreenLabel(Buffer const *) const; /// EDITABLE editable() const { return IS_EDITABLE; } /// Inset::Code lyxCode() const { return Inset::REF_CODE; } /// - void edit(BufferView *, int, int, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); - /// bool display() const { return false; } /// int latex(Buffer const *, std::ostream &, diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 937841fb64..d13ee3a8a5 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -441,57 +441,6 @@ string const InsetTabular::editMessage() const } -void InsetTabular::edit(BufferView * bv, int x, int y, mouse_button::state button) -{ - UpdatableInset::edit(bv, x, y, button); - - if (!bv->lockInset(this)) { - lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl; - return; - } - locked = true; - the_locking_inset = 0; - inset_x = 0; - inset_y = 0; - setPos(bv, x, y); - clearSelection(); - finishUndo(); - if (insetHit(bv, x, y) && (button != mouse_button::button3)) { - activateCellInsetAbs(bv, x, y, button); - } -} - - -void InsetTabular::edit(BufferView * bv, bool front) -{ - UpdatableInset::edit(bv, front); - - if (!bv->lockInset(this)) { - lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl; - return; - } - finishUndo(); - locked = true; - the_locking_inset = 0; - inset_x = 0; - inset_y = 0; - if (front) { - if (isRightToLeft(bv)) - actcell = tabular->GetLastCellInRow(0); - else - actcell = 0; - } else { - if (isRightToLeft(bv)) - actcell = tabular->GetFirstCellInRow(tabular->rows()-1); - else - actcell = tabular->GetNumberOfCells() - 1; - } - clearSelection(); - resetPos(bv); - bv->fitCursor(); -} - - void InsetTabular::insetUnlock(BufferView * bv) { if (the_locking_inset) { @@ -556,7 +505,7 @@ bool InsetTabular::lockInsetInInset(BufferView * bv, UpdatableInset * inset) } if (in->getInsetFromID(id)) { actcell = i; - in->edit(bv); + in->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT)); return the_locking_inset->lockInsetInInset(bv, inset); } } @@ -777,8 +726,49 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd) // the_locking_inset->localDispatch might unlock it. old_locking_inset = the_locking_inset; RESULT result = UpdatableInset::localDispatch(cmd); - BufferView * bv = cmd.view(); + + if (cmd.action == LFUN_INSET_EDIT) { + + if (!bv->lockInset(this)) { + lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl; + return DISPATCHED; + } + + finishUndo(); + locked = true; + the_locking_inset = 0; + inset_x = 0; + inset_y = 0; + + if (cmd.argument.size()) { + if (cmd.argument == "left") { + if (isRightToLeft(bv)) + actcell = tabular->GetLastCellInRow(0); + else + actcell = 0; + } else { + if (isRightToLeft(bv)) + actcell = tabular->GetFirstCellInRow(tabular->rows()-1); + else + actcell = tabular->GetNumberOfCells() - 1; + } + clearSelection(); + resetPos(bv); + bv->fitCursor(); + } + + else { + setPos(bv, cmd.x, cmd.y); + clearSelection(); + finishUndo(); + if (insetHit(bv, cmd.x, cmd.y) && cmd.button() != mouse_button::button3) { + activateCellInsetAbs(bv, cmd.x, cmd.y, cmd.button()); + } + } + return DISPATCHED; + } + if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) { resetPos(bv); return result; @@ -2082,7 +2072,7 @@ bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, mouse_button } //inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell); //inset_y = cursor.y(); - inset->edit(bv, x, y, button); + inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT, x, y, button)); if (!the_locking_inset) return false; updateLocal(bv, CELL); @@ -2574,7 +2564,7 @@ InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const // otherwise we have to lock the next inset and ask for it's selecttion UpdatableInset * inset = static_cast(tabular->GetCellInset(actcell)); - inset->edit(bv, 0, 0, mouse_button::none); + inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT)); WordLangTuple word(selectNextWordInt(bv, value)); nodraw(false); if (!word.word().empty()) @@ -2600,7 +2590,7 @@ WordLangTuple InsetTabular::selectNextWordInt(BufferView * bv, float & value) co // otherwise we have to lock the next inset and ask for it's selecttion UpdatableInset * inset = static_cast(tabular->GetCellInset(++actcell)); - inset->edit(bv); + inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT)); return selectNextWordInt(bv, value); } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 116c5a73b0..b1992c9cca 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -45,7 +45,6 @@ #ifndef INSETTABULAR_H #define INSETTABULAR_H - #include "inset.h" #include "tabular.h" #include "LString.h" @@ -97,10 +96,6 @@ public: void update(BufferView *, bool = false); /// string const editMessage() const; - /// - void edit(BufferView *, int x, int y, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); // void insetUnlock(BufferView *); /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 90a2b6f26d..51eac4683a 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -71,6 +71,7 @@ using std::for_each; using lyx::pos_type; using lyx::textclass_type; + // These functions should probably go into bufferview_funcs somehow (Jug) void InsetText::saveLyXTextState(LyXText * t) const @@ -598,109 +599,6 @@ string const InsetText::editMessage() const } -void InsetText::edit(BufferView * bv, int x, int y, mouse_button::state button) -{ - UpdatableInset::edit(bv, x, y, button); - - if (!bv->lockInset(this)) { - lyxerr[Debug::INSETS] << "Cannot lock inset" << endl; - return; - } - locked = true; - the_locking_inset = 0; - inset_pos = inset_x = inset_y = 0; - inset_boundary = false; - inset_par = 0; - old_par = 0; - int tmp_y = (y < 0) ? 0 : y; - bool clear = false; - if (!lt) { - lt = getLyXText(bv); - clear = true; - } - // we put here -1 and not button as now the button in the - // edit call should not be needed we will fix this in 1.3.x - // cycle hopefully (Jug 20020509) - // FIXME: GUII I've changed this to none: probably WRONG - if (!checkAndActivateInset(bv, x, tmp_y, mouse_button::none)) { - lt->setCursorFromCoordinates(x - drawTextXOffset, - y + insetAscent); - lt->cursor.x_fix(lt->cursor.x()); - } - lt->clearSelection(); - finishUndo(); - // If the inset is empty set the language of the current font to the - // language to the surronding text (if different). - if (paragraphs.begin()->empty() && - boost::next(paragraphs.begin()) == paragraphs.end()&& - bv->getParentLanguage(this) != lt->current_font.language()) - { - LyXFont font(LyXFont::ALL_IGNORE); - font.setLanguage(bv->getParentLanguage(this)); - setFont(bv, font, false); - } - if (clear) - lt = 0; - - int code = CURSOR; - if (drawFrame_ == LOCKED) - code = CURSOR|DRAW_FRAME; - updateLocal(bv, code, false); - - // Tell the paragraph dialog that we've entered an insettext. - bv->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE)); -} - - -void InsetText::edit(BufferView * bv, bool front) -{ - UpdatableInset::edit(bv, front); - - if (!bv->lockInset(this)) { - lyxerr[Debug::INSETS] << "Cannot lock inset" << endl; - return; - } - locked = true; - the_locking_inset = 0; - inset_pos = inset_x = inset_y = 0; - inset_boundary = false; - inset_par = 0; - old_par = 0; - bool clear = false; - if (!lt) { - lt = getLyXText(bv); - clear = true; - } - if (front) - lt->setCursor(paragraphs.begin(), 0); - else { - ParagraphList::iterator it = paragraphs.begin(); - ParagraphList::iterator end = paragraphs.end(); - while (boost::next(it) != end) - ++it; -// int const pos = (p->size() ? p->size()-1 : p->size()); - lt->setCursor(it, it->size()); - } - lt->clearSelection(); - finishUndo(); - // If the inset is empty set the language of the current font to the - // language to the surronding text (if different). - if (paragraphs.begin()->empty() && - boost::next(paragraphs.begin()) == paragraphs.end() && - bv->getParentLanguage(this) != lt->current_font.language()) { - LyXFont font(LyXFont::ALL_IGNORE); - font.setLanguage(bv->getParentLanguage(this)); - setFont(bv, font, false); - } - if (clear) - lt = 0; - int code = CURSOR; - if (drawFrame_ == LOCKED) - code = CURSOR|DRAW_FRAME; - updateLocal(bv, code, false); -} - - void InsetText::insetUnlock(BufferView * bv) { if (the_locking_inset) { @@ -812,7 +710,7 @@ bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset) } if (it.getInset()->getInsetFromID(id)) { getLyXText(bv)->setCursorIntern(pit, it.getPos()); - it.getInset()->edit(bv); + it.getInset()->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT)); return the_locking_inset->lockInsetInInset(bv, inset); } } @@ -1090,18 +988,91 @@ void InsetText::lfunMouseMotion(FuncRequest const & cmd) } -Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) +Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd) { - BufferView * bv = ev.view(); - switch (ev.action) { + BufferView * bv = cmd.view(); + + if (cmd.action == LFUN_INSET_EDIT) { + UpdatableInset::localDispatch(cmd); + + if (!bv->lockInset(this)) { + lyxerr[Debug::INSETS] << "Cannot lock inset" << endl; + return DISPATCHED; + } + + locked = true; + the_locking_inset = 0; + inset_pos = inset_x = inset_y = 0; + inset_boundary = false; + inset_par = 0; + old_par = 0; + + bool clear = false; + if (!lt) { + lt = getLyXText(bv); + clear = true; + } + + if (cmd.argument.size()) { + if (cmd.argument == "left") + lt->setCursor(paragraphs.begin(), 0); + else { + ParagraphList::iterator it = paragraphs.begin(); + ParagraphList::iterator end = paragraphs.end(); + while (boost::next(it) != end) + ++it; + // int const pos = (p->size() ? p->size()-1 : p->size()); + lt->setCursor(it, it->size()); + } + } else { + int tmp_y = (cmd.y < 0) ? 0 : cmd.y; + // we put here -1 and not button as now the button in the + // edit call should not be needed we will fix this in 1.3.x + // cycle hopefully (Jug 20020509) + // FIXME: GUII I've changed this to none: probably WRONG + if (!checkAndActivateInset(bv, cmd.x, tmp_y, mouse_button::none)) { + lt->setCursorFromCoordinates(cmd.x - drawTextXOffset, + cmd.y + insetAscent); + lt->cursor.x_fix(lt->cursor.x()); + } + } + + lt->clearSelection(); + finishUndo(); + + // If the inset is empty set the language of the current font to the + // language to the surronding text (if different). + if (paragraphs.begin()->empty() && + boost::next(paragraphs.begin()) == paragraphs.end()&& + bv->getParentLanguage(this) != lt->current_font.language()) + { + LyXFont font(LyXFont::ALL_IGNORE); + font.setLanguage(bv->getParentLanguage(this)); + setFont(bv, font, false); + } + + if (clear) + lt = 0; + int code = CURSOR; + if (drawFrame_ == LOCKED) + code = CURSOR | DRAW_FRAME; + + updateLocal(bv, code, false); + // Tell the paragraph dialog that we've entered an insettext. + bv->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE)); + return DISPATCHED; + } + + + switch (cmd.action) { case LFUN_MOUSE_PRESS: - lfunMousePress(ev); + lfunMousePress(cmd); return DISPATCHED; case LFUN_MOUSE_MOTION: - lfunMouseMotion(ev); + lfunMouseMotion(cmd); return DISPATCHED; case LFUN_MOUSE_RELEASE: - return lfunMouseRelease(ev) ? DISPATCHED : UNDISPATCHED; + return lfunMouseRelease(cmd) ? DISPATCHED : UNDISPATCHED; default: break; } @@ -1109,16 +1080,16 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) bool was_empty = (paragraphs.begin()->empty() && boost::next(paragraphs.begin()) == paragraphs.end()); no_selection = false; - RESULT result = UpdatableInset::localDispatch(ev); + RESULT result = UpdatableInset::localDispatch(cmd); if (result != UNDISPATCHED) return DISPATCHED; result = DISPATCHED; - if (ev.action < 0 && ev.argument.empty()) + if (cmd.action < 0 && cmd.argument.empty()) return FINISHED; if (the_locking_inset) { - result = the_locking_inset->localDispatch(ev); + result = the_locking_inset->localDispatch(cmd); if (result == DISPATCHED_NOUPDATE) return result; else if (result == DISPATCHED) { @@ -1167,7 +1138,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) if (lt->selection.set()) cursor_update = SELECTION; - switch (ev.action) { + switch (cmd.action) { // Normal chars case LFUN_SELFINSERT: @@ -1175,7 +1146,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) // setErrorMessage(N_("Document is read only")); break; } - if (!ev.argument.empty()) { + if (!cmd.argument.empty()) { /* Automatically delete the currently selected * text and replace it with what is being * typed in now. Depends on lyxrc settings @@ -1193,9 +1164,9 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) } } lt->clearSelection(); - for (string::size_type i = 0; i < ev.argument.length(); ++i) { + for (string::size_type i = 0; i < cmd.argument.length(); ++i) { bv->owner()->getIntl().getTransManager(). - TranslateAndInsert(ev.argument[i], lt); + TranslateAndInsert(cmd.argument[i], lt); } } lt->selection.cursor = lt->cursor; @@ -1289,7 +1260,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) if (clip.empty()) break; - if (ev.argument == "paragraph") { + if (cmd.argument == "paragraph") { lt->insertStringAsParagraphs(clip); } else { lt->insertStringAsLines(clip); @@ -1362,7 +1333,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) // and current buffer's textclass (number). */ LyXTextClass const & tclass = bv->buffer()->params.getLyXTextClass(); - string layout = ev.argument; + string layout = cmd.argument; bool hasLayout = tclass.hasLayout(layout); // If the entry is obsolete, use the new one instead. @@ -1375,7 +1346,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) // see if we found the layout number: if (!hasLayout) { - FuncRequest lf(LFUN_MESSAGE, N_("Layout ") + ev.argument + N_(" not known")); + FuncRequest lf(LFUN_MESSAGE, N_("Layout ") + cmd.argument + N_(" not known")); bv->owner()->dispatch(lf); break; } @@ -1405,7 +1376,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) cur_value = pit->params().spacing().getValue(); } - istringstream istr(STRCONV(ev.argument)); + istringstream istr(STRCONV(cmd.argument)); string tmp; istr >> tmp; Spacing::Space new_spacing = cur_spacing; @@ -1430,7 +1401,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) new_spacing = Spacing::Default; } else { lyxerr << _("Unknown spacing argument: ") - << ev.argument << endl; + << cmd.argument << endl; } if (cur_spacing != new_spacing || cur_value != new_value) { pit->params().spacing(Spacing(new_spacing, new_value)); @@ -1452,7 +1423,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) case LFUN_ENDBUF: case LFUN_BEGINNINGBUF: updwhat = cursor_update; - if (!bv->dispatch(ev)) + if (!bv->dispatch(cmd)) result = UNDISPATCHED; break; @@ -1469,7 +1440,7 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & ev) // fallthrough default: - if (!bv->dispatch(ev)) + if (!bv->dispatch(cmd)) result = UNDISPATCHED; break; } @@ -1929,7 +1900,8 @@ bool InsetText::checkAndActivateInset(BufferView * bv, bool front) static_cast(cpar(bv)->getInset(cpos(bv))); if (!isHighlyEditableInset(inset)) return false; - inset->edit(bv, front); + FuncRequest cmd(bv, LFUN_INSET_EDIT, front ? "left" : "right"); + inset->localDispatch(cmd); if (!the_locking_inset) return false; updateLocal(bv, CURSOR, false); @@ -1961,7 +1933,8 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y, y = insetDescent; inset_x = cix(bv) - top_x + drawTextXOffset; inset_y = ciy(bv) + drawTextYOffset; - inset->edit(bv, x - inset_x, y - inset_y, button); + FuncRequest cmd(bv, LFUN_INSET_EDIT, x - inset_x, y - inset_y, button); + inset->localDispatch(cmd); if (!the_locking_inset) return false; updateLocal(bv, CURSOR, false); diff --git a/src/insets/insettext.h b/src/insets/insettext.h index f8b1161bd1..422cdf68a1 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -12,12 +12,12 @@ #ifndef INSETTEXT_H #define INSETTEXT_H - #include "updatableinset.h" #include "LString.h" #include "LColor.h" #include "ParagraphList.h" #include "RowList.h" +#include "frontends/mouse_state.h" #include "support/types.h" @@ -102,10 +102,6 @@ public: /// string const editMessage() const; /// - void edit(BufferView *, int, int, mouse_button::state); - /// - void edit(BufferView *, bool front = true); - /// bool isTextInset() const { return true; } /// void insetUnlock(BufferView *); diff --git a/src/insets/insettoc.C b/src/insets/insettoc.C index 8b7816766f..46137a94c7 100644 --- a/src/insets/insettoc.C +++ b/src/insets/insettoc.C @@ -12,6 +12,7 @@ #include "gettext.h" #include "insettoc.h" +#include "funcrequest.h" #include "BufferView.h" #include "frontends/LyXView.h" #include "frontends/Dialogs.h" @@ -53,16 +54,15 @@ Inset::Code InsetTOC::lyxCode() const } -void InsetTOC::edit(BufferView * bv, int, int, mouse_button::state) +dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd) { - InsetCommandMailer mailer("toc", *this); - mailer.showDialog(bv); -} - - -void InsetTOC::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); + switch (cmd.action) { + case LFUN_INSET_EDIT: + InsetCommandMailer("toc", *this).showDialog(cmd.view()); + return DISPATCHED; + default: + return UNDISPATCHED; + } } diff --git a/src/insets/insettoc.h b/src/insets/insettoc.h index 142c8de333..22edad4b77 100644 --- a/src/insets/insettoc.h +++ b/src/insets/insettoc.h @@ -28,12 +28,10 @@ public: return new InsetTOC(params(), same_id); } /// + dispatch_result localDispatch(FuncRequest const & cmd); + /// string const getScreenLabel(Buffer const *) const; /// - void edit(BufferView * bv, int, int, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); - /// EDITABLE editable() const { return IS_EDITABLE; } /// bool display() const { return true; } diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index 0c1c1f17aa..56f85717ef 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -7,10 +7,11 @@ * * Full author contact details are available in file CREDITS */ + #include - #include "inseturl.h" +#include "funcrequest.h" #include "BufferView.h" #include "LaTeXFeatures.h" #include "frontends/LyXView.h" @@ -29,21 +30,19 @@ InsetUrl::InsetUrl(InsetCommandParams const & p, bool) InsetUrl::~InsetUrl() { - InsetCommandMailer mailer("url", *this); - mailer.hideDialog(); + InsetCommandMailer("url", *this).hideDialog(); } -void InsetUrl::edit(BufferView * bv, int, int, mouse_button::state) +dispatch_result InsetUrl::localDispatch(FuncRequest const & cmd) { - InsetCommandMailer mailer("url", *this); - mailer.showDialog(bv); -} - - -void InsetUrl::edit(BufferView * bv, bool) -{ - edit(bv, 0, 0, mouse_button::none); + switch (cmd.action) { + case LFUN_INSET_EDIT: + InsetCommandMailer("url", *this).showDialog(cmd.view()); + return DISPATCHED; + default: + return InsetCommand::localDispatch(cmd); + } } diff --git a/src/insets/inseturl.h b/src/insets/inseturl.h index 4f5d2693a4..83f2a80058 100644 --- a/src/insets/inseturl.h +++ b/src/insets/inseturl.h @@ -31,6 +31,8 @@ public: return new InsetUrl(params(), same_id); } /// + dispatch_result localDispatch(FuncRequest const & cmd); + /// Inset::Code lyxCode() const { return Inset::URL_CODE; } /// void validate(LaTeXFeatures &) const; @@ -39,10 +41,6 @@ public: /// EDITABLE editable() const { return IS_EDITABLE; } /// - void edit(BufferView *, int, int, mouse_button::state); - /// - void edit(BufferView * bv, bool front = true); - /// bool display() const { return false; } /// int latex(Buffer const *, std::ostream &, diff --git a/src/insets/updatableinset.C b/src/insets/updatableinset.C index 1772858e63..eb61360c69 100644 --- a/src/insets/updatableinset.C +++ b/src/insets/updatableinset.C @@ -52,14 +52,6 @@ void UpdatableInset::fitInsetCursor(BufferView *) const {} -void UpdatableInset::edit(BufferView *, int, int, mouse_button::state) -{} - - -void UpdatableInset::edit(BufferView *, bool) -{} - - void UpdatableInset::draw(BufferView *, LyXFont const &, int /* baseline */, float & x) const { diff --git a/src/insets/updatableinset.h b/src/insets/updatableinset.h index 5c9826f51e..a3ddeaaaa1 100644 --- a/src/insets/updatableinset.h +++ b/src/insets/updatableinset.h @@ -66,10 +66,6 @@ public: /// virtual void insetUnlock(BufferView *); /// - virtual void edit(BufferView *, int x, int y, mouse_button::state button); - /// - virtual void edit(BufferView *, bool front = true); - /// virtual void draw(BufferView *, LyXFont const &, int baseline, float & x) const; /// diff --git a/src/lfuns.h b/src/lfuns.h index d078ebcf78..d8891495e4 100644 --- a/src/lfuns.h +++ b/src/lfuns.h @@ -312,7 +312,7 @@ enum kb_action { LFUN_MOUSE_RELEASE, // André 9 Aug 2002 LFUN_MOUSE_DOUBLE, // André 9 Aug 2002 LFUN_MOUSE_TRIPLE, // André 9 Aug 2002 - LFUN_EDIT, // André 16 Aug 2002 + LFUN_INSET_EDIT, // André 16 Aug 2002 LFUN_INSET_WRAP, // Dekel 7 Apr 2002 // 240 LFUN_TRACK_CHANGES, // Levon 20021001 (cool date !) diff --git a/src/lyxfunc.C b/src/lyxfunc.C index bcff99a8ef..7cc5f9424c 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1366,7 +1366,8 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose) if (view()->theLockingInset()) view()->unlockInset(view()->theLockingInset()); if (par->inInset()) { - par->inInset()->edit(view()); + FuncRequest cmd(view(), LFUN_INSET_EDIT, "left"); + par->inInset()->localDispatch(cmd); } // Set the cursor view()->getLyXText()->setCursor(par, 0); diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 3c73fc5d27..816e81216d 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -13,12 +13,9 @@ */ #include -#include #include "Lsstream.h" #include "support/LAssert.h" - - #include "formula.h" #include "formulamacro.h" #include "lyxrc.h" @@ -53,14 +50,16 @@ #include "intl.h" #include "ref_inset.h" +#include + using std::endl; using std::ostream; using std::vector; using std::abs; using std::max; -MathCursor * mathcursor = 0; +MathCursor * mathcursor = 0; namespace { @@ -68,15 +67,13 @@ namespace { int first_x; int first_y; - - bool openNewInset(BufferView * bv, UpdatableInset * new_inset) { if (!bv->insertInset(new_inset)) { delete new_inset; return false; } - new_inset->edit(bv, true); + new_inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT, "left")); return true; } @@ -169,31 +166,6 @@ string const InsetFormulaBase::editMessage() const } -void InsetFormulaBase::edit(BufferView * bv, int x, int y, mouse_button::state) -{ - if (!bv->lockInset(this)) - lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl; - releaseMathCursor(bv); - mathcursor = new MathCursor(this, true); - metrics(bv); - mathcursor->setPos(x + xo_, y + yo_); - // if that is removed, we won't get the magenta box when entering an - // inset for the first time - bv->updateInset(this); -} - - -void InsetFormulaBase::edit(BufferView * bv, bool front) -{ - if (!bv->lockInset(this)) - lyxerr << "Cannot lock math inset in edit call!\n"; - releaseMathCursor(bv); - mathcursor = new MathCursor(this, front); - metrics(bv); - bv->updateInset(this); -} - - void InsetFormulaBase::insetUnlock(BufferView * bv) { if (mathcursor) { @@ -369,10 +341,29 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) // << " y: '" << cmd.y // << "' button: " << cmd.button() << endl; + BufferView * bv = cmd.view(); + // delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE) bool remove_inset = false; switch (cmd.action) { + case LFUN_INSET_EDIT: + if (!bv->lockInset(this)) + lyxerr << "Cannot lock math inset in edit call!\n"; + releaseMathCursor(bv); + if (!cmd.argument.empty()) { + mathcursor = new MathCursor(this, cmd.argument == "left"); + metrics(bv); + } else { + mathcursor = new MathCursor(this, true); + metrics(bv); + mathcursor->setPos(cmd.x + xo_, cmd.y + yo_); + } + // if that is removed, we won't get the magenta box when entering an + // inset for the first time + bv->updateInset(this); + return DISPATCHED; + case LFUN_MOUSE_PRESS: //lyxerr << "Mouse single press\n"; return lfunMousePress(cmd); @@ -392,7 +383,6 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) if (!mathcursor) return UNDISPATCHED; - BufferView * bv = cmd.view(); string argument = cmd.argument; RESULT result = DISPATCHED; bool sel = false; diff --git a/src/mathed/formulabase.h b/src/mathed/formulabase.h index 03005f904a..f2fa252137 100644 --- a/src/mathed/formulabase.h +++ b/src/mathed/formulabase.h @@ -59,10 +59,6 @@ public: /// what appears in the minibuffer when opening virtual string const editMessage() const; /// - virtual void edit(BufferView *, int x, int y, mouse_button::state button); - /// - virtual void edit(BufferView *, bool front = true); - /// virtual void fitInsetCursor(BufferView *) const; /// FIXME virtual void getCursorPos(BufferView *, int &, int &) const; diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 19ebb970c8..85e62e18a4 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -241,9 +241,6 @@ public: /// identifies things that can get \limits or \nolimits virtual bool takesLimits() const { return false; } - /// - virtual void edit(BufferView *, int, int, mouse_button::state) {} - /// request "external features" virtual void validate(LaTeXFeatures &) const {} /// char char code if possible diff --git a/src/text.C b/src/text.C index 42e937aaf7..b79fb23475 100644 --- a/src/text.C +++ b/src/text.C @@ -2203,7 +2203,8 @@ LyXText::selectNextWordToSpellcheck(float & value) if (cursor.pos() < cursor.par()->size() && cursor.par()->isInset(cursor.pos())) { // lock the inset! - cursor.par()->getInset(cursor.pos())->edit(bv()); + FuncRequest cmd(bv(), LFUN_INSET_EDIT, "left"); + cursor.par()->getInset(cursor.pos())->localDispatch(cmd); // now call us again to do the above trick // but obviously we have to start from down below ;) return bv()->text->selectNextWordToSpellcheck(value); diff --git a/src/text2.C b/src/text2.C index eaf7008f93..9dec90a8d0 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1231,7 +1231,7 @@ void LyXText::updateCounters() string const oldLabel = pit->params().labelString(); - int maxdepth = 0; + size_t maxdepth = 0; if (pit != ownerParagraphs().begin()) maxdepth = boost::prior(pit)->getMaxDepthAfter(); @@ -2046,7 +2046,8 @@ void LyXText::cursorUp(bool selecting) y -= topy; Inset * inset_hit = checkInsetHit(x, y1); if (inset_hit && isHighlyEditableInset(inset_hit)) { - inset_hit->edit(bv(), x, y - (y2 - y1), mouse_button::none); + inset_hit->localDispatch( + FuncRequest(bv(), LFUN_INSET_EDIT, x, y - (y2 - y1), mouse_button::none)); } } #else @@ -2070,7 +2071,8 @@ void LyXText::cursorDown(bool selecting) y -= topy; Inset * inset_hit = checkInsetHit(x, y1); if (inset_hit && isHighlyEditableInset(inset_hit)) { - inset_hit->edit(bv(), x, y - (y2 - y1), mouse_button::none); + FuncRequest cmd(bv(), LFUN_INSET_EDIT, x, y - (y2 - y1), mouse_button::none); + inset_hit->localDispatch(cmd); } } #else diff --git a/src/text3.C b/src/text3.C index a3657a9067..d838a18b38 100644 --- a/src/text3.C +++ b/src/text3.C @@ -385,8 +385,10 @@ void doInsertInset(LyXText * lt, FuncRequest const & cmd, gotsel = true; } if (bv->insertInset(inset)) { - if (edit) - inset->edit(bv); + if (edit) { + FuncRequest cmd(bv, LFUN_INSET_EDIT, "left"); + inset->localDispatch(cmd); + } if (gotsel && pastesel) bv->owner()->dispatch(FuncRequest(LFUN_PASTESELECTION)); } @@ -606,7 +608,8 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) && isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) { Inset * tmpinset = cursor.par()->getInset(cursor.pos()); cmd.message(tmpinset->editMessage()); - tmpinset->edit(bv, !is_rtl); + FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "left" : "right"); + tmpinset->localDispatch(cmd1); break; } if (!is_rtl) @@ -631,7 +634,8 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd) isHighlyEditableInset(cursor.par()->getInset(cursor.pos()))) { Inset * tmpinset = cursor.par()->getInset(cursor.pos()); cmd.message(tmpinset->editMessage()); - tmpinset->edit(bv, is_rtl); + FuncRequest cmd1(bv, LFUN_INSET_EDIT, is_rtl ? "right" : "left"); + tmpinset->localDispatch(cmd1); break; } if (is_rtl) diff --git a/src/undo_funcs.C b/src/undo_funcs.C index 63cbe37fc9..93ad12cfaf 100644 --- a/src/undo_funcs.C +++ b/src/undo_funcs.C @@ -11,6 +11,7 @@ #include "undo_funcs.h" #include "lyxtext.h" +#include "funcrequest.h" #include "BufferView.h" #include "buffer.h" #include "insets/updatableinset.h" @@ -218,7 +219,8 @@ bool textHandleUndo(BufferView * bv, Undo & undo) it = static_cast(tmppar->inInset()); LyXText * t; if (it) { - it->edit(bv); + FuncRequest cmd(bv, LFUN_INSET_EDIT, "left"); + it->localDispatch(cmd); t = it->getLyXText(bv); } else { t = bv->text; @@ -242,7 +244,8 @@ bool textHandleUndo(BufferView * bv, Undo & undo) LyXText * t; Inset * it = tmppar->inInset(); if (it) { - it->edit(bv); + FuncRequest cmd(bv, LFUN_INSET_EDIT, "left"); + it->localDispatch(cmd); t = it->getLyXText(bv); } else { t = bv->text;