]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
John's Layout Tabular UI improvements and Martins fixes to clearing the
[lyx.git] / src / text2.C
index e9cca2e3a463784721779308542890fbe4ccf2c5..19ad0bdc1d4517f45c1b2bef7c94a0bc73ffeeb1 100644 (file)
@@ -17,7 +17,7 @@
 #include "lyxtext.h"
 #include "LString.h"
 #include "paragraph.h"
-#include "layout.h"
+#include "lyxtextclasslist.h"
 #include "LyXView.h"
 #include "undo_funcs.h"
 #include "buffer.h"
@@ -1013,7 +1013,7 @@ void LyXText::setSelection(BufferView * bview)
 
 
 string const LyXText::selectionAsString(Buffer const * buffer,
-                                       bool label) const
+                                        bool label) const
 {
        if (!selection.set()) return string();
        string result;
@@ -1684,8 +1684,8 @@ void LyXText::insertInset(BufferView * bview, Inset * inset)
 {
        if (!cursor.par()->insetAllowed(inset->lyxCode()))
                return;
-       setUndo(bview, Undo::INSERT,
-               cursor.par(), cursor.par()->next());
+       // I don't know if this is necessary here (Jug 20020102)
+       setUndo(bview, Undo::INSERT, cursor.par(), cursor.par()->next());
        cursor.par()->insertInset(cursor.pos(), inset);
        // Just to rebreak and refresh correctly.
        // The character will not be inserted a second time
@@ -2100,9 +2100,12 @@ void LyXText::setCursor(BufferView * bview, Paragraph * par,
 }
 
 
-void LyXText::setCursor(BufferView *bview, LyXCursor & cur, Paragraph * par,
+void LyXText::setCursor(BufferView * bview, LyXCursor & cur, Paragraph * par,
                        pos_type pos, bool boundary) const
 {
+       lyx::Assert(par);
+       lyx::Assert(bview);
+       
        cur.par(par);
        cur.pos(pos);
        cur.boundary(boundary);
@@ -2125,11 +2128,15 @@ void LyXText::setCursor(BufferView *bview, LyXCursor & cur, Paragraph * par,
        pos_type cursor_vpos = 0;
        pos_type last = rowLastPrintable(row);
 
-       if (pos > last + 1)   // This shouldn't happen.
+       if (pos > last + 1) {
+               // This shouldn't happen.
                pos = last + 1;
-       else if (pos < row->pos())
+               cur.pos(pos);
+       } else if (pos < row->pos()) {
                pos = row->pos();
-
+               cur.pos(pos);
+       }
+       
        if (last < row->pos())
                 cursor_vpos = row->pos();
        else if (pos > last && !boundary)