From 961b1a47ed2621b4f126580031bbe9f999c2c4fd Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Mon, 18 Mar 2002 13:47:37 +0000 Subject: [PATCH] Find selection inside InsetText and always leave pasted text selected. (fix #100, #35) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3763 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView2.C | 10 +++++++--- src/BufferView_pimpl.C | 31 ++++++++++++++++++------------- src/ChangeLog | 13 +++++++++++++ src/text2.C | 6 ++++-- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/BufferView2.C b/src/BufferView2.C index 247290b26b..1ef20a9936 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -393,7 +393,7 @@ void BufferView::pasteEnvironment() void BufferView::copy() { if (available()) { - text->copySelection(this); + getLyXText()->copySelection(this); owner()->message(_("Copy")); } } @@ -413,7 +413,8 @@ void BufferView::cut(bool realcut) void BufferView::paste() { - if (!available()) return; + if (!available()) + return; owner()->message(_("Paste")); @@ -426,11 +427,14 @@ void BufferView::paste() // paste text->pasteSelection(this); 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 } diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index b0521442c7..15eaec939d 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -589,7 +589,8 @@ void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state) void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, unsigned int button) { - if (!buffer_ || !screen_.get()) return; + if (!buffer_ || !screen_.get()) + return; Inset * inset_hit = checkInsetHit(bv_->text, xpos, ypos); @@ -605,6 +606,16 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, } } + // 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 + // we have to check this first + bool paste_internally = false; + if (button == 2 && bv_->getLyXText()->selection.set()) { + owner_->getLyXFunc()->dispatch(LFUN_COPY); + paste_internally = true; + } + if (bv_->theLockingInset()) { // We are in inset locking mode @@ -625,14 +636,6 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, int const screen_first = bv_->text->first_y; - // Middle button press pastes if we have a selection - bool paste_internally = false; - if (button == 2 - && bv_->text->selection.set()) { - owner_->getLyXFunc()->dispatch(LFUN_COPY); - paste_internally = true; - } - // Clear the selection screen_->toggleSelection(bv_->text, bv_); bv_->text->clearSelection(); @@ -679,7 +682,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, owner_->getLyXFunc()->dispatch(LFUN_PASTE); else owner_->getLyXFunc()->dispatch(LFUN_PASTESELECTION, - "paragraph"); + "paragraph"); selection_possible = false; return; } @@ -1388,14 +1391,16 @@ void BufferView::Pimpl::center() void BufferView::Pimpl::pasteClipboard(bool asPara) { - if (!buffer_) return; + if (!buffer_) + return; screen_->hideCursor(); beforeChange(bv_->text); string const clip(workarea_.getClipboard()); - if (clip.empty()) return; + if (clip.empty()) + return; if (asPara) { bv_->getLyXText()->insertStringAsParagraphs(bv_, clip); @@ -1574,7 +1579,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_PASTESELECTION: { - bool asPara = false; + bool asPara = false; if (argument == "paragraph") asPara = true; pasteClipboard(asPara); diff --git a/src/ChangeLog b/src/ChangeLog index feae4c52d9..e865935982 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2002-03-18 Juergen Vigna + + * BufferView2.C (copy): use getLyXText() so that we do it inside an + inset if we're there actually (probably not used right now but this + is the direction to go for unifying code). + (paste): disable code to clear the selection. + + * BufferView_pimpl.C (workAreaButtonPress): check also for a selection + inside an InsetText and move the check further up as it is in the + wrong place. + + * text2.C (pasteSelection): set a selection over the pasted text. + 2002-03-14 Kayvan A. Sylvan * Makefile.am (lyx_DEPENDENCIES): Swap the order of libfrontend diff --git a/src/text2.C b/src/text2.C index 7f8404d7c8..8f4b20b779 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1793,14 +1793,16 @@ void LyXText::pasteSelection(BufferView * bview) int pos = cursor.pos(); CutAndPaste::pasteSelection(&actpar, &endpar, pos, - bview->buffer()->params.textclass); + bview->buffer()->params.textclass); redoParagraphs(bview, cursor, endpar); setCursor(bview, cursor.par(), cursor.pos()); clearSelection(); - + + selection.cursor = cursor; setCursor(bview, actpar, pos); + setSelection(bview); updateCounters(bview, cursor.row()); } -- 2.39.5