]> git.lyx.org Git - features.git/commitdiff
fix the cursor-y problem in math
authorAndré Pönitz <poenitz@gmx.net>
Tue, 13 Apr 2004 12:47:48 +0000 (12:47 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 13 Apr 2004 12:47:48 +0000 (12:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8646 a592a061-630c-0410-9148-cb99ea01b6c8

13 files changed:
src/cursor.C
src/insets/insetbase.C
src/insets/insetbase.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/mathed/math_mboxinset.C
src/mathed/math_mboxinset.h
src/mathed/math_nestinset.C
src/mathed/math_nestinset.h
src/mathed/math_textinset.C
src/mathed/math_textinset.h

index 41716183f48551b3fef33c2b52057dc8a14fe86a..9ae8bee4cb669d68d86eba25d2d531692169d462 100644 (file)
@@ -270,7 +270,7 @@ void LCursor::getPos(int & x, int & y) const
        x = 0;
        y = 0;
        if (!empty())
-               inset().getCursorPos(back(), x, y);
+               inset().getCursorPos(*this, x, y);
 }
 
 
@@ -1085,7 +1085,8 @@ bool LCursor::bruteFind(int x, int y, int xlow, int xhigh, int ylow, int yhigh)
                // avoid invalid nesting when selecting
                if (!selection() || positionable(it, anchor_)) {
                        int xo = 0, yo = 0;
-                       CursorSlice & cur = it.back();
+                       LCursor cur = *this;
+                       cur.setCursor(it, false);
                        cur.inset().getCursorPos(cur, xo, yo);
                        if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) {
                                double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
@@ -1118,7 +1119,8 @@ void LCursor::bruteFind2(int x, int y)
        et.back().pos() = et.back().asMathInset()->cell(et.back().idx()).size();
        for (int i = 0; ; ++i) {
                int xo, yo;
-               CursorSlice & cur = it.back();
+               LCursor cur = *this;
+               cur.setCursor(it, false);
                cur.inset().getCursorPos(cur, xo, yo);
                double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
                // '<=' in order to take the last possible position
index 7bc3fc0b5b49d1addf745d0090bbe97f85d8c5b3..f4f637e0a4064864a25616bb3d8bab95f83a1147 100644 (file)
@@ -227,7 +227,7 @@ void InsetBase::markErased()
 {}
 
 
-void InsetBase::getCursorPos(CursorSlice const &, int & x, int & y) const
+void InsetBase::getCursorPos(LCursor const &, int & x, int & y) const
 {
        lyxerr << "InsetBase::getCursorPos called directly" << std::endl;
        x = 100;
index 6c70bceed88ff5c325e2efd5ceb2453b3d6983bb..5f9e1c2ac9dec8737bc52d4246aff752f1cfe4ce 100644 (file)
@@ -106,7 +106,7 @@ public:
        /// do we cover screen position x/y?
        virtual bool covers(int x, int y) const;
        /// get the screen positions of the cursor (see note in cursor.C)
-       virtual void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
+       virtual void getCursorPos(LCursor const & cur, int & x, int & y) const;
 
        /// is this an inset that can be moved into?
        virtual bool isActive() const { return nargs() > 0; }
index 983be071640391610c6989fcc83c1927b98b2a5a..770d259e7f3db22dbe5622cce9c80cb766ff95ca 100644 (file)
@@ -948,7 +948,7 @@ InsetText & InsetTabular::cell(int idx)
 }
 
 
-void InsetTabular::getCursorPos(CursorSlice const & cur, int & x, int & y) const
+void InsetTabular::getCursorPos(LCursor const & cur, int & x, int & y) const
 {
        cell(cur.idx()).getCursorPos(cur, x, y);
 }
index 48aaa35cd9918eafb33cbcb4bf56535cbd70992a..a12205c7d1d074447616ca8960db8ae6b4414920 100644 (file)
@@ -96,9 +96,9 @@ public:
        ///
        void validate(LaTeXFeatures & features) const;
        ///
-       InsetOld::Code lyxCode() const { return InsetOld::TABULAR_CODE; }
+       Code lyxCode() const { return InsetOld::TABULAR_CODE; }
        /// get the absolute screen x,y of the cursor
-       void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
+       void getCursorPos(LCursor const & cur, int & x, int & y) const;
        ///
        bool tabularFeatures(LCursor & cur, std::string const & what);
        ///
index 735c96e2fb5adea5b6ef38c2242e410dfe91c117..131557a2b6d59f1db9290f611e291d530c168141 100644 (file)
@@ -388,10 +388,10 @@ void InsetText::validate(LaTeXFeatures & features) const
 }
 
 
-void InsetText::getCursorPos(CursorSlice const & cur, int & x, int & y) const
+void InsetText::getCursorPos(LCursor const & cur, int & x, int & y) const
 {
-       x = text_.cursorX(cur);
-       y = text_.cursorY(cur);
+       x = text_.cursorX(cur.top());
+       y = text_.cursorY(cur.top());
 }
 
 
index 87e1153bc39e84b988e199475130a522ac739467..d89bb3413e4aee9d0ec14c8dfea50240d7d174c1 100644 (file)
@@ -90,7 +90,7 @@ public:
        ///
        InsetOld::Code lyxCode() const { return InsetOld::TEXT_CODE; }
        /// FIXME, document
-       void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
+       void getCursorPos(LCursor const & cur, int & x, int & y) const;
        ///
        void setFont(BufferView *, LyXFont const &,
                     bool toggleall = false,
index 083860cfa35e290f81d28b4cd3d3e523127a97ab..c3f090db000e8d73283536517af0225100c483c9 100644 (file)
@@ -17,6 +17,7 @@
 #include "BufferView.h"
 #include "buffer.h"
 #include "bufferparams.h"
+#include "cursor.h"
 #include "debug.h"
 #include "metricsinfo.h"
 #include "output_latex.h"
@@ -101,8 +102,8 @@ LyXText * MathMBoxInset::getText(int) const
 }
 
 
-void MathMBoxInset::getCursorPos(CursorSlice const & cur, int & x, int & y) const
+void MathMBoxInset::getCursorPos(LCursor const & cur, int & x, int & y) const
 {
-       x = text_.cursorX(cur);
-       y = text_.cursorY(cur);
+       x = text_.cursorX(cur.top());
+       y = text_.cursorY(cur.top());
 }
index c4cd9a20d5a6d7574140e2c42c69e5ffc8ed7e50..9a8be27272e2f4d2f4381cbf107c92d5435fa501 100644 (file)
@@ -44,7 +44,7 @@ public:
        ///
        LyXText * getText(int) const;
        ///
-       void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
+       void getCursorPos(LCursor const & cur, int & x, int & y) const;
 protected:
        ///
        mutable LyXText text_;
index e4d0cfb34c187dc0227352b7aa8b3adca2f51e31..e471435cda6cfd860ec258bd59bd352e2d4fcca1 100644 (file)
@@ -86,13 +86,12 @@ MathArray const & MathNestInset::cell(idx_type i) const
 }
 
 
-void MathNestInset::getCursorPos(CursorSlice const & cur,
-       int & x, int & y) const
+void MathNestInset::getCursorPos(LCursor const & cur, int & x, int & y) const
 {
        BOOST_ASSERT(ptr_cmp(&cur.inset(), this));
        MathArray const & ar = cur.cell();
        x = ar.xo() + ar.pos2x(cur.pos());
-       y = ar.yo();
+       y = ar.yo() + cur.bv().top_y();
        // move cursor visually into empty cells ("blue rectangles");
        if (cur.cell().empty())
                x += 2;
index d315ef306aadd293837dfd0a08cad4c2c63c2fa0..012f1542ae67182f2c55678d741ad35a24f40676 100644 (file)
@@ -37,7 +37,7 @@ public:
        /// identifies NestInsets
        MathNestInset const * asNestInset() const { return this; }
        /// get cursor position
-       void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
+       void getCursorPos(LCursor const & cur, int & x, int & y) const;
        ///
        void edit(LCursor & cur, bool left);
        ///
index 9219d995238fec72fb0b8d52e59d1ae780fcaa67..7f1e870884be182ae465710ca829c0564820f86a 100644 (file)
@@ -13,7 +13,7 @@
 #include "math_textinset.h"
 #include "math_data.h"
 
-#include "cursor_slice.h"
+#include "cursor.h"
 #include "debug.h"
 #include "metricsinfo.h"
 
@@ -42,9 +42,9 @@ MathInset::idx_type MathTextInset::pos2row(pos_type pos) const
 }
 
 
-void MathTextInset::getCursorPos(CursorSlice const & cur, int & x, int & y) const
+void MathTextInset::getCursorPos(LCursor const & cur, int & x, int & y) const
 {
-       CursorSlice c = cur;
+       LCursor c = cur;
        c.idx() = pos2row(cur.pos());
        c.pos() -= cache_.cellinfo_[c.idx()].begin_;
        cache_.getCursorPos(c, x, y);
index 04826766c09bb9768239aaf97b78eb25a1f2597b..c9a82d13b1f2111c0505825530f86ad6b9764c5f 100644 (file)
@@ -22,9 +22,9 @@ public:
        ///
        MathTextInset();
        ///
-       virtual std::auto_ptr<InsetBase> clone() const;
+       std::auto_ptr<InsetBase> clone() const;
        /// get cursor position
-       void getCursorPos(CursorSlice const & cur, int & x, int & y) const;
+       void getCursorPos(LCursor const & cur, int & x, int & y) const;
        /// this stores metrics information in cache_
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        /// draw according to cached metrics