commit 9686fe0c79cdb547f8778d8552402c393491af87
Author: Stephan Witt <[email protected]>
Date:   Thu Aug 11 22:45:51 2022 +0200

    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
---
 lib/RELEASE-NOTES            |    2 ++
 src/BufferParams.cpp         |    2 +-
 src/frontends/qt/GuiView.cpp |    9 ++++++---
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/RELEASE-NOTES b/lib/RELEASE-NOTES
index 02bb3de..ccab1bc 100644
--- a/lib/RELEASE-NOTES
+++ b/lib/RELEASE-NOTES
@@ -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
 
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index e62d010..3bb9445 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -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";
        }
 
diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 28c196d..4492e75 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -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;
                        }
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to