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
This commit is contained in:
Jürgen Vigna 2002-03-05 14:55:20 +00:00
parent d228f08abd
commit 82cc1af962
5 changed files with 31 additions and 10 deletions

View 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.

View 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;
}

View File

@ -132,6 +132,8 @@ public:
bool forceDefaultParagraphs(Inset const *) const {
return true;
}
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
private:
///

View 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)

View 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;