]> git.lyx.org Git - features.git/commitdiff
Improved synctex support
authorStephan Witt <switt@lyx.org>
Sat, 13 Aug 2022 12:20:03 +0000 (14:20 +0200)
committerStephan Witt <switt@lyx.org>
Sat, 13 Aug 2022 12:20:03 +0000 (14:20 +0200)
- Add check for converter with active synctex support to check for synchronized output for activate forward search.

src/Buffer.cpp
src/Buffer.h
src/frontends/qt/GuiView.cpp

index 96005b92157f18b816c8dbc965d66c4faf994cc5..da630da90a6310542473d22261f423db074e4d79 100644 (file)
@@ -1110,6 +1110,22 @@ bool Buffer::readDocument(Lexer & lex)
 }
 
 
+bool Buffer::isSyncTeXenabled() const
+{
+       bool enabled = params().output_sync;
+
+       if (!enabled)
+               for (auto const & c : theConverters()) {
+                       const string dest = c.to().substr(0,3);
+                       if (dest == "dvi" || dest == "pdf") {
+                               const string cmd = c.command();
+                               enabled |= cmd.find("--synctex=1") != string::npos;
+                               if (enabled) break;
+                       }
+               }
+       return enabled;
+}
+
 bool Buffer::importString(string const & format, docstring const & contents, ErrorList & errorList)
 {
        Format const * fmt = theFormats().getFormat(format);
index 7f40351a90a214c1a61d0b85d00431e3ccf567b8..ba066f724c5cd86f61435060bc515cd4b72941d3 100644 (file)
@@ -221,6 +221,11 @@ public:
        int readHeader(Lexer & lex);
 
        double fontScalingFactor() const;
+       /// check for active synctex support:
+       /// - either the document has synchronize output enabled or
+       /// - there is a converter to dvi or pdf defined with synctex command line argument
+       ///   this is the "expert mode", false positives are possible
+       bool isSyncTeXenabled() const;
 
 private:
        ///
index 4492e752091b2cdcc2bd19324cad59c6c8ad2d09..d03fe3bc2f008ac340c2e7769d65dd5f3c7f2d12 100644 (file)
@@ -2681,7 +2681,7 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                break;
        case LFUN_FORWARD_SEARCH:
                enable = !(lyxrc.forward_search_dvi.empty() && lyxrc.forward_search_pdf.empty()) &&
-                       doc_buffer && doc_buffer->params().output_sync;
+                       doc_buffer && doc_buffer->isSyncTeXenabled();
                break;
 
        case LFUN_FILE_INSERT_PLAINTEXT: