]> git.lyx.org Git - lyx.git/commitdiff
* insettabular.[Ch]: remove remains of the 'update' mechanism,
authorAndré Pönitz <poenitz@gmx.net>
Mon, 16 Feb 2004 11:58:51 +0000 (11:58 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 16 Feb 2004 11:58:51 +0000 (11:58 +0000)
  simplify cursor moving function,
  re-enable horizontal scrolling for large tables

* insetbase.C:
* insetbase.[Ch]: remove explicit 'DispatchResult' return type and
  implicitly assume 'DispatchResult(true, true) with exception of
  InsetBase::priv_dispatch which does the equivalent of
  'retrun DispatchResult(false)'

* inset*.[Ch] (priv_dispatch): adjust

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8435 a592a061-630c-0410-9148-cb99ea01b6c8

74 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/PosIterator.C
src/cursor.C
src/cursor.h
src/cursor_slice.C
src/cursor_slice.h
src/insets/ChangeLog
src/insets/insetbase.C
src/insets/insetbase.h
src/insets/insetbibitem.C
src/insets/insetbibitem.h
src/insets/insetbibtex.C
src/insets/insetbibtex.h
src/insets/insetbox.C
src/insets/insetbox.h
src/insets/insetbranch.C
src/insets/insetbranch.h
src/insets/insetcharstyle.C
src/insets/insetcharstyle.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/insetcommandparams.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetexternal.C
src/insets/insetexternal.h
src/insets/insetfloat.C
src/insets/insetfloat.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetlabel.C
src/insets/insetlabel.h
src/insets/insetlatexaccent.h
src/insets/insetnote.C
src/insets/insetnote.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/insetvspace.C
src/insets/insetvspace.h
src/insets/insetwrap.C
src/insets/insetwrap.h
src/insets/updatableinset.C
src/insets/updatableinset.h
src/lyxtext.h
src/mathed/ChangeLog
src/mathed/command_inset.C
src/mathed/command_inset.h
src/mathed/formula.C
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_hullinset.C
src/mathed/math_hullinset.h
src/mathed/math_mboxinset.C
src/mathed/math_mboxinset.h
src/mathed/math_nestinset.C
src/mathed/math_nestinset.h
src/mathed/math_scriptinset.C
src/mathed/math_scriptinset.h
src/mathed/ref_inset.C
src/mathed/ref_inset.h
src/rowpainter.C
src/tabular.C
src/text.C
src/text2.C
src/text3.C

index 5880205469c9d0af6debe5f5abfe765fcbbdce08..fa3fe6e807d44906eb9aba7614d93b090eebbd6a 100644 (file)
@@ -925,12 +925,12 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
                // built temporary path to inset
                InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
                lyxerr << "hit inset at tip: " << inset << endl;
-               lyxerr << "created temp cursor: " << cur << endl;
+               lyxerr << "created temp cursor:\n" << cur << endl;
 
                // Try to dispatch to an non-editable inset near this position
                DispatchResult res;
                if (inset)
-                       res = inset->dispatch(cur, cmd);
+                       inset->dispatch(cur, cmd);
 
                // Dispatch to the temp cursor.
                // An inset (or LyXText) can assign this to bv->cursor()
index 6b7c967b8579fbf4ead0d4803142bdfd555232cf..679fdf9c92d10546dd765508e9996ca49aa3b5d3 100644 (file)
@@ -1,3 +1,19 @@
+2004-02-16  André Pönitz  <poenitz@gmx.net>
+
+       * cursor.[Ch]: use new '_void_ dispatch(...)' signature (see
+         insets/ChangeLog)
+
+       * cursor_slice.[Ch]: remove unneeded acessor function
+
+       * lyxtext.h: rename rtl() to isRTL()
+
+       * rowpainter.C:
+       * tabular.C:
+       * text.C:
+       * text2.C:
+       * text3.C: adjust
+
+
 2004-02-16  Alfredo Braunstein  <abraunst@lyx.org>
 
        * rowpainter.C (paintSelection): coord fix
index 0dba637dd0c6fd41f587adcaeabbbd81b03f82f5..3dcd602eb2721a3eaae1dbdf22019322441f619c 100644 (file)
@@ -119,7 +119,7 @@ PosIterator & PosIterator::operator--()
                --p.pos;
                InsetBase * inset = p.pit->getInset(p.pos);
                if (inset)
-                       p.index = inset->numParagraphs();
+                       p.index = inset->nargs();
        } else {
                if (p.pit == p.pl->begin()) {
                        if (stack_.size() == 1)
index 49859013e3fde7b304c8c94591c643b729be9f77..1679c27d5e2e8fc53538a16280cf221db088d77b 100644 (file)
@@ -81,18 +81,22 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
 {
        lyxerr << "\nLCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
        FuncRequest cmd = cmd0;
+       disp_.update(true);
+       disp_.val(NONE);
        for (current_ = cursor_.size() - 1; current_ >= 1; --current_) {
-               DispatchResult res = inset()->dispatch(*this, cmd);
-               if (res.dispatched()) {
-                       current_ = cursor_.size() - 1;
-                       return DispatchResult(true, true);
-               }
+               // the inset's dispatch() is supposed to reset the update and
+               // val flags if necessary 
+               inset()->dispatch(*this, cmd);
                
-
                // "Mutate" the request for semi-handled requests that need
                // additional handling in outer levels.
-               switch (res.val()) {
+               switch (disp_.val()) {
+                       case NONE:
+                               // the inset handled the event fully
+                               current_ = cursor_.size() - 1;
+                               return DispatchResult(true, true);
                        case FINISHED:
+                               // the inset handled the event partially
                                cmd = FuncRequest(LFUN_FINISHED_LEFT);
                                break;
                        case FINISHED_RIGHT:
@@ -106,15 +110,15 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
                                break;
                        default:
                                //lyxerr << "not handled on level " << current_
-                               //      << " val: " << res.val() << endl;
+                               //      << " val: " << disp_.val() << endl;
                                break;
                }
        }
        BOOST_ASSERT(current_ == 0);
-       DispatchResult res = bv_->text()->dispatch(*this, cmd);
+       bv_->text()->dispatch(*this, cmd);
        //lyxerr << "   result: " << res.val() << endl;
        current_ = cursor_.size() - 1;
-       return res;
+       return disp_;
 }
 
 
@@ -1356,9 +1360,10 @@ char LCursor::halign()
 
 bool LCursor::goUpDown(bool up)
 {
-       // Be warned: The 'logic' implemented in this function is highly fragile.
-       // A distance of one pixel or a '<' vs '<=' _really_ matters.
-       // So fiddle around with it only if you know what you are doing!
+       // Be warned: The 'logic' implemented in this function is highly
+       // fragile. A distance of one pixel or a '<' vs '<=' _really
+       // matters. So fiddle around with it only if you think you know
+       // what you are doing!
   int xo = 0;
        int yo = 0;
        getPos(xo, yo);
@@ -1484,10 +1489,9 @@ void LCursor::bruteFind2(int x, int y)
        double best_dist = 1e10;
 
        CursorBase it = cursor_;
-       it.back().pos(0);
+       it.back().pos() = 0;
        CursorBase et = cursor_;
-       int n = et.back().asMathInset()->cell(et.back().idx_).size();
-       et.back().pos(n);
+       et.back().pos() = et.back().asMathInset()->cell(et.back().idx_).size();
        for (int i = 0; ; ++i) {
                int xo, yo;
                CursorSlice & cur = it.back();
@@ -1936,3 +1940,21 @@ string LCursor::getPossibleLabel()
 {
        return inMathed() ? "eq:" : text()->getPossibleLabel(*this);
 }
+
+
+void LCursor::notdispatched()
+{
+       disp_.dispatched(false);
+}
+
+
+void LCursor::dispatched(dispatch_result_t res)
+{
+       disp_.val(res);
+}
+
+
+void LCursor::noupdate()
+{
+       disp_.update(false);
+}
index 842ff17c63b9aae0797c469dbc8f38c9905be347..b860827eb4d446dcfd58fe0a605e005dfa581399 100644 (file)
@@ -13,6 +13,7 @@
 #define CURSOR_H
 
 #include "cursor_slice.h"
+#include "dispatchresult.h"
 
 #include <iosfwd>
 #include <vector>
@@ -289,6 +290,10 @@ public:
        void replaceWord(std::string const & replacestring);
        /// update our view
        void update();
+       ///
+       void dispatched(dispatch_result_t res);
+       void notdispatched();
+       void noupdate();
 
        /// output
        friend std::ostream & operator<<(std::ostream & os, LCursor const & cur);
@@ -298,6 +303,9 @@ public:
        std::vector<CursorSlice> cursor_;
        /// the anchor position
        std::vector<CursorSlice> anchor_;
+       
+       /// 
+       DispatchResult disp_;
 
 private:
        ///
index cbbda47d1a276cf24d277ac417d6244b81ccced6..20a0331c8c7383679e6872c95c537645ce74780f 100644 (file)
@@ -41,12 +41,6 @@ CursorSlice::CursorSlice(InsetBase * p)
 }
 
 
-void CursorSlice::idx(idx_type idx)
-{
-       idx_ = idx;
-}
-
-
 size_t CursorSlice::nargs() const
 {
        return inset_->nargs();
@@ -77,12 +71,6 @@ CursorSlice::idx_type & CursorSlice::idx()
 }
 
 
-void CursorSlice::par(par_type par)
-{
-       par_ = par;
-}
-
-
 CursorSlice::par_type CursorSlice::par() const
 {
        return par_;
@@ -95,12 +83,6 @@ CursorSlice::par_type & CursorSlice::par()
 }
 
 
-void CursorSlice::pos(pos_type pos)
-{
-       pos_ = pos;
-}
-
-
 CursorSlice::pos_type CursorSlice::pos() const
 {
        return pos_;
@@ -119,12 +101,6 @@ CursorSlice::pos_type CursorSlice::lastpos() const
 }
 
 
-void CursorSlice::boundary(bool boundary)
-{
-       boundary_ = boundary;
-}
-
-
 bool CursorSlice::boundary() const
 {
        return boundary_;
@@ -233,8 +209,9 @@ bool operator>(CursorSlice const & p, CursorSlice const & q)
 
 std::ostream & operator<<(std::ostream & os, CursorSlice const & item)
 {
-       os << "inset: " << item.inset_
-          << " text: " << item.text()
+       os
+//        << "inset: " << item.inset_
+//        << " text: " << item.text()
           << " idx: " << item.idx_
           << " par: " << item.par_
           << " pos: " << item.pos_
index 3bf2e31dbe5ea97d02fda4a2bdeecc9e7c868675..33770a54216f06bc0e9858d57a057952a415fe6c 100644 (file)
@@ -58,22 +58,16 @@ public:
 
        /// the current inset
        InsetBase * inset() const { return inset_; }
-       /// set the paragraph that contains this cursor
-       void idx(idx_type idx);
        /// return the cell this cursor is in
        idx_type idx() const;
        /// return the cell this cursor is in
        idx_type & idx();
        /// return the last cell in this inset
        idx_type lastidx() const { return nargs() - 1; }
-       /// set the paragraph that contains this cursor
-       void par(par_type par);
        /// return the paragraph this cursor is in
        par_type par() const;
        /// return the paragraph this cursor is in
        par_type & par();
-       /// set the position within the paragraph
-       void pos(pos_type pos);
        /// return the position within the paragraph
        pos_type pos() const;
        /// return the position within the paragraph
@@ -95,8 +89,6 @@ public:
        /// texted specific stuff
        ///
        /// see comment for the member
-       void boundary(bool b);
-       /// see comment for the member
        bool boundary() const;
        /// see comment for the member
        bool & boundary();
index 5bb604fda4631fed00183606a9df91d135fa3523..b0eee06f163e4d1ad529f77c457cab2cb5e5a6e8 100644 (file)
@@ -1,4 +1,18 @@
 
+2004-02-16  André Pönitz  <poenitz@gmx.net>
+
+       * insetbase.C:
+       * insetbase.[Ch]: remove explicit 'DispatchResult' return type and
+         implicitly assume 'DispatchResult(true, true) with exception of
+         InsetBase::priv_dispatch which does the equivalent of 
+         'retrun DispatchResult(false)'
+
+       * inset*.[Ch] (priv_dispatch): adjust
+
+       * insettabular.[Ch]: remove remains of the 'update' mechanism,
+         simplify cursor moving function,
+         re-enable horizontal scrolling for large tables
+
 2004-02-13  André Pönitz  <poenitz@gmx.net>
 
        * insettabular.[Ch]: some work after IU
index b8ebb5757fcb6fe150d96fb2aa6717223ac58e86..07a27dbdc5d472a84c744ee09edab1ef6c2ab392 100644 (file)
 
 
 
-DispatchResult InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetBase::dispatch(LCursor & cur, FuncRequest const & cmd)
 {
-       return priv_dispatch(cur, cmd);
+       priv_dispatch(cur, cmd);
 }
 
 
-DispatchResult InsetBase::priv_dispatch(LCursor &, FuncRequest const &)
+void InsetBase::priv_dispatch(LCursor & cur, FuncRequest const &)
 {
-       lyxerr << "InsetBase::priv_dispatch" << std::endl;
-       return DispatchResult(false);
+       cur.noupdate();
+       cur.notdispatched();
 }
 
 
@@ -46,9 +46,9 @@ void InsetBase::edit(LCursor &, bool)
 }
 
 
-InsetBase * InsetBase::editXY(LCursor & cur, int, int)
+InsetBase * InsetBase::editXY(LCursor &, int x, int y)
 {
-       lyxerr << "InsetBase: edit xy" << std::endl;
+       lyxerr << "InsetBase: editXY x:" << x << " y: " << y << std::endl;
        return this;
 }
 
@@ -133,29 +133,6 @@ std::string const & InsetBase::getInsetName() const
 }
 
 
-int InsetBase::getCell(int x, int y) const
-{
-       for (int i = 0, n = numParagraphs(); i < n; ++i) {
-               LyXText * text = getText(i);
-               //lyxerr << "### text: " << text << " i: " << i
-               //      << " xo: " << text->xo_ << "..." << text->xo_ + text->width
-               //      << " yo: " << text->yo_ 
-               //      << " yo: " << text->yo_ - text->ascent() << "..."
-               //              <<  text->yo_ + text->descent()
-               //      << std::endl;   
-               if (x >= text->xo_
-                               && x <= text->xo_ + text->width
-                               && y >= text->yo_ 
-                               && y <= text->yo_ + text->height)
-               {
-                       lyxerr << "### found text # " << i << std::endl;        
-                       return i;
-               }
-       }
-       return -1;
-}
-
-
 void InsetBase::markErased()
 {}
 
index 607230c532445a2295a48589f967de9636ce042c..aceaf310c334492c8f6bce6184c900aead6c0187 100644 (file)
@@ -68,7 +68,7 @@ public:
        virtual UpdatableInset * asUpdatableInset() { return 0; }
 
        // the real dispatcher
-       DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
+       void dispatch(LCursor & cur, FuncRequest const & cmd);
 
        /// cursor enters
        virtual void edit(LCursor & cur, bool left);
@@ -340,10 +340,6 @@ public:
 
        /// if this insets owns text cells (e.g. InsetText) return cell num
        virtual LyXText * getText(int /*num*/) const { return 0; }
-       ///
-       virtual int numParagraphs() const { return 0; }
-       /// returns cell covering position (x,y), -1 if none exists
-       virtual int getCell(int x, int y) const;
 
        /** Adds a LaTeX snippet to the Preview Loader for transformation
         *  into a bitmap image. Does not start the laoding process.
@@ -354,8 +350,7 @@ public:
        virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
 protected:
        // the real dispatcher
-       virtual
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 public:
        /// returns LyX code associated with the inset. Used for TOC, ...)
        virtual Code lyxCode() const { return NO_CODE; }
index 49fa857cce3c22425feeeab1d66e3aa5de902634..682d0f97a8e2005159af679a8286f066923c3dde 100644 (file)
@@ -53,8 +53,7 @@ auto_ptr<InsetBase> InsetBibitem::clone() const
 }
 
 
-DispatchResult
-InsetBibitem::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetBibitem::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
@@ -62,15 +61,16 @@ InsetBibitem::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                InsetCommandParams p;
                InsetCommandMailer::string2params("bibitem", cmd.argument, p);
                if (p.getCmdName().empty())
-                       return DispatchResult(true, true);
+                       break;
                setParams(p);
                cur.bv().update();
                cur.bv().fitCursor();
-               return DispatchResult(true, true);
+               break;
        }
 
        default:
-               return InsetCommand::priv_dispatch(cur, cmd);
+               InsetCommand::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
index 06f5813cade600b02c04b559fff1d8045fe297e5..7f988b5803014c3a7c1821dd20e5a64ebd6cfe4e 100644 (file)
@@ -50,9 +50,7 @@ public:
        std::string const getBibLabel() const;
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        ///
        int counter;
index 32ed3d3a8fe0480fd7390092de887baf8c2b6810..49dffcd6bed2cb077a7b7472bd2dce31dbde9561 100644 (file)
@@ -65,8 +65,7 @@ std::auto_ptr<InsetBase> InsetBibtex::clone() const
 }
 
 
-DispatchResult
-InsetBibtex::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetBibtex::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
@@ -75,11 +74,12 @@ InsetBibtex::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                InsetCommandMailer::string2params("bibtex", cmd.argument, p);
                if (!p.getCmdName().empty())
                        setParams(p);
-               return DispatchResult(true, true);
+               break;
        }
                
        default:
-               return InsetCommand::priv_dispatch(cur, cmd);
+               InsetCommand::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
index d1f6480d6abc7e07cddaa1e2bbb8b4a131cded25..ea64e5efee77891da001fb17353bbfe68edc9558 100644 (file)
@@ -46,9 +46,7 @@ public:
        bool delDatabase(std::string const &);
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 };
 
 #endif // INSET_BIBTEX_H
index 4f647c53fbc35c2b4ac3703c5995aaa97beb2097..b57eae3d786e665073a985a5c285725832b0c6eb 100644 (file)
@@ -169,8 +169,7 @@ bool InsetBox::showInsetDialog(BufferView * bv) const
 }
 
 
-DispatchResult
-InsetBox::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetBox::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
@@ -178,22 +177,24 @@ InsetBox::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                lyxerr << "InsetBox::dispatch MODIFY" << endl;
                InsetBoxMailer::string2params(cmd.argument, params_);
                setButtonLabel();
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
                InsetBoxMailer(*this).updateDialog(&cur.bv());
-               return DispatchResult(true);
+               break;
 
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
                        InsetBoxMailer(*this).showDialog(&cur.bv());
-                       return DispatchResult(true);
+                       break;
                }
-               return InsetCollapsable::priv_dispatch(cur, cmd);
+               InsetCollapsable::priv_dispatch(cur, cmd);
+               break;
 
        default:
-               return InsetCollapsable::priv_dispatch(cur, cmd);
+               InsetCollapsable::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
index 3b6b17dab18ed3a0244099a3b95ad44cc261ff1e..4b4030625bec019badafa01c975b2f0ae3b72045 100644 (file)
@@ -105,9 +105,7 @@ public:
        };
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        friend class InsetBoxParams;
 
index 40003e9687fb868ae5b045da23045238f2c81c1e..177489943462d4e26d446b27a6e88f3305db8cda 100644 (file)
@@ -110,8 +110,7 @@ bool InsetBranch::showInsetDialog(BufferView * bv) const
 }
 
 
-DispatchResult
-InsetBranch::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetBranch::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
@@ -119,27 +118,30 @@ InsetBranch::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                InsetBranchMailer::string2params(cmd.argument, params);
                params_.branch = params.branch;
                setButtonLabel();
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_MOUSE_PRESS:
                if (cmd.button() != mouse_button::button3)
-                       return InsetCollapsable::priv_dispatch(cur, cmd);
-               return DispatchResult(false);
+                       InsetCollapsable::priv_dispatch(cur, cmd);
+               else
+                       cur.notdispatched();
+               break;
 
        case LFUN_INSET_DIALOG_UPDATE:
                InsetBranchMailer(*this).updateDialog(&cur.bv());
-               return DispatchResult(true);
+               break;
 
        case LFUN_MOUSE_RELEASE:
-               if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
+               if (cmd.button() == mouse_button::button3 && hitButton(cmd))
                        InsetBranchMailer(*this).showDialog(&cur.bv());
-                       return DispatchResult(true);
-               }
-               return InsetCollapsable::priv_dispatch(cur, cmd);
+               else
+                       InsetCollapsable::priv_dispatch(cur, cmd);
+               break;
 
        default:
-               return InsetCollapsable::priv_dispatch(cur, cmd);
+               InsetCollapsable::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
index 50f2ccb7c450115a30d336257da0e45915276c6f..aba81186a138976fbda7f31b0947dc8b16d504da 100644 (file)
@@ -81,9 +81,7 @@ public:
 
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        friend class InsetBranchParams;
 
index db6a945005beddc5a0625fa3f4232d819d8b4295..5c127a4648f66ba703b63ee523723ef5a9f5377d 100644 (file)
@@ -146,20 +146,20 @@ void InsetCharStyle::getDrawFont(LyXFont & font) const
 }
 
 
-DispatchResult
-InsetCharStyle::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetCharStyle::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        setStatus(Inlined);
        switch (cmd.action) {
                case LFUN_MOUSE_PRESS:
-                       if (cmd.button() == mouse_button::button3) {
+                       if (cmd.button() == mouse_button::button3)
                                has_label_ = !has_label_;
-                               return DispatchResult(true);
-                       }
-                       inset.dispatch(cur, cmd);
-                       return DispatchResult(true, true);
+                       else
+                               inset.dispatch(cur, cmd);
+                       break;
+
                default:
-                       return InsetCollapsable::priv_dispatch(cur, cmd);
+                       InsetCollapsable::priv_dispatch(cur, cmd);
+                       break;
        }
 }
 
index 135b1fa77c7e8f86c236e048768a7e9260a6b1d9..88eed54511e76118bf7e5279626eec89a413c852 100644 (file)
@@ -85,9 +85,7 @@ public:
 
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 
 private:
        friend class InsetCharStyleParams;
index 97f34812d9bdcc82cc33921c1ead4b843c6c10d1..dc5dd625817f1e11b3cb17024ce067fbd793bde4 100644 (file)
@@ -201,19 +201,18 @@ bool InsetCollapsable::descendable() const
 }
 
 
-DispatchResult
-InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
+void InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
 {
-       if (cmd.button() == mouse_button::button3) {
+       if (cmd.button() == mouse_button::button3)
                showInsetDialog(&cur.bv());
-       }
 
        switch (status_) {
+
        case Collapsed:
                lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
                setStatus(Open);
                edit(cur, true);
-               return DispatchResult(true, true);
+               break;
 
        case Open: {
                FuncRequest cmd1 = cmd;
@@ -221,17 +220,18 @@ InsetCollapsable::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
                if (hitButton(cmd1)) {
                        lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
                        setStatus(Collapsed);
-                       return DispatchResult(false, FINISHED_RIGHT);
+                       cur.dispatched(FINISHED_RIGHT);
+                       break;
                }
                lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
-               return inset.dispatch(cur, cmd);
+               inset.dispatch(cur, cmd);
+               break;
        }
+
        case Inlined:
-               return inset.dispatch(cur, cmd);
+               inset.dispatch(cur, cmd);
+               break;
        }
-       BOOST_ASSERT(false);
-       // shut up compiler
-       return DispatchResult(true, true);
 }
 
 
@@ -320,8 +320,7 @@ InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y)
 }
 
 
-DispatchResult
-InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        //lyxerr << "\nInsetCollapsable::priv_dispatch (begin): cmd: " << cmd
        //      << "  button y: " << button_dim.y2 << endl;
@@ -331,30 +330,33 @@ InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                                inset.dispatch(cur, cmd);
                        else if (status_ == Open && cmd.y > button_dim.y2)
                                inset.dispatch(cur, cmd);
-                       return DispatchResult(true, true);
+                       break;
 
                case LFUN_MOUSE_MOTION:
                        if (status_ == Inlined)
                                inset.dispatch(cur, cmd);
                        else if (status_ == Open && cmd.y > button_dim.y2)
                                inset.dispatch(cur, cmd);
-                       return DispatchResult(true, true);
+                       break;
 
                case LFUN_MOUSE_RELEASE:
-                       return lfunMouseRelease(cur, cmd);
+                       lfunMouseRelease(cur, cmd);
+                       break;
 
                case LFUN_INSET_TOGGLE:
                        if (inset.text_.toggleInset(cur))
-                               return DispatchResult(true, true);
+                               break;
                        if (status_ == Open) {
                                setStatus(Inlined);
-                               return DispatchResult(true, true);
+                               break;
                        }
                        setStatus(Collapsed);
-                       return DispatchResult(false, FINISHED_RIGHT);
+                       cur.dispatched(FINISHED_RIGHT);
+                       break;
 
                default:
-                       return inset.dispatch(cur, cmd);
+                       inset.dispatch(cur, cmd);
+                       break;
        }
 }
 
@@ -390,9 +392,9 @@ int InsetCollapsable::scroll(bool recursive) const
 }
 
 
-int InsetCollapsable::numParagraphs() const
+size_t InsetCollapsable::nargs() const
 {
-       return inset.numParagraphs();
+       return inset.nargs();
 }
 
 
index e2785d82f338c4688d323f8be37d151c1c92d7d7..e2911cbc27f3c1e41c8b3eb140431d7aa144b4f1 100644 (file)
@@ -97,7 +97,7 @@ public:
        ///
        void scroll(BufferView & bv, int offset) const;
        ///
-       int numParagraphs() const;
+       size_t nargs() const;
        ///
        LyXText * getText(int) const;
        ///
@@ -123,7 +123,7 @@ public:
 
 protected:
        ///
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
        ///
        void dimension_collapsed(Dimension &) const;
        ///
@@ -141,7 +141,7 @@ protected:
 
 private:
        ///
-       DispatchResult lfunMouseRelease(LCursor & cur, FuncRequest const & cmd);
+       void lfunMouseRelease(LCursor & cur, FuncRequest const & cmd);
 
 public:
        ///
index c932a2ac9f61150e37fcb0aaf482092a559e4b61..5e6430cb8e7f1744094a59408be098e50321a64e 100644 (file)
@@ -98,33 +98,35 @@ int InsetCommand::docbook(Buffer const &, ostream &,
 }
 
 
-DispatchResult
-InsetCommand::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetCommand::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
                InsetCommandParams p;
                InsetCommandMailer::string2params(mailer_name_, cmd.argument, p);
-               if (p.getCmdName().empty())
-                       return DispatchResult(false);
-               setParams(p);
-               cur.bv().update();
-               return DispatchResult(true, true);
+               if (p.getCmdName().empty()) {   
+                       cur.notdispatched();
+               } else {
+                       setParams(p);
+                       cur.bv().update();
+               }
+               break;
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
                InsetCommandMailer(cmd.argument, *this).updateDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_INSET_DIALOG_SHOW:
        case LFUN_MOUSE_RELEASE: {
                if (!mailer_name_.empty())
                        InsetCommandMailer(mailer_name_, *this).showDialog(&cur.bv());
-               return DispatchResult(true);
+               break;
        }
 
        default:
-               return DispatchResult(false);
+               InsetOld::priv_dispatch(cur, cmd);
+               break;
        }
 
 }
index ce0b85b629a5666b3c8607bdca5a310223ff6e68..6bb797ed1e19539f300e9c332abcb1649dd6c1af 100644 (file)
@@ -74,9 +74,7 @@ public:
 
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
        ///
        std::string const getCommand() const { return p_.getCommand(); }
        ///
index fd6b63d8202bd78c8bf0b188d975917d139c320a..e863a3772d570815b507c6aeff2d84c4439ffa47 100644 (file)
@@ -24,8 +24,7 @@ public:
        ///
        InsetCommandParams();
        ///
-       explicit
-       InsetCommandParams(std::string const & n,
+       explicit InsetCommandParams(std::string const & n,
                            std::string const & c = std::string(),
                            std::string const & o = std::string());
        ///
index 4893e5a2a3400766e519e5748b1b9c7bab915b2f..40aaff995954f47be01c224a4bab8c22c2ca05dc 100644 (file)
@@ -208,7 +208,7 @@ int InsetERT::docbook(Buffer const &, ostream & os,
 }
 
 
-DispatchResult InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        //lyxerr << "\nInsetERT::priv_dispatch (begin): cmd: " << cmd << endl;
        switch (cmd.action) {
@@ -217,9 +217,10 @@ DispatchResult InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                InsetCollapsable::CollapseStatus st;
                InsetERTMailer::string2params(cmd.argument, st);
                setStatus(st);
-               return DispatchResult(true, true);
+               break;
        }
 
+       // suppress these
        case LFUN_LAYOUT:
        case LFUN_BOLD:
        case LFUN_CODE:
@@ -235,10 +236,11 @@ DispatchResult InsetERT::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_FONT_SIZE:
        case LFUN_FONT_STATE:
        case LFUN_UNDERLINE:
-               return DispatchResult(true);
+               break;
 
        default:
-               return InsetCollapsable::priv_dispatch(cur, cmd);
+               InsetCollapsable::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
index d17fdc2558f5f72f53ecf4ddf12e756dd702cccf..9927e45be0c0df07408afb5118ca33793aa6a7dd 100644 (file)
@@ -74,9 +74,7 @@ public:
        bool forceDefaultParagraphs(InsetBase const *) const { return true; }
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        ///
        void init();
index 7bc4d67980698f3b01473abfb1beb859d4b9a721..3c5d14ea6598a7fe4e80a167eb4ad755fbb41911 100644 (file)
@@ -441,8 +441,7 @@ void InsetExternal::statusChanged() const
 }
 
 
-DispatchResult
-InsetExternal::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetExternal::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
@@ -451,7 +450,7 @@ InsetExternal::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                InsetExternalParams p;
                InsetExternalMailer::string2params(cmd.argument, buffer, p);
                external::editExternal(p, buffer);
-               return DispatchResult(true);
+               break;
        }
 
        case LFUN_INSET_MODIFY: {
@@ -460,19 +459,19 @@ InsetExternal::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                InsetExternalMailer::string2params(cmd.argument, buffer, p);
                setParams(p, buffer);
                cur.bv().update();
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
                InsetExternalMailer(*this).updateDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_MOUSE_RELEASE:
                InsetExternalMailer(*this).showDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
 
        default:
-               return DispatchResult(false);
+               InsetOld::dispatch(cur, cmd);
        }
 }
 
index 5afe94dca027912875c1491208dbf8553da93bbe..c6b0c47a0e2a4b5c4622ec446ee184f60650c9eb 100644 (file)
@@ -151,9 +151,7 @@ public:
 
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        /** This method is connected to the graphics loader, so we are
         *  informed when the image has been loaded.
index e5caa64fa6bb1a81144431360ac73be380d5a84d..4b00ff4a782265d32d7069193c1b299f283ca0ee 100644 (file)
@@ -155,8 +155,7 @@ InsetFloat::~InsetFloat()
 }
 
 
-DispatchResult
-InsetFloat::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetFloat::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
@@ -167,16 +166,17 @@ InsetFloat::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                params_.wide      = params.wide;
                wide(params_.wide, cur.bv().buffer()->params());
                cur.bv().update();
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_INSET_DIALOG_UPDATE: {
                InsetFloatMailer(*this).updateDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
        }
 
        default:
-               return InsetCollapsable::priv_dispatch(cur, cmd);
+               InsetCollapsable::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
index ee1abdf614cd5e47e24a6075a56eec61a33f843c..8d69c1c05e04284e88b8c7df27c742426e9071aa 100644 (file)
@@ -78,9 +78,7 @@ public:
        ///
        InsetFloatParams const & params() const { return params_; }
 protected:
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        ///
        InsetFloatParams params_;
index 245596e17c463685c36f9d738877eb7c6de88d73..bb4a0cdfd0e749ca75136b3f5a35ffd1296e098b 100644 (file)
@@ -191,8 +191,7 @@ void InsetGraphics::statusChanged() const
 }
 
 
-DispatchResult
-InsetGraphics::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetGraphics::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
@@ -203,19 +202,20 @@ InsetGraphics::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        setParams(p);
                        cur.bv().update();
                }
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
                InsetGraphicsMailer(*this).updateDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_MOUSE_RELEASE:
                InsetGraphicsMailer(*this).showDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
 
        default:
-               return DispatchResult(false);
+               InsetOld::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
index a51ca6e2e7953b6f73bf4ce057e6eeee8850d338..60770ef658e671f8619a73b7884c2c7ec129581c 100644 (file)
@@ -81,7 +81,7 @@ public:
        void edit(LCursor & cur, bool left);
 protected:
        ///
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        ///
        friend class InsetGraphicsMailer;
index 52aaf38c8d86fac7e8505b0c2d09c24a37748662..ca9155c5d0db97f458160839c49d28c054e05f8c 100644 (file)
@@ -108,8 +108,7 @@ InsetInclude::~InsetInclude()
 }
 
 
-DispatchResult
-InsetInclude::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetInclude::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
@@ -120,24 +119,25 @@ InsetInclude::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        set(p, *cur.bv().buffer());
                        cur.bv().update();
                }
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
                InsetIncludeMailer(*this).updateDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_MOUSE_RELEASE:
                if (button_.box().contains(cmd.x, cmd.y))
                        InsetIncludeMailer(*this).showDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_INSET_DIALOG_SHOW:
                InsetIncludeMailer(*this).showDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
 
        default:
-               return DispatchResult(false);
+               InsetOld::dispatch(cur, cmd);
+               break;
        }
 }
 
index 750b8209d83ee0c0b20daddbbca41360622c0189..7e4340f56a465147bbfab26d529e92d229dfe59d 100644 (file)
@@ -83,9 +83,7 @@ public:
        void addPreview(lyx::graphics::PreviewLoader &) const;
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        /// Slot receiving a signal that the preview is ready to display.
        void statusChanged() const;
index 7b2332cc0d04060c0aa71b0046293067ca9ae5d4..75644d4295218ecf0173ccedf95a742acf9bdadb 100644 (file)
@@ -91,25 +91,27 @@ void changeRefsIfUnique(BufferView & bv, string const & from, string const & to)
 } // namespace anon
 
 
-DispatchResult
-InsetLabel::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetLabel::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
                InsetCommandParams p;
                InsetCommandMailer::string2params("label", cmd.argument, p);
-               if (p.getCmdName().empty())
-                       return DispatchResult(false);
+               if (p.getCmdName().empty()) {
+                       cur.notdispatched();
+                       break;
+               }
                if (p.getContents() != params().getContents())
                        changeRefsIfUnique(cur.bv(), params().getContents(),
                                                       p.getContents());
                setParams(p);
-               return DispatchResult(true, true);
+               break;
        }
 
        default:
-               return InsetCommand::priv_dispatch(cur, cmd);
+               InsetCommand::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
index 6ee2e374e231f261d70ad45be2d85ff0db00f507..0a5adfccd2d58e1f86f690de000198b270775cc2 100644 (file)
@@ -42,9 +42,7 @@ public:
                    OutputParams const &) const;
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 };
 
 #endif
index d35f71bd2580c1f7eafc5ffd84d44358eb83ec72..96228daea66412dc888e996ea37b598d6dfca6a9 100644 (file)
@@ -30,8 +30,7 @@ public:
        ///
        InsetLatexAccent();
        ///
-       explicit
-       InsetLatexAccent(std::string const & str);
+       explicit InsetLatexAccent(std::string const & str);
        ///
        void metrics(MetricsInfo &, Dimension &) const;
        ///
index fb1d4cf68d2b6e2170af48e9e8629f24274612ae..ba99588e4c6737133df39fd2fe3f1ce494b58b2e 100644 (file)
@@ -184,31 +184,30 @@ bool InsetNote::showInsetDialog(BufferView * bv) const
 }
 
 
-DispatchResult
-InsetNote::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetNote::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
-       case LFUN_INSET_MODIFY: {
+       case LFUN_INSET_MODIFY:
                InsetNoteMailer::string2params(cmd.argument, params_);
                setButtonLabel();
                cur.bv().update();
-               return DispatchResult(true, true);
-       }
+               break;
 
        case LFUN_INSET_DIALOG_UPDATE:
                InsetNoteMailer(*this).updateDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_MOUSE_RELEASE:
-               if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
+               if (cmd.button() == mouse_button::button3 && hitButton(cmd))
                        InsetNoteMailer(*this).showDialog(&cur.bv());
-                       return DispatchResult(true, true);
-               }
-               return InsetCollapsable::priv_dispatch(cur, cmd);
+               else
+                       InsetCollapsable::priv_dispatch(cur, cmd);
+               break;
 
        default:
-               return InsetCollapsable::priv_dispatch(cur, cmd);
+               InsetCollapsable::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
index 7beaac4648281f64bd464f981c8ef0460e3eb23f..83cb528ae750e036f61999f2fc622213f94aa5d1 100644 (file)
@@ -75,9 +75,7 @@ public:
        InsetNoteParams const & params() const { return params_; }
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        friend class InsetNoteParams;
 
index 12140b5ae0232bf65d6e5fd0cde267b775bf5de3..490d5e58090dd593c703c67336cbfda8328fb5d8 100644 (file)
@@ -40,7 +40,7 @@ InsetRef::InsetRef(InsetRef const & ir)
 {}
 
 
-DispatchResult InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_MOUSE_PRESS:
@@ -49,10 +49,10 @@ DispatchResult InsetRef::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        cur.bv().owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
                else
                        InsetCommandMailer("ref", *this).showDialog(&cur.bv());
-               return DispatchResult(true, true);
+               return;
 
        case LFUN_MOUSE_RELEASE:
-               return DispatchResult(true, true);
+               return;
 
        default:
                return InsetCommand::priv_dispatch(cur, cmd);
index a89ac5d4b8ceb3e557ad3e3d0588b3a61c62696d..0fb54e4a0368e645bdf5fcccf74dc4be93edfdaa 100644 (file)
@@ -65,7 +65,7 @@ public:
        void validate(LaTeXFeatures & features) const;
 protected:
        ///
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        ///
        bool isLatex;
index 667a347b6ed7a3dc4fd7b26a6a4cb477e67a6ee5..4046479f086256323ebdefa2788678e52dfa114a 100644 (file)
@@ -155,19 +155,17 @@ bool InsetTabular::hasPasteBuffer() const
 
 InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
        : tabular(buf.params(), max(rows, 1), max(columns, 1)),
-         buffer_(&buf), cursorx_(0), cursory_(0)
+         buffer_(&buf), cursorx_(0)
 {
        tabular.setOwner(this);
-       in_reset_pos = 0;
 }
 
 
 InsetTabular::InsetTabular(InsetTabular const & tab)
        : UpdatableInset(tab), tabular(tab.tabular),
-               buffer_(tab.buffer_), cursorx_(0), cursory_(0)
+               buffer_(tab.buffer_), cursorx_(0)
 {
        tabular.setOwner(this);
-       in_reset_pos = 0;
 }
 
 
@@ -233,7 +231,25 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
                BOOST_ASSERT(false);
        }
 
-       calculate_dimensions_of_cells(mi);
+       for (int i = 0, cell = -1; i < tabular.rows(); ++i) {
+               int maxAsc = 0;
+               int maxDesc = 0;
+               for (int j = 0; j < tabular.columns(); ++j) {
+                       if (tabular.isPartOfMultiColumn(i, j))
+                               continue;
+                       ++cell;
+                       Dimension dim;
+                       MetricsInfo m = mi;
+                       m.base.textwidth =
+                               tabular.column_info[j].p_width.inPixels(mi.base.textwidth);
+                       tabular.getCellInset(cell).metrics(m, dim);
+                       maxAsc  = max(maxAsc, dim.asc);
+                       maxDesc = max(maxDesc, dim.des);
+                       tabular.setWidthOfCell(cell, dim.wid);
+               }
+               tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
+               tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT);
+       }
 
        dim.asc = tabular.getAscentOfRow(0);
        dim.des = tabular.getHeightOfTabular() - tabular.getAscentOfRow(0) + 1;
@@ -254,11 +270,11 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
 
        x += ADD_TO_TABULAR_WIDTH;
 
-       int cell = 0;
+       int idx = 0;
        first_visible_cell = -1;
        for (int i = 0; i < tabular.rows(); ++i) {
                int nx = x;
-               cell = tabular.getCellNumber(i, 0);
+               idx = tabular.getCellNumber(i, 0);
                if (y + tabular.getDescentOfRow(i) <= 0 &&
                          y - tabular.getAscentOfRow(i) < pi.pain.paperHeight())
                {
@@ -273,15 +289,15 @@ void InsetTabular::draw(PainterInfo & pi, int x, int y) const
                        if (tabular.isPartOfMultiColumn(i, j))
                                continue;
                        if (first_visible_cell < 0)
-                               first_visible_cell = cell;
+                               first_visible_cell = idx;
                        if (bv->cursor().selection())
-                               drawCellSelection(pi, nx, y, i, j, cell);
+                               drawCellSelection(pi, nx, y, i, j, idx);
 
-                       int const cx = nx + tabular.getBeginningOfTextInCell(cell);
-                       tabular.getCellInset(cell).draw(pi, cx, y);
-                       drawCellLines(pi.pain, nx, y, i, cell);
-                       nx += tabular.getWidthOfColumn(cell);
-                       ++cell;
+                       int const cx = nx + tabular.getBeginningOfTextInCell(idx);
+                       cell(idx).draw(pi, cx, y);
+                       drawCellLines(pi.pain, nx, y, i, idx);
+                       nx += tabular.getWidthOfColumn(idx);
+                       ++idx;
                }
 
 // Would be nice, but for some completely unfathomable reason,
@@ -361,48 +377,6 @@ string const InsetTabular::editMessage() const
 }
 
 
-void InsetTabular::updateLocal(LCursor & cur) const
-{
-       cur.bv().update();
-       resetPos(cur);
-}
-
-
-void InsetTabular::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
-{
-       if (cmd.button() == mouse_button::button3)
-               return;
-
-       int cell = getCell(cmd.x + xo_, cmd.y + yo_);
-       cur.selection() = false;
-
-       lyxerr << "# InsetTabular::lfunMousePress cell: " << cell << endl;
-       if (cell == -1) {
-               //cur.cursor_ = theTempCursor;
-               cur.push(this);
-               cur.idx() = cell;
-       } else {
-               setPos(cur, cmd.x, cmd.y);
-               //cur.cursor_ = theTempCursor;
-               cur.idx() = cell;
-       }
-       cur.resetAnchor();
-       lyxerr << cur << endl;
-
-       if (cmd.button() == mouse_button::button2)
-               dispatch(cur, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
-}
-
-
-void InsetTabular::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
-{
-       int const actcell = getCell(cmd.x + xo_, cmd.y + yo_);
-       lyxerr << "# InsetTabular::lfunMouseRelease cell: " << actcell << endl;
-       if (cmd.button() == mouse_button::button3)
-               InsetTabularMailer(*this).showDialog(&cur.bv());
-}
-
-
 void InsetTabular::edit(LCursor & cur, bool left)
 {
        lyxerr << "InsetTabular::edit: " << this << endl;
@@ -429,185 +403,110 @@ void InsetTabular::edit(LCursor & cur, bool left)
 
 InsetBase * InsetTabular::editXY(LCursor & cur, int x, int y)
 {
-       lyxerr << "InsetTabular::edit: " << this << endl;
+       //lyxerr << "InsetTabular::editXY: " << this << endl;
        cur.selection() = false;
        cur.push(this);
        return setPos(cur, x, y);
        //int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
-       //if (x > xx)
-       //      activateCellInset(bv, cell, x - xx, y - cursory_);
 }
 
 
-void InsetTabular::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
+void InsetTabular::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
-       int const actcell = getCell(cmd.x + xo_, cmd.y + yo_);
-       cur.idx() = actcell;
-       lyxerr << "# InsetTabular::lfunMouseMotion cell: " << actcell << endl;
-
-       setPos(cur, cmd.x, cmd.y);
-/*
-       if (!hasSelection()) {
-               setSelection(actcell, actcell);
-               cur.setSelection();
-       } else {
-               setSelection(sel_cell_start, actcell);
-               tablemode = (sel_cell_start != actcell);
-       }
-*/
-}
-
+       lyxerr << "# InsetTabular::dispatch: cmd: " << cmd << endl;
+       //lyxerr << "  cur:\n" << cur << endl;
+       CursorSlice sl = cur.current();
 
-DispatchResult
-InsetTabular::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
-{
-       lyxerr << "# InsetTabular::dispatch: " << cmd << endl;
-
-       InsetText & cell = tabular.getCellInset(cur.idx());
-
-       DispatchResult result(true, true);
        switch (cmd.action) {
 
        case LFUN_MOUSE_PRESS:
+               // we'll pop up the table dialog on release
                if (cmd.button() == mouse_button::button3)
-                       DispatchResult(true, true);
-
-       case LFUN_MOUSE_MOTION:
-               lfunMouseMotion(cur, cmd);
-               return DispatchResult(true, true);
-
-       case LFUN_MOUSE_RELEASE:
-               lfunMouseRelease(cur, cmd);
-               return DispatchResult(true, true);
-
-#if 0
-       int const cell = cur.idx();
-       lyxerr << "# InsetTabular::dispatch: A " << cur << endl;
-       result = cell.dispatch(cur, cmd);
-
-       switch (result.val()) {
-       case FINISHED:
-               if (movePrevCell(cur))
-                       result = DispatchResult(true, true);
-               else
-                       result = DispatchResult(false, FINISHED);
+                       break;
+               cur.selection() = false;
+               setPos(cur, cmd.x, cmd.y);
+               cur.resetAnchor();
+               cur.bv().cursor() = cur;
+               //if (cmd.button() == mouse_button::button2)
+               //      dispatch(cur, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
+               //lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
                break;
 
-       case FINISHED_RIGHT:
-               if (moveNextCell(cur))
-                       result = DispatchResult(true, true);
-               else
-                       result = DispatchResult(false, FINISHED_RIGHT);
+       case LFUN_MOUSE_MOTION:
+               if (cmd.button() != mouse_button::button1)
+                       break;
+               setPos(cur, cmd.x, cmd.y);
+               cur.bv().cursor().cursor_ = cur.cursor_;
+               cur.bv().cursor().selection() = true;
+               //lyxerr << "# InsetTabular::MouseMotion\n" << cur.bv().cursor() << endl;
                break;
 
-       case FINISHED_UP:
-               if (moveUpLock(cur))
-                       result = DispatchResult(true, true);
-               else
-                       result = DispatchResult(false, FINISHED_UP);
+       case LFUN_MOUSE_RELEASE:
+               //lyxerr << "# InsetTabular::MouseRelease\n" << cur.bv().cursor() << endl;
+               if (cmd.button() == mouse_button::button3)
+                       InsetTabularMailer(*this).showDialog(&cur.bv());
                break;
 
-       case FINISHED_DOWN:
-               if (moveDownLock(cur))
-                       result = DispatchResult(true, true);
-               else
-                       result = DispatchResult(false, FINISHED_UP);
+       case LFUN_CELL_BACKWARD:
+               movePrevCell(cur);
+               cur.selection() = false;
                break;
-#endif
 
-       case LFUN_CELL_BACKWARD:
        case LFUN_CELL_FORWARD:
-               if (cmd.action == LFUN_CELL_FORWARD)
-                       moveNextCell(cur);
-               else
-                       movePrevCell(cur);
+               moveNextCell(cur);
                cur.selection() = false;
-               return result;
+               break;
 
        case LFUN_SCROLL_INSET:
-               if (!cmd.argument.empty()) {
-                       if (cmd.argument.find('.') != cmd.argument.npos)
-                               scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
-                       else
-                               scroll(cur.bv(), strToInt(cmd.argument));
-                       cur.update();
-                       return DispatchResult(true, true);
-               }
+               if (cmd.argument.empty())
+                       break;
+               if (cmd.argument.find('.') != cmd.argument.npos)
+                       scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
+               else
+                       scroll(cur.bv(), strToInt(cmd.argument));
+               cur.update();
+               break;
 
        case LFUN_RIGHTSEL:
-       case LFUN_RIGHT: {
-               CursorSlice sl = cur.current();
-               cell.dispatch(cur, cmd);
+       case LFUN_RIGHT:
+               cell(cur.idx()).dispatch(cur, cmd);
                if (sl == cur.current())
                        isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur);
                if (sl == cur.current())
-                       result = DispatchResult(true, true);
+                       cur.dispatched(FINISHED_RIGHT);
                break;
-       }
 
        case LFUN_LEFTSEL: 
-       case LFUN_LEFT: {
-               CursorSlice sl = cur.current();
-               cell.dispatch(cur, cmd);
+       case LFUN_LEFT:
+               cell(cur.idx()).dispatch(cur, cmd);
                if (sl == cur.current())
                        isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
                if (sl == cur.current())
-                       result = DispatchResult(true, true);
+                       cur.dispatched(FINISHED);
                break;
-       }
-
-#if 0
-       case LFUN_DOWNSEL: {
-               int const start = hasSelection() ? sel_cell_start : cur.idx();
-               int const ocell = cur.idx();
-               // if we are starting a selection, only select
-               // the current cell at the beginning
-               if (hasSelection()) {
-                       moveDown(cur);
-                       if (ocell == sel_cell_end ||
-                                       tabular.column_of_cell(ocell) >
-tabular.column_of_cell(cur.idx()))
-                               //setSelection(start, tabular.getCellBelow(sel_cell_end));
-                       else
-                               //setSelection(start, tabular.getLastCellBelow(sel_cell_end));
-               } else {
-                       //setSelection(start, start);
-               }
-               break;
-       }
-#endif
 
+       case LFUN_DOWNSEL:
        case LFUN_DOWN:
-               if (!moveDown(cur))
-                       result = DispatchResult(false, FINISHED_DOWN);
-               cur.selection() = false;
-               break;
-
-#if 0
-       case LFUN_UPSEL: {
-               int const start = hasSelection() ? sel_cell_start : cur.idx();
-               int const ocell = cur.idx();
-               // if we are starting a selection, only select
-               // the current cell at the beginning
-               if (hasSelection()) {
-                       moveUp(cur);
-                       if (ocell == sel_cell_end ||
-                                       tabular.column_of_cell(ocell) >
-tabular.column_of_cell(cur.idx()))
-                               //setSelection(start, tabular.getCellAbove(sel_cell_end));
-                       else
-                               //setSelection(start, tabular.getLastCellAbove(sel_cell_end));
-               } else {
-                       //setSelection(start, start);
-               }
+               cell(cur.idx()).dispatch(cur, cmd);
+               if (sl == cur.current())
+                       if (tabular.row_of_cell(cur.idx()) != tabular.rows() - 1) {
+                               cur.idx() = tabular.getCellBelow(cur.idx());
+                               resetPos(cur);
+                       }
+               if (sl == cur.current())
+                       cur.dispatched(FINISHED_DOWN);
                break;
-       }
-#endif
 
+       case LFUN_UPSEL:
        case LFUN_UP:
-               if (!moveUp(cur))
-                       result = DispatchResult(false, FINISHED_DOWN);
-               cur.selection() = false;
+               cell(cur.idx()).dispatch(cur, cmd);
+               if (sl == cur.current())
+                       if (tabular.row_of_cell(cur.idx()) != 0) {
+                               cur.idx() = tabular.getCellAbove(cur.idx());
+                               resetPos(cur);
+                       }
+               if (sl == cur.current())
+                       cur.dispatched(FINISHED_UP);
                break;
 
        case LFUN_NEXT: {
@@ -657,7 +556,7 @@ tabular.column_of_cell(cur.idx()))
 
        case LFUN_TABULAR_FEATURE:
                if (!tabularFeatures(cur, cmd.argument))
-                       result = DispatchResult(false);
+                       cur.notdispatched();
                break;
 
        // insert file functions
@@ -665,7 +564,7 @@ tabular.column_of_cell(cur.idx()))
        case LFUN_FILE_INSERT_ASCII: {
                string tmpstr = getContentsOfAsciiFile(&cur.bv(), cmd.argument, false);
                if (!tmpstr.empty() && !insertAsciiString(cur.bv(), tmpstr, false))
-                       result = DispatchResult(false);
+                       cur.notdispatched();
                break;
        }
 
@@ -695,7 +594,7 @@ tabular.column_of_cell(cur.idx()))
                if (tablemode(cur))
                        cutSelection(cur);
                else
-                       cell.dispatch(cur, cmd);
+                       cell(cur.idx()).dispatch(cur, cmd);
                break;
 
        case LFUN_COPY:
@@ -713,11 +612,11 @@ tabular.column_of_cell(cur.idx()))
                        int cols = 1;
                        int rows = 1;
                        int maxCols = 1;
-                       string::size_type len = clip.length();
-                       string::size_type p = 0;
-
-                       while (p < len &&
-                                               (p = clip.find_first_of("\t\n", p)) != string::npos) {
+                       size_t len = clip.length();
+                       for (size_t p = 0; p < len; ++p) {
+                               p = clip.find_first_of("\t\n", p);
+                               if (p == string::npos)
+                                       break;
                                switch (clip[p]) {
                                case '\t':
                                        ++cols;
@@ -729,7 +628,6 @@ tabular.column_of_cell(cur.idx()))
                                        cols = 1;
                                        break;
                                }
-                               ++p;
                        }
                        maxCols = max(cols, maxCols);
 
@@ -739,37 +637,34 @@ tabular.column_of_cell(cur.idx()))
                        string::size_type op = 0;
                        int cell = 0;
                        int cells = paste_tabular->getNumberOfCells();
-                       p = 0;
                        cols = 0;
                        LyXFont font;
-                       while (cell < cells && p < len &&
-                                               (p = clip.find_first_of("\t\n", p)) != string::npos) {
-                               if (p >= len)
+                       for (size_t p = 0; cell < cells && p < len; ++p) {
+                               p = clip.find_first_of("\t\n", p);
+                               if (p == string::npos || p >= len)
                                        break;
                                switch (clip[p]) {
                                case '\t':
                                        paste_tabular->getCellInset(cell).
-                                               setText(clip.substr(op, p-op), font);
+                                               setText(clip.substr(op, p - op), font);
                                        ++cols;
                                        ++cell;
                                        break;
                                case '\n':
                                        paste_tabular->getCellInset(cell).
-                                               setText(clip.substr(op, p-op), font);
+                                               setText(clip.substr(op, p - op), font);
                                        while (cols++ < maxCols)
                                                ++cell;
                                        cols = 0;
                                        break;
                                }
-                               ++p;
-                               op = p;
+                               op = p + 1;
                        }
                        // check for the last cell if there is no trailing '\n'
                        if (cell < cells && op < len)
                                paste_tabular->getCellInset(cell).
-                                       setText(clip.substr(op, len-op), font);
-               } else if (!insertAsciiString(cur.bv(), clip, true))
-               {
+                                       setText(clip.substr(op, len - op), font);
+               } else if (!insertAsciiString(cur.bv(), clip, true)) {
                        // so that the clipboard is used and it goes on
                        // to default
                        // and executes LFUN_PASTESELECTION in insettext!
@@ -784,23 +679,16 @@ tabular.column_of_cell(cur.idx()))
                        pasteSelection(cur);
                        break;
                }
-               // fall through
-
-       // ATTENTION: the function above has to be PASTE and PASTESELECTION!!!
+               cell(cur.idx()).dispatch(cur, cmd);
+               break;
 
        default:
-               // handle font changing stuff on selection before we lock the inset
-               // in the default part!
-               result = cell.dispatch(cur, cmd);
-               // we try to activate the actual inset and put this event down to
-               // the insets dispatch function.
+               // we try to handle this event in the insets dispatch function.
+               cell(cur.idx()).dispatch(cur, cmd);
                break;
        }
 
-       updateLocal(cur);
        InsetTabularMailer(*this).updateDialog(&cur.bv());
-
-       return result;
 }
 
 
@@ -861,41 +749,38 @@ void InsetTabular::validate(LaTeXFeatures & features) const
 }
 
 
-void InsetTabular::calculate_dimensions_of_cells(MetricsInfo & mi) const
+InsetText const & InsetTabular::cell(int idx) const
 {
-       for (int i = 0, cell = -1; i < tabular.rows(); ++i) {
-               int maxAsc = 0;
-               int maxDesc = 0;
-               for (int j = 0; j < tabular.columns(); ++j) {
-                       if (tabular.isPartOfMultiColumn(i, j))
-                               continue;
-                       ++cell;
-                       Dimension dim;
-                       MetricsInfo m = mi;
-                       m.base.textwidth =
-                               tabular.column_info[j].p_width.inPixels(mi.base.textwidth);
-                       tabular.getCellInset(cell).metrics(m, dim);
-                       maxAsc  = max(maxAsc, dim.asc);
-                       maxDesc = max(maxDesc, dim.des);
-                       tabular.setWidthOfCell(cell, dim.wid);
-               }
-               tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
-               tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT);
-       }
+       return tabular.getCellInset(idx);
+}
+
+
+InsetText & InsetTabular::cell(int idx)
+{
+       return tabular.getCellInset(idx);
 }
 
 
 void InsetTabular::getCursorPos(CursorSlice const & cur, int & x, int & y) const
 {
-       tabular.getCellInset(cur.idx()).getCursorPos(cur, x, y);
+       cell(cur.idx()).getCursorPos(cur, x, y);
 }
 
 
 InsetBase * InsetTabular::setPos(LCursor & cur, int x, int y) const
 {
-       cur.idx() = getCell(x, y);
-       InsetBase * inset = tabular.getCellInset(cur.idx()).text_.editXY(cur, x, y);
-       lyxerr << "# InsetTabular::setPos()  cursor: " << cur << endl;
+       int idx_min = 0;
+       int dist_min = 1000000;
+       for (idx_type i = 0; i < nargs(); ++i) {
+               int d = getText(i)->dist(x, y);
+               if (d < dist_min) {
+                       dist_min = d;
+                       idx_min = i;
+               }
+       }
+       cur.idx() = idx_min;
+       InsetBase * inset = cell(cur.idx()).text_.editXY(cur, x, y);
+       //lyxerr << "# InsetTabular::setPos()\n" << cur << endl;
        return inset;
 }
 
@@ -914,33 +799,12 @@ int InsetTabular::getCellXPos(int cell) const
 }
 
 
-void InsetTabular::resetPos(LCursor &) const
+void InsetTabular::resetPos(LCursor & cur) const
 {
-#if 0
-#ifdef WITH_WARNINGS
-#warning This should be fixed in the right manner (20011128 Jug)
-#endif
-       // fast hack to fix infinite repaintings!
-       if (in_reset_pos > 0)
-               return;
-
        BufferView & bv = cur.bv();
-       int cell = 0;
        int actcell = cur.idx();
        int actcol = tabular.column_of_cell(actcell);
-       int actrow = 0;
-       cursory_ = 0;
-       for (; cell < actcell && !tabular.isLastRow(cell); ++cell) {
-               if (tabular.isLastCellInRow(cell)) {
-                       cursory_ += tabular.getDescentOfRow(actrow) +
-                                        tabular.getAscentOfRow(actrow + 1) +
-                                        tabular.getAdditionalHeight(actrow + 1);
-                       ++actrow;
-               }
-       }
 
-       // we need this only from here on!!!
-       ++in_reset_pos;
        int const offset = ADD_TO_TABULAR_WIDTH + 2;
        int new_x = getCellXPos(actcell) + offset;
        int old_x = cursorx_;
@@ -950,149 +814,70 @@ void InsetTabular::resetPos(LCursor &) const
                tabular.getWidthOfTabular() < bv.workWidth()-20)
        {
                scroll(bv, 0.0F);
-               updateLocal(cur);
        } else if (cursorx_ - offset > 20 &&
                   cursorx_ - offset + tabular.getWidthOfColumn(actcell)
                   > bv.workWidth() - 20) {
                scroll(bv, - tabular.getWidthOfColumn(actcell) - 20);
-               updateLocal(cur);
        } else if (cursorx_ - offset < 20) {
                scroll(bv, 20 - cursorx_ + offset);
-               updateLocal(cur);
        } else if (scroll() && xo_ > 20 &&
                   xo_ + tabular.getWidthOfTabular() > bv.workWidth() - 20) {
                scroll(bv, old_x - cursorx_);
-               updateLocal(cur);
        }
-       InsetTabularMailer(*this).updateDialog(&bv);
-       in_reset_pos = 0;
-#endif
-}
-
-
-bool InsetTabular::moveRight(LCursor & cur)
-{
-       bool moved = isRightToLeft(cur) ? movePrevCell(cur) : moveNextCell(cur);
-       if (!moved)
-               return false;
-       resetPos(cur);
-       return true;
-}
-
-
-bool InsetTabular::moveLeft(LCursor & cur)
-{
-       bool moved = isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
-       if (!moved)
-               return false;
-       resetPos(cur);
-       return true;
-}
-
-
-bool InsetTabular::moveLeftLock(LCursor & cur)
-{
-       bool moved = isRightToLeft(cur) ? moveNextCell(cur) : movePrevCell(cur);
-       if (!moved)
-               return false;
-       activateCellInset(cur, cur.idx(), true);
-       return true;
-}
 
-
-bool InsetTabular::moveUp(LCursor & cur)
-{
-       if (tabular.row_of_cell(cur.idx()) == 0)
-               return false;
-       cur.idx() = tabular.getCellAbove(cur.idx());
-       resetPos(cur);
-       return true;
-}
-
-
-bool InsetTabular::moveUpLock(LCursor & cur)
-{
-       if (tabular.row_of_cell(cur.idx()) == 0)
-               return false;
-       cur.idx() = tabular.getCellAbove(cur.idx());
-       resetPos(cur);
-       activateCellInset(cur, cur.idx(), cur.x_target(), 0);
-       return true;
-}
-
-
-bool InsetTabular::moveDown(LCursor & cur)
-{
-       if (tabular.row_of_cell(cur.idx()) == tabular.rows() - 1)
-               return false;
-       cur.idx() = tabular.getCellBelow(cur.idx());
-       resetPos(cur);
-       return true;
-}
-
-
-bool InsetTabular::moveDownLock(LCursor & cur)
-{
-       if (tabular.row_of_cell(cur.idx()) == tabular.rows() - 1)
-               return false;
-       cur.idx() = tabular.getCellBelow(cur.idx());
-       resetPos(cur);
-       activateCellInset(cur, cur.idx(), cur.x_target());
-       return true;
+       InsetTabularMailer(*this).updateDialog(&bv);
 }
 
 
-bool InsetTabular::moveNextCell(LCursor & cur)
+void InsetTabular::moveNextCell(LCursor & cur)
 {
        lyxerr << "InsetTabular::moveNextCell 1 cur: " << cur << endl;
        if (isRightToLeft(cur)) {
                if (tabular.isFirstCellInRow(cur.idx())) {
                        int row = tabular.row_of_cell(cur.idx());
                        if (row == tabular.rows() - 1)
-                               return false;
+                               return;
                        cur.idx() = tabular.getLastCellInRow(row);
                        cur.idx() = tabular.getCellBelow(cur.idx());
                } else {
                        if (cur.idx() == 0)
-                               return false;
+                               return;
                        --cur.idx();
                }
        } else {
                if (tabular.isLastCell(cur.idx()))
-                       return false;
+                       return;
                ++cur.idx();
        }
        cur.par() = 0;
        cur.pos() = 0;
        lyxerr << "InsetTabular::moveNextCell 2 cur: " << cur << endl;
        resetPos(cur);
-       return true;
 }
 
 
-bool InsetTabular::movePrevCell(LCursor & cur)
+void InsetTabular::movePrevCell(LCursor & cur)
 {
        if (isRightToLeft(cur)) {
                if (tabular.isLastCellInRow(cur.idx())) {
                        int row = tabular.row_of_cell(cur.idx());
                        if (row == 0)
-                               return false;
+                               return;
                        cur.idx() = tabular.getFirstCellInRow(row);
                        cur.idx() = tabular.getCellAbove(cur.idx());
                } else {
                        if (tabular.isLastCell(cur.idx()))
-                               return false;
+                               return;
                        ++cur.idx();
                }
        } else {
                if (cur.idx() == 0) // first cell
-                       return false;
+                       return;
                --cur.idx();
        }
        cur.par() = 0;
        cur.pos() = 0;
        resetPos(cur);
-       return true;
 }
 
 
@@ -1470,27 +1255,10 @@ void InsetTabular::tabularFeatures(LCursor & cur,
                break;
        }
 
-       updateLocal(cur);
        InsetTabularMailer(*this).updateDialog(&bv);
 }
 
 
-void InsetTabular::activateCellInset(LCursor & cur, int cell, int x, int y)
-{
-       cur.idx() = cell;
-       tabular.getCellInset(cell).editXY(cur, x, y);
-       updateLocal(cur);
-}
-
-
-void InsetTabular::activateCellInset(LCursor & cur, int cell, bool behind)
-{
-       cur.idx() = cell;
-       tabular.getCellInset(cell).edit(cur, behind);
-       updateLocal(cur);
-}
-
-
 bool InsetTabular::showInsetDialog(BufferView * bv) const
 {
        InsetTabularMailer(*this).showDialog(bv);
@@ -1777,7 +1545,7 @@ void InsetTabular::cutSelection(LCursor & cur)
        getSelection(cur, rs, re, cs, ce); 
        for (int i = rs; i <= re; ++i)
                for (int j = cs; j <= ce; ++j)
-                       tabular.getCellInset(tabular.getCellNumber(i, j)).clear(track);
+                       cell(tabular.getCellNumber(i, j)).clear(track);
 }
 
 
@@ -1808,24 +1576,22 @@ void InsetTabular::getSelection(LCursor & cur,
 }
 
 
-int InsetTabular::numParagraphs() const
+size_t InsetTabular::nargs() const
 {
        return tabular.getNumberOfCells();
 }
 
 
-LyXText * InsetTabular::getText(int i) const
+LyXText * InsetTabular::getText(int idx) const
 {
-       return i < tabular.getNumberOfCells()
-               ? tabular.getCellInset(i).getText(0)
-               : 0;
+       return size_t(idx) < nargs() ? cell(idx).getText(0) : 0;
 }
 
 
 void InsetTabular::markErased()
 {
-       for (int cell = 0; cell < tabular.getNumberOfCells(); ++cell)
-               tabular.getCellInset(cell).markErased();
+       for (idx_type idx = 0; idx < nargs(); ++idx)
+               cell(idx).markErased();
 }
 
 
@@ -1966,6 +1732,9 @@ bool InsetTabular::tablemode(LCursor & cur) const
 }
 
 
+
+
+
 string const InsetTabularMailer::name_("tabular");
 
 InsetTabularMailer::InsetTabularMailer(InsetTabular const & inset)
index a0739b73ab8ab00613bb5b7db552c3c347929082..9d4a7eac5097114aa7af666790df5f841da50d45 100644 (file)
@@ -8,21 +8,14 @@
  *
  * Full author contact details are available in file CREDITS.
  */
-// This is the rewrite of the tabular (table) support.
-
-// It will probably be a lot of work.
 
-// One first goal could be to make the inset read the old table format
-// and just output it again... no viewing at all.
 
-// When making the internal structure of tabular support I really think
-// that STL containers should be used. This will separate the container from
-// the rest of the code, which is a good thing.
+// This is the rewrite of the tabular (table) support.
 
 // Ideally the tabular support should do as the mathed and use
 // LaTeX in the .lyx file too.
 
-// Things to think of when desingning the new tabular support:
+// Things to think of when designing the new tabular support:
 // - color support (colortbl, color)
 // - decimal alignment (dcloumn)
 // - custom lines (hhline)
@@ -48,9 +41,6 @@
 #include "inset.h"
 #include "tabular.h"
 
-#include "frontends/mouse_state.h"
-
-
 class FuncStatus;
 class LyXLex;
 class Painter;
@@ -82,8 +72,6 @@ public:
        ///
        std::string const editMessage() const;
        ///
-       void updateLocal(LCursor & cur) const;
-       ///
        bool insetAllowed(InsetOld::Code) const { return true; }
        ///
        bool isTextInset() const { return true; }
@@ -125,8 +113,12 @@ public:
                std::string const & argument, int cell) const;
        /// Appends \c list with all labels found within this inset.
        void getLabelList(Buffer const &, std::vector<std::string> & list) const;
+       /// number of cells
+       size_t nargs() const;
        ///
-       int numParagraphs() const;
+       InsetText const & cell(int) const;
+       ///
+       InsetText & cell(int);
        ///
        LyXText * getText(int) const;
 
@@ -159,48 +151,21 @@ public:
 
 protected:
        ///
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
-       ///
-       void lfunMousePress(LCursor & cur, FuncRequest const & cmd);
-       ///
-       void lfunMouseRelease(LCursor & cur, FuncRequest const & cmd);
-       ///
-       void lfunMouseMotion(LCursor & cur, FuncRequest const & cmd);
-       ///
-       void calculate_dimensions_of_cells(MetricsInfo & mi) const;
        ///
        void drawCellLines(Painter &, int x, int baseline,
-                          int row, int cell) const;
+               int row, int cell) const;
        ///
        void drawCellSelection(PainterInfo &, int x, int baseline,
-                              int row, int column, int cell) const;
+               int row, int column, int cell) const;
        ///
        InsetBase * setPos(LCursor & cur, int x, int y) const;
-       ///
-       bool moveRight(LCursor & cur);
-       ///
-       bool moveLeft(LCursor & cur);
-       ///
-       bool moveUp(LCursor & cur);
-       ///
-       bool moveDown(LCursor & cur);
 
        ///
-       bool moveRightLock(LCursor & cur);
+       void moveNextCell(LCursor & cur);
        ///
-       bool moveLeftLock(LCursor & cur);
-       ///
-       bool moveUpLock(LCursor & cur);
-       ///
-       bool moveDownLock(LCursor & cur);
-
-       ///
-       bool moveNextCell(LCursor & cur);
-       ///
-       bool movePrevCell(LCursor & cur);
-
-
+       void movePrevCell(LCursor & cur);
        ///
        int getCellXPos(int cell) const;
        ///
@@ -208,14 +173,6 @@ private:
        ///
        void removeTabularRow();
        ///
-       //void clearSelection() const;
-       ///
-       //void setSelection(int start, int end) const;
-       ///
-       void activateCellInset(LCursor &, int cell, int x, int y);
-       ///
-       void activateCellInset(LCursor &, int cell, bool behind);
-       ///
        bool hasPasteBuffer() const;
        ///
        bool copySelection(LCursor & cur);
@@ -230,28 +187,15 @@ private:
                int & rs, int & re, int & cs, int & ce) const;
        ///
        bool insertAsciiString(BufferView &, std::string const & buf, bool usePaste);
-
        /// are we operating on several cells?
        bool tablemode(LCursor & cur) const;
 
-       //
-       // Private structures and variables
        ///
        Buffer const * buffer_;
        ///
        mutable int cursorx_;
        ///
-       mutable int cursory_;
-       /// true if a set of cells are selected
-       //mutable bool has_selection;
-       /// the starting cell selection nr
-       //mutable int sel_cell_start;
-       /// the ending cell selection nr
-       //mutable int sel_cell_end;
-       ///
        mutable int first_visible_cell;
-       ///
-       mutable int in_reset_pos;
 };
 
 
index 5a619577054556d7ba75b088370a76159c3903b5..f5ab5875f7a3a05d6d8570f1e7913adc305d9bee 100644 (file)
@@ -309,7 +309,7 @@ InsetBase * InsetText::editXY(LCursor & cur, int x, int y)
 }
 
 
-DispatchResult InsetText::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetText::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        //lyxerr << "InsetText::priv_dispatch (begin), act: "
        //      << cmd.action << " " << endl;
@@ -317,7 +317,7 @@ DispatchResult InsetText::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
        setViewCache(&cur.bv());
 
        bool was_empty = paragraphs().begin()->empty() && paragraphs().size() == 1;
-       DispatchResult result = text_.dispatch(cur, cmd);
+       text_.dispatch(cur, cmd);
 
        // If the action has deleted all text in the inset, we need
        // to change the language to the language of the surronding
@@ -331,7 +331,6 @@ DispatchResult InsetText::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
        }
 
        //lyxerr << "InsetText::priv_dispatch (end)" << endl;
-       return result;
 }
 
 
index ed99e024dfad23c265d9f0eb18cced6a480bf62a..e752fc98443591feae5c2663220b54a9db39a0e7 100644 (file)
@@ -150,14 +150,14 @@ public:
        ///
        InsetBase * editXY(LCursor & cur, int x, int y);
 
-       ///
-       int numParagraphs() const { return 1; }
+       /// number of cells in this inset
+       size_t nargs() const { return 1; }
        ///
        ParagraphList & paragraphs() const;
 
 private:
        ///
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
        ///
        void updateLocal(LCursor &);
        ///
index 59d7efdc776930ebeca74f6419b43896ef971de6..1938eee454606ffd45761d306a23083be0400e8d 100644 (file)
@@ -60,22 +60,22 @@ std::auto_ptr<InsetBase> InsetVSpace::clone() const
 }
 
 
-DispatchResult
-InsetVSpace::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetVSpace::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
                InsetVSpaceMailer::string2params(cmd.argument, space_);
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_MOUSE_PRESS:
                InsetVSpaceMailer(*this).showDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
 
        default:
-               return InsetOld::priv_dispatch(cur, cmd);
+               InsetOld::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
index 1a805d54825dc2cf6ce4f46d4303a3ace5e3050c..58eca2979908fb2de1b5b978a01d31e805c352cc 100644 (file)
@@ -54,9 +54,7 @@ public:
 
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 
 private:
        ///
index 3e08a57637e9c00d28e0fee710f6daa8b2cccffc..00e2caa97fd907e5ff0fecc1457fa6df09aa50d6 100644 (file)
@@ -80,27 +80,25 @@ InsetWrap::~InsetWrap()
 }
 
 
-DispatchResult
-InsetWrap::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void InsetWrap::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
                InsetWrapParams params;
                InsetWrapMailer::string2params(cmd.argument, params);
-
                params_.placement = params.placement;
                params_.width     = params.width;
-
                cur.bv().update();
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
                InsetWrapMailer(*this).updateDialog(&cur.bv());
-               return DispatchResult(true, true);
+               break;
 
        default:
-               return InsetCollapsable::priv_dispatch(cur, cmd);
+               InsetCollapsable::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
index 25d87c086aff9459c4328b5ed6ccf79d017fda83..b7b1b6ca86943d2f126dc6c4ba17eb418c1d0798 100644 (file)
@@ -68,9 +68,7 @@ public:
        InsetWrapParams const & params() const { return params_; }
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       virtual void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        ///
        InsetWrapParams params_;
index 4666658635f27badbefa1db93c811d665b944d94..028f36a66374d7e1f50419666960544eebadbe26 100644 (file)
@@ -84,26 +84,24 @@ void UpdatableInset::scroll(BufferView & bv, int offset) const
 }
 
 
-///  An updatable inset could handle lyx editing commands
-DispatchResult
-UpdatableInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void UpdatableInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
-       case LFUN_MOUSE_RELEASE:
-               return DispatchResult(editable() == IS_EDITABLE);
+       //case LFUN_MOUSE_RELEASE:
+       //      return DispatchResult(editable() == IS_EDITABLE);
 
        case LFUN_SCROLL_INSET:
-               if (!cmd.argument.empty()) {
+               if (cmd.argument.empty()) {
                        if (cmd.argument.find('.') != cmd.argument.npos)
                                scroll(cur.bv(), static_cast<float>(strToDbl(cmd.argument)));
                        else
                                scroll(cur.bv(), strToInt(cmd.argument));
                        cur.bv().update();
-                       return DispatchResult(true, true);
                }
+               break;
 
        default:
-               return DispatchResult(false);
+               InsetOld::dispatch(cur, cmd);
        }
 }
 
index 275d00c71106a16d1fc9dbfe24b81ff80cd29c2d..b216b4e4429b55f50cb9be641a4fa34a3152dc74 100644 (file)
@@ -38,9 +38,7 @@ public:
 
 protected:
        ///  An updatable inset could handle lyx editing commands
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
        /// scrolls to absolute position in bufferview-workwidth * sx units
        void scroll(BufferView &, float sx) const;
        /// scrolls offset pixels
index 77ed1ee2b99b93d036f615cdfd1a9def1dee2644..a569a2dd280e8eda2e502d393185fa0acfe372f5 100644 (file)
@@ -124,6 +124,9 @@ public:
        void draw(PainterInfo & pi, int x, int y) const;
        /// draw textselection
        void drawSelection(PainterInfo & pi, int x, int y) const;
+       /// returns distance of this cell to the point given by x and y
+       // assumes valid position and size cache
+       int dist(int x, int y) const;
 
        /// try to handle that request
        DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
@@ -342,6 +345,8 @@ public:
        double spacing(Paragraph const & par) const;
        /// make a suggestion for a label
        std::string getPossibleLabel(LCursor & cur) const;
+       /// is this paragraph right-to-left?
+       bool isRTL(Paragraph const & par) const;
 
        ///
        DispatchResult moveRight(LCursor & cur);
@@ -460,8 +465,6 @@ private:
        void charInserted();
        /// set 'number' font property
        void number(LCursor & cur);
-       /// is the cursor paragraph right-to-left?
-       bool rtl(LCursor & cur) const;
 };
 
 /// return the default height of a row in pixels, considering font zoom
index f8619979ab74e6de61b280ecc843527f4952ac50..ba06be1fdf2dde9557cd976d18ed79433d46b19c 100644 (file)
@@ -1,3 +1,4 @@
+
 2004-02-04  Martin Vermeer  <martin.vermeer@hut.fi>
 
        * math_nestinset.C: workaround gcc 2.95 pointer comparison bug,
index 8ddd8fbe9aff80b96dc6d302888d40f4f986e5a7..eaf57d62304e685839fc31d6084bd709fc22e10e 100644 (file)
@@ -54,17 +54,6 @@ void CommandInset::draw(PainterInfo & pi, int x, int y) const
 }
 
 
-DispatchResult
-CommandInset::priv_dispatch(LCursor & bv, FuncRequest const & cmd)
-{
-       switch (cmd.action) {
-               default:
-                       return MathNestInset::priv_dispatch(bv, cmd);
-       }
-       return DispatchResult(false);
-}
-
-
 void CommandInset::write(WriteStream & os) const
 {
        os << '\\' << name_.c_str();
index b724832cc2cb00e127de734e8b5e41224320cf27..6842f1071d703cb631c61a10ab1a5fd97e57b32d 100644 (file)
@@ -14,6 +14,7 @@
 #define COMMAND_INSET_H
 
 #include "math_nestinset.h"
+
 #include "insets/render_button.h"
 
 
@@ -38,11 +39,6 @@ public:
        std::string const createDialogStr(std::string const & name) const;
 
        std::string const & commandname() const { return name_; }
-protected:
-       ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        std::string name_;
        mutable bool set_label_;
index 06aa68e22c179834022710cb637042cd5cc45bde..a19daa922c75b2ef98d6fa879a9405734729ed7e 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "BufferView.h"
 #include "cursor.h"
-#include "dispatchresult.h"
 #include "debug.h"
 #include "funcrequest.h"
 #include "gettext.h"
index 9ed68656e3c867d535b3bd29bc56b96eb758a5a4..5a8c3faded3cb023c046cfd7a161f19be72d217b 100644 (file)
@@ -16,7 +16,6 @@
 #include "math_streamstr.h"
 #include "BufferView.h"
 #include "cursor.h"
-#include "dispatchresult.h"
 #include "debug.h"
 #include "funcrequest.h"
 #include "LColor.h"
@@ -1043,8 +1042,7 @@ void MathGridInset::splitCell(LCursor & cur)
 }
 
 
-DispatchResult
-MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        //lyxerr << "*** MathGridInset: request: " << cmd << endl;
        switch (cmd.action) {
@@ -1054,11 +1052,12 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        //      GridInsetMailer(*this).showDialog();
                        //      return DispatchResult(true, true);
                        //}
-                       return MathNestInset::priv_dispatch(cur, cmd);
+                       MathNestInset::priv_dispatch(cur, cmd);
+                       return;
 
                case LFUN_INSET_DIALOG_UPDATE:
                        GridInsetMailer(*this).updateDialog(&cur.bv());
-                       return DispatchResult(false);
+                       return;
 
                // insert file functions
                case LFUN_DELETE_LINE_FORWARD:
@@ -1074,12 +1073,12 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                                cur.idx() = cur.lastidx();
                        if (cur.pos() > cur.lastpos())
                                cur.pos() = cur.lastpos();
-                       return DispatchResult(true, FINISHED);
+                       return;
 
                case LFUN_CELL_SPLIT:
                        ////recordUndo(cur, Undo::ATOMIC);
                        splitCell(cur);
-                       return DispatchResult(true, FINISHED);
+                       return;
 
                case LFUN_BREAKLINE: {
                        ////recordUndo(cur, Undo::INSERT);
@@ -1098,7 +1097,8 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        cur.idx() = cur.lastpos();
 
                        //mathcursor->normalize();
-                       return DispatchResult(true, FINISHED);
+                       cur.dispatched(FINISHED);
+                       return;
                }
 
                case LFUN_TABULAR_FEATURE: {
@@ -1152,10 +1152,12 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                                copyCol(col(cur.idx()));
                        else if (s == "swap-column")
                                swapCol(col(cur.idx()));
-                       else
-                               return DispatchResult(false);
+                       else {
+                               cur.notdispatched();
+                               return;
+                       }
                        lyxerr << "returning DispatchResult(true, FINISHED)" << endl;
-                       return DispatchResult(true, FINISHED);
+                       return;
                }
 
                case LFUN_PASTE: {
@@ -1168,10 +1170,10 @@ MathGridInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                                cur.pos() += grid.cell(0).size();
                        } else {
                                // multiple cells
-                               col_type const numcols = min(grid.ncols(), ncols() -
-col(cur.idx()));
-                               row_type const numrows = min(grid.nrows(), nrows() -
-cur.row());
+                               col_type const numcols =
+                                       min(grid.ncols(), ncols() - col(cur.idx()));
+                               row_type const numrows =
+                                       min(grid.nrows(), nrows() - cur.row());
                                for (row_type r = 0; r < numrows; ++r) {
                                        for (col_type c = 0; c < numcols; ++c) {
                                                idx_type i = index(r + cur.row(), c + col(cur.idx()));
@@ -1188,10 +1190,11 @@ cur.row());
                                        for (col_type c = 0; c < grid.ncols(); ++c)
                                                cell(i).append(grid.cell(grid.index(r, c)));
                        }
-                       return DispatchResult(true, FINISHED);
+                       return;
                }
 
                default:
-                       return MathNestInset::priv_dispatch(cur, cmd);
+                       MathNestInset::priv_dispatch(cur, cmd);
+                       return;
        }
 }
index cc81bc7e678c0e1a5c58025fd11d098a8b110ef2..8a66eef708f793cfc29241c5413faef930b44d00 100644 (file)
@@ -216,7 +216,7 @@ public:
 
 protected:
        ///
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
        /// returns x offset of cell compared to inset
        int cellXOffset(idx_type idx) const;
        /// returns y offset of cell compared to inset
index 19a1f94e7a614200209b951e53d0a58a90ae9f42..c2c78c1dac11f3eb06ff9ea96262a27ed9eee26f 100644 (file)
@@ -784,96 +784,96 @@ void MathHullInset::doExtern(LCursor & cur, FuncRequest const & func)
 }
 
 
-DispatchResult
-MathHullInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void MathHullInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        //lyxerr << "*** MathHullInset: request: " << cmd << endl;
        switch (cmd.action) {
 
-               case LFUN_BREAKLINE:
-                       if (type_ == "simple" || type_ == "equation") {
-                               mutate("eqnarray");
-                               cur.idx() = 1;
-                               cur.pos() = 0;
-                               return DispatchResult(true, FINISHED);
-                       }
-                       return MathGridInset::priv_dispatch(cur, cmd);
-
-               case LFUN_MATH_NUMBER:
-                       //lyxerr << "toggling all numbers" << endl;
-                       if (display()) {
-                               ////recordUndo(cur, Undo::INSERT);
-                               bool old = numberedType();
-                               if (type_ == "multline")
-                                       numbered(nrows() - 1, !old);
-                               else
-                                       for (row_type row = 0; row < nrows(); ++row)
-                                               numbered(row, !old);
-                               cur.message(old ? _("No number") : _("Number"));
-                       }
-                       return DispatchResult(true, true);
-
-               case LFUN_MATH_NONUMBER:
-                       if (display()) {
-                               row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
-                               ////recordUndo(cur, Undo::INSERT);
-                               bool old = numbered(r);
-                               cur.message(old ? _("No number") : _("Number"));
-                               numbered(r, !old);
-                       }
-                       return DispatchResult(true, true);
-
-               case LFUN_INSERT_LABEL: {
-                       row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
-                       string old_label = label(r);
-                       string new_label = cmd.argument;
-
-                       if (new_label.empty()) {
-                               string const default_label =
-                                       (lyxrc.label_init_length >= 0) ? "eq:" : "";
-                               pair<bool, string> const res = old_label.empty()
-                                       ? Alert::askForText(_("Enter new label to insert:"), default_label)
-                                       : Alert::askForText(_("Enter label:"), old_label);
-                               if (!res.first)
-                                       return DispatchResult(false);
-                               new_label = lyx::support::trim(res.second);
-                       }
+       case LFUN_BREAKLINE:
+               if (type_ == "simple" || type_ == "equation") {
+                       mutate("eqnarray");
+                       cur.idx() = 1;
+                       cur.pos() = 0;
+                       //cur.dispatched(FINISHED);
+                       return;
+               }
+               MathGridInset::priv_dispatch(cur, cmd);
+               return;
 
-                       //if (new_label == old_label)
-                       //      break;  // Nothing to do
+       case LFUN_MATH_NUMBER:
+               //lyxerr << "toggling all numbers" << endl;
+               if (display()) {
+                       ////recordUndo(cur, Undo::INSERT);
+                       bool old = numberedType();
+                       if (type_ == "multline")
+                               numbered(nrows() - 1, !old);
+                       else
+                               for (row_type row = 0; row < nrows(); ++row)
+                                       numbered(row, !old);
+                       cur.message(old ? _("No number") : _("Number"));
+               }
+               return;
 
-                       if (!new_label.empty())
-                               numbered(r, true);
-                       label(r, new_label);
-                       return DispatchResult(true, true);
+       case LFUN_MATH_NONUMBER:
+               if (display()) {
+                       row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
+                       ////recordUndo(cur, Undo::INSERT);
+                       bool old = numbered(r);
+                       cur.message(old ? _("No number") : _("Number"));
+                       numbered(r, !old);
                }
+               return;
 
-               case LFUN_MATH_EXTERN:
-                       doExtern(cur, cmd);
-                       return DispatchResult(true, FINISHED);
-
-               case LFUN_MATH_MUTATE: {
-                       lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
-                       row_type r = cur.row();
-                       col_type c = cur.col();
-                       mutate(cmd.argument);
-                       cur.idx() = r * ncols() + c;
-                       if (cur.idx() >= nargs())
-                               cur.idx() = nargs() - 1;
-                       if (cur.pos() > cur.lastpos())
-                               cur.pos() = cur.lastpos();
-                       return DispatchResult(true, FINISHED);
+       case LFUN_INSERT_LABEL: {
+               row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
+               string old_label = label(r);
+               string new_label = cmd.argument;
+
+               if (new_label.empty()) {
+                       string const default_label =
+                               (lyxrc.label_init_length >= 0) ? "eq:" : "";
+                       pair<bool, string> const res = old_label.empty()
+                               ? Alert::askForText(_("Enter new label to insert:"), default_label)
+                               : Alert::askForText(_("Enter label:"), old_label);
+                       new_label = lyx::support::trim(res.second);
                }
 
-               case LFUN_MATH_DISPLAY: {
-                       mutate(type_ == "simple" ? "equation" : "simple");
-                       cur.idx() = 0;
+               if (!new_label.empty())
+                       numbered(r, true);
+               label(r, new_label);
+               return;
+       }
+
+       case LFUN_MATH_EXTERN:
+               doExtern(cur, cmd);
+               //cur.dispatched(FINISHED);
+               return;
+
+       case LFUN_MATH_MUTATE: {
+               lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
+               row_type r = cur.row();
+               col_type c = cur.col();
+               mutate(cmd.argument);
+               cur.idx() = r * ncols() + c;
+               if (cur.idx() >= nargs())
+                       cur.idx() = nargs() - 1;
+               if (cur.pos() > cur.lastpos())
                        cur.pos() = cur.lastpos();
-                       return DispatchResult(true, FINISHED);
-               }
+               //cur.dispatched(FINISHED);
+               return;
+       }
+
+       case LFUN_MATH_DISPLAY: {
+               mutate(type_ == "simple" ? "equation" : "simple");
+               cur.idx() = 0;
+               cur.pos() = cur.lastpos();
+               //cur.dispatched(FINISHED);
+               return;
+       }
 
-               default:
-                       return MathGridInset::priv_dispatch(cur, cmd);
+       default:
+               MathGridInset::priv_dispatch(cur, cmd);
+               return;
        }
 }
 
index 9548e594297148156a7917a83843407b645d8ffa..30c9e8cc083545481b68488e475f1cdb57fb3baa 100644 (file)
@@ -117,7 +117,7 @@ public:
 
 protected:
        ///
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
        ///
        std::string eolString(row_type row, bool fragile) const;
 
index 2e5fdbb32852f0158ea1aa6c0091a284c0012768..0b7fa1548539e2e5c2063824f84535290282bbe3 100644 (file)
@@ -64,9 +64,9 @@ void MathMBoxInset::write(WriteStream & os) const
 }
 
 
-DispatchResult MathMBoxInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void MathMBoxInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
-       return text_.dispatch(cur, cmd);
+       text_.dispatch(cur, cmd);
 }
 
 
index 8758b000f437090dff883e6a02900099ed5bee1f..25a3dc417bdb75a74b0b8ee85553ce2560d54614 100644 (file)
@@ -31,7 +31,7 @@ public:
        /// draw according to cached metrics
        void draw(PainterInfo &, int x, int y) const;
        ///
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 
        ///
        void write(WriteStream & os) const;
index 99d2b8f4e80c4d5ff471765ccfece32763de0e68..90a3f74b4dfc5fb790b22e8e66de53b9082f9e78 100644 (file)
@@ -348,8 +348,7 @@ void MathNestInset::handleFont2(LCursor & cur, string const & arg)
 }
 
 
-DispatchResult
-MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        lyxerr << "MathNestInset: request: " << cmd << std::endl;
 
@@ -362,7 +361,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        cur.cell().insert(cur.pos(), ar);
                        cur.pos() += ar.size();
                }
-               return DispatchResult(true, true);
+               break;
 /*
        case LFUN_PASTE: {
                size_t n = 0;
@@ -372,141 +371,184 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        cur.macroModeClose();
                //recordUndo(cur, Undo::ATOMIC);
                cur.selPaste(n);
-               return DispatchResult(true, true);
+               break;
        }
 */
 
        case LFUN_PASTESELECTION:
-               return dispatch(cur, FuncRequest(LFUN_PASTE, cur.bv().getClipboard())); 
+               dispatch(cur, FuncRequest(LFUN_PASTE, cur.bv().getClipboard()));
+               break;
 
        case LFUN_MOUSE_PRESS:
-               return lfunMousePress(cur, cmd);
+               lfunMousePress(cur, cmd);
+               break;
+
        case LFUN_MOUSE_MOTION:
-               return lfunMouseMotion(cur, cmd);
+               lfunMouseMotion(cur, cmd);
+               break;
+
        case LFUN_MOUSE_RELEASE:
-               return lfunMouseRelease(cur, cmd);
+               lfunMouseRelease(cur, cmd);
+               break;
+
        case LFUN_MOUSE_DOUBLE:
        case LFUN_MOUSE_TRIPLE:
                //lyxerr << "Mouse double" << endl;
                //lyxerr << "Mouse triple" << endl;
-               return dispatch(cur, FuncRequest(LFUN_WORDSEL));
+               dispatch(cur, FuncRequest(LFUN_WORDSEL));
+               break;
+
+       case LFUN_FINISHED_LEFT:
+               cur.pop(cur.currentDepth());
+               cur.bv().cursor() = cur;
+               break;
+
+       case LFUN_FINISHED_RIGHT:
+               cur.pop(cur.currentDepth());
+               ++cur.pos();
+               cur.bv().cursor() = cur;
+               break;
+
+       case LFUN_FINISHED_UP:
+               cur.pop(cur.currentDepth());
+               //idxUpDown(cur, true);
+               cur.bv().cursor() = cur;
+               break;
+
+       case LFUN_FINISHED_DOWN:
+               cur.pop(cur.currentDepth());
+               //idxUpDown(cur, false);
+               cur.bv().cursor() = cur;
+               break;
 
        case LFUN_RIGHTSEL:
        case LFUN_RIGHT:
                cur.selHandle(cmd.action == LFUN_RIGHTSEL);
-               return cur.right() ?
-                       DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
+               if (!cur.right()) 
+                       cur.dispatched(FINISHED_RIGHT);
+               break;
 
        case LFUN_LEFTSEL:
        case LFUN_LEFT:
                cur.selHandle(cmd.action == LFUN_LEFTSEL);
-               return cur.left() ?
-                       DispatchResult(true, true) : DispatchResult(false, FINISHED);
+               if (!cur.left())
+                       cur.dispatched(FINISHED);
+               break;
 
        case LFUN_UPSEL:
        case LFUN_UP:
                cur.selHandle(cmd.action == LFUN_UPSEL);
-               return cur.up() ?
-                       DispatchResult(true, true) : DispatchResult(false, FINISHED_UP);
+               if (!cur.up())
+                       cur.dispatched(FINISHED_UP);
+               break;
 
        case LFUN_DOWNSEL:
        case LFUN_DOWN:
                cur.selHandle(cmd.action == LFUN_DOWNSEL);
-               return cur.down() ?
-                       DispatchResult(true, true) : DispatchResult(false, FINISHED_DOWN);
+               if (!cur.down())
+                       cur.dispatched(FINISHED_DOWN);
+               break;
 
        case LFUN_WORDSEL:
                cur.home();
                cur.resetAnchor();
                cur.selection() = true;
                cur.end();
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_UP_PARAGRAPHSEL:
        case LFUN_UP_PARAGRAPH:
        case LFUN_DOWN_PARAGRAPHSEL:
        case LFUN_DOWN_PARAGRAPH:
-               return DispatchResult(true, FINISHED);
+               break;
 
        case LFUN_WORDLEFTSEL:
        case LFUN_WORDLEFT:
                cur.selHandle(cmd.action == LFUN_WORDLEFTSEL);
-               return cur.home()
-                       ? DispatchResult(true, true) : DispatchResult(true, FINISHED);
+               if (!cur.home())
+                       cur.dispatched(FINISHED);
+               break;
 
        case LFUN_WORDRIGHTSEL:
        case LFUN_WORDRIGHT:
                cur.selHandle(cmd.action == LFUN_WORDRIGHTSEL);
-               return cur.end()
-                       ? DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
+               if (!cur.end())
+                       cur.dispatched(FINISHED_RIGHT);
+               break;
 
        case LFUN_HOMESEL:
        case LFUN_HOME:
                cur.selHandle(cmd.action == LFUN_HOMESEL);
-               return cur.home()
-                       ? DispatchResult(true, true) : DispatchResult(true, FINISHED);
+               if (!cur.home())
+                       cur.dispatched(FINISHED_RIGHT);
+               break;
 
        case LFUN_ENDSEL:
        case LFUN_END:
                cur.selHandle(cmd.action == LFUN_ENDSEL);
-               return cur.end()
-                       ? DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
+               if (!cur.end())
+                       cur.dispatched(FINISHED_RIGHT);
+               break;
 
        case LFUN_PRIORSEL:
        case LFUN_PRIOR:
        case LFUN_BEGINNINGBUFSEL:
        case LFUN_BEGINNINGBUF:
-               return DispatchResult(true, FINISHED);
+               cur.dispatched(FINISHED);
+               break;
 
        case LFUN_NEXTSEL:
        case LFUN_NEXT:
        case LFUN_ENDBUFSEL:
        case LFUN_ENDBUF:
-               return DispatchResult(false, FINISHED_RIGHT);
+               cur.dispatched(FINISHED_RIGHT);
+               break;
 
        case LFUN_CELL_FORWARD:
                cur.inset()->idxNext(cur);
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_CELL_BACKWARD:
                cur.inset()->idxPrev(cur);
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_DELETE_WORD_BACKWARD:
        case LFUN_BACKSPACE:
                //recordUndo(cur, Undo::ATOMIC);
                cur.backspace();
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_DELETE_WORD_FORWARD:
        case LFUN_DELETE:
                //recordUndo(cur, Undo::ATOMIC);
                cur.erase();
-               return DispatchResult(true, FINISHED);
+               cur.dispatched(FINISHED);
+               break;
 
        case LFUN_ESCAPE:
-               if (!cur.selection())
-                       return DispatchResult(true, true);
-               cur.selClear();
-               return DispatchResult(false);
+               if (cur.selection()) 
+                       cur.selClear();
+               else 
+                       cur.dispatched(FINISHED);
+               break;
 
        case LFUN_INSET_TOGGLE:
                cur.lockToggle();
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_SELFINSERT:
-               if (!cmd.argument.empty()) {
-                       //recordUndo(cur, Undo::ATOMIC);
-                       if (cmd.argument.size() == 1) {
-                               if (cur.interpret(cmd.argument[0]))
-                                       return DispatchResult(true, true);
-                               else
-                                       return DispatchResult(false, FINISHED_RIGHT);
-                       }
+               if (cmd.argument.empty()) {
+                       cur.dispatched(FINISHED_RIGHT);
+                       break;
+               }
+               //recordUndo(cur, Undo::ATOMIC);
+               if (cmd.argument.size() != 1) {
                        cur.insert(cmd.argument);
+                       break;
                }
-               return DispatchResult(false, FINISHED_RIGHT);
-
+               if (!cur.interpret(cmd.argument[0]))
+                       cur.dispatched(FINISHED_RIGHT);
+               break;
 
 #if 0
 //
@@ -533,18 +575,17 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                istringstream is(cmd.argument.c_str());
                is >> x >> y;
                cur.setScreenPos(x, y);
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_CUT:
                //recordUndo(cur, Undo::DELETE);
                cur.selCut();
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_COPY:
                cur.selCopy();
-               return DispatchResult(true, true);
-
+               break;
 
        // Special casing for superscript in case of LyX handling
        // dead-keys:
@@ -555,7 +596,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        //recordUndo(cur, Undo::ATOMIC);
                        cur.script(true);
                }
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_UMLAUT:
        case LFUN_ACUTE:
@@ -571,44 +612,44 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_TIE:
        case LFUN_OGONEK:
        case LFUN_HUNG_UMLAUT:
-               return DispatchResult(true, true);
+               break;
 
        //  Math fonts
        case LFUN_FREEFONT_APPLY:
        case LFUN_FREEFONT_UPDATE:
                handleFont2(cur, cmd.argument);
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_BOLD:
                handleFont(cur, cmd.argument, "mathbf");
-               return DispatchResult(true, true);
+               break;
        case LFUN_SANS:
                handleFont(cur, cmd.argument, "mathsf");
-               return DispatchResult(true, true);
+               break;
        case LFUN_EMPH:
                handleFont(cur, cmd.argument, "mathcal");
-               return DispatchResult(true, true);
+               break;
        case LFUN_ROMAN:
                handleFont(cur, cmd.argument, "mathrm");
-               return DispatchResult(true, true);
+               break;
        case LFUN_CODE:
                handleFont(cur, cmd.argument, "texttt");
-               return DispatchResult(true, true);
+               break;
        case LFUN_FRAK:
                handleFont(cur, cmd.argument, "mathfrak");
-               return DispatchResult(true, true);
+               break;
        case LFUN_ITAL:
                handleFont(cur, cmd.argument, "mathit");
-               return DispatchResult(true, true);
+               break;
        case LFUN_NOUN:
                handleFont(cur, cmd.argument, "mathbb");
-               return DispatchResult(true, true);
+               break;
        //case LFUN_FREEFONT_APPLY:
                handleFont(cur, cmd.argument, "textrm");
-               return DispatchResult(true, true);
+               break;
        case LFUN_DEFAULT:
                handleFont(cur, cmd.argument, "textnormal");
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_MATH_MODE:
 #if 1
@@ -624,7 +665,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        handleFont(cur, cmd.argument, "textrm");
                //cur.owner()->message(_("math text mode toggled"));
 #endif
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_MATH_SIZE:
 #if 0
@@ -633,7 +674,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        cur.setSize(arg);
                }
 #endif
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_INSERT_MATRIX: {
                //recordUndo(cur, Undo::ATOMIC);
@@ -650,7 +691,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                v_align += 'c';
                cur.niceInsert(
                        MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_MATH_DELIM: {
@@ -664,25 +705,25 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        rs = ')';
                //recordUndo(cur, Undo::ATOMIC);
                cur.handleNest(MathAtom(new MathDelimInset(ls, rs)));
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_SPACE_INSERT:
        case LFUN_MATH_SPACE:
                //recordUndo(cur, Undo::ATOMIC);
                cur.insert(MathAtom(new MathSpaceInset(",")));
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_UNDO:
 #warning look here
                //cur.bv().owner()->message(_("Invalid action in math mode!"));
-               return DispatchResult(true, true);
+               break;
 
        case LFUN_INSET_ERT:
                // interpret this as if a backslash was typed
                //recordUndo(cur, Undo::ATOMIC);
                cur.interpret('\\');
-               return DispatchResult(true, true);
+               break;
 
 // FIXME: We probably should swap parts of "math-insert" and "self-insert"
 // handling such that "self-insert" works on "arbitrary stuff" too, and
@@ -690,10 +731,7 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_INSERT_MATH:
                //recordUndo(cur, Undo::ATOMIC);
                cur.niceInsert(cmd.argument);
-               return DispatchResult(true, true);
-
-       case LFUN_DIALOG_SHOW:
-               return DispatchResult(false);
+               break;
 
        case LFUN_DIALOG_SHOW_NEW_INSET: {
                string const & name = cmd.argument;
@@ -704,10 +742,8 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        data = tmp.createDialogStr(name);
                }
 #endif
-               if (data.empty())
-                       return DispatchResult(false);
                cur.bv().owner()->getDialogs().show(name, data, 0);
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_INSET_APPLY: {
@@ -715,15 +751,16 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                InsetBase * base = cur.bv().owner()->getDialogs().getOpenInset(name);
 
                if (base) {
-                       FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
-                       return base->dispatch(cur, fr);
+                       base->dispatch(cur, FuncRequest(LFUN_INSET_MODIFY, cmd.argument));
+                       break;
                }
                MathArray ar;
                if (createMathInset_fromDialogStr(cmd.argument, ar)) {
                        cur.insert(ar);
-                       return DispatchResult(true, true);
+                       break;
                }
-               return DispatchResult(false);
+               cur.notdispatched();
+               break;
        }
 
 #warning look here
@@ -731,9 +768,9 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 
        case LFUN_WORD_REPLACE:
        case LFUN_WORD_FIND:
-               return
-                       searchForward(&cur.bv(), cmd.getArg(0), false, false)
-                               ? DispatchResult(true, true) : DispatchResult(false);
+               if (!searchForward(&cur.bv(), cmd.getArg(0), false, false))
+                       cur.notdispatched();
+               break;
 
        cur.normalize();
        cur.touch();
@@ -747,12 +784,12 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                if (remove_inset)
                        cur.bv().owner()->dispatch(FuncRequest(LFUN_DELETE));
        }
-
-       return result;  // original version
+       break;
 #endif
 
        default:
-               return MathDimInset::priv_dispatch(cur, cmd);
+               MathDimInset::priv_dispatch(cur, cmd);
+               break;
        }
 }
 
@@ -792,15 +829,14 @@ InsetBase * MathNestInset::editXY(LCursor & cur, int x, int y)
 }
 
 
-DispatchResult
-MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
+void MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
 {
        //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
 
        if (cmd.button() == mouse_button::button1) {
                // try to dispatch to enclosed insets first
                //cur.bv().stuffClipboard(cur.grabSelection());
-               return DispatchResult(true, true);
+               return;
        }
 
        if (cmd.button() == mouse_button::button2) {
@@ -810,21 +846,20 @@ MathNestInset::lfunMouseRelease(LCursor & cur, FuncRequest const & cmd)
                cur.setScreenPos(cmd.x, cmd.y);
                cur.insert(ar);
                cur.bv().update();
-               return DispatchResult(true, true);
+               return;
        }
 
        if (cmd.button() == mouse_button::button3) {
                // try to dispatch to enclosed insets first
                cur.bv().owner()->getDialogs().show("mathpanel");
-               return DispatchResult(true, true);
+               return;
        }
 
-       return DispatchResult(false);
+       cur.notdispatched();
 }
 
 
-DispatchResult
-MathNestInset::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
+void MathNestInset::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
 {
        lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
        if (cmd.button() == mouse_button::button1) {
@@ -834,30 +869,22 @@ MathNestInset::lfunMousePress(LCursor & cur, FuncRequest const & cmd)
                //cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
                lyxerr << "lfunMousePress: setting cursor to: " << cur << endl;
                cur.bv().cursor() = cur;
-               return DispatchResult(true, true);
        }
 
        if (cmd.button() == mouse_button::button2) {
-               return priv_dispatch(cur, FuncRequest(LFUN_PASTESELECTION));
-       }
-
-       if (cmd.button() == mouse_button::button3) {
-               return DispatchResult(true, true);
+               priv_dispatch(cur, FuncRequest(LFUN_PASTESELECTION));
        }
-
-       return DispatchResult(true, true);
 }
 
 
-DispatchResult
-MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
+void MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
 {
        // only select with button 1
        if (cmd.button() != mouse_button::button1)
-               return DispatchResult(true, true);
+               return;
 
        if (abs(cmd.x - first_x) < 2 && abs(cmd.y - first_y) < 2)
-               return DispatchResult(true, true);
+               return;
 
        first_x = cmd.x;
        first_y = cmd.y;
@@ -868,5 +895,5 @@ MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
        //cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
        cur.bv().cursor().cursor_ = cur.cursor_;
        cur.bv().cursor().selection() = true;
-       return DispatchResult(true, true);
+       return;
 }
index 58532f31ba0b12500bf6a5bea7e64fe0d66e37a2..2519733af0a0a65b57ac7a06c2d34f81ec14a614 100644 (file)
@@ -101,7 +101,7 @@ public:
 
 protected:
        ///
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
        ///
        void handleFont(LCursor & cur,
                std::string const & arg, std::string const & font);
@@ -111,11 +111,11 @@ protected:
 
 private:
        /// lfun handler
-       DispatchResult lfunMousePress(LCursor &, FuncRequest const &);
+       void lfunMousePress(LCursor &, FuncRequest const &);
        ///
-       DispatchResult lfunMouseRelease(LCursor &, FuncRequest const &);
+       void lfunMouseRelease(LCursor &, FuncRequest const &);
        ///
-       DispatchResult lfunMouseMotion(LCursor &, FuncRequest const &);
+       void lfunMouseMotion(LCursor &, FuncRequest const &);
 
 protected:
        /// we store the cells in a vector
index 6e6f75514109c6cfb71e642ab773f3c46b4f61aa..07bf1164b7ae254b9f456eb4da1e5233ef9a5634 100644 (file)
@@ -513,10 +513,9 @@ void MathScriptInset::notifyCursorLeaves(idx_type idx)
 }
 
 
-DispatchResult
-MathScriptInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void MathScriptInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
-       lyxerr << "MathScriptInset: request: " << cmd << std::endl;
+       //lyxerr << "MathScriptInset: request: " << cmd << std::endl;
 
        if (cmd.action == LFUN_MATH_LIMITS) {
                if (!cmd.argument.empty()) {
@@ -530,8 +529,8 @@ MathScriptInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
                        limits_ = hasLimits() ? -1 : 1;
                else
                        limits_ = 0;
-               return DispatchResult(true, true);
+               return;
        }
 
-       return MathNestInset::priv_dispatch(cur, cmd);
+       MathNestInset::priv_dispatch(cur, cmd);
 }
index 2f9dd58b408cc92fa55e8eb99d893896ad89c625..5d6c17f1323ed60e67be4955596fe5b0ff5c45c3 100644 (file)
@@ -98,7 +98,7 @@ public:
        void infoize2(std::ostream & os) const;
 protected:
        ///
-       DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 private:
        /// returns x offset for main part
        int dxx() const;
index 391cffda4960177a9afffea1668c5ada10e4433d..6350669d5e61fc88724ea50ad1c29d1eef79bcd8 100644 (file)
@@ -16,7 +16,6 @@
 
 #include "BufferView.h"
 #include "cursor.h"
-#include "dispatchresult.h"
 #include "debug.h"
 #include "funcrequest.h"
 #include "math_support.h"
@@ -54,41 +53,44 @@ void RefInset::infoize(std::ostream & os) const
 }
 
 
-DispatchResult RefInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
+void RefInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY:
                if (cmd.getArg(0) == "ref") {
                        MathArray ar;
-                       if (!createMathInset_fromDialogStr(cmd.argument, ar))
-                               return DispatchResult(false);
-                       *this = *ar[0].nucleus()->asRefInset();
-                       return DispatchResult(true, true);
+                       if (createMathInset_fromDialogStr(cmd.argument, ar)) {
+                               *this = *ar[0].nucleus()->asRefInset(); 
+                               return;
+                       }
                }
-               return DispatchResult(false);
+               cur.notdispatched();
+               return;
 
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button3) {
                        lyxerr << "trying to goto ref" << cell(0) << endl;
                        cur.bv().dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
-                       return DispatchResult(true, true);
+                       return;
                }
                if (cmd.button() == mouse_button::button1) {
                        // Eventually trigger dialog with button 3
                        // not 1
                        string const data = createDialogStr("ref");
                        cur.bv().owner()->getDialogs().show("ref", data, this);
-                       return DispatchResult(true, true);
+                       return;
                }
-               return DispatchResult(false);
+               cur.notdispatched();
+               return;
 
        case LFUN_MOUSE_PRESS:
        case LFUN_MOUSE_MOTION:
                // eat other mouse commands
-               return DispatchResult(true, true);
+               return;
 
        default:
-               return CommandInset::priv_dispatch(cur, cmd);
+               CommandInset::priv_dispatch(cur, cmd);
+               return;
        }
 }
 
index 8ca6155f79429ae2d0e927e9f8e786a2835a9161..4e33280bd483a85ee7b0b45f10406d9c1529cc40 100644 (file)
@@ -60,9 +60,7 @@ public:
        static std::string const & getName(int type);
 protected:
        ///
-       virtual
-       DispatchResult
-       priv_dispatch(LCursor & cur, FuncRequest const & cmd);
+       void priv_dispatch(LCursor & cur, FuncRequest const & cmd);
 };
 
 #endif
index a44eb4d169fa377bfe6faaf594184f0b8de6962b..208956483ea4a3eb99da728ee9106de4ce419949 100644 (file)
@@ -391,7 +391,7 @@ void RowPainter::paintBackground()
 
 void RowPainter::paintSelection()
 {
-       bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
+       bool const is_rtl = text_.isRTL(*pit_);
 
        // the current selection
        LCursor const & cur = bv_.cursor();
@@ -621,7 +621,7 @@ void RowPainter::paintFirst()
 
        int const ww = bv_.workWidth();
 
-       bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
+       bool const is_rtl = text_.isRTL(*pit_);
        bool const is_seq = isFirstInSequence(pit_, text_.paragraphs());
        //lyxerr << "paintFirst: " << pit_->id() << " is_seq: " << is_seq << std::endl;
 
@@ -715,7 +715,7 @@ void RowPainter::paintFirst()
 void RowPainter::paintLast()
 {
        int const ww = bv_.workWidth();
-       bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
+       bool const is_rtl = text_.isRTL(*pit_);
        int const endlabel = getEndLabel(pit_, text_.paragraphs());
 
        // draw an endlabel
index b6aacc72e0392e0395e2c299030439011da2d9b9..4dc6cb787d2454b2cfd525297093d553c61901d6 100644 (file)
@@ -2008,8 +2008,9 @@ int LyXTabular::TeXRow(ostream & os, int i, Buffer const & buf,
                ret += TeXCellPreamble(os, cell);
                InsetText & inset = getCellInset(cell);
 
-               bool rtl = inset.paragraphs().begin()->isRightToLeftPar(bufferparams) &&
-                       !inset.paragraphs().begin()->empty() && getPWidth(cell).zero();
+               bool rtl = inset.text_.isRTL(inset.paragraphs().front())
+                       && !inset.paragraphs().begin()->empty()
+                       && getPWidth(cell).zero();
 
                if (rtl)
                        os << "\\R{";
index de104b34ca7f197b3088ed842489509e7851956a..deab330d9228038702da5f64e1c556ae6dd7fbdf 100644 (file)
@@ -1032,8 +1032,7 @@ void LyXText::prepareToPrint(ParagraphList::iterator pit, Row & row) const
        double fill_separator = 0;
        double x = 0;
 
-       bool const is_rtl =
-               pit->isRightToLeftPar(bv()->buffer()->params());
+       bool const is_rtl = isRTL(*pit);
        if (is_rtl)
                x = rightMargin(*pit);
        else
@@ -1851,8 +1850,7 @@ int LyXText::cursorX(CursorSlice const & cur) const
        if (end <= row_pos)
                cursor_vpos = row_pos;
        else if (pos >= end)
-               cursor_vpos = (pit->isRightToLeftPar(bv()->buffer()->params()))
-                       ? row_pos : end;
+               cursor_vpos = isRTL(*pit) ? row_pos : end;
        else if (pos > row_pos && pos >= end)
                // Place cursor after char at (logical) position pos - 1
                cursor_vpos = (bidi.level(pos - 1) % 2 == 0)
@@ -2038,8 +2036,7 @@ string LyXText::getPossibleLabel(LCursor & cur) const
                text = "thm"; // Create a correct prefix for prettyref
 
        text += ':';
-       if (layout->latextype == LATEX_PARAGRAPH ||
-           lyxrc.label_init_length < 0)
+       if (layout->latextype == LATEX_PARAGRAPH || lyxrc.label_init_length < 0)
                text.erase();
 
        string par_text = pit->asString(*cur.bv().buffer(), false);
@@ -2056,3 +2053,22 @@ string LyXText::getPossibleLabel(LCursor & cur) const
 
        return text;
 }
+
+
+int LyXText::dist(int x, int y) const
+{
+       int xx = 0;
+       int yy = 0;
+
+       if (x < xo_)
+               xx = xo_ - x;
+       else if (x > xo_ + width)
+               xx = x - xo_ - width;
+
+       if (y < yo_ - ascent())
+               yy = yo_ - ascent() - y;
+       else if (y > yo_ + descent())
+               yy = y - yo_ - descent();
+
+       return xx + yy;
+}
index fc52daaf6d3f1f2c3547af2c72e65fd37ef90026..5140ddb4495b813a3ed209f991b702a7c43d649f 100644 (file)
@@ -959,7 +959,7 @@ void LyXText::copySelection(LCursor & cur)
               && getPar(cur.selBegin())->isLineSeparator(cur.selBegin().pos())
               && (cur.selBegin().par() != cur.selEnd().par()
                   || cur.selBegin().pos() < cur.selEnd().pos()))
-               cur.selBegin().pos(cur.selBegin().pos() + 1);
+               ++cur.selBegin().pos();
 
        CutAndPaste::copySelection(getPar(cur.selBegin().par()),
                                   getPar(cur.selEnd().par()),
@@ -1098,9 +1098,9 @@ void LyXText::setCursor(CursorSlice & cur, par_type par,
 {
        BOOST_ASSERT(par != int(paragraphs().size()));
 
-       cur.par(par);
-       cur.pos(pos);
-       cur.boundary(boundary);
+       cur.par() = par;
+       cur.pos() = pos;
+       cur.boundary() = boundary;
 
        // no rows, no fun...
        if (paragraphs().begin()->rows.empty())
@@ -1114,30 +1114,28 @@ void LyXText::setCursor(CursorSlice & cur, par_type par,
        // None of these should happen, but we're scaredy-cats
        if (pos < 0) {
                lyxerr << "dont like -1" << endl;
-               pos = 0;
-               cur.pos(0);
                BOOST_ASSERT(false);
-       } else if (pos > para.size()) {
+       }
+
+       if (pos > para.size()) {
                lyxerr << "dont like 1, pos: " << pos
                       << " size: " << para.size()
                       << " row.pos():" << row.pos()
                       << " par: " << par << endl;
-               pos = 0;
-               cur.pos(0);
                BOOST_ASSERT(false);
-       } else if (pos > end) {
+       }
+
+       if (pos > end) {
                lyxerr << "dont like 2 please report" << endl;
                // This shouldn't happen.
-               pos = end;
-               cur.pos(pos);
                BOOST_ASSERT(false);
-       } else if (pos < row.pos()) {
+       }
+       
+       if (pos < row.pos()) {
                lyxerr << "dont like 3 please report pos:" << pos
                       << " size: " << para.size()
                       << " row.pos():" << row.pos()
                       << " par: " << par << endl;
-               pos = row.pos();
-               cur.pos(pos);
                BOOST_ASSERT(false);
        }
 }
@@ -1264,9 +1262,7 @@ pos_type LyXText::getColumnNearX(ParagraphList::iterator pit,
 
        // If lastrow is false, we don't need to compute
        // the value of rtl.
-       bool const rtl = lastrow
-               ? pit->isRightToLeftPar(bv()->buffer()->params())
-               : false;
+       bool const rtl = lastrow ? isRTL(*pit) : false;
        if (lastrow &&
                 ((rtl  &&  left_side && vc == row.pos() && x < tmpx - 5) ||
                  (!rtl && !left_side && vc == end  && x > tmpx + 5)))
@@ -1358,7 +1354,7 @@ bool LyXText::checkAndActivateInset(LCursor & cur, bool front)
 
 DispatchResult LyXText::moveRight(LCursor & cur)
 {
-       if (rtl(cur))
+       if (isRTL(cur.paragraph()))
                return moveLeftIntern(cur, false, true, false);
        else
                return moveRightIntern(cur, true, true, false);
@@ -1367,7 +1363,7 @@ DispatchResult LyXText::moveRight(LCursor & cur)
 
 DispatchResult LyXText::moveLeft(LCursor & cur)
 {
-       if (rtl(cur))
+       if (isRTL(cur.paragraph()))
                return moveRightIntern(cur, true, true, false);
        else
                return moveLeftIntern(cur, false, true, false);
index 616b72d251f779a89e77b1afd7368333e0871d8f..79641090e638f0a170a502a2e285b0e34c570bf7 100644 (file)
@@ -366,9 +366,9 @@ void LyXText::number(LCursor & cur)
 }
 
 
-bool LyXText::rtl(LCursor & cur) const
+bool LyXText::isRTL(Paragraph const & par) const
 {
-       return cur.paragraph().isRightToLeftPar(bv()->buffer()->params());
+       return par.isRightToLeftPar(bv()->buffer()->params());
 }
 
 
@@ -429,7 +429,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_WORDRIGHT:
                if (!cur.mark())
                        cur.clearSelection();
-               if (rtl(cur))
+               if (isRTL(cur.paragraph()))
                        cursorLeftOneWord(cur);
                else
                        cursorRightOneWord(cur);
@@ -439,7 +439,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_WORDLEFT:
                if (!cur.mark())
                        cur.clearSelection();
-               if (rtl(cur))
+               if (isRTL(cur.paragraph()))
                        cursorRightOneWord(cur);
                else
                        cursorLeftOneWord(cur);
@@ -463,7 +463,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_RIGHTSEL:
                if (!cur.selection())
                        cur.resetAnchor();
-               if (rtl(cur))
+               if (isRTL(cur.paragraph()))
                        cursorLeft(cur, true);
                else
                        cursorRight(cur, true);
@@ -473,7 +473,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_LEFTSEL:
                if (!cur.selection())
                        cur.resetAnchor();
-               if (rtl(cur))
+               if (isRTL(cur.paragraph()))
                        cursorRight(cur, true);
                else
                        cursorLeft(cur, true);
@@ -539,7 +539,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_WORDRIGHTSEL:
                if (!cur.selection())
                        cur.resetAnchor();
-               if (rtl(cur))
+               if (isRTL(cur.paragraph()))
                        cursorLeftOneWord(cur);
                else
                        cursorRightOneWord(cur);
@@ -549,7 +549,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_WORDLEFTSEL:
                if (!cur.selection())
                        cur.resetAnchor();
-               if (rtl(cur))
+               if (isRTL(cur.paragraph()))
                        cursorRightOneWord(cur);
                else
                        cursorLeftOneWord(cur);
@@ -1439,7 +1439,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_FINISHED_LEFT:
                lyxerr << "handle LFUN_FINISHED_LEFT" << endl;
                cur.pop(cur.currentDepth());
-               if (rtl(cur))
+               if (isRTL(cur.paragraph()))
                        cursorLeft(cur, true);
                cur.bv().cursor() = cur;
                break;
@@ -1447,7 +1447,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_FINISHED_RIGHT:
                lyxerr << "handle LFUN_FINISHED_RIGHT" << endl;
                cur.pop(cur.currentDepth());
-               if (!rtl(cur))
+               if (!isRTL(cur.paragraph()))
                        cursorRight(cur, true);
                cur.bv().cursor() = cur;
                break;