]> git.lyx.org Git - lyx.git/commitdiff
* cursor.[Ch]: remove direct access to anchor
authorAndré Pönitz <poenitz@gmx.net>
Mon, 2 Feb 2004 16:38:13 +0000 (16:38 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 2 Feb 2004 16:38:13 +0000 (16:38 +0000)
* text.C: remove findText() hack

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

src/BufferView_pimpl.C
src/ChangeLog
src/cursor.C
src/cursor.h
src/lyxtext.h
src/rowpainter.C
src/text.C
src/text2.C
src/text3.C

index a71644d47b129c51d47cf776f725259d05b54727..8b8b00989645cdc241dfaef419a36e9c76ed4c6b 100644 (file)
@@ -328,9 +328,6 @@ void BufferView::Pimpl::buffer(Buffer * b)
                if (bv_->text() == 0)
                        resizeCurrentBuffer();
 
-               // FIXME: needed when ?
-               fitCursor();
-
                // Buffer-dependent dialogs should be updated or
                // hidden. This should go here because some dialogs (eg ToC)
                // require bv_->text.
@@ -905,7 +902,7 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
                if (inset) {
                        res = inset->dispatch(cur, cmd);
                } else {
-                       res = cur.innerText()->dispatch(cur, cmd);
+                       res = bv_->text()->dispatch(cur, cmd);
                }
 
                if (bv_->fitCursor() || res.update()) {
index 83653aae7b9727d4308d77c877fb6bc303908c76..c1f42914d69aa1914ec7a442043f7d970350b6b7 100644 (file)
@@ -1,4 +1,10 @@
 
+2004-02-02  André Pönitz  <poenitz@gmx.net>
+
+       * cursor.[Ch]: remove direct access to anchor
+
+       * text.C: remove findText() hack
+
 2004-02-02  Alfredo Braunstein  <abraunst@lyx.org>
 
        * iterators.[Ch] (lockPath): remove in favour of...
index 7c43f3092f394bd9bff6c9447fd4c3052446e6a3..955d3084242cac94ae577e926f897e931de49198 100644 (file)
@@ -474,6 +474,12 @@ void LCursor::clearTargetX()
 }
 
 
+LyXText * LCursor::text() const
+{
+       return current_ ? current().text() : bv_->text();
+}
+
+
 Paragraph & LCursor::paragraph()
 {
        return current_ ? current().paragraph() : *bv_->text()->getPar(par());
@@ -723,7 +729,7 @@ std::ostream & operator<<(std::ostream & os, LCursor const & cur)
        os << "\n";
        for (size_t i = 0, n = cur.cursor_.size(); i != n; ++i)
                os << "  (" << cur.cursor_[i] << " | " << cur.anchor_[i] << "\n";
-       return os;
+       return os << "current: " << cur.current_ << endl;
 }
 
 
@@ -1705,7 +1711,7 @@ CursorSlice LCursor::normalAnchor()
        }
        //lyx::BOOST_ASSERT(Anchor_.size() >= cursor.depth());
        // use Anchor on the same level as Cursor
-       CursorSlice normal = anchor_[depth() - 1];
+       CursorSlice normal = anchor_[current_];
 #if 0
        if (depth() < anchor_.size() && !(normal < xx())) {
                // anchor is behind cursor -> move anchor behind the inset
index f7a119fd15e02fae1925bacb8c1a06a9994e2f61..68c257c793479496c2291ff2c8b9ec7b351a58f0 100644 (file)
@@ -201,6 +201,8 @@ public:
        ///
        Paragraph const & paragraph() const;
        ///
+       LyXText * text() const;
+       ///
        InsetBase * innerInsetOfType(int code) const;
        ///
        InsetTabular * innerInsetTabular() const;
index 61a8cbbdc42e543303009901ef6f060c68401a39..4a29e3022d6456d192ffe064a4dd872fe914abcb 100644 (file)
@@ -391,10 +391,6 @@ public:
        CursorSlice & cursor();
        /// the topmost cursor slice
        CursorSlice const & cursor() const;
-       /// access to the selection anchor
-       CursorSlice & anchor();
-       /// access to the selection anchor
-       CursorSlice const & anchor() const;
 
        friend class LyXScreen;
 
index 7772d889f216f1c6153f81daf2530a539a91f142..1bebde2723f658e0977c7c2490056f00bdd0bad7 100644 (file)
@@ -136,8 +136,9 @@ RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
                paintBackground();
 
        // paint the selection background
-       if (bv_.cursor().selection() && &text_ == bv_.cursor().innerText())
-               paintSelection();
+#warning look here for selection
+       //if (bv_.cursor().selection() && &text_ == bv_.cursor().innerText())
+       //      paintSelection();
 
        // vertical lines for appendix
        paintAppendix();
index 82cd90bb996c8314c5763caddd6c5c1c075b612d..78874de8a286220ce5a8dff16b846b063e7bfc12 100644 (file)
@@ -1933,46 +1933,26 @@ int LyXText::cursorY(CursorSlice const & cur) const
 }
 
 
-namespace {
-
-int findText(LyXText const * text)
-{
-       CursorBase & cur = text->bv()->cursor().cursor_;
-       //lyxerr << "findText: text: " << text << " cursor: "
-       //      << text->bv()->cursor() << endl;
-       for (int i = cur.size() - 1; i > 0; --i)
-               if (cur[i].text() == text)
-                       return i;
-       if (text->bv()->text() == text)
-               return 0;
-       lyxerr << "Trying to access text not touched by cursor" << endl;
-       BOOST_ASSERT(false);
-       return 0; // shut up compiler
-}
-
-}
-
-
 CursorSlice & LyXText::cursor()
 {
        //lyxerr << "# accessing slice " << findText(this) << endl;
-       return bv()->cursor().cursor_[findText(this)];
+       if (this != bv()->cursor().text()) {
+               lyxerr << "cursor: " << bv()->cursor()
+                       << "\ntext: " << bv()->cursor().text() 
+                       << "\nthis: " << this << endl;
+               BOOST_ASSERT(false);
+       }
+       return bv()->cursor().current();
 }
 
 
 CursorSlice const & LyXText::cursor() const
 {
-       return bv()->cursor().cursor_[findText(this)];
-}
-
-
-CursorSlice & LyXText::anchor()
-{
-       return bv()->cursor().anchor_[findText(this)];
-}
-
-
-CursorSlice const & LyXText::anchor() const
-{
-       return bv()->cursor().anchor_[findText(this)];
+       if (this != bv()->cursor().text()) {
+               lyxerr << "cursor: " << bv()->cursor()
+                       << "\ntext: " << bv()->cursor().text() 
+                       << "\nthis: " << this << endl;
+               BOOST_ASSERT(false);
+       }
+       return bv()->cursor().current();
 }
index 3aa14065e64f7b1e305d9ca1210be7fda80f5249..8e0afeab877607650c35a7ad6163c8b1d4a1780e 100644 (file)
@@ -79,9 +79,9 @@ LyXText::LyXText(BufferView * bv, bool in_inset)
 {}
 
 
-void LyXText::init(BufferView * bview)
+void LyXText::init(BufferView * bv)
 {
-       bv_owner = bview;
+       bv_owner = bv;
 
        ParagraphList::iterator const beg = paragraphs().begin();
        ParagraphList::iterator const end = paragraphs().end();
@@ -94,8 +94,7 @@ void LyXText::init(BufferView * bview)
        current_font = getFont(beg, 0);
 
        redoParagraphs(beg, end);
-       setCursorIntern(0, 0);
-       bv()->cursor().resetAnchor();
+       bv->cursor().resetAnchor();
 
        updateCounters();
 }
index c9461f4648afe8aed4d7d87a0c07b315db3388e4..ccd48cb57bc54b9a05a5a67a495fd69e7499e1da 100644 (file)
@@ -762,9 +762,10 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
        case LFUN_BACKSPACE_SKIP:
                // Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
                if (!cur.selection()) {
-                       CursorSlice cur = cursor();
+#warning look here
+                       //CursorSlice cur = cursor();
                        backspace();
-                       anchor() = cur;
+                       //anchor() = cur;
                } else {
                        cutSelection(true, false);
                }
@@ -793,10 +794,11 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
                // When at the beginning of a paragraph, remove
                // indentation and add a "defskip" at the top.
                // Otherwise, do the same as LFUN_BREAKPARAGRAPH.
-               CursorSlice cur = cursor();
+#warning look here
+//             CursorSlice cur = cursor();
                replaceSelection(bv->getLyXText());
                if (cur.pos() == 0) {
-                       ParagraphParameters & params = getPar(cur)->params();
+                       ParagraphParameters & params = getPar(cur.current())->params();
                        setParagraph(
                                        params.spacing(),
                                        params.align(),
@@ -805,7 +807,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
                        breakParagraph(bv->buffer()->paragraphs(), 0);
                }
                bv->update();
-               anchor() = cur;
+//     anchor() = cur;
                bv->switchKeyMap();
                bv->owner()->view_state_changed();
                break;