a bit of selection is back

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8415 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2004-02-06 16:50:29 +00:00
parent 67f9c9fdae
commit 299b6e315a
4 changed files with 39 additions and 50 deletions

View File

@ -890,7 +890,9 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
cmd.y += bv_->top_y();
//lyxerr << "*** workAreaDispatch: request: " << cmd << std::endl;
LCursor cur(*bv_);
cur.selection() = bv_->cursor().selection();
switch (cmd.action) {
#if 0
case LFUN_MOUSE_MOTION: {
if (!available())
@ -910,9 +912,10 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
}
return true;
}
#else
case LFUN_MOUSE_MOTION:
#endif
case LFUN_MOUSE_MOTION:
case LFUN_MOUSE_PRESS:
case LFUN_MOUSE_RELEASE:
case LFUN_MOUSE_DOUBLE:

View File

@ -80,12 +80,10 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
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()) {
@ -108,8 +106,6 @@ DispatchResult LCursor::dispatch(FuncRequest const & cmd0)
}
}
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;
@ -736,10 +732,11 @@ void LCursor::selClearOrDel()
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;
}

View File

@ -803,7 +803,6 @@ MathNestInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd)
void MathNestInset::edit(LCursor & cur, bool left)
{
lyxerr << "XXX Called MathNestInset::edit" << endl;
cur.push(this);
cur.idx() = left ? 0 : cur.lastidx();
cur.pos() = left ? 0 : cur.lastpos();
@ -813,8 +812,6 @@ void MathNestInset::edit(LCursor & cur, bool left)
void MathNestInset::edit(LCursor & cur, int x, int y)
{
lyxerr << "XXX Called MathNestInset::edit with '"
<< x << ' ' << y << "'" << endl;
int idx_min = 0;
int dist_min = 1000000;
for (idx_type i = 0; i < nargs(); ++i) {
@ -911,7 +908,8 @@ MathNestInset::lfunMouseMotion(LCursor & cur, FuncRequest const & cmd)
if (!cur.selection())
cur.selBegin();
cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
cur.bv().update();
//cur.setScreenPos(cmd.x + xo_, cmd.y + yo_);
cur.bv().cursor().cursor_ = cur.cursor_;
cur.bv().cursor().selection() = true;
return DispatchResult(true, true);
}

View File

@ -587,15 +587,12 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
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());
if (cursor().pos() > cursorPar()->beginOfBody()) {
replaceSelection(this);
insertInset(new InsetNewline);
moveCursor(cur, false);
}
break;
}
@ -661,7 +658,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
break;
case LFUN_BREAKPARAGRAPH:
replaceSelection(bv->getLyXText());
replaceSelection(this);
breakParagraph(bv->buffer()->paragraphs(), 0);
bv->update();
cur.resetAnchor();
@ -670,7 +667,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
break;
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
replaceSelection(bv->getLyXText());
replaceSelection(this);
breakParagraph(bv->buffer()->paragraphs(), 1);
bv->update();
cur.resetAnchor();
@ -684,7 +681,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
// 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(
@ -824,7 +821,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
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));
@ -985,7 +982,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
}
case LFUN_QUOTE: {
replaceSelection(bv->getLyXText());
replaceSelection(this);
ParagraphList::iterator pit = cursorPar();
lyx::pos_type pos = cursor().pos();
char c;
@ -1008,7 +1005,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
}
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, "");
@ -1030,7 +1027,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
}
case LFUN_MOUSE_TRIPLE:
if (bv->buffer() && cmd.button() == mouse_button::button1) {
if (cmd.button() == mouse_button::button1) {
selection_possible = true;
cursorHome();
cur.resetAnchor();
@ -1041,7 +1038,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
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());
@ -1049,15 +1046,9 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
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
@ -1068,6 +1059,7 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
}
RowList::iterator cursorrow = cursorRow();
#warning
setCursorFromCoordinates(cmd.x, cmd.y);
// This is to allow jumping over large insets
@ -1078,16 +1070,16 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
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
@ -1096,11 +1088,19 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
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
@ -1116,12 +1116,6 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
// 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();
@ -1148,9 +1142,6 @@ DispatchResult LyXText::dispatch(LCursor & cur, FuncRequest const & cmd)
}
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)