//lyxerr << "*** workAreaDispatch: request: " << cmd << std::endl;
LCursor cur(*bv_);
cur.push(bv_->buffer()->inset());
- cur.resetAnchor();
cur.selection() = bv_->cursor().selection();
// Doesn't go through lyxfunc, so we need to update
screen().hideCursor();
- // either the inset under the cursor or the
+ // Either the inset under the cursor or the
// surrounding LyXText will handle this event.
- // built temporary path to inset
+ // Build temporary cursor.
InsetBase * inset = bv_->text()->editXY(cur, cmd.x, cmd.y);
lyxerr << "hit inset at tip: " << inset << endl;
lyxerr << "created temp cursor:\n" << cur << endl;
+ // Put anchor at the same position.
+ cur.resetAnchor();
+
// Try to dispatch to an non-editable inset near this position
// via the temp cursor. If the inset wishes to change the real
// cursor it has to do so explicitly by using
if (inset)
inset->dispatch(cur, cmd);
- // Now dispatch to the real cursor. Any change to the cursor
- // is immediate.
+ // Now dispatch to the temporary cursor. If the real cursor should
+ // be modified, the inset's dispatch has to do so explicitly.
if (!res.dispatched())
res = cur.dispatch(cmd);
- // If the request was dispatched the temp cursor should have been
- // in a way to be used as new 'real' cursor.
- if (res.dispatched())
- bv_->cursor() = cur;
-
// Redraw if requested or necessary.
if (res.update())
update();
CursorSlice & LCursor::anchor()
{
+ if (anchor_.size() < size()) {
+ lyxerr << "anchor_.size() < cursor_.size() "
+ "should not happen when accessing the anchor" << endl;
+ BOOST_ASSERT(false);
+ }
BOOST_ASSERT(!anchor_.empty());
- return anchor_.back();
+ // this size is cursor_.size()
+ return anchor_[size() - 1];
}
CursorSlice const & LCursor::anchor() const
{
+ if (anchor_.size() < size()) {
+ lyxerr << "anchor_.size() < cursor_.size() "
+ "should not happen when accessing the anchor" << endl;
+ BOOST_ASSERT(false);
+ }
+ // this size is cursor_.size()
BOOST_ASSERT(!anchor_.empty());
- return anchor_.back();
+ return anchor_[size() - 1];
}
{
selection() = true;
// a selection with no contents is not a selection
+#warning doesnt look ok
if (par() == anchor().par() && pos() == anchor().pos())
selection() = false;
}
}
-void LCursor::selClear()
-{
- resetAnchor();
- clearSelection();
-}
-
-
void LCursor::selCopy()
{
if (selection()) {
void selPaste(size_t n);
///
void selHandle(bool selecting);
- /// start selection
- void selStart();
- /// clear selection
- void selClear();
/// clears or deletes selection depending on lyxrc setting
void selClearOrDel();
//
if (&p.inset() != &q.inset()) {
lyxerr << "can't compare cursor and anchor in different insets\n"
<< "p: " << p << '\n' << "q: " << q << endl;
- return true;
+ BOOST_ASSERT(false);
}
if (p.idx() != q.idx())
return p.idx() < q.idx();
MathAtom const & DocIterator::nextAtom() const
{
BOOST_ASSERT(!empty());
+ lyxerr << "lastpos: " << lastpos() << " next atom:\n" << *this << endl;
BOOST_ASSERT(pos() < lastpos());
return cell()[pos()];
}
MathAtom & DocIterator::nextAtom()
{
BOOST_ASSERT(!empty());
+ lyxerr << "lastpos: " << lastpos() << " next atom:\n" << *this << endl;
BOOST_ASSERT(pos() < lastpos());
return cell()[pos()];
}
lyxerr << "# InsetTabular::dispatch: cmd: " << cmd << endl;
//lyxerr << " cur:\n" << cur << endl;
CursorSlice sl = cur.top();
+ LCursor & bvcur = cur.bv().cursor();
switch (cmd.action) {
cur.selection() = false;
setPos(cur, cmd.x, cmd.y);
cur.resetAnchor();
- cur.bv().cursor().setCursor(cur, false);
+ bvcur = cur;
//if (cmd.button() == mouse_button::button2)
// dispatch(cur, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
//lyxerr << "# InsetTabular::MousePress\n" << cur.bv().cursor() << endl;
case LFUN_MOUSE_MOTION:
if (cmd.button() != mouse_button::button1)
break;
+ // ignore motions deeper nested than the real anchor
+ if (bvcur.selection() && bvcur.anchor_.size() < cur.size())
+ break;
setPos(cur, cmd.x, cmd.y);
- cur.bv().cursor().setCursor(cur, true);
- //lyxerr << "# InsetTabular::MouseMotion\n" << cur.bv().cursor() << endl;
+ bvcur.setCursor(cur, true);
+ //lyxerr << "# InsetTabular::MouseMotion\n" << bvcur << endl;
break;
case LFUN_MOUSE_RELEASE:
- //lyxerr << "# InsetTabular::MouseRelease\n" << cur.bv().cursor() << endl;
+ //lyxerr << "# InsetTabular::MouseRelease\n" << bvcur << endl;
if (cmd.button() == mouse_button::button3)
InsetTabularMailer(*this).showDialog(&cur.bv());
break;
bool InsetTabular::tablemode(LCursor & cur) const
{
- return cur.selBegin().idx() != cur.selEnd().idx();
+ return cur.selection() && cur.selBegin().idx() != cur.selEnd().idx();
}
flag.enabled(false);
}
+ //lyxerr << "LyXFunc::getStatus: got: " << flag.enabled() << endl;
return flag;
}
break;
}
- case LFUN_BREAKLINE: {
-#ifdef WITH_WARNINGS
-#warning swallow 'Return' if the minibuffer is focused. But how?
-#endif
- break;
- }
-
case LFUN_ALL_INSETS_TOGGLE: {
string action;
string const name = split(argument, action, ' ');
void MathHullInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
{
- lyxerr << "*** MathHullInset: request: " << cmd << endl;
+ //lyxerr << "*** MathHullInset: request: " << cmd << endl;
switch (cmd.action) {
case LFUN_BREAKLINE:
case LFUN_ESCAPE:
if (cur.selection())
- cur.selClear();
+ cur.clearSelection();
else
cmd = FuncRequest(LFUN_FINISHED_LEFT);
break;
if (cmd.button() == mouse_button::button2) {
MathArray ar;
asArray(cur.bv().getClipboard(), ar);
- cur.selClear();
+ cur.clearSelection();
cur.setScreenPos(cmd.x, cmd.y);
cur.insert(ar);
cur.bv().update();
if (cmd.button() == mouse_button::button1) {
first_x = cmd.x;
first_y = cmd.y;
- cur.selClear();
//cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
lyxerr << "lfunMousePress: setting cursor to: " << cur << endl;
+ cur.resetAnchor();
cur.bv().cursor() = cur;
}
first_x = cmd.x;
first_y = cmd.y;
- if (!cur.selection())
- cur.selBegin();
-
- //cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
cur.bv().cursor().setCursor(cur, true);
}
Change::Type Paragraph::lookupChange(lyx::pos_type pos) const
{
- BOOST_ASSERT(!size() || pos < size());
+ BOOST_ASSERT(empty() || pos < size());
return pimpl_->lookupChange(pos);
}
Change const Paragraph::lookupChangeFull(lyx::pos_type pos) const
{
- BOOST_ASSERT(!size() || pos < size());
+ BOOST_ASSERT(empty() || pos < size());
return pimpl_->lookupChangeFull(pos);
}
DocIterator pos = cur.selectionBegin();
DocIterator posend = cur.selectionEnd();
+ lyxerr << "pos: " << pos << " posend: " << posend << endl;
+
BufferParams const & params = bv()->buffer()->params();
- for (; pos != posend; pos.forwardChar()) {
- LyXFont f = getFont(pos.par(), pos.pos());
- f.update(font, params.language, toggleall);
- setCharFont(pos.par(), pos.pos(), f);
+ // Don't use forwardChar here as posend might have
+ // pos() == lastpos() and forwardChar would miss it.
+ for (; pos != posend; pos.forwardPos()) {
+ if (pos.pos() != pos.lastpos()) {
+ LyXFont f = getFont(pos.par(), pos.pos());
+ f.update(font, params.language, toggleall);
+ setCharFont(pos.par(), pos.pos(), f);
+ }
}
redoParagraphs(beg, end + 1);
if (sel.empty()) {
cur.insert(new MathHullInset);
- cur.dispatch(FuncRequest(LFUN_RIGHT));
+ cur.nextInset()->edit(cur, true);
cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple"));
// don't do that also for LFUN_MATH_MODE unless you want end up with
// always changing to mathrm when opening an inlined inset
lyxerr << "BufferView::Pimpl::dispatch: no selection possible\n";
break;
}
+
+ // ignore motions deeper nested than the real anchor
+ LCursor & bvcur = cur.bv().cursor();
+ if (bvcur.selection() && bvcur.anchor_.size() < cur.size())
+ break;
+
CursorSlice old = cur.top();
setCursorFromCoordinates(cur, cmd.x, cmd.y);
finishUndo();
cur.x_target() = cursorX(cur.top());
+ // Set cursor here.
+ bv->cursor() = cur;
+
+ // Don't allow selection after a big jump.
if (bv->fitCursor())
selection_possible = false;
bv->owner()->dispatch(FuncRequest(LFUN_PASTESELECTION, "paragraph"));
selection_possible = false;
}
+
break;
}