Do not paint an invisible cursor.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27631 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2008-11-18 23:57:26 +00:00
parent 912979d2db
commit 550f1d9ce8
3 changed files with 16 additions and 3 deletions

View File

@ -2222,10 +2222,11 @@ Point BufferView::coordOffset(DocIterator const & dit, bool boundary) const
Point BufferView::getPos(DocIterator const & dit, bool boundary) const
{
if (!paragraphVisible(dit))
return Point(-1, -1);
CursorSlice const & bot = dit.bottom();
TextMetrics const & tm = textMetrics(bot.text());
if (!tm.contains(bot.pit()))
return Point(-1, -1);
Point p = coordOffset(dit, boundary); // offset from outer paragraph
p.y_ += tm.parMetrics(bot.pit()).position();
@ -2233,6 +2234,15 @@ Point BufferView::getPos(DocIterator const & dit, bool boundary) const
}
bool BufferView::paragraphVisible(DocIterator const & dit) const
{
CursorSlice const & bot = dit.bottom();
TextMetrics const & tm = textMetrics(bot.text());
return tm.contains(bot.pit());
}
void BufferView::draw(frontend::Painter & pain)
{
if (height_ == 0 || width_ == 0)

View File

@ -251,6 +251,8 @@ public:
///
Point getPos(DocIterator const & dit, bool boundary) const;
/// is the paragraph of the cursor visible ?
bool paragraphVisible(DocIterator const & dit) const;
///

View File

@ -567,7 +567,8 @@ void GuiWorkArea::showCursor()
// if it doesn't touch the screen, don't try to show it
bool cursorInView = true;
if (y + h < 0 || y >= viewport()->height())
if (y + h < 0 || y >= viewport()->height()
|| !cur.bv().paragraphVisible(cur))
cursorInView = false;
// show cursor on screen