]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetNewline.cpp
Stupid bug fix.
[lyx.git] / src / insets / InsetNewline.cpp
index 72f7e1370999042f364f799b79349801025edcd8..62be1d3ca87e2f909b1cab6929de57236768d743 100644 (file)
@@ -52,23 +52,16 @@ void InsetNewlineParams::write(ostream & os) const
 
 void InsetNewlineParams::read(Lexer & lex)
 {
-       lex.next();
-       string const command = lex.getString();
-
-       if (command == "newline")
+       string token;
+       lex.setContext("InsetNewlineParams::read");
+       lex >> token;   
+       if (token == "newline")
                kind = InsetNewlineParams::NEWLINE;
-       else if (command == "linebreak")
+       else if (token == "linebreak")
                kind = InsetNewlineParams::LINEBREAK;
        else
-               lex.printError("InsetNewline: Unknown kind: `$$Token'");
-
-       string token;
-       lex >> token;
-       if (!lex)
-               return;
-       if (token != "\\end_inset")
-               lex.printError("Missing \\end_inset at this point. "
-                              "Read: `$$Token'");
+               lex.printError("Unknown kind: `$$Token'");
+       lex >> "\\end_inset";
 }
 
 
@@ -122,9 +115,8 @@ bool InsetNewline::getStatus(Cursor & cur, FuncRequest const & cmd,
                        InsetNewlineParams params;
                        string2params(to_utf8(cmd.argument()), params);
                        status.setOnOff(params_.kind == params.kind);
-               } else {
-                       status.enabled(true);
                }
+               status.setEnabled(true);
                return true;
        default:
                return Inset::getStatus(cur, cmd, status);
@@ -267,18 +259,11 @@ void InsetNewline::string2params(string const & in, InsetNewlineParams & params)
        params = InsetNewlineParams();
        if (in.empty())
                return;
-
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
-
-       string name;
-       lex >> name;
-       if (!lex || name != "newline") {
-               LYXERR0("Expected arg 1 to be \"newlien\" in " << in);
-               return;
-       }
-
+       lex.setContext("InsetNewline::string2params");
+       lex >> "newline";
        params.read(lex);
 }