- int const top_y = bv->top_y();
- int const h = workarea().workHeight();
- int newtop = top_y;
- int x, y, asc, desc;
-
- bv->cursor().getPos(x, y);
- bv->cursor().getDim(asc, desc);
-
- bool const big_row = h / 4 < asc + desc && asc + desc < h;
-
- if (y + desc - top_y >= h) {
- if (big_row)
- newtop = y + desc - h;
- else
- newtop = y - h / 2;
-
- } else if (top_y > max(y - asc, 0)) {
- if (big_row)
- newtop = y - asc;
- else {
- newtop = y - h / 2;
- newtop = min(newtop, top_y);
- }
- }
-
- newtop = max(newtop, 0);
- if (newtop == top_y)
- return false;
-
- bv->top_y(newtop);
- return true;