]> git.lyx.org Git - lyx.git/commitdiff
Alfredo's patch.
authorAndré Pönitz <poenitz@gmx.net>
Mon, 10 Nov 2003 18:15:55 +0000 (18:15 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 10 Nov 2003 18:15:55 +0000 (18:15 +0000)
Enough for today...

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

src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/bufferview_funcs.h
src/lyxtext.h
src/paragraph_funcs.C
src/paragraph_funcs.h
src/text2.C
src/text3.C

index 8fd5b93286c68ff256e48086a261fd514c152060..c99eb53632b379644fbc2c83778611cb578d223f 100644 (file)
@@ -605,8 +605,11 @@ void BufferView::Pimpl::update()
                bv_->getLyXText()->redoCursor();
 
                // update all 'visible' paragraphs
-               ParagraphList::iterator beg, end;
-               getVisiblePars(beg, end);
+               ParagraphList::iterator beg;
+               ParagraphList::iterator end;
+               getParsInRange(buffer_->paragraphs(),
+                              top_y(), top_y() + workarea().workHeight(),
+                              beg, end);
                bv_->text->redoParagraphs(beg, end);
 
                updateScrollbar();
@@ -968,7 +971,8 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
                        lyxerr << "cursor is: " << bv_->cursor() << endl;
                        lyxerr << "dispatching " << cmd1 << " to surrounding LyXText "
                                << bv_->cursor().innerText() << endl;
-                       bv_->cursor().innerText()->dispatch(cmd1);
+                       theTempCursor.innerText()->dispatch(cmd1);
+                       cursor_ = theTempCursor;
                        //return DispatchResult(true, true);
                }
 
@@ -979,7 +983,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
                // FIXME: we should skip these when selecting
                owner_->updateLayoutChoice();
                owner_->updateToolbar();
-               fitCursor();
+//             fitCursor();
 
                // slight hack: this is only called currently when we
                // clicked somewhere, so we force through the display
@@ -1341,20 +1345,3 @@ void BufferView::Pimpl::updateParagraphDialog()
 }
 
 
-void BufferView::Pimpl::getVisiblePars
-       (ParagraphList::iterator & beg, ParagraphList::iterator & end)
-{
-       beg = bv_->text->cursorPar();
-       end = beg;
-
-       for ( ; beg != bv_->text->ownerParagraphs().begin(); --beg)
-               if (beg->y - top_y() < 0)
-                       break;
-
-       if (beg != bv_->text->ownerParagraphs().begin())
-               --beg;
-
-       for ( ; end != bv_->text->ownerParagraphs().end(); ++end)
-               if (end->y - top_y() > workarea().workHeight())
-                       break;
-}
index a7f06bce88f4bd1589159cb6d723ef068679d05c..776888c2d9f3e36637f42c3059ffb5cd8f8815d8 100644 (file)
@@ -193,8 +193,6 @@ private:
        void MenuInsertLyXFile(std::string const & filen);
        /// our workarea
        WorkArea & workarea() const;
-       /// range of visible main text paragraphs
-       void getVisiblePars(ParagraphList::iterator &, ParagraphList::iterator &);
 
        ///
        LCursor cursor_;
index 491dde8781d6a4aed51a1d5bef325646beb5ea98..6504f4fc90bc77ecadfb0b00685b249ffdef397f 100644 (file)
@@ -61,7 +61,6 @@ std::string const currentState(BufferView *);
 void replaceSelection(LyXText * lt);
 
 
-
 }; // namespace bv_funcs
 
 #endif
index a8602403596e48aa4168840f3e9d2e1011011de1..af7f6bcfb576c904ccef376a8871dcea555113bd 100644 (file)
@@ -343,9 +343,8 @@ public:
        void updateCounters();
        /**
         * Returns an inset if inset was hit, or 0 if not.
-        * If hit, the coordinates are changed relative to the inset.
         */
-       InsetOld * checkInsetHit(int & x, int & y);
+       InsetOld * checkInsetHit(int x, int y);
 
        ///
        int singleWidth(ParagraphList::iterator pit, lyx::pos_type pos) const;
index ec55e8bea656246813e1c992b0b850f5d804cae7..884b6933dc8af4af2c919ea8c8111d84904ab811 100644 (file)
@@ -610,3 +610,24 @@ Paragraph const & ownerPar(Buffer const & buf, InsetOld const * inset)
        BOOST_ASSERT(false);
        return buf.paragraphs().front(); // shut up compiler
 }
+
+
+
+
+void getParsInRange(ParagraphList & pl,
+                   int ystart, int yend,
+                   ParagraphList::iterator & beg,
+                   ParagraphList::iterator & end)
+{
+       ParagraphList::iterator const endpar = pl.end();
+       ParagraphList::iterator const begpar = pl.begin();
+
+       BOOST_ASSERT(begpar != endpar);
+
+       beg = endpar;
+       for (--beg; beg != begpar && beg->y > ystart; --beg)
+               ;
+
+       for (end = beg ; end != endpar && end->y < yend; ++end)
+               ;
+}
index dc282599e1411f6229a264113273c5a0ac32da9d..22be6f6668179bd670592c4bcdd398d535c58b55 100644 (file)
@@ -75,5 +75,12 @@ ParagraphList::iterator outerPar(Buffer const & buf, InsetOld const * inset);
 /// find owning paragraph containing an inset
 Paragraph const & ownerPar(Buffer const & buf, InsetOld const * inset);
 
+/// stretch range beg,end to the minimum containing ystart, yend
+void getParsInRange(ParagraphList & pl,
+                   int ystart, int yend,
+                   ParagraphList::iterator & beg,
+                   ParagraphList::iterator & end);
+
+
 
 #endif // PARAGRAPH_FUNCS_H
index fe8c5ddd9dc059f5fcba26165af59832cbd2882d..725bca209c530d2186845b8f419f25fa906f9be0 100644 (file)
@@ -1624,11 +1624,10 @@ void LyXText::cursorUp(bool selecting)
        if (!selecting) {
                int topy = bv()->top_y();
                int y1 = cursor.y() - topy;
-               int y2 = y1;
                y -= topy;
                InsetOld * inset_hit = checkInsetHit(x, y1);
                if (inset_hit && isHighlyEditableInset(inset_hit))
-                       inset_hit->edit(bv(), x, y - (y2 - y1));
+                       inset_hit->edit(bv(), x, y);
        }
 #else
        lyxerr << "cursorUp: y " << cursor.y() << " bl: " <<
@@ -1650,11 +1649,10 @@ void LyXText::cursorDown(bool selecting)
        if (!selecting) {
                int topy = bv()->top_y();
                int y1 = cursor.y() - topy;
-               int y2 = y1;
                y -= topy;
                InsetOld * inset_hit = checkInsetHit(x, y1);
                if (inset_hit && isHighlyEditableInset(inset_hit))
-                       inset_hit->edit(bv(), x, y - (y2 - y1));
+                       inset_hit->edit(bv(), x, y);
        }
 #else
        setCursorFromCoordinates(bv()->x_target(),
index 09eecd3e14d3559da66c3c12ce7f8fc0f0a6764f..a82a92dda507d41942f8e2595c59a74af9c5a6fa 100644 (file)
@@ -31,6 +31,7 @@
 #include "lyxrc.h"
 #include "lyxrow.h"
 #include "paragraph.h"
+#include "paragraph_funcs.h"
 #include "ParagraphParameters.h"
 #include "text_funcs.h"
 #include "undo.h"
@@ -256,11 +257,15 @@ string const freefont2string()
 
 
 
-InsetOld * LyXText::checkInsetHit(int & x, int & y)
+InsetOld * LyXText::checkInsetHit(int x, int y)
 {
-       ParagraphList::iterator pit = ownerParagraphs().begin();
-       ParagraphList::iterator end = ownerParagraphs().end();
+       ParagraphList::iterator pit;
+       ParagraphList::iterator end;
 
+       getParsInRange(ownerParagraphs(),
+                      bv()->top_y(), bv()->top_y() + bv()->workHeight(),
+                      pit, end);
+       
        lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
        for ( ; pit != end; ++pit) {
                InsetList::iterator iit = pit->insetlist.begin();
@@ -279,7 +284,6 @@ InsetOld * LyXText::checkInsetHit(int & x, int & y)
                            && y <= inset->y() + inset->descent())
                        {
                                lyxerr << "Hit inset: " << inset << endl;
-                               y += bv()->top_y();
                                return inset;
                        }
                }