]> git.lyx.org Git - features.git/commitdiff
LyXCursor::x_fix -> BufferView::x_target
authorAndré Pönitz <poenitz@gmx.net>
Tue, 4 Nov 2003 07:43:03 +0000 (07:43 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 4 Nov 2003 07:43:03 +0000 (07:43 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8026 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/ChangeLog
src/insets/insettext.C
src/lyxcursor.C
src/lyxcursor.h
src/lyxfunc.C
src/text2.C
src/text3.C

index dd17b915d5161a8f42d4bbb32c6cfa9f80c1d80b..1cdbf0c75e9dd9a40e84ef28694497eac714ce27 100644 (file)
@@ -56,7 +56,8 @@ extern BufferList bufferlist;
 
 BufferView::BufferView(LyXView * owner, int xpos, int ypos,
                       int width, int height)
-       : pimpl_(new Pimpl(this, owner, xpos, ypos, width, height))
+       : pimpl_(new Pimpl(this, owner, xpos, ypos, width, height)),
+         x_target_(0)
 {
        text = 0;
 }
@@ -580,3 +581,15 @@ int BufferView::workHeight() const
 {
        return pimpl_->workarea().workHeight();
 }
+
+
+void BufferView::x_target(int x)
+{
+       x_target_ = x;
+}
+
+
+int BufferView::x_target() const
+{
+       return x_target_;
+}
index cb7246f6dbcdd34cdd7eaa2fe7caf22c7c0e7230..f05a62fd6828adb1138a50ac732ba3704855ca33 100644 (file)
@@ -201,6 +201,11 @@ public:
 
        /// execute the given function
        bool dispatch(FuncRequest const & argument);
+       
+       /// set target x position of cursor
+       void BufferView::x_target(int x);
+       /// return target x position of cursor
+       int BufferView::x_target() const;
 
 private:
        /// Set the current locking inset
@@ -210,6 +215,21 @@ private:
        friend struct BufferView::Pimpl;
 
        Pimpl * pimpl_;
+
+       /**
+        * The target x position of the cursor. This is used for when
+        * we have text like :
+        *
+        * blah blah blah blah| blah blah blah
+        * blah blah blah
+        * blah blah blah blah blah blah
+        *
+        * When we move onto row 3, we would like to be vertically aligned
+        * with where we were in row 1, despite the fact that row 2 is
+        * shorter than x()
+        */
+       int x_target_;
+
 };
 
 #endif // BUFFERVIEW_H
index 7082c6b234e72a3658ac154823e4a6f2c7e532fe..398b7bc629f8047e91c7b22b29164215d7c23785 100644 (file)
        * buffer.h:
        * bufferview_funcs.C: remove getInsetFromId()
 
+       * lyxcursor.[Ch]:
+       * BufferView.[Ch]: move x_fix from LyXCursor to BufferView
+
+       * lyxfunc.C:
+       * text2.C:
+       * text3.C: adjust
+
 2003-11-03  Alfredo Braunstein  <abraunst@libero.it>
 
        * PosIterator.C (distance, advance): new
index 458b3fbe9bb65b23e4f99cef7535e510d9e6ed53..ea03e0d76f94e5f9063f3617d38435d5c13b4dac 100644 (file)
@@ -512,7 +512,7 @@ void InsetText::lfunMousePress(FuncRequest const & cmd)
                text_.setCursorFromCoordinates(cmd.x, cmd.y + dim_.asc);
                // set the selection cursor!
                text_.selection.cursor = text_.cursor;
-               text_.cursor.x_fix(text_.cursor.x());
+               bv->x_target(text_.cursor.x());
 
                text_.clearSelection();
                updateLocal(bv, false);
@@ -584,7 +584,7 @@ void InsetText::lfunMouseMotion(FuncRequest const & cmd)
        BufferView * bv = cmd.view();
        LyXCursor cur = text_.cursor;
        text_.setCursorFromCoordinates (cmd.x, cmd.y + dim_.asc);
-       text_.cursor.x_fix(text_.cursor.x());
+       bv->x_target(text_.cursor.x());
        if (cur == text_.cursor)
                return;
        text_.setSelection();
@@ -632,7 +632,7 @@ InsetText::priv_dispatch(FuncRequest const & cmd,
                        if (!checkAndActivateInset(bv, cmd.x, tmp_y, mouse_button::none)) {
                                text_.setCursorFromCoordinates(cmd.x, cmd.y + dim_.asc);
                                text_.cursor.x(text_.cursor.x());
-                               text_.cursor.x_fix(text_.cursor.x());
+                               bv->x_target(text_.cursor.x());
                        }
                }
 
index c49d23f8ffd03308a8706c7b14bf60dfa205ec58..3caa2ead36d9370e91bdd64bdf2043c2182e6a7c 100644 (file)
@@ -17,7 +17,7 @@
 
 
 LyXCursor::LyXCursor()
-       : par_(-1), pos_(0), boundary_(false), x_(0), x_fix_(0), y_(0)
+       : par_(-1), pos_(0), boundary_(false), x_(0), y_(0)
 {}
 
 
@@ -62,24 +62,13 @@ void LyXCursor::x(int n)
        x_ = n;
 }
 
+
 int LyXCursor::x() const
 {
        return x_;
 }
 
 
-void LyXCursor::x_fix(int i)
-{
-       x_fix_ = i;
-}
-
-
-int LyXCursor::x_fix() const
-{
-       return x_fix_;
-}
-
-
 void LyXCursor::y(int i)
 {
        y_ = i;
index 471d6d8277d90e3018587684ef8090a3217748d5..dd9497e2974b5a17fcd04491eae6c06bd4dd24bf 100644 (file)
@@ -45,21 +45,6 @@ public:
        void x(int i);
        /// return the x position in pixels
        int x() const;
-       /// set the cached x position
-       void x_fix(int i);
-       /**
-        * Return the cached x position of the cursor. This is used for when
-        * we have text like :
-        *
-        * blah blah blah blah| blah blah blah
-        * blah blah blah
-        * blah blah blah blah blah blah
-        *
-        * When we move onto row 3, we would like to be vertically aligned
-        * with where we were in row 1, despite the fact that row 2 is
-        * shorter than x()
-        */
-       int x_fix() const;
        /// set the y position in pixels
        void y(int i);
        /// return the y position in pixels
@@ -88,8 +73,6 @@ private:
        bool boundary_;
        /// the pixel x position
        int x_;
-       /// the cached x position
-       int x_fix_;
        /// the pixel y position
        int y_;
 };
index 64bcf29385be2c0cec5c093841e082247abff3ea..99c68b272fd26fa3cc8e18686a869af27ca1f65d 100644 (file)
@@ -972,7 +972,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                                text->cursor.x() + inset_x,
                                                text->cursor.y() -
                                                row.baseline() - 1);
-                                       text->cursor.x_fix(text->cursor.x());
+                                       view()->x_target(text->cursor.x());
 #else
                                        text->cursorUp(view());
 #endif
@@ -995,7 +995,7 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                                text->cursor.y() -
                                                row.baseline() +
                                                row.height() + 1);
-                                       text->cursor.x_fix(text->cursor.x());
+                                       view()->x_target(text->cursor.x());
 #else
                                        text->cursorDown(view());
 #endif
index 49c5bbcc490467e81cc15a3fdfb909862971baf2..6b5d4328a010480700d85101f05b9548d01c617a 100644 (file)
@@ -1339,9 +1339,8 @@ void LyXText::setCursor(LyXCursor & cur, paroffset_type par,
                BOOST_ASSERT(false);
        }
        // now get the cursors x position
-       float x = getCursorX(pit, row, pos, boundary);
-       cur.x(int(x));
-       cur.x_fix(cur.x());
+       cur.x(int(getCursorX(pit, row, pos, boundary)));
+       bv()->x_target(cur.x());
 }
 
 
@@ -1620,7 +1619,7 @@ void LyXText::cursorUp(bool selecting)
        ParagraphList::iterator cpit = cursorPar();
        Row const & crow = *cpit->getRow(cursor.pos());
 #if 1
-       int x = cursor.x_fix();
+       int x = bv()->x_target();
        int y = cursor.y() - crow.baseline() - 1;
        setCursorFromCoordinates(x, y);
        if (!selecting) {
@@ -1637,7 +1636,7 @@ void LyXText::cursorUp(bool selecting)
 #else
        lyxerr << "cursorUp: y " << cursor.y() << " bl: " <<
                crow.baseline() << endl;
-       setCursorFromCoordinates(cursor.x_fix(),
+       setCursorFromCoordinates(bv()->x_target(),
                cursor.y() - crow.baseline() - 1);
 #endif
 }
@@ -1648,7 +1647,7 @@ void LyXText::cursorDown(bool selecting)
        ParagraphList::iterator cpit = cursorPar();
        Row const & crow = *cpit->getRow(cursor.pos());
 #if 1
-       int x = cursor.x_fix();
+       int x = bv()->x_target();
        int y = cursor.y() - crow.baseline() + crow.height() + 1;
        setCursorFromCoordinates(x, y);
        if (!selecting) {
@@ -1663,7 +1662,7 @@ void LyXText::cursorDown(bool selecting)
                }
        }
 #else
-       setCursorFromCoordinates(cursor.x_fix(),
+       setCursorFromCoordinates(bv()->x_target(),
                 cursor.y() - crow.baseline() + crow.height() + 1);
 #endif
 }
index e47e7e4067fdeffc0ca4e99613334e56ec48e42e..5635facaa402ba1f98555c350f29ff7e2ded670f 100644 (file)
@@ -260,7 +260,7 @@ void LyXText::cursorPrevious()
                return;
        }
 
-       setCursorFromCoordinates(cursor.x_fix(), y);
+       setCursorFromCoordinates(bv()->x_target(), y);
        finishUndo();
 
        if (crit == bv()->text->cursorRow()) {
@@ -313,7 +313,7 @@ void LyXText::cursorNext()
        Row const & rr = *getRowNearY(y, dummypit);
        y = dummypit->y + rr.y_offset();
 
-       setCursorFromCoordinates(cursor.x_fix(), y);
+       setCursorFromCoordinates(bv()->x_target(), y);
        // + bv->workHeight());
        finishUndo();
 
@@ -1326,7 +1326,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
                        bv->text->setCursorFromCoordinates(x, y + screen_first);
                finishUndo();
                bv->text->selection.cursor = bv->text->cursor;
-               bv->text->cursor.x_fix(bv->text->cursor.x());
+               bv->x_target(bv->text->cursor.x());
 
                if (bv->fitCursor())
                        selection_possible = false;