diff --git a/ChangeLog b/ChangeLog index 857c62aecc..749c57d0c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2001-10-15 Jean-Marc Lasgouttes + + * src/text2.C (fixCursorAfterDelete): new method. Fixes the parameters + of a cursor (row, etc.) after a character has been deleted + (DeleteEmptyParagraphMechanism): call the method above on _all_ + cursors held by the LyXText when a double space has been + detected/deleted. + +2001-10-01 Jean-Marc Lasgouttes + + * lib/languages: change default encoding for estonian to latin1 + 2001-10-01 Garst R. Reese * lib/tex/hollywood.cls: diff --git a/lib/languages b/lib/languages index a179390039..fe5730d911 100644 --- a/lib/languages +++ b/lib/languages @@ -17,7 +17,7 @@ dutch dutch "Dutch" false iso8859-1 nl "" english english "English" false iso8859-1 en "" esperanto esperanto "Esperanto" false iso8859-3 eo "" #and what country code should esperanto have?? (Garst) -estonian estonian "Estonian" false iso8859-4 et_EE "" +estonian estonian "Estonian" false iso8859-1 et_EE "" finnish finnish "Finnish" false iso8859-1 fi "" frenchb frenchb "French" false iso8859-1 fr "" french french "French (GUTenberg)" false iso8859-1 fr "" diff --git a/src/lyxtext.h b/src/lyxtext.h index 7a7d551ced..144a2b2b8d 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -220,15 +220,15 @@ public: /// mutable LyXCursor sel_cursor; /// - LyXCursor sel_start_cursor; + mutable LyXCursor sel_start_cursor; /// mutable LyXCursor sel_end_cursor; /// needed for the toggling - LyXCursor last_sel_cursor; + mutable LyXCursor last_sel_cursor; /// - LyXCursor toggle_cursor; + mutable LyXCursor toggle_cursor; /// - LyXCursor toggle_end_cursor; + mutable LyXCursor toggle_end_cursor; /// need the selection cursor: void SetSelection(); @@ -566,6 +566,12 @@ private: float & fill_label_hfill, bool bidi = true) const; + // fix the cursor `cur' after a characters has been deleted at `where' + // position. Called by deleteEmptyParagraphMechanism + void fixCursorAfterDelete(BufferView * bview, + LyXCursor & cur, + LyXCursor const & where) const; + /// void DeleteEmptyParagraphMechanism(BufferView *, LyXCursor const & old_cursor) const; diff --git a/src/text2.C b/src/text2.C index 7afd888e9a..267e71957a 100644 --- a/src/text2.C +++ b/src/text2.C @@ -2332,6 +2332,26 @@ void LyXText::CopySelection(BufferView * bview) bview->buffer()->params.textclass); } +// fix the cursor `cur' after a characters has been deleted at `where' +// position. Called by deleteEmptyParagraphMechanism +void LyXText::fixCursorAfterDelete(BufferView * bview, + LyXCursor & cur, + LyXCursor const & where) const +{ + // if cursor is not in the paragraph where the delete occured, + // do nothing + if (cur.par() != where.par()) + return; + + // if cursor position is after the place where the delete occured, + // update it + if (cur.pos() > where.pos()) + cur.pos(cur.pos()-1); + + // recompute row et al. for this cursor + SetCursor(bview, cur, cur.par(), cur.pos(), cur.boundary()); +} + void LyXText::PasteSelection(BufferView * bview) { @@ -3072,21 +3092,32 @@ void LyXText::DeleteEmptyParagraphMechanism(BufferView * bview, // 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.pos() > 0 && old_cursor.pos() < old_cursor.par()->Last() && old_cursor.par()->IsLineSeparator(old_cursor.pos()) && old_cursor.par()->IsLineSeparator(old_cursor.pos() - 1)) { old_cursor.par()->Erase(old_cursor.pos() - 1); RedoParagraphs(bview, old_cursor, old_cursor.par()->Next()); - // correct cursor - if (old_cursor.par() == cursor.par() && - cursor.pos() > old_cursor.pos()) { - SetCursorIntern(bview, cursor.par(), - cursor.pos() - 1); - } else - SetCursorIntern(bview, cursor.par(), - cursor.pos()); + +#ifdef WITH_WARNINGS +#warning This will not work anymore when we have multiple views of the same buffer +// In this case, we will have to correct also the cursors held by +// other bufferviews. It will probably be easier to do that in a more +// automated way in LyXCursor code. (JMarc 26/09/2001) +#endif + // correct all cursors held by the LyXText + fixCursorAfterDelete(bview, cursor, old_cursor); + fixCursorAfterDelete(bview, sel_cursor, old_cursor); + fixCursorAfterDelete(bview, sel_start_cursor, + old_cursor); + fixCursorAfterDelete(bview, sel_end_cursor, + old_cursor); + fixCursorAfterDelete(bview, last_sel_cursor, + old_cursor); + fixCursorAfterDelete(bview, toggle_cursor, old_cursor); + fixCursorAfterDelete(bview, toggle_end_cursor, + old_cursor); return; } }