]> git.lyx.org Git - features.git/commitdiff
Fix part of the line-delete-forward problem
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 26 May 2000 16:13:01 +0000 (16:13 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 26 May 2000 16:13:01 +0000 (16:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@776 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/CutAndPaste.C
src/lyxparagraph.h
src/paragraph.C
src/text.C
src/text2.C

index c061d55a49e7262dbe84f38189ab83cca5521f11..fabbdc51b077af69997a2906b24d1c86f598565a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2000-05-26  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * src/lyxparagraph.h: renamed ClearParagraph() to
+       StripLeadingSpaces() and moved it to paragraph.C. We pass the
+       textclass as parameter, and do nothing if free_spacing is
+       true. This fixes part of the line-delete-forward problems.
+
+       * src/CutAndPaste.C (cutSelection): use StripLeadingSpaces.
+       (pasteSelection): ditto.
+       (SwitchLayoutsBetweenClasses): more translatable strings.
+
+       * src/text2.C (CutSelection): use StripLeadingSpaces.
+       (PasteSelection): ditto.
+       (DeleteEmptyParagraphMechanism): ditto.
+
 2000-05-26  Juergen Vigna  <jug@sad.it>
 
        * src/TabularLayout.C (TabularOptionsCB): removed delete-table as this
index dc80a25457fcd49516ca3972f63d8a58ef5c002a..b0fb73c4ce2d8ad26cbba500a88b7fab939594b3 100644 (file)
@@ -123,7 +123,7 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar,
    
        // paste the paragraphs again, if possible
        if (doclear)
-           startpar->Next()->ClearParagraph();
+           startpar->Next()->StripLeadingSpaces(textclass);
        if (startpar->FirstPhysicalPar()->HasSameLayout(startpar->Next()) || 
            !startpar->Next()->Last()) {
            startpar->ParFromPos(start)->PasteParagraph();
@@ -341,7 +341,7 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar,
                lastbuffer->MakeSameLayout(lastbuffer->next);
                lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph();
            } else
-               lastbuffer->Next()->ClearParagraph();
+               lastbuffer->Next()->StripLeadingSpaces(tc);
        }
        // restore the simple cut buffer
        buf = simple_cut_clone;
@@ -388,12 +388,12 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(LyXTextClassList::size_type c1,
        
        if (name != textclasslist.NameOfLayout(c2, par->layout)) {
            ++ret;
-           string s = "Layout had to be changed from\n"
-               + name + " to "
-               + textclasslist.NameOfLayout(c2, par->layout)
-               + "\nbecause of class conversion from\n"
-               + textclasslist.NameOfClass(c1) + " to "
-               + textclasslist.NameOfClass(c2);
+           string s = _("Layout had to be changed from\n")
+                   + name + _(" to ")
+                   + textclasslist.NameOfLayout(c2, par->layout)
+                   + _("\nbecause of class conversion from\n")
+                   + textclasslist.NameOfClass(c1) + _(" to ")
+                   + textclasslist.NameOfClass(c2);
            InsetError * new_inset = new InsetError(s);
            par->InsertChar(0, LyXParagraph::META_INSET);
            par->InsertInset(0, new_inset);
index d7054fdc1692bae44db7ee053ab6a04c38ba82be..1c2d14834ebeb9ff292155ebe39764a8c4c6906f 100644 (file)
@@ -474,18 +474,7 @@ public:
        LyXParagraph * FirstSelfrowPar();
 
        ///
-       int ClearParagraph() {
-               int i = 0;
-               if (!IsDummy() && !table){
-                       while (Last()
-                              && (IsNewline(0) 
-                                  || IsLineSeparator(0))){
-                               Erase(0);
-                               ++i;
-                       }
-               }
-               return i;
-       }
+       int StripLeadingSpaces(LyXTextClassList::size_type tclass); 
        
        /** A paragraph following a footnote is a "dummy". A paragraph
          with a footnote in it is stored as three paragraphs:
index 8e3c383f179c90cb944b2b2cb0540abb18746d8e..11ca5d39a143e758c159d13aa4ac566064fdf1cd 100644 (file)
@@ -1489,6 +1489,22 @@ LyXParagraph * LyXParagraph::FirstSelfrowPar()
                return tmppar;
 }
 
+int LyXParagraph::StripLeadingSpaces(LyXTextClassList::size_type tclass) 
+{
+       if (textclasslist.Style(tclass, GetLayout()).free_spacing)
+               return 0;
+       
+       int i = 0;
+       if (!IsDummy() && !table){
+               while (Last()
+                      && (IsNewline(0) || IsLineSeparator(0))){
+                       Erase(0);
+                       ++i;
+               }
+       }
+       return i;
+}
+
 
 LyXParagraph * LyXParagraph::Clone() const
 {
index 4c33dc9e41de33dc454f0b4071e1b163e27632df..f74e773fb544b13b6a5e3a179175ca73bf2a8514 100644 (file)
@@ -3201,11 +3201,14 @@ void LyXText::DeleteWordBackward()
 /* -------> Kill to end of line. */
 void LyXText::DeleteLineForward()
 {
-       LyXCursor tmpcursor = cursor;
+       
+
        if (!cursor.par->Last())
+               // Paragraph is empty, so we just go to the right
                CursorRight();
-       // CHECK See comment on top of text.C
        else {
+               // CHECK See comment on top of text.C
+               LyXCursor tmpcursor = cursor;
                CursorEnd();
                sel_cursor = cursor;
                cursor = tmpcursor;
@@ -3219,11 +3222,7 @@ void LyXText::DeleteLineForward()
 }
 
 
-// Change the case of a word at cursor position. The meaning of action
-// is:
-// 0  change to lowercase
-// 1  capitalize word
-// 2  change to uppercase
+// Change the case of a word at cursor position. 
 // This function directly manipulates LyXParagraph::text because there
 // is no LyXParagraph::SetChar currently. I did what I could to ensure
 // that it is correct. I guess part of it should be moved to
index 18575e9d789feb325ceca9990948a1d63b137bea..4537bd86cdfe0b15c38d6666b9455a97a17ffe24 100644 (file)
@@ -2173,7 +2173,7 @@ void LyXText::CutSelection(bool doclear)
    
                // paste the paragraphs again, if possible
                if (doclear)
-                       sel_start_cursor.par->Next()->ClearParagraph();
+                       sel_start_cursor.par->Next()->StripLeadingSpaces(simple_cut_buffer_textclass);
                if (sel_start_cursor.par->FirstPhysicalPar()->HasSameLayout(sel_start_cursor.par->Next())
                    || 
                    !sel_start_cursor.par->Next()->Last())
@@ -2182,7 +2182,7 @@ void LyXText::CutSelection(bool doclear)
 
        // sometimes necessary
        if (doclear)
-               sel_start_cursor.par->ClearParagraph();
+               sel_start_cursor.par->StripLeadingSpaces(simple_cut_buffer_textclass);
 
        RedoParagraphs(sel_start_cursor, endpar);
    
@@ -2272,7 +2272,7 @@ void LyXText::CutSelection(bool doclear)
 
     // sometimes necessary
     if (doclear)
-       sel_start_cursor.par->ClearParagraph();
+       sel_start_cursor.par->StripLeadingSpaces(buffer->params.textclass);
 
     RedoParagraphs(sel_start_cursor, endpar);
    
@@ -2631,7 +2631,7 @@ void LyXText::PasteSelection()
                                lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph();
         
                        } else
-                               lastbuffer->Next()->ClearParagraph();
+                               lastbuffer->Next()->StripLeadingSpaces(buffer->params.textclass);
                }
 
                // restore the simple cut buffer
@@ -3579,7 +3579,8 @@ void LyXText::DeleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const
        // MISSING
 
        // If the pos around the old_cursor were spaces, delete one of them.
-       if (old_cursor.par != cursor.par || old_cursor.pos != cursor.pos) { // Only if the cursor has really moved
+       if (old_cursor.par != cursor.par || old_cursor.pos != cursor.pos) { 
+               // Only if the cursor has really moved
                
                if (old_cursor.pos > 0
                    && old_cursor.pos < old_cursor.par->Last()
@@ -3710,7 +3711,7 @@ void LyXText::DeleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const
                        }
                }
                if (!deleted) {
-                       if (old_cursor.par->ClearParagraph()) {
+                       if (old_cursor.par->StripLeadingSpaces(buffer->params.textclass)) {
                                RedoParagraphs(old_cursor, old_cursor.par->Next());
                                // correct cursor y
                                SetCursorIntern(cursor.par, cursor.pos);