JMarc> I do not really know, but I'd like to point out that it is a common
JMarc> problem for the insets. We should really find a fix.

There are people out there who are FAR more knowledgeable than me. Could I have
comments on the following scheme please.

It seems to me that the place to check what to do with an inset is in text.C.
At the moment, the relevant code is at line 570++:

        if (c == LyXParagraph::META_INSET) {
                Inset const * tmpinset = row->par()->GetInset(pos);
                if (tmpinset) {
                        tmpinset->draw(bview, font, offset+row->baseline(), x,
                                       cleared);
                }
                ...
        }

It seems that this is a good place to check the contents of the inset and if
empty to remove it. Something like:

        if (c == LyXParagraph::META_INSET) {
                Inset const * tmpinset = row->par()->GetInset(pos);
                if (tmpinset) {
                        if( tmpinset->isEmpty() && tmpinset->DialogIsHidden() )
                                row->par()->Erase(pos);
                        else
                                tmpinset->draw(bview, font, offset+row->baseline(), x, 
 cleared);
                }
                ...
        }

Note that isEmpty() and DialogIsHidden() are imaginary methods at the moment!

isEmpty would be something like:
bool isEmpty()
{
        return ( getContents().empty() && getOptions().empty );
}
although it is probably inset specific. Certainly not:
bool isEmpty()
{
        return ( getScreenLabel().empty() );
}
because this contains extra characters (brackets etc).

The DialogIsHidden() check is needed so that the inset is not deleted when the
dialog is launched for the first time. This would work if LyXText::draw()
is called after the dialog is lauched when the inset is created. I'm not sure
whether this is the case.

Angus

Reply via email to