]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
Painter and scrollbar API patches
[lyx.git] / src / text2.C
index 71f861cc8124604459edc73a46d7ce14f1f9cda5..e8d347f0126e3b0320e1434d23520e10a2cb25c8 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 "font.h"
+#include "frontends/Painter.h"
+#include "frontends/font_metrics.h"
 #include "debug.h"
 #include "lyxrc.h"
 #include "lyxrow.h"
@@ -739,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);
@@ -917,9 +915,9 @@ void LyXText::fullRebreak(BufferView * bview)
 // important for the screen
 
 
-/* the cursor set functions have a special mechanism. When they
- * realize, that you left an empty paragraph, they will delete it.
- * They also delete the corresponding row */
+// the cursor set functions have a special mechanism. When they
+// realize, that you left an empty paragraph, they will delete it.
+// They also delete the corresponding row 
 
 // need the selection cursor:
 void LyXText::setSelection(BufferView * bview)
@@ -1149,11 +1147,11 @@ pos_type LyXText::beginningOfMainBody(Buffer const * buf,
 }
 
 
-/* the DTP switches for paragraphs. LyX will store them in the
-* first physicla paragraph. When a paragraph is broken, the top settings
-* rest, the bottom settings are given to the new one. So I can make shure,
-* they do not duplicate themself and you cannnot make dirty things with
-* them!  */
+// the DTP switches for paragraphs. LyX will store them in the first
+// physicla paragraph. When a paragraph is broken, the top settings rest,
+// the bottom settings are given to the new one. So I can make shure,
+// they do not duplicate themself and you cannnot make dirty things with
+// them!
 
 void LyXText::setParagraph(BufferView * bview,
                           bool line_top, bool line_bottom,
@@ -1341,9 +1339,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
                par->enumdepth = par->depthHook(par->getDepth())->enumdepth;
                par->setCounter(6 + par->enumdepth,
                                par->depthHook(par->getDepth())->getCounter(6 + par->enumdepth));
-               /* reset the counters.
-                * A depth change is like a breaking layout
-                */
+               // reset the counters.A depth change is like a breaking layout
                for (int i = 6 + par->enumdepth + 1; i < 10; ++i)
                        par->setCounter(i, 0);
        }
@@ -2072,6 +2068,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()))
        {
@@ -2146,7 +2143,7 @@ float LyXText::getCursorX(BufferView * bview, Row * row,
                pos_type pos = vis2log(vpos);
                if (main_body > 0 && pos == main_body - 1) {
                        x += fill_label_hfill +
-                               lyxfont::width(textclasslist[
+                               font_metrics::width(textclasslist[
                                                       bview->buffer()->params.textclass][
                                        row->par()->layout()]
                                               .labelsep,
@@ -2333,7 +2330,7 @@ void LyXText::cursorUp(BufferView * bview, bool selecting) const
                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);
+                       inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none);
                }
        }
 #else
@@ -2357,7 +2354,7 @@ void LyXText::cursorDown(BufferView * bview, bool selecting) const
                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);
+                       inset_hit->edit(bview, x, y - (y2 - y1), mouse_button::none);
                }
        }
 #else
@@ -2404,6 +2401,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());
 }
@@ -2656,9 +2658,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