move cut&paste lfun handling from BufferView to LyXText

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5112 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-08-26 13:25:49 +00:00
parent c85b8791ae
commit 17b41b1655
6 changed files with 51 additions and 92 deletions

View File

@ -130,12 +130,6 @@ public:
///
bool gotoLabel(string const & label);
///
void paste();
///
void cut(bool realcut = true);
///
void copy();
///
void pasteEnvironment();
///
void copyEnvironment();

View File

@ -391,57 +391,7 @@ void BufferView::pasteEnvironment()
}
void BufferView::copy()
{
if (available()) {
getLyXText()->copySelection(this);
owner()->message(_("Copy"));
}
}
void BufferView::cut(bool realcut)
{
if (available()) {
hideCursor();
update(text, BufferView::SELECT|BufferView::FITCUR);
text->cutSelection(this, true, realcut);
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
owner()->message(_("Cut"));
}
}
void BufferView::paste()
{
if (!available())
return;
owner()->message(_("Paste"));
hideCursor();
// clear the selection
toggleSelection();
text->clearSelection();
update(text, BufferView::SELECT|BufferView::FITCUR);
// paste
text->pasteSelection(this);
// bug 393
text->clearSelection();
update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
// why fake a selection only I think it should be a real one and not only
// a painted one (Jug 20020318).
#if 0
// clear the selection
toggleSelection();
text->clearSelection();
update(text, BufferView::SELECT|BufferView::FITCUR);
#endif
}
/* these functions are for the spellchecker */
// these functions are for the spellchecker
WordLangTuple const BufferView::nextWord(float & value)
{
if (!available()) {

View File

@ -1442,19 +1442,6 @@ bool BufferView::Pimpl::dispatch(FuncRequest const & ev)
break;
}
case LFUN_PASTE:
bv_->paste();
switchKeyMap();
break;
case LFUN_CUT:
bv_->cut();
break;
case LFUN_COPY:
bv_->copy();
break;
case LFUN_LAYOUT_COPY:
bv_->copyEnvironment();
break;

View File

@ -3,6 +3,11 @@
* paragraph.[Ch]: Martin's patch for the \end_deeper bug
* BufferView.h:
* BufferView2.C:
* BufferView_pimpl.C:
* text3.C: mun hanfling of LFUN_CUT/COPY/PASTE to LyXText
2002-08-25 John Levon <levon@movementarian.org>
* LyXAction.C: fix margin note description

View File

@ -395,21 +395,10 @@ void MathCursor::insert(MathArray const & ar)
macroModeClose();
if (selection_)
eraseSelection();
array().insert(pos(), ar);
pos() += ar.size();
}
/*
void MathCursor::paste(MathArray const & ar)
{
Anchor_ = Cursor_;
selection_ = true;
array().insert(pos(), ar);
pos() += ar.size();
}
*/
void MathCursor::paste(MathGridInset const & data)
{

View File

@ -485,7 +485,9 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
// just comment out the line below...
bv->showCursor();
} else {
bv->cut(false);
update(bv, false);
cutSelection(bv, true);
update(bv);
}
bv->moveCursorUpdate(false);
bv->owner()->view_state_changed();
@ -518,15 +520,16 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
cursorLeft(bv);
Delete(bv);
selection.cursor = cursor;
update(bv);
}
} else {
Delete(bv);
selection.cursor = cursor;
update(bv);
}
} else
bv->cut(false);
} else {
update(bv, false);
cutSelection(bv, true);
}
update(bv);
break;
@ -540,8 +543,11 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
// just comment out the line below...
bv->showCursor();
}
} else
bv->cut(false);
} else {
update(bv, false);
cutSelection(bv, true);
update(bv);
}
bv->owner()->view_state_changed();
bv->switchKeyMap();
break;
@ -562,14 +568,15 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
cur.par()->params().spacing(),
cur.par()->params().align(),
cur.par()->params().labelWidthString(), 0);
update(bv);
} else {
backspace(bv);
selection.cursor = cur;
update(bv);
}
} else
bv->cut(false);
} else {
update(bv, false);
cutSelection(bv, true);
}
update(bv);
break;
case LFUN_BREAKPARAGRAPH:
@ -769,6 +776,33 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
update(bv);
break;
case LFUN_PASTE:
cmd.message(_("Paste"));
bv->hideCursor();
// clear the selection
bv->toggleSelection();
clearSelection();
update(bv, false);
pasteSelection(bv);
clearSelection(); // bug 393
update(bv, false);
update(bv);
bv->switchKeyMap();
break;
case LFUN_CUT:
bv->hideCursor();
update(bv, false);
cutSelection(bv, true);
update(bv);
cmd.message(_("Cut"));
break;
case LFUN_COPY:
copySelection(bv);
cmd.message(_("Copy"));
break;
case LFUN_BEGINNINGBUFSEL:
if (inset_owner)
return Inset::UNDISPATCHED;