]> git.lyx.org Git - features.git/commitdiff
Find selection inside InsetText and always leave pasted text selected.
authorJürgen Vigna <jug@sad.it>
Mon, 18 Mar 2002 13:47:37 +0000 (13:47 +0000)
committerJürgen Vigna <jug@sad.it>
Mon, 18 Mar 2002 13:47:37 +0000 (13:47 +0000)
(fix #100, #35)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3763 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView2.C
src/BufferView_pimpl.C
src/ChangeLog
src/text2.C

index 247290b26bf7724ef8e3b60506c4ffb397d78fec..1ef20a99368a771ba917a63f9522a6cbf20ec579 100644 (file)
@@ -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
 }
 
 
index b0521442c73616c3809040c9da1ea7092b9f8c3e..15eaec939dcc6eca32ed40a8c44a53d099309276 100644 (file)
@@ -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);
index feae4c52d9186fb780f2815fb75199a012561501..e8659359821aa593f631dd4b15a0117345350760 100644 (file)
@@ -1,3 +1,16 @@
+2002-03-18  Juergen Vigna  <jug@sad.it>
+
+       * 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  <kayvan@sylvan.com>
 
        * Makefile.am (lyx_DEPENDENCIES): Swap the order of libfrontend
index 7f8404d7c8ed3bddf163fb623382e16f5acba80a..8f4b20b7794df8bd24c4abb1140c8635c80fd5bd 100644 (file)
@@ -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());
 }