anchor_pit_(0), anchor_ypos_(0),
inlineCompletionUniqueChars_(0),
last_inset_(0), mouse_position_cache_(),
- bookmark_edit_position_(0), gui_(0)
+ bookmark_edit_position_(-1), gui_(0)
{}
///
fp.pit = d->cursor_.bottom().pit();
fp.pos = d->cursor_.bottom().pos();
theSession().lastFilePos().save(buffer_.fileName(), fp);
+
+ if (d->last_inset_)
+ d->last_inset_->setMouseHover(this, false);
delete d;
}
void BufferView::processUpdateFlags(Update::flags flags)
{
- // last_inset_ points to the last visited inset. This pointer may become
- // invalid because of keyboard editing. Since all such operations
- // causes screen update(), I reset last_inset_ to avoid such a problem.
- d->last_inset_ = 0;
-
// This is close to a hot-path.
LYXERR(Debug::DEBUG, "BufferView::processUpdateFlags()"
<< "[fitcursor = " << (flags & Update::FitCursor)
}
-void BufferView::scrollDocView(int value)
+void BufferView::scrollDocView(int value, bool update)
{
int const offset = value - d->scrollbarParameters_.position;
// cut off at the top
if (value <= d->scrollbarParameters_.min) {
DocIterator dit = doc_iterator_begin(&buffer_);
- showCursor(dit);
+ showCursor(dit, false, update);
LYXERR(Debug::SCROLLING, "scroll to top");
return;
}
if (value >= d->scrollbarParameters_.max) {
DocIterator dit = doc_iterator_end(&buffer_);
dit.backwardPos();
- showCursor(dit);
+ showCursor(dit, false, update);
LYXERR(Debug::SCROLLING, "scroll to bottom");
return;
}
// It seems we didn't find the correct pit so stay on the safe side and
// scroll to bottom.
LYXERR0("scrolling position not found!");
- scrollDocView(d->scrollbarParameters_.max);
+ scrollDocView(d->scrollbarParameters_.max, update);
return;
}
DocIterator dit = doc_iterator_begin(&buffer_);
dit.pit() = i;
LYXERR(Debug::SCROLLING, "value = " << value << " -> scroll to pit " << i);
- showCursor(dit);
+ showCursor(dit, false, update);
}
void BufferView::recenter()
{
- showCursor(d->cursor_, true);
+ showCursor(d->cursor_, true, true);
}
void BufferView::showCursor()
{
- showCursor(d->cursor_, false);
+ showCursor(d->cursor_, false, true);
}
-void BufferView::showCursor(DocIterator const & dit, bool recenter)
+void BufferView::showCursor(DocIterator const & dit,
+ bool recenter, bool update)
{
- if (scrollToCursor(dit, recenter)) {
+ if (scrollToCursor(dit, recenter) && update) {
buffer_.changed(true);
updateHoveredInset();
}
LASSERT(!pm.rows().empty(), /**/);
// FIXME: smooth scrolling doesn't work in mathed.
CursorSlice const & cs = dit.innerTextSlice();
- int offset = coordOffset(dit, dit.boundary()).y_;
+ int offset = coordOffset(dit).y_;
int ypos = pm.position() + offset;
Dimension const & row_dim =
pm.getRow(cs.pos(), dit.boundary()).dimension();
int scrolled = 0;
if (recenter)
scrolled = scroll(ypos - height_/2);
+
+ // If the top part of the row falls of the screen, we scroll
+ // up to align the top of the row with the top of the screen.
else if (ypos - row_dim.ascent() < 0)
- scrolled = scrollUp(- ypos + row_dim.ascent());
- else if (ypos + row_dim.descent() > height_)
- scrolled = scrollDown(ypos - height_ + defaultRowHeight() );
+ scrolled = scrollUp(-ypos + row_dim.ascent());
+
+ // If the bottom of the row falls of the screen, we scroll down.
+ // However, we have to be careful not to scroll that much that
+ // the top falls of the screen.
+ else if (ypos + row_dim.descent() > height_) {
+ int ynew = height_ - row_dim.descent();
+ if (ynew < row_dim.ascent())
+ ynew = row_dim.ascent();
+ int const scroll = ypos - ynew;
+ scrolled = scrollDown(scroll);
+ }
// else, nothing to do, the cursor is already visible so we just return.
return scrolled != 0;
tm.redoParagraph(bot_pit);
ParagraphMetrics const & pm = tm.parMetrics(bot_pit);
- int offset = coordOffset(dit, dit.boundary()).y_;
+ int offset = coordOffset(dit).y_;
d->anchor_pit_ = bot_pit;
CursorSlice const & cs = dit.innerTextSlice();
flag.setOnOff(buffer_.params().compressed);
break;
}
-
+
+ case LFUN_BUFFER_TOGGLE_OUTPUT_SYNC: {
+ flag.setOnOff(buffer_.params().output_sync);
+ break;
+ }
+
case LFUN_SCREEN_UP:
case LFUN_SCREEN_DOWN:
case LFUN_SCROLL:
buffer_.params().compressed = !buffer_.params().compressed;
break;
+ case LFUN_BUFFER_TOGGLE_OUTPUT_SYNC:
+ buffer_.params().output_sync = !buffer_.params().output_sync;
+ break;
+
case LFUN_SCREEN_UP:
case LFUN_SCREEN_DOWN: {
Point p = getPos(cur);
Alert::warning(_("Branch already exists"), drtmp.message());
break;
}
- lyx::dispatch(FuncRequest(LFUN_BRANCH_INSERT, branch_name));
+ BranchList & branch_list = buffer_.params().branchlist();
+ vector<docstring> const branches =
+ getVectorFromString(branch_name, branch_list.separator());
+ for (vector<docstring>::const_iterator it = branches.begin();
+ it != branches.end(); ++it) {
+ branch_name = *it;
+ lyx::dispatch(FuncRequest(LFUN_BRANCH_INSERT, branch_name));
+ }
break;
}
return;
bool need_redraw = false;
- if (d->last_inset_)
+ if (d->last_inset_) {
// Remove the hint on the last hovered inset (if any).
- need_redraw |= d->last_inset_->setMouseHover(false);
+ need_redraw |= d->last_inset_->setMouseHover(this, false);
+ d->last_inset_ = 0;
+ }
// const_cast because of setMouseHover().
Inset * inset = const_cast<Inset *>(covering_inset);
- if (inset)
- // Highlight the newly hovered inset (if any).
- need_redraw |= inset->setMouseHover(true);
+ if (inset && inset->setMouseHover(this, true)) {
+ need_redraw = true;
+ // Only the insets that accept the hover state, do
+ // clear the last_inset_, so only set the last_inset_
+ // member if the hovered setting is accepted.
+ d->last_inset_ = inset;
+ }
- d->last_inset_ = inset;
-
if (need_redraw) {
LYXERR(Debug::PAINTING, "Mouse hover detected at: ("
<< d->mouse_position_cache_.x_ << ", "
}
+void BufferView::clearLastInset(Inset * inset) const
+{
+ if (d->last_inset_ != inset) {
+ LYXERR0("Wrong last_inset!");
+ LASSERT(false, /**/);
+ }
+ d->last_inset_ = 0;
+}
+
+
void BufferView::mouseEventDispatch(FuncRequest const & cmd0)
{
//lyxerr << "[ cmd0 " << cmd0 << "]" << endl;
}
-Point BufferView::coordOffset(DocIterator const & dit, bool boundary) const
+Point BufferView::coordOffset(DocIterator const & dit) const
{
int x = 0;
int y = 0;
int yy = 0;
// get relative position inside sl.inset()
- sl.inset().cursorPos(*this, sl, boundary && (i + 1 == dit.depth()), xx, yy);
+ sl.inset().cursorPos(*this, sl, dit.boundary() && (i + 1 == dit.depth()), xx, yy);
// Make relative position inside of the edited inset relative to sl.inset()
x += xx;
// In case of an RTL inset, the edited inset will be positioned to the left
// of xx:yy
if (sl.text()) {
- bool boundary_i = boundary && i + 1 == dit.depth();
+ bool boundary_i = dit.boundary() && i + 1 == dit.depth();
bool rtl = textMetrics(sl.text()).isRTL(sl, boundary_i);
if (rtl)
x -= lastw;
size_t rend;
if (sl.pos() > 0 && dit.depth() == 1) {
int pos = sl.pos();
- if (pos && boundary)
+ if (pos && dit.boundary())
--pos;
-// lyxerr << "coordOffset: boundary:" << boundary << " depth:" << dit.depth() << " pos:" << pos << " sl.pos:" << sl.pos() << endl;
+// lyxerr << "coordOffset: boundary:" << dit.boundary() << " depth:" << dit.depth() << " pos:" << pos << " sl.pos:" << sl.pos() << endl;
rend = pm.pos2row(pos);
} else
rend = pm.pos2row(sl.pos());
TextMetrics const & bottom_tm = textMetrics(dit.bottom().text());
// Make relative position from the nested inset now bufferview absolute.
- int xx = bottom_tm.cursorX(dit.bottom(), boundary && dit.depth() == 1);
+ int xx = bottom_tm.cursorX(dit.bottom(), dit.boundary() && dit.depth() == 1);
x += xx;
// In the RTL case place the nested inset at the left of the cursor in
// the outer paragraph
- bool boundary_1 = boundary && 1 == dit.depth();
+ bool boundary_1 = dit.boundary() && 1 == dit.depth();
bool rtl = bottom_tm.isRTL(dit.bottom(), boundary_1);
if (rtl)
x -= lastw;
CursorSlice const & bot = dit.bottom();
TextMetrics const & tm = textMetrics(bot.text());
- Point p = coordOffset(dit, dit.boundary()); // offset from outer paragraph
+ // offset from outer paragraph
+ Point p = coordOffset(dit);
p.y_ += tm.parMetrics(bot.pit()).position();
return p;
}