From: Jürgen Vigna Date: Tue, 5 Mar 2002 14:55:20 +0000 (+0000) Subject: Changed behaviour of Inlined ERT insets (fix 251). X-Git-Tag: 1.6.10~19733 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=82cc1af962f3e00502d9e994f6da45dc5ec06688;p=features.git Changed behaviour of Inlined ERT insets (fix 251). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3665 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 6340248d89..7de29516de 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2002-03-05 Juergen Vigna + + * insetert.C (status): change behaviour of Inlined. + (getMaxWidth): added for new inlined behaviour. + 2002-03-05 José Abílio Oliveira Matos * 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. diff --git a/src/insets/insetert.C b/src/insets/insetert.C index d1f4dbeee2..982a249e29 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -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(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; +} diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 8c9c57ce54..fbd1f4896a 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -132,6 +132,8 @@ public: bool forceDefaultParagraphs(Inset const *) const { return true; } + /// + int getMaxWidth(BufferView *, UpdatableInset const *) const; private: /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 8396845fed..090bf6c966 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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) diff --git a/src/text.C b/src/text.C index 86e448e998..eab4bc762f 100644 --- a/src/text.C +++ b/src/text.C @@ -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;