On Thu, Aug 22, 2002 at 08:34:40AM +0200, Juergen Vigna wrote:
> >
> > A dirty fix for now would be to put code on the menu emitting a sequence
> > "begin-paragraph; option-insert;" (pseudocode).
>
> I think this could be fixed for now quite easily. We just have to
> draw OptInset as the first thing in LyXText (so WYSISYG is always
> given!),
Not easy IMHO.
> then we should write them to the LyXFile first so that
> in the next read they outtomagically are at the first positions,
> which then won't give conflictls later when we find a better
> solution,
That, together with my above dirty fix.
> would that be a plan? IMO this can be realized quite and
> also in a more or less clean way.
Hmmm, not very clean, but a compromise that will prevent "wrong" document
files being easily created or living on forever. Yes.
> (Obviously first we would have to commit this patch then we can
> try to do the above, if you give the go I may even find the time
> to have a go ;)
Martin
PS just tried it. It isn't so hard. I have in insetoptarg.C:
void InsetOptArg::write(Buffer const * buf, ostream & os) const
{
os << "\n\\begin_inset OptArg" << "\n";
InsetCollapsable::write(buf, os);
os << "\n\\end_inset \n\n";
}
and then in paragraph.C:
@@ -241,6 +254,13 @@ void Paragraph::writeFile(Buffer const *
if (bibkey)
bibkey->write(buf, os);
+ // Put Optional Argument inset always at start:
+ InsetOptArg * ioa = optArgInset(*this);
+ if (layout()->optionalargs == 1) {
+ if (ioa != 0)
+ ioa->write(buf, os);
+ }
+
LyXFont font1(LyXFont::ALL_INHERIT, bparams.language);
int column = 0;
@@ -274,10 +294,13 @@ void Paragraph::writeFile(Buffer const *
// the file
inset->write(buf, os);
} else {
- os << "\n\\begin_inset ";
- inset->write(buf, os);
- os << "\n\\end_inset \n\n";
- column = 0;
+ // Suppress writing opt arg in middle:
+ if (inset != ioa) {
+ os << "\n\\begin_inset ";
+ inset->write(buf, os);
+ os << "\n\\end_inset \n\n";
+ column = 0;
+ }
}
}
break;
...and this works. It even has the added benefit of silently dropping
optional insets in illegal places...
Martin
msg43373/pgp00000.pgp
Description: PGP signature
