]> git.lyx.org Git - lyx.git/blobdiff - src/screen.C
John's Layout Tabular UI improvements and Martins fixes to clearing the
[lyx.git] / src / screen.C
index f2c195a559f3883e4b0d5233a4fc1595f32e255f..616b0916e4cd70ed6b560cef1b019e3ba0b30707 100644 (file)
@@ -128,11 +128,11 @@ void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
                LyXText::text_status st = text->status();
                text->getVisibleRow(bv, y + y_offset,
                                    x_offset, row, y + text->first);
-               while(internal && text->status() == LyXText::CHANGED_IN_DRAW) {
+               internal = internal && (st != LyXText::CHANGED_IN_DRAW);
+               while (internal && text->status() == LyXText::CHANGED_IN_DRAW) {
                        if (text->fullRebreak(bv)) {
                                st = LyXText::NEED_MORE_REFRESH;
                                text->setCursor(bv, text->cursor.par(), text->cursor.pos());
-                               bv->fitCursor();
                        }
                        text->status(bv, st);
                        text->getVisibleRow(bv, y + y_offset,
@@ -388,26 +388,33 @@ unsigned int LyXScreen::topCursorVisible(LyXText const * text)
 {
        int newtop = text->first;
 
-       if (text->cursor.y()
-           - text->cursor.row()->baseline()
-           + text->cursor.row()->height()
+       Row * row = text->cursor.row();
+
+       // Is this a hack? Yes, probably... (Lgb)
+       if (!row)
+               return max(newtop, 0);
+       
+       if (text->cursor.y() - row->baseline() + row->height()
            - text->first >= owner.height()) {
-               if (text->cursor.row()->height() < owner.height()
-                   && text->cursor.row()->height() > owner.height() / 4)
+               if (row->height() < owner.height()
+                   && row->height() > owner.height() / 4) {
                        newtop = text->cursor.y()
-                               + text->cursor.row()->height()
-                               - text->cursor.row()->baseline() - owner.height();
-               else
+                               + row->height()
+                               - row->baseline() - owner.height();
+               } else {
+                       // scroll down
                        newtop = text->cursor.y()
-                               - 3 * owner.height() / 4;   /* the scroll region must be so big!! */
-       } else if (static_cast<int>((text->cursor.y()) - text->cursor.row()->baseline()) <
-                  text->first && text->first > 0)
-       {
-               if (text->cursor.row()->height() < owner.height()
-                   && text->cursor.row()->height() > owner.height() / 4)
-                       newtop = text->cursor.y() - text->cursor.row()->baseline();
-               else {
-                       newtop = text->cursor.y() - owner.height() / 4;
+                               - owner.height() / 2;   /* the scroll region must be so big!! */
+               }
+               
+       } else if (static_cast<int>((text->cursor.y()) - row->baseline()) <
+                  text->first && text->first > 0) {
+               if (row->height() < owner.height()
+                   && row->height() > owner.height() / 4) {
+                       newtop = text->cursor.y() - row->baseline();
+               } else {
+                       // scroll up
+                       newtop = text->cursor.y() - owner.height() / 2;
                        newtop = min(newtop, int(text->first));
                }
        }
@@ -432,7 +439,7 @@ bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
 
    
 void LyXScreen::update(LyXText * text, BufferView * bv,
-                      int y_offset, int x_offset)
+                       int y_offset, int x_offset)
 {
        switch (text->status()) {
        case LyXText::NEED_MORE_REFRESH:
@@ -440,7 +447,10 @@ void LyXScreen::update(LyXText * text, BufferView * bv,
                int const y = max(int(text->refresh_y - text->first), 0);
                drawFromTo(text, bv, y, owner.height(), y_offset, x_offset);
                text->refresh_y = 0;
-               text->status(bv, LyXText::UNCHANGED);
+               // otherwise this is called ONLY from BufferView_pimpl(update)
+               // or we should see to set this flag accordingly
+               if (text != bv->text)
+                       text->status(bv, LyXText::UNCHANGED);
                expose(0, y, owner.workWidth(), owner.height() - y);
        }
        break;
@@ -452,7 +462,10 @@ void LyXScreen::update(LyXText * text, BufferView * bv,
                // this because if we had a major update the refresh_row could
                // have been set to 0!
                if (text->refresh_row) {
-                       text->status(bv, LyXText::UNCHANGED);
+                       // otherwise this is called ONLY from BufferView_pimpl(update)
+                       // or we should see to set this flag accordingly
+                       if (text != bv->text)
+                               text->status(bv, LyXText::UNCHANGED);
                        expose(0, text->refresh_y - text->first + y_offset,
                                   owner.workWidth(), text->refresh_row->height());
                }