]> git.lyx.org Git - lyx.git/blobdiff - src/buffer.C
more cursor dispatch
[lyx.git] / src / buffer.C
index d159f095680c0541338860d102a738c6719adf43..d9ba8c0f676b4dc3b0794d6745ea876436c87d8c 100644 (file)
@@ -132,7 +132,7 @@ extern BufferList bufferlist;
 
 namespace {
 
-const int LYX_FORMAT = 225;
+const int LYX_FORMAT = 229;
 
 } // namespace anon
 
@@ -148,7 +148,6 @@ struct Buffer::Impl
        BufferParams params;
        LyXVC lyxvc;
        string temppath;
-       bool nicefile;
        TexRow texrow;
 
        /// need to regenerate .tex ?
@@ -186,8 +185,7 @@ struct Buffer::Impl
 
 
 Buffer::Impl::Impl(Buffer & parent, string const & file, bool readonly_)
-       : nicefile(true),
-         lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_),
+       : lyx_clean(true), bak_clean(true), unnamed(false), read_only(readonly_),
          filename(file), filepath(OnlyPath(file)), file_fully_loaded(false),
                text(0, 0)
 {
@@ -294,18 +292,6 @@ string const & Buffer::temppath() const
 }
 
 
-bool & Buffer::niceFile()
-{
-       return pimpl_->nicefile;
-}
-
-
-bool Buffer::niceFile() const
-{
-       return pimpl_->nicefile;
-}
-
-
 TexRow & Buffer::texrow()
 {
        return pimpl_->texrow;
@@ -390,6 +376,7 @@ void unknownClass(string const & unknown)
 
 } // anon
 
+
 int Buffer::readHeader(LyXLex & lex)
 {
        int unknown_tokens = 0;
@@ -435,9 +422,8 @@ int Buffer::readHeader(LyXLex & lex)
 // if par = 0 normal behavior
 // else insert behavior
 // Returns false if "\end_document" is not read (Asger)
-bool Buffer::readBody(LyXLex & lex, ParagraphList::iterator pit)
+bool Buffer::readBody(LyXLex & lex)
 {
-       Paragraph::depth_type depth = 0;
        bool the_end_read = false;
 
        if (paragraphs().empty()) {
@@ -458,70 +444,13 @@ bool Buffer::readBody(LyXLex & lex, ParagraphList::iterator pit)
                tmpbuf.readHeader(lex);
        }
 
-       while (lex.isOK()) {
-               lex.nextToken();
-               string const token = lex.getString();
-
-               if (token.empty())
-                       continue;
-
-               lyxerr[Debug::PARSER] << "Handling token: `"
-                                     << token << '\'' << endl;
-
-               if (token == "\\end_document") {
-                       the_end_read = true;
-                       continue;
-               }
-
-               readParagraph(lex, token, paragraphs(), pit, depth);
-       }
+       if (text().read(*this, lex))
+               the_end_read = true;
 
        return the_end_read;
 }
 
 
-int Buffer::readParagraph(LyXLex & lex, string const & token,
-                         ParagraphList & pars, ParagraphList::iterator & pit,
-                         lyx::depth_type & depth)
-{
-       static Change current_change;
-       int unknown = 0;
-
-       if (token == "\\begin_layout") {
-               lex.pushToken(token);
-
-               Paragraph par;
-               par.params().depth(depth);
-               if (params().tracking_changes)
-                       par.trackChanges();
-               LyXFont f(LyXFont::ALL_INHERIT, params().language);
-               par.setFont(0, f);
-
-               // insert after
-               if (pit != pars.end())
-                       ++pit;
-
-               pit = pars.insert(pit, par);
-
-               // FIXME: goddamn InsetTabular makes us pass a Buffer
-               // not BufferParams
-               ::readParagraph(*this, *pit, lex);
-
-       } else if (token == "\\begin_deeper") {
-               ++depth;
-       } else if (token == "\\end_deeper") {
-               if (!depth) {
-                       lex.printError("\\end_deeper: " "depth is already null");
-               } else {
-                       --depth;
-               }
-       } else {
-               ++unknown;
-       }
-       return unknown;
-}
-
-
 // needed to insert the selection
 void Buffer::insertStringAsLines(ParagraphList::iterator & par, pos_type & pos,
                                 LyXFont const & fn, string const & str)
@@ -701,7 +630,7 @@ bool Buffer::readFile(LyXLex & lex, string const & filename,
 
        }
 
-       bool the_end = readBody(lex, pit);
+       bool the_end = readBody(lex);
        params().setPaperStuff();
 
        if (!the_end) {
@@ -905,11 +834,10 @@ void Buffer::makeLaTeXFile(ostream & os,
                           bool output_preamble, bool output_body)
 {
        OutputParams runparams = runparams_in;
-       niceFile() = runparams.nice; // this will be used by Insetincludes.
 
        // validate the buffer.
        lyxerr[Debug::LATEX] << "  Validating buffer..." << endl;
-       LaTeXFeatures features(*this, params());
+       LaTeXFeatures features(*this, params(), runparams.nice);
        validate(features);
        lyxerr[Debug::LATEX] << "  Buffer validation done." << endl;
 
@@ -1001,9 +929,6 @@ void Buffer::makeLaTeXFile(ostream & os,
        lyxerr[Debug::INFO] << "Finished making LaTeX file." << endl;
        lyxerr[Debug::INFO] << "Row count was " << texrow().rows() - 1
                            << '.' << endl;
-
-       // we want this to be true outside previews (for insetexternal)
-       niceFile() = true;
 }
 
 
@@ -1048,10 +973,7 @@ void Buffer::makeLinuxDocFile(string const & fname,
        if (!openFileWrite(ofs, fname))
                return;
 
-       niceFile() = runparams.nice; // this will be used by included files.
-
-       LaTeXFeatures features(*this, params());
-
+       LaTeXFeatures features(*this, params(), runparams.nice);
        validate(features);
 
        texrow().reset();
@@ -1097,9 +1019,6 @@ void Buffer::makeLinuxDocFile(string const & fname,
 
        ofs.close();
        // How to check for successful close
-
-       // we want this to be true outside previews (for insetexternal)
-       niceFile() = true;
 }
 
 
@@ -1111,9 +1030,7 @@ void Buffer::makeDocBookFile(string const & fname,
        if (!openFileWrite(ofs, fname))
                return;
 
-       niceFile() = runparams.nice; // this will be used by Insetincludes.
-
-       LaTeXFeatures features(*this, params());
+       LaTeXFeatures features(*this, params(), runparams.nice);
        validate(features);
 
        texrow().reset();
@@ -1158,9 +1075,6 @@ void Buffer::makeDocBookFile(string const & fname,
 
        ofs.close();
        // How to check for successful close
-
-       // we want this to be true outside previews (for insetexternal)
-       niceFile() = true;
 }
 
 
@@ -1274,7 +1188,8 @@ void Buffer::getLabelList(std::vector<string> & list) const
 
 
 // This is also a buffer property (ale)
-void Buffer::fillWithBibKeys(std::vector<std::pair<string, string> > & keys) const
+void Buffer::fillWithBibKeys(std::vector<std::pair<string, string> > & keys)
+       const
 {
        /// if this is a child document and the parent is already loaded
        /// use the parent's list instead  [ale990412]