Em Dom 10 Jul 2005 07:35, João Luis Meloni Assirati escreveu: > Hi, > > I'm sorry for the delay. Here are the final patches for DVI inverse search > for lyx 1.4.
New versions of the patches. The last ones dont generate the correct .dvi file when LFUN_UPDATE is called. I also split the ChangeLogs into separated diffs. Regards, João.
Index: lib/configure.m4 =================================================================== RCS file: /cvs/lyx/lyx-devel/lib/configure.m4,v retrieving revision 1.101 diff -u -r1.101 configure.m4 --- lib/configure.m4 2005/06/14 10:29:46 1.101 +++ lib/configure.m4 2005/07/12 12:13:28 @@ -230,6 +230,29 @@ latex_to_dvi=$LATEX test -z "$latex_to_dvi" && latex_to_dvi="none" +echo -n "Checking if $LATEX can do source specials... " +cat >chksp.tex <<EOF +\\nonstopmode +\\documentclass{article} +\\begin{document} +Source specials test. +\\end{document} +EOF +# Is there any other known switch for source specials +# besides --src-specials? +for opt in --src-specials; do + if $LATEX $opt chksp.tex </dev/null 1>/dev/null 2>&1; then + source_specials_switch=$opt + break + fi +done +if test "$source_specials_switch"; then + echo "yes with $source_specials_switch." +else + echo "no." +fi +rm -f chksp.{tex,log,aux,dvi} + # Search for pdflatex if test ${lyx_check_config} = no ; then latex_to_pdf=none @@ -692,6 +715,7 @@ $rc_entries \\font_encoding "$chk_fontenc" \\tex_allows_spaces $tex_allows_spaces +\\source_specials_switch "$source_specials_switch" EOF if [ "x$use_cygwin_path_fix" != "x" ]
Index: lib/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/lib/ChangeLog,v retrieving revision 1.715 diff -u -r1.715 ChangeLog --- lib/ChangeLog 2005/07/12 10:33:43 1.715 +++ lib/ChangeLog 2005/07/12 12:14:09 @@ -1,3 +1,9 @@ +2005-07-12 Joao Luis Meloni Assirati <[EMAIL PROTECTED]> + + * configure.m4: add code to check if latex can do source specials. + Write the command line switch to lyxrc.defaults under the option + \source_specials_switch. + 2005-07-12 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * layouts/scrclass.inc: fix bad comment.
Index: src/converter.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/converter.h,v retrieving revision 1.40 diff -u -r1.40 converter.h --- src/converter.h 2005/01/14 19:13:17 1.40 +++ src/converter.h 2005/07/12 13:03:03 @@ -107,12 +107,13 @@ bool convert(Buffer const * buffer, std::string const & from_file, std::string const & to_file_base, std::string const & from_format, std::string const & to_format, - std::string & to_file, bool try_default = false); + std::string & to_file, bool try_default = false, + bool for_preview = false); /// bool convert(Buffer const * buffer, std::string const & from_file, std::string const & to_file_base, std::string const & from_format, std::string const & to_format, - bool try_default = false); + bool try_default = false, bool for_preview = false); /// void update(Formats const & formats); /// @@ -137,7 +138,7 @@ std::string const & filename); /// bool runLaTeX(Buffer const & buffer, std::string const & command, - OutputParams const &); + std::string const & name, OutputParams const &); /// ConverterList converterlist_; /// Index: src/converter.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/converter.C,v retrieving revision 1.106 diff -u -r1.106 converter.C --- src/converter.C 2005/06/09 15:19:07 1.106 +++ src/converter.C 2005/07/12 13:03:04 @@ -281,7 +281,8 @@ bool Converters::convert(Buffer const * buffer, string const & from_file, string const & to_file_base, string const & from_format, string const & to_format, - string & to_file, bool try_default) + string & to_file, bool try_default, + bool for_preview) { string const to_ext = formats.extension(to_format); to_file = ChangeExtension(to_file_base, to_ext); @@ -321,6 +322,7 @@ } OutputParams runparams; runparams.flavor = getFlavor(edgepath); + runparams.srcspecials = (for_preview && to_format == "dvi"); string path = OnlyPath(from_file); Path p(path); @@ -356,7 +358,7 @@ run_latex = true; string const command = subst(conv.command, token_from, ""); lyxerr[Debug::FILES] << "Running " << command << endl; - if (!runLaTeX(*buffer, command, runparams)) + if (!runLaTeX(*buffer, command, from_file, runparams)) return false; } else { if (conv.need_aux && !run_latex @@ -364,7 +366,7 @@ lyxerr[Debug::FILES] << "Running " << latex_command_ << " to update aux file"<< endl; - runLaTeX(*buffer, latex_command_, runparams); + runLaTeX(*buffer, latex_command_, from_file, runparams); } string const infile2 = (conv.original_dir) @@ -513,11 +515,11 @@ bool Converters::convert(Buffer const * buffer, string const & from_file, string const & to_file_base, string const & from_format, string const & to_format, - bool try_default) + bool try_default, bool for_preview) { string to_file; return convert(buffer, from_file, to_file_base, from_format, to_format, - to_file, try_default); + to_file, try_default, for_preview); } @@ -566,7 +568,7 @@ bool Converters::runLaTeX(Buffer const & buffer, string const & command, - OutputParams const & runparams) + string const & name, OutputParams const & runparams) { buffer.busy(true); buffer.message(_("Running LaTeX...")); @@ -574,7 +576,6 @@ runparams.document_language = buffer.params().language->babel(); // do the LaTeX run(s) - string const name = buffer.getLatexName(); LaTeX latex(command, runparams, name, buffer.filePath()); TeXErrors terr; showMessage show(buffer); Index: src/exporter.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/exporter.h,v retrieving revision 1.22 diff -u -r1.22 exporter.h --- src/exporter.h 2005/01/19 15:03:29 1.22 +++ src/exporter.h 2005/07/12 13:03:04 @@ -26,11 +26,12 @@ /// static bool Export(Buffer * buffer, std::string const & format, - bool put_in_tempdir, std::string & result_file); + bool put_in_tempdir, bool for_preview, + std::string & result_file); /// static bool Export(Buffer * buffer, std::string const & format, - bool put_in_tempdir); + bool put_in_tempdir, bool for_preview); /// static bool Preview(Buffer * buffer, std::string const & format); Index: src/exporter.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/exporter.C,v retrieving revision 1.60 diff -u -r1.60 exporter.C --- src/exporter.C 2005/04/26 11:12:10 1.60 +++ src/exporter.C 2005/07/12 13:03:05 @@ -136,7 +136,8 @@ bool Exporter::Export(Buffer * buffer, string const & format, - bool put_in_tempdir, string & result_file) + bool put_in_tempdir, bool for_preview, + string & result_file) { string backend_format; OutputParams runparams; @@ -164,6 +165,11 @@ backend_format = format; string filename = buffer->getLatexName(false); + if(for_preview && format == "dvi") { + filename = ChangeExtension(filename, ""); + filename += "_pre"; + filename = ChangeExtension(filename, "tex"); + } filename = AddName(buffer->temppath(), filename); filename = ChangeExtension(filename, formats.extension(backend_format)); @@ -196,7 +202,8 @@ } if (!converters.convert(buffer, filename, filename, - backend_format, format, result_file)) + backend_format, format, result_file, + false, for_preview)) return false; if (!put_in_tempdir) { @@ -236,17 +243,18 @@ bool Exporter::Export(Buffer * buffer, string const & format, - bool put_in_tempdir) + bool put_in_tempdir, bool for_preview) { string result_file; - return Export(buffer, format, put_in_tempdir, result_file); + return Export(buffer, format, put_in_tempdir, for_preview, result_file); } bool Exporter::Preview(Buffer * buffer, string const & format) { string result_file; - if (!Export(buffer, format, true, result_file)) + if (!Export(buffer, format, true, + !lyxrc.source_specials_switch.empty(), result_file)) return false; return formats.view(*buffer, result_file, format); } Index: src/outputparams.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/outputparams.h,v retrieving revision 1.13 diff -u -r1.13 outputparams.h --- src/outputparams.h 2005/07/07 10:51:56 1.13 +++ src/outputparams.h 2005/07/12 13:03:05 @@ -89,6 +89,10 @@ OutputParams instances. */ boost::shared_ptr<ExportData> exportdata; + + /** Whether to insert or not source specials. + */ + bool srcspecials; }; #endif // NOT OUTPUTPARAMS_H Index: src/outputparams.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/outputparams.C,v retrieving revision 1.3 diff -u -r1.3 outputparams.C --- src/outputparams.C 2004/11/02 11:25:16 1.3 +++ src/outputparams.C 2005/07/12 13:03:05 @@ -18,7 +18,7 @@ : flavor(LATEX), nice(false), moving_arg(false), free_spacing(false), use_babel(false), linelen(0), depth(0), - exportdata(new ExportData) + exportdata(new ExportData), srcspecials(false) {} Index: src/LaTeX.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/LaTeX.C,v retrieving revision 1.109 diff -u -r1.109 LaTeX.C --- src/LaTeX.C 2005/02/23 16:56:40 1.109 +++ src/LaTeX.C 2005/07/12 13:03:05 @@ -383,7 +383,8 @@ int LaTeX::startscript() { - string tmp = cmd + ' ' + QuoteName(file) + " > " + os::nulldev(); + string tmp = cmd + (runparams.srcspecials?(' ' + lyxrc.source_specials_switch):"") + + ' ' + QuoteName(file) + " > " + os::nulldev(); Systemcall one; return one.startscript(Systemcall::Wait, tmp); } Index: src/lyxfunc.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxfunc.C,v retrieving revision 1.658 diff -u -r1.658 lyxfunc.C --- src/lyxfunc.C 2005/05/31 14:40:24 1.658 +++ src/lyxfunc.C 2005/07/12 13:03:06 @@ -790,7 +790,7 @@ } case LFUN_UPDATE: - Exporter::Export(owner->buffer(), argument, true); + Exporter::Export(owner->buffer(), argument, true, true); view()->showErrorList(BufferFormat(*owner->buffer())); break; @@ -800,7 +800,7 @@ break; case LFUN_BUILDPROG: - Exporter::Export(owner->buffer(), "program", true); + Exporter::Export(owner->buffer(), "program", true, false); view()->showErrorList(_("Build")); break; @@ -813,7 +813,7 @@ if (argument == "custom") owner->getDialogs().show("sendto"); else { - Exporter::Export(owner->buffer(), argument, false); + Exporter::Export(owner->buffer(), argument, false, false); view()->showErrorList(BufferFormat(*owner->buffer())); } break; @@ -847,7 +847,7 @@ } else { Exporter::Export(buffer, format_name, true, - filename); + false, filename); } // Substitute $$FName for filename @@ -882,7 +882,7 @@ Buffer * buffer = owner->buffer(); - if (!Exporter::Export(buffer, "dvi", true)) { + if (!Exporter::Export(buffer, "dvi", true, false)) { showPrintError(buffer->fileName()); break; } @@ -1097,10 +1097,8 @@ } view()->setCursorFromRow(row); - view()->center(); - // see BufferView_pimpl::center() - view()->updateScrollbar(); + view()->update(); break; } @@ -1980,6 +1978,7 @@ case LyXRC::RC_SERVERPIPE: case LyXRC::RC_SET_COLOR: case LyXRC::RC_SHOW_BANNER: + case LyXRC::RC_SOURCE_SPECIALS_SWITCH: case LyXRC::RC_SPELL_COMMAND: case LyXRC::RC_TEMPDIRPATH: case LyXRC::RC_TEMPLATEPATH: Index: src/lyxrc.h =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxrc.h,v retrieving revision 1.93 diff -u -r1.93 lyxrc.h --- src/lyxrc.h 2005/03/25 15:27:29 1.93 +++ src/lyxrc.h 2005/07/12 13:03:07 @@ -120,6 +120,7 @@ RC_SERVERPIPE, RC_SET_COLOR, RC_SHOW_BANNER, + RC_SOURCE_SPECIALS_SWITCH, RC_SPELL_COMMAND, RC_TEMPDIRPATH, RC_TEMPLATEPATH, @@ -384,6 +385,10 @@ * The string is input, stored and output in native format. */ std::string path_prefix; + /** Which command line option to pass to latex for + * dvi with source information + */ + std::string source_specials_switch; }; Index: src/lyxrc.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/lyxrc.C,v retrieving revision 1.191 diff -u -r1.191 lyxrc.C --- src/lyxrc.C 2005/06/18 00:18:28 1.191 +++ src/lyxrc.C 2005/07/12 13:03:08 @@ -155,6 +155,7 @@ { "\\serverpipe", LyXRC::RC_SERVERPIPE }, { "\\set_color", LyXRC::RC_SET_COLOR }, { "\\show_banner", LyXRC::RC_SHOW_BANNER }, + { "\\source_specials_switch", LyXRC::RC_SOURCE_SPECIALS_SWITCH }, { "\\spell_command", LyXRC::RC_SPELL_COMMAND }, { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH }, { "\\template_path", LyXRC::RC_TEMPLATEPATH }, @@ -280,6 +281,7 @@ preview = PREVIEW_OFF; preview_hashed_labels = false; preview_scale_factor = "0.9"; + source_specials_switch = ""; user_name = lyx::support::user_name(); @@ -1150,6 +1152,11 @@ path_prefix = lexrc.getString(); break; + case RC_SOURCE_SPECIALS_SWITCH: + if (lexrc.next()) + source_specials_switch = lexrc.getString(); + break; + case RC_LAST: break; // this is just a dummy } } @@ -1978,6 +1985,11 @@ case RC_VIEWER: // Ignore it + case RC_SOURCE_SPECIALS_SWITCH: + if (ignore_system_lyxrc || + source_specials_switch != system_lyxrc.source_specials_switch) + os << "\\source_specials_switch " << '"' << source_specials_switch << '"' << '\n'; + os << "\n#\n" << "# CONVERTERS SECTION ##########################\n" << "#\n\n"; @@ -2387,6 +2399,10 @@ case RC_SHOW_BANNER: str = _("De-select if you don't want the startup banner."); + break; + + case RC_SOURCE_SPECIALS_SWITCH: + str = _("LaTeX command line switch to enable source information in the dvi."); break; case RC_SPELL_COMMAND: Index: src/insets/ExternalSupport.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/ExternalSupport.C,v retrieving revision 1.21 diff -u -r1.21 ExternalSupport.C --- src/insets/ExternalSupport.C 2005/07/10 09:31:27 1.21 +++ src/insets/ExternalSupport.C 2005/07/12 13:03:09 @@ -315,7 +315,7 @@ support::ChangeExtension(to_file, string()); /* bool const success = */ converters.convert(&buffer, temp_file, to_file_base, - from_format, to_format, true); + from_format, to_format, true, false); // return success } Index: src/insets/insetgraphics.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/insetgraphics.C,v retrieving revision 1.282 diff -u -r1.282 insetgraphics.C --- src/insets/insetgraphics.C 2005/07/10 09:31:27 1.282 +++ src/insets/insetgraphics.C 2005/07/12 13:03:09 @@ -706,7 +706,7 @@ << "\tfile to convert = " << temp_file << '\n' << "\t from " << from << " to " << to << '\n'; - if (converters.convert(&buf, temp_file, temp_file, from, to, true)) { + if (converters.convert(&buf, temp_file, temp_file, from, to, true, false)) { runparams.exportdata->addExternalFile("latex", to_file, output_to_file); runparams.exportdata->addExternalFile("dvi",
Index: src/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/ChangeLog,v retrieving revision 1.2213 diff -u -r1.2213 ChangeLog --- src/ChangeLog 2005/07/07 10:51:55 1.2213 +++ src/ChangeLog 2005/07/12 12:12:38 @@ -1,3 +1,19 @@ +2005-07-12 Joao Luis Meloni Assirati <[EMAIL PROTECTED]> + + * exporter.{C.h} (Export): + * converter.{C,h} (convert): add the argument bool for_preview to + discriminate the conversion to dvi preview with source specials. + * converter.{C,h} (runLaTeX): Add the argument string name to runLaTeX + to tell which is the tex file being latexed which now is different + from buffer.getLatexName() in the conversion tex->dvi with source + specials. + * LaTeX.C (startscript): add the command line switch for source specials + to latex in startscript. + * outputparams.{C,h}: nem member bool srcspecials. + * lyxrc.C: add configuration option \source_specials_switch. + * lyxfunc.C: adjust uses of Exporter::Export fix LFUN_GOTOFILEROW. + * buffer.C (dispatch): adjust use of Exporter::Export. + 2005-06-21 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * buffer.C: format incremented to 242. There is no file format per Index: src/insets/ChangeLog =================================================================== RCS file: /cvs/lyx/lyx-devel/src/insets/ChangeLog,v retrieving revision 1.1161 diff -u -r1.1161 ChangeLog --- src/insets/ChangeLog 2005/07/10 09:31:27 1.1161 +++ src/insets/ChangeLog 2005/07/12 12:12:54 @@ -1,3 +1,8 @@ +2005-07-12 Joao Luis Meloni Assirati <[EMAIL PROTECTED]> + * ExternalSupport.C (updateExternal): + * insetgraphics.C (prepareFile): adjust from argument changes in + converters.convert. + 2005-07-10 Georg Baum <[EMAIL PROTECTED]> * ExternalSupport.C (subst_path): adjust to latex_path changes and