some fitcursor work

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8074 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Alfredo Braunstein 2003-11-11 09:06:41 +00:00
parent 6789af0a32
commit 29eaa76094
9 changed files with 49 additions and 16 deletions

View File

@ -343,9 +343,22 @@ void BufferView::Pimpl::buffer(Buffer * b)
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) {
@ -354,7 +367,8 @@ bool BufferView::Pimpl::fitCursor()
} else {
ret = screen().fitCursor(bv_->text, bv_);
}
#else
#endif
#if 0
ret = screen().fitCursor(bv_->text, bv_);
#endif
@ -958,7 +972,8 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
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;
@ -969,13 +984,15 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
// 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_);

View File

@ -1,3 +1,9 @@
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>

View File

@ -113,6 +113,7 @@ void LCursor::push(UpdatableInset * inset)
{
lyxerr << "LCursor::push() inset: " << inset << endl;
data_.push_back(CursorItem(inset));
cached_y_ = bv_->top_y() + inset->y();
}
@ -161,7 +162,7 @@ void LCursor::getPos(int & x, int & y) const
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();
@ -176,7 +177,7 @@ void LCursor::getPos(int & x, int & y) const
//y = inset->insetInInsetY() + bv_->text->cursor.y();
inset->getCursorPos(bv_, x, y);
x += inset->x();
y += inset->y();
y += cached_y_;
}
}

View File

@ -82,6 +82,9 @@ public:
std::vector<CursorItem> data_;
///
BufferView * bv_;
private:
///
int cached_y_;
};
#endif // LYXCURSOR_H

View File

@ -1,3 +1,6 @@
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>

View File

@ -173,7 +173,7 @@ void LyXScreen::showCursor(BufferView & bv)
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

View File

@ -1,3 +1,7 @@
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>

View File

@ -268,9 +268,9 @@ bool InsetCollapsable::hitButton(FuncRequest const & cmd) const
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);
}
@ -288,8 +288,7 @@ void InsetCollapsable::edit(BufferView * bv, int x, int y)
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);
}

View File

@ -289,7 +289,7 @@ void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/)
if (!text_.selection.set())
text_.selection.cursor = text_.cursor;
bv->fitCursor();
// bv->fitCursor();
bv->update();
bv->owner()->view_state_changed();
bv->owner()->updateMenubar();
@ -780,7 +780,7 @@ bool InsetText::insertInset(BufferView * bv, InsetOld * inset)
{
inset->setOwner(this);
text_.insertInset(inset);
bv->fitCursor();
// bv->fitCursor();
updateLocal(bv, true);
return true;
}
@ -847,7 +847,7 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
if (selectall)
text_.clearSelection();
bv->fitCursor();
// bv->fitCursor();
updateLocal(bv, true);
}