last_inset_(0), clickable_inset_(false),
mouse_position_cache_(),
bookmark_edit_position_(-1), gui_(0),
- horiz_scroll_offset_(0),
- caret_ascent_(0), caret_descent_(0)
+ horiz_scroll_offset_(0)
{
xsel_cache_.set = false;
}
Update::flags update_flags_;
///
CoordCache coord_cache_;
+ ///
+ typedef map<MathData const *, MathRow> MathRows;
+ MathRows math_rows_;
/// Estimated average par height for scrollbar.
int wh_;
/// a slice pointing to the start of the row where the cursor
/// is (at last draw time)
CursorSlice current_row_slice_;
-
- // The vertical size of the blinking caret. Only used for math
- // Using it for text could be bad when undo restores the cursor
- // current font, since the caret size could become wrong.
- int caret_ascent_;
- int caret_descent_;
};
// That is to say, if a cursor is in a nested inset, it will be
// restore to the left of the top level inset.
LastFilePosSection::FilePos fp;
+ fp.file = buffer_.fileName();
fp.pit = d->cursor_.bottom().pit();
fp.pos = d->cursor_.bottom().pos();
- theSession().lastFilePos().save(buffer_.fileName(), fp);
+ theSession().lastFilePos().save(fp);
if (d->last_inset_)
d->last_inset_->setMouseHover(this, false);
}
+MathRow const & BufferView::mathRow(MathData const * cell) const
+{
+ auto it = d->math_rows_.find(cell);
+ LATTEST(it != d->math_rows_.end());
+ return it->second;
+}
+
+
+void BufferView::setMathRow(MathData const * cell, MathRow const & mrow)
+{
+ d->math_rows_[cell] = mrow;
+}
+
+
Buffer & BufferView::buffer()
{
return buffer_;
// Clear out the position cache in case of full screen redraw,
d->coord_cache_.clear();
+ d->math_rows_.clear();
// Clear out paragraph metrics to avoid having invalid metrics
// in the cache from paragraphs not relayouted below
}
-void BufferView::insertLyXFile(FileName const & fname)
+void BufferView::insertLyXFile(FileName const & fname, bool const ignorelang)
{
LASSERT(d->cursor_.inTexted(), return);
ErrorList & el = buffer_.errorList("Parse");
// Copy the inserted document error list into the current buffer one.
el = buf.errorList("Parse");
+ ParagraphList & pars = buf.paragraphs();
+ if (ignorelang)
+ // set main language of imported file to context language
+ buf.changeLanguage(buf.language(), d->cursor_.getFont().language());
buffer_.undo().recordUndo(d->cursor_);
- cap::pasteParagraphList(d->cursor_, buf.paragraphs(),
+ cap::pasteParagraphList(d->cursor_, pars,
buf.params().documentClassPtr(), el);
res = _("Document %1$s inserted.");
} else {
}
-void BufferView::setCaretAscentDescent(int asc, int des)
-{
- d->caret_ascent_ = asc;
- d->caret_descent_ = des;
-}
-
-
void BufferView::caretPosAndHeight(Point & p, int & h) const
{
int asc, des;
Cursor const & cur = cursor();
if (cur.inMathed()) {
- asc = d->caret_ascent_;
- des = d->caret_descent_;
+ MathRow const & mrow = mathRow(&cur.cell());
+ asc = mrow.caret_ascent;
+ des = mrow.caret_descent;
} else {
Font const font = cur.real_current_font;
frontend::FontMetrics const & fm = theFontMetrics(font);
}
-bool BufferView::cursorInView(Point const & p, int h) const
+bool BufferView::caretInView() const
{
- Cursor const & cur = cursor();
+ if (!paragraphVisible(cursor()))
+ return false;
+ Point p;
+ int h;
+ caretPosAndHeight(p, h);
+
// does the cursor touch the screen ?
- if (p.y_ + h < 0 || p.y_ >= workHeight() || !paragraphVisible(cur))
+ if (p.y_ + h < 0 || p.y_ >= workHeight())
return false;
return true;
}
// however, the different coordinates of insets and paragraphs
// needs to be updated.
LYXERR(Debug::PAINTING, "Strategy: NoScreenUpdate");
- pi.full_repaint = false;
if (pain.isNull()) {
pi.full_repaint = true;
tm.draw(pi, 0, y);