]> git.lyx.org Git - features.git/commitdiff
Changed behaviour of Inlined ERT insets (fix 251).
authorJürgen Vigna <jug@sad.it>
Tue, 5 Mar 2002 14:55:20 +0000 (14:55 +0000)
committerJürgen Vigna <jug@sad.it>
Tue, 5 Mar 2002 14:55:20 +0000 (14:55 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3665 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/insetert.C
src/insets/insetert.h
src/insets/insettext.C
src/text.C

index 6340248d89d3b59e1428603b43a874d8c4277b44..7de29516def7ec6c7b1fe2a78063e64c174adcfd 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-05  Juergen Vigna  <jug@sad.it>
+
+       * insetert.C (status): change behaviour of Inlined.
+       (getMaxWidth): added for new inlined behaviour.
+
 2002-03-05  José Abílio Oliveira Matos  <jamatos@novalis.fc.up.pt>
 
        * insetnote.h (linuxdoc, docbook): add empty methods.
@@ -8,6 +13,8 @@
 
        * insettext.C (insetButtonPress): don't call exit on a InsetButtonPress
        only that one in the inset. Should be enough.
+       (updateLocal): set the selection cursor always if we don't have a
+       selection to be sure it's set!
 
        * insettabular.C (insetButtonPress): don't hit a sub inset 2 times.
 
index d1f4dbeee2a39c64ee9ed8b9d8ab036a3ce58363..982a249e29ccbd074dbc917d92c63f3cc740997a 100644 (file)
@@ -23,6 +23,7 @@
 #include "lyxtext.h"
 #include "debug.h"
 #include "lyxtextclasslist.h"
+#include "lyxrow.h"
 
 #include "insets/insettext.h"
 
@@ -626,20 +627,17 @@ void InsetERT::status(BufferView * bv, ERTStatus const st) const
 {
        if (st != status_) {
                status_ = st;
+               need_update = FULL;
                switch (st) {
                case Inlined:
-                       inset.setAutoBreakRows(false);
+                       inset.setUpdateStatus(bv, InsetText::INIT);
                        break;
                case Open:
-                       inset.setAutoBreakRows(true);
                        collapsed_ = false;
-                       need_update = FULL;
                        setButtonLabel();
                        break;
                case Collapsed:
-                       inset.setAutoBreakRows(true);
                        collapsed_ = true;
-                       need_update = FULL;
                        setButtonLabel();
                        if (bv)
                                bv->unlockInset(const_cast<InsetERT *>(this));
@@ -691,3 +689,15 @@ void InsetERT::getDrawFont(LyXFont & font) const
        font.setFamily(LyXFont::TYPEWRITER_FAMILY);
        font.setColor(LColor::latex);
 }
+
+
+int InsetERT::getMaxWidth(BufferView * bv, UpdatableInset const * in) const
+{
+       int w = InsetCollapsable::getMaxWidth(bv, in);
+       if (status_ != Inlined || w < 0)
+               return w;
+       LyXText * text = inset.getLyXText(bv);
+       if (text->width < w && !text->firstRow()->next())
+               return -1;
+       return w;
+}
index 8c9c57ce54507ceb9de59745ce0ecea68b12294c..fbd1f4896a93f85ebc68608fdd4040e56e3dfb32 100644 (file)
@@ -132,6 +132,8 @@ public:
        bool forceDefaultParagraphs(Inset const *) const {
                return true;
        }
+       ///
+       int getMaxWidth(BufferView *, UpdatableInset const *) const;
 
 private:
        ///
index 8396845fed5523c6af58afdaa22cb1d36a9c984d..090bf6c966090a0bb67f13ab83cbe4abdf9601ea 100644 (file)
@@ -613,6 +613,8 @@ void InsetText::updateLocal(BufferView * bv, int what, bool mark_dirty) const
        setUpdateStatus(bv, what);
        bool flag = (((need_update != CURSOR) && (need_update != NONE)) ||
                     (lt->status() != LyXText::UNCHANGED) || lt->selection.set());
+       if (!lt->selection.set())
+               lt->selection.cursor = lt->cursor;
        if (clear)
                lt = 0;
        if (flag)
index 86e448e998d6ff3bc5aea35d9cfd4522c6445be2..eab4bc762f329cb659cb85c221cbef337acf222a 100644 (file)
@@ -1788,7 +1788,6 @@ void LyXText::insertChar(BufferView * bview, char c)
                textclasslist[bview->buffer()->params.textclass][cursor.row()->par()->layout()].free_spacing ||
                cursor.row()->par()->isFreeSpacing();
 
-
        if (lyxrc.auto_number) {
                static string const number_operators = "+-/*";
                static string const number_unary_operators = "+-";
@@ -1910,7 +1909,7 @@ void LyXText::insertChar(BufferView * bview, char c)
        Row * row = cursor.row();
        int y = cursor.y() - row->baseline();
        if (c != Paragraph::META_INSET) /* Here case LyXText::InsertInset 
-                                           * already insertet the character */
+                                        * already insertet the character */
                cursor.par()->insertChar(cursor.pos(), c);
        setCharFont(bview->buffer(), cursor.par(), cursor.pos(), rawtmpfont);
 
@@ -1929,7 +1928,8 @@ void LyXText::insertChar(BufferView * bview, char c)
                 || ((cursor.pos() < cursor.par()->size()) &&
                         cursor.par()->isInset(cursor.pos()+1))
             || cursor.row()->fill() == -1)
-           && row->previous() && row->previous()->par() == row->par()) {
+           && row->previous() && row->previous()->par() == row->par())
+       {
                pos_type z = nextBreakPoint(bview,
                                                           row->previous(),
                                                           workWidth(bview));
@@ -1973,8 +1973,8 @@ void LyXText::insertChar(BufferView * bview, char c)
    
        // recalculate the fill of the row
        if (row->fill() >= 0)  /* needed because a newline
-                             * will set fill to -1. Otherwise
-                             * we would not get a rebreak! */
+                               * will set fill to -1. Otherwise
+                               * we would not get a rebreak! */
                row->fill(fill(bview, row, workWidth(bview)));
        if (row->fill() < 0) {
                refresh_y = y;