-bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
- int /*x*/, int y, int asc, int desc)
-{
- int const vheight = workarea().workHeight();
- int newtop = text->top_y();
-
- if (y + desc - text->top_y() >= vheight)
- newtop = y - 3 * vheight / 4; // the scroll region must be so big!!
- else if (y - asc < text->top_y()
- && text->top_y() > 0) {
- newtop = y - vheight / 4;
- }
-
- newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb)
-
- if (newtop != text->top_y()) {
- draw(text, bv, newtop);
- text->top_y(newtop);
- return true;
- }
-
- return false;
-}
-
-
-unsigned int LyXScreen::topCursorVisible(LyXText * text)
-{
- 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();
-
-#warning SUPER HACK DISABLED (Lgb)
-#if 0
- // Is this a hack? Yes, probably... (Lgb)
- if (!row)
- return max(newtop, 0);
-#endif
- if (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 (static_cast<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);
- }
- }
-
- newtop = max(newtop, 0);
-
- return newtop;
-}
-
-
-bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
-{
- // Is a change necessary?
- int const newtop = topCursorVisible(text);
- bool const result = (newtop != text->top_y());
- if (result) {
- draw(text, bv, newtop);
- }
-
- return result;
-}
-
-
-void LyXScreen::update(BufferView & bv, int yo, int xo)
-{
- int const vwidth = workarea().workWidth();
- int const vheight = workarea().workHeight();
- LyXText * text = bv.text;
-
- workarea().getPainter().start();
-
- switch (text->refreshStatus()) {
- case LyXText::REFRESH_ROW:
- case LyXText::REFRESH_AREA:
- {
- text->updateRowPositions();
- int const y = max(int(text->refresh_y - text->top_y()), 0);
- drawFromTo(text, &bv, y, vheight, yo, xo);
- expose(0, y, vwidth, vheight - y);
- break;
- }
- case LyXText::REFRESH_NONE:
- // Nothing needs done
- break;
- }
-
- workarea().getPainter().end();
-}
-
-
-void LyXScreen::toggleSelection(LyXText * text, BufferView * bv,
- bool kill_selection,
- int yo, int xo)