ParagraphList & paragraphs)
: height(0), width(0), inset_owner(inset), bv_owner(bv),
in_inset_(ininset), paragraphs_(¶graphs),
- cache_pos_(-1), x0_(0), y0_(0)
+ cache_pos_(-1), xo_(0), yo_(0)
{}
ParagraphList::iterator pit = getPar(par);
Row const & row = *pit->getRow(pos);
+
int y = pit->y + row.y_offset();
// y is now the beginning of the cursor row
pos_type pos, bool setfont, bool boundary)
{
setCursor(cursor, par, pos, boundary);
- bv()->x_target(cursor.x() + x0_);
+ bv()->x_target(cursor.x() + xo_);
if (setfont)
setCurrentFont();
}
void LyXText::cursorUp(bool selecting)
{
- ParagraphList::iterator cpit = cursorPar();
- Row const & crow = *cpit->getRow(cursor.pos());
- int x = bv()->x_target() - x0_;
- int y = cursor.y() - crow.baseline() - 1;
+ Row const & row = *cursorRow();
+ int x = bv()->x_target() - xo_;
+ int y = cursor.y() - row.baseline() - 1;
setCursorFromCoordinates(x, y);
+
if (!selecting) {
- y += y0_ - bv()->top_y();
- lyxerr << "y:" << y << " y0: " << y0_ << endl;
- InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y);
+ int y_abs = y + yo_ - bv()->top_y();
+ InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y_abs);
if (inset_hit && isHighlyEditableInset(inset_hit))
- inset_hit->edit(bv(), bv()->x_target(), y);
+ inset_hit->edit(bv(), bv()->x_target(), y_abs);
}
}
void LyXText::cursorDown(bool selecting)
{
- ParagraphList::iterator cpit = cursorPar();
- Row const & crow = *cpit->getRow(cursor.pos());
- int x = bv()->x_target() - x0_;
- int y = cursor.y() - crow.baseline() + crow.height() + 1;
+ Row const & row = *cursorRow();
+ int x = bv()->x_target() - xo_;
+ int y = cursor.y() - row.baseline() + row.height() + 1;
setCursorFromCoordinates(x, y);
+
if (!selecting) {
- y += y0_ - bv()->top_y();
- InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y);
+ int y_abs = y + yo_ - bv()->top_y();
+ InsetOld * inset_hit = checkInsetHit(bv()->x_target(), y_abs);
if (inset_hit && isHighlyEditableInset(inset_hit))
- inset_hit->edit(bv(), bv()->x_target(), y);
+ inset_hit->edit(bv(), bv()->x_target(), y_abs);
}
}
ParagraphList::iterator end;
getParsInRange(ownerParagraphs(),
- bv()->top_y(), bv()->top_y() + bv()->workHeight(),
+ bv()->top_y() - yo_,
+ bv()->top_y() - yo_ + bv()->workHeight(),
pit, end);
lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
RowList::iterator crit = cursorRow();
- int x = bv()->x_target() - x0_;
- int y = bv()->top_y() - y0_;
+ int x = bv()->x_target() - xo_;
+ int y = bv()->top_y() - yo_;
setCursorFromCoordinates(x, y);
if (crit == cursorRow()) {
{
RowList::iterator crit = cursorRow();
- int x = bv()->x_target() - x0_;
- int y = bv()->top_y() + bv()->workHeight() - y0_;
+ int x = bv()->x_target() - xo_;
+ int y = bv()->top_y() + bv()->workHeight() - yo_;
setCursorFromCoordinates(x, y);
if (crit == cursorRow()) {
// FIXME: shouldn't be top-text-specific
if (cursorrow == cursorRow() && !in_inset_) {
if (cmd.y - bv->top_y() >= bv->workHeight())
- cursorDown(false);
+ cursorDown(true);
else if (cmd.y - bv->top_y() < 0)
- cursorUp(false);
+ cursorUp(true);
}
setSelection();
break;
setCursorFromCoordinates(cmd.x, cmd.y);
selection.cursor = cursor;
finishUndo();
- bv->x_target(cursor.x() + x0_);
+ bv->x_target(cursor.x() + xo_);
if (bv->fitCursor())
selection_possible = false;