// store some values to be used inside of the handlers
getPos(beforeDispX_, beforeDispY_);
- beforeDispDepth_ = depth();
-
+ beforeDispatchCursor_ = *this;
for (; depth(); pop()) {
LYXERR(Debug::DEBUG) << "Cursor::dispatch: cmd: "
<< cmd0 << endl << *this << endl;
if (disp_.dispatched())
break;
}
+
// it completely to get a 'bomb early' behaviour in case this
// object will be used again.
if (!disp_.dispatched()) {
operator=(safe);
disp_.update(Update::None);
disp_.dispatched(false);
+ } else {
+ // restore the previous one because nested Cursor::dispatch calls
+ // are possible which would change it
+ beforeDispatchCursor_ = safe.beforeDispatchCursor_;
}
}
// if we cannot move up/down inside this inset anymore
if (x_target_ == -1)
setTargetX(xo);
- else if (xo - textTargetOffset() != x_target() && depth() == beforeDispDepth_) {
+ else if (xo - textTargetOffset() != x_target() &&
+ depth() == beforeDispatchCursor_.depth()) {
// In text mode inside the line (not left or right) possibly set a new target_x,
// but only if we are somewhere else than the previous target-offset.
row + 1 >= int(pm.rows().size()))
return false;
}
-
+
// with and without selection are handled differently
if (!selection()) {
int yo = bv_funcs::getPos(bv(), *this, boundary()).y_;
top().pos() = std::min(tm.x2pos(pit(), 0, xo), top().lastpos());
}
}
-
+
updateNeeded |= bv().checkDepm(*this, old);
}
-
+
updateTextTargetOffset();
return true;
}
Font Cursor::getFont() const
{
+ // The logic here should more or less match to the Text::setCurrentFont
+ // logic, i.e. the cursor height should give a hint what will happen
+ // if a character is entered.
+
// HACK. far from being perfect...
- int s = 0;
// go up until first non-0 text is hit
// (innermost text is 0 in mathed)
+ int s = 0;
for (s = depth() - 1; s >= 0; --s)
if (operator[](s).text())
break;
CursorSlice const & sl = operator[](s);
Text const & text = *sl.text();
- Font font = text.getPar(sl.pit()).getFont(
- bv().buffer()->params(),
- sl.pos(),
+ Paragraph const & par = text.getPar(sl.pit());
+
+ // on boundary, so we are really at the character before
+ pos_type pos = sl.pos();
+ if (pos > 0 && boundary())
+ --pos;
+
+ // on space? Take the font before (only for RTL boundary stay)
+ if (pos > 0) {
+ if (pos == sl.lastpos()
+ || (par.isSeparator(pos) &&
+ !text.isRTLBoundary(buffer(), par, pos)))
+ --pos;
+ }
+
+ // get font at the position
+ Font font = par.getFont(bv().buffer()->params(), pos,
outerFont(sl.pit(), text.paragraphs()));
return font;
}
+bool notifyCursorLeaves(DocIterator const & old, Cursor & cur)
+{
+ // find inset in common
+ size_type i;
+ for (i = 0; i < old.depth() && i < cur.depth(); ++i) {
+ if (&old.inset() != &cur.inset())
+ break;
+ }
+
+ // notify everything on top of the common part in old cursor,
+ // but stop if the inset claims the cursor to be invalid now
+ for (; i < old.depth(); ++i) {
+ if (old[i].inset().notifyCursorLeaves(cur))
+ return true;
+ }
+
+ return false;
+}
+
+
} // namespace lyx