Uwe Stöhr wrote: > Here is the patch. Thanks, it looks better. There are still some things to be considered, though.
> To be able to set a default value, I introduced a new unit for Length. I > cannot think of another solution because using a real length to mark that > the user wants the default is not possible, since every set width might be > desired by the user. AFAICS, you have not defined a default length, but a default unit. This might be confused with the already used defaultUnit(), and it doesn't look like a clean solution. You could instead distinguish two types of indendation: ParagraphIndentSeparation and ParagraphCustomIndentSeparation. I think this would be the cleaner approach. The by far best method, I think, would be to setup a HSpace class similar to the VSpace class. This class could inherit Length and DEFAULT. I.e., enum HSpaceKind { DEFAULT, LENGTH ///< user-defined length }; I think it is trivial to set up such a class if you start from VSpace. Some further comments > @@ -566,6 +579,13 @@ > string parsep; > lex >> parsep; > paragraph_separation = parseptranslator().find(parsep); > + } else if (token == "\\paragraph_indentation") { > + lex.next(); > + string indentation = lex.getString(); > + if (indentation == "default") > + pimpl_->indentation = Length(Length::DEFAULT); Does this work? I don't think you can construct a length this way, i.e. via Length(Length::UNIT) > + else > + pimpl_->indentation = Length(indentation); > } else if (token == "\\defskip") { > lex.next(); > string defskip = lex.getString(); > @@ -1370,6 +1393,7 @@ > } > > if (paragraph_separation) { > + // when skip separation > switch (getDefSkip().kind()) { > case VSpace::SMALLSKIP: > os << > "\\setlength{\\parskip}{\\smallskipamount}\n"; @@ -1390,9 +1414,17 @@ > break; > } > texrow.newline(); > - > os << "\\setlength{\\parindent}{0pt}\n"; > texrow.newline(); > + } else { > + // when separation by indentation > + // only output something when a indetn width is given > + if (getIndentation().value() > 0) { Why value() > 0? Am I not allowed to set the indendation to "0em"? > + os << "\\setlength{\\parindent}{" > + << from_utf8(getIndentation().asString()) > + << "}\n"; > + texrow.newline(); > + } > } > > // Now insert the LyX specific LaTeX commands... > @@ -600,8 +620,11 @@ > Spacing::Double, qt_("Double")); > textLayoutModule->lspacingCO->insertItem( > Spacing::Other, qt_("Custom")); > - > + // remove the %-items from the unit choices > + textLayoutModule->indentLengthCO->noPercents(); \setlength{\parindent}{.05\columnwidth} works for me and strikes me not too absurd. > +void GuiDocument::setIndent(int item) > +{ > + bool const enable = (item == 1); > + textLayoutModule->indentLE->setEnabled(enable); > + textLayoutModule->indentLengthCO->setEnabled(enable); > + textLayoutModule->skipLE->setEnabled(false); > + textLayoutModule->skipLengthCO->setEnabled(false); > + // clear values, otherwise one would get for a new document the > + // same settings as default as for a currently opened document It strikes me wrong to do this in the frontend. Probably in Buffer::readHeader(Lexer & lex)? Jürgen