]> git.lyx.org Git - features.git/commitdiff
edit->LFUN_INSET_EDIT + CHangeLog + working URL insets.
authorAndré Pönitz <poenitz@gmx.net>
Fri, 16 May 2003 07:44:00 +0000 (07:44 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 16 May 2003 07:44:00 +0000 (07:44 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6969 a592a061-630c-0410-9148-cb99ea01b6c8

55 files changed:
src/BufferView.C
src/ChangeLog
src/insets/ChangeLog
src/insets/inset.C
src/insets/inset.h
src/insets/insetbibitem.C
src/insets/insetbibitem.h
src/insets/insetbibtex.C
src/insets/insetbibtex.h
src/insets/insetbutton.C
src/insets/insetcite.C
src/insets/insetcite.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetcommand.C
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetexternal.C
src/insets/insetexternal.h
src/insets/insetfloatlist.C
src/insets/insetfloatlist.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetindex.C
src/insets/insetindex.h
src/insets/insetlabel.C
src/insets/insetlabel.h
src/insets/insetlatexaccent.C
src/insets/insetparent.C
src/insets/insetparent.h
src/insets/insetref.C
src/insets/insetref.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/insettoc.C
src/insets/insettoc.h
src/insets/inseturl.C
src/insets/inseturl.h
src/insets/updatableinset.C
src/insets/updatableinset.h
src/lfuns.h
src/lyxfunc.C
src/mathed/formulabase.C
src/mathed/formulabase.h
src/mathed/math_inset.h
src/text.C
src/text2.C
src/text3.C
src/undo_funcs.C

index e126352f4a934cad20f33d7c18cfb13341c76f62..4d998fbc7381b69f634c72466159e97c6a1c7db8 100644 (file)
@@ -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);
                                }
                        }
index cb2f9e8ecd9095c2204fe6184306db631d8633b3..1357a0bb2d1ea333808e4e45b489eef07f851f24 100644 (file)
@@ -1,4 +1,13 @@
 
+2003-05-16  André Pönitz  <poenitz@gmx.net>
+       
+       * BufferView.C:
+       * lyxfunc.C:
+       * text.C:
+       * text2.C:
+       * text3.C:
+       * undo_funcs.C: edit() -> LFUN_INSET_EDIT
+
 2003-05-14  Alfredo Braunstein  <abraunst@libero.it>
 
        * lyx_main.C (init): remove spurious static_cast
index c7b59c7ab22b9f2d37e2221f4d0d17a9ce850e39..fffb773cf9368b94f36ccc823a30005cc7ded97a 100644 (file)
@@ -1,4 +1,31 @@
 
+
+2003-05-16 André Pönitz  <poenitz@gmx.net>
+
+       * 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 <poenitz@gmx.net>
 
        * insetbibitem.C:
index ff8d77a51fc33b065ae64eaa6e1a98eb0344cc9a..5c89fc89f8623335d14c8c66e836f8d065508702 100644 (file)
@@ -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;
 }
 
index a1e36f39c857fd0190c54deabee9213bbf1661e9..b306b35f2b795ecbc5bc52ed55f522866df801c7 100644 (file)
 #ifndef INSET_H
 #define INSET_H
 
-
-#include <vector>
 #include "LString.h"
 #include "LColor.h"
 #include "insetbase.h"
 #include "frontends/mouse_state.h"
 #include "support/types.h"
 
+#include <vector>
+
 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; }
index 71b49ac8d8235a8edf83b6ac2cfbe5e8415d996f..37372d16769fb8174b855eba6119f6a1bf2afc14 100644 (file)
@@ -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)
 {
index 8156b1ca7e8719c4e70976358d745fd2bf3058e4..b1f15eae6ff6928865d88b38474132e15c37f506 100644 (file)
@@ -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;
        ///
index 8970efb5764707444891704d569234a09e3d90a8..21b54b9112f970d90d0bf863980308d61a2b38c1 100644 (file)
@@ -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;
+               return  DISPATCHED;
        }
-       break;
+
        default:
-               result = InsetCommand::localDispatch(cmd);
+               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());
index eaddf10fac79c19248db999cf32e2040e31f12f8..966e3afc9a7934dca8684939ad0bdf1ce8f4ce6a 100644 (file)
@@ -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;
        ///
index 9fa257d2e11f8a9e00ffb23a3c090e6b9e45d392..809f49cf776ce387e2c4ae3e62d63d7af146a156 100644 (file)
@@ -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);
 }
index 8bd95bfdbea5f73c6cad53c8bd0767386521126c..419cf6f21958eb1613de8510f1b2a9d9919cbe7d 100644 (file)
@@ -12,6 +12,7 @@
 #include <config.h>
 
 #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);
-
-       InsetCommandMailer mailer("citation", *this);
-       mailer.showDialog(bv);
-}
-
-
-void InsetCitation::edit(BufferView * bv, bool)
-{
-       edit(bv, 0, 0, mouse_button::none);
+       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;
+
+               default:
+                       return UNDISPATCHED;
+       }
+       return DISPATCHED;
 }
 
 
index 3cec12c54d1fd1c920786aa7fcf2c1ca7e97fb1b..587ba52564884a91bb6300c7a1b17fa2cb491672 100644 (file)
@@ -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
index 07bb71e72fa2b3397b4dfa3087cbe80d7e9608ac..ddac8d46c7e0be076c0d7659462995ea06461650 100644 (file)
@@ -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;
 }
 
 
index b1d84ce018ddb753704a6886be1ccad4e5a4d531..d7310607341b089241356ab47659a65f40e982c3 100644 (file)
@@ -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);
index 86203f397bb319ff83363fe91a839e42c64305cc..fda67c103bfd3807fef70df9bfaca9f12900a04e 100644 (file)
@@ -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;
 }
 
 
index 38135356cd1a57c4bf2463967c00f912efdb0567..1470506170a0bccc5086c5d3880bcd49fc0c1ef5 100644 (file)
@@ -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);
-}
index 84581860955f03726e4d10a721f85c014e59e322..fa23e55fa4c30ef9ecfed82503beeafdba6adb42 100644 (file)
@@ -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 {
index 62fedfe989946ffaf01b5deb91bdb5374dfa704f..2c5db8d3ae1b4ea401da11446091f8c40cf43ac4 100644 (file)
@@ -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_);
index df6c19eb6bec68e3a4aa699ab57f30751f9d2f35..e6cd89a1b7e3b2fba1dd2f22df88005f37ebb58f 100644 (file)
@@ -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,
index aae22af7f8fcf5860f9c5c8d6608abf3909d7806..fa27977806cde4790530e2b4a7290514338532fe 100644 (file)
@@ -34,7 +34,6 @@
 #include <cstdio>
 #include <utility>
 
-
 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 << ",\""
index fe4f0eb62217618a320bc2659b7bcb8129a1afda..930a9d904cab25dcf3e50f34c8da21183fe040d5 100644 (file)
@@ -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;
index 32779cf7712fd487a332d2529f4cfa72908b5c2c..0891b43cb4e2f5f3b691486e4b15cab7778e3266 100644 (file)
@@ -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);
+       }
 }
 
 
index a5b7f68442d2d2af92ffe85fafcb70104deedbd7..f5ec613dfced1a0d3ef32b7100f4c61ad4cf9461 100644 (file)
@@ -30,11 +30,9 @@ public:
                return new InsetFloatList(getCmdName());
        }
        ///
-       string const getScreenLabel(Buffer const *) const;
-       ///
-       void edit(BufferView * bv, int, int, mouse_button::state);
+       dispatch_result localDispatch(FuncRequest const & cmd);
        ///
-       void edit(BufferView * bv, bool front = true);
+       string const getScreenLabel(Buffer const *) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
index 29c8dd28dce86522484b0b982387c3ffa74f5aad..f423210c58408ddf1d1db3f68e7cbf003925f4ac 100644 (file)
@@ -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;
index 868f6d623e4451da847a42eb7e44196443fc1dac..2acaa173d1cef1fdd7752023d47b7ccf055b3501 100644 (file)
@@ -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;
index 58c806bce1184028ee05b2d5cf8f87e30147335c..1cb80029f30f2c309ad92aaff0855dff14ee0d04 100644 (file)
@@ -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'
index 6d04d8cd1fc3577811ce4fd6ddacf57a2a52ed3a..99d930061e096f1eece840c6dfef3248c3783c68 100644 (file)
@@ -12,7 +12,6 @@
 #ifndef INSET_INCLUDE_H
 #define INSET_INCLUDE_H
 
-
 #include "insetcommand.h"
 
 #include <boost/scoped_ptr.hpp>
@@ -83,10 +82,6 @@ public:
        /// This returns the list of bibkeys on the child buffer
        void fillWithBibKeys(std::vector<std::pair<string,string> > & 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;
index c7f4b935eb046a8007d58add7bfcbaf507b21fea..cbd6dd8495bb21d48cd7bbfdf29d664921a5588a 100644 (file)
@@ -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");
index 3f13751563d3fe840ce94b58a4aa006e6ce1d22a..79ae38e58d3d2c74c5e8a1b225b45488e8cd6559 100644 (file)
@@ -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; }
index 66963db35005b0d03398cbd7e78de312fdfb6f78..128f4ac7f74df3584b0eb93c28efab87c87f1fb7 100644 (file)
@@ -45,18 +45,17 @@ vector<string> 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
 {
index b4478c3d82c099206c864ddb4536d1a0fbb186f5..db4272070e3a3597143a1379529766dffc497b3a 100644 (file)
@@ -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<string> const getLabelList() const;
        ///
        int latex(Buffer const *, std::ostream &,
index 50df0dd6f367542edc8ba957d8528380f2e6f943..da4bbe4375143929aab8585eb8387e7ef748248d 100644 (file)
@@ -10,8 +10,8 @@
 
 #include <config.h>
 
-
 #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
index 556fdca8dc2601d607736effd7a5ee5510afaeaf..7f1097ba6f7560743f59e9dac0e52ca20c81c460 100644 (file)
 
 #include <config.h>
 
-
-
 #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
-}
-
-
-void InsetParent::edit(BufferView * bv, int, int, mouse_button::state)
-{
-       bv->owner()->dispatch(FuncRequest(LFUN_CHILDOPEN, getContents()));
+       return bformat(_("Parent: %1$s"), getContents());
 }
 
 
-void InsetParent::edit(BufferView * bv, bool)
+dispatch_result InsetParent::localDispatch(FuncRequest const & cmd)
 {
-       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;
+       }
 }
 
 
index b47a2be3a32bc4577e5035fbc27c4bc61e0f6c5e..1dc44baa7e688a731d23259510aaa376ecf1aa78 100644 (file)
@@ -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
index 42f57792f0d1e3286297ae71979565a30e9f9e68..0231e58d7b871d1c9cfa926aaacc17ad6203d070 100644 (file)
@@ -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;
index 9a5dac30df17acf2a083e76ac327b823517b8b18..a54ea0313ce44657ee2bec85ca4a1918e91e4596 100644 (file)
@@ -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 &,
index 937841fb64bc70580c68b87579c0a431c6ed97c3..d13ee3a8a5b70f56891090745c13148aa576432d 100644 (file)
@@ -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<UpdatableInset*>(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<UpdatableInset*>(tabular->GetCellInset(++actcell));
-       inset->edit(bv);
+       inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
        return selectNextWordInt(bv, value);
 }
 
index 116c5a73b0f567a512be28ff22b2255a47165837..b1992c9ccadb16782fcc5ffbd7bf8eebfad9b231 100644 (file)
@@ -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 *);
        ///
index 90a2b6f26d68f60622f3080b2bac47c24dadbb55..51eac4683adb56bd16237e49dc98bce23eb5fcf2 100644 (file)
@@ -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<UpdatableInset*>(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);
index f8b1161bd196ea642156c489a660fd1e2a1accab..422cdf68a1af0e6cd2e6dd34ea0b9907c84f0e96 100644 (file)
 #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 *);
index 8b7816766f6ed10a2efd5209fd4aea00b9f1cf0c..46137a94c78fad93855924e60c05a21dbe21e4bb 100644 (file)
@@ -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;
+       }
 }
 
 
index 142c8de333980a9e093d5e33382ad266ece9c496..22edad4b776fbe4ebef398c521e426a0ed4792ee 100644 (file)
@@ -28,11 +28,9 @@ public:
                return new InsetTOC(params(), same_id);
        }
        ///
-       string const getScreenLabel(Buffer const *) const;
-       ///
-       void edit(BufferView * bv, int, int, mouse_button::state);
+       dispatch_result localDispatch(FuncRequest const & cmd);
        ///
-       void edit(BufferView * bv, bool front = true);
+       string const getScreenLabel(Buffer const *) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
index 0c1c1f17aac7bc9d86c6b4ea156d1c219054ad3b..56f85717ef69878044cbbb28dec0cf47e61f4d34 100644 (file)
@@ -7,10 +7,11 @@
  *
  * Full author contact details are available in file CREDITS
  */
-#include <config.h>
 
+#include <config.h>
 
 #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);
+       }
 }
 
 
index 4f5d2693a4cfef6d2edcc20a963c3a3fd517f16d..83f2a80058292d591972635b29dfd15dafe3ed34 100644 (file)
@@ -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 &,
index 1772858e63cf15c96cc7aaeb75b1f7a579af6e84..eb61360c69a585d1dcb5cbc15b5ecb5e268861e7 100644 (file)
@@ -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
 {
index 5c9826f51ee41f49c29ea29dc44a8e34c54b918d..a3ddeaaaa1e43473391319f4ffadd48242b42261 100644 (file)
@@ -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;
        ///
index d078ebcf78a1934d7ba4848de3b417e3308a6995..d8891495e4f879393e7e681ca2a15aded72e7bd0 100644 (file)
@@ -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 !)
index bcff99a8ef3d111839b29c8569e69c4db6d9be3d..7cc5f9424c989ecf62bac80749bd27d90d87fe95 100644 (file)
@@ -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);
index 3c73fc5d27e7c5dabd09a014b6c5e448bb4079b6..816e81216d2d64ff2604d061f98638e1722a4c00 100644 (file)
 */
 
 #include <config.h>
-#include <fstream>
 
 #include "Lsstream.h"
 #include "support/LAssert.h"
-
-
 #include "formula.h"
 #include "formulamacro.h"
 #include "lyxrc.h"
 #include "intl.h"
 #include "ref_inset.h"
 
+#include <fstream>
+
 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;
index 03005f904ae5cf991d951f185988b1eee81a12b6..f2fa2521374e514283267ae3318f1e7901ea4b4e 100644 (file)
@@ -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;
index 19ebb970c82b156e75be5d27d0e54c3e07a069de..85e62e18a4c6ed93f59ac58961eed1a35f3a5898 100644 (file)
@@ -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
index 42e937aaf70b0471f5833185d2efde1ca19d1c17..b79fb2347599ced4074095c119a330d0ab16a3c1 100644 (file)
@@ -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);
index eaf7008f93847921c42b7bb53673ce56ad2d85b5..9dec90a8d0b46c8f2c2abd1743ba934331c66f01 100644 (file)
@@ -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
index a3657a90678b328b3c2216d1503297626af9cd60..d838a18b3892d70ad6d948e9425e58523b00193f 100644 (file)
@@ -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)
index 63cbe37fc91a8a3794116fa191c76df248e8472e..93ad12cfaf78035c35551c2f6ad962249e2dce96 100644 (file)
@@ -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<UpdatableInset*>(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;