- int const vwidth = workarea().workWidth();
- int const vheight = workarea().workHeight();
- LyXText * text = bv.text;
-
- workarea().getPainter().start();
-
- switch (text->refreshStatus()) {
- 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_ROW:
- {
- text->updateRowPositions();
- // ok I will update the current cursor row
- drawOneRow(text, &bv, text->refresh_row, text->refresh_y,
- yo, xo);
- // this because if we had a major update the refresh_row could
- // have been set to 0!
- if (text->refresh_row != text->rows().end()) {
- expose(0, text->refresh_y - text->top_y() + yo,
- vwidth, text->refresh_row->height());
- }
- }
- 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)
-{
- // only if there is a selection
- if (!text->selection.set()) return;
-
- int const bottom = min(
- max(static_cast<int>(text->selection.end.y()
- - text->selection.end.row()->baseline()
- + text->selection.end.row()->height()),
- text->top_y()),
- static_cast<int>(text->top_y() + workarea().workHeight()));
- int const top = min(
- max(static_cast<int>(text->selection.start.y() -
- text->selection.start.row()->baseline()),
- text->top_y()),
- static_cast<int>(text->top_y() + workarea().workHeight()));
-
- if (kill_selection)
- text->selection.set(false);
-
- workarea().getPainter().start();
-
- drawFromTo(text, bv, top - text->top_y(), bottom - text->top_y(),
- yo, xo);
- expose(0, top - text->top_y(),
- workarea().workWidth(),
- bottom - text->top_y() - (top - text->top_y()));
-
- workarea().getPainter().end();
-}
-
-
-void LyXScreen::toggleToggle(LyXText * text, BufferView * bv,
- int yo, int xo)
-{
- if (text->toggle_cursor.par() == text->toggle_end_cursor.par()
- && text->toggle_cursor.pos() == text->toggle_end_cursor.pos())
- return;
-
- int const top_tmp = text->toggle_cursor.y()
- - text->toggle_cursor.row()->baseline();
- int const bottom_tmp = text->toggle_end_cursor.y()
- - text->toggle_end_cursor.row()->baseline()
- + text->toggle_end_cursor.row()->height();
-
- int const offset = yo < 0 ? yo : 0;
- int const bottom = min(max(bottom_tmp, text->top_y()),
- static_cast<int>(text->top_y() + workarea().workHeight())) - offset;
- int const top = min(max(top_tmp, text->top_y()),
- static_cast<int>(text->top_y() + workarea().workHeight())) - offset;
-
- workarea().getPainter().start();
-
- drawFromTo(text, bv, top - text->top_y(), bottom - text->top_y(), yo, xo);
- expose(0, top - text->top_y(), workarea().workWidth(),
- bottom - text->top_y() - (top - text->top_y()));
-
- workarea().getPainter().end();