-#if 1
- Update();
-#else
- if (text->status == LyXText::NEED_MORE_REFRESH) {
- /* ok I will update till the current cursor row */
- Row * row = text->refresh_row;
- long y = text->refresh_y;
- long y2 = y;
-
- if (y > long(text->cursor.y)) {
- Update();
- return;
- }
-
- while (row
- && row != text->cursor.row
- && y < long(first + owner.height())) {
- DrawOneRow(row, y);
- row = row->next;
- }
-
- DrawOneRow(row, y);
- screen_refresh_y = y;
- screen_refresh_row = row->next;
- text->status = LyXText::UNCHANGED;
- // Is the right regin exposed?
- expose(0, y2 - first,
- owner.workWidth(), y - y2);
- } else if (text->status == LyXText::NEED_VERY_LITTLE_REFRESH) {
- /* ok I will update the current cursor row */
- long y = text->refresh_y;
- DrawOneRow(text->refresh_row, y);
- text->status = LyXText::UNCHANGED;
- expose(0, text->refresh_y - first,
- owner.workWidth(), text->refresh_row->height);
- }
-#endif
-}
-#endif
-
-
-void LyXScreen::ToggleSelection(bool kill_selection)
-{
- /* only if there is a selection */
- if (!text->selection) return;
-
- //long top = text->sel_start_cursor.y
- // - text->sel_start_cursor.row->baseline;
- //long bottom = text->sel_end_cursor.y
- // - text->sel_end_cursor.row->baseline
- // + text->sel_end_cursor.row->height;
-
- //top = max(top, first);
- //bottom = max(bottom, first);
-
- //bottom = min(max(bottom, first), first + owner.height());
- //top = min(max(top, first), first + owner.height());
- long bottom = min(max(text->sel_end_cursor.y
- - text->sel_end_cursor.row->baseline
- + text->sel_end_cursor.row->height, first),
- first + owner.height());
- long top = min(max(text->sel_start_cursor.y
- - text->sel_start_cursor.row->baseline, first),
- first + owner.height());
+ // 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->first_y),
+ static_cast<int>(text->first_y + owner.height()));
+ int const top = min(
+ max(static_cast<int>(text->selection.start.y() -
+ text->selection.start.row()->baseline()),
+ text->first_y),
+ static_cast<int>(text->first_y + owner.height()));