]> git.lyx.org Git - lyx.git/commitdiff
the monster patch
authorAndré Pönitz <poenitz@gmx.net>
Thu, 15 Jan 2004 17:34:44 +0000 (17:34 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 15 Jan 2004 17:34:44 +0000 (17:34 +0000)
mathed is completely broken, but it's difficult to imprevo with such a
big patch in the tree.

If things don't improve until tomorrow evening, I'll revert this.

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

95 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/cursor.C
src/cursor.h
src/cursor_slice.C
src/cursor_slice.h
src/factory.C
src/factory.h
src/frontends/LyXView.C
src/frontends/LyXView.h
src/frontends/controllers/ControlSearch.C
src/frontends/controllers/ControlThesaurus.C
src/funcrequest.C
src/funcrequest.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/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/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/lyxfind.C
src/lyxfind.h
src/lyxfunc.C
src/lyxtext.h
src/mathed/ChangeLog
src/mathed/command_inset.C
src/mathed/command_inset.h
src/mathed/formulabase.C
src/mathed/formulabase.h
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_fracbase.C
src/mathed/math_fracbase.h
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_hullinset.C
src/mathed/math_hullinset.h
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_macro.C
src/mathed/math_macro.h
src/mathed/math_nestinset.C
src/mathed/math_nestinset.h
src/mathed/math_oversetinset.C
src/mathed/math_oversetinset.h
src/mathed/math_rootinset.C
src/mathed/math_rootinset.h
src/mathed/math_scriptinset.C
src/mathed/math_scriptinset.h
src/mathed/math_textinset.C
src/mathed/math_textinset.h
src/mathed/math_undersetinset.C
src/mathed/math_undersetinset.h
src/mathed/ref_inset.C
src/mathed/ref_inset.h
src/text3.C
src/undo.C
src/undo.h

index c751f2771bfc3cf8fabeee9334e6af4d059a0d3d..97b946aedfd33df953309d8caff27ff36dcffbd4 100644 (file)
@@ -914,16 +914,16 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
        case LFUN_MOUSE_MOTION: {
                if (!available())
                        return false;
-               FuncRequest cmd1(cmd, bv_);
+               FuncRequest cmd1 = cmd;
                UpdatableInset * inset = bv_->fullCursor().innerInset();
                DispatchResult res;
                if (inset) {
                        cmd1.x -= inset->x();
                        cmd1.y -= inset->y();
-                       res = inset->dispatch(cmd1);
+                       res = inset->dispatch(*bv_, cmd1);
                } else {
                        cmd1.y += bv_->top_y();
-                       res = bv_->fullCursor().innerText()->dispatch(cmd1);
+                       res = bv_->fullCursor().innerText()->dispatch(*bv_, cmd1);
                }
 
                if (bv_->fitCursor() || res.update()) {
@@ -955,17 +955,16 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
 
                // built temporary path to inset
                InsetOld * inset = insetFromCoords(bv_, cmd.x, cmd.y);
-               FuncRequest cmd1(cmd, bv_);
                DispatchResult res;
 
                // try to dispatch to that inset
                if (inset) {
-                       FuncRequest cmd2 = cmd1;
+                       FuncRequest cmd2 = cmd;
                        lyxerr << "dispatching action " << cmd2.action
                               << " to inset " << inset << endl;
                        cmd2.x -= inset->x();
                        cmd2.y -= inset->y();
-                       res = inset->dispatch(cmd2);
+                       res = inset->dispatch(*bv_, cmd2);
                        if (res.update()) {
                                bv_->update();
                                bv_->fullCursor().updatePos();
@@ -992,12 +991,13 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
                // otherwise set cursor to surrounding LyXText
                if (!res.dispatched()) {
                        lyxerr << "temp cursor is: " << theTempCursor << endl;
-                       lyxerr << "dispatching " << cmd1
+                       lyxerr << "dispatching " << cmd
                               << " to surrounding LyXText "
                               << theTempCursor.innerText() << endl;
                        bv_->fullCursor(theTempCursor);
+                       FuncRequest cmd1 = cmd;
                        cmd1.y += bv_->top_y();
-                       res = bv_->fullCursor().innerText()->dispatch(cmd1);
+                       res = bv_->fullCursor().innerText()->dispatch(*bv_, cmd1);
                        if (bv_->fitCursor() || res.update())
                                bv_->update();
 
@@ -1027,12 +1027,9 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
 }
 
 
-bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
+bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
 {
        // Make sure that the cached BufferView is correct.
-       FuncRequest ev = ev_in;
-       ev.setView(bv_);
-
        lyxerr[Debug::ACTION] << "BufferView::Pimpl::Dispatch:"
                << " action[" << ev.action << ']'
                << " arg[" << ev.argument << ']'
@@ -1138,13 +1135,13 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
        case LFUN_MATH_IMPORT_SELECTION: // Imports LaTeX from the X selection
        case LFUN_MATH_DISPLAY:          // Open or create a displayed math inset
        case LFUN_MATH_MODE:             // Open or create an inlined math inset
-               mathDispatch(ev);
+               mathDispatch(*bv_, ev);
                break;
 
        case LFUN_INSET_INSERT: {
                // Same as above.
                BOOST_ASSERT(false);
-               InsetOld * inset = createInset(ev);
+               InsetOld * inset = createInset(bv_, ev);
                if (!inset || !insertInset(inset))
                        delete inset;
                break;
@@ -1236,11 +1233,11 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
        }
 
        case LFUN_WORD_FIND:
-               lyx::find::find(ev);
+               lyx::find::find(bv_, ev);
                break;
 
        case LFUN_WORD_REPLACE:
-               lyx::find::replace(ev);
+               lyx::find::replace(bv_, ev);
                break;
 
        case LFUN_MARK_OFF:
@@ -1275,7 +1272,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev_in)
                break;
 
        default:
-               return bv_->getLyXText()->dispatch(FuncRequest(ev, bv_)).dispatched();
+               return bv_->getLyXText()->dispatch(*bv_, ev).dispatched();
        } // end of switch
 
        return true;
index 2eebfe60009f85fc415739ec72c2e9df35a7c92a..4d3a440c041ba954c1984c6628c3a250e152636c 100644 (file)
@@ -1,3 +1,19 @@
+
+2004-01-15  André Pönitz  <poenitz@gmx.net>
+
+       * cursor_slice.[Ch]: add a few covienience functions
+
+       * funcrequest.[Ch]: remove BufferView * member
+
+       * BufferView_pimpl.C:
+       * cursor.C:
+       * factory.[Ch]:
+       * lyxfind.[Ch]:
+       * lyxfunc.C:
+       * lyxtext.h:
+       * text3.C:
+       * undo.[Ch]: adjust to this and changed signature of Inset::priv_dispatch()
+
 2004-01-14  Alfredo Braunstein  <abraunst@lyx.org>
 
        * text.C (getWord): fix getWord (and thus LFUN_WORDSEL)
index 9af49d463895c585cd9f8e6a162a2e5b78dd8bdf..acd21c840246b5bd31bf260448e2f6867aa4c0af 100644 (file)
@@ -54,7 +54,7 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
        for (int i = cursor_.size() - 1; i >= 1; --i) {
                CursorSlice const & citem = cursor_[i];
                lyxerr << "trying to dispatch to inset " << citem.inset_ << endl;
-               DispatchResult res = citem.inset_->dispatch(cmd);
+               DispatchResult res = citem.inset_->dispatch(*bv_, cmd);
                if (res.dispatched()) {
                        lyxerr << " successfully dispatched to inset " << citem.inset_ << endl;
                        return DispatchResult(true, true);
@@ -63,19 +63,19 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
                switch (res.val()) {
                        case FINISHED:
                                pop(i);
-                               cmd = FuncRequest(bv_, LFUN_FINISHED_LEFT);
+                               cmd = FuncRequest(LFUN_FINISHED_LEFT);
                                break;
                        case FINISHED_RIGHT:
                                pop(i);
-                               cmd = FuncRequest(bv_, LFUN_FINISHED_RIGHT);
+                               cmd = FuncRequest(LFUN_FINISHED_RIGHT);
                                break;
                        case FINISHED_UP:
                                pop(i);
-                               cmd = FuncRequest(bv_, LFUN_FINISHED_UP);
+                               cmd = FuncRequest(LFUN_FINISHED_UP);
                                break;
                        case FINISHED_DOWN:
                                pop(i);
-                               cmd = FuncRequest(bv_, LFUN_FINISHED_DOWN);
+                               cmd = FuncRequest(LFUN_FINISHED_DOWN);
                                break;
                        default:
                                lyxerr << "not handled on level " << i << " val: " << res.val() << endl;
@@ -83,7 +83,7 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
                }
        }
        lyxerr << "trying to dispatch to main text " << bv_->text() << endl;
-       DispatchResult res = bv_->text()->dispatch(cmd);
+       DispatchResult res = bv_->text()->dispatch(*bv_, cmd);
        lyxerr << "   result: " << res.val() << endl;
 
        if (!res.dispatched()) {
@@ -97,7 +97,7 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
 }
 
 
-void LCursor::push(UpdatableInset * inset)
+void LCursor::push(InsetBase * inset)
 {
        lyxerr << "LCursor::push()  inset: " << inset << endl;
        cursor_.push_back(CursorSlice(inset));
@@ -186,9 +186,11 @@ void LCursor::getPos(int & x, int & y) const
                // inset->draw() is not called: this doesn't update
                // inset.top_baseline, so getCursor() returns an old value.
                // Ugly as you like.
-               inset->getCursorPos(cursor_.back().idx_, x, y);
-               x += inset->x();
-               y += cached_y_;
+               if (inset) {
+                       inset->getCursorPos(cursor_.back().idx_, x, y);
+                       x += inset->x();
+                       y += cached_y_;
+               }
        }
 }
 
index 704544cf95026fd0373054f6d36cdfa965fcaa22..9088e3671e4125ebe27a1ede2145bf83515f3f63 100644 (file)
@@ -43,7 +43,7 @@ public:
        /// dispatch from innermost inset upwards
        DispatchResult dispatch(FuncRequest const & cmd);
        ///
-       void push(UpdatableInset * inset);
+       void push(InsetBase * inset);
        /// restrict cursor nesting to given size
        void pop(int depth);
        /// pop one level off the cursor
index ce9b4605c392a04c5f669785ee775dfaa67b286c..ba26f5e87f57e1c2576337668eeba03a38203d65 100644 (file)
@@ -51,6 +51,12 @@ CursorSlice::idx_type CursorSlice::idx() const
 }
 
 
+CursorSlice::idx_type & CursorSlice::idx()
+{
+       return idx_;
+}
+
+
 void CursorSlice::par(par_type par)
 {
        par_ = par;
@@ -63,6 +69,12 @@ CursorSlice::par_type CursorSlice::par() const
 }
 
 
+CursorSlice::par_type & CursorSlice::par()
+{
+       return par_;
+}
+
+
 void CursorSlice::pos(pos_type pos)
 {
        pos_ = pos;
@@ -75,6 +87,20 @@ CursorSlice::pos_type CursorSlice::pos() const
 }
 
 
+CursorSlice::pos_type & CursorSlice::pos()
+{
+       return pos_;
+}
+
+
+CursorSlice::pos_type CursorSlice::lastpos() const
+{
+       BOOST_ASSERT(inset_);
+#warning implement me for texted, too.
+       return inset_->asMathInset() ? cell().size() : 0;
+}
+
+
 void CursorSlice::boundary(bool boundary)
 {
        boundary_ = boundary;
@@ -87,22 +113,29 @@ bool CursorSlice::boundary() const
 }
 
 
-MathInset * CursorSlice::asMathInset() const
+CursorSlice::row_type CursorSlice::row() const
 {
-       return inset_ ? inset_->asMathInset() : 0;
+       BOOST_ASSERT(asMathInset());
+       asMathInset()->row(idx_);
 }
 
 
-UpdatableInset * CursorSlice::asUpdatableInset() const
+CursorSlice::col_type CursorSlice::col() const
 {
-       return inset_ ? inset_->asUpdatableInset() : 0;
+       BOOST_ASSERT(asMathInset());
+       asMathInset()->col(idx_);
 }
 
 
-void CursorSlice::cell(CursorSlice::idx_type idx) const
+MathInset * CursorSlice::asMathInset() const
 {
-       BOOST_ASSERT(asMathInset());
-       asMathInset()->cell(idx);
+       return inset_ ? inset_->asMathInset() : 0;
+}
+
+
+UpdatableInset * CursorSlice::asUpdatableInset() const
+{
+       return inset_ ? inset_->asUpdatableInset() : 0;
 }
 
 
index 0b557bff9d277ad9b7a25c2cedadc4a5c88155ca..303a0e39cddc5c1f02d8a63c2a4c64d1820f15f8 100644 (file)
@@ -45,6 +45,10 @@ public:
        typedef lyx::paroffset_type par_type;
        /// type for cursor positions within a cell
        typedef lyx::pos_type pos_type;
+       /// type for row indices
+       typedef size_t row_type;
+       /// type for col indices
+       typedef size_t col_type;
 
        ///
        CursorSlice();
@@ -55,14 +59,26 @@ public:
        void idx(idx_type idx);
        /// return the paragraph this cursor is in
        idx_type idx() const;
+       /// return the paragraph this cursor is in
+       idx_type & idx();
        /// 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
+       pos_type & pos();
+       /// return the last position within the paragraph
+       pos_type lastpos() const;
+       /// return the grid row of the current cell
+       row_type row() const;
+       /// return the grid row of the current cell
+       col_type col() const;
 
        /// FIXME
        void boundary(bool b);
@@ -81,8 +97,6 @@ public:
        ///
        /// returns cell corresponding to this position
        MathArray & cell() const;
-       /// set cell corresponding to this position
-       void cell(idx_type idx) const;
        /// gets screen position of the thing
        void getScreenPos(int & x, int & y) const;
        ///
index c5aab75b5be17abcfafa5d45018ebad4b852bec4..f5a79b3ec543ba7d9fae794743371a4f566aac82 100644 (file)
@@ -69,9 +69,8 @@ using std::endl;
 using std::string;
 
 
-InsetOld * createInset(FuncRequest const & cmd)
+InsetOld * createInset(BufferView * bv, FuncRequest const & cmd)
 {
-       BufferView * bv = cmd.view();
        BufferParams const & params = bv->buffer()->params();
 
        switch (cmd.action) {
@@ -163,7 +162,7 @@ InsetOld * createInset(FuncRequest const & cmd)
                if (icp.getContents().empty()) {
                        lv->getDialogs().show("index", data, 0);
                } else {
-                       lv->dispatch(FuncRequest(bv, LFUN_INSET_APPLY, data));
+                       lv->dispatch(FuncRequest(LFUN_INSET_APPLY, data));
                }
                return 0;
        }
@@ -235,7 +234,7 @@ InsetOld * createInset(FuncRequest const & cmd)
                        return new InsetERT(params, st);
 
                } else if (name == "external") {
-                       Buffer const & buffer = *cmd.view()->buffer();
+                       Buffer const & buffer = *bv->buffer();
                        InsetExternalParams iep;
                        InsetExternalMailer::string2params(cmd.argument,
                                                           buffer, iep);
@@ -244,7 +243,7 @@ InsetOld * createInset(FuncRequest const & cmd)
                        return inset.release();
 
                } else if (name == "graphics") {
-                       Buffer const & buffer = *cmd.view()->buffer();
+                       Buffer const & buffer = *bv->buffer();
                        InsetGraphicsParams igp;
                        InsetGraphicsMailer::string2params(cmd.argument,
                                                           buffer, igp);
index f9d76b39c50309825a1211446f3505a44d67b370..d1a6d5e32efddd01d59b0302dcc93f8db101d806 100644 (file)
 #ifndef FACTORY_H
 #define FACTORY_H
 
-class InsetOld;
+class Buffer;
+class BufferView;
 class FuncRequest;
+class InsetOld;
 class LyXLex;
-class Buffer;
+
 
 /// creates inset according to 'cmd'
-InsetOld * createInset(FuncRequest const & cmd);
+InsetOld * createInset(BufferView * bv, FuncRequest const & cmd);
 
 /// read inset from a file
 InsetOld * readInset(LyXLex & lex, Buffer const & buf);
index a018e067ce98cdbab7dfaa78207e044fc20929a1..ef85ab161230e4ab464f848a9419b76eb755089a 100644 (file)
@@ -185,12 +185,9 @@ void LyXView::updateWindowTitle()
 }
 
 
-void LyXView::dispatch(FuncRequest const & req)
+void LyXView::dispatch(FuncRequest const & cmd)
 {
-       // substitute the correct BufferView here
-       FuncRequest r = req;
-       r.setView(view().get());
-       getLyXFunc().dispatch(r);
+       getLyXFunc().dispatch(cmd);
 }
 
 
index c16c7a9a331eefc2ce48ec0f7e3a0b4e0680acf3..96b1ebb71d0d7753379cf8d1b29db2f55be0d0fe 100644 (file)
@@ -130,7 +130,7 @@ public:
        void resetAutosaveTimer();
 
        /// dispatch to current BufferView
-       void dispatch(FuncRequest const & req);
+       void dispatch(FuncRequest const & cmd);
 
        /** redraw \c inset in all the BufferViews in which it is currently
         *  visible. If successful return a pointer to the owning Buffer.
index 075316f9d0dae9c6dd15c7bd3757c29bdccaf363..5bd503ad018d7f37971907eb9c95f0fca14a43f8 100644 (file)
@@ -34,19 +34,15 @@ void ControlSearch::find(string const & search,
        string const data =
                lyx::find::find2string(search,
                                       casesensitive, matchword, forward);
-       FuncRequest const fr(bufferview(), LFUN_WORD_FIND, data);
-       lv_.dispatch(fr);
+       lv_.dispatch(FuncRequest(LFUN_WORD_FIND, data));
 }
 
 
 void ControlSearch::replace(string const & search, string const & replace,
-                           bool casesensitive, bool matchword,
-                           bool forward, bool all)
+                           bool casesensitive, bool matchword, bool forward, bool all)
 {
        string const data =
                lyx::find::replace2string(search, replace,
-                                         casesensitive, matchword,
-                                         all, forward);
-       FuncRequest const fr(bufferview(), LFUN_WORD_REPLACE, data);
-       lv_.dispatch(fr);
+                                         casesensitive, matchword, all, forward);
+       lv_.dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
 }
index 6ea45d044d75ee7d4fb6c070cb2b9eaad47a7ac9..fe60194256d4354549f426d52290cf30dbfdcb6b 100644 (file)
@@ -48,16 +48,13 @@ void ControlThesaurus::replace(string const & newstr)
                                          true,  // match word
                                          false, // all words
                                          true); // forward
-       FuncRequest const fr(kernel().bufferview(), LFUN_WORD_REPLACE, data);
-       kernel().dispatch(fr);
+       kernel().dispatch(FuncRequest(LFUN_WORD_REPLACE, data));
 }
 
 
-Thesaurus::Meanings const &
-ControlThesaurus::getMeanings(string const & str)
+Thesaurus::Meanings const & ControlThesaurus::getMeanings(string const & str)
 {
        if (str != laststr_)
                meanings_ = thesaurus.lookup(str);
-
        return meanings_;
 }
index 108fe2a2617599ea154a901c32a0fb64e2380004..8dfd9f6d792f3e10cdf3a6906fa822824f97a297 100644 (file)
@@ -28,66 +28,31 @@ using std::string;
 
 
 FuncRequest::FuncRequest()
-       : view_(0), action(LFUN_NOACTION), x(0), y(0), button_(mouse_button::none)
+       : action(LFUN_NOACTION), x(0), y(0), button_(mouse_button::none)
 {}
 
 
 FuncRequest::FuncRequest(kb_action act)
-       : view_(0), action(act), x(0), y(0), button_(mouse_button::none)
+       : action(act), x(0), y(0), button_(mouse_button::none)
 {}
 
 
 FuncRequest::FuncRequest(kb_action act, string const & arg)
-       : view_(0), action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
+       : action(act), argument(arg), x(0), y(0), button_(mouse_button::none)
 {}
 
 
-FuncRequest::FuncRequest
-               (kb_action act, int ax, int ay, mouse_button::state button)
-       : view_(0), action(act), x(ax), y(ay), button_(button)
-{}
-
-
-FuncRequest::FuncRequest(BufferView * view, kb_action act)
-       : view_(view), action(act), x(0), y(0), button_(mouse_button::none)
-{}
-
-
-FuncRequest::FuncRequest(BufferView * view, kb_action act, string const & arg)
-       : view_(view), action(act), argument(arg), x(0),  y(0), button_(mouse_button::none)
-{}
-
-
-FuncRequest::FuncRequest
-               (BufferView * view, kb_action act, int ax, int ay, mouse_button::state but)
-       : view_(view), action(act), x(ax), y(ay), button_(but)
+FuncRequest::FuncRequest(kb_action act, int ax, int ay, mouse_button::state but)
+       : action(act), x(ax), y(ay), button_(but)
 {}
 
 
 FuncRequest::FuncRequest(FuncRequest const & cmd, string const & arg)
-       : view_(cmd.view_), action(cmd.action), argument(arg),
+       : action(cmd.action), argument(arg),
          x(cmd.x), y(cmd.y), button_(cmd.button_)
 {}
 
 
-FuncRequest::FuncRequest(FuncRequest const & cmd, BufferView * view)
-       : view_(view), action(cmd.action), argument(cmd.argument),
-         x(cmd.x), y(cmd.y), button_(cmd.button_)
-{}
-
-
-BufferView * FuncRequest::view() const
-{
-       return view_;
-}
-
-
-void FuncRequest::setView(BufferView * view)
-{
-       view_ = view;
-}
-
-
 mouse_button::state FuncRequest::button() const
 {
        return button_;
@@ -96,19 +61,21 @@ mouse_button::state FuncRequest::button() const
 
 void FuncRequest::message(string const & msg) const
 {
-       if (view_)
-               view_->owner()->getLyXFunc().setMessage(msg);
-       else
-               lyxerr  << "Dropping message '" << msg << "'" << endl;
+#warning FIXME
+       //if (view_)
+       //      view_->owner()->getLyXFunc().setMessage(msg);
+       //else
+       lyxerr  << "Dropping message '" << msg << "'" << endl;
 }
 
 
 void FuncRequest::errorMessage(string const & msg) const
 {
-       if (view_)
-               view_->owner()->getLyXFunc().setErrorMessage(msg);
-       else
-               lyxerr  << "Dropping error message '" << msg << "'" << endl;
+#warning FIXME
+       //if (view_)
+       //      view_->owner()->getLyXFunc().setErrorMessage(msg);
+       //else
+       lyxerr  << "Dropping error message '" << msg << "'" << endl;
 }
 
 
index 9501ca9da19d60f5268db33a6154ae92fb8696cf..8224d29460e857cdc41e92648cec43c2f0ad9fb2 100644 (file)
@@ -18,8 +18,6 @@
 #include <string>
 #include <iosfwd>
 
-class BufferView;
-
 /**
  * This class encapsulates a LyX action and its argument
  * in order to pass it around easily.
@@ -34,22 +32,9 @@ public:
        FuncRequest(kb_action act, int x, int y, mouse_button::state button);
        /// actions with extra argument
        FuncRequest(kb_action act, std::string const & arg);
-       /// actions without extra argument
-       FuncRequest(BufferView * bv, kb_action act);
-       /// actions with extra argument
-       FuncRequest(BufferView * bv, kb_action act, std::string const & arg);
-       /// for mouse events
-       FuncRequest(BufferView * bv, kb_action act,
-               int x, int y, mouse_button::state button);
        /// for changing requests a bit
        FuncRequest(FuncRequest const & cmd, std::string const & arg);
-       /// for changing requests a bit
-       FuncRequest(FuncRequest const & cmd, BufferView * bv);
 
-       /// access to the view
-       BufferView * view() const;
-       /// access to the view
-       void setView(BufferView * bv);
        /// access to button
        mouse_button::state button() const;
 
@@ -61,10 +46,7 @@ public:
        /// argument parsing, extract argument i as std::string
        std::string getArg(unsigned int i) const;
 
-private:
-       /// the BufferView we are talking to
-       BufferView * view_;
-public:  // should be private, too...
+public:  // should be private
        /// the action
        kb_action action;
        /// the action's std::string argument
index e5cee8549ce4a01051158609b06e7ffc29609b89..9bbdf1e70b477314863f1bb010ba99a437da4f58 100644 (file)
@@ -1,4 +1,28 @@
 
+2004-01-15  André Pönitz  <poenitz@gmx.net>
+
+       * insetbase.[Ch]:
+       * insetbibitem.[Ch]:
+       * insetbibtex.[Ch]:
+       * insetbox.[Ch]:
+       * insetbranch.[Ch]:
+       * insetcharstyle.[Ch]:
+       * insetcollapsable.[Ch]:
+       * insetcommand.[Ch]:
+       * insetert.[Ch]:
+       * insetexternal.[Ch]:
+       * insetfloat.[Ch]:
+       * insetgraphics.[Ch]:
+       * insetinclude.[Ch]:
+       * insetlabel.[Ch]:
+       * insetnote.[Ch]:
+       * insetref.[Ch]:
+       * insettabular.[Ch]:
+       * insettext.[Ch]:
+       * insetvspace.[Ch]:
+       * insetwrap.[Ch]:
+       * updatableinset.[Ch] (priv_dispatch et al): change signature.
+
 2004-01-08  André Pönitz  <poenitz@gmx.net>
 
        * insetcollapsable.[Ch]:
index fea008ea8be8627e6fff22c6b8b11dda6acc626f..c9c606203eb38394feb570680c11a4a608ab236d 100644 (file)
 #include "dispatchresult.h"
 
 
-DispatchResult
-InsetBase::dispatch(FuncRequest const & f, idx_type & i, pos_type & p)
-{
-       return priv_dispatch(f, i, p);
-}
-
-
-DispatchResult
-InsetBase::dispatch(FuncRequest const & f)
+DispatchResult InsetBase::dispatch(BufferView & bv, FuncRequest const & cmd)
 {
-       idx_type i = 0;
-       pos_type p = 0;
-       return priv_dispatch(f, i, p);
+       return priv_dispatch(bv, cmd);
 }
 
 
 DispatchResult
-InsetBase::priv_dispatch(FuncRequest const &, idx_type &, pos_type &)
+InsetBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        return DispatchResult(false);
 }
index a7de6df4ed622041bbe979f32df81eadcd7b7945..3302b99d9bde1eb970ac564e52a8834712f30161 100644 (file)
@@ -54,10 +54,7 @@ public:
        virtual UpdatableInset * asUpdatableInset() { return 0; }
 
        // the real dispatcher
-       DispatchResult
-       dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
-       // the real dispatcher
-       DispatchResult dispatch(FuncRequest const & cmd);
+       DispatchResult dispatch(BufferView & bv, FuncRequest const & cmd);
 
        /// cursor enters
        virtual void edit(BufferView * bv, bool left);
@@ -77,8 +74,7 @@ public:
 protected:
        // the real dispatcher
        virtual
-       DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       DispatchResult priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 };
 
 #endif
index 25ed6a6b53e05c0d2986014f4a3eca0afe276d41..6a732d716e1f574ed7db234d577aaaf49668c582 100644 (file)
@@ -54,8 +54,7 @@ auto_ptr<InsetBase> InsetBibitem::clone() const
 
 
 DispatchResult
-InsetBibitem::priv_dispatch(FuncRequest const & cmd,
-                           idx_type & idx, pos_type & pos)
+InsetBibitem::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
@@ -65,13 +64,13 @@ InsetBibitem::priv_dispatch(FuncRequest const & cmd,
                if (p.getCmdName().empty())
                        return DispatchResult(true, true);
                setParams(p);
-               cmd.view()->update();
-               cmd.view()->fitCursor();
+               bv.update();
+               bv.fitCursor();
                return DispatchResult(true, true);
        }
 
        default:
-               return InsetCommand::priv_dispatch(cmd, idx, pos);
+               return InsetCommand::priv_dispatch(bv, cmd);
        }
 }
 
index 96fe35a949d8eb7379c5552e068bf0f3aa7d23f3..b64a72f45c4ad575cfb896c9215e6d438ad70793 100644 (file)
@@ -52,7 +52,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        ///
        int counter;
index 028d1dfe718e2c2819dc1e6cc7675d30cf5fd3a6..bfc7806ffa8536ac7bad87c578a17c3cd4a23778 100644 (file)
@@ -66,11 +66,8 @@ std::auto_ptr<InsetBase> InsetBibtex::clone() const
 
 
 DispatchResult
-InsetBibtex::priv_dispatch(FuncRequest const & cmd,
-                          idx_type & idx, pos_type & pos)
+InsetBibtex::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
-       DispatchResult result(false);
-       
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
@@ -78,17 +75,12 @@ InsetBibtex::priv_dispatch(FuncRequest const & cmd,
                InsetCommandMailer::string2params("bibtex", cmd.argument, p);
                if (!p.getCmdName().empty())
                        setParams(p);
-               result.dispatched(true);
-               result.update(true);
+               return DispatchResult(true, true);
        }
-               break;
                
        default:
-               result = InsetCommand::priv_dispatch(cmd, idx, pos);
-               break;
+               return InsetCommand::priv_dispatch(bv, cmd);
        }
-
-       return result;
 }
 
 
index f00f1ffb0af824cdffb374fc80c8c6e534c85c11..2146fff6ed404e28c6cb1e69088e4691365fc923 100644 (file)
@@ -48,7 +48,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 };
 
 #endif // INSET_BIBTEX_H
index e4547b6c1ca93c51b025bd6ad32c75e0f4fc7370..bcc0ab67f73c9d196f2a4ec90c8bda9f8ef3fa71 100644 (file)
@@ -170,37 +170,30 @@ bool InsetBox::showInsetDialog(BufferView * bv) const
 
 
 DispatchResult
-InsetBox::priv_dispatch(FuncRequest const & cmd,
-                       idx_type & idx, pos_type & pos)
+InsetBox::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
-       DispatchResult result(false);
-       BufferView * bv = cmd.view();
-
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
                lyxerr << "InsetBox::dispatch MODIFY" << endl;
                InsetBoxMailer::string2params(cmd.argument, params_);
                setButtonLabel();
-               result.dispatched(true);
-               result.update(true);
-               return result;
+               return DispatchResult(true, true);
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
-               InsetBoxMailer(*this).updateDialog(bv);
-               result.dispatched(true);
-               return result;
+               InsetBoxMailer(*this).updateDialog(&bv);
+               return DispatchResult(true);
 
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
-                       InsetBoxMailer(*this).showDialog(bv);
+                       InsetBoxMailer(*this).showDialog(&bv);
                        return DispatchResult(true);
                }
-               return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+               return InsetCollapsable::priv_dispatch(bv, cmd);
 
        default:
-               return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+               return InsetCollapsable::priv_dispatch(bv, cmd);
        }
 }
 
index 7be734f89e1c78ac0d2b0ae77f4276b04df235aa..af396197b47a8dbb8878aa4797a1a91a312040d8 100644 (file)
@@ -107,7 +107,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        friend class InsetBoxParams;
 
index 67ecbc6e0b052376ab15797e12f3325fe6bbf53c..37c3b81ec3ce987d1ef56ecfd23b9160239329ac 100644 (file)
@@ -111,10 +111,8 @@ bool InsetBranch::showInsetDialog(BufferView * bv) const
 
 
 DispatchResult
-InsetBranch::priv_dispatch(FuncRequest const & cmd,
-                          idx_type & idx, pos_type & pos)
+InsetBranch::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
-       BufferView * bv = cmd.view();
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
                InsetBranchParams params;
@@ -126,22 +124,22 @@ InsetBranch::priv_dispatch(FuncRequest const & cmd,
 
        case LFUN_MOUSE_PRESS:
                if (cmd.button() != mouse_button::button3)
-                       return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+                       return InsetCollapsable::priv_dispatch(bv, cmd);
                return DispatchResult(false);
 
        case LFUN_INSET_DIALOG_UPDATE:
-               InsetBranchMailer(*this).updateDialog(bv);
+               InsetBranchMailer(*this).updateDialog(&bv);
                return DispatchResult(true);
 
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
-                       InsetBranchMailer(*this).showDialog(bv);
+                       InsetBranchMailer(*this).showDialog(&bv);
                        return DispatchResult(true);
                }
-               return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+               return InsetCollapsable::priv_dispatch(bv, cmd);
 
        default:
-               return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+               return InsetCollapsable::priv_dispatch(bv, cmd);
        }
 }
 
index f76465c2c970cf72cd41d174c9349fd5f0268714..89dcb076b0ddf09793672342788a9e79f2732ed8 100644 (file)
@@ -83,7 +83,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        friend class InsetBranchParams;
 
index dd7c66f7831a6f471a2d5db3f8382d3275186169..9189d35544e92b212fa9e9ea4454d87c44d3ecfe 100644 (file)
@@ -134,7 +134,7 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
        int a = 0;
        int d = 0;
        font_metrics::rectText(params_.type, font, w, a, d);
-       pi.pain.rectText(x + 0.5 * (dim_.wid - w)
+       pi.pain.rectText(x + (dim_.wid - w) / 2
                y + inset.descent() + a,
                params_.type, font, LColor::none, LColor::none);
        }
@@ -148,8 +148,7 @@ void InsetCharStyle::getDrawFont(LyXFont & font) const
 
 
 DispatchResult
-InsetCharStyle::priv_dispatch(FuncRequest const & cmd,
-                       idx_type & idx, pos_type & pos)
+InsetCharStyle::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        setStatus(Inlined);
        switch (cmd.action) {
@@ -158,11 +157,10 @@ InsetCharStyle::priv_dispatch(FuncRequest const & cmd,
                                has_label_ = !has_label_;
                                return DispatchResult(true);
                        }
-                       inset.dispatch(cmd);
+                       inset.dispatch(bv, cmd);
                        return DispatchResult(true, true);
-                       break;
                default:
-                       return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+                       return InsetCollapsable::priv_dispatch(bv, cmd);
        }
 }
 
index d7c3f4cd80d58ba5988b805dce79f59924ece675..58104ba35684afdfb97549b117385ad0b84020ef 100644 (file)
@@ -87,7 +87,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 
 private:
        friend class InsetCharStyleParams;
index 1f1620982b6ff41ada2a60fce43f55632ee37466..b850b4d42b350c142211e2b05d8c983afc93628c 100644 (file)
@@ -213,13 +213,12 @@ FuncRequest InsetCollapsable::adjustCommand(FuncRequest const & cmd)
 }
 
 
-DispatchResult InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
+DispatchResult
+InsetCollapsable::lfunMouseRelease(BufferView & bv, FuncRequest const & cmd)
 {
-       BufferView * bv = cmd.view();
-
        if (cmd.button() == mouse_button::button3) {
                lyxerr << "InsetCollapsable::lfunMouseRelease 0" << endl;
-               showInsetDialog(bv);
+               showInsetDialog(&bv);
                return DispatchResult(true, true);
        }
 
@@ -227,7 +226,7 @@ DispatchResult InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
        case Collapsed:
                lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
                setStatus(Open);
-               edit(bv, true);
+               edit(&bv, true);
                return DispatchResult(true, true);
 
        case Open:
@@ -235,13 +234,12 @@ DispatchResult InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
                        lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
                        setStatus(Collapsed);
                        return DispatchResult(false, FINISHED_RIGHT);
-               } else {
-                       lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
-                       return inset.dispatch(adjustCommand(cmd));
-               }       
+               }
+               lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
+               return inset.dispatch(bv, adjustCommand(cmd));
 
        case Inlined:
-               return inset.dispatch(cmd);
+               return inset.dispatch(bv, cmd);
        }
 
        return DispatchResult(true, true);
@@ -329,27 +327,27 @@ void InsetCollapsable::edit(BufferView * bv, int x, int y)
 
 
 DispatchResult
-InsetCollapsable::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+InsetCollapsable::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        //lyxerr << "\nInsetCollapsable::priv_dispatch (begin): cmd: " << cmd
        //      << "  button y: " << button_dim.y2 << endl;
        switch (cmd.action) {
                case LFUN_MOUSE_PRESS:
                        if (status_ == Inlined)
-                               inset.dispatch(cmd);
+                               inset.dispatch(bv, cmd);
                        else if (status_ == Open && cmd.y > button_dim.y2)
-                               inset.dispatch(adjustCommand(cmd));
+                               inset.dispatch(bv, adjustCommand(cmd));
                        return DispatchResult(true, true);
 
                case LFUN_MOUSE_MOTION:
                        if (status_ == Inlined)
-                               inset.dispatch(cmd);
+                               inset.dispatch(bv, cmd);
                        else if (status_ == Open && cmd.y > button_dim.y2)
-                               inset.dispatch(adjustCommand(cmd));
+                               inset.dispatch(bv, adjustCommand(cmd));
                        return DispatchResult(true, true);
 
                case LFUN_MOUSE_RELEASE:
-                       return lfunMouseRelease(cmd);
+                       return lfunMouseRelease(bv, cmd);
 
                case LFUN_INSET_TOGGLE:
                        if (inset.text_.toggleInset())
@@ -363,7 +361,7 @@ InsetCollapsable::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
                        }
 
                default:
-                       return inset.dispatch(adjustCommand(cmd));
+                       return inset.dispatch(bv, adjustCommand(cmd));
        }
        //lyxerr << "InsetCollapsable::priv_dispatch (end)" << endl;
 }
@@ -463,13 +461,13 @@ void InsetCollapsable::setLabelFont(LyXFont & font)
 }
 
 
-void InsetCollapsable::scroll(BufferView * bv, float sx) const
+void InsetCollapsable::scroll(BufferView & bv, float sx) const
 {
        UpdatableInset::scroll(bv, sx);
 }
 
 
-void InsetCollapsable::scroll(BufferView * bv, int offset) const
+void InsetCollapsable::scroll(BufferView & bv, int offset) const
 {
        UpdatableInset::scroll(bv, offset);
 }
index be75893a9d36218ca8a8eb246e6efbd9dde09f93..232e7d00d7254798f37f33004b93474bdea624af 100644 (file)
@@ -91,9 +91,9 @@ public:
        ///
        int scroll(bool recursive=true) const;
        ///
-       void scroll(BufferView *bv, float sx) const;
+       void scroll(BufferView bv, float sx) const;
        ///
-       void scroll(BufferView *bv, int offset) const;
+       void scroll(BufferView bv, int offset) const;
        ///
        int numParagraphs() const;
        ///
@@ -121,7 +121,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
        ///
        void dimension_collapsed(Dimension &) const;
        ///
@@ -139,7 +139,7 @@ protected:
 
 private:
        ///
-       DispatchResult lfunMouseRelease(FuncRequest const &);
+       DispatchResult lfunMouseRelease(BufferView & bv, FuncRequest const &);
        ///
        FuncRequest adjustCommand(FuncRequest const &);
 
index 80d5ae8d12b2270f51ea265516f3ec5462b7685e..354acc3831ad09bcc4acf9b8e0e9d3ea2cfc24b4 100644 (file)
@@ -100,7 +100,7 @@ int InsetCommand::docbook(Buffer const &, ostream &,
 
 
 DispatchResult
-InsetCommand::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+InsetCommand::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
@@ -108,21 +108,19 @@ InsetCommand::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
                InsetCommandMailer::string2params(mailer_name_, cmd.argument, p);
                if (p.getCmdName().empty())
                        return DispatchResult(false);
-
                setParams(p);
-               cmd.view()->update();
+               bv.update();
                return DispatchResult(true, true);
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
-               InsetCommandMailer(cmd.argument, *this).updateDialog(cmd.view());
+               InsetCommandMailer(cmd.argument, *this).updateDialog(&bv);
                return DispatchResult(true, true);
 
        case LFUN_INSET_DIALOG_SHOW:
        case LFUN_MOUSE_RELEASE: {
                if (!mailer_name_.empty())
-                       InsetCommandMailer(mailer_name_, *this).
-                               showDialog(cmd.view());
+                       InsetCommandMailer(mailer_name_, *this).showDialog(&bv);
                return DispatchResult(true);
        }
 
index 829db405bb9164fa0eecece0157febabdb18e1f8..c20d3efe0a9af95f6c45df2b1136f51cbed25bb6 100644 (file)
@@ -77,7 +77,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
        ///
        std::string const getCommand() const { return p_.getCommand(); }
        ///
index e81ec4795f7ec1e08aa23a4d7d1d5ff4480dce0a..897fc621b067e215083799698d281194666098dc 100644 (file)
@@ -208,19 +208,16 @@ int InsetERT::docbook(Buffer const &, ostream & os,
 }
 
 
-DispatchResult
-InsetERT::priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
+DispatchResult InsetERT::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
-       case LFUN_INSET_MODIFY:
-                {
-                       InsetCollapsable::CollapseStatus st;
-
-                       InsetERTMailer::string2params(cmd.argument, st);
-                       setStatus(st);
-                       return DispatchResult(true, true);
-               }
+       case LFUN_INSET_MODIFY: {
+               InsetCollapsable::CollapseStatus st;
+               InsetERTMailer::string2params(cmd.argument, st);
+               setStatus(st);
+               return DispatchResult(true, true);
+       }
 
        case LFUN_LAYOUT:
        case LFUN_BOLD:
@@ -240,7 +237,7 @@ InsetERT::priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos)
                return DispatchResult(true);
 
        default:
-               return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+               return InsetCollapsable::priv_dispatch(bv, cmd);
        }
 }
 
index ef23eb1f6cf7f782ad7017e84dfb5a72601a4787..a200c7921c43ae63f487c2cfb09104f46d49383c 100644 (file)
@@ -76,7 +76,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        ///
        void init();
index afe126119f10a8790733acc287c1ab5e293f253a..654342b74dc9bd0e12dd3e27b8edac8195ba83bb 100644 (file)
@@ -441,14 +441,12 @@ void InsetExternal::statusChanged() const
 
 
 DispatchResult
-InsetExternal::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+InsetExternal::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
        case LFUN_EXTERNAL_EDIT: {
-               BOOST_ASSERT(cmd.view());
-
-               Buffer const & buffer = *cmd.view()->buffer();
+               Buffer const & buffer = *bv.buffer();
                InsetExternalParams p;
                InsetExternalMailer::string2params(cmd.argument, buffer, p);
                external::editExternal(p, buffer);
@@ -456,22 +454,20 @@ InsetExternal::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
        }
 
        case LFUN_INSET_MODIFY: {
-               BOOST_ASSERT(cmd.view());
-
-               Buffer const & buffer = *cmd.view()->buffer();
+               Buffer const & buffer = *bv.buffer();
                InsetExternalParams p;
                InsetExternalMailer::string2params(cmd.argument, buffer, p);
                setParams(p, buffer);
-               cmd.view()->update();
+               bv.update();
                return DispatchResult(true, true);
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
-               InsetExternalMailer(*this).updateDialog(cmd.view());
+               InsetExternalMailer(*this).updateDialog(&bv);
                return DispatchResult(true, true);
 
        case LFUN_MOUSE_RELEASE:
-               InsetExternalMailer(*this).showDialog(cmd.view());
+               InsetExternalMailer(*this).showDialog(&bv);
                return DispatchResult(true, true);
 
        default:
index 4bd37d33503cf73842ed4aeea90269659a7e3f8a..0f65f54d4f6a32072552a2801a60405d5495a7d7 100644 (file)
@@ -152,7 +152,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        /** This method is connected to the graphics loader, so we are
         *  informed when the image has been loaded.
index 46a7f1ac5c1b3e1088919c725df2043bd6667025..0ed46be8a3b4131ccfd3318684165f26e29ff323 100644 (file)
@@ -156,30 +156,27 @@ InsetFloat::~InsetFloat()
 
 
 DispatchResult
-InsetFloat::priv_dispatch(FuncRequest const & cmd,
-                         idx_type & idx, pos_type & pos)
+InsetFloat::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
                InsetFloatParams params;
                InsetFloatMailer::string2params(cmd.argument, params);
-
                params_.placement = params.placement;
                params_.wide      = params.wide;
-
-               wide(params_.wide, cmd.view()->buffer()->params());
-               cmd.view()->update();
+               wide(params_.wide, bv.buffer()->params());
+               bv.update();
                return DispatchResult(true, true);
        }
 
        case LFUN_INSET_DIALOG_UPDATE: {
-               InsetFloatMailer(*this).updateDialog(cmd.view());
+               InsetFloatMailer(*this).updateDialog(&bv);
                return DispatchResult(true, true);
        }
 
        default:
-               return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+               return InsetCollapsable::priv_dispatch(bv, cmd);
        }
 }
 
index d7a045cf101f144569e2b34f9129104653bc950c..d738916645967fef887a2d370c7f3009a3dd028f 100644 (file)
@@ -80,7 +80,7 @@ public:
 protected:
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        ///
        InsetFloatParams params_;
index 257efeece25264d28ab3ba6d5136b2edb9c552dc..f9f5e1352f8cb558e7178860bfa9f8e4c67798f1 100644 (file)
@@ -192,26 +192,26 @@ void InsetGraphics::statusChanged() const
 
 
 DispatchResult
-InsetGraphics::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+InsetGraphics::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
-               Buffer const & buffer = *cmd.view()->buffer();
+               Buffer const & buffer = *bv.buffer();
                InsetGraphicsParams p;
                InsetGraphicsMailer::string2params(cmd.argument, buffer, p);
                if (!p.filename.empty()) {
                        setParams(p);
-                       cmd.view()->update();
+                       bv.update();
                }
                return DispatchResult(true, true);
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
-               InsetGraphicsMailer(*this).updateDialog(cmd.view());
+               InsetGraphicsMailer(*this).updateDialog(&bv);
                return DispatchResult(true, true);
 
        case LFUN_MOUSE_RELEASE:
-               InsetGraphicsMailer(*this).showDialog(cmd.view());
+               InsetGraphicsMailer(*this).showDialog(&bv);
                return DispatchResult(true, true);
 
        default:
index 7efcf15ceba99ed9a9984e61e6bbd7f3f4579d16..bd7b4f08cab0a9f82209578c31f851a54772303e 100644 (file)
@@ -83,7 +83,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        ///
        friend class InsetGraphicsMailer;
index 2b5d00b857a70a1277bb077e655bb8f5505d15a9..e79356d7d9da4edb1f3e0b93420c835cc42625fe 100644 (file)
@@ -108,7 +108,7 @@ InsetInclude::~InsetInclude()
 
 
 DispatchResult
-InsetInclude::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+InsetInclude::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
@@ -116,23 +116,23 @@ InsetInclude::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
                InsetCommandParams p;
                InsetIncludeMailer::string2params(cmd.argument, p);
                if (!p.getCmdName().empty()) {
-                       set(p, *cmd.view()->buffer());
-                       cmd.view()->update();
+                       set(p, *bv.buffer());
+                       bv.update();
                }
                return DispatchResult(true, true);
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
-               InsetIncludeMailer(*this).updateDialog(cmd.view());
+               InsetIncludeMailer(*this).updateDialog(&bv);
                return DispatchResult(true, true);
 
        case LFUN_MOUSE_RELEASE:
                if (button_.box().contains(cmd.x, cmd.y))
-                       InsetIncludeMailer(*this).showDialog(cmd.view());
+                       InsetIncludeMailer(*this).showDialog(&bv);
                return DispatchResult(true, true);
 
        case LFUN_INSET_DIALOG_SHOW:
-               InsetIncludeMailer(*this).showDialog(cmd.view());
+               InsetIncludeMailer(*this).showDialog(&bv);
                return DispatchResult(true, true);
 
        default:
index 95247a5e5aa63a95bf4f07e5995951bdcdb14343..456abb80a848782566247c55fdb6cd43fbcc4022 100644 (file)
@@ -85,7 +85,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        /// Slot receiving a signal that the preview is ready to display.
        void statusChanged() const;
index 6276c36194b56824109b9e92f429beb1e277ea23..07a2b287635aff366199b73752f411c8aa744b7e 100644 (file)
@@ -52,12 +52,8 @@ string const InsetLabel::getScreenLabel(Buffer const &) const
 
 
 DispatchResult
-InsetLabel::priv_dispatch(FuncRequest const & cmd,
-                         idx_type & idx, pos_type & pos)
+InsetLabel::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
-       BOOST_ASSERT(cmd.view());
-       BufferView * const bv = cmd.view();
-
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
@@ -65,20 +61,17 @@ InsetLabel::priv_dispatch(FuncRequest const & cmd,
                InsetCommandMailer::string2params("label", cmd.argument, p);
                if (p.getCmdName().empty())
                        return DispatchResult(false);
-
                bool clean = true;
-               if (bv && p.getContents() != params().getContents()) {
-                       clean = bv->ChangeRefsIfUnique(params().getContents(),
+               if (p.getContents() != params().getContents())
+                       clean = bv.ChangeRefsIfUnique(params().getContents(),
                                                       p.getContents());
-               }
-
                setParams(p);
-               bv->update();
+               bv.update();
                return DispatchResult(true, true);
        }
 
        default:
-               return InsetCommand::priv_dispatch(cmd, idx, pos);
+               return InsetCommand::priv_dispatch(bv, cmd);
        }
 }
 
index d81f71556bc99a9412300fb00eb9434deb879bc4..8bdea8a29178e0382292fa4ffba3d126086f4bae 100644 (file)
@@ -44,7 +44,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 };
 
 #endif
index 3a8c38a2d340545a0251bae1de0aa28ea73860ee..58c3546c889da6c5e2ae07a9ee4713be132e1915 100644 (file)
@@ -184,33 +184,30 @@ bool InsetNote::showInsetDialog(BufferView * bv) const
 
 
 DispatchResult
-InsetNote::priv_dispatch(FuncRequest const & cmd,
-                        idx_type & idx, pos_type & pos)
+InsetNote::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
-       BufferView * bv = cmd.view();
-
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
                InsetNoteMailer::string2params(cmd.argument, params_);
                setButtonLabel();
-               bv->update();
+               bv.update();
                return DispatchResult(true, true);
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
-               InsetNoteMailer(*this).updateDialog(bv);
+               InsetNoteMailer(*this).updateDialog(&bv);
                return DispatchResult(true, true);
 
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button3 && hitButton(cmd)) {
-                       InsetNoteMailer(*this).showDialog(bv);
+                       InsetNoteMailer(*this).showDialog(&bv);
                        return DispatchResult(true, true);
                }
-               // fallthrough:
+               return InsetCollapsable::priv_dispatch(bv, cmd);
 
        default:
-               return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+               return InsetCollapsable::priv_dispatch(bv, cmd);
        }
 }
 
index c2d660f5188276847c45600d5414182a51379a4c..bf58055955f2f75678feeedc4609a1ee23b2c6c3 100644 (file)
@@ -77,7 +77,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        friend class InsetNoteParams;
 
index af6c17cba2894e8df844345bfcff2aa93d465a94..da32aa0c4abc1d94891b94fd51c500304a12c830 100644 (file)
@@ -40,21 +40,19 @@ InsetRef::InsetRef(InsetRef const & ir)
 
 
 DispatchResult
-InsetRef::priv_dispatch(FuncRequest const & cmd,
-                       idx_type & idx, pos_type & pos)
+InsetRef::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_MOUSE_PRESS:
                // Eventually trigger dialog with button 3 not 1
                if (cmd.button() == mouse_button::button3)
-                       cmd.view()->owner()->
-                               dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
+                       bv.owner()->dispatch(FuncRequest(LFUN_REF_GOTO, getContents()));
                else
-                       InsetCommandMailer("ref", *this).showDialog(cmd.view());
+                       InsetCommandMailer("ref", *this).showDialog(&bv);
                return DispatchResult(true, true);
 
        default:
-               return InsetCommand::priv_dispatch(cmd, idx, pos);
+               return InsetCommand::priv_dispatch(bv, cmd);
        }
 }
 
index 73ab89aa39ecc2f44c77bf5ac97269b0e49f0dd2..dc13a021eb59183f4b2fde9ee7b598fb37edf470 100644 (file)
@@ -70,7 +70,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        ///
        bool isLatex;
index f00f825910de8f8fb64083c21020304bd8c168f0..8f912121e4f2f7dda4c1d58c47cda5af342f25f3 100644 (file)
@@ -375,9 +375,9 @@ string const InsetTabular::editMessage() const
 }
 
 
-void InsetTabular::updateLocal(BufferView * bv) const
+void InsetTabular::updateLocal(BufferView & bv) const
 {
-       bv->update();
+       bv.update();
        resetPos(bv);
 }
 
@@ -385,64 +385,62 @@ extern LCursor theTempCursor;
 
 
 
-void InsetTabular::lfunMousePress(FuncRequest const & cmd)
+void InsetTabular::lfunMousePress(BufferView & bv, FuncRequest const & cmd)
 {
        if (hasSelection() && cmd.button() == mouse_button::button3)
                return;
 
-       BufferView * bv = cmd.view();
-
        int cell = getCell(cmd.x + xo_, cmd.y + yo_);
        clearSelection();
 
        lyxerr << "# InsetTabular::lfunMousePress cell: " << cell << endl;
        if (cell == -1) {
                tablemode = true;
-               bv->fullCursor(theTempCursor);
-               bv->fullCursor().push(this);
-               bv->fullCursor().cell(cell);
+               bv.fullCursor(theTempCursor);
+               bv.fullCursor().push(this);
+               bv.fullCursor().cell(cell);
        } else {
                tablemode = false;
                setPos(bv, cmd.x, cmd.y);
-               bv->fullCursor(theTempCursor);
-               bv->fullCursor().cell(cell);
+               bv.fullCursor(theTempCursor);
+               bv.fullCursor().cell(cell);
        }
-       lyxerr << bv->cursor() << endl;
+       lyxerr << bv.cursor() << endl;
 
        if (cmd.button() == mouse_button::button2)
-               dispatch(FuncRequest(bv, LFUN_PASTESELECTION, "paragraph"));
+               dispatch(bv, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
 }
 
 
-void InsetTabular::lfunMouseMotion(FuncRequest const & cmd)
+void InsetTabular::lfunMouseMotion(BufferView & bv, FuncRequest const & cmd)
 {
-       BufferView * bv = cmd.view();
        int const actcell = getCell(cmd.x + xo_, cmd.y + yo_);
        lyxerr << "# InsetTabular::lfunMouseMotion cell: " << actcell << endl;
 
        setPos(bv, cmd.x, cmd.y);
        if (!hasSelection()) {
                setSelection(actcell, actcell);
-               bv->setSelection();
+               bv.setSelection();
        } else {
-               bv->cursor().cell(actcell);
+               bv.cursor().idx(actcell);
                setSelection(sel_cell_start, actcell);
                tablemode = (sel_cell_start != actcell);
        }
 }
 
 
-void InsetTabular::lfunMouseRelease(FuncRequest const & cmd)
+void InsetTabular::lfunMouseRelease(BufferView & bv, 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(cmd.view());
+               InsetTabularMailer(*this).showDialog(&bv);
 }
 
 
-void InsetTabular::edit(BufferView * bv, bool left)
+void InsetTabular::edit(BufferView * view, bool left)
 {
+       BufferView & bv = *view;
        lyxerr << "InsetTabular::edit: " << this << endl;
        finishUndo();
        //tablemode = false;
@@ -460,10 +458,10 @@ void InsetTabular::edit(BufferView * bv, bool left)
        }
        clearSelection();
        resetPos(bv);
-       bv->fitCursor();
-       bv->fullCursor().push(this);
-       bv->fullCursor().cell(cell);
-       lyxerr << bv->cursor() << endl;
+       bv.fitCursor();
+       bv.fullCursor().push(this);
+       bv.fullCursor().cell(cell);
+       lyxerr << bv.cursor() << endl;
 }
 
 
@@ -473,7 +471,7 @@ void InsetTabular::edit(BufferView * bv, int x, int y)
                << &tabular.cell_info[0][0].inset << endl;
 
        finishUndo();
-       setPos(bv, x, y);
+       setPos(*bv, x, y);
        clearSelection();
        finishUndo();
        //int xx = cursorx_ - xo_ + tabular.getBeginningOfTextInCell(actcell);
@@ -484,40 +482,37 @@ void InsetTabular::edit(BufferView * bv, int x, int y)
 
 
 DispatchResult
-InsetTabular::priv_dispatch(FuncRequest const & cmd,
-       idx_type & idx, pos_type & pos)
+InsetTabular::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        lyxerr << "# InsetTabular::dispatch: " << cmd
                << " tablemode: " << tablemode << endl;
 
        DispatchResult result(true, true);
-       BufferView * bv = cmd.view();
-
        switch (cmd.action) {
 
        case LFUN_MOUSE_PRESS:
-               lfunMousePress(cmd);
+               lfunMousePress(bv, cmd);
                return DispatchResult(true, true);
 
        case LFUN_MOUSE_MOTION:
-               lfunMouseMotion(cmd);
+               lfunMouseMotion(bv, cmd);
                return DispatchResult(true, true);
 
        case LFUN_MOUSE_RELEASE:
-               lfunMouseRelease(cmd);
+               lfunMouseRelease(bv, cmd);
                return DispatchResult(true, true);
 
        default:
                break;
        }
 
-       CursorSlice & cur = bv->cursor();
+       CursorSlice & cur = bv.cursor();
 
        if (!tablemode) {
                
                int cell = cur.idx_;
                lyxerr << "# InsetTabular::dispatch: A " << cur << endl;
-               result = tabular.getCellInset(cell).dispatch(cmd, idx, pos);
+               result = tabular.getCellInset(cell).dispatch(bv, cmd);
 
                switch (result.val()) {
                case FINISHED:
@@ -571,10 +566,10 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
                case LFUN_SCROLL_INSET:
                        if (!cmd.argument.empty()) {
                                if (cmd.argument.find('.') != cmd.argument.npos)
-                                       scroll(cmd.view(), static_cast<float>(strToDbl(cmd.argument)));
+                                       scroll(bv, static_cast<float>(strToDbl(cmd.argument)));
                                else
-                                       scroll(cmd.view(), strToInt(cmd.argument));
-                               cmd.view()->update();
+                                       scroll(bv, strToInt(cmd.argument));
+                               bv.update();
                                return DispatchResult(true, true);
                        }
 
@@ -677,16 +672,16 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
                case LFUN_NEXT: {
                        if (hasSelection())
                                clearSelection();
-                       int actcell = bv->cursor().idx();
+                       int actcell = bv.cursor().idx();
                        int actcol = tabular.column_of_cell(actcell);
                        int column = actcol;
-                       if (bv->top_y() + bv->painter().paperHeight()
+                       if (bv.top_y() + bv.painter().paperHeight()
                                        < yo_ + tabular.getHeightOfTabular())
                        {
-                               bv->scrollDocView(bv->top_y() + bv->painter().paperHeight());
-                               cur.idx_ = tabular.getCellBelow(first_visible_cell) + column;
+                               bv.scrollDocView(bv.top_y() + bv.painter().paperHeight());
+                               cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
                        } else {
-                               cur.idx_ = tabular.getFirstCellInRow(tabular.rows() - 1) + column;
+                               cur.idx() = tabular.getFirstCellInRow(tabular.rows() - 1) + column;
                        }
                        resetPos(bv);
                        break;
@@ -695,17 +690,17 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
                case LFUN_PRIOR: {
                        if (hasSelection())
                                clearSelection();
-                       int actcell = bv->cursor().idx();
+                       int actcell = bv.cursor().idx();
                        int actcol = tabular.column_of_cell(actcell);
                        int column = actcol;
                        if (yo_ < 0) {
-                               bv->scrollDocView(bv->top_y() - bv->painter().paperHeight());
+                               bv.scrollDocView(bv.top_y() - bv.painter().paperHeight());
                                if (yo_ > 0)
-                                       cur.idx_ = column;
+                                       cur.idx() = column;
                                else
-                                       cur.idx_ = tabular.getCellBelow(first_visible_cell) + column;
+                                       cur.idx() = tabular.getCellBelow(first_visible_cell) + column;
                        } else {
-                               cur.idx_ = column;
+                               cur.idx() = column;
                        }
                        resetPos(bv);
                        break;
@@ -737,11 +732,11 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
                        break;
 
                case LFUN_LAYOUT_TABULAR:
-                       InsetTabularMailer(*this).showDialog(bv);
+                       InsetTabularMailer(*this).showDialog(&bv);
                        break;
 
                case LFUN_INSET_DIALOG_UPDATE:
-                       InsetTabularMailer(*this).updateDialog(bv);
+                       InsetTabularMailer(*this).updateDialog(&bv);
                        break;
 
                case LFUN_TABULAR_FEATURE:
@@ -752,7 +747,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
                // insert file functions
                case LFUN_FILE_INSERT_ASCII_PARA:
                case LFUN_FILE_INSERT_ASCII: {
-                       string tmpstr = getContentsOfAsciiFile(bv, cmd.argument, false);
+                       string tmpstr = getContentsOfAsciiFile(&bv, cmd.argument, false);
                        if (!tmpstr.empty() && !insertAsciiString(bv, tmpstr, false))
                                result = DispatchResult(false);
                        break;
@@ -774,13 +769,13 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
                case LFUN_CUT:
                        if (copySelection(bv)) {
                                recordUndo(bv, Undo::DELETE);
-                               cutSelection(bv->buffer()->params());
+                               cutSelection(bv.buffer()->params());
                        }
                        break;
 
                case LFUN_DELETE:
                        recordUndo(bv, Undo::DELETE);
-                       cutSelection(bv->buffer()->params());
+                       cutSelection(bv.buffer()->params());
                        break;
 
                case LFUN_COPY:
@@ -791,7 +786,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
                        break;
 
                case LFUN_PASTESELECTION: {
-                       string const clip = bv->getClipboard();
+                       string const clip = bv.getClipboard();
                        if (clip.empty())
                                break;
                        if (clip.find('\t') != string::npos) {
@@ -819,7 +814,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
                                maxCols = max(cols, maxCols);
 
                                paste_tabular.reset(
-                                       new LyXTabular(bv->buffer()->params(), rows, maxCols));
+                                       new LyXTabular(bv.buffer()->params(), rows, maxCols));
 
                                string::size_type op = 0;
                                int cell = 0;
@@ -883,7 +878,7 @@ InsetTabular::priv_dispatch(FuncRequest const & cmd,
                }
 
                updateLocal(bv);
-               InsetTabularMailer(*this).updateDialog(bv);
+               InsetTabularMailer(*this).updateDialog(&bv);
        }
 
        if (cmd.action == LFUN_INSET_TOGGLE) {
@@ -985,7 +980,7 @@ void InsetTabular::getCursorPos(int cell, int & x, int & y) const
 }
 
 
-void InsetTabular::setPos(BufferView * bv, int x, int y) const
+void InsetTabular::setPos(BufferView & bv, int x, int y) const
 {
        int const cell = getCell(x + xo_, y + yo_);
        lyxerr << "# InsetTabular::setPos()  cell: " << cell << endl;
@@ -1036,7 +1031,7 @@ int InsetTabular::getCellXPos(int cell) const
 }
 
 
-void InsetTabular::resetPos(BufferView *) const
+void InsetTabular::resetPos(BufferView &) const
 {
 #if 0
 #ifdef WITH_WARNINGS
@@ -1074,15 +1069,15 @@ void InsetTabular::resetPos(BufferView *) const
                updateLocal(bv);
        } else if (cursorx_ - offset > 20 &&
                   cursorx_ - offset + tabular.getWidthOfColumn(actcell)
-                  > bv->workWidth() - 20) {
-               scroll(bv, - tabular.getWidthOfColumn(actcell) - 20);
+                  > bv.workWidth() - 20) {
+               scroll(&bv, - tabular.getWidthOfColumn(actcell) - 20);
                updateLocal(bv);
        } else if (cursorx_ - offset < 20) {
-               scroll(bv, 20 - cursorx_ + offset);
+               scroll(&bv, 20 - cursorx_ + offset);
                updateLocal(bv);
        } else if (scroll() && xo_ > 20 &&
                   xo_ + tabular.getWidthOfTabular() > bv->workWidth() - 20) {
-               scroll(bv, old_x - cursorx_);
+               scroll(&bv, old_x - cursorx_);
                updateLocal(bv);
        }
        InsetTabularMailer(*this).updateDialog(bv);
@@ -1091,7 +1086,7 @@ void InsetTabular::resetPos(BufferView *) const
 }
 
 
-bool InsetTabular::moveRight(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveRight(BufferView & bv, CursorSlice & cur)
 {
        bool moved = isRightToLeft(bv)
                ? movePrevCell(bv, cur) : moveNextCell(bv, cur);
@@ -1102,7 +1097,7 @@ bool InsetTabular::moveRight(BufferView * bv, CursorSlice & cur)
 }
 
 
-bool InsetTabular::moveRightLock(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveRightLock(BufferView & bv, CursorSlice & cur)
 {
        bool moved = isRightToLeft(bv)
                ? movePrevCell(bv, cur) : moveNextCell(bv, cur);
@@ -1113,7 +1108,7 @@ bool InsetTabular::moveRightLock(BufferView * bv, CursorSlice & cur)
 }
 
 
-bool InsetTabular::moveLeft(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveLeft(BufferView & bv, CursorSlice & cur)
 {
        bool moved = isRightToLeft(bv)
                ? moveNextCell(bv, cur) : movePrevCell(bv, cur);
@@ -1124,7 +1119,7 @@ bool InsetTabular::moveLeft(BufferView * bv, CursorSlice & cur)
 }
 
 
-bool InsetTabular::moveLeftLock(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveLeftLock(BufferView & bv, CursorSlice & cur)
 {
        bool moved = isRightToLeft(bv)
                ? moveNextCell(bv, cur) : movePrevCell(bv, cur);
@@ -1135,7 +1130,7 @@ bool InsetTabular::moveLeftLock(BufferView * bv, CursorSlice & cur)
 }
 
 
-bool InsetTabular::moveUp(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveUp(BufferView & bv, CursorSlice & cur)
 {
        if (tabular.row_of_cell(cur.idx_) == 0)
                return false;
@@ -1145,18 +1140,18 @@ bool InsetTabular::moveUp(BufferView * bv, CursorSlice & cur)
 }
 
 
-bool InsetTabular::moveUpLock(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveUpLock(BufferView & bv, CursorSlice & cur)
 {
        if (tabular.row_of_cell(cur.idx_) == 0)
                return false;
        cur.idx_ = tabular.getCellAbove(cur.idx_);
        resetPos(bv);
-       activateCellInset(bv, cur.idx_, bv->x_target(), 0);
+       activateCellInset(bv, cur.idx_, bv.x_target(), 0);
        return true;
 }
 
 
-bool InsetTabular::moveDown(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveDown(BufferView & bv, CursorSlice & cur)
 {
        if (tabular.row_of_cell(cur.idx_) == tabular.rows() - 1)
                return false;
@@ -1166,18 +1161,18 @@ bool InsetTabular::moveDown(BufferView * bv, CursorSlice & cur)
 }
 
 
-bool InsetTabular::moveDownLock(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveDownLock(BufferView & bv, CursorSlice & cur)
 {
        if (tabular.row_of_cell(cur.idx_) == tabular.rows() - 1)
                return false;
        cur.idx_ = tabular.getCellBelow(cur.idx_);
        resetPos(bv);
-       activateCellInset(bv, cur.idx_, bv->x_target());
+       activateCellInset(bv, cur.idx_, bv.x_target());
        return true;
 }
 
 
-bool InsetTabular::moveNextCell(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::moveNextCell(BufferView & bv, CursorSlice & cur)
 {
        lyxerr << "InsetTabular::moveNextCell 1 cur: " << cur << endl;
        if (isRightToLeft(bv)) {
@@ -1205,7 +1200,7 @@ bool InsetTabular::moveNextCell(BufferView * bv, CursorSlice & cur)
 }
 
 
-bool InsetTabular::movePrevCell(BufferView * bv, CursorSlice & cur)
+bool InsetTabular::movePrevCell(BufferView & bv, CursorSlice & cur)
 {
        if (isRightToLeft(bv)) {
                if (tabular.isLastCellInRow(cur.idx_)) {
@@ -1231,7 +1226,7 @@ bool InsetTabular::movePrevCell(BufferView * bv, CursorSlice & cur)
 }
 
 
-bool InsetTabular::tabularFeatures(BufferView * bv, string const & what)
+bool InsetTabular::tabularFeatures(BufferView & bv, string const & what)
 {
        LyXTabular::Feature action = LyXTabular::LAST_ACTION;
 
@@ -1279,10 +1274,10 @@ void checkLongtableSpecial(LyXTabular::ltType & ltt,
 } // anon namespace
 
 
-void InsetTabular::tabularFeatures(BufferView * bv,
+void InsetTabular::tabularFeatures(BufferView & bv,
        LyXTabular::Feature feature, string const & value)
 {
-       int actcell = bv->cursor().idx();
+       int actcell = bv.cursor().idx();
        int sel_col_start;
        int sel_col_end;
        int sel_row_start;
@@ -1369,13 +1364,13 @@ void InsetTabular::tabularFeatures(BufferView * bv,
 
        case LyXTabular::APPEND_ROW:
                // append the row into the tabular
-               tabular.appendRow(bv->buffer()->params(), actcell);
+               tabular.appendRow(bv.buffer()->params(), actcell);
                tabular.setOwner(this);
                break;
 
        case LyXTabular::APPEND_COLUMN:
                // append the column into the tabular
-               tabular.appendColumn(bv->buffer()->params(), actcell);
+               tabular.appendColumn(bv.buffer()->params(), actcell);
                tabular.setOwner(this);
                actcell = tabular.getCellNumber(row, column);
                break;
@@ -1494,7 +1489,7 @@ void InsetTabular::tabularFeatures(BufferView * bv,
                        if (tabular.isMultiColumn(actcell))
                                tabular.unsetMultiColumn(actcell);
                        else
-                               tabular.setMultiColumn(bv->buffer(), actcell, 1);
+                               tabular.setMultiColumn(bv.buffer(), actcell, 1);
                        break;
                }
                // we have a selection so this means we just add all this
@@ -1509,7 +1504,7 @@ void InsetTabular::tabularFeatures(BufferView * bv,
                        s_start = sel_cell_start;
                        s_end = sel_cell_end;
                }
-               tabular.setMultiColumn(bv->buffer(), s_start, s_end - s_start + 1);
+               tabular.setMultiColumn(bv.buffer(), s_start, s_end - s_start + 1);
                actcell = s_start;
                clearSelection();
                break;
@@ -1606,22 +1601,22 @@ void InsetTabular::tabularFeatures(BufferView * bv,
        }
 
        updateLocal(bv);
-       InsetTabularMailer(*this).updateDialog(bv);
+       InsetTabularMailer(*this).updateDialog(&bv);
 }
 
 
-void InsetTabular::activateCellInset(BufferView * bv, int cell, int x, int y)
+void InsetTabular::activateCellInset(BufferView & bv, int cell, int x, int y)
 {
-       tabular.getCellInset(cell).edit(bv, x, y);
-       bv->cursor().cell(cell);
+       tabular.getCellInset(cell).edit(&bv, x, y);
+       bv.cursor().idx(cell);
        updateLocal(bv);
 }
 
 
-void InsetTabular::activateCellInset(BufferView * bv, int cell, bool behind)
+void InsetTabular::activateCellInset(BufferView & bv, int cell, bool behind)
 {
-       tabular.getCellInset(cell).edit(bv, behind);
-       bv->cursor().cell(cell);
+       tabular.getCellInset(cell).edit(&bv, behind);
+       bv.cursor().idx(cell);
        updateLocal(bv);
 }
 
@@ -1828,7 +1823,7 @@ void InsetTabular::getLabelList(Buffer const & buffer,
 }
 
 
-bool InsetTabular::copySelection(BufferView * bv)
+bool InsetTabular::copySelection(BufferView & bv)
 {
        if (!hasSelection())
                return false;
@@ -1874,18 +1869,18 @@ bool InsetTabular::copySelection(BufferView * bv)
 
        ostringstream os;
        OutputParams const runparams;
-       paste_tabular->plaintext(*bv->buffer(), os, runparams,
-                                ownerPar(*bv->buffer(), this).params().depth(), true, '\t');
-       bv->stuffClipboard(os.str());
+       paste_tabular->plaintext(*bv.buffer(), os, runparams,
+                                ownerPar(*bv.buffer(), this).params().depth(), true, '\t');
+       bv.stuffClipboard(os.str());
        return true;
 }
 
 
-bool InsetTabular::pasteSelection(BufferView * bv)
+bool InsetTabular::pasteSelection(BufferView & bv)
 {
        if (!paste_tabular)
                return false;
-       int actcell = bv->cursor().idx();
+       int actcell = bv.cursor().idx();
        int actcol = tabular.column_of_cell(actcell);
        int actrow = tabular.row_of_cell(actcell);
        for (int r1 = 0, r2 = actrow;
@@ -1946,9 +1941,9 @@ bool InsetTabular::cutSelection(BufferParams const & bp)
 }
 
 
-bool InsetTabular::isRightToLeft(BufferView * bv)
+bool InsetTabular::isRightToLeft(BufferView & bv)
 {
-       return bv->getParentLanguage(this)->RightToLeft();
+       return bv.getParentLanguage(this)->RightToLeft();
 }
 
 
@@ -2011,7 +2006,7 @@ bool InsetTabular::forceDefaultParagraphs(InsetOld const * in) const
 }
 
 
-bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
+bool InsetTabular::insertAsciiString(BufferView & bv, string const & buf,
                                     bool usePaste)
 {
        if (buf.length() <= 0)
@@ -2023,7 +2018,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
        string::size_type len = buf.length();
        string::size_type p = 0;
 
-       int actcell = bv->cursor().idx();
+       int actcell = bv.cursor().idx();
        int actcol = tabular.column_of_cell(actcell);
        int actrow = tabular.row_of_cell(actcell);
 
@@ -2048,9 +2043,7 @@ bool InsetTabular::insertAsciiString(BufferView * bv, string const & buf,
        int row = 0;
        if (usePaste) {
                paste_tabular.reset(
-                       new LyXTabular(bv->buffer()->params(), rows, maxCols)
-                       );
-
+                       new LyXTabular(bv.buffer()->params(), rows, maxCols));
                paste_tabular->setOwner(this);
                loctab = paste_tabular.get();
                cols = 0;
index 09a509de3a27a7cbfcc83515439e8d8c78189890..e7c90a4415cb70066a4670f6610e8c54f780f39e 100644 (file)
@@ -82,7 +82,7 @@ public:
        ///
        std::string const editMessage() const;
        ///
-       void updateLocal(BufferView *) const;
+       void updateLocal(BufferView & bv) const;
        ///
        bool insetAllowed(InsetOld::Code) const { return true; }
        ///
@@ -112,9 +112,9 @@ public:
        /// get the absolute screen x,y of the cursor
        void getCursorPos(int cell, int & x, int & y) const;
        ///
-       bool tabularFeatures(BufferView * bv, std::string const & what);
+       bool tabularFeatures(BufferView & bv, std::string const & what);
        ///
-       void tabularFeatures(BufferView * bv, LyXTabular::Feature feature,
+       void tabularFeatures(BufferView & bv, LyXTabular::Feature feature,
                             std::string const & val = std::string());
        ///
        void openLayoutDialog(BufferView *) const;
@@ -162,14 +162,14 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        ///
-       void lfunMousePress(FuncRequest const &);
+       void lfunMousePress(BufferView & bv, FuncRequest const & cmd);
        ///
-       void lfunMouseRelease(FuncRequest const &);
+       void lfunMouseRelease(BufferView & bv, FuncRequest const & cmd);
        ///
-       void lfunMouseMotion(FuncRequest const &);
+       void lfunMouseMotion(BufferView & bv, FuncRequest const & cmd);
        ///
        void calculate_dimensions_of_cells(MetricsInfo & mi) const;
        ///
@@ -179,35 +179,35 @@ private:
        void drawCellSelection(Painter &, int x, int baseline,
                               int row, int column, int cell) const;
        ///
-       void setPos(BufferView *, int x, int y) const;
+       void setPos(BufferView &, int x, int y) const;
        ///
-       bool moveRight(BufferView *, CursorSlice & cur);
+       bool moveRight(BufferView &, CursorSlice & cur);
        ///
-       bool moveLeft(BufferView *, CursorSlice & cur);
+       bool moveLeft(BufferView &, CursorSlice & cur);
        ///
-       bool moveUp(BufferView *, CursorSlice & cur);
+       bool moveUp(BufferView &, CursorSlice & cur);
        ///
-       bool moveDown(BufferView *, CursorSlice & cur);
+       bool moveDown(BufferView &, CursorSlice & cur);
 
        ///
-       bool moveRightLock(BufferView *, CursorSlice & cur);
+       bool moveRightLock(BufferView &, CursorSlice & cur);
        ///
-       bool moveLeftLock(BufferView *, CursorSlice & cur);
+       bool moveLeftLock(BufferView &, CursorSlice & cur);
        ///
-       bool moveUpLock(BufferView *, CursorSlice & cur);
+       bool moveUpLock(BufferView &, CursorSlice & cur);
        ///
-       bool moveDownLock(BufferView *, CursorSlice & cur);
+       bool moveDownLock(BufferView &, CursorSlice & cur);
 
        ///
-       bool moveNextCell(BufferView *, CursorSlice & cur);
+       bool moveNextCell(BufferView &, CursorSlice & cur);
        ///
-       bool movePrevCell(BufferView *, CursorSlice & cur);
+       bool movePrevCell(BufferView &, CursorSlice & cur);
 
 
        ///
        int getCellXPos(int cell) const;
        ///
-       void resetPos(BufferView *) const;
+       void resetPos(BufferView &) const;
        ///
        void removeTabularRow();
        ///
@@ -215,24 +215,24 @@ private:
        ///
        void setSelection(int start, int end) const;
        ///
-       void activateCellInset(BufferView *, int cell, int x, int y);
+       void activateCellInset(BufferView &, int cell, int x, int y);
        ///
-       void activateCellInset(BufferView *, int cell, bool behind);
+       void activateCellInset(BufferView &, int cell, bool behind);
        ///
        bool hasPasteBuffer() const;
        ///
-       bool copySelection(BufferView *);
+       bool copySelection(BufferView &);
        ///
-       bool pasteSelection(BufferView *);
+       bool pasteSelection(BufferView &);
        ///
        bool cutSelection(BufferParams const & bp);
        ///
-       bool isRightToLeft(BufferView *);
+       bool isRightToLeft(BufferView &);
        ///
        void getSelection(int cell,
                int & scol, int & ecol, int & srow, int & erow) const;
        ///
-       bool insertAsciiString(BufferView *, std::string const & buf, bool usePaste);
+       bool insertAsciiString(BufferView &, std::string const & buf, bool usePaste);
 
        //
        // Private structures and variables
index aa15d2e3d2d19424bd1b5aaeadb0f32448bac7ac..cd4953c42ad98dd57e3399e93411bc689f13058f 100644 (file)
@@ -298,14 +298,13 @@ void InsetText::edit(BufferView * bv, int x, int y)
 }
 
 
-DispatchResult InsetText::priv_dispatch(FuncRequest const & cmd,
-       idx_type &, pos_type &)
+DispatchResult
+InsetText::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        //lyxerr << "InsetText::priv_dispatch (begin), act: "
        //      << cmd.action << " " << endl;
 
-       BufferView * bv = cmd.view();
-       setViewCache(bv);
+       setViewCache(&bv);
 
        DispatchResult result;
        result.dispatched(true);
@@ -314,10 +313,10 @@ DispatchResult InsetText::priv_dispatch(FuncRequest const & cmd,
 
        switch (cmd.action) {
        case LFUN_MOUSE_PRESS:
-               bv->fullCursor(theTempCursor);
+               bv.fullCursor(theTempCursor);
                // fall through
        default:
-               result = text_.dispatch(cmd);
+               result = text_.dispatch(bv, cmd);
                break;
        }
 
@@ -327,7 +326,7 @@ DispatchResult InsetText::priv_dispatch(FuncRequest const & cmd,
        if (!was_empty && paragraphs().begin()->empty() &&
            paragraphs().size() == 1) {
                LyXFont font(LyXFont::ALL_IGNORE);
-               font.setLanguage(bv->getParentLanguage(this));
+               font.setLanguage(bv.getParentLanguage(this));
                text_.setFont(font, false);
        }
 
index 6ed086f9d68beb8001c0d5210f4db9cb37adf0cf..c09f845873a612a17d60c5b2a448963edf74a31f 100644 (file)
@@ -116,11 +116,11 @@ public:
        ///
        int scroll(bool recursive = true) const;
        ///
-       void scroll(BufferView * bv, float sx) const {
+       void scroll(BufferView & bv, float sx) const {
                UpdatableInset::scroll(bv, sx);
        }
        ///
-       void scroll(BufferView * bv, int offset) const {
+       void scroll(BufferView & bv, int offset) const {
                UpdatableInset::scroll(bv, offset);
        }
        ///
@@ -156,7 +156,7 @@ public:
 private:
        ///
        DispatchResult
-       priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
        ///
        void updateLocal(BufferView *);
        ///
index 7b7c9a3998676c577679669d3d477f2e59578a03..9a249fffe5e751f27bf386ab85d877de78a0113f 100644 (file)
@@ -60,8 +60,7 @@ std::auto_ptr<InsetBase> InsetVSpace::clone() const
 
 
 DispatchResult
-InsetVSpace::priv_dispatch(FuncRequest const & cmd,
-                          idx_type & idx, pos_type & pos)
+InsetVSpace::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
 
@@ -71,11 +70,11 @@ InsetVSpace::priv_dispatch(FuncRequest const & cmd,
        }
 
        case LFUN_MOUSE_PRESS:
-               InsetVSpaceMailer(*this).showDialog(cmd.view());
+               InsetVSpaceMailer(*this).showDialog(&bv);
                return DispatchResult(true, true);
 
        default:
-               return InsetOld::priv_dispatch(cmd, idx, pos);
+               return InsetOld::priv_dispatch(bv, cmd);
        }
 }
 
index 42113b4e0ff52cb154d4e18ee638c5790e4daa36..4ce44ce6bf0530b9881605481e5472fafdb3c3ca 100644 (file)
@@ -56,7 +56,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 
 private:
        ///
index df42307e19e98499499bdbd2d2571decd7226b97..1ea115fb2a79a405290989c5599b23d1b222bbe9 100644 (file)
@@ -80,8 +80,7 @@ InsetWrap::~InsetWrap()
 
 
 DispatchResult
-InsetWrap::priv_dispatch(FuncRequest const & cmd,
-                        idx_type & idx, pos_type & pos)
+InsetWrap::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY: {
@@ -91,16 +90,16 @@ InsetWrap::priv_dispatch(FuncRequest const & cmd,
                params_.placement = params.placement;
                params_.width     = params.width;
 
-               cmd.view()->update();
+               bv.update();
                return DispatchResult(true, true);
        }
 
        case LFUN_INSET_DIALOG_UPDATE:
-               InsetWrapMailer(*this).updateDialog(cmd.view());
+               InsetWrapMailer(*this).updateDialog(&bv);
                return DispatchResult(true, true);
 
        default:
-               return InsetCollapsable::priv_dispatch(cmd, idx, pos);
+               return InsetCollapsable::priv_dispatch(bv, cmd);
        }
 }
 
index 7525d45838bb83048996c83c840c2627066937fe..60a8872a87b7d0f36c22ed2a30cc1a6f9e257bf4 100644 (file)
@@ -70,7 +70,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        ///
        InsetWrapParams params_;
index a0cc5e25cb8fc36f27c7543bc2f91915e493d84a..dfd3aedd348734778f4af8fd9e98606f5a94848f 100644 (file)
@@ -37,14 +37,14 @@ InsetOld::EDITABLE UpdatableInset::editable() const
 }
 
 
-void UpdatableInset::scroll(BufferView * bv, float s) const
+void UpdatableInset::scroll(BufferView & bv, float s) const
 {
        if (!s) {
                scx = 0;
                return;
        }
 
-       int const workW = bv->workWidth();
+       int const workW = bv.workWidth();
        int const tmp_xo_ = xo_ - scx;
 
        if (tmp_xo_ > 0 && tmp_xo_ + width() < workW)
@@ -60,7 +60,7 @@ void UpdatableInset::scroll(BufferView * bv, float s) const
 }
 
 
-void UpdatableInset::scroll(BufferView * bv, int offset) const
+void UpdatableInset::scroll(BufferView & bv, int offset) const
 {
        if (offset > 0) {
                if (!scx && xo_ >= 20)
@@ -72,10 +72,10 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const
                        scx += offset;
        } else {
 #warning metrics?
-               if (!scx && xo_ + width() < bv->workWidth() - 20)
+               if (!scx && xo_ + width() < bv.workWidth() - 20)
                        return;
-               if (xo_ - scx + offset + width() < bv->workWidth() - 20) {
-                       scx += bv->workWidth() - width() - xo_ - 20;
+               if (xo_ - scx + offset + width() < bv.workWidth() - 20) {
+                       scx += bv.workWidth() - width() - xo_ - 20;
                } else {
                        scx += offset;
                }
@@ -85,7 +85,7 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const
 
 ///  An updatable inset could handle lyx editing commands
 DispatchResult
-UpdatableInset::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
+UpdatableInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_MOUSE_RELEASE:
@@ -94,10 +94,10 @@ UpdatableInset::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
        case LFUN_SCROLL_INSET:
                if (!cmd.argument.empty()) {
                        if (cmd.argument.find('.') != cmd.argument.npos)
-                               scroll(cmd.view(), static_cast<float>(strToDbl(cmd.argument)));
+                               scroll(bv, static_cast<float>(strToDbl(cmd.argument)));
                        else
-                               scroll(cmd.view(), strToInt(cmd.argument));
-                       cmd.view()->update();
+                               scroll(bv, strToInt(cmd.argument));
+                       bv.update();
                        return DispatchResult(true, true);
                }
 
index b549dc212fd328c4e3e77da8808f2e8cc41d7b44..51382ed94086d18abcdee542d7d133af79b3ef6d 100644 (file)
@@ -25,7 +25,7 @@ class UpdatableInset : public InsetOld {
 public:
        ///
        virtual EDITABLE editable() const;
-       /// identification as math inset
+       /// identification as text inset in a cursor slice
        UpdatableInset * asUpdatableInset() { return this; }
 
        /// return the cursor pos, relative to the inset pos
@@ -37,18 +37,16 @@ public:
                { return InsetOld::scroll(recursive); }
        ///
        virtual bool showInsetDialog(BufferView *) const { return false; }
-       ///
-       virtual void toggleSelection(BufferView *, bool /*kill_selection*/) {}
 
 protected:
        ///  An updatable inset could handle lyx editing commands
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
        /// scrolls to absolute position in bufferview-workwidth * sx units
-       void scroll(BufferView *, float sx) const;
+       void scroll(BufferView &, float sx) const;
        /// scrolls offset pixels
-       void scroll(BufferView *, int offset) const;
+       void scroll(BufferView &, int offset) const;
 };
 
 #endif
index 96c3da77a069677bcdbc7d7a81e6f8851a2dcc23..65d5843b6b57d968a1011946601f18467fe6b5c8 100644 (file)
@@ -106,9 +106,9 @@ string const replace2string(string const & search, string const & replace,
 }
 
 
-void find(FuncRequest const & ev)
+void find(BufferView * bv, FuncRequest const & ev)
 {
-       if (!ev.view() || ev.action != LFUN_WORD_FIND)
+       if (!bv || ev.action != LFUN_WORD_FIND)
                return;
 
        // data is of the form
@@ -121,7 +121,6 @@ void find(FuncRequest const & ev)
        bool matchword     = parse_bool(howto);
        bool forward       = parse_bool(howto);
 
-       BufferView * bv = ev.view();
        bool const found = ::find(bv, search,
                                  forward, casesensitive, matchword);
 
@@ -130,9 +129,9 @@ void find(FuncRequest const & ev)
 }
 
 
-void replace(FuncRequest const & ev)
+void replace(BufferView * bv, FuncRequest const & ev)
 {
-       if (!ev.view() || ev.action != LFUN_WORD_REPLACE)
+       if (!bv || ev.action != LFUN_WORD_REPLACE)
                return;
 
        // data is of the form
@@ -149,7 +148,6 @@ void replace(FuncRequest const & ev)
        bool all           = parse_bool(howto);
        bool forward       = parse_bool(howto);
 
-       BufferView * bv = ev.view();
        LyXView * lv = bv->owner();
 
        int const replace_count = all ?
index f37642513b1246b92f9938a6b4819ef25188d382..8a82caac878c06251190ea40caf07f6f871aa56f 100644 (file)
@@ -49,13 +49,13 @@ std::string const replace2string(std::string const & search,
  *  \c ev.argument and act on it.
  * The string is encoded by \c find2string.
  */
-void find(FuncRequest const & ev);
+void find(BufferView * bv, FuncRequest const & ev);
 
 /** Parse the string encoding of the replace request that is found in
  *  \c ev.argument and act on it.
  * The string is encoded by \c replace2string.
  */
-void replace(FuncRequest const &);
+void replace(BufferView * bv, FuncRequest const &);
 
 /// find the next change in the buffer
 bool findNextChange(BufferView * bv);
index 4b040eb805569a0cb2bf4ecda375b44fb298e044..284f1202b1cb5e8c4c91cfeb5b6b0d8f51d3e750 100644 (file)
@@ -257,9 +257,7 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
                if (encoded_last_key != 0) {
                        string arg;
                        arg += encoded_last_key;
-
-                       dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
-
+                       dispatch(FuncRequest(LFUN_SELFINSERT, arg));
                        lyxerr[Debug::KEY] << "SelfInsert arg[`"
                                   << argument << "']" << endl;
                }
@@ -888,10 +886,8 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
 
                        bool const fw = action == LFUN_WORDFINDFORWARD;
                        string const data =
-                               lyx::find::find2string(searched_string,
-                                                      true, false, fw);
-                       FuncRequest const fr(view(), LFUN_WORD_FIND, data);
-                       view()->dispatch(fr);
+                               lyx::find::find2string(searched_string, true, false, fw);
+                       view()->dispatch(FuncRequest(LFUN_WORD_FIND, data));
                        break;
                }
 
@@ -1295,7 +1291,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                case LFUN_INSET_DIALOG_SHOW: {
                        InsetOld * inset = view()->getLyXText()->getInset();
                        if (inset)
-                               inset->dispatch(FuncRequest(view(), LFUN_INSET_DIALOG_SHOW));
+                               inset->dispatch(*view(), FuncRequest(LFUN_INSET_DIALOG_SHOW));
                        break;
                }
 
@@ -1304,9 +1300,8 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                        // Can only update a dialog connected to an existing inset
                        InsetBase * inset = owner->getDialogs().getOpenInset(name);
                        if (inset) {
-                               FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
-                                                                func.argument);
-                               inset->dispatch(fr);
+                               FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, func.argument);
+                               inset->dispatch(*view(), fr);
                        } else if (name == "paragraph") {
                                dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
                        }
@@ -1444,18 +1439,12 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                        break;
 
                case LFUN_EXTERNAL_EDIT:
-                       InsetExternal().dispatch(FuncRequest(view(), action, argument));
+                       InsetExternal().dispatch(*view(), FuncRequest(action, argument));
                        break;
 
-               default: {
-                               DispatchResult result =
-                                       view()->fullCursor().dispatch(FuncRequest(func, view()));
-                               if (result.dispatched())
-                                       lyxerr << "dispatched by Cursor::dispatch()" << endl;
-                               else
-                                       lyxerr << "### NOT DISPATCHED BY Cursor::dispatch() ###" << endl;
-                               break;
-                       }
+               default:
+                       view()->fullCursor().dispatch(FuncRequest(func));
+                       break;
                }
        }
 
index f63a9a1eaa4108f78207712492ccc2af0b798f91..87a75db6423746e7bde71f231ec1e005050fa96c 100644 (file)
@@ -122,7 +122,7 @@ public:
        void draw(PainterInfo & pi, int x, int y) const;
 
        /// try to handle that request
-       DispatchResult dispatch(FuncRequest const & cmd);
+       DispatchResult dispatch(BufferView & bv, FuncRequest const & cmd);
 
        BufferView * bv();
 
index f41ca6e5c3b6453ee77fa8bf2a029fde6ea5918d..d0f9aaab63ae9fe2f807f68c574bf87e072272a4 100644 (file)
@@ -1,3 +1,10 @@
+
+
+2004-01-15  André Pönitz  <poenitz@gmx.net>
+
+       * *.[Ch]: change signature of priv_dispatch to prepare 
+       inset unification
+
 2003-12-15  Ronald Florence <ron@18james.com>
 
        * math_symbolinset.C: fixed "ugly" patch for Qt/Mac fonts.
index a2657c8f56f15371392830edb600ed882a67ec07..ca0f0ebb4e06e261b551e78587f1998e7062fa29 100644 (file)
@@ -55,12 +55,11 @@ void CommandInset::draw(PainterInfo & pi, int x, int y) const
 
 
 DispatchResult
-CommandInset::priv_dispatch(FuncRequest const & cmd,
-                           idx_type & idx, pos_type & pos)
+CommandInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
                default:
-                       return MathNestInset::priv_dispatch(cmd, idx, pos);
+                       return MathNestInset::priv_dispatch(bv, cmd);
        }
        return DispatchResult(false);
 }
index c9739b48e26cce88e39f2d9a488cce2712afcf57..4ac6a413fb05bca56a62a35d22027e9b61c736b2 100644 (file)
@@ -42,7 +42,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        std::string name_;
        mutable bool set_label_;
index 899acf434e283a87d37cee2ec8440a6b1491ed5a..fb3251fbce46eaaa7ae76ab902f8798f5d9e141e 100644 (file)
@@ -62,13 +62,13 @@ namespace {
 int first_x;
 int first_y;
 
-bool openNewInset(BufferView * bv, UpdatableInset * inset)
+bool openNewInset(BufferView & bv, UpdatableInset * inset)
 {
-       if (!bv->insertInset(inset)) {
+       if (!bv.insertInset(inset)) {
                delete inset;
                return false;
        }
-       inset->edit(bv, true);
+       inset->edit(&bv, true);
        return true;
 }
 
@@ -111,7 +111,7 @@ void InsetFormulaBase::mutateToText()
 
 
 void InsetFormulaBase::handleFont
-       (BufferView * bv, string const & arg, string const & font)
+       (BufferView & bv, string const & arg, string const & font)
 {
        // this whole function is a hack and won't work for incremental font
        // changes...
@@ -126,7 +126,7 @@ void InsetFormulaBase::handleFont
 }
 
 
-void InsetFormulaBase::handleFont2(BufferView * bv, string const & arg)
+void InsetFormulaBase::handleFont2(BufferView & bv, string const & arg)
 {
        recordUndo(bv, Undo::ATOMIC);
        LyXFont font;
@@ -156,7 +156,7 @@ void InsetFormulaBase::insetUnlock(BufferView * bv)
        if (mathcursor) {
                if (mathcursor->inMacroMode())
                        mathcursor->macroModeClose();
-               releaseMathCursor(bv);
+               releaseMathCursor(*bv);
        }
        if (bv->buffer())
                generatePreview(*bv->buffer());
@@ -203,13 +203,12 @@ void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
 }
 
 
-DispatchResult InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
+DispatchResult InsetFormulaBase::lfunMouseRelease(
+       BufferView & bv, FuncRequest const & cmd)
 {
        if (!mathcursor)
                return DispatchResult(false);
-
-       BufferView * bv = cmd.view();
-       bv->update();
+       bv.update();
        //lyxerr << "lfunMouseRelease: buttons: " << cmd.button() << endl;
 
        if (cmd.button() == mouse_button::button3) {
@@ -217,28 +216,28 @@ DispatchResult InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
                if (!mathcursor->dispatch(cmd).dispatched()) {
                        // launch math panel for right mouse button
                        lyxerr << "lfunMouseRelease: undispatched: " << cmd.button() << endl;
-                       bv->owner()->getDialogs().show("mathpanel");
+                       bv.owner()->getDialogs().show("mathpanel");
                }
                return DispatchResult(true, true);
        }
 
        if (cmd.button() == mouse_button::button2) {
                MathArray ar;
-               asArray(bv->getClipboard(), ar);
+               asArray(bv.getClipboard(), ar);
                mathcursor->selClear();
                mathcursor->setScreenPos(cmd.x + xo_, cmd.y + yo_);
                mathcursor->insert(ar);
-               bv->update();
+               bv.update();
                return DispatchResult(true, true);
        }
 
        if (cmd.button() == mouse_button::button1) {
                // try to dispatch to enclosed insets first
                mathcursor->dispatch(cmd);
-               cmd.view()->stuffClipboard(mathcursor->grabSelection());
+               bv.stuffClipboard(mathcursor->grabSelection());
                // try to set the cursor
                //delete mathcursor;
-               //mathcursor = new MathCursor(this, x == 0);
+               //mathcursor = new MathCursor(bv, this, x == 0);
                //metrics(bv);
                //mathcursor->setScreenPos(x + xo_, y + yo_);
                return DispatchResult(true, true);
@@ -248,15 +247,15 @@ DispatchResult InsetFormulaBase::lfunMouseRelease(FuncRequest const & cmd)
 }
 
 
-DispatchResult InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
+DispatchResult InsetFormulaBase::lfunMousePress(
+       BufferView & bv, FuncRequest const & cmd)
 {
-       BufferView * bv = cmd.view();
        //lyxerr << "lfunMousePress: buttons: " << cmd.button() << endl;
 
        if (!mathcursor || mathcursor->formula() != this) {
                lyxerr[Debug::MATHED] << "re-create cursor" << endl;
                releaseMathCursor(bv);
-               mathcursor = new MathCursor(this, cmd.x == 0);
+               mathcursor = new MathCursor(&bv, this, cmd.x == 0);
                //metrics(bv);
                mathcursor->setScreenPos(cmd.x + xo_, cmd.y + yo_);
        }
@@ -275,12 +274,13 @@ DispatchResult InsetFormulaBase::lfunMousePress(FuncRequest const & cmd)
                return DispatchResult(true, true);
        }
 
-       bv->update();
+       bv.update();
        return DispatchResult(true, true);
 }
 
 
-DispatchResult InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
+DispatchResult InsetFormulaBase::lfunMouseMotion(
+       BufferView & bv, FuncRequest const & cmd)
 {
        if (!mathcursor)
                return DispatchResult(true, true);
@@ -301,9 +301,8 @@ DispatchResult InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
        if (!mathcursor->selection())
                mathcursor->selStart();
 
-       BufferView * bv = cmd.view();
        mathcursor->setScreenPos(cmd.x + xo_, cmd.y + yo_);
-       bv->update();
+       bv.update();
        return DispatchResult(true, true);
 }
 
@@ -311,8 +310,8 @@ DispatchResult InsetFormulaBase::lfunMouseMotion(FuncRequest const & cmd)
 void InsetFormulaBase::edit(BufferView * bv, bool left)
 {
        lyxerr << "Called FormulaBase::edit" << endl;
-       releaseMathCursor(bv);
-       mathcursor = new MathCursor(this, left);
+       releaseMathCursor(*bv);
+       mathcursor = new MathCursor(bv, this, left);
        bv->fullCursor().push(this);
        // if that is removed, we won't get the magenta box when entering an
        // inset for the first time
@@ -323,8 +322,8 @@ void InsetFormulaBase::edit(BufferView * bv, bool left)
 void InsetFormulaBase::edit(BufferView * bv, int x, int y)
 {
        lyxerr << "Called FormulaBase::EDIT with '" << x << ' ' << y << "'" << endl;
-       releaseMathCursor(bv);
-       mathcursor = new MathCursor(this, true);
+       releaseMathCursor(*bv);
+       mathcursor = new MathCursor(bv, this, true);
        //metrics(bv);
        mathcursor->setScreenPos(x + xo_, y + yo_);
        bv->fullCursor().push(this);
@@ -335,8 +334,7 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int y)
 
 
 DispatchResult
-InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
-                               idx_type &, pos_type &)
+InsetFormulaBase::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        //lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
        //      << " arg: '" << cmd.argument
@@ -344,24 +342,22 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
        //      << " y: '" << cmd.y
        //      << "' button: " << cmd.button() << endl;
 
-       BufferView * bv = cmd.view();
-
        // delete empty mathbox (LFUN_BACKSPACE and LFUN_DELETE)
        bool remove_inset = false;
 
        switch (cmd.action) {
                case LFUN_MOUSE_PRESS:
                        //lyxerr << "Mouse single press" << endl;
-                       return lfunMousePress(cmd);
+                       return lfunMousePress(bv, cmd);
                case LFUN_MOUSE_MOTION:
                        //lyxerr << "Mouse motion" << endl;
-                       return lfunMouseMotion(cmd);
+                       return lfunMouseMotion(bv, cmd);
                case LFUN_MOUSE_RELEASE:
                        //lyxerr << "Mouse single release" << endl;
-                       return lfunMouseRelease(cmd);
+                       return lfunMouseRelease(bv, cmd);
                case LFUN_MOUSE_DOUBLE:
                        //lyxerr << "Mouse double" << endl;
-                       return dispatch(FuncRequest(LFUN_WORDSEL));
+                       return dispatch(bv, FuncRequest(LFUN_WORDSEL));
                default:
                        break;
        }
@@ -402,9 +398,9 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
                result = mathcursor->right(sel) ?
                        DispatchResult(true, true) : DispatchResult(false, FINISHED_RIGHT);
                //lyxerr << "calling scroll 20" << endl;
-               //scroll(bv, 20);
+               //scroll(&bv, 20);
                // write something to the minibuffer
-               //bv->owner()->message(mathcursor->info());
+               //bv.owner()->message(mathcursor->info());
                break;
 
        case LFUN_LEFTSEL:
@@ -580,7 +576,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
                        mathcursor->niceInsert(MathAtom(new MathHullInset("simple")));
                else
                        handleFont(bv, cmd.argument, "textrm");
-               //bv->owner()->message(_("math text mode toggled"));
+               //bv.owner()->message(_("math text mode toggled"));
                break;
 
        case LFUN_MATH_SIZE:
@@ -630,7 +626,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
                break;
 
        case LFUN_UNDO:
-               bv->owner()->message(_("Invalid action in math mode!"));
+               bv.owner()->message(_("Invalid action in math mode!"));
                break;
 
 
@@ -695,18 +691,17 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
                if (data.empty())
                        result = DispatchResult(false);
                else
-                       bv->owner()->getDialogs().show(name, data, 0);
+                       bv.owner()->getDialogs().show(name, data, 0);
                break;
        }
 
        case LFUN_INSET_APPLY: {
                string const name = cmd.getArg(0);
-               InsetBase * base =
-                       bv->owner()->getDialogs().getOpenInset(name);
+               InsetBase * base = bv.owner()->getDialogs().getOpenInset(name);
 
                if (base) {
-                       FuncRequest fr(bv, LFUN_INSET_MODIFY, cmd.argument);
-                       result = base->dispatch(fr);
+                       FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
+                       result = base->dispatch(bv, fr);
                } else {
                        MathArray ar;
                        if (createMathInset_fromDialogStr(cmd.argument, ar)) {
@@ -722,7 +717,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
        case LFUN_WORD_REPLACE:
        case LFUN_WORD_FIND: {
                result = 
-                       searchForward(cmd.view(), cmd.getArg(0), false, false)
+                       searchForward(&bv, cmd.getArg(0), false, false)
                                ? DispatchResult(true, true) : DispatchResult(false);
                break;
        }
@@ -732,7 +727,7 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
        }
 
        if (result == DispatchResult(true, true))
-               bv->update();
+               bv.update();
 
        mathcursor->normalize();
        mathcursor->touch();
@@ -740,26 +735,26 @@ InsetFormulaBase::priv_dispatch(FuncRequest const & cmd,
        BOOST_ASSERT(mathcursor);
 
        if (mathcursor->selection() || was_selection)
-               toggleInsetSelection(bv);
+               toggleInsetSelection(&bv);
 
        if (result.dispatched()) {
                revealCodes(bv);
-               cmd.view()->stuffClipboard(mathcursor->grabSelection());
+               bv.stuffClipboard(mathcursor->grabSelection());
        } else {
                releaseMathCursor(bv);
                if (remove_inset)
-                       bv->owner()->dispatch(FuncRequest(LFUN_DELETE));
+                       bv.owner()->dispatch(FuncRequest(LFUN_DELETE));
        }
 
        return result;  // original version
 }
 
 
-void InsetFormulaBase::revealCodes(BufferView * bv) const
+void InsetFormulaBase::revealCodes(BufferView & bv) const
 {
        if (!mathcursor)
                return;
-       bv->owner()->message(mathcursor->info());
+       bv.owner()->message(mathcursor->info());
 
 #if 0
        // write something to the minibuffer
@@ -785,7 +780,7 @@ void InsetFormulaBase::revealCodes(BufferView * bv) const
                res = res.substr(pos - 30);
        if (res.size() > 60)
                res = res.substr(0, 60);
-       bv->owner()->message(res);
+       bv.owner()->message(res);
 #endif
 }
 
@@ -851,7 +846,7 @@ bool InsetFormulaBase::searchForward(BufferView * bv, string const & str,
                MathArray const & a = top.asMathInset()->cell(top.idx_);
                if (a.matchpart(ar, top.pos_)) {
                        delete mathcursor;
-                       mathcursor = new MathCursor(this, true);
+                       mathcursor = new MathCursor(bv, this, true);
                        //metrics(bv);
                        mathcursor->setSelection(it, ar.size());
                        current = it;
@@ -889,28 +884,28 @@ string InsetFormulaBase::selectionAsString() const
 /////////////////////////////////////////////////////////////////////
 
 
-void mathDispatchCreation(FuncRequest const & cmd, bool display)
+void mathDispatchCreation(BufferView & bv, FuncRequest const & cmd,
+       bool display)
 {
-       BufferView * bv = cmd.view();
        // use selection if available..
        //string sel;
        //if (action == LFUN_MATH_IMPORT_SELECTION)
        //      sel = "";
        //else
 
-       string sel = bv->getLyXText()->selectionAsString(*bv->buffer(), false);
+       string sel = bv.getLyXText()->selectionAsString(*bv.buffer(), false);
 
        if (sel.empty()) {
-               InsetFormula * f = new InsetFormula(bv);
+               InsetFormula * f = new InsetFormula(&bv);
                if (openNewInset(bv, f)) {
-                       bv->fullCursor().innerInset()->
-                               dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
+                       bv.fullCursor().innerInset()->
+                               dispatch(bv, FuncRequest(LFUN_MATH_MUTATE, "simple"));
                        // don't do that also for LFUN_MATH_MODE unless you want end up with
                        // always changing to mathrm when opening an inlined inset
                        // -- I really hate "LyXfunc overloading"...
                        if (display)
-                               f->dispatch(FuncRequest(bv, LFUN_MATH_DISPLAY));
-                       f->dispatch(FuncRequest(bv, LFUN_INSERT_MATH, cmd.argument));
+                               f->dispatch(bv, FuncRequest(LFUN_MATH_DISPLAY));
+                       f->dispatch(bv, FuncRequest(LFUN_INSERT_MATH, cmd.argument));
                }
        } else {
                // create a macro if we see "\\newcommand" somewhere, and an ordinary
@@ -921,31 +916,30 @@ void mathDispatchCreation(FuncRequest const & cmd, bool display)
                        f = new InsetFormula(sel);
                else
                        f = new InsetFormulaMacro(sel);
-               bv->getLyXText()->cutSelection(true, false);
+               bv.getLyXText()->cutSelection(true, false);
                openNewInset(bv, f);
        }
        cmd.message(N_("Math editor mode"));
 }
 
 
-void mathDispatch(FuncRequest const & cmd)
+void mathDispatch(BufferView & bv, FuncRequest const & cmd)
 {
-       BufferView * bv = cmd.view();
-       if (!bv->available())
+       if (!bv.available())
                return;
 
        switch (cmd.action) {
 
                case LFUN_MATH_DISPLAY:
-                       mathDispatchCreation(cmd, true);
+                       mathDispatchCreation(bv, cmd, true);
                        break;
 
                case LFUN_MATH_MODE:
-                       mathDispatchCreation(cmd, false);
+                       mathDispatchCreation(bv, cmd, false);
                        break;
 
                case LFUN_MATH_IMPORT_SELECTION:
-                       mathDispatchCreation(cmd, false);
+                       mathDispatchCreation(bv, cmd, false);
                        break;
 
                case LFUN_MATH_MACRO:
@@ -964,11 +958,11 @@ void mathDispatch(FuncRequest const & cmd)
                case LFUN_INSERT_MATH:
                case LFUN_INSERT_MATRIX:
                case LFUN_MATH_DELIM: {
-                       InsetFormula * f = new InsetFormula(bv);
+                       InsetFormula * f = new InsetFormula(&bv);
                        if (openNewInset(bv, f)) {
-                               UpdatableInset * inset = bv->fullCursor().innerInset();
-                               inset->dispatch(FuncRequest(bv, LFUN_MATH_MUTATE, "simple"));
-                               inset->dispatch(cmd);
+                               UpdatableInset * inset = bv.fullCursor().innerInset();
+                               inset->dispatch(bv, FuncRequest(LFUN_MATH_MUTATE, "simple"));
+                               inset->dispatch(bv, cmd);
                        }
                        break;
                }
index dfc58331ffe4d16d450aaa374d13f65128aff431..e50002ddaa048789bf3c32051a3916ace727e3fb 100644 (file)
@@ -75,7 +75,7 @@ public:
        ///
        virtual void mutateToText();
        ///
-       virtual void revealCodes(BufferView *) const;
+       virtual void revealCodes(BufferView & bv) const;
        ///
        virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
        ///
@@ -89,19 +89,18 @@ public:
 protected:
        /// To allow transparent use of math editing functions
        virtual
-       DispatchResult
-       priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
+       DispatchResult priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        /// unimplemented
        void operator=(const InsetFormulaBase &);
        /// common base for handling accents
-       void handleAccent(BufferView * bv, std::string const & arg, std::string const & name);
+       void handleAccent(BufferView & bv, std::string const & arg, std::string const & name);
        /// lfun handler
-       DispatchResult lfunMousePress(FuncRequest const &);
+       DispatchResult lfunMousePress(BufferView &, FuncRequest const &);
        ///
-       DispatchResult lfunMouseRelease(FuncRequest const &);
+       DispatchResult lfunMouseRelease(BufferView &, FuncRequest const &);
        ///
-       DispatchResult lfunMouseMotion(FuncRequest const &);
+       DispatchResult lfunMouseMotion(BufferView &, FuncRequest const &);
 
 protected:
 
@@ -114,16 +113,16 @@ protected:
        virtual void generatePreview(Buffer const &) const {}
 
        ///
-       void handleFont(BufferView * bv, std::string const & arg, std::string const & font);
+       void handleFont(BufferView & bv, std::string const & arg, std::string const & font);
        ///
-       void handleFont2(BufferView * bv, std::string const & arg);
+       void handleFont2(BufferView & bv, std::string const & arg);
 };
 
 // We don't really mess want around with mathed stuff outside mathed.
 // So do it here.
-void mathDispatch(FuncRequest const &);
+void mathDispatch(BufferView & bv, FuncRequest const & cmd);
 
 ///
-void releaseMathCursor(BufferView * bv);
+void releaseMathCursor(BufferView & bv);
 
 #endif
index 11578c0f9973aaa221f4cbd46d1b094eed1ecae3..e13156d5d20ea5503a42ad52843176dd98d56e45 100644 (file)
 #include <config.h>
 
 #include "math_cursor.h"
-#include "lyxrc.h"
-#include "support/limited_stack.h"
-#include "dispatchresult.h"
+#include "BufferView.h"
+#include "cursor.h"
 #include "debug.h"
-#include "support/std_sstream.h"
+#include "dispatchresult.h"
 #include "formulabase.h"
 #include "funcrequest.h"
+#include "lyxrc.h"
 #include "math_braceinset.h"
 #include "math_commentinset.h"
 #include "math_charinset.h"
@@ -32,6 +32,9 @@
 #include "math_support.h"
 #include "math_unknowninset.h"
 
+#include "support/limited_stack.h"
+#include "support/std_sstream.h"
+
 #include <boost/assert.hpp>
 
 //#define FILEDEBUG 1
@@ -43,7 +46,6 @@ using std::isalpha;
 #endif
 using std::min;
 using std::swap;
-
 using std::ostringstream;
 
 
@@ -51,25 +53,24 @@ using std::ostringstream;
 limited_stack<string> theCutBuffer;
 
 
-MathCursor::MathCursor(InsetFormulaBase * formula, bool front)
-       :       formula_(formula), autocorrect_(false), selection_(false), targetx_(-1)
+MathCursor::MathCursor(BufferView * bv, InsetFormulaBase * formula, bool front)
+       :       formula_(formula), autocorrect_(false), selection_(false), bv_(bv)
 {
        front ? first() : last();
-       Anchor_ = Cursor_;
 }
 
 
 MathCursor::~MathCursor()
 {
        // ensure that 'notifyCursorLeave' is called
-       while (popLeft())
-               ;
+       //while (popLeft())
+       //      ;
 }
 
 
 void MathCursor::push(MathAtom & t)
 {
-       Cursor_.push_back(CursorSlice(t.nucleus()));
+       bv_->fullCursor().push(t.nucleus());
 }
 
 
@@ -77,7 +78,7 @@ void MathCursor::pushLeft(MathAtom & t)
 {
        //lyxerr << "Entering atom " << t << " left" << endl;
        push(t);
-       t->idxFirst(idx(), pos());
+       t->idxFirst(*bv_);
 }
 
 
@@ -86,7 +87,7 @@ void MathCursor::pushRight(MathAtom & t)
        //lyxerr << "Entering atom " << t << " right" << endl;
        posLeft();
        push(t);
-       t->idxLast(idx(), pos());
+       t->idxLast(*bv_);
 }
 
 
@@ -99,7 +100,7 @@ bool MathCursor::popLeft()
                return false;
        }
        inset()->notifyCursorLeaves(idx());
-       Cursor_.pop_back();
+       bv_->fullCursor().pop();
        return true;
 }
 
@@ -113,7 +114,7 @@ bool MathCursor::popRight()
                return false;
        }
        inset()->notifyCursorLeaves(idx());
-       Cursor_.pop_back();
+       bv_->fullCursor().pop();
        posRight();
        return true;
 }
@@ -137,11 +138,14 @@ bool MathCursor::popRight()
 #endif
 
 
-bool MathCursor::isInside(MathInset const * p) const
+bool MathCursor::isInside(MathInset const *) const
 {
+#warning FIXME
+/*
        for (unsigned i = 0; i < depth(); ++i)
                if (Cursor_[i].asMathInset() == p)
                        return true;
+*/
        return false;
 }
 
@@ -154,6 +158,8 @@ bool MathCursor::openable(MathAtom const & t, bool sel) const
        if (t->lock())
                return false;
 
+#warning FIXME
+#if 0
        if (sel) {
                // we can't move into anything new during selection
                if (depth() == Anchor_.size())
@@ -161,6 +167,11 @@ bool MathCursor::openable(MathAtom const & t, bool sel) const
                if (t.operator->() != Anchor_[depth()].asMathInset())
                        return false;
        }
+#else
+       if (sel)
+               return false;
+#endif
+
        return true;
 }
 
@@ -193,7 +204,7 @@ bool MathCursor::left(bool sel)
 {
        dump("Left 1");
        autocorrect_ = false;
-       targetx_ = -1; // "no target"
+       bv_->x_target(-1); // "no target"
        if (inMacroMode()) {
                macroModeClose();
                return true;
@@ -213,7 +224,7 @@ bool MathCursor::right(bool sel)
 {
        dump("Right 1");
        autocorrect_ = false;
-       targetx_ = -1; // "no target"
+       bv_->x_target(-1); // "no target"
        if (inMacroMode()) {
                macroModeClose();
                return true;
@@ -231,17 +242,21 @@ bool MathCursor::right(bool sel)
 
 void MathCursor::first()
 {
-       Cursor_.clear();
+#warning FIXME
+       //Cursor_.clear();
        push(formula_->par());
-       inset()->idxFirst(idx(), pos());
+       inset()->idxFirst(*bv_);
+       bv_->resetAnchor();
 }
 
 
 void MathCursor::last()
 {
-       Cursor_.clear();
+#warning FIXME
+       //Cursor_.clear();
        push(formula_->par());
-       inset()->idxLast(idx(), pos());
+       inset()->idxLast(*bv_);
+       bv_->resetAnchor();
 }
 
 
@@ -273,7 +288,7 @@ void MathCursor::setScreenPos(int x, int y)
                dump("setScreenPos 1.5");
                first();
        }
-       targetx_ = -1; // "no target"
+       bv_->x_target(-1); // "no target"
        dump("setScreenPos 2");
 }
 
@@ -285,10 +300,10 @@ bool MathCursor::home(bool sel)
        autocorrect_ = false;
        selHandle(sel);
        macroModeClose();
-       if (!inset()->idxHome(idx(), pos()))
+       if (!inset()->idxHome(*bv_))
                return popLeft();
        dump("home 2");
-       targetx_ = -1; // "no target"
+       bv_->x_target(-1); // "no target"
        return true;
 }
 
@@ -299,10 +314,10 @@ bool MathCursor::end(bool sel)
        autocorrect_ = false;
        selHandle(sel);
        macroModeClose();
-       if (!inset()->idxEnd(idx(), pos()))
+       if (!inset()->idxEnd(*bv_))
                return popRight();
        dump("end 2");
-       targetx_ = -1; // "no target"
+       bv_->x_target(-1); // "no target"
        return true;
 }
 
@@ -491,10 +506,13 @@ bool MathCursor::up(bool sel)
        dump("up 1");
        macroModeClose();
        selHandle(sel);
+#warning FIXME
+#if 0
        CursorBase save = Cursor_;
        if (goUpDown(true))
                return true;
        Cursor_ = save;
+#endif
        autocorrect_ = false;
        return selection_;
 }
@@ -505,10 +523,13 @@ bool MathCursor::down(bool sel)
        dump("down 1");
        macroModeClose();
        selHandle(sel);
+#warning FIXME
+#if 0
        CursorBase save = Cursor_;
        if (goUpDown(false))
                return true;
        Cursor_ = save;
+#endif
        autocorrect_ = false;
        return selection_;
 }
@@ -547,8 +568,8 @@ string MathCursor::macroName() const
 
 void MathCursor::selClear()
 {
-       Anchor_.clear();
-       selection_ = false;
+       bv_->resetAnchor();
+       bv_->clearSelection();
 }
 
 
@@ -597,7 +618,7 @@ void MathCursor::selHandle(bool sel)
        if (sel == selection_)
                return;
        //clear();
-       Anchor_ = Cursor_;
+       bv_->resetAnchor();
        selection_ = sel;
 }
 
@@ -606,7 +627,7 @@ void MathCursor::selStart()
 {
        dump("selStart 1");
        //clear();
-       Anchor_ = Cursor_;
+       bv_->resetAnchor();
        selection_ = true;
        dump("selStart 2");
 }
@@ -649,8 +670,8 @@ void MathCursor::getScreenPos(int & x, int & y) const
 
 int MathCursor::targetX() const
 {
-       if (targetx_ != -1)
-               return targetx_;
+       if (bv_->x_target() != -1)
+               return bv_->x_target();
        int x = 0, y = 0;
        getScreenPos(x, y);
        return x;
@@ -689,6 +710,8 @@ MathCursor::pos_type MathCursor::pos() const
 
 void MathCursor::adjust(pos_type from, difference_type diff)
 {
+#warning FIXME
+#if 0
        if (cursor().pos_ > from)
                cursor().pos_ += diff;
        if (Anchor_.back().pos_ > from)
@@ -696,6 +719,7 @@ void MathCursor::adjust(pos_type from, difference_type diff)
        // just to be on the safe side
        // theoretically unecessary
        normalize();
+#endif
 }
 
 
@@ -740,6 +764,8 @@ bool MathCursor::selection() const
 
 MathGridInset * MathCursor::enclosingGrid(MathCursor::idx_type & idx) const
 {
+#warning FIXME
+#if 0
        for (MathInset::difference_type i = depth() - 1; i >= 0; --i) {
                MathGridInset * p = Cursor_[i].asMathInset()->asGridInset();
                if (p) {
@@ -747,28 +773,38 @@ MathGridInset * MathCursor::enclosingGrid(MathCursor::idx_type & idx) const
                        return p;
                }
        }
+#endif
        return 0;
 }
 
 
 void MathCursor::popToHere(MathInset const * p)
 {
+#warning FIXME
+#if 0
        while (depth() && Cursor_.back().asMathInset() != p)
                Cursor_.pop_back();
+#endif
 }
 
 
 void MathCursor::popToEnclosingGrid()
 {
+#warning FIXME
+#if 0
        while (depth() && !Cursor_.back().asMathInset()->asGridInset())
                Cursor_.pop_back();
+#endif
 }
 
 
 void MathCursor::popToEnclosingHull()
 {
+#warning FIXME
+#if 0
        while (depth() && !Cursor_.back().asMathInset()->asHullInset())
                Cursor_.pop_back();
+#endif
 }
 
 
@@ -779,7 +815,7 @@ void MathCursor::pullArg()
        if (popLeft()) {
                plainErase();
                array().insert(pos(), a);
-               Anchor_ = Cursor_;
+               bv_->resetAnchor();
        } else {
                formula()->mutateToText();
        }
@@ -788,10 +824,13 @@ void MathCursor::pullArg()
 
 void MathCursor::touch()
 {
+#warning
+#if 0
        CursorBase::const_iterator it = Cursor_.begin();
        CursorBase::const_iterator et = Cursor_.end();
        for ( ; it != et; ++it)
                it->cell().touch();
+#endif
 }
 
 
@@ -884,13 +923,13 @@ MathArray & MathCursor::array() const
 
 void MathCursor::idxNext()
 {
-       inset()->idxNext(idx(), pos());
+       inset()->idxNext(*bv_);
 }
 
 
 void MathCursor::idxPrev()
 {
-       inset()->idxPrev(idx(), pos());
+       inset()->idxPrev(*bv_);
 }
 
 
@@ -925,15 +964,13 @@ void MathCursor::getSelection(CursorSlice & i1, CursorSlice & i2) const
 
 CursorSlice & MathCursor::cursor()
 {
-       BOOST_ASSERT(depth());
-       return Cursor_.back();
+       return bv_->cursor();
 }
 
 
 CursorSlice const & MathCursor::cursor() const
 {
-       BOOST_ASSERT(depth());
-       return Cursor_.back();
+       return bv_->cursor();
 }
 
 
@@ -947,10 +984,10 @@ bool MathCursor::goUpDown(bool up)
        getScreenPos(xo, yo);
 
        // check if we had something else in mind, if not, this is the future goal
-       if (targetx_ == -1)
-               targetx_ = xo;
+       if (bv_->x_target() == -1)
+               bv_->x_target(xo);
        else
-               xo = targetx_;
+               xo = bv_->x_target();
 
        // try neigbouring script insets
        if (!selection()) {
@@ -981,7 +1018,7 @@ bool MathCursor::goUpDown(bool up)
        }
 
        // try current cell for e.g. text insets
-       if (inset()->idxUpDown2(idx(), pos(), up, targetx_))
+       if (inset()->idxUpDown2(*bv_, up, bv_->x_target()))
                return true;
 
        //xarray().boundingBox(xlow, xhigh, ylow, yhigh);
@@ -998,7 +1035,7 @@ bool MathCursor::goUpDown(bool up)
        while (1) {
                //lyxerr << "updown: We are in " << inset() << " idx: " << idx() << endl;
                // ask inset first
-               if (inset()->idxUpDown(idx(), pos(), up, targetx_)) {
+               if (inset()->idxUpDown(*bv_, up, bv_->x_target())) {
                        // try to find best position within this inset
                        if (!selection())
                                bruteFind2(xo, yo);
@@ -1028,6 +1065,7 @@ bool MathCursor::goUpDown(bool up)
 bool MathCursor::bruteFind
        (int x, int y, int xlow, int xhigh, int ylow, int yhigh)
 {
+#if 0
        CursorBase best_cursor;
        double best_dist = 1e10;
 
@@ -1055,19 +1093,23 @@ bool MathCursor::bruteFind
                increment(it);
        }
 
-       if (best_dist < 1e10)
-               Cursor_ = best_cursor;
+#warning FIXME
+       //if (best_dist < 1e10)
+       //      Cursor_ = best_cursor;
        return best_dist < 1e10;
+#endif
+       return 0;
 }
 
 
 void MathCursor::bruteFind2(int x, int y)
 {
+#if 0
        double best_dist = 1e10;
 
-       CursorBase it = Cursor_;
+       CursorBase it = bv_->fullCursor().cursor_;
        it.back().pos(0);
-       CursorBase et = Cursor_;
+       CursorBase et = bv_->fullCursor().cursor_;
        int n = et.back().asMathInset()->cell(et.back().idx_).size();
        et.back().pos(n);
        for (int i = 0; ; ++i) {
@@ -1085,6 +1127,7 @@ void MathCursor::bruteFind2(int x, int y)
                        break;
                increment(it);
        }
+#endif
 }
 
 
@@ -1098,13 +1141,13 @@ bool MathCursor::idxLineLast()
 
 bool MathCursor::idxLeft()
 {
-       return inset()->idxLeft(idx(), pos());
+       return inset()->idxLeft(*bv_);
 }
 
 
 bool MathCursor::idxRight()
 {
-       return inset()->idxRight(idx(), pos());
+       return inset()->idxRight(*bv_);
 }
 
 
@@ -1153,7 +1196,7 @@ bool MathCursor::script(bool up)
 bool MathCursor::interpret(char c)
 {
        //lyxerr << "interpret 2: '" << c << "'" << endl;
-       targetx_ = -1; // "no target"
+       bv_->x_target(-1); // "no target"
        if (inMacroArgMode()) {
                --pos();
                plainErase();
@@ -1288,10 +1331,13 @@ bool MathCursor::interpret(char c)
 
 void MathCursor::setSelection(CursorBase const & where, size_type n)
 {
+#warning FIXME
+#if 0
        selection_ = true;
        Anchor_ = where;
        Cursor_ = where;
        cursor().pos_ += n;
+#endif
 }
 
 
@@ -1313,7 +1359,8 @@ string MathCursor::info() const
        ostringstream os;
        os << "Math editor mode.  ";
        for (int i = 0, n = depth(); i < n; ++i) {
-               Cursor_[i].asMathInset()->infoize(os);
+#warning FIXME
+               //Cursor_[i].asMathInset()->infoize(os);
                os << "  ";
        }
        if (hasPrevAtom())
@@ -1325,7 +1372,7 @@ string MathCursor::info() const
 
 unsigned MathCursor::depth() const
 {
-       return Cursor_.size();
+       return bv_->fullCursor().cursor_.size();
 }
 
 
@@ -1416,8 +1463,10 @@ string MathCursor::grabAndEraseSelection()
 
 CursorSlice MathCursor::normalAnchor() const
 {
+#warning FIXME
+#if 0
        if (Anchor_.size() < depth()) {
-               Anchor_ = Cursor_;
+               bv_->resetAnchor();
                lyxerr << "unusual Anchor size" << endl;
        }
        //lyx::BOOST_ASSERT(Anchor_.size() >= cursor.depth());
@@ -1428,11 +1477,15 @@ CursorSlice MathCursor::normalAnchor() const
                ++normal.pos_;
        }
        return normal;
+#else
+       return cursor();
+#endif
 }
 
 
 DispatchResult MathCursor::dispatch(FuncRequest const & cmd)
 {
+/*
        // mouse clicks are somewhat special
        // check
        switch (cmd.action) {
@@ -1462,9 +1515,10 @@ DispatchResult MathCursor::dispatch(FuncRequest const & cmd)
        }
 
        for (int i = Cursor_.size() - 1; i >= 0; --i) {
-               CursorSlice & pos = Cursor_[i];
-               DispatchResult const res =
-                       pos.asMathInset()->dispatch(cmd, pos.idx_, pos.pos_);
+               CursorBase tmp = bv->Cursor_;
+               bv
+               CursorSlice & pos = tmp.back()
+               DispatchResult const res = pos.asMathInset()->dispatch(bv, cmd);
                if (res.dispatched()) {
                        if (res.val() == FINISHED) {
                                if (i + 1 < Cursor_.size())
@@ -1474,17 +1528,21 @@ DispatchResult MathCursor::dispatch(FuncRequest const & cmd)
                        return res;
                }
        }
+*/
        return DispatchResult(false);
 }
 
 
 MathInset::mode_type MathCursor::currentMode() const
 {
+#warning FIXME
+#if 0
        for (int i = Cursor_.size() - 1; i >= 0; --i) {
                MathInset::mode_type res = Cursor_[i].asMathInset()->currentMode();
                if (res != MathInset::UNDECIDED_MODE)
                        return res;
        }
+#endif
        return MathInset::UNDECIDED_MODE;
 }
 
@@ -1523,12 +1581,12 @@ void MathCursor::handleFont(string const & font)
 }
 
 
-void releaseMathCursor(BufferView * bv)
+void releaseMathCursor(BufferView & bv)
 {
        if (mathcursor) {
-               InsetFormulaBase * f =  mathcursor->formula();
+               InsetFormulaBase * f = mathcursor->formula();
                delete mathcursor;
                mathcursor = 0;
-               f->insetUnlock(bv);
+               f->insetUnlock(&bv);
        }
 }
index 6bf922cbc0ea903dcd93f098b1a99297d90e2aea..23c94a7ed731ba0650fd763e4f0f2d4ac716379f 100644 (file)
@@ -19,7 +19,6 @@
 
 #include <string>
 
-
 class InsetFormulaBase;
 class BufferView;
 class PainterInfo;
@@ -53,7 +52,7 @@ public:
        typedef size_t             col_type;
 
        ///
-       explicit MathCursor(InsetFormulaBase *, bool left);
+       explicit MathCursor(BufferView *, InsetFormulaBase *, bool left);
        ///
        ~MathCursor();
        ///
@@ -280,10 +279,6 @@ private:
        /// write access to cursor cell index
        idx_type & idx();
 
-       /// path of positions the cursor had to go if it were leaving each inset
-       CursorBase Cursor_;
-       /// path of positions the anchor had to go if it were leaving each inset
-       mutable CursorBase Anchor_;
        /// pointer to enclsing LyX inset
        InsetFormulaBase * formula_;
        // Selection stuff
@@ -295,11 +290,11 @@ private:
        bool selection_;
        /// are we entering a macro name?
        bool macromode_;
-       /// are we targeting a certain x coordinate, if so, which one?
-       int targetx_;
+       ///
+       BufferView * bv_;
 };
 
 extern MathCursor * mathcursor;
-void releaseMathCursor(BufferView * bv);
+void releaseMathCursor(BufferView & bv);
 
 #endif
index 24bbd29ca042481b296b35b03a7093ed2a1c15de..ecc16c71d7ac66c0cccba9731adbe10f8952f9a4 100644 (file)
@@ -19,25 +19,25 @@ MathFracbaseInset::MathFracbaseInset()
 {}
 
 
-bool MathFracbaseInset::idxRight(idx_type &, pos_type &) const
+bool MathFracbaseInset::idxRight(BufferView &) const
 {
        return false;
 }
 
 
-bool MathFracbaseInset::idxLeft(idx_type &, pos_type &) const
+bool MathFracbaseInset::idxLeft(BufferView &) const
 {
        return false;
 }
 
 
-bool MathFracbaseInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
-       int targetx) const
+bool MathFracbaseInset::idxUpDown(BufferView & bv, bool up, int targetx) const
 {
+       CursorSlice & cur = cursorTip(bv);
        MathInset::idx_type target = !up; // up ? 0 : 1, since upper cell has idx 0
-       if (idx == target)
+       if (cur.idx() == target)
                return false;
-       idx = target;
-       pos = cell(idx).x2pos(targetx);
+       cur.idx() = target;
+       cur.pos() = cell(target).x2pos(targetx);
        return true;
 }
index 57645ba5e51709b4eac8cd23cbe7280c2bb45512..3e4549b9f1b89c8ca5739bb5f9db8c4f4ac1b153 100644 (file)
@@ -20,11 +20,11 @@ public:
        ///
        MathFracbaseInset();
        ///
-       bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+       bool idxUpDown(BufferView &, bool up, int targetx) const;
        ///
-       bool idxLeft(idx_type & idx, pos_type & pos) const;
+       bool idxLeft(BufferView &) const;
        ///
-       bool idxRight(idx_type & idx, pos_type & pos) const;
+       bool idxRight(BufferView &) const;
 };
 
 #endif
index d16f82776cfd17ed3badbd83fc1ff4662a07013c..77e3badbc6c3290e55e31d86ecb3aedfa21eed10 100644 (file)
@@ -751,115 +751,119 @@ int MathGridInset::cellYOffset(idx_type idx) const
 }
 
 
-bool MathGridInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
-       int targetx) const
+bool MathGridInset::idxUpDown(BufferView & bv, bool up, int targetx) const
 {
+       CursorSlice & cur = cursorTip(bv);
        if (up) {
-               if (idx < ncols())
+               if (cur.idx() < ncols())
                        return false;
-               idx -= ncols();
-               pos = cell(idx).x2pos(targetx - cell(idx).xo());
-               return true;
+               cur.idx() -= ncols();
        } else {
-               if (idx >= ncols() * (nrows() - 1))
+               if (cur.idx() >= ncols() * (nrows() - 1))
                        return false;
-               idx += ncols();
-               pos = cell(idx).x2pos(targetx - cell(idx).xo());
-               return true;
+               cur.idx() += ncols();
        }
+       cur.pos() = cur.cell().x2pos(targetx - cur.cell().xo());
+       return true;
 }
 
 
-bool MathGridInset::idxLeft(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxLeft(BufferView & bv) const
 {
        // leave matrix if on the left hand edge
-       if (col(idx) == 0)
+       CursorSlice & cur = cursorTip(bv);
+       if (cur.col() == 0)
                return false;
-       --idx;
-       pos = cell(idx).size();
+       --cur.idx();
+       cur.pos() = cur.lastpos();
        return true;
 }
 
 
-bool MathGridInset::idxRight(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxRight(BufferView & bv) const
 {
        // leave matrix if on the right hand edge
-       if (col(idx) + 1 == ncols())
+       CursorSlice & cur = cursorTip(bv);
+       if (cur.col() + 1 == ncols())
                return false;
-       ++idx;
-       pos = 0;
+       ++cur.idx();
+       cur.pos() = 0;
        return true;
 }
 
 
-bool MathGridInset::idxFirst(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxFirst(BufferView & bv) const
 {
+       CursorSlice & cur = cursorTip(bv);
        switch (v_align_) {
                case 't':
-                       idx = 0;
+                       cur.idx() = 0;
                        break;
                case 'b':
-                       idx = (nrows() - 1) * ncols();
+                       cur.idx() = (nrows() - 1) * ncols();
                        break;
                default:
-                       idx = ((nrows() - 1) / 2) * ncols();
+                       cur.idx() = ((nrows() - 1) / 2) * ncols();
        }
-       pos = 0;
+       cur.pos() = 0;
        return true;
 }
 
 
-bool MathGridInset::idxLast(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxLast(BufferView & bv) const
 {
+       CursorSlice & cur = cursorTip(bv);
        switch (v_align_) {
                case 't':
-                       idx = ncols() - 1;
+                       cur.idx() = ncols() - 1;
                        break;
                case 'b':
-                       idx = nargs() - 1;
+                       cur.idx() = nargs() - 1;
                        break;
                default:
-                       idx = ((nrows() - 1) / 2 + 1) * ncols() - 1;
+                       cur.idx() = ((nrows() - 1) / 2 + 1) * ncols() - 1;
        }
-       pos = cell(idx).size();
+       cur.pos() = cur.lastpos();
        return true;
 }
 
 
-bool MathGridInset::idxHome(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxHome(BufferView & bv) const
 {
-       if (pos > 0) {
-               pos = 0;
+       CursorSlice & cur = cursorTip(bv);
+       if (cur.pos() > 0) {
+               cur.pos() = 0;
                return true;
        }
-       if (col(idx) > 0) {
-               idx -= idx % ncols();
-               pos = 0;
+       if (cur.col() > 0) {
+               cur.idx() -= cur.idx() % ncols();
+               cur.pos() = 0;
                return true;
        }
-       if (idx > 0) {
-               idx = 0;
-               pos = 0;
+       if (cur.idx() > 0) {
+               cur.idx() = 0;
+               cur.pos() = 0;
                return true;
        }
        return false;
 }
 
 
-bool MathGridInset::idxEnd(idx_type & idx, pos_type & pos) const
+bool MathGridInset::idxEnd(BufferView & bv) const
 {
-       if (pos < cell(idx).size()) {
-               pos = cell(idx).size();
+       CursorSlice & cur = cursorTip(bv);
+       if (cur.pos() < cur.lastpos()) {
+               cur.pos() = cur.lastpos();
                return true;
        }
-       if (col(idx) < ncols() - 1) {
-               idx = idx - idx % ncols() + ncols() - 1;
-               pos = cell(idx).size();
+       if (cur.col() < ncols() - 1) {
+               cur.idx() = cur.idx() - cur.idx() % ncols() + ncols() - 1;
+               cur.pos() = cur.lastpos();
                return true;
        }
-       if (idx < nargs() - 1) {
-               idx = nargs() - 1;
-               pos = cell(idx).size();
+       if (cur.idx() < nargs() - 1) {
+               cur.idx() = nargs() - 1;
+               cur.pos() = cur.lastpos();
                return true;
        }
        return false;
@@ -1029,22 +1033,24 @@ int MathGridInset::border() const
 }
 
 
-void MathGridInset::splitCell(idx_type & idx, pos_type & pos)
+void MathGridInset::splitCell(BufferView & bv)
 {
-       if (idx + 1 == nargs())
+       CursorSlice & cur = cursorTip(bv);
+       if (cur.idx() + 1 == nargs())
                return;
-       MathArray ar = cell(idx);
-       ar.erase(0, pos);
-       cell(idx).erase(pos, cell(idx).size());
-       ++idx;
-       pos = 0;
-       cell(idx).insert(0, ar);
+       MathArray ar = cur.cell();
+       ar.erase(0, cur.pos());
+       cur.cell().erase(cur.pos(), cur.lastpos());
+       ++cur.idx();
+       cur.pos() = 0;
+       cur.cell().insert(0, ar);
 }
 
 
-DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
-       idx_type & idx, pos_type & pos)
+DispatchResult
+MathGridInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
+       CursorSlice & cur = cursorTip(bv);
        switch (cmd.action) {
 
                case LFUN_MOUSE_RELEASE:
@@ -1055,7 +1061,7 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
                        return DispatchResult(false);
 
                case LFUN_INSET_DIALOG_UPDATE:
-                       GridInsetMailer(*this).updateDialog(cmd.view());
+                       GridInsetMailer(*this).updateDialog(&bv);
                        return DispatchResult(false);
 
                // insert file functions
@@ -1067,33 +1073,33 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
                        //      return;
                        //}
                        if (nrows() > 1)
-                               delRow(row(idx));
-                       if (idx >= nargs())
-                               idx = nargs() - 1;
-                       if (pos > cell(idx).size())
-                               pos = cell(idx).size();
+                               delRow(cur.row());
+                       if (cur.idx() >= nargs())
+                               cur.idx() = nargs() - 1;
+                       if (cur.pos() > cur.lastpos())
+                               cur.pos() = cur.lastpos();
                        return DispatchResult(true, FINISHED);
 
                case LFUN_CELL_SPLIT:
                        //recordUndo(bv, Undo::ATOMIC);
-                       splitCell(idx, pos);
+                       splitCell(bv);
                        return DispatchResult(true, FINISHED);
 
                case LFUN_BREAKLINE: {
                        //recordUndo(bv, Undo::INSERT);
-                       row_type const r = row(idx);
+                       row_type const r = cur.row();
                        addRow(r);
 
                        // split line
-                       for (col_type c = col(idx) + 1; c < ncols(); ++c)
+                       for (col_type c = col(cur.idx()) + 1; c < ncols(); ++c)
                                std::swap(cell(index(r, c)), cell(index(r + 1, c)));
 
                        // split cell
-                       splitCell(idx, pos);
-                       std::swap(cell(idx), cell(idx + ncols() - 1));
-                       if (idx > 0)
-                               --idx;
-                       pos = cell(idx).size();
+                       splitCell(bv);
+                       std::swap(cell(cur.idx()), cell(cur.idx() + ncols() - 1));
+                       if (cur.idx() > 0)
+                               --cur.idx();
+                       cur.idx() = cur.lastpos();
 
                        //mathcursor->normalize();
                        return DispatchResult(true, FINISHED);
@@ -1111,45 +1117,45 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
                        else if (s == "valign-bottom")
                                valign('b');
                        else if (s == "align-left")
-                               halign('l', col(idx));
+                               halign('l', col(cur.idx()));
                        else if (s == "align-right")
-                               halign('r', col(idx));
+                               halign('r', col(cur.idx()));
                        else if (s == "align-center")
-                               halign('c', col(idx));
+                               halign('c', col(cur.idx()));
                        else if (s == "append-row")
                                for (int i = 0, n = extractInt(is); i < n; ++i)
-                                       addRow(row(idx));
+                                       addRow(cur.row());
                        else if (s == "delete-row")
                                for (int i = 0, n = extractInt(is); i < n; ++i) {
-                                       delRow(row(idx));
-                                       if (idx > nargs())
-                                               idx -= ncols();
+                                       delRow(cur.row());
+                                       if (cur.idx() > nargs())
+                                               cur.idx() -= ncols();
                                }
                        else if (s == "copy-row")
                                for (int i = 0, n = extractInt(is); i < n; ++i)
-                                       copyRow(row(idx));
+                                       copyRow(cur.row());
                        else if (s == "swap-row")
-                               swapRow(row(idx));
+                               swapRow(cur.row());
                        else if (s == "append-column")
                                for (int i = 0, n = extractInt(is); i < n; ++i) {
-                                       row_type r = row(idx);
-                                       col_type c = col(idx);
+                                       row_type r = cur.row();
+                                       col_type c = col(cur.idx());
                                        addCol(c);
-                                       idx = index(r, c);
+                                       cur.idx() = index(r, c);
                                }
                        else if (s == "delete-column")
                                for (int i = 0, n = extractInt(is); i < n; ++i) {
-                                       row_type r = row(idx);
-                                       col_type c = col(idx);
-                                       delCol(col(idx));
-                                       idx = index(r, c);
-                                       if (idx > nargs())
-                                               idx -= ncols();
+                                       row_type r = cur.row();
+                                       col_type c = col(cur.idx());
+                                       delCol(col(cur.idx()));
+                                       cur.idx() = index(r, c);
+                                       if (cur.idx() > nargs())
+                                               cur.idx() -= ncols();
                                }
                        else if (s == "copy-column")
-                               copyCol(col(idx));
+                               copyCol(col(cur.idx()));
                        else if (s == "swap-column")
-                               swapCol(col(idx));
+                               swapCol(col(cur.idx()));
                        else
                                return DispatchResult(false);
                        lyxerr << "returning DispatchResult(true, FINISHED)" << endl;
@@ -1162,19 +1168,21 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
                        mathed_parse_normal(grid, cmd.argument);
                        if (grid.nargs() == 1) {
                                // single cell/part of cell
-                               cell(idx).insert(pos, grid.cell(0));
-                               pos += grid.cell(0).size();
+                               cur.cell().insert(cur.pos(), grid.cell(0));
+                               cur.pos() += grid.cell(0).size();
                        } else {
                                // multiple cells
-                               col_type const numcols = min(grid.ncols(), ncols() - col(idx));
-                               row_type const numrows = min(grid.nrows(), nrows() - row(idx));
+                               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 + row(idx), c + col(idx));
+                                               idx_type i = index(r + cur.row(), c + col(cur.idx()));
                                                cell(i).insert(0, grid.cell(grid.index(r, c)));
                                        }
                                        // append the left over horizontal cells to the last column
-                                       idx_type i = index(r + row(idx), ncols() - 1);
+                                       idx_type i = index(r + cur.row(), ncols() - 1);
                                        for (MathInset::col_type c = numcols; c < grid.ncols(); ++c)
                                                cell(i).append(grid.cell(grid.index(r, c)));
                                }
@@ -1188,6 +1196,6 @@ DispatchResult MathGridInset::priv_dispatch(FuncRequest const & cmd,
                }
 
                default:
-                       return MathNestInset::priv_dispatch(cmd, idx, pos);
+                       return MathNestInset::priv_dispatch(bv, cmd);
        }
 }
index c60ed8108f3133f3458aef423fd51d87bb4ccae5..37ff4a289b8eec34ed140a5cd9d4af5a46ff2fca 100644 (file)
@@ -145,19 +145,19 @@ public:
        row_type row(idx_type idx) const;
 
        ///
-       bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+       bool idxUpDown(BufferView &, bool up, int targetx) const;
        ///
-       bool idxLeft(idx_type & idx, pos_type & pos) const;
+       bool idxLeft(BufferView &) const;
        ///
-       bool idxRight(idx_type & idx, pos_type & pos) const;
+       bool idxRight(BufferView &) const;
        ///
-       bool idxFirst(idx_type & idx, pos_type & pos) const;
+       bool idxFirst(BufferView &) const;
        ///
-       bool idxLast(idx_type & idx, pos_type & pos) const;
+       bool idxLast(BufferView &) const;
        ///
-       bool idxHome(idx_type & idx, pos_type & pos) const;
+       bool idxHome(BufferView &) const;
        ///
-       bool idxEnd(idx_type & idx, pos_type & pos) const;
+       bool idxEnd(BufferView &) const;
        ///
        bool idxDelete(idx_type & idx);
        /// pulls cell after pressing erase
@@ -218,7 +218,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 
        /// returns x offset of cell compared to inset
        int cellXOffset(idx_type idx) const;
@@ -231,7 +231,7 @@ protected:
        /// extract number of columns from alignment string
        col_type guessColumns(std::string const & halign) const;
        /// splits cells and shifts right part to the next cell
-       void splitCell(idx_type &, pos_type & pos);
+       void splitCell(BufferView & pos);
 
 public:
        /// row info
index caf7b2393620ebaef98dcde29ffd0f1252e53f69..c1b6771167d5da088ea8f74c25bdbaf113a06a99 100644 (file)
@@ -135,18 +135,20 @@ MathInset::mode_type MathHullInset::currentMode() const
 }
 
 
-bool MathHullInset::idxFirst(idx_type & idx, pos_type & pos) const
+bool MathHullInset::idxFirst(BufferView & bv) const
 {
-       idx = 0;
-       pos = 0;
+       CursorSlice & cur = cursorTip(bv);
+       cur.idx() = 0;
+       cur.pos() = 0;
        return true;
 }
 
 
-bool MathHullInset::idxLast(idx_type & idx, pos_type & pos) const
+bool MathHullInset::idxLast(BufferView & bv) const
 {
-       idx = nargs() - 1;
-       pos = cell(idx).size();
+       CursorSlice & cur = cursorTip(bv);
+       cur.idx() = nargs() - 1;
+       cur.pos() = cur.lastpos();
        return true;
 }
 
@@ -694,9 +696,9 @@ void MathHullInset::check() const
 }
 
 
-void MathHullInset::doExtern
-       (FuncRequest const & func, idx_type & idx, pos_type & pos)
+void MathHullInset::doExtern(FuncRequest const & func, BufferView & bv)
 {
+       CursorSlice & cur = cursorTip(bv);
        string lang;
        string extra;
        istringstream iss(func.argument.c_str());
@@ -719,72 +721,75 @@ void MathHullInset::doExtern
        eq.push_back(MathAtom(new MathCharInset('=')));
 
        // go to first item in line
-       idx -= idx % ncols();
-       pos = 0;
+       cur.idx() -= cur.idx() % ncols();
+       cur.pos() = 0;
 
        if (getType() == "simple") {
-               size_type pos = cell(idx).find_last(eq);
+               size_type pos = cur.cell().find_last(eq);
                MathArray ar;
                if (mathcursor && mathcursor->selection()) {
                        asArray(mathcursor->grabAndEraseSelection(), ar);
-               } else if (pos == cell(idx).size()) {
-                       ar = cell(idx);
+               } else if (pos == cur.cell().size()) {
+                       ar = cur.cell();
                        lyxerr << "use whole cell: " << ar << endl;
                } else {
-                       ar = MathArray(cell(idx).begin() + pos + 1, cell(idx).end());
+                       ar = MathArray(cur.cell().begin() + pos + 1, cur.cell().end());
                        lyxerr << "use partial cell form pos: " << pos << endl;
                }
-               cell(idx).append(eq);
-               cell(idx).append(pipeThroughExtern(lang, extra, ar));
-               pos = cell(idx).size();
+               cur.cell().append(eq);
+               cur.cell().append(pipeThroughExtern(lang, extra, ar));
+               cur.pos() = cur.lastpos();
                return;
        }
 
        if (getType() == "equation") {
                lyxerr << "use equation inset" << endl;
                mutate("eqnarray");
-               MathArray & ar = cell(idx);
+               MathArray & ar = cur.cell();
                lyxerr << "use cell: " << ar << endl;
-               cell(idx + 1) = eq;
-               cell(idx + 2) = pipeThroughExtern(lang, extra, ar);
+               ++cur.idx();
+               cur.cell() = eq;
+               ++cur.idx();
+               cur.cell() = pipeThroughExtern(lang, extra, ar);
                // move to end of line
-               idx += 2;
-               pos = cell(idx).size();
+               cur.pos() = cur.lastpos();
                return;
        }
 
        {
                lyxerr << "use eqnarray" << endl;
-               idx -= idx % ncols();
-               idx += 2;
-               pos = 0;
-               MathArray ar = cell(idx);
+               cur.idx() += 2 - cur.idx() % ncols();
+               cur.pos() = 0;
+               MathArray ar = cur.cell();
                lyxerr << "use cell: " << ar << endl;
 #ifdef WITH_WARNINGS
 #warning temporarily disabled
 #endif
-               addRow(row(idx));
-               cell(idx + 2) = eq;
-               cell(idx + 3) = pipeThroughExtern(lang, extra, ar);
-               idx += 3;
-               pos = cell(idx).size();
+               addRow(cur.row());
+               ++cur.idx();
+               ++cur.idx();
+               cur.cell() = eq;
+               ++cur.idx();
+               cur.cell() = pipeThroughExtern(lang, extra, ar);
+               cur.pos() = cur.lastpos();
        }
 }
 
 
-DispatchResult MathHullInset::priv_dispatch
-       (FuncRequest const & cmd, idx_type & idx, pos_type & pos)
+DispatchResult
+MathHullInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
+       CursorSlice & cur = cursorTip(bv);
        switch (cmd.action) {
 
                case LFUN_BREAKLINE:
                        if (type_ == "simple" || type_ == "equation") {
                                mutate("eqnarray");
-                               idx = 1;
-                               pos = 0;
+                               cur.idx() = 1;
+                               cur.pos() = 0;
                                return DispatchResult(true, FINISHED);
                        }
-                       return MathGridInset::priv_dispatch(cmd, idx, pos);
+                       return MathGridInset::priv_dispatch(bv, cmd);
 
                case LFUN_MATH_NUMBER:
                        //lyxerr << "toggling all numbers" << endl;
@@ -802,7 +807,7 @@ DispatchResult MathHullInset::priv_dispatch
 
                case LFUN_MATH_NONUMBER:
                        if (display()) {
-                               row_type r = (type_ == "multline") ? nrows() - 1 : row(idx);
+                               row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
                                //recordUndo(bv, Undo::INSERT);
                                bool old = numbered(r);
                                //bv->owner()->message(old ? _("No number") : _("Number"));
@@ -811,7 +816,7 @@ DispatchResult MathHullInset::priv_dispatch
                        return DispatchResult(true, true);
 
                case LFUN_INSERT_LABEL: {
-                       row_type r = (type_ == "multline") ? nrows() - 1 : row(idx);
+                       row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
                        string old_label = label(r);
                        string new_label = cmd.argument;
 
@@ -836,31 +841,31 @@ DispatchResult MathHullInset::priv_dispatch
                }
 
                case LFUN_MATH_EXTERN:
-                       doExtern(cmd, idx, pos);
+                       doExtern(cmd, bv);
                        return DispatchResult(true, FINISHED);
 
                case LFUN_MATH_MUTATE: {
                        lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
-                       row_type r = row(idx);
-                       col_type c = col(idx);
+                       row_type r = cur.row();
+                       col_type c = cur.col();
                        mutate(cmd.argument);
-                       idx = r * ncols() + c;
-                       if (idx >= nargs())
-                               idx = nargs() - 1;
-                       if (pos > cell(idx).size())
-                               pos = cell(idx).size();
+                       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_MATH_DISPLAY: {
                        mutate(type_ == "simple" ? "equation" : "simple");
-                       idx = 0;
-                       pos = cell(idx).size();
+                       cur.idx() = 0;
+                       cur.pos() = cur.lastpos();
                        return DispatchResult(true, FINISHED);
                }
 
                default:
-                       return MathGridInset::priv_dispatch(cmd, idx, pos);
+                       return MathGridInset::priv_dispatch(bv, cmd);
        }
 }
 
index e568af0db6aaaee01f1bca5bbc4fc1faf7b33593..2c19c15b747b39a2ff166902125f7c155704a51a 100644 (file)
@@ -81,9 +81,9 @@ public:
        ///
        char defaultColAlign(col_type col);
        ///
-       bool idxFirst(idx_type &, pos_type &) const;
+       bool idxFirst(BufferView &) const;
        ///
-       bool idxLast(idx_type &, pos_type &) const;
+       bool idxLast(BufferView &) const;
 
        ///
        std::string fileInsetLabel() const;
@@ -100,7 +100,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
        ///
        std::string eolString(row_type row, bool fragile) const;
 
@@ -116,7 +116,7 @@ private:
        ///
        std::string nicelabel(row_type row) const;
        ///
-       void doExtern(FuncRequest const & func, idx_type & idx, pos_type & pos);
+       void doExtern(FuncRequest const & func, BufferView &);
        ///
        void glueall();
        ///
index ae0226a884c600cf4f69d6dccb59fca0c22b97cd..fd56951bbc118e50b6b87083a5770f9aad43c82e 100644 (file)
@@ -56,61 +56,61 @@ void MathInset::substitute(MathMacro const &)
 {}
 
 
-bool MathInset::idxNext(idx_type &, pos_type &) const
+bool MathInset::idxNext(BufferView &) const
 {
        return false;
 }
 
 
-bool MathInset::idxRight(idx_type &, pos_type &) const
+bool MathInset::idxRight(BufferView &) const
 {
        return false;
 }
 
 
-bool MathInset::idxPrev(idx_type &, pos_type &) const
+bool MathInset::idxPrev(BufferView &) const
 {
        return false;
 }
 
 
-bool MathInset::idxLeft(idx_type &, pos_type &) const
+bool MathInset::idxLeft(BufferView &) const
 {
        return false;
 }
 
 
-bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
+bool MathInset::idxUpDown(BufferView &, bool, int) const
 {
        return false;
 }
 
 
-bool MathInset::idxUpDown2(idx_type &, pos_type &, bool, int) const
+bool MathInset::idxUpDown2(BufferView &, bool, int) const
 {
        return false;
 }
 
 
-bool MathInset::idxFirst(idx_type &, pos_type &) const
+bool MathInset::idxFirst(BufferView &) const
 {
        return false;
 }
 
 
-bool MathInset::idxLast(idx_type &, pos_type &) const
+bool MathInset::idxLast(BufferView &) const
 {
        return false;
 }
 
 
-bool MathInset::idxHome(idx_type &, pos_type &) const
+bool MathInset::idxHome(BufferView &) const
 {
        return false;
 }
 
 
-bool MathInset::idxEnd(idx_type &, pos_type &) const
+bool MathInset::idxEnd(BufferView &) const
 {
        return false;
 }
index f3018235aaa2382e2de2d0df84de7d163a8f5eea..2503ca5228062e11c5e292367961c92f41750fb3 100644 (file)
@@ -13,6 +13,7 @@
 #ifndef MATH_INSET_H
 #define MATH_INSET_H
 
+#include "cursor_slice.h"
 #include "insets/insetbase.h"
 
 #include <string>
@@ -94,30 +95,28 @@ public:
        virtual void drawT(TextPainter &, int x, int y) const;
 
        /// Where should we go when we press the up or down cursor key?
-       virtual bool idxUpDown(idx_type & idx, pos_type & pos, bool up,
-               int targetx) const;
+       virtual bool idxUpDown(BufferView & bv, bool up, int targetx) const;
        /// Where should we go when we press the up or down cursor key?
-       virtual bool idxUpDown2(idx_type & idx, pos_type & pos, bool up,
-               int targetx) const;
+       virtual bool idxUpDown2(BufferView & bv, bool up, int targetx) const;
        /// The left key
-       virtual bool idxLeft(idx_type & idx, pos_type & pos) const;
+       virtual bool idxLeft(BufferView & bv) const;
        /// The right key
-       virtual bool idxRight(idx_type & idx, pos_type & pos) const;
+       virtual bool idxRight(BufferView & bv) const;
 
        /// Move one physical cell up
-       virtual bool idxNext(idx_type & idx, pos_type & pos) const;
+       virtual bool idxNext(BufferView & bv) const;
        /// Move one physical cell down
-       virtual bool idxPrev(idx_type & idx, pos_type & pos) const;
+       virtual bool idxPrev(BufferView & bv) const;
 
        /// Target pos when we enter the inset from the left by pressing "Right"
-       virtual bool idxFirst(idx_type & idx, pos_type & pos) const;
+       virtual bool idxFirst(BufferView & bv) const;
        /// Target pos when we enter the inset from the right by pressing "Left"
-       virtual bool idxLast(idx_type & idx, pos_type & pos) const;
+       virtual bool idxLast(BufferView & bv) const;
 
        /// Where should we go if we press home?
-       virtual bool idxHome(idx_type & idx, pos_type & pos) const;
+       virtual bool idxHome(BufferView & bv) const;
        /// Where should we go if we press end?
-       virtual bool idxEnd(idx_type & idx, pos_type & pos) const;
+       virtual bool idxEnd(BufferView & bv) const;
 
        /// Delete a cell and move cursor
        virtual bool idxDelete(idx_type &) { return false; }
index aaad86b832c2c7a52db88da4fbcf44ce63b429d6..30e32bc52a3ed67b86800c9842b1197f766e7a85 100644 (file)
@@ -155,30 +155,28 @@ void MathMacro::dump() const
 }
 
 
-bool MathMacro::idxUpDown(idx_type & idx, pos_type &, bool up, int x) const
+bool MathMacro::idxUpDown(BufferView & bv, bool up, int x) const
 {
-       pos_type pos;
+       CursorSlice & cur = cursorTip(bv);
        if (up) {
-               if (!MathNestInset::idxLeft(idx, pos))
+               if (!MathNestInset::idxLeft(bv))
                        return false;
-               pos = cell(idx).x2pos(x);
-               return true;
        } else {
-               if (!MathNestInset::idxRight(idx, pos))
+               if (!MathNestInset::idxRight(bv))
                        return false;
-               pos = cell(idx).x2pos(x);
-               return true;
        }
+       cur.pos() = cur.cell().x2pos(x);
+       return true;
 }
 
 
-bool MathMacro::idxLeft(idx_type &, pos_type &) const
+bool MathMacro::idxLeft(BufferView &) const
 {
        return false;
 }
 
 
-bool MathMacro::idxRight(idx_type &, pos_type &) const
+bool MathMacro::idxRight(BufferView &) const
 {
        return false;
 }
index 8912501b5e32711aa6c8a39ed61df1c0bce99460..6e95bc6a4fc5fc6dfbc2268d7af45b61f6494225 100644 (file)
@@ -38,11 +38,11 @@ public:
        void dump() const;
 
        ///
-       bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+       bool idxUpDown(BufferView &, bool up, int targetx) const;
        ///
-       bool idxLeft(idx_type & idx, pos_type & pos) const;
+       bool idxLeft(BufferView &) const;
        ///
-       bool idxRight(idx_type & idx, pos_type & pos) const;
+       bool idxRight(BufferView &) const;
 
        ///
        void validate(LaTeXFeatures &) const;
index a1a35f9652dee6bad5be6814940979871c646154..1caaee458e89ee1938515d1cc7ddeec58c985c83 100644 (file)
@@ -71,73 +71,78 @@ void MathNestInset::metrics(MetricsInfo const & mi) const
 }
 
 
-bool MathNestInset::idxNext(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxNext(BufferView & bv) const
 {
-       if (idx + 1 >= nargs())
+       CursorSlice & cur = cursorTip(bv);
+       if (cur.idx() + 1 >= nargs())
                return false;
-       ++idx;
-       pos = 0;
+       ++cur.idx();
+       cur.pos() = 0;
        return true;
 }
 
 
-bool MathNestInset::idxRight(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxRight(BufferView & bv) const
 {
-       return idxNext(idx, pos);
+       return idxNext(bv);
 }
 
 
-bool MathNestInset::idxPrev(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxPrev(BufferView & bv) const
 {
-       if (idx == 0)
+       CursorSlice & cur = cursorTip(bv);
+       if (cur.idx() == 0)
                return false;
-       --idx;
-       pos = cell(idx).size();
+       --cur.idx();
+       cur.pos() = cur.lastpos();
        return true;
 }
 
 
-bool MathNestInset::idxLeft(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxLeft(BufferView & bv) const
 {
-       return idxPrev(idx, pos);
+       return idxPrev(bv);
 }
 
 
-bool MathNestInset::idxFirst(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxFirst(BufferView & bv) const
 {
+       CursorSlice & cur = cursorTip(bv);
        if (nargs() == 0)
                return false;
-       idx = 0;
-       pos = 0;
+       cur.idx() = 0;
+       cur.pos() = 0;
        return true;
 }
 
 
-bool MathNestInset::idxLast(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxLast(BufferView & bv) const
 {
+       CursorSlice & cur = cursorTip(bv);
        if (nargs() == 0)
                return false;
-       idx = nargs() - 1;
-       pos = cell(idx).size();
+       cur.idx() = nargs() - 1;
+       cur.pos() = cur.lastpos();
        return true;
 }
 
 
-bool MathNestInset::idxHome(idx_type & /* idx */, pos_type & pos) const
+bool MathNestInset::idxHome(BufferView & bv) const
 {
-       if (pos == 0)
+       CursorSlice & cur = cursorTip(bv);
+       if (cur.pos() == 0)
                return false;
-       pos = 0;
+       cur.pos() = 0;
        return true;
 }
 
 
-bool MathNestInset::idxEnd(idx_type & idx, pos_type & pos) const
+bool MathNestInset::idxEnd(BufferView & bv) const
 {
-       pos_type n = cell(idx).size();
-       if (pos == n)
+       CursorSlice & cur = cursorTip(bv);
+       if (cur.lastpos() == cur.lastpos())
                return false;
-       pos = n;
+       cur.pos() = cur.lastpos();
        return true;
 }
 
@@ -276,33 +281,29 @@ void MathNestInset::notifyCursorLeaves(idx_type idx)
 
 
 DispatchResult
-MathNestInset::priv_dispatch(FuncRequest const & cmd,
-                            idx_type & idx, pos_type & pos)
+MathNestInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
-       BufferView * bv = cmd.view();
-
+       CursorSlice & cur = cursorTip(bv);
        switch (cmd.action) {
 
                case LFUN_PASTE: {
                        MathArray ar;
                        mathed_parse_cell(ar, cmd.argument);
-                       cell(idx).insert(pos, ar);
-                       pos += ar.size();
+                       cur.cell().insert(cur.pos(), ar);
+                       cur.pos() += ar.size();
                        return DispatchResult(true, true);
                }
 
                case LFUN_PASTESELECTION:
-                       return
-                               dispatch(
-                                       FuncRequest(bv, LFUN_PASTE, bv->getClipboard()), idx, pos);
+                       return dispatch(bv, FuncRequest(LFUN_PASTE, bv.getClipboard())); 
 
                case LFUN_MOUSE_PRESS:
                        if (cmd.button() == mouse_button::button2)
-                               return priv_dispatch(FuncRequest(bv, LFUN_PASTESELECTION), idx, pos);
+                               return priv_dispatch(bv, FuncRequest(LFUN_PASTESELECTION));
                        return DispatchResult(false);
 
                default:
-                       return MathInset::priv_dispatch(cmd, idx, pos);
+                       return MathInset::priv_dispatch(bv, cmd);
        }
 }
 
index 16bf5e7fe3cc5172896eec34c1c54837d6cce166..2227ac2ae49256ff080dfcd8839e81584e74e1e5 100644 (file)
@@ -43,24 +43,24 @@ public:
        void getScreenPos(idx_type idx, pos_type pos, int & x, int & y) const;
 
        /// order of movement through the cells when pressing the left key
-       bool idxLeft(idx_type & idx, pos_type & pos) const;
+       bool idxLeft(BufferView &) const;
        /// order of movement through the cells when pressing the right key
-       bool idxRight(idx_type & idx, pos_type & pos) const;
+       bool idxRight(BufferView &) const;
 
        /// move one physical cell up
-       bool idxNext(idx_type & idx, pos_type & pos) const;
+       bool idxNext(BufferView &) const;
        /// move one physical cell down
-       bool idxPrev(idx_type & idx, pos_type & pos) const;
+       bool idxPrev(BufferView &) const;
 
        /// target pos when we enter the inset from the left by pressing "Right"
-       bool idxFirst(idx_type & idx, pos_type & pos) const;
+       bool idxFirst(BufferView &) const;
        /// target pos when we enter the inset from the right by pressing "Left"
-       bool idxLast(idx_type & idx, pos_type & pos) const;
+       bool idxLast(BufferView &) const;
 
        /// where should we go if we press home?
-       bool idxHome(idx_type & idx, pos_type & pos) const;
+       bool idxHome(BufferView &) const;
        /// where should we go if we press end?
-       bool idxEnd(idx_type & idx, pos_type & pos) const;
+       bool idxEnd(BufferView &) const;
 
        /// number of cells currently governed by us
        idx_type nargs() const;
@@ -101,7 +101,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 
        /// we store the cells in a vector
        typedef std::vector<MathArray> cells_type;
index c38fc7fcf5749ac0e518c193227451739490f390..4053c543b38c816b6091c74ac48ddcbaae981b67 100644 (file)
@@ -47,18 +47,20 @@ void MathOversetInset::draw(PainterInfo & pi, int x, int y) const
 }
 
 
-bool MathOversetInset::idxFirst(idx_type & i, pos_type & pos) const
+bool MathOversetInset::idxFirst(BufferView & bv) const
 {
-       i = 1;
-       pos = 0;
+       CursorSlice & cur = cursorTip(bv);
+       cur.idx() = 1;
+       cur.pos() = 0;
        return true;
 }
 
 
-bool MathOversetInset::idxLast(idx_type & i, pos_type & pos) const
+bool MathOversetInset::idxLast(BufferView & bv) const
 {
-       i = 1;
-       pos = cell(i).size();
+       CursorSlice & cur = cursorTip(bv);
+       cur.idx() = 1;
+       cur.pos() = cur.lastpos();
        return true;
 }
 
index a0dea822b6a6d03505f671f1eac03d28d97c9b4e..72aa05e4fd3af289efe938423be48ac86d6e7174 100644 (file)
@@ -25,9 +25,9 @@ public:
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
-       bool idxFirst(idx_type & idx, pos_type & pos) const;
+       bool idxFirst(BufferView &) const;
        ///
-       bool idxLast(idx_type & idx, pos_type & pos) const;
+       bool idxLast(BufferView &) const;
 
        ///
        void write(WriteStream & os) const;
index 98c214552afb28f0f0bf2305552b75ce6b1cc01c..6d9513a5bbac0a076fe0cbeb7c1d91f701246c8f 100644 (file)
@@ -78,13 +78,14 @@ void MathRootInset::normalize(NormalStream & os) const
 }
 
 
-bool MathRootInset::idxUpDown(idx_type & idx, pos_type & pos, bool up, int) const
+bool MathRootInset::idxUpDown(BufferView & bv, bool up, int) const
 {
+       CursorSlice & cur = cursorTip(bv);
        bool target = !up; // up ? 0 : 1;
-       if (idx == target)
+       if (cur.idx() == target)
                return false;
-       idx = target;
-       pos = target ? 0 : cell(0).size();
+       cur.idx() = target;
+       cur.pos() = up ? cur.lastpos() : 0;
        return true;
 }
 
index 366c77d43ddb74b8176531da14d314c21fdb232c..e90ae842b0e144d8c542a86db2e14cfb29e57fa9 100644 (file)
@@ -24,7 +24,7 @@ public:
        ///
        virtual std::auto_ptr<InsetBase> clone() const;
        ///
-       bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+       bool idxUpDown(BufferView &, bool up, int targetx) const;
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
index 1118070fe76bf63b34a64b20214b594673d123a0..5b6c4a2e7f72f478006edcf370cf0112c33866b8 100644 (file)
@@ -72,18 +72,20 @@ MathScriptInset * MathScriptInset::asScriptInset()
 }
 
 
-bool MathScriptInset::idxFirst(idx_type & idx, pos_type & pos) const
+bool MathScriptInset::idxFirst(BufferView & bv) const
 {
-       idx = 2;
-       pos = 0;
+       CursorSlice & cur = cursorTip(bv);
+       cur.idx() = 2;
+       cur.pos() = 0;
        return true;
 }
 
 
-bool MathScriptInset::idxLast(idx_type & idx, pos_type & pos) const
+bool MathScriptInset::idxLast(BufferView & bv) const
 {
-       idx = 2;
-       pos = nuc().size();
+       CursorSlice & cur = cursorTip(bv);
+       cur.idx() = 2;
+       cur.pos() = nuc().size();
        return true;
 }
 
@@ -313,36 +315,36 @@ bool MathScriptInset::hasDown() const
 }
 
 
-bool MathScriptInset::idxRight(idx_type &, pos_type &) const
+bool MathScriptInset::idxRight(BufferView &) const
 {
        return false;
 }
 
 
-bool MathScriptInset::idxLeft(idx_type &, pos_type &) const
+bool MathScriptInset::idxLeft(BufferView &) const
 {
        return false;
 }
 
 
-bool MathScriptInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
-       int) const
+bool MathScriptInset::idxUpDown(BufferView & bv, bool up, int) const
 {
-       if (idx == 1) {
+       CursorSlice & cur = cursorTip(bv);
+       if (cur.idx() == 1) {
                // if we are 'up' we can't go further up
                if (up)
                        return false;
                // otherwise go to last base position
-               idx = 2;
-               pos = cell(2).size();
+               cur.idx() = 2;
+               cur.pos() = cur.lastpos();
        }
 
-       else if (idx == 0) {
+       else if (cur.idx() == 0) {
                // if we are 'down' we can't go further down
                if (!up)
                        return false;
-               idx = 2;
-               pos = cell(2).size();
+               cur.idx() = 2;
+               cur.pos() = cur.lastpos();
        }
 
        else {
@@ -352,9 +354,9 @@ bool MathScriptInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
                        return false;
                // go up/down only if in the last position
                // or in the first position of something with displayed limits
-               if (pos == cell(2).size() || (pos == 0 && hasLimits())) {
-                       idx = up;
-                       pos = 0;
+               if (cur.pos() == cur.lastpos() || (cur.pos() == 0 && hasLimits())) {
+                       cur.idx() = up;
+                       cur.pos() = 0;
                        return true;
                }
                return false;
@@ -513,8 +515,7 @@ void MathScriptInset::notifyCursorLeaves(idx_type idx)
 
 
 DispatchResult
-MathScriptInset::priv_dispatch(FuncRequest const & cmd,
-                         idx_type & idx, pos_type & pos)
+MathScriptInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        if (cmd.action == LFUN_MATH_LIMITS) {
                if (!cmd.argument.empty()) {
@@ -531,5 +532,5 @@ MathScriptInset::priv_dispatch(FuncRequest const & cmd,
                return DispatchResult(true, true);
        }
 
-       return MathNestInset::priv_dispatch(cmd, idx, pos);
+       return MathNestInset::priv_dispatch(bv, cmd);
 }
index 5253d0f66025c86f3d54f8fddd276777884362af..32d0b5479c3572e8c07a0e1d186cfa136c51810e 100644 (file)
@@ -48,15 +48,15 @@ public:
        /// write content as something readable by Octave
        void octave(OctaveStream &) const;
        /// move cursor left
-       bool idxLeft(idx_type &, pos_type &) const;
+       bool idxLeft(BufferView &) const;
        /// move cursor right
-       bool idxRight(idx_type &, pos_type &) const;
+       bool idxRight(BufferView &) const;
        /// move cursor up or down
-       bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+       bool idxUpDown(BufferView &, bool up, int targetx) const;
        /// Target pos when we enter the inset from the left by pressing "Right"
-       bool idxFirst(idx_type & idx, pos_type & pos) const;
+       bool idxFirst(BufferView &) const;
        /// Target pos when we enter the inset from the right by pressing "Left"
-       bool idxLast(idx_type & idx, pos_type & pos) const;
+       bool idxLast(BufferView &) const;
        /// can we enter this cell?
        bool validCell(idx_type i) const { return i == 2 || script_[i]; }
 
@@ -99,7 +99,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 private:
        /// returns x offset for main part
        int dxx() const;
index 9000c3cb7d854ddb0228b8f5eca1b7e4e0b547e6..afd9a9a288f9c8aae601700ab1ceb348622e0c01 100644 (file)
@@ -49,7 +49,8 @@ void MathTextInset::getScreenPos(idx_type /*idx*/, pos_type pos, int & x, int &
 }
 
 
-bool MathTextInset::idxUpDown2(idx_type &, pos_type & pos, bool up,
+#if 0
+bool MathTextInset::idxUpDown2(BufferView & pos, bool up,
        int /*targetx*/) const
 {
        // try to move only one screen row up or down if possible
@@ -70,6 +71,7 @@ bool MathTextInset::idxUpDown2(idx_type &, pos_type & pos, bool up,
        pos = cell2.begin_ + cache_.cell(i).x2pos(x, cell2.glue_);
        return true;
 }
+#endif
 
 
 void MathTextInset::metrics(MetricsInfo & mi, Dimension & dim) const
index 5bc34dc3f56522d4a0ec9ca7cfe453b42ede3c88..97d5170598813ace5af88f8c7131325c48d5d44f 100644 (file)
@@ -33,7 +33,7 @@ public:
        void drawSelection(PainterInfo & pi,
                idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
        /// moves cursor up or down
-       bool idxUpDown2(idx_type &, pos_type & pos, bool up, int targetx) const;
+       //bool idxUpDown2(BufferView & pos, bool up, int targetx) const;
 protected:
        /// row corresponding to given position
        idx_type pos2row(pos_type pos) const;
index 8162266a1792bbace92936be30c37b67ef4dda1a..4dce259f58f7cfe5dca61e01f7830efe1ab09b5d 100644 (file)
@@ -47,30 +47,32 @@ void MathUndersetInset::draw(PainterInfo & pi, int x, int y) const
 }
 
 
-bool MathUndersetInset::idxFirst(idx_type & i, pos_type & pos) const
+bool MathUndersetInset::idxFirst(BufferView & bv) const
 {
-       i = 1;
-       pos = 0;
+       CursorSlice & cur = cursorTip(bv);
+       cur.idx() = 1;
+       cur.pos() = 0;
        return true;
 }
 
 
-bool MathUndersetInset::idxLast(idx_type & i, pos_type & pos) const
+bool MathUndersetInset::idxLast(BufferView & bv) const
 {
-       i = 1;
-       pos = cell(i).size();
+       CursorSlice & cur = cursorTip(bv);
+       cur.idx() = 1;
+       cur.pos() = cur.lastpos();
        return true;
 }
 
 
-bool MathUndersetInset::idxUpDown(idx_type & idx, pos_type & pos, bool up,
-       int targetx) const
+bool MathUndersetInset::idxUpDown(BufferView & bv, bool up, int targetx) const
 {
+       CursorSlice & cur = cursorTip(bv);
        idx_type target = up; // up ? 1 : 0, since upper cell has idx 1
-       if (idx == target)
+       if (cur.idx() == target)
                return false;
-       idx = target;
-       pos = cell(idx).x2pos(targetx);
+       cur.idx() = target;
+       cur.pos() = cur.cell().x2pos(targetx);
        return true;
 }
 
index 7886a2842320a6307682c9c98ec7b8198b0916f1..064235552941c116b3231ff86c8dd318feea8d8a 100644 (file)
@@ -25,11 +25,11 @@ public:
        ///
        void draw(PainterInfo & pi, int x, int y) const;
        ///
-       bool idxFirst(idx_type & idx, pos_type & pos) const;
+       bool idxFirst(BufferView &) const;
        ///
-       bool idxLast(idx_type & idx, pos_type & pos) const;
+       bool idxLast(BufferView &) const;
        ///
-       bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
+       bool idxUpDown(BufferView &, bool up, int targetx) const;
        ///
        void write(WriteStream & os) const;
        ///
index 2e749924bb3a2e854d5c54a8fed146620bcaf913..23ec4e5b1b8529872710638943026f00b73630d8 100644 (file)
@@ -54,8 +54,7 @@ void RefInset::infoize(std::ostream & os) const
 
 
 DispatchResult
-RefInset::priv_dispatch(FuncRequest const & cmd,
-                       idx_type & idx, pos_type & pos)
+RefInset::priv_dispatch(BufferView & bv, FuncRequest const & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY:
@@ -72,15 +71,14 @@ RefInset::priv_dispatch(FuncRequest const & cmd,
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button3) {
                        lyxerr << "trying to goto ref" << cell(0) << endl;
-                       cmd.view()->dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
+                       bv.dispatch(FuncRequest(LFUN_REF_GOTO, asString(cell(0))));
                        return DispatchResult(true, true);
                }
                if (cmd.button() == mouse_button::button1) {
                        // Eventually trigger dialog with button 3
                        // not 1
                        string const data = createDialogStr("ref");
-                       cmd.view()->owner()->getDialogs().
-                               show("ref", data, this);
+                       bv.owner()->getDialogs().show("ref", data, this);
                        return DispatchResult(true, true);
                }
                break;
@@ -89,7 +87,7 @@ RefInset::priv_dispatch(FuncRequest const & cmd,
                // eat other mouse commands
                return DispatchResult(true, true);
        default:
-               return CommandInset::priv_dispatch(cmd, idx, pos);
+               return CommandInset::priv_dispatch(bv, cmd);
        }
        // not our business
        return DispatchResult(false);
index d5de1403dda6178dc09e3c22998faa48325f1293..a65f9be9e28458ae6b3943c5fa3ec77902366af0 100644 (file)
@@ -62,7 +62,7 @@ protected:
        ///
        virtual
        DispatchResult
-       priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
+       priv_dispatch(BufferView & bv, FuncRequest const & cmd);
 };
 
 #endif
index 7c34e2c4c9ca9e60910e31af5bff7c2baa795103..522f1b53de044a4f4c956adf9c0492c3b84f03b9 100644 (file)
@@ -409,14 +409,13 @@ void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
 }
 
 
-void doInsertInset(FuncRequest const & cmd, bool edit, bool pastesel)
+void doInsertInset(BufferView * bv, FuncRequest const & cmd,
+       bool edit, bool pastesel)
 {
-       InsetOld * inset = createInset(cmd);
+       InsetOld * inset = createInset(bv, cmd);
        if (!inset)
                return;
 
-       BufferView * bv = cmd.view();
-
        bool gotsel = false;
        if (bv->selection().set()) {
                bv->owner()->dispatch(FuncRequest(LFUN_CUT));
@@ -448,11 +447,11 @@ bool LyXText::rtl() const
 }
 
 
-DispatchResult LyXText::dispatch(FuncRequest const & cmd)
+DispatchResult LyXText::dispatch(BufferView & view, FuncRequest const & cmd)
 {
        //lyxerr[Debug::ACTION] << "LyXText::dispatch: cmd: " << cmd << endl;
 
-       BufferView * bv = cmd.view();
+       BufferView * bv = &view;
 
        switch (cmd.action) {
 
@@ -858,17 +857,17 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
                string const name = cmd.getArg(0);
                InsetBase * inset = bv->owner()->getDialogs().getOpenInset(name);
                if (inset) {
-                       FuncRequest fr(bv, LFUN_INSET_MODIFY, cmd.argument);
-                       inset->dispatch(fr);
+                       FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument);
+                       inset->dispatch(*bv, fr);
                } else {
-                       FuncRequest fr(bv, LFUN_INSET_INSERT, cmd.argument);
-                       dispatch(fr);
+                       FuncRequest fr(LFUN_INSET_INSERT, cmd.argument);
+                       dispatch(*bv, fr);
                }
                break;
        }
 
        case LFUN_INSET_INSERT: {
-               InsetOld * inset = createInset(cmd);
+               InsetOld * inset = createInset(bv, cmd);
                if (inset && !bv->insertInset(inset))
                        delete inset;
                break;
@@ -890,7 +889,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
                if (cursorPar()->layout()->free_spacing)
                        insertChar(' ');
                else
-                       doInsertInset(cmd, false, false);
+                       doInsertInset(bv, cmd, false, false);
                moveCursor(bv, false);
                break;
 
@@ -1358,12 +1357,12 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_ENVIRONMENT_INSERT:
                // Open the inset, and move the current selection
                // inside it.
-               doInsertInset(cmd, true, true);
+               doInsertInset(bv, cmd, true, true);
                break;
 
        case LFUN_INDEX_INSERT:
                // Just open the inset
-               doInsertInset(cmd, true, false);
+               doInsertInset(bv, cmd, true, false);
                break;
 
        case LFUN_INDEX_PRINT:
@@ -1372,7 +1371,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_INSERT_LINE:
        case LFUN_INSERT_PAGEBREAK:
                // do nothing fancy
-               doInsertInset(cmd, false, false);
+               doInsertInset(bv, cmd, false, false);
                break;
 
        case LFUN_DEPTH_MIN:
@@ -1398,7 +1397,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
        case LFUN_MATH_NUMBER:
        case LFUN_MATH_EXTERN:
        case LFUN_MATH_SIZE:
-               mathDispatch(cmd);
+               mathDispatch(*bv, cmd);
                break;
 
        case LFUN_EMPH:
index 410ec3bc355b6ca8492b882664b6970a024d5e81..2d47d2f51a3e541454db162a2627ae9b1092b6ba 100644 (file)
@@ -293,5 +293,11 @@ void recordUndo(Undo::undo_kind kind, LyXText const * text, paroffset_type par)
 
 void recordUndo(BufferView * bv, Undo::undo_kind kind)
 {
-       recordUndo(kind, bv->text(), bv->text()->cursor().par());
+       recordUndo(*bv, kind);
+}
+
+
+void recordUndo(BufferView & bv, Undo::undo_kind kind)
+{
+       recordUndo(kind, bv.text(), bv.text()->cursor().par());
 }
index edf8f5562e86bf93111e33fc00ea0aac55509b8d..a45e97bff56493e78e23b73a3ab3903e14467a31 100644 (file)
@@ -110,6 +110,7 @@ void recordUndo(Undo::undo_kind kind,
 
 /// convienience: prepare undo for the paragraph that contains the cursor
 void recordUndo(BufferView *, Undo::undo_kind kind);
+void recordUndo(BufferView &, Undo::undo_kind kind);
 
 /// are we avoiding tracking undos currently?
 extern bool undo_frozen;