]> git.lyx.org Git - features.git/commitdiff
support synctex in tex2lyx.cpp
authorUwe Stöhr <uwestoehr@lyx.org>
Sun, 24 Jun 2012 14:59:21 +0000 (16:59 +0200)
committerUwe Stöhr <uwestoehr@lyx.org>
Sun, 24 Jun 2012 14:59:21 +0000 (16:59 +0200)
- tex2lyx/Preamble.cpp/h: handle \synctex and package srcltx
- tex2lyx/test/test-structure.tex: add \synctex

src/tex2lyx/Preamble.cpp
src/tex2lyx/Preamble.h
src/tex2lyx/test/test-structure.tex

index 5504c535af32215139023e7f9624ca8bac3a9c6f..ad9b76014cf1b6fab38844bb8679426bf6d6a5b3 100644 (file)
@@ -470,6 +470,7 @@ Preamble::Preamble() : one_language(true), title_layout_found(false)
        //h_options;
        h_output_changes          = "false";
        h_output_sync             = "0";
+       //h_output_sync_macro
        h_papercolumns            = "1";
        h_paperfontsize           = "default";
        h_paperorientation        = "portrait";
@@ -776,6 +777,15 @@ void Preamble::handle_package(Parser &p, string const & name,
                options.clear();
        }
 
+       else if (name == "srcltx") {
+               h_output_sync = "1";
+               if (!opts.empty()) {
+                       h_output_sync_macro = "\\usepackage[" + opts + "]{srcltx}";
+                       options.clear();
+               } else
+                       h_output_sync_macro = "\\usepackage{srcltx}";
+       }
+
        else if (is_known(name, known_old_language_packages)) {
                // known language packages from the times before babel
                // if they are found and not also babel, they will be used as
@@ -969,8 +979,10 @@ bool Preamble::writeLyXHeader(ostream & os, bool subdoc)
           << "\\font_tt_scale " << h_font_tt_scale << "\n\n"
           << "\\graphics " << h_graphics << "\n"
           << "\\default_output_format " << h_default_output_format << "\n"
-          << "\\output_sync " << h_output_sync << "\n"
-          << "\\bibtex_command " << h_bibtex_command << "\n"
+          << "\\output_sync " << h_output_sync << "\n";
+       if (h_output_sync == "1")
+               os << "\\output_sync_macro \"" << h_output_sync_macro << "\"\n";
+       os << "\\bibtex_command " << h_bibtex_command << "\n"
           << "\\index_command " << h_index_command << "\n";
        if (!h_float_placement.empty())
                os << "\\float_placement " << h_float_placement << "\n";
@@ -1451,6 +1463,19 @@ void Preamble::parse(Parser & p, string const & forceclass,
                else if (t.cs() == "setstretch")
                        h_spacing = "other " + p.verbatim_item();
 
+               else if (t.cs() == "synctex") {
+                       // the scheme is \synctex=value
+                       // where value can only be "1" or "-1"
+                       h_output_sync = "1";
+                       // there can be any character behind the value (e.g. a linebreak or a '\'
+                       // therefore we extract it char by char
+                       p.get_token();
+                       string value = p.get_token().asInput();
+                       if (value == "-")
+                               value += p.get_token().asInput();
+                       h_output_sync_macro = "\\synctex=" + value;
+               }
+
                else if (t.cs() == "begin") {
                        string const name = p.getArg('{', '}');
                        if (name == "document")
index b9ab8643b5eaee09e40a3647f63c0457fb27c5ea..ba4ef31c8eb3267dcde5fb5ebd4c94b0a60ca2a0 100644 (file)
@@ -124,6 +124,7 @@ private:
        std::string h_options;
        std::string h_output_changes;
        std::string h_output_sync;
+       std::string h_output_sync_macro;
        std::string h_papercolumns;
        std::string h_paperfontsize;
        std::string h_paperorientation;
index 3cb6fc7a89dd25910f134323fab80be348abf1a4..345750a894637d5d99fac34a026831e67cf134d1 100644 (file)
@@ -4,7 +4,7 @@
 \usepackage[latin9]{inputenc}
 \usepackage{color}
 \usepackage{rotfloat}
-\usepackage{wrapfig}
+\synctex=-1\usepackage{wrapfig}
 
 \makeatletter