- LyXCursor const & cursor = text->cursor;
- int top_y = text->bv()->top_y();
- int newtop = top_y;
- unsigned int const vheight = workarea().workHeight();
-
- Row & row = *text->cursorPar()->getRow(cursor.pos());
-
- 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 != bv->top_y());
- bv->top_y(newtop);
- return result;