bool BufferView::Pimpl::fitCursor()
{
lyxerr << "BufferView::Pimpl::fitCursor." << endl;
- bool ret;
-#ifndef LOCK
+ int x,y;
+ bv_->cursor().getPos(x, y);
+
+ if (y < top_y() || y > top_y() + workarea().workHeight()) {
+ int newtop = y - workarea().workHeight() / 2;
+ newtop = std::max(0, newtop);
+ top_y(newtop);
+ updateScrollbar();
+ return true;
+ }
+ return false;
+
+// dead code below
+ bool ret;
+#if 0
UpdatableInset * tli =
static_cast<UpdatableInset *>(cursor_.innerInset());
if (tli) {
} else {
ret = screen().fitCursor(bv_->text, bv_);
}
-#else
+#endif
+#if 0
ret = screen().fitCursor(bv_->text, bv_);
#endif
case FINISHED_DOWN:
theTempCursor.pop();
bv_->cursor() = theTempCursor;
- bv_->cursor().innerText()->setCursorFromCoordinates(cmd.x, cmd.y);
+ bv_->cursor().innerText()->setCursorFromCoordinates(cmd.x, top_y() + cmd.y);
+ bv_->fitCursor();
return true;
default:
lyxerr << "not dispatched by inner inset val: " << res.val() << endl;
// otherwise set cursor to surrounding LyXText
if (!res.dispatched()) {
lyxerr << "cursor is: " << bv_->cursor() << endl;
- lyxerr << "dispatching " << cmd1 << " to surrounding LyXText "
- << bv_->cursor().innerText() << endl;
- theTempCursor.innerText()->dispatch(cmd1);
+ lyxerr << "dispatching " << cmd1
+ << " to surrounding LyXText "
+ << bv_->cursor().innerText() << endl;
cursor_ = theTempCursor;
+ theTempCursor.dispatch(cmd1);
//return DispatchResult(true, true);
}
+ bv_->update();
// see workAreaKeyPress
cursor_timeout.restart();
screen().showCursor(*bv_);
+2003-11-11 Alfredo Braunstein <abraunst@libero.it>
+
+ * cursor.C (getPos): return absolute cached y coord
+
+ * BufferView_pimpl.C (fitCursor): new simplistic code
+ (workAreaDispatch): add a fitCursor call
2003-11-10 André Pönitz <poenitz@gmx.net>
{
lyxerr << "LCursor::push() inset: " << inset << endl;
data_.push_back(CursorItem(inset));
+ cached_y_ = bv_->top_y() + inset->y();
}
if (data_.empty()) {
x = bv_->text->cursor.x();
y = bv_->text->cursor.y();
- y -= bv_->top_y();
+// y -= bv_->top_y();
} else {
// Would be nice to clean this up to make some understandable sense...
UpdatableInset * inset = innerInset();
//y = inset->insetInInsetY() + bv_->text->cursor.y();
inset->getCursorPos(bv_, x, y);
x += inset->x();
- y += inset->y();
+ y += cached_y_;
}
}
std::vector<CursorItem> data_;
///
BufferView * bv_;
+private:
+ ///
+ int cached_y_;
};
#endif // LYXCURSOR_H
+2003-11-11 Alfredo Braunstein <abraunst@libero.it>
+
+ * screen.C (showCursor): use absolute coords form LCursor
2003-11-10 André Pönitz <poenitz@gmx.net>
int x = 0;
int y = 0;
bv.cursor().getPos(x, y);
- y -= ascent;
+ y -= ascent + bv.top_y();
//lyxerr << "LyXScreen::showCursor x: " << x << " y: " << y << endl;
// if it doesn't fit entirely on the screen, don't try to show it
+2003-11-11 Alfredo Braunstein <abraunst@libero.it>
+
+ * insettext.C (updateLocal, insertInset, setFont): remove
+ fitCursor calls
2003-11-10 André Pönitz <poenitz@gmx.net>
void InsetCollapsable::edit(BufferView * bv, bool left)
{
lyxerr << "InsetCollapsable: edit left/right" << endl;
- bv->cursor().push(this);
inset.edit(bv, left);
open(bv);
+ bv->cursor().push(this);
}
if (y <= button_dim.y2)
inset.edit(bv, x, 0);
else
- inset.edit(bv, x,
- ascent() + y - height_collapsed() + inset.ascent());
+ inset.edit(bv, x, ascent() + y - height_collapsed() + inset.ascent());
}
bv->cursor().push(this);
}
if (!text_.selection.set())
text_.selection.cursor = text_.cursor;
- bv->fitCursor();
+// bv->fitCursor();
bv->update();
bv->owner()->view_state_changed();
bv->owner()->updateMenubar();
{
inset->setOwner(this);
text_.insertInset(inset);
- bv->fitCursor();
+// bv->fitCursor();
updateLocal(bv, true);
return true;
}
if (selectall)
text_.clearSelection();
- bv->fitCursor();
+// bv->fitCursor();
updateLocal(bv, true);
}