]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
more guii moving around.
[lyx.git] / src / text2.C
index 64c45adcd4dba101a12f6494daff96fd2099a81f..dd00754792007ddc06eb919d063c98cad23c6b94 100644 (file)
 #include "LString.h"
 #include "paragraph.h"
 #include "lyxtextclasslist.h"
-#include "LyXView.h"
+#include "frontends/LyXView.h"
 #include "undo_funcs.h"
 #include "buffer.h"
 #include "bufferparams.h"
 #include "gettext.h"
 #include "BufferView.h"
-#include "LyXView.h"
 #include "CutAndPaste.h"
-#include "Painter.h"
+#include "frontends/Painter.h"
 #include "font.h"
 #include "debug.h"
 #include "lyxrc.h"
@@ -500,14 +499,16 @@ Paragraph * LyXText::setLayout(BufferView * bview,
        // ok we have a selection. This is always between sstart_cur
        // and sel_end cursor
        cur = sstart_cur;
+       Paragraph * par = sstart_cur.par();
+       Paragraph * epar = send_cur.par()->next();
 
        LyXLayout const & lyxlayout =
                textclasslist[bview->buffer()->params.textclass][layout];
 
        do {
-               cur.par()->applyLayout(layout);
-               makeFontEntriesLayoutSpecific(bview->buffer(), cur.par());
-               Paragraph * fppar = cur.par();
+               par->applyLayout(layout);
+               makeFontEntriesLayoutSpecific(bview->buffer(), par);
+               Paragraph * fppar = par;
                fppar->params().spaceTop(lyxlayout.fill_top ?
                                         VSpace(VSpace::VFILL)
                                         : VSpace(VSpace::NONE));
@@ -515,15 +516,15 @@ Paragraph * LyXText::setLayout(BufferView * bview,
                                            VSpace(VSpace::VFILL)
                                            : VSpace(VSpace::NONE));
                if (lyxlayout.margintype == MARGIN_MANUAL)
-                       cur.par()->setLabelWidthString(lyxlayout.labelstring());
+                       par->setLabelWidthString(lyxlayout.labelstring());
                if (lyxlayout.labeltype != LABEL_BIBLIO
                    && fppar->bibkey) {
                        delete fppar->bibkey;
                        fppar->bibkey = 0;
                }
-               if (cur.par() != send_cur.par())
-                       cur.par(cur.par()->next());
-       } while (cur.par() != send_cur.par());
+               cur.par(par);
+               par = par->next();
+       } while (par != epar);
 
        return endpar;
 }
@@ -737,11 +738,10 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall)
        freezeUndo();
        cursor = selection.start;
        while (cursor.par() != selection.end.par() ||
-              (cursor.pos() < selection.end.pos()))
+              cursor.pos() < selection.end.pos()) 
        {
                if (cursor.pos() < cursor.par()->size()) {
-                       // an open footnote should behave
-                       // like a closed one
+                       // an open footnote should behave like a closed one
                        setCharFont(bview, cursor.par(), cursor.pos(),
                                    font, toggleall);
                        cursor.pos(cursor.pos() + 1);
@@ -898,18 +898,17 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur,
 }
 
 
-bool LyXText::fullRebreak(BufferView * bview)
+void LyXText::fullRebreak(BufferView * bview)
 {
        if (!firstrow) {
                init(bview);
-               return true;
+               return;
        }
        if (need_break_row) {
                breakAgain(bview, need_break_row);
                need_break_row = 0;
-               return true;
+               return;
        }
-       return true;
 }
 
 
@@ -2071,6 +2070,7 @@ void LyXText::setCursor(BufferView * bview, LyXCursor & cur, Paragraph * par,
        cur.iy(y + row->baseline());
        Inset * ins;
        if (row->previous() && pos &&
+               row->previous()->par() == row->par() &&
                par->getChar(pos) == Paragraph::META_INSET &&
                (ins=par->getInset(pos)) && (ins->needFullRow() || ins->display()))
        {
@@ -2117,7 +2117,7 @@ float LyXText::getCursorX(BufferView * bview, Row * row,
        float fill_label_hfill;
        // This call HAS to be here because of the BidiTables!!!
        prepareToPrint(bview, row, x, fill_separator, fill_hfill,
-                      fill_label_hfill);
+                      fill_label_hfill);
 
        if (last < row->pos())
                cursor_vpos = row->pos();
@@ -2319,17 +2319,21 @@ void LyXText::cursorRight(BufferView * bview, bool internal) const
 }
 
 
-void LyXText::cursorUp(BufferView * bview) const
+void LyXText::cursorUp(BufferView * bview, bool selecting) const
 {
 #if 1
        int x = cursor.x_fix();
        int y = cursor.y() - cursor.row()->baseline() - 1;
        setCursorFromCoordinates(bview, x, y);
-       int y1 = cursor.iy() - first_y;
-       int y2 = y1;
-       Inset * inset_hit = bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
-       if (inset_hit && isHighlyEditableInset(inset_hit)) {
-               inset_hit->edit(bview, x, y - (y2 - y1), 0);
+       if (!selecting) {
+               int y1 = cursor.iy() - first_y;
+               int y2 = y1;
+               y -= first_y;
+               Inset * inset_hit =
+                       bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
+               if (inset_hit && isHighlyEditableInset(inset_hit)) {
+                       inset_hit->edit(bview, x, y - (y2 - y1), 0);
+               }
        }
 #else
        setCursorFromCoordinates(bview, cursor.x_fix(),
@@ -2338,18 +2342,22 @@ void LyXText::cursorUp(BufferView * bview) const
 }
 
 
-void LyXText::cursorDown(BufferView * bview) const
+void LyXText::cursorDown(BufferView * bview, bool selecting) const
 {
 #if 1
        int x = cursor.x_fix();
        int y = cursor.y() - cursor.row()->baseline() +
                cursor.row()->height() + 1;
        setCursorFromCoordinates(bview, x, y);
-       int y1 = cursor.iy() - first_y;
-       int y2 = y1;
-       Inset * inset_hit = bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
-       if (inset_hit && isHighlyEditableInset(inset_hit)) {
-               inset_hit->edit(bview, x, y - (y2 - y1), 0);
+       if (!selecting && cursor.row() == cursor.irow()) {
+               int y1 = cursor.iy() - first_y;
+               int y2 = y1;
+               y -= first_y;
+               Inset * inset_hit =
+                       bview->checkInsetHit(const_cast<LyXText *>(this), x, y1);
+               if (inset_hit && isHighlyEditableInset(inset_hit)) {
+                       inset_hit->edit(bview, x, y - (y2 - y1), 0);
+               }
        }
 #else
        setCursorFromCoordinates(bview, cursor.x_fix(),
@@ -2395,6 +2403,11 @@ void LyXText::fixCursorAfterDelete(BufferView * bview,
        if (cur.pos() > where.pos())
                cur.pos(cur.pos()-1);
 
+       // check also if we don't want to set the cursor on a spot behind the
+       // pagragraph because we erased the last character.
+       if (cur.pos() > cur.par()->size())
+               cur.pos(cur.par()->size());
+       
        // recompute row et al. for this cursor
        setCursor(bview, cur, cur.par(), cur.pos(), cur.boundary());
 }
@@ -2647,9 +2660,6 @@ LyXText::text_status LyXText::status() const
 
 void LyXText::status(BufferView * bview, LyXText::text_status st) const
 {
-       // well as much as I know && binds more then || so the above and the
-       // below are identical (this for your known use of parentesis!)
-       // Now some explanation:
        // We should only go up with refreshing code so this means that if
        // we have a MORE refresh we should never set it to LITTLE if we still
        // didn't handle it (and then it will be UNCHANGED. Now as long as