Hi,

here's an IDEA for a bugfixing patch. It SEEMS to fix the
delete-does-actually-cut problem. I figured it out with some trial'n'error
hacking. You have been warned. So if necessary, improve the code before
applying this.

There are, e.g., several CutCB calls in lyxfunc.C I don't understand, so I
don't know if they should cut or delete...

BTW, there's another bug with cut&paste: if you have text selected and
type somthing, the selection is replaced by with what you typed. But if
you paste something, it does not replace the current selection. If I find
time, I will try to fix that.

Regards
 Daniel
 
-- 
PGP Key fingerprint = 3D 98 9E D2 00 B6 E0 9D  7E B9 77 23 17 E2 11 6A
http://cgi4all.alabanza.com/glasatelier/
diff -ur lyx1.0.0/src/lyx_cb.C lyx/src/lyx_cb.C
--- lyx1.0.0/src/lyx_cb.C       Sun Jan 31 18:19:38 1999
+++ lyx/src/lyx_cb.C    Thu Feb  4 22:05:55 1999
@@ -2230,12 +2230,12 @@
 }
 
 
-void CutCB()
+void CutCB(bool keep_copy)
 {
        if (current_view->available()) {
                current_view->getScreen()->HideCursor();
                current_view->currentBuffer()->update(-2);
-               current_view->currentBuffer()->text->CutSelection();
+               current_view->currentBuffer()->text->CutSelection(keep_copy);
                current_view->currentBuffer()->update(1);
                minibuffer->Set(_("Cut"));
        }
diff -ur lyx1.0.0/src/lyx_cb.h lyx/src/lyx_cb.h
--- lyx1.0.0/src/lyx_cb.h       Mon Oct 26 23:18:18 1998
+++ lyx/src/lyx_cb.h    Thu Feb  4 22:05:10 1999
@@ -37,7 +37,7 @@
 ///
 extern void FreeCB();
 ///
-extern void CutCB();
+extern void CutCB(bool keep_copy = true);
 ///
 extern void PasteCB();
 ///
diff -ur lyx1.0.0/src/lyxfunc.C lyx/src/lyxfunc.C
--- lyx1.0.0/src/lyxfunc.C      Sun Jan 31 18:19:40 1999
+++ lyx/src/lyxfunc.C   Thu Feb  4 22:07:29 1999
@@ -1703,7 +1703,7 @@
                                owner->currentView()->getScreen()->ShowCursor();
                        }
                } else {
-                       CutCB();
+                       CutCB(false);
                }
                SetUpdateTimer();
        }
diff -ur lyx1.0.0/src/lyxtext.h lyx/src/lyxtext.h
--- lyx1.0.0/src/lyxtext.h      Tue Dec 29 14:13:35 1998
+++ lyx/src/lyxtext.h   Thu Feb  4 21:59:23 1999
@@ -298,7 +298,7 @@
        ///
        void MeltFootnoteEnvironment();
        ///
-       void CutSelection(bool = true);
+       void CutSelection(bool keep_copy = true, bool = false);
        ///
        void CopySelection();
        ///
diff -ur lyx1.0.0/src/text2.C lyx/src/text2.C
--- lyx1.0.0/src/text2.C        Mon Feb  1 19:36:44 1999
+++ lyx/src/text2.C     Thu Feb  4 22:04:40 1999
@@ -1754,7 +1754,7 @@
 }
 
 
-void LyXText::CutSelection(bool doclear)
+void LyXText::CutSelection(bool keep_copy, bool doclear)
 {
        /* This doesn't make sense, if there is no selection */ 
        if (!selection) {
@@ -1807,11 +1807,12 @@
                sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->previous, 
                undoendpar);
    
-       /* delete the simple_cut_buffer */ 
-       DeleteSimpleCutBuffer();
-   
-       /* set the textclass */
-       simple_cut_buffer_textclass = parameters->textclass;
+       if( keep_copy ) {
+               /* delete the simple_cut_buffer */ 
+               DeleteSimpleCutBuffer();
+               /* set the textclass */
+               simple_cut_buffer_textclass = parameters->textclass;
+       }
 
 #ifdef WITH_WARNINGS
 #warning Asger: Make cut more intelligent here.
@@ -1857,19 +1858,23 @@
        if (sel_start_cursor.par->ParFromPos(sel_start_cursor.pos) 
            == sel_end_cursor.par->ParFromPos(sel_end_cursor.pos)) {
                /* only within one paragraph */
-               simple_cut_buffer = new LyXParagraph();
+               if( keep_copy )
+                       simple_cut_buffer = new LyXParagraph();
                for (i=sel_start_cursor.pos; i< sel_end_cursor.pos; i++){
                        /* table stuff -- begin*/
                        if (sel_start_cursor.par->table
                            && sel_start_cursor.par->IsNewline(sel_start_cursor.pos)){
-                               
sel_start_cursor.par->CopyIntoMinibuffer(sel_start_cursor.pos);
+                               if( keep_copy )
+                                       
+sel_start_cursor.par->CopyIntoMinibuffer(sel_start_cursor.pos);
                                sel_start_cursor.pos++;
                        } else {
                                /* table stuff -- end*/
-                               
sel_start_cursor.par->CopyIntoMinibuffer(sel_start_cursor.pos);
+                               if( keep_copy )
+                                       
+sel_start_cursor.par->CopyIntoMinibuffer(sel_start_cursor.pos);
                                sel_start_cursor.par->Erase(sel_start_cursor.pos);
                        }
-                       
simple_cut_buffer->InsertFromMinibuffer(simple_cut_buffer->Last());
+                       if( keep_copy )
+                               
+simple_cut_buffer->InsertFromMinibuffer(simple_cut_buffer->Last());
                }
                /* check for double spaces */
                if (sel_start_cursor.pos &&
@@ -1878,9 +1883,11 @@
                    sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos)){
                        sel_start_cursor.par->Erase(sel_start_cursor.pos);
                }
-               if (space_wrapped)
-                       simple_cut_buffer->InsertChar(i - sel_start_cursor.pos, ' ');
-               endpar = sel_end_cursor.par->Next();
+               if( keep_copy ) {
+                       if (space_wrapped)
+                               simple_cut_buffer->InsertChar(i - 
+sel_start_cursor.pos, ' ');
+                       endpar = sel_end_cursor.par->Next();
+               }
        }
        else {
                /* cut more than one paragraph */ 
@@ -1893,30 +1900,35 @@
                sel_end_cursor.par = sel_end_cursor.par->Next();
                sel_end_cursor.pos = 0;
    
-               cursor = sel_end_cursor;
+               if( keep_copy ) {
+                       cursor = sel_end_cursor;
    
-               /* please break behind a space, if there is one. The space should
-                * be copied too */ 
-               if (sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos))
-                       sel_start_cursor.pos++;
+                       /* please break behind a space, if there is one. The space 
+should
+                        * be copied too */ 
+                       if 
+(sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos))
+                               sel_start_cursor.pos++;
+               }
    
                sel_start_cursor.par->BreakParagraphConservative(sel_start_cursor.pos);
-               if (!sel_start_cursor.pos
-                   || sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos - 1)
-                   || sel_start_cursor.par->IsNewline(sel_start_cursor.pos - 1)) {
-                       sel_start_cursor.par->Next()->InsertChar(0, ' ');
-               }
-   
-               /* store the endparagraph for redoing later */
-               endpar = sel_end_cursor.par->Next();   /* needed because
-                                                       * the sel_end_
-                                                       * cursor.par
-                                                       * will be pasted!*/
-   
-               /*store the selection */ 
-               simple_cut_buffer = 
sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->next;
-               simple_cut_buffer->previous = NULL;
-               sel_end_cursor.par->previous->next = NULL;
+
+               if( keep_copy ) {
+                       if (!sel_start_cursor.pos
+                       || sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos 
+- 1)
+                       || sel_start_cursor.par->IsNewline(sel_start_cursor.pos - 1)) {
+                               sel_start_cursor.par->Next()->InsertChar(0, ' ');
+                       }
+
+                       /* store the endparagraph for redoing later */
+                       endpar = sel_end_cursor.par->Next();   /* needed because
+                                                               * the sel_end_
+                                                               * cursor.par
+                                                               * will be pasted!*/
+
+                       /*store the selection */ 
+                       simple_cut_buffer = 
+sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->next;
+                       simple_cut_buffer->previous = NULL;
+                       sel_end_cursor.par->previous->next = NULL;
+               }
 
                /* cut the selection */ 
                sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->next 
@@ -1926,24 +1938,26 @@
                        = sel_start_cursor.par->ParFromPos(sel_start_cursor.pos);
 
                /* care about footnotes */
-               if (simple_cut_buffer->footnoteflag) {
-                       LyXParagraph *tmppar = simple_cut_buffer;
-                       while (tmppar){
-                               tmppar->footnoteflag = LyXParagraph::NO_FOOTNOTE;
-                               tmppar = tmppar->next;
+               if( keep_copy ) {
+                       if (simple_cut_buffer->footnoteflag) {
+                               LyXParagraph *tmppar = simple_cut_buffer;
+                               while (tmppar){
+                                       tmppar->footnoteflag = 
+LyXParagraph::NO_FOOTNOTE;
+                                       tmppar = tmppar->next;
+                               }
                        }
-               }
 
-               /* the cut selection should begin with standard layout */
-               simple_cut_buffer->Clear(); 
-   
-               /* paste the paragraphs again, if possible  */
-               if (doclear)
-                       sel_start_cursor.par->Next()->ClearParagraph();
-               if 
(sel_start_cursor.par->FirstPhysicalPar()->HasSameLayout(sel_start_cursor.par->Next())
-                   || 
-                   !sel_start_cursor.par->Next()->Last())
-                       
sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->PasteParagraph();
+                       /* the cut selection should begin with standard layout */
+                       simple_cut_buffer->Clear(); 
+
+                       /* paste the paragraphs again, if possible  */
+                       if (doclear)
+                               sel_start_cursor.par->Next()->ClearParagraph();
+                       if 
+(sel_start_cursor.par->FirstPhysicalPar()->HasSameLayout(sel_start_cursor.par->Next())
+                       || 
+                       !sel_start_cursor.par->Next()->Last())
+                               
+sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->PasteParagraph();
+               }
 
    
                /* maybe a forgotten blank */
@@ -1955,9 +1969,11 @@
        }   
 
 
-       /* sometimes necessary */
-       if (doclear)
-               sel_start_cursor.par->ClearParagraph();
+       if( keep_copy ) {
+               /* sometimes necessary */
+               if (doclear)
+                       sel_start_cursor.par->ClearParagraph();
+       }
 
        RedoParagraphs(sel_start_cursor, endpar);
    

Reply via email to