]> git.lyx.org Git - features.git/commitdiff
move handling of LFUN_APPENDIX to LyXText
authorAndré Pönitz <poenitz@gmx.net>
Mon, 19 Aug 2002 15:39:25 +0000 (15:39 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 19 Aug 2002 15:39:25 +0000 (15:39 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5025 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/lyxtext.h
src/text.C
src/text2.C

index 02e44f21b3e010576315671f81ae93def63d996c..0c2ad4684176862b14ff311052ffb47d75f15825 100644 (file)
@@ -143,16 +143,17 @@ boost::signals::connection lostcon;
 } // anon namespace
 
 
-BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
+BufferView::Pimpl::Pimpl(BufferView * bv, LyXView * owner,
             int xpos, int ypos, int width, int height)
-       : bv_(b), owner_(o), buffer_(0), cursor_timeout(400),
+       : bv_(bv), owner_(owner), buffer_(0), cursor_timeout(400),
          using_xterm_cursor(false)
 {
        workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height));
        screen_.reset(LyXScreenFactory::create(workarea()));
 
        // Setup the signals
-       doccon = workarea().scrollDocView.connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
+       doccon = workarea().scrollDocView
+               .connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
        resizecon = workarea().workAreaResize
                .connect(boost::bind(&BufferView::Pimpl::workAreaResize, this));
        bpresscon = workarea().workAreaButtonPress
@@ -172,7 +173,8 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
        lostcon = workarea().selectionLost
                .connect(boost::bind(&BufferView::Pimpl::selectionLost, this));
 
-       timecon = cursor_timeout.timeout.connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
+       timecon = cursor_timeout.timeout
+               .connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
        cursor_timeout.start();
        saved_positions.resize(saved_positions_num);
 }
@@ -214,12 +216,12 @@ void BufferView::Pimpl::buffer(Buffer * b)
                bv_->text = 0;
        }
 
-       // Set current buffer
+       // set current buffer
        buffer_ = b;
 
        if (bufferlist.getState() == BufferList::CLOSING) return;
 
-       // If we are closing the buffer, use the first buffer as current
+       // if we are closing the buffer, use the first buffer as current
        if (!buffer_) {
                buffer_ = bufferlist.first();
        }
@@ -234,7 +236,8 @@ void BufferView::Pimpl::buffer(Buffer * b)
                }
 
                // FIXME: needed when ?
-               bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
+               bv_->text->first_y =
+                       screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
 
                // Similarly, buffer-dependent dialogs should be updated or
                // hidden. This should go here because some dialogs (eg ToC)
@@ -1499,19 +1502,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
        LyXTextClass const & tclass = buffer_->params.getLyXTextClass();
 
        switch (ev.action) {
-               // --- Misc -------------------------------------------
-       case LFUN_APPENDIX:
-       {
-               if (available()) {
-                       LyXText * lt = bv_->getLyXText();
-                       lt->toggleAppendix(bv_);
-                       update(lt,
-                              BufferView::SELECT
-                              | BufferView::FITCUR
-                              | BufferView::CHANGE);
-               }
-       }
-       break;
 
        case LFUN_TOC_INSERT:
        {
@@ -1524,7 +1514,7 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
        }
 
        case LFUN_SCROLL_INSET:
-               // this is not handled here as this funktion is only aktive
+               // this is not handled here as this function is only active
                // if we have a locking_inset and that one is (or contains)
                // a tabular-inset
                break;
@@ -3162,7 +3152,9 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
                break;
 
        default:
-               return false;
+               FuncRequest cmd = ev;
+               cmd.setView(bv_);
+               return bv_->getLyXText()->dispatch(cmd);
        } // end of switch
 
        return true;
index 2b3820c394026eff480297f340b8b2d2ccfc0570..0e86b7cb0bdab2397805963403ae0787d8f738fb 100644 (file)
@@ -1,3 +1,11 @@
+
+2002-08-19  André Pönitz <poenitz@gmx.net>
+
+       * lyxtext.h:
+       * text.C: new LyXText::dispatch()
+
+       * BufferView_pimpl.C: move handling of LFUN_APPENDIX to LyXText
+
 2002-08-18  Dekel Tsur  <dekelts@tau.ac.il>
 
        * text.C (paintRowSelection): Fix code for rows with both RTL & LTR text.
index ba127439e73537c1636442aea0f00ffff516ffb5..96de949c3d2b38ce657b04d16db4ea5b9d4ec630 100644 (file)
@@ -131,8 +131,7 @@ public:
          paragraphs */
        void decDepth(BufferView *);
 
-       /** Get the depth at current cursor position
-        */
+       /// get the depth at current cursor position
        int getDepth() const;
 
        /** set font over selection and make a total rebreak of those
@@ -170,7 +169,7 @@ public:
        ///
        void insertInset(BufferView *, Inset * inset);
 
-       /** Completes the insertion with a full rebreak. */
+       /// Completes the insertion with a full rebreak
        void fullRebreak(BufferView *);
 
        ///
@@ -191,6 +190,9 @@ public:
        ///
        void status(BufferView *, text_status) const;
 
+       ///
+       Inset::RESULT dispatch(FuncRequest const & cmd);
+
 private:
        /** wether the screen needs a refresh,
           starting with refresh_y
@@ -444,8 +446,6 @@ public:
        ///
        void checkParagraph(BufferView *, Paragraph * par, lyx::pos_type pos);
        ///
-       void toggleAppendix(BufferView *);
-       ///
        int workWidth(BufferView *) const;
        ///
        int workWidth(BufferView *, Inset * inset) const;
@@ -622,6 +622,8 @@ public:
 private:
        ///
        void setCounter(Buffer const *, Paragraph * par) const;
+       ///
+       Inset::RESULT lfunAppendix(FuncRequest const & cmd);
 
        /*
         * some low level functions
index e29788c31c87e849cc4f5dd6e84366ad8fa2f2ef..4568a031077b7ee7aca15d6bb7b6bddbe1de749f 100644 (file)
@@ -29,6 +29,7 @@
 #include "ParagraphParameters.h"
 #include "undo_funcs.h"
 #include "WordLangTuple.h"
+#include "funcrequest.h"
 
 #include "insets/insetbib.h"
 #include "insets/insettext.h"
@@ -3947,3 +3948,49 @@ int LyXText::getDepth() const
 {
        return cursor.par()->getDepth();
 }
+
+
+Inset::RESULT LyXText::lfunAppendix(FuncRequest const & cmd)
+{
+       BufferView * bv = cmd.view();
+       // what is this good for?
+       if (!bv->available())
+               return Inset::UNDISPATCHED;
+
+       Paragraph * par = cursor.par();
+       bool start = !par->params().startOfAppendix();
+
+       // ensure that we have only one start_of_appendix in this document
+       Paragraph * tmp = ownerParagraph();
+       for (; tmp; tmp = tmp->next()) {
+               tmp->params().startOfAppendix(false);
+       }
+
+       par->params().startOfAppendix(start);
+
+       // we can set the refreshing parameters now
+       status(cmd.view(), LyXText::NEED_MORE_REFRESH);
+       refresh_y = 0;
+       refresh_row = 0; // not needed for full update
+       updateCounters(cmd.view());
+       setCursor(cmd.view(), cursor.par(), cursor.pos());
+       bv->update(this,
+                                BufferView::SELECT
+                                | BufferView::FITCUR
+                                | BufferView::CHANGE);
+       return Inset::DISPATCHED;
+}
+
+
+Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
+{
+       switch (cmd.action) {
+               case LFUN_APPENDIX:
+                       return lfunAppendix(cmd);
+
+               default:
+                       return Inset::UNDISPATCHED;
+       }
+       // shut up compiler
+       return Inset::UNDISPATCHED;
+}
index e8aafd77449bfd109de20212467aeeb1d6c51196..afd3351592f05201454b1ae4d038d09c060a41b3 100644 (file)
@@ -2370,28 +2370,6 @@ bool LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
 }
 
 
-void LyXText::toggleAppendix(BufferView * bview)
-{
-       Paragraph * par = cursor.par();
-       bool start = !par->params().startOfAppendix();
-
-       // ensure that we have only one start_of_appendix in this document
-       Paragraph * tmp = ownerParagraph();
-       for (; tmp; tmp = tmp->next()) {
-               tmp->params().startOfAppendix(false);
-       }
-
-       par->params().startOfAppendix(start);
-
-       // we can set the refreshing parameters now
-       status(bview, LyXText::NEED_MORE_REFRESH);
-       refresh_y = 0;
-       refresh_row = 0; // not needed for full update
-       updateCounters(bview);
-       setCursor(bview, cursor.par(), cursor.pos());
-}
-
-
 Paragraph * LyXText::ownerParagraph() const
 {
        if (inset_owner) {