]> git.lyx.org Git - features.git/commitdiff
open insets when selection is set there
authorAndré Pönitz <poenitz@gmx.net>
Thu, 14 Jul 2005 17:30:24 +0000 (17:30 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 14 Jul 2005 17:30:24 +0000 (17:30 +0000)
 to avoid crashs with cold coord cache

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10188 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/cursor.C
src/insets/insetbase.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/lyxfunc.C
src/mathed/math_parser.C

index 49a986493a685bb95b94916e4936ddd4ea0b81fb..bf9964534674c604d471918ab465566caa5456d4 100644 (file)
@@ -1,4 +1,9 @@
 
+2005-05-07  André Pönitz  <poenitz@gmx.net>
+
+       * cursor.C (setSelection): open insets when selection is set there
+    to avoid crashs with cold coord cache
+
 2005-05-07  André Pönitz  <poenitz@gmx.net>
 
        * trans_mgr.C (insert): move cursor to the right after inserting
index d77f7c25c918735a8a0a0390eaa6e4ecca31088f..8e2a117d0108a3ba690799458761b01967fe3482 100644 (file)
@@ -393,7 +393,7 @@ DocIterator LCursor::selectionEnd() const
 void LCursor::setSelection()
 {
        selection() = true;
-       // a selection with no contents is not a selection
+       // A selection with no contents is not a selection
 #ifdef WITH_WARNINGS
 #warning doesnt look ok
 #endif
@@ -408,6 +408,9 @@ void LCursor::setSelection(DocIterator const & where, size_t n)
        selection() = true;
        anchor_ = where;
        pos() += n;
+       // Open all collapsed insets
+       for (int i = depth() - 1; i >= 0; --i)
+               operator[](i).inset().setStatus(*this, InsetBase::Open);
 }
 
 
index e414bd6b150a1eadb3b5f879f6be0399f21a4290..52ead301278ad23a302967ee74a9e018d4be54ac 100644 (file)
@@ -338,10 +338,6 @@ public:
        /// used to toggle insets
        /// is the inset open?
        virtual bool isOpen() const { return false; }
-       /// open the inset
-       virtual void open() {}
-       /// close the inset
-       virtual void close() {}
        /// should this inset be handled like a normal charater
        virtual bool isChar() const { return false; }
        /// is this equivalent to a letter?
@@ -399,6 +395,14 @@ public:
        virtual int ascent() const { return 10; }
        /// pretty arbitrary
        virtual int descent() const { return 10; }
+       ///
+       enum CollapseStatus {
+               Collapsed,
+               Inlined,
+               Open
+       };
+       ///
+       virtual void setStatus(LCursor &, CollapseStatus) {}
 protected:
        InsetBase();
        InsetBase(InsetBase const &);
index 1a829021c049dab01a13274796402fa6b953b9d4..7e371e6235d063221b5c0edcfe0ba21d4ef7b96b 100644 (file)
@@ -257,7 +257,6 @@ void InsetCollapsable::edit(LCursor & cur, bool left)
        //lyxerr << "InsetCollapsable: edit left/right" << endl;
        cur.push(*this);
        InsetText::edit(cur, left);
-       open();
 }
 
 
index 1f747325d9e3ce15eafebd03a0a854197090f404..a552119eb43ff7204763188f026a0c60d1a23381 100644 (file)
@@ -35,12 +35,6 @@ public:
        ///
        static int const TEXT_TO_BOTTOM_OFFSET = 2;
        ///
-       enum CollapseStatus {
-               Collapsed,
-               Inlined,
-               Open
-       };
-       ///
        InsetCollapsable(BufferParams const &, CollapseStatus status = Open);
        ///
        void read(Buffer const &, LyXLex &);
@@ -86,10 +80,11 @@ public:
        bool allowSpellCheck() const { return true; }
        ///
        bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
-
-protected:
        ///
        void setStatus(LCursor & cur, CollapseStatus st);
+
+protected:
+
        ///
        virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
        ///
index 36ec96f45b027951f4776528efd40d91926fd93e..f052b75abf1b3c914b1503f74707beb00ce00527 100644 (file)
@@ -1510,10 +1510,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                default: {
                        view()->cursor().dispatch(cmd);
                        update |= view()->cursor().result().update();
-                       if (!view()->cursor().result().dispatched()) {
+                       if (!view()->cursor().result().dispatched())
                                update |= view()->dispatch(cmd);
-                       }
-
                        break;
                }
                }
index 05d57e8d175bd01f13c67f72b0ed89edfba871fb..216c49df5596341cb2524a12b472e586d89b591b 100644 (file)
@@ -181,7 +181,7 @@ void delEmptyLastRow(MathGridInset & grid)
                if (!grid.cell(grid.index(row, col)).empty())
                        return;
        }
-       grid.delRow(row + 1);
+       grid.delRow(row);
 }