]> git.lyx.org Git - features.git/commitdiff
Fixed bug where delete/backspace like operations on selections filled the
authorJürgen Vigna <jug@sad.it>
Wed, 8 Aug 2001 14:36:56 +0000 (14:36 +0000)
committerJürgen Vigna <jug@sad.it>
Wed, 8 Aug 2001 14:36:56 +0000 (14:36 +0000)
cut'n paste buffer. Now this buffer is not touched by this operations.

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

src/BufferView.h
src/BufferView2.C
src/BufferView_pimpl.C
src/ChangeLog
src/CutAndPaste.C
src/CutAndPaste.h
src/lyxtext.h
src/text.C
src/text2.C

index 027d46cb900d352be5faf58b5f59e39ea46c3971..ff0a3ffbfef17805412131a87ed8850942a2a17a 100644 (file)
@@ -136,7 +136,7 @@ public:
        ///
        void paste();
        ///
-       void cut();
+       void cut(bool realcut = true);
        ///
        void copy();
        ///
index c7f58f9bf6bebb1f7e1b9da4c68c1e567aefc119..21f99d0e33c0625eca258e7eba5b50b82234d0e1 100644 (file)
@@ -295,12 +295,12 @@ void BufferView::copy()
 }
 
 
-void BufferView::cut()
+void BufferView::cut(bool realcut)
 {
        if (available()) {
                hideCursor();
                update(text, BufferView::SELECT|BufferView::FITCUR);
-               text->cutSelection(this);
+               text->cutSelection(this, true, realcut);
                update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                owner()->message(_("Cut"));
        }
index f8bcd15520cb494e75532812aeece4514e4fec07..d5d677604bc1c0ece3e9d1feb0432a92dc56c589 100644 (file)
@@ -2353,7 +2353,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        // just comment out the line below...
                        showCursor();
                } else {
-                       bv_->cut();
+                       bv_->cut(false);
                }
                moveCursorUpdate(false);
                owner_->showState();
@@ -2409,7 +2409,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                                       | BufferView::CHANGE);
                        }
                } else {
-                       bv_->cut();
+                       bv_->cut(false);
                }
        }
        break;
@@ -2496,7 +2496,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                                showCursor();
                        }
                } else {
-                       bv_->cut();
+                       bv_->cut(false);
                }
                owner_->showState();
                setState();
@@ -2536,7 +2536,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                                       | BufferView::CHANGE);
                        }
                } else
-                       bv_->cut();
+                       bv_->cut(false);
        }
        break;
 
@@ -3103,7 +3103,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                
                if (lyxrc.auto_region_delete) {
                        if (lt->selection.set()) {
-                               lt->cutSelection(bv_, false);
+                               lt->cutSelection(bv_, false, false);
                                bv_->update(lt,
                                            BufferView::SELECT
                                            | BufferView::FITCUR
index e8775d62e8a48d84c3bdf3ca7ea7c35ccfed9d0e..a4ad4a6f961bcdf234399c195d8129bacd449ba5 100644 (file)
@@ -1,5 +1,16 @@
 2001-08-08  Juergen Vigna  <jug@sad.it>
 
+       * BufferView_pimpl.C (Dispatch): use a non-cut-buffer cut on DELTE
+       BACKSPACE type functions.
+
+       * CutAndPaste.C (cutSelection): added a bool so that the stuff actually
+       is only cutted from the document but not put in the cut-buffer, where
+       still the old stuff should be.
+
+       * text2.C (cutSelection): added bool to pass to CutAndPaste::cutSelection.
+
+       * BufferView2.C (cut): added a bool to pass to LyXText::cutSelection.
+
        * tabular.C (SetWidthOfCell): fixed special case where the width
        was not updated!
        (LeftLine): handle '|' in align_special.
index 428c9c9980c6c5af95be30e56d4bef27e902aeee..a3c6f64d879a9c235279d93a4ccdaa2dfaed15d5 100644 (file)
@@ -73,44 +73,50 @@ void DeleteBuffer()
 
 
 bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
-                              int start, int & end, char tc, bool doclear)
+                               int start, int & end, char tc, bool doclear,
+                                                          bool realcut)
 {
        if (!startpar || (start > startpar->size()))
                return false;
        
-       DeleteBuffer();
+       if (realcut)
+               DeleteBuffer();
        
        textclass = tc;
        
-       if (!(*endpar) ||
-           startpar == (*endpar)) {
+       if (!(*endpar) || startpar == (*endpar)) {
                // only within one paragraph
-               buf = new Paragraph;
+               if (realcut)
+                       buf = new Paragraph;
                Paragraph::size_type i = start;
                if (end > startpar->size())
                        end = startpar->size();
                for (; i < end; ++i) {
-                       startpar->copyIntoMinibuffer(*current_view->buffer(),
-                                                    start);
+                       if (realcut)
+                               startpar->copyIntoMinibuffer(*current_view->buffer(),
+                                                            start);
                        startpar->erase(start);
-                       
-                       buf->insertFromMinibuffer(buf->size());
+                       if (realcut)
+                               buf->insertFromMinibuffer(buf->size());
                }
                end = start - 1;
        } else {
                // more than one paragraph
                (*endpar)->breakParagraphConservative(current_view->buffer()->params,
-                                                     end);
+                                                     end);
                *endpar = (*endpar)->next();
                end = 0;
                
                startpar->breakParagraphConservative(current_view->buffer()->params,
-                                                    start);
+                                                    start);
                
                // store the selection
-               buf = startpar->next();
-               
-               buf->previous(0);
+               if (realcut) {
+                       buf = startpar->next();
+                       buf->previous(0);
+               } else {
+                       startpar->next()->previous(0);
+               }
                (*endpar)->previous()->next(0);
                
                // cut the selection
@@ -119,7 +125,8 @@ bool CutAndPaste::cutSelection(Paragraph * startpar, Paragraph ** endpar,
                (*endpar)->previous(startpar);
                
                // the cut selection should begin with standard layout
-               buf->clear(); 
+               if (realcut)
+                       buf->clear(); 
                
                // paste the paragraphs again, if possible
                if (doclear)
index 173de5ce75c5384edb4b8a532b53fd7929aa8434..13ff9ed33db059c5371f550828d93cbd0a26c98f 100644 (file)
@@ -25,7 +25,8 @@ public:
        ///
        static
        bool cutSelection(Paragraph * startpar, Paragraph ** endpar,
-                      int start, int & end, char tc, bool doclear = false);
+                      int start, int & end, char tc, bool doclear = false,
+                                         bool realcut = true);
        ///
        static
        bool copySelection(Paragraph * startpar, Paragraph * endpar,
index 440ad32691ce6931865c26c7a2bcbe78bc1afd65..a3d5f0930be39ae043e86f882994df7a4af64585 100644 (file)
@@ -397,7 +397,7 @@ public:
        /// 
        void toggleInset(BufferView *);
        ///
-       void cutSelection(BufferView *, bool = true);
+       void cutSelection(BufferView *, bool doclear = true, bool realcut = true);
        ///
        void copySelection(BufferView *);
        ///
index 1c13e8eb9e1321f3b826146301fe216058e9d069..0d49609619f92bb7c0c5531caa6230e4a914e34a 100644 (file)
@@ -2400,10 +2400,10 @@ void LyXText::deleteWordForward(BufferView * bview)
                setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos());
                selection.cursor = cursor;
                cursor = tmpcursor;
-               setSelection(bview); 
+               setSelection(bview);
                
                /* -----> Great, CutSelection() gets rid of multiple spaces. */
-               cutSelection(bview);
+               cutSelection(bview, true, false);
        }
 }
 
@@ -2422,7 +2422,7 @@ void LyXText::deleteWordBackward(BufferView * bview)
               selection.cursor = cursor;
               cursor = tmpcursor;
               setSelection(bview);
-              cutSelection(bview);
+              cutSelection(bview, true, false);
        }
 }
 
@@ -2448,7 +2448,7 @@ void LyXText::deleteLineForward(BufferView * bview)
                if (!selection.set()) {
                        deleteWordForward(bview);
                } else {
-                       cutSelection(bview);
+                       cutSelection(bview, true, false);
                }
        }
 }
@@ -2576,7 +2576,9 @@ void LyXText::Delete(BufferView * bview)
        if ((cursor.par()->previous() ? cursor.par()->previous()->id() : 0)
            == old_cur_par_prev_id
            && cursor.par()->id() != old_cur_par_id)
+       {
                return; // delete-empty-paragraph-mechanism has done it
+       }
 
        // if you had success make a backspace
        if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
@@ -2639,8 +2641,7 @@ void LyXText::backspace(BufferView * bview)
 
                if (cursor.par()->previous()) {
                        setUndo(bview, Undo::DELETE,
-                               cursor.par()->previous(),
-                               cursor.par()->next());
+                               cursor.par()->previous(), cursor.par()->next());
                }
                
                Paragraph * tmppar = cursor.par();
@@ -2653,8 +2654,8 @@ void LyXText::backspace(BufferView * bview)
                if (cursor.par()->previous()) { 
                        // steps into the above paragraph.
                        setCursorIntern(bview, cursor.par()->previous(),
-                                       cursor.par()->previous()->size(),
-                                       false);
+                                       cursor.par()->previous()->size(),
+                                       false);
                }
 
                /* Pasting is not allowed, if the paragraphs have different
@@ -2670,8 +2671,8 @@ void LyXText::backspace(BufferView * bview)
                if (cursor.par() != tmppar
                    && (cursor.par()->getLayout() == tmppar->getLayout()
                        || tmppar->getLayout() == 0 /*standard*/)
-                   && cursor.par()->getAlign() == tmppar->getAlign()) {
-
+                   && cursor.par()->getAlign() == tmppar->getAlign())
+               {
                        removeParagraph(tmprow);
                        removeRow(tmprow);
                        cursor.par()->pasteParagraph(bview->buffer()->params);
@@ -2708,13 +2709,13 @@ void LyXText::backspace(BufferView * bview)
                /* this is the code for a normal backspace, not pasting
                 * any paragraphs */ 
                setUndo(bview, Undo::DELETE,
-                       cursor.par(), cursor.par()->next()); 
+                       cursor.par(), cursor.par()->next()); 
                // We used to do cursorLeftIntern() here, but it is
                // not a good idea since it triggers the auto-delete
                // mechanism. So we do a cursorLeftIntern()-lite,
                // without the dreaded mechanism. (JMarc)
                setCursorIntern(bview, cursor.par(), cursor.pos()- 1,
-                               false, cursor.boundary());
+                               false, cursor.boundary());
                
                // some insets are undeletable here
                if (cursor.par()->getChar(cursor.pos()) == Paragraph::META_INSET) {
@@ -2738,8 +2739,8 @@ void LyXText::backspace(BufferView * bview)
                if (cursor.pos() < rowLast(row) ||
                    !cursor.par()->isLineSeparator(cursor.pos())) {
                        row->fill(row->fill() + singleWidth(bview,
-                                                           cursor.par(),
-                                                           cursor.pos()));
+                                                           cursor.par(),
+                                                           cursor.pos()));
                }
                
                /* some special code when deleting a newline. This is similar
index d7a122f79bfa3bda057b80bab469fb4ea3ff8f25..7d4172e5ffa6ec01b3b3288919ac3e4d24653bf4 100644 (file)
@@ -1663,7 +1663,7 @@ void LyXText::pasteEnvironmentType(BufferView * bview)
 }
 
 
-void LyXText::cutSelection(BufferView * bview, bool doclear)
+void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut)
 {
        // Stuff what we got on the clipboard. Even if there is no selection.
 
@@ -1705,15 +1705,17 @@ void LyXText::cutSelection(BufferView * bview, bool doclear)
                endpar = selection.end.par();
                int pos = selection.end.pos();
                CutAndPaste::cutSelection(selection.start.par(), &endpar,
-                                         selection.start.pos(), pos,
-                                         bview->buffer()->params.textclass, doclear);
+                                         selection.start.pos(), pos,
+                                         bview->buffer()->params.textclass, doclear,
+                                         realcut);
                selection.end.pos(pos);
        } else {
                endpar = selection.end.par();
                int pos = selection.end.pos();
                CutAndPaste::cutSelection(selection.start.par(), &endpar,
-                                         selection.start.pos(), pos,
-                                         bview->buffer()->params.textclass, doclear);
+                                         selection.start.pos(), pos,
+                                         bview->buffer()->params.textclass, doclear,
+                                                                 realcut);
                cursor.par(endpar);
                selection.end.par(endpar);
                selection.end.pos(pos);
@@ -1845,7 +1847,7 @@ void LyXText::replaceSelectionWithString(BufferView * bview,
        }
        
        // Cut the selection
-       cutSelection(bview);
+       cutSelection(bview, true, false);
 
        unFreezeUndo();
 }
@@ -2138,18 +2140,23 @@ void LyXText::setCursorIntern(BufferView * bview, Paragraph * par,
 {
        InsetText * it = static_cast<InsetText *>(par->inInset());
        if (it) {
-               lyxerr << "InsetText   is " << it << endl;
-               lyxerr << "inset_owner is " << inset_owner << endl;
                if (it != inset_owner) {
+                       lyxerr << "InsetText   is " << it << endl;
+                       lyxerr << "inset_owner is " << inset_owner << endl;
 #warning I belive this code is wrong. (Lgb)
 #warning Jürgen, have a look at this. (Lgb)
+#warning Hmmm, I guess you are right but we
+#warning should verify when this is needed
                        // Jürgen, would you like to have a look?
                        // I guess we need to move the outer cursor
                        // and open and lock the inset (bla bla bla)
                        // stuff I don't know... so can you have a look?
                        // (Lgb)
+                       // I moved the lyxerr stuff in here so we can see if this
+                       // is actually really needed and where!
+                       // (Jug)
                        it->getLyXText(bview)->setCursorIntern(bview, par, pos, setfont,
-                                                              boundary);
+                                                              boundary);
                        return;
                }
        }