]> git.lyx.org Git - lyx.git/commitdiff
Create ParagraphParameters::read(). JMarc, please note the change to LyXLex - is...
authorJohn Levon <levon@movementarian.org>
Wed, 12 Mar 2003 07:39:17 +0000 (07:39 +0000)
committerJohn Levon <levon@movementarian.org>
Wed, 12 Mar 2003 07:39:17 +0000 (07:39 +0000)
Works for me anyhoo

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6463 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/ParagraphParameters.C
src/buffer.C
src/lyxlex_pimpl.C

index b1bce08ae43a6a51bca7467bc305ea377f730129..0f0e006a0b309053ef0da60af57298d6f03d6c07 100644 (file)
@@ -1,3 +1,13 @@
+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:
index 76fb8aff4ec2e8b885b5d85b5d15022e7b0508b6..90ca29c7303f10a07125579543fcbd9c708a5cde 100644 (file)
@@ -5,6 +5,8 @@
 #include "tex-strings.h"
 #include "lyxlex.h"
 
+#include "support/lstrings.h"
+
 #include <iostream>
 
 using std::ostream;
@@ -268,6 +270,86 @@ void ParagraphParameters::leftIndent(LyXLength const & li)
 
 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;
+               }
+       }
 }
 
 
index 78e2e0795f0b846515432970fcbbc20e8597b8ad..65819731e677eb0035789b7786fec884c017b685 100644 (file)
@@ -536,7 +536,6 @@ Buffer::readToken(LyXLex & lex, ParagraphList & pars,
                } else {
 #endif
                        Paragraph * par = new Paragraph();
-                       par->layout(params.getLyXTextClass().defaultLayout());
                        if (params.tracking_changes)
                                par->trackChanges();
                        pos = 0;
@@ -546,6 +545,9 @@ Buffer::readToken(LyXLex & lex, ParagraphList & pars,
                        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;
@@ -652,69 +654,6 @@ Buffer::readToken(LyXLex & lex, ParagraphList & pars,
                }
                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);
index 653d6fe04e092d2f34600454b6224c557a9c43b5..35d843f8dfb4f6e3fd07d446ecc52e2f35a0a8fa 100644 (file)
@@ -144,7 +144,7 @@ bool LyXLex::Pimpl::next(bool esc /* = false */)
                // 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);
@@ -434,7 +434,7 @@ bool LyXLex::Pimpl::nextToken()
                // 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);