]> git.lyx.org Git - features.git/commitdiff
Various small fixes, look in ChangeLog
authorJürgen Vigna <jug@sad.it>
Fri, 31 Mar 2000 10:35:53 +0000 (10:35 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 31 Mar 2000 10:35:53 +0000 (10:35 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@636 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/BufferView2.C
src/insets/inset.C
src/insets/insetcollapsable.C
src/insets/insetcommand.C
src/insets/insetfoot.C
src/insets/insettext.C
src/insets/lyxinset.h
src/lyxfunc.C
src/paragraph.C

index 1a3643c01b6b4b0a231d8aacfc1b3e307bb0be60..2ec7f801cd4cf05ad82fd15a661f453033a0fce7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2000-03-31  Juergen Vigna  <jug@sad.it>
+
+       * src/paragraph.C (GetInset): commented out text[pos] = ' '
+       (Clone): changed mode how the paragraph-data is copied to the
+       new clone-paragraph.
+
+       * src/lyxfunc.C (Dispatch): fixed small problem when calling
+       GetInset(pos) with no inset anymore there (in inset UNDO)
+
+       * src/insets/insetcommand.C (draw): small fix as here x is
+       incremented not as much as width() returns (2 before, 2 behind = 4)
+
+2000-03-30  Juergen Vigna  <jug@sad.it>
+
+       * src/insets/insettext.C (InsetText): small fix in initialize
+       widthOffset (should not be done in the init() function)
+
 2000-03-29  Amir Karger <karger@lyx.org>
 
        * lib/examples/it_ItemizeBullets.lyx: translation by 
index 956f0f0353f11810012fc002241ff469141f759f..6aa4869c32b3199f67de233bdaba774b581bf93f 100644 (file)
@@ -230,6 +230,19 @@ void BufferView::insertInset(Inset * inset, string const & lout,
        }
        
        text->InsertInset(inset);
+#if 1
+       // if we enter a text-inset the cursor should be to the left side
+       // of it! This couldn't happen before as Undo was not handled inside
+       // inset now after the Undo LyX tries to call inset->Edit(...) again
+       // and cannot do this as the cursor is behind the inset and GetInset
+       // does not return the inset!
+       if (inset->IsTextInset()) {
+               if (text->cursor.par->getParDirection()==LYX_DIR_LEFT_TO_RIGHT)
+                       text->CursorLeft();
+               else
+                       text->CursorRight();
+       }
+#endif
        update(-1);
 
        text->UnFreezeUndo();   
index 0c9d6602b2d63902e9060573dc28b306c4d0e93f..bf30dfd85d0e6edcea7213620cab1bf6c80026f9 100644 (file)
@@ -41,6 +41,13 @@ Inset::EDITABLE Inset::Editable() const
   return NOT_EDITABLE;
 }
 
+bool Inset::IsTextInset() const
+{
+       return ((LyxCode() == TEXT_CODE) ||
+               (LyxCode() == ERT_CODE) ||
+               (LyxCode() == FOOT_CODE) ||
+               (LyxCode() == MARGIN_CODE));
+}
 
 void Inset::Validate(LaTeXFeatures &) const
 {
index ba13a0c950240b1cf828cea08a47f1a97b6d7871..532abb133b60ff985eb0d617143f02fc0a70c0ae 100644 (file)
@@ -20,7 +20,8 @@
 #include "Painter.h"
 
 
-InsetCollapsable::InsetCollapsable(Buffer * bf): InsetText(bf)
+InsetCollapsable::InsetCollapsable(Buffer * bf)
+               : InsetText(bf)
 {
     collapsed = true;
     label = "Label";
@@ -37,6 +38,7 @@ Inset * InsetCollapsable::Clone() const
     InsetCollapsable * result = new InsetCollapsable(buffer);
     result->init(buffer, par);
 
+    result->collapsed = collapsed;
     return result;
 }
 
index 0a566e3463d1011eb27f6cc871d79f04af25166c..3fada648cf056e3c007dcbfe00e06b8fefdf13b2 100644 (file)
@@ -89,7 +89,7 @@ int InsetCommand::width(Painter & pain, LyXFont const &) const
                              LColor::commandbg, LColor::commandframe,
                              false, width, ascent, descent);
        }
-       return width+4;
+       return width + 4;
 }
 
 
@@ -111,7 +111,7 @@ void InsetCommand::draw(Painter & pain, LyXFont const &,
                              true, width);
        }
 
-       x += width;
+       x += width + 4;
 }
 
 
index 05087bb391d89c445e881e4b027744ceaf66d197..37a294aef845e3598eefa747c4e00199ef0297be 100644 (file)
@@ -21,7 +21,8 @@
 #include "Painter.h"
 
 
-InsetFoot::InsetFoot(Buffer * bf): InsetCollapsable(bf)
+InsetFoot::InsetFoot(Buffer * bf)
+               : InsetCollapsable(bf)
 {
     setLabel(_("foot"));
     LyXFont font(LyXFont::ALL_SANE);
@@ -38,6 +39,7 @@ Inset * InsetFoot::Clone() const
     InsetFoot * result = new InsetFoot(buffer);
     result->init(buffer, par);
 
+    result->collapsed = collapsed;
     return result;
 }
 
index 54083dbacb29ec29708cc5f04d8be9aa4be7cbaa..f3c0367203eb4bb360bb0ad07a9c1f24bc16ceb4 100644 (file)
@@ -60,6 +60,7 @@ extern unsigned char getCurrentTextClass(Buffer *);
 InsetText::InsetText(Buffer * buf)
 {
     par = new LyXParagraph();
+    widthOffset = 0;
     init(buf);
 }
 
@@ -67,6 +68,7 @@ InsetText::InsetText(Buffer * buf)
 InsetText::InsetText(InsetText const & ins, Buffer * buf)
 {
     par = 0;
+    widthOffset = 0;
     init(buf, ins.par);
 }
 
@@ -75,15 +77,7 @@ void InsetText::init(Buffer * buf, LyXParagraph *p)
     if (p) {
        if (par)
            delete par;
-       par = new LyXParagraph(p);
-       for(int pos = 0; pos < p->Last(); ++pos) {
-           par->InsertChar(pos, p->GetChar(pos));
-           par->SetFont(pos, p->GetFontSettings(pos));
-           if ((p->GetChar(pos) == LyXParagraph::META_INSET) &&
-               p->GetInset(pos)) {
-               par->InsertInset(pos, p->GetInset(pos)->Clone());
-           }
-       }
+       par = p->Clone();
     }
     the_locking_inset = 0;
     buffer = buf;
@@ -93,7 +87,7 @@ void InsetText::init(Buffer * buf, LyXParagraph *p)
     interline_space = 1;
     no_selection = false;
     init_inset = true;
-    maxAscent = maxDescent = insetWidth = widthOffset = 0;
+    maxAscent = maxDescent = insetWidth = 0;
     autoBreakRows = false;
     xpos = 0.0;
 }
index dd6b1bc3a35a7c8fb08daa0d15aecfc6d358ca59..bf45450c71fed122e1681e55ddc74e84b620fe9c 100644 (file)
@@ -83,6 +83,8 @@ public:
                ///
                TEXT_CODE,
                ///
+               ERT_CODE,
+               ///
                FOOT_CODE,
                ///
                MARGIN_CODE,
@@ -116,6 +118,8 @@ public:
        ///
        virtual EDITABLE Editable() const;
        ///
+       bool IsTextInset() const;
+       ///
        virtual bool AutoDelete() const;
        ///
        virtual void Write(ostream &) const = 0;
@@ -140,7 +144,7 @@ public:
        virtual bool Deletable() const;
 
        /// returns LyX code associated with the inset. Used for TOC, ...)
-       virtual Inset::Code LyxCode() const = 0;
+       virtual Inset::Code LyxCode() const { return NO_CODE; }
   
        /// Get the label that appears at screen
        virtual string getLabel(int) const {
index 8a408234129b993bcb39a4fa88ed29947d740044..11bcf8ba296b9b678eea6223f023eea9c9f67ed9 100644 (file)
@@ -532,10 +532,15 @@ string LyXFunc::Dispatch(int ac,
                                inset->GetCursorPos(slx, sly);
                                owner->view()->unlockInset(inset);
                                owner->view()->menuUndo();
-                               inset = static_cast<UpdatableInset*>(
-                                       owner->view()->text->cursor.par->
-                                       GetInset(owner->view()->text->
-                                                cursor.pos));
+                               if (owner->view()->text->cursor.par->
+                                   IsInset(owner->view()->text->cursor.pos)) {
+                                       inset = static_cast<UpdatableInset*>(
+                                               owner->view()->text->cursor.par->
+                                               GetInset(owner->view()->text->
+                                                        cursor.pos));
+                               } else {
+                                       inset = 0;
+                               }
                                if (inset)
                                        inset->Edit(owner->view(),slx,sly,0);
                                return string();
index 3678cf608446b5946aeffdab6ca2f9a6fdc0f8d5..12cb47523cbf64870e8e3bf62b52e377ef2eec94 100644 (file)
@@ -659,7 +659,7 @@ Inset * LyXParagraph::GetInset(LyXParagraph::size_type pos)
        }
        lyxerr << "ERROR (LyXParagraph::GetInset): "
                "Inset does not exist: " << pos << endl;
-       text[pos] = ' '; // WHY!!! does this set the pos to ' '????
+       // text[pos] = ' '; // WHY!!! does this set the pos to ' '????
        // Did this commenting out introduce a bug? So far I have not
        // see any, please enlighten me. (Lgb)
        // My guess is that since the inset does not exist, we might
@@ -1477,11 +1477,27 @@ LyXParagraph * LyXParagraph::Clone() const
                
     
        // copy everything behind the break-position to the new paragraph
-   
+
+       // IMO this is not correct. Here we should not use the Minibuffer to
+       // copy stuff, as the Minibuffer is global and we could be in a
+       // situation where we copy a paragraph inside a paragraph (this now
+       // is possible think of Text-Insets!). So I'm changing this so that
+       // then inside the Text-Inset I can use par->Clone() to copy the
+       // paragraph data from one inset to the other!
+#if 0
        for (size_type i = 0; i < size(); ++i) {
                CopyIntoMinibuffer(i);
                result->InsertFromMinibuffer(i);
        }
+#else
+       for(size_type i = 0; i < size(); ++i) {
+           result->InsertChar(i, GetChar(i));
+           result->SetFont(i, GetFontSettings(i));
+           if ((GetChar(i) == LyXParagraph::META_INSET) && GetInset(i)) {
+               result->InsertInset(i, GetInset(i)->Clone());
+           }
+       }
+#endif
        result->text.resize(result->text.size());
        return result;
 }