+2003-03-12 John Levon <levon@movementarian.org>
+
+ * buffer.C:
+ * ParagraphParameters.C: move par params input to
+ a read() method
+
+ * lyxlex_pimpl.C: make nextToken()/next() after a pushToken()
+ behave like a normal read from the stream wrt reading
+ a line vs. a \\token
+
2003-03-12 John Levon <levon@movementarian.org>
* paragraph.C:
#include "tex-strings.h"
#include "lyxlex.h"
+#include "support/lstrings.h"
+
#include <iostream>
using std::ostream;
void ParagraphParameters::read(LyXLex & lex)
{
+ while (lex.isOK()) {
+ lex.nextToken();
+ string const token = lex.getString();
+
+ if (token.empty())
+ continue;
+
+ if (token[0] != '\\') {
+ lex.pushToken(token);
+ break;
+ }
+
+ if (token == "\\noindent") {
+ noindent(true);
+ } else if (token == "\\leftindent") {
+ lex.nextToken();
+ LyXLength value(lex.getString());
+ leftIndent(value);
+ } else if (token == "\\fill_top") {
+ spaceTop(VSpace(VSpace::VFILL));
+ } else if (token == "\\fill_bottom") {
+ spaceBottom(VSpace(VSpace::VFILL));
+ } else if (token == "\\line_top") {
+ lineTop(true);
+ } else if (token == "\\line_bottom") {
+ lineBottom(true);
+ } else if (token == "\\pagebreak_top") {
+ pagebreakTop(true);
+ } else if (token == "\\pagebreak_bottom") {
+ pagebreakBottom(true);
+ } else if (token == "\\start_of_appendix") {
+ startOfAppendix(true);
+ } else if (token == "\\paragraph_spacing") {
+ lex.next();
+ string const tmp = rtrim(lex.getString());
+ if (tmp == "single") {
+ spacing(Spacing(Spacing::Single));
+ } else if (tmp == "onehalf") {
+ spacing(Spacing(Spacing::Onehalf));
+ } else if (tmp == "double") {
+ spacing(Spacing(Spacing::Double));
+ } else if (tmp == "other") {
+ lex.next();
+ spacing(Spacing(Spacing::Other,
+ lex.getFloat()));
+ } else {
+ lex.printError("Unknown spacing token: '$$Token'");
+ }
+ } else if (token == "\\align") {
+ int tmpret = lex.findToken(string_align);
+ if (tmpret == -1)
+ ++tmpret;
+ int const tmpret2 = int(pow(2.0, tmpret));
+ align(LyXAlignment(tmpret2));
+ } else if (token == "\\added_space_top") {
+ lex.nextToken();
+ VSpace value = VSpace(lex.getString());
+ // only add the length when value > 0 or
+ // with option keep
+ if ((value.length().len().value() != 0) ||
+ value.keep() ||
+ (value.kind() != VSpace::LENGTH))
+ spaceTop(value);
+ } else if (token == "\\added_space_bottom") {
+ lex.nextToken();
+ VSpace value = VSpace(lex.getString());
+ // only add the length when value > 0 or
+ // with option keep
+ if ((value.length().len().value() != 0) ||
+ value.keep() ||
+ (value.kind() != VSpace::LENGTH))
+ spaceBottom(value);
+ } else if (token == "\\labelwidthstring") {
+ lex.eatLine();
+ labelWidthString(lex.getString());
+ } else {
+ lex.pushToken(token);
+ break;
+ }
+ }
}
} else {
#endif
Paragraph * par = new Paragraph();
- par->layout(params.getLyXTextClass().defaultLayout());
if (params.tracking_changes)
par->trackChanges();
pos = 0;
if (!layout->obsoleted_by().empty())
par->layout(params.getLyXTextClass()[layout->obsoleted_by()]);
par->params().depth(depth);
+
+ par->params().read(lex);
+
// insert after
if (pit != pars.end())
++pit;
}
else
--depth;
- } else if (token == "\\noindent") {
- pit->params().noindent(true);
- } else if (token == "\\leftindent") {
- lex.nextToken();
- LyXLength value(lex.getString());
- pit->params().leftIndent(value);
- } else if (token == "\\fill_top") {
- pit->params().spaceTop(VSpace(VSpace::VFILL));
- } else if (token == "\\fill_bottom") {
- pit->params().spaceBottom(VSpace(VSpace::VFILL));
- } else if (token == "\\line_top") {
- pit->params().lineTop(true);
- } else if (token == "\\line_bottom") {
- pit->params().lineBottom(true);
- } else if (token == "\\pagebreak_top") {
- pit->params().pagebreakTop(true);
- } else if (token == "\\pagebreak_bottom") {
- pit->params().pagebreakBottom(true);
- } else if (token == "\\start_of_appendix") {
- pit->params().startOfAppendix(true);
- } else if (token == "\\paragraph_spacing") {
- lex.next();
- string const tmp = rtrim(lex.getString());
- if (tmp == "single") {
- pit->params().spacing(Spacing(Spacing::Single));
- } else if (tmp == "onehalf") {
- pit->params().spacing(Spacing(Spacing::Onehalf));
- } else if (tmp == "double") {
- pit->params().spacing(Spacing(Spacing::Double));
- } else if (tmp == "other") {
- lex.next();
- pit->params().spacing(Spacing(Spacing::Other,
- lex.getFloat()));
- } else {
- lex.printError("Unknown spacing token: '$$Token'");
- }
- } else if (token == "\\align") {
- int tmpret = lex.findToken(string_align);
- if (tmpret == -1)
- ++tmpret;
- int const tmpret2 = int(pow(2.0, tmpret));
- pit->params().align(LyXAlignment(tmpret2));
- } else if (token == "\\added_space_top") {
- lex.nextToken();
- VSpace value = VSpace(lex.getString());
- // only add the length when value > 0 or
- // with option keep
- if ((value.length().len().value() != 0) ||
- value.keep() ||
- (value.kind() != VSpace::LENGTH))
- pit->params().spaceTop(value);
- } else if (token == "\\added_space_bottom") {
- lex.nextToken();
- VSpace value = VSpace(lex.getString());
- // only add the length when value > 0 or
- // with option keep
- if ((value.length().len().value() != 0) ||
- value.keep() ||
- (value.kind() != VSpace::LENGTH))
- pit->params().spaceBottom(value);
- } else if (token == "\\labelwidthstring") {
- lex.eatLine();
- pit->params().labelWidthString(lex.getString());
// do not delete this token, it is still needed!
} else if (token == "\\newline") {
pit->insertChar(pos, Paragraph::META_NEWLINE, font, current_change);
// There can have been a whole line pushed so
// we extract the first word and leaves the rest
// in pushTok. (Lgb)
- if (pushTok.find(' ') != string::npos) {
+ if (pushTok.find(' ') != string::npos && pushTok[0] == '\\') {
string tmp;
pushTok = split(pushTok, tmp, ' ');
tmp.copy(buff, string::npos);
// There can have been a whole line pushed so
// we extract the first word and leaves the rest
// in pushTok. (Lgb)
- if (pushTok.find(' ') != string::npos) {
+ if (pushTok.find(' ') != string::npos && pushTok[0] == '\\') {
string tmp;
pushTok = split(pushTok, tmp, ' ');
tmp.copy(buff, string::npos);