- LyXCursor const & cursor = text->cursor;
- int top_y = text->top_y();
- int newtop = top_y;
- int const vheight = workarea().workHeight();
-
- RowList::iterator row = text->cursorRow();
-
- if (int(cursor.y() - row->baseline() + row->height() - top_y) >= vheight) {
- if (row->height() < vheight
- && row->height() > vheight / 4) {
- newtop = cursor.y()
- + row->height()
- - row->baseline() - vheight;
- } else {
- // scroll down, the scroll region must be so big!!
- newtop = cursor.y() - vheight / 2;
- }
-
- } else if (int(cursor.y() - row->baseline()) < top_y && top_y > 0) {
- if (row->height() < vheight && row->height() > vheight / 4) {
- newtop = cursor.y() - row->baseline();
- } else {
- // scroll up
- newtop = cursor.y() - vheight / 2;
- newtop = min(newtop, top_y);
- }
- }
-
- return max(newtop, 0);
-}
-
-
-bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
-{
- // Is a change necessary?
- int const newtop = topCursorVisible(text);
- bool const result = (newtop != text->top_y());
- text->top_y(newtop);
- return result;