]> git.lyx.org Git - features.git/commitdiff
fix selection bug + latin9 tweaks
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 27 Sep 2001 09:52:06 +0000 (09:52 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 27 Sep 2001 09:52:06 +0000 (09:52 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2808 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxfunc.C
src/lyxtext.h
src/paragraph_pimpl.C
src/text2.C

index 14879c5c862a774d76dc38f18a5de3c7bbcaf8c7..98757c3ef26f89e6f29da7965a2623e58b7ebeaa 100644 (file)
@@ -1,3 +1,14 @@
+2001-09-27  Adrien Rebollo  <adrien.rebollo@gmx.fr>
+
+       * paragraph_pimpl.C (simpleTeXSpecialChars): handle latin9 too.
+
+2001-09-26  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
+
+       * 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-09-27  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * BufferView_pimpl.C (buffer): call WorkArea::show to pop-up the
index d168f41aa57126f1c6d5269be75111f2fce214d3..d1df3e1b24dc86d4e49ae36ad81360105c85fff4 100644 (file)
@@ -241,7 +241,7 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state)
                return;
        }
 
-       // Can we be sure that this will work for all X-Windows
+       // Can we be sure that this will work for all X Window
        // implementations? (Lgb)
        // This code snippet makes lyx ignore some keys. Perhaps
        // all of them should be explictly mentioned?
index 5ed0732a65aca129bd0ebeb1e689f38020f80e54..3be37e1cfff0300516523e2044fcbe50e2f0dddf 100644 (file)
@@ -241,7 +241,7 @@ public:
          */
        mutable LyXCursor cursor; // actual cursor position
 
-       /** The structrue that keeps track of the selections set. */
+       /** The structure that keeps track of the selections set. */
        struct Selection {
                Selection() 
                        : set_(false), mark_(false)
@@ -269,12 +269,12 @@ public:
        };
        mutable Selection selection;
 
-       /// needed for the toggling
-       LyXCursor last_sel_cursor; // cursor position on last selection made
-       ///
-       LyXCursor toggle_cursor;   // the following two are needed for toggling
-       ///                           the selection in screen.C
-       LyXCursor toggle_end_cursor;
+       /// needed for the toggling (cursor position on last selection made)
+       mutable LyXCursor last_sel_cursor; 
+       /// needed for toggling the selection in screen.C
+       mutable LyXCursor toggle_cursor;
+       /// needed for toggling the selection in screen.C
+       mutable LyXCursor toggle_end_cursor;
    
        /// need the selection cursor:
        void setSelection(BufferView *);
@@ -544,6 +544,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;
index 6bcc718fa42e75f42161e455058137202685bf8e..de5185747e83653c97c95a50044a4d64bb12f6e4 100644 (file)
@@ -323,10 +323,13 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                case '°': case '±': case '²': case '³':  
                case '×': case '÷': case '¹': case 'ª':
                case 'º': case '¬': case 'µ':
-                       if (bparams.inputenc == "latin1" ||
+                       if ((bparams.inputenc == "latin1" ||
+                            bparams.inputenc == "latin9") ||
                            (bparams.inputenc == "auto" &&
-                            font.language()->encoding()->LatexName()
-                            == "latin1")) {
+                            (font.language()->encoding()->LatexName()
+                             == "latin1" ||
+                             font.language()->encoding()->LatexName()
+                             == "latin9"))) {
                                os << "\\ensuremath{"
                                   << c
                                   << '}';
index caaa887447852a72d031f4f13dbad8c409ff93f3..fbd32326a578115d994e8e4daad142f0d76fb4ec 100644 (file)
@@ -2195,7 +2195,7 @@ void LyXText::setCursorIntern(BufferView * bview, Paragraph * par,
                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 I believe 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
@@ -2349,6 +2349,26 @@ void LyXText::cursorDownParagraph(BufferView * bview) const
        }
 }
 
+// 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::deleteEmptyParagraphMechanism(BufferView * bview,
                                            LyXCursor const & old_cursor) const
@@ -2396,14 +2416,25 @@ void LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
                    && 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, selection.cursor,
+                                            old_cursor);
+                       fixCursorAfterDelete(bview, selection.start,
+                                            old_cursor);
+                       fixCursorAfterDelete(bview, selection.end, old_cursor);
+                       fixCursorAfterDelete(bview, last_sel_cursor,
+                                            old_cursor);
+                       fixCursorAfterDelete(bview, toggle_cursor, old_cursor);
+                       fixCursorAfterDelete(bview, toggle_end_cursor,
+                                            old_cursor);
                        return;
                }
        }