-int Buffer::runLiterate()
-{
- if (!users->text) return 0;
-
- ProhibitInput(users);
-
- // get LaTeX-Filename
- string name = getLatexName();
- // get Literate-Filename
- string lit_name = OnlyFilename(ChangeExtension (getLatexName(),
- lyxrc.literate_extension));
-
- string path = OnlyPath(filename);
-
- string org_path = path;
- if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
- path = tmppath;
- }
-
- Path p(path); // path to Literate file
- users->owner()->getMiniBuffer()->Set(_("Running Literate..."));
-
- // Remove all error insets
- bool removedErrorInsets = users->removeAutoInsets();
-
- // generate the Literate file if necessary
- makeLaTeXFile(lit_name, org_path, false);
-
- string latex_command = lyxrc.pdf_mode ?
- lyxrc.pdflatex_command : lyxrc.latex_command;
- Literate literate(latex_command, name, filepath,
- lit_name,
- lyxrc.literate_command, lyxrc.literate_error_filter,
- lyxrc.build_command, lyxrc.build_error_filter);
- TeXErrors terr;
- int res = literate.weave(terr, users->owner()->getMiniBuffer());
-
- // check return value from literate.weave().
- if ((res & Literate::NO_LOGFILE)) {
- WriteAlert(_("Literate command did not work!"),
- _("Missing log file:"), name);
- } else if ((res & Literate::ERRORS)) {
- users->owner()->getMiniBuffer()->Set(_("Done"));
- // Insert all errors as errors boxes
- users->insertErrors(terr);
-
- // Dvi should also be kept dirty if the latex run
- // ends up with errors. However it should be possible
- // to view a dirty dvi too.
- } else {
- //no errors or any other things to think about so:
- users->owner()->getMiniBuffer()->Set(_("Done"));
- }
-
- // if we removed error insets before we ran LaTeX or if we inserted
- // error insets after we ran LaTeX this must be run:
- if (removedErrorInsets || (res & Literate::ERRORS)){
- users->redraw();
- users->fitCursor(users->text);
- //users->updateScrollbar();
- }
- AllowInput(users);
-
- return literate.getNumErrors();
-}
-
-
-int Buffer::buildProgram()
-{
- if (!users->text) return 0;
-
- ProhibitInput(users);
-
- // get LaTeX-Filename
- string name = getLatexName();
- // get Literate-Filename
- string lit_name = OnlyFilename(ChangeExtension(getLatexName(),
- lyxrc.literate_extension));
-
- string path = OnlyPath(filename);
-
- string org_path = path;
- if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
- path = tmppath;
- }
-
- Path p(path); // path to Literate file
- users->owner()->getMiniBuffer()->Set(_("Building Program..."));
-
- // Remove all error insets
- bool removedErrorInsets = users->removeAutoInsets();
-
- // generate the LaTeX file if necessary
- if (!isNwClean() || removedErrorInsets) {
- makeLaTeXFile(lit_name, org_path, false);
- markNwDirty();
- }
-
- string latex_command = lyxrc.pdf_mode ?
- lyxrc.pdflatex_command : lyxrc.latex_command;
- Literate literate(latex_command, name, filepath,
- lit_name,
- lyxrc.literate_command, lyxrc.literate_error_filter,
- lyxrc.build_command, lyxrc.build_error_filter);
- TeXErrors terr;
- int const res = literate.build(terr, users->owner()->getMiniBuffer());
-
- // check return value from literate.build().
- if ((res & Literate::NO_LOGFILE)) {
- WriteAlert(_("Build did not work!"),
- _("Missing log file:"), name);
- } else if ((res & Literate::ERRORS)) {
- users->owner()->getMiniBuffer()->Set(_("Done"));
- // Insert all errors as errors boxes
- users->insertErrors(terr);
-
- // Literate files should also be kept dirty if the literate
- // command run ends up with errors.
- } else {
- //no errors or any other things to think about so:
- users->owner()->getMiniBuffer()->Set(_("Done"));
- markNwClean();
- }
-
- // if we removed error insets before we ran Literate/Build or
- // if we inserted error insets after we ran Literate/Build this
- // must be run:
- if (removedErrorInsets || (res & Literate::ERRORS)){
- users->redraw();
- users->fitCursor(users->text);
- //users->updateScrollbar();
- }
- AllowInput(users);
-
- return literate.getNumErrors();
-}
-
-