lyxerr << "\nLCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
FuncRequest cmd = cmd0;
for (current_ = cursor_.size() - 1; current_ >= 1; --current_) {
- lyxerr << "trying to dispatch to inset " << inset() << endl;
DispatchResult res = inset()->dispatch(*this, cmd);
- if (res.dispatched()) {
- lyxerr << " successfully dispatched to inset " << inset() << endl;
+ if (res.dispatched())
return DispatchResult(true, true);
- }
+
// "Mutate" the request for semi-handled requests that need
// additional handling in outer levels.
switch (res.val()) {
}
}
BOOST_ASSERT(current_ == 0);
- //lyxerr << "trying to dispatch to main text " << bv_->text()
- // << " with cursor: " << *this << endl;
DispatchResult res = bv_->text()->dispatch(*this, cmd);
//lyxerr << " result: " << res.val() << endl;
return res;
std::ostream & operator<<(std::ostream & os, LCursor const & cur)
{
- os << "\n";
for (size_t i = 0, n = cur.cursor_.size(); i != n; ++i)
os << " (" << cur.cursor_[i] << " | " << cur.anchor_[i] << "\n";
- return os << "current: " << cur.current_ << endl;
+ os << " current: " << cur.current_ << endl;
+ os << " selection: " << cur.selection_ << endl;
+ return os;
}
break;
case LFUN_BREAKLINE: {
- lyx::pos_type body = cursorPar()->beginOfBody();
-
// Not allowed by LaTeX (labels or empty par)
- if (cursor().pos() <= body)
- break;
-
- replaceSelection(bv->getLyXText());
- insertInset(new InsetNewline);
- moveCursor(cur, false);
+ if (cursor().pos() > cursorPar()->beginOfBody()) {
+ replaceSelection(this);
+ insertInset(new InsetNewline);
+ moveCursor(cur, false);
+ }
break;
}
break;
case LFUN_BREAKPARAGRAPH:
- replaceSelection(bv->getLyXText());
+ replaceSelection(this);
breakParagraph(bv->buffer()->paragraphs(), 0);
bv->update();
cur.resetAnchor();
break;
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
- replaceSelection(bv->getLyXText());
+ replaceSelection(this);
breakParagraph(bv->buffer()->paragraphs(), 1);
bv->update();
cur.resetAnchor();
// Otherwise, do the same as LFUN_BREAKPARAGRAPH.
#warning look here
// CursorSlice cur = cursor();
- replaceSelection(bv->getLyXText());
+ replaceSelection(this);
if (cur.pos() == 0) {
ParagraphParameters & params = getPar(cur.current())->params();
setParagraph(
case LFUN_PASTE:
cur.message(_("Paste"));
- replaceSelection(bv->getLyXText());
+ replaceSelection(this);
#warning FIXME Check if the arg is in the domain of available selections.
if (isStrUnsignedInt(cmd.argument))
pasteSelection(strToUnsignedInt(cmd.argument));
}
case LFUN_QUOTE: {
- replaceSelection(bv->getLyXText());
+ replaceSelection(this);
ParagraphList::iterator pit = cursorPar();
lyx::pos_type pos = cursor().pos();
char c;
}
case LFUN_DATE_INSERT: {
- replaceSelection(bv->getLyXText());
+ replaceSelection(this);
time_t now_time_t = time(NULL);
struct tm * now_tm = localtime(&now_time_t);
setlocale(LC_TIME, "");
}
case LFUN_MOUSE_TRIPLE:
- if (bv->buffer() && cmd.button() == mouse_button::button1) {
+ if (cmd.button() == mouse_button::button1) {
selection_possible = true;
cursorHome();
cur.resetAnchor();
break;
case LFUN_MOUSE_DOUBLE:
- if (bv->buffer() && cmd.button() == mouse_button::button1) {
+ if (cmd.button() == mouse_button::button1) {
selection_possible = true;
selectWord(lyx::WHOLE_WORD_STRICT);
bv->haveSelection(cur.selection());
break;
case LFUN_MOUSE_MOTION: {
-#if 0
// Only use motion with button 1
//if (ev.button() != mouse_button::button1)
// return false;
- // don't set anchor_
- bv->cursor().cursor_ = cur.cursor_;
-
- if (!bv->buffer())
- break;
// The test for not selection possible is needed, that
// only motion events are used, where the bottom press
// event was on the drawing area too
}
RowList::iterator cursorrow = cursorRow();
+#warning
setCursorFromCoordinates(cmd.x, cmd.y);
// This is to allow jumping over large insets
else if (cmd.y - bv->top_y() < 0)
cursorUp(true);
}
- cur.setSelection();
-#endif
+
+ // don't set anchor_
+ bv->cursor().cursor_ = cur.cursor_;
+ bv->cursor().setSelection();
+
break;
}
// Single-click on work area
case LFUN_MOUSE_PRESS: {
- if (!bv->buffer())
- break;
-
// ok ok, this is a hack (for xforms)
// We shouldn't go further down as we really should only do the
// scrolling and be done with this. Otherwise we may open some
bv->scroll(-lyxrc.wheel_jump);
break;
}
+
if (cmd.button() == mouse_button::button5) {
bv->scroll(lyxrc.wheel_jump);
break;
}
+ // Right click on a footnote flag opens float menu
+ if (cmd.button() == mouse_button::button3) {
+ cur.clearSelection();
+ selection_possible = false;
+ break;
+ }
+
// Middle button press pastes if we have a selection
// We do this here as if the selection was inside an inset
// it could get cleared on the unlocking of the inset so
// Clear the selection
cur.clearSelection();
- // Right click on a footnote flag opens float menu
- if (cmd.button() == mouse_button::button3) {
- selection_possible = false;
- break;
- }
-
setCursorFromCoordinates(cur.current(), cmd.x - xo_,
cmd.y - yo_);
cur.resetAnchor();
}
case LFUN_MOUSE_RELEASE: {
- if (!bv->buffer())
- break;
-
// do nothing if we used the mouse wheel
if (cmd.button() == mouse_button::button4
|| cmd.button() == mouse_button::button5)