]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
Move #includes out of header files.
[lyx.git] / src / text2.C
index 2675333c6d95da86568412629036ffe15d908d42..8158ebaa6c6f89d0b3c21069a10b3cf4b9f75e60 100644 (file)
@@ -37,6 +37,7 @@
 #include "frontends/font_metrics.h"
 #include "debug.h"
 #include "lyxrc.h"
+#include "Floating.h"
 #include "FloatList.h"
 #include "language.h"
 #include "ParagraphParameters.h"
@@ -675,21 +676,12 @@ void LyXText::cursorEnd()
                return;
 
        RowList::iterator rit = cursorRow();
-       RowList::iterator next_rit = boost::next(rit);
-       RowList::iterator end = boost::next(rit);
        ParagraphList::iterator pit = cursor.par();
-       pos_type last_pos = lastPos(*pit, rit);
-
-       if (next_rit == end) {
-               ++last_pos;
-       } else {
-               if (pit->empty() ||
-                   (pit->getChar(last_pos) != ' ' && !pit->isNewline(last_pos))) {
-                       ++last_pos;
-               }
-       }
-
-       setCursor(pit, last_pos);
+       pos_type pos = lastPos(*pit, rit);
+       /* cursor should be before a hard newline only */
+       if (!pit->isNewline(pos))
+               ++pos;
+       setCursor(pit, pos);
 }
 
 
@@ -1361,18 +1353,12 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
        RowList::iterator row = getRow(pit, pos);
        int y = row->y();
 
-       RowList::iterator old_row = row;
-       // if we are before the first char of this row and are still in the
-       // same paragraph and there is a previous row then put the cursor on
-       // the end of the previous row
-       cur.iy(y + row->baseline());
-
        // y is now the beginning of the cursor row
        y += row->baseline();
        // y is now the cursor baseline
        cur.y(y);
 
-       pos_type last = lastPrintablePos(*pit, old_row);
+       pos_type last = lastPrintablePos(*pit, row);
 
        // None of these should happen, but we're scaredy-cats
        if (pos > pit->size()) {
@@ -1394,11 +1380,6 @@ void LyXText::setCursor(LyXCursor & cur, ParagraphList::iterator pit,
        float x = getCursorX(pit, row, pos, last, boundary);
        cur.x(int(x));
        cur.x_fix(cur.x());
-       if (old_row != row) {
-               x = getCursorX(pit, old_row, pos, last, boundary);
-               cur.ix(int(x));
-       } else
-               cur.ix(cur.x());
 }
 
 
@@ -1635,9 +1616,6 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur, int x, int y)
        cur.x(x);
        cur.y(y + rit->baseline());
 
-       cur.iy(cur.y());
-       cur.ix(cur.x());
-
        cur.boundary(bound);
 }
 
@@ -1684,7 +1662,7 @@ void LyXText::cursorUp(bool selecting)
        setCursorFromCoordinates(x, y);
        if (!selecting) {
                int topy = bv_owner->top_y();
-               int y1 = cursor.iy() - topy;
+               int y1 = cursor.y() - topy;
                int y2 = y1;
                y -= topy;
                InsetOld * inset_hit = checkInsetHit(x, y1);
@@ -1710,7 +1688,7 @@ void LyXText::cursorDown(bool selecting)
        setCursorFromCoordinates(x, y);
        if (!selecting && cursorRow() == cursorIRow()) {
                int topy = bv_owner->top_y();
-               int y1 = cursor.iy() - topy;
+               int y1 = cursor.y() - topy;
                int y2 = y1;
                y -= topy;
                InsetOld * inset_hit = checkInsetHit(x, y1);