top_x = int(x);
owner()->update(bv, f, true);
bv->text->status = LyXText::CHANGED_IN_DRAW;
+// return;
}
top_baseline = baseline;
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
}
- if (!cleared && (need_update == CURSOR)) {
+ if (!cleared && (need_update == CURSOR) && !TEXT(bv)->selection) {
x += width(bv, f);
need_update = NONE;
return;
}
- x += TEXT_TO_INSET_OFFSET; // place for border
+ x += 1; // place for border
long int y = 0;
Row * row = TEXT(bv)->GetRowNearY(y);
y += baseline - row->ascent_of_text() + 1;
row = row->next();
}
} else if (need_update == SELECTION) {
- bv->screen()->ToggleToggle(getLyXText(bv), y, x);
+ bv->screen()->ToggleToggle(TEXT(bv), y, x);
} else {
locked = false;
+ if (need_update == CURSOR) {
+ bv->screen()->ToggleSelection(TEXT(bv), y, x, true);
+ TEXT(bv)->ClearSelection();
+ TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ }
bv->screen()->Update(TEXT(bv), y, x);
locked = true;
}
else if (!the_locking_inset || (what != CURSOR))
need_update = what;
}
- if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED))
+ if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED) ||
+ TEXT(bv)->selection)
bv->updateInset(this, mark_dirty);
if (old_par != cpar(bv)) {
bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
the_locking_inset = 0;
inset_pos = inset_x = inset_y = 0;
inset_par = 0;
+ old_par = 0;
if (!checkAndActivateInset(bv, x, y, button))
TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
y+TEXT(bv)->first+insetAscent);
locked = false;
TEXT(bv)->selection = 0;
UpdateLocal(bv, CLEAR_FRAME, false);
- bv->owner()->getToolbar()->combox->select(bv->text->cursor.par()->GetLayout()+1);
+ if (owner())
+ bv->owner()->getToolbar()->combox->
+ select(owner()->getLyXText(bv)->cursor.par()->GetLayout()+1);
+ else
+ bv->owner()->getToolbar()->combox->select(bv->text->cursor.par()->
+ GetLayout()+1);
}
the_locking_inset = 0;
if (lr)
moveRight(bv, false);
+ old_par = 0; // force layout setting
UpdateLocal(bv, CURSOR_PAR, false);
return true;
}
void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
{
- if (TEXT(bv)->selection) {
- TEXT(bv)->selection = 0;
- UpdateLocal(bv, FULL, false);
- }
no_selection = false;
int tmp_x = x - drawTextXOffset;
return;
}
}
- if (!inset)
+ if (!inset) {
TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
y+TEXT(bv)->first+insetAscent);
+ TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ UpdateLocal(bv, CURSOR, false);
+ bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
+ old_par = cpar(bv);
+ }
}
y - inset_y,state);
return;
}
-#warning REDO this (Jug)
if (!no_selection) {
-// LyXCursor old = selection_end_cursor;
HideInsetCursor(bv);
-// setPos(bv->painter(), x, y);
-// selection_end_cursor = cursor;
-// if (old != selection_end_cursor)
-// UpdateLocal(bv, false, false);
+ TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
+ y+TEXT(bv)->first+insetAscent);
+ TEXT(bv)->SetSelection();
+ if (TEXT(bv)->toggle_cursor.par()!=TEXT(bv)->toggle_end_cursor.par() ||
+ TEXT(bv)->toggle_cursor.pos()!=TEXT(bv)->toggle_end_cursor.pos())
+ UpdateLocal(bv, SELECTION, false);
ShowInsetCursor(bv);
}
no_selection = false;
UpdateLocal(bv, SELECTION, false);
break;
case LFUN_RIGHT:
- bv->text->FinishUndo();
result = moveRight(bv);
- TEXT(bv)->selection = 0;
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ bv->text->FinishUndo();
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_LEFTSEL:
case LFUN_LEFT:
bv->text->FinishUndo();
result= moveLeft(bv);
- TEXT(bv)->selection = 0;
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_DOWNSEL:
case LFUN_DOWN:
bv->text->FinishUndo();
result = moveDown(bv);
- TEXT(bv)->selection = 0;
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_UPSEL:
case LFUN_UP:
bv->text->FinishUndo();
result = moveUp(bv);
- TEXT(bv)->selection = 0;
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_HOME:
bv->text->FinishUndo();
TEXT(bv)->CursorHome(bv);
- TEXT(bv)->selection = 0;
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_END:
TEXT(bv)->CursorEnd(bv);
- TEXT(bv)->selection = 0;
- TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
UpdateLocal(bv, CURSOR, false);
break;
case LFUN_BACKSPACE:
}
-void LyXScreen::ToggleSelection(LyXText * text, bool kill_selection)
+void LyXScreen::ToggleSelection(LyXText * text, int y_offset, int x_offset,
+ bool kill_selection)
{
// only if there is a selection
if (!text->selection) return;
if (kill_selection)
text->selection = 0;
- DrawFromTo(text, top - text->first, bottom - text->first);
+ DrawFromTo(text, top - text->first, bottom - text->first,
+ y_offset, x_offset);
expose(0, top - text->first,
owner.workWidth(),
bottom - text->first - (top - text->first));
bottom = min(max(ulong(bottom), text->first), text->first + owner.height());
top = min(max(ulong(top), text->first), text->first + owner.height());
-
+
DrawFromTo(text, top - text->first, bottom - text->first, y_offset,
x_offset);
expose(0, top - text->first, owner.workWidth(),
}
if (selection) {
+ int w;
+ if (inset_owner)
+ w = inset_owner->width(bview, font);
+ else
+ w = ww;
/* selection code */
if (bidi_same_direction) {
if (sel_start_cursor.row() == row_ptr &&
else
pain.fillRectangle(x_offset + sel_start_cursor.x(),
y_offset,
- ww - sel_start_cursor.x(),
+ w - sel_start_cursor.x(),
row_ptr->height(),
LColor::selection);
} else if (sel_end_cursor.row() == row_ptr) {
if (is_rtl)
pain.fillRectangle(x_offset + sel_end_cursor.x(),
y_offset,
- ww - sel_end_cursor.x(),
+ w - sel_end_cursor.x(),
row_ptr->height(),
LColor::selection);
else
LColor::selection);
} else if (y > long(sel_start_cursor.y())
&& y < long(sel_end_cursor.y())) {
- pain.fillRectangle(x_offset, y_offset, ww,
+ pain.fillRectangle(x_offset, y_offset, w,
row_ptr->height(),
LColor::selection);
}
sel_end_cursor.row() != row_ptr &&
y > long(sel_start_cursor.y())
&& y < long(sel_end_cursor.y())) {
- pain.fillRectangle(x_offset, y_offset, ww,
+ pain.fillRectangle(x_offset, y_offset, w,
row_ptr->height(),
LColor::selection);
} else if (sel_start_cursor.row() == row_ptr ||