From 4664c58a9ec04b28fd946ed595c76428098b556b Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 26 May 2000 16:13:01 +0000 Subject: [PATCH] Fix part of the line-delete-forward problem git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@776 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 15 +++++++++++++++ src/CutAndPaste.C | 16 ++++++++-------- src/lyxparagraph.h | 13 +------------ src/paragraph.C | 16 ++++++++++++++++ src/text.C | 13 ++++++------- src/text2.C | 13 +++++++------ 6 files changed, 53 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index c061d55a49..fabbdc51b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2000-05-26 Jean-Marc Lasgouttes + + * 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 * src/TabularLayout.C (TabularOptionsCB): removed delete-table as this diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index dc80a25457..b0fb73c4ce 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -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); diff --git a/src/lyxparagraph.h b/src/lyxparagraph.h index d7054fdc16..1c2d14834e 100644 --- a/src/lyxparagraph.h +++ b/src/lyxparagraph.h @@ -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: diff --git a/src/paragraph.C b/src/paragraph.C index 8e3c383f17..11ca5d39a1 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -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 { diff --git a/src/text.C b/src/text.C index 4c33dc9e41..f74e773fb5 100644 --- a/src/text.C +++ b/src/text.C @@ -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 diff --git a/src/text2.C b/src/text2.C index 18575e9d78..4537bd86cd 100644 --- a/src/text2.C +++ b/src/text2.C @@ -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); -- 2.39.2