Make sure the selection painting is updated after LFUN_UP or LFUN_DOWN. See http://thread.gmane.org/gmane.editors.lyx.devel/113428

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27567 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2008-11-16 18:03:52 +00:00
parent fbbf69f10c
commit 84a186ebf6
3 changed files with 39 additions and 14 deletions

View File

@ -1702,6 +1702,28 @@ bool Cursor::upDownInMath(bool up)
}
bool Cursor::atFirstOrLastRow(bool up)
{
TextMetrics const & tm = bv_->textMetrics(text());
ParagraphMetrics const & pm = tm.parMetrics(pit());
int row;
if (pos() && boundary())
row = pm.pos2row(pos() - 1);
else
row = pm.pos2row(pos());
if (up) {
if (pit() == 0 && row == 0)
return true;
} else {
if (pit() + 1 >= int(text()->paragraphs().size()) &&
row + 1 >= int(pm.rows().size()))
return true;
}
return false;
}
bool Cursor::upDownInText(bool up, bool & updateNeeded)
{
LASSERT(text(), /**/);
@ -1755,15 +1777,8 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
else
row = pm.pos2row(pos());
// are we not at the start or end?
if (up) {
if (pit() == 0 && row == 0)
return false;
} else {
if (pit() + 1 >= int(text()->paragraphs().size()) &&
row + 1 >= int(pm.rows().size()))
return false;
}
if (atFirstOrLastRow(up))
return false;
// with and without selection are handled differently
if (!selection()) {

View File

@ -359,6 +359,8 @@ public:
/// move the cursor up by sending an internal LFUN_DOWN,
/// return true if fullscreen update is needed
bool down();
/// whether the cursor is either at the first or last row
bool atFirstOrLastRow(bool up);
/// move up/down in a text inset, called for LFUN_UP/DOWN,
/// return true if successful, updateNeeded set to true if fullscreen
/// update is needed, otherwise it's not touched

View File

@ -640,16 +640,24 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// stop/start the selection
bool select = cmd.action == LFUN_DOWN_SELECT ||
cmd.action == LFUN_UP_SELECT;
cur.selHandle(select);
// move cursor up/down
bool up = cmd.action == LFUN_UP_SELECT || cmd.action == LFUN_UP;
bool const successful = cur.upDownInText(up, needsUpdate);
if (successful) {
// redraw if you leave mathed (for the decorations)
bool const atFirstOrLastRow = cur.atFirstOrLastRow(up);
if (!atFirstOrLastRow) {
needsUpdate |= cur.selHandle(select);
cur.selHandle(select);
cur.upDownInText(up, needsUpdate);
needsUpdate |= cur.beforeDispatchCursor().inMathed();
} else
} else {
// if the cursor cannot be moved up or down do not remove
// the selection right now, but wait for the next dispatch.
if (select)
needsUpdate |= cur.selHandle(select);
cur.upDownInText(up, needsUpdate);
cur.undispatched();
}
break;
}