-}
-
-
-void LyXScreen::ToggleSelection(bool kill_selection)
-{
- long top = 0;
- long bottom = 0;
-
- /* only if there is a selection */
- if (!text->selection)
- return;
-
- if (fast_selection || mono_video){
-
- /* selection only in one row ?*/
- if (text->sel_start_cursor.y == text->sel_end_cursor.y) {
-
- /* only if something is visible */
- if (text->sel_start_cursor.y
- - text->sel_start_cursor.row->baseline
- - first < _height
- && text->sel_start_cursor.y
- - text->sel_start_cursor.row->baseline +
- text->sel_start_cursor.row->height - first > 0) {
- top = text->sel_start_cursor.y
- - text->sel_start_cursor.row->baseline
- - first;
- bottom = top
- + text->sel_start_cursor.row->height;
- if (top<0)
- top = 0;
- if (bottom > _height)
- bottom = _height;
- XFillRectangle(fl_display,_window,
- getGC(gc_select),
- text->sel_start_cursor.x
- +_offset_x,
- top+_offset_y,
- text->sel_end_cursor.x
- - text->sel_start_cursor.x,
- bottom - top);
- }
- } else {
- /* the sel_start_cursor row first */
- /* only if anything is visible */
- if (text->sel_start_cursor.y
- - text->sel_start_cursor.row->baseline
- - first < _height
- && text->sel_start_cursor.y
- - text->sel_start_cursor.row->baseline +
- text->sel_start_cursor.row->height - first > 0) {
- top = text->sel_start_cursor.y
- - text->sel_start_cursor.row->baseline
- - first;
- bottom = top
- + text->sel_start_cursor.row->height;
- if (top<0)
- top = 0;
- if (bottom > _height)
- bottom = _height;
- XFillRectangle(fl_display,_window,
- getGC(gc_select),
- text->sel_start_cursor.x
- +_offset_x,
- top+_offset_y,
- _width
- - text->sel_start_cursor.x,
- bottom - top);
- }
-
- /* the main body */
-
- if (text->sel_start_cursor.row->next !=
- text->sel_end_cursor.row) {
- top = text->sel_start_cursor.y
- - text->sel_start_cursor.row->baseline
- + text->sel_start_cursor.row->height;
- bottom = text->sel_end_cursor.y
- - text->sel_end_cursor.row->baseline;
-
- if (top - first < 0)
- top = first;
- if (bottom - first < 0)
- bottom = first;
-
- if (bottom - first > _height)
- bottom = first + _height;
- if (top - first > _height)
- top = first + _height;
-
- if (top != bottom) {
- XFillRectangle(fl_display,
- _window,
- getGC(gc_select),
- 0+_offset_x,
- top - first+_offset_y,
- _width,
- bottom - top);
- }
- }
-
- /* the sel_end_cursor row last */
- if (text->sel_end_cursor.y
- - text->sel_end_cursor.row->baseline
- - first < _height
- && text->sel_end_cursor.y
- - text->sel_end_cursor.row->baseline +
- text->sel_end_cursor.row->height - first > 0) {
- top = text->sel_end_cursor.y
- - text->sel_end_cursor.row->baseline
- - first;
- bottom = top
- + text->sel_end_cursor.row->height;
- if (top<0)
- top = 0;
- if (bottom > _height)
- bottom = _height;
- XFillRectangle(fl_display,_window,
- getGC(gc_select),
- 0+_offset_x,
- top+_offset_y,
- text->sel_end_cursor.x,
- bottom - top);
- }
- }
- } else {
- top = text->sel_start_cursor.y
- - text->sel_start_cursor.row->baseline;
- bottom = text->sel_end_cursor.y
- - text->sel_end_cursor.row->baseline
- + text->sel_end_cursor.row->height;
-
- if (top - first < 0)
- top = first;
- if (bottom - first < 0)
- bottom = first;
-
- if (bottom - first > _height)
- bottom = first + _height;
- if (top - first > _height)
- top = first + _height;
-
- if (kill_selection)
- text->selection = 0;
- DrawFromTo(top - first, bottom - first);
- expose(0, top - first, _width, bottom - first - (top - first));
- }
-}
-
-
-void LyXScreen::ToggleToggle()
-{
- long top = 0;
- long bottom = 0;
-
- if (text->toggle_cursor.par == text->toggle_end_cursor.par
- && text->toggle_cursor.pos == text->toggle_end_cursor.pos)
- return;
-
- if (fast_selection || mono_video){
-
- /* selection only in one row ?*/
- if (text->toggle_cursor.y == text->toggle_end_cursor.y) {
-
- /* only if anything is visible */
- if (text->toggle_cursor.y - text->toggle_cursor.row->baseline - first < _height
- && text->toggle_cursor.y - text->toggle_cursor.row->baseline +
- text->toggle_cursor.row->height - first > 0) {
- top = text->toggle_cursor.y - text->toggle_cursor.row->baseline - first;
- bottom = top + text->toggle_cursor.row->height;
- if (top < 0) top = 0;
- if (bottom > _height) bottom = _height;
- XFillRectangle(fl_display,_window,
- getGC(gc_select),
- text->toggle_cursor.x+_offset_x,
- top+_offset_y,
- text->toggle_end_cursor.x -
- text->toggle_cursor.x,
- bottom - top);
- }
- } else {
- /* the toggle_cursor row first */
- /* only if anything is visible */
- if (text->toggle_cursor.y - text->toggle_cursor.row->baseline - first < _height
- && text->toggle_cursor.y - text->toggle_cursor.row->baseline +
- text->toggle_cursor.row->height - first > 0) {
- top = text->toggle_cursor.y - text->toggle_cursor.row->baseline - first;
- bottom = top + text->toggle_cursor.row->height;
- if (top<0)
- top = 0;
- if (bottom > _height)
- bottom = _height;
- XFillRectangle(fl_display,_window,
- getGC(gc_select),
- text->toggle_cursor.x+_offset_x,
- top+_offset_y,
- _width - text->toggle_cursor.x,
- bottom - top);
- }
-
- /* the main body */
-
- if (text->toggle_cursor.row->next !=
- text->toggle_end_cursor.row) {
- top = text->toggle_cursor.y
- - text->toggle_cursor.row->baseline
- + text->toggle_cursor.row->height;
- bottom = text->toggle_end_cursor.y
- - text->toggle_end_cursor.row->baseline;
-
- if (top - first < 0)
- top = first;
- if (bottom - first < 0)
- bottom = first;
-
- if (bottom - first > _height)
- bottom = first + _height;
- if (top - first > _height)
- top = first + _height;
-
- if (top != bottom) {
- XFillRectangle(fl_display,_window,
- getGC(gc_select),
- 0+_offset_x,
- top - first+_offset_y,
- _width,
- bottom - top);
- }
- }
-
- /* the toggle_end_cursor row last */
- if (text->toggle_end_cursor.y - text->toggle_end_cursor.row->baseline - first < _height
- && text->toggle_end_cursor.y - text->toggle_end_cursor.row->baseline +
- text->toggle_end_cursor.row->height - first > 0) {
- top = text->toggle_end_cursor.y
- - text->toggle_end_cursor.row->baseline
- - first;
- bottom = top
- + text->toggle_end_cursor.row->height;
- if (top<0)
- top = 0;
- if (bottom > _height)
- bottom = _height;
- XFillRectangle(fl_display,_window,
- getGC(gc_select),
- 0+_offset_x,
- top+_offset_y,
- text->toggle_end_cursor.x,
- bottom - top);
- }
- }
- } else {
- top = text->toggle_cursor.y
- - text->toggle_cursor.row->baseline;
- bottom = text->toggle_end_cursor.y
- - text->toggle_end_cursor.row->baseline
- + text->toggle_end_cursor.row->height;
-
- if (top - first < 0)
- top = first;
- if (bottom - first < 0)
- bottom = first;
-
- if (bottom - first > _height)
- bottom = first + _height;
- if (top - first > _height)
- top = first + _height;
-
- DrawFromTo(top - first, bottom - first);
- expose(0, top - first, _width, bottom - first - (top - first));