]> git.lyx.org Git - features.git/commitdiff
Improved synctex support
authorStephan Witt <switt@lyx.org>
Thu, 11 Aug 2022 20:45:51 +0000 (22:45 +0200)
committerStephan Witt <switt@lyx.org>
Thu, 11 Aug 2022 20:45:51 +0000 (22:45 +0200)
- 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

lib/RELEASE-NOTES
src/BufferParams.cpp
src/frontends/qt/GuiView.cpp

index 02bb3deed83ab3fc5477557903b5311b8ff50abc..ccab1bc96ba26c438e405e7ed497229610866d07 100644 (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
 
index e62d0100c8e6094f1b5424d653766ddda3ecf6c1..3bb9445adb1917c32c56b9cfb1a34eda7cea753c 100644 (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";
        }
 
index 28c196da8559f9d9b12379bbb4439f86049046e7..4492e752091b2cdcc2bd19324cad59c6c8ad2d09 100644 (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;
                        }