Improved synctex support

- Check the state of the synchronize TeX output option of the document to enable or disable the LFUN for forward-search.
- write synctex macro to TeX source not only for PdfLaTeX
This commit is contained in:
Stephan Witt 2022-08-11 22:45:51 +02:00
parent 7391ca961d
commit 9686fe0c79
3 changed files with 9 additions and 4 deletions

View File

@ -35,6 +35,8 @@
* Document (or selection statistics) is now shown in status bar and can be
disabled by the context menu.
* The actual enabled state of the synchronize TeX output option of the document
is used to enable or disable the menu item for forward-search.
!!Documents compilation process and images conversion

View File

@ -2191,7 +2191,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
os << from_utf8(output_sync_macro) +"\n";
else if (features.runparams().flavor == Flavor::LaTeX)
os << "\\usepackage[active]{srcltx}\n";
else if (features.runparams().flavor == Flavor::PdfLaTeX)
else
os << "\\synctex=-1\n";
}

View File

@ -2680,7 +2680,8 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
case LFUN_WINDOW_RAISE:
break;
case LFUN_FORWARD_SEARCH:
enable = !(lyxrc.forward_search_dvi.empty() && lyxrc.forward_search_pdf.empty());
enable = !(lyxrc.forward_search_dvi.empty() && lyxrc.forward_search_pdf.empty()) &&
doc_buffer && doc_buffer->params().output_sync;
break;
case LFUN_FILE_INSERT_PLAINTEXT:
@ -4903,10 +4904,12 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
dr.setMessage(_("Please, preview the document first."));
break;
}
bool const goto_dvi = have_dvi && !lyxrc.forward_search_dvi.empty();
bool const goto_pdf = have_pdf && !lyxrc.forward_search_pdf.empty();
string outname = dviname.onlyFileName();
string command = lyxrc.forward_search_dvi;
if (!have_dvi || (have_pdf &&
pdfname.lastModified() > dviname.lastModified())) {
if ((!goto_dvi || goto_pdf) &&
pdfname.lastModified() > dviname.lastModified()) {
outname = pdfname.onlyFileName();
command = lyxrc.forward_search_pdf;
}