From 9f9104d9c4b97358649311f67796849549cfaf02 Mon Sep 17 00:00:00 2001 From: Pavel Sanda Date: Tue, 25 May 2010 11:36:00 +0000 Subject: [PATCH] Introduce output_sync ui for forward/reverse search git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34498 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/FORMAT | 6 +- lib/lyx2lyx/lyx_2_0.py | 19 ++- src/Buffer.cpp | 3 +- src/BufferParams.cpp | 18 +++ src/BufferParams.h | 4 + src/frontends/qt4/GuiDocument.cpp | 10 ++ src/frontends/qt4/ui/OutputUi.ui | 204 +++++++++++++++++++----------- 7 files changed, 185 insertions(+), 79 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index 9bd34626aa..e4f75687e2 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -7,8 +7,12 @@ The good example would be 2010-01-10 entry. ----------------------- +2010-05-25 Pavel Sanda + * Format incremented to 390: support for ouput sync (forward/reverse) + search. New boolean \forward_search and string \forward_macro. + 2010-05-24 Richard Heck - * Format incremented to 389: remove quotes from html_latex_* params. + * Format incremented to 389: remove quotes from html_latex_* params. 2010-05-18 Uwe Stöhr * Format incremented to 388: support for page sizes A0-3, A6, B0-3, B6 diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py index bf62cbf599..cf5ca855be 100644 --- a/lib/lyx2lyx/lyx_2_0.py +++ b/lib/lyx2lyx/lyx_2_0.py @@ -1577,6 +1577,17 @@ def revert_html_quotes(document): m = l.match(line) document.header[i] = "\\html_latex_end \"" + m.group(1) + "\"" + +def revert_output_sync(document): + " Remove forward search options " + i = find_token(document.header, '\\forward_search', 0) + if i != -1: + del document.header[i] + i = find_token(document.header, '\\forward_macro', 0) + if i != -1: + del document.header[i] + + ## # Conversion hub # @@ -1625,10 +1636,12 @@ convert = [[346, []], [386, []], [387, []], [388, []], - [389, [convert_html_quotes]] - ] + [389, [convert_html_quotes]], + [390, []] + ] -revert = [[388, [revert_html_quotes]], +revert = [[389, [revert_output_sync]], + [388, [revert_html_quotes]], [387, [revert_pagesizes]], [386, [revert_math_scale]], [385, [revert_lyx_version]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index b80a69407a..d0b9a4db4a 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -126,7 +126,7 @@ namespace { // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -int const LYX_FORMAT = 389; // rgh: change how html_latex_* is stored +int const LYX_FORMAT = 390; // ps: forward view typedef map DepClean; typedef map > RefCache; @@ -673,6 +673,7 @@ int Buffer::readHeader(Lexer & lex) params().isfontcolor = false; params().notefontcolor = lyx::rgbFromHexName("#cccccc"); params().boxbgcolor = lyx::rgbFromHexName("#ff0000"); + params().output_sync_macro.erase(); for (int i = 0; i < 4; ++i) { params().user_defined_bullet(i) = ITEMIZE_DEFAULTS[i]; diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 93853b17ef..bfcae0e618 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -404,6 +404,8 @@ BufferParams::BufferParams() html_be_strict = false; html_math_output = MathML; html_math_img_scale = 1.0; + + output_sync = false; } @@ -834,6 +836,10 @@ string BufferParams::readToken(Lexer & lex, string const & token, } else if (token == "\\html_latex_end") { lex.eatLine(); html_latex_end = lex.getString(); + } else if (token == "\\output_sync") { + lex >> output_sync; + } else if (token == "\\output_sync_macro") { + lex >> output_sync_macro; } else { lyxerr << "BufferParams::readToken(): Unknown token: " << token << endl; @@ -936,6 +942,9 @@ void BufferParams::writeFile(ostream & os) const } os << "\n\\graphics " << graphicsDriver << '\n'; os << "\\default_output_format " << defaultOutputFormat << '\n'; + os << "\\output_sync " << output_sync << '\n'; + if (!output_sync_macro.empty()) + os << "\\output_sync_macro \"" << output_sync_macro << "\"\n"; os << "\\bibtex_command " << bibtex_command << '\n'; os << "\\index_command " << index_command << '\n'; @@ -1653,6 +1662,15 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, // Now insert the LyX specific LaTeX commands... docstring lyxpreamble; + if (output_sync) { + if (!output_sync_macro.empty()) + lyxpreamble += from_utf8(output_sync_macro) +"\n"; + else if (features.runparams().flavor == OutputParams::LATEX) + lyxpreamble += "\\usepackage[active]{srcltx}\n"; + else if (features.runparams().flavor == OutputParams::PDFLATEX) + lyxpreamble += "\\synctex=-1\n"; + } + // due to interferences with babel and hyperref, the color package has to // be loaded (when it is not already loaded) before babel when hyperref // is used with the colorlinks option, see diff --git a/src/BufferParams.h b/src/BufferParams.h index a4143a0c7e..9466758857 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -399,6 +399,10 @@ public: std::string html_latex_start; /// std::string html_latex_end; + /// generate output usable for reverse/forward search + bool output_sync; + /// custom LaTeX macro from user instead our own + std::string output_sync_macro; private: /// diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index ddfed79a96..6d97e6233d 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -653,6 +653,10 @@ GuiDocument::GuiDocument(GuiView & lv) this, SLOT(change_adaptor())); connect(outputModule->xetexCB, SIGNAL(toggled(bool)), this, SLOT(xetexChanged(bool))); + connect(outputModule->outputsyncCB, SIGNAL(clicked()), + this, SLOT(change_adaptor())); + connect(outputModule->synccustomCB, SIGNAL(editTextChanged(QString)), + this, SLOT(change_adaptor())); connect(outputModule->defaultFormatCO, SIGNAL(activated(int)), this, SLOT(change_adaptor())); connect(outputModule->mathimgSB, SIGNAL(valueChanged(double)), @@ -2274,6 +2278,9 @@ void GuiDocument::applyView() bool const xetex = outputModule->xetexCB->isChecked(); bp_.useXetex = xetex; + bp_.output_sync = outputModule->outputsyncCB->isChecked(); + bp_.output_sync_macro = fromqstr(outputModule->synccustomCB->currentText()); + int mathfmt = outputModule->mathoutCB->currentIndex(); if (mathfmt == -1) mathfmt = 0; @@ -2704,6 +2711,9 @@ void GuiDocument::paramsToDialog() outputModule->xetexCB->setChecked( bp_.baseClass()->outputType() == lyx::LATEX && bp_.useXetex); + outputModule->outputsyncCB->setChecked(bp_.output_sync); + outputModule->synccustomCB->setEditText(toqstr(bp_.output_sync_macro)); + outputModule->mathimgSB->setValue(bp_.html_math_img_scale); outputModule->mathoutCB->setCurrentIndex(bp_.html_math_output); outputModule->strictCB->setChecked(bp_.html_be_strict); diff --git a/src/frontends/qt4/ui/OutputUi.ui b/src/frontends/qt4/ui/OutputUi.ui index 6aa665848a..58bd0d2b6c 100644 --- a/src/frontends/qt4/ui/OutputUi.ui +++ b/src/frontends/qt4/ui/OutputUi.ui @@ -1,75 +1,69 @@ - + OutputUi - - + + 0 0 - 310 - 386 + 335 + 310 - + Form - - - 9 - - - 6 - - - - + + + + Output Format - + true - - + + 9 - + 6 - - - + + + 6 - + 0 - - + + Specify the default output format (for view/update) - + De&fault Output Format: - + defaultFormatCO - - + + Specify the default output format (for view/update) - - - + + + Use the XeTeX processing engine - + Use &XeTeX @@ -77,117 +71,179 @@ - - - + + + + SyncTeX for PDF, srcltx for DVI + + + Output Sync (Resources for Forward/Backward Search) + + + true + + + true + + + false + + + + + + + + Custom Macro: + + + + + + + Custom LaTeX preamble macro + + + true + + + + + + + + + \synctex=1 + + + + + \synctex=-1 + + + + + \usepackage[active]{srcltx} + + + + + + + + + + + + 75 true - + XHTML Output Options - + true - - - - + + + + 50 false - + Whether to comply strictly with XHTML 1.1. - + Strict XHTML 1.1 - - - + + + 50 false - + Math Output - - - + + + 50 false - + Format to use for math output. - + MathML - + HTML - + Images - + LaTeX - - - + + + 50 false - + Math Image Scaling - - - + + + 50 false - + Scaling factor for images used for math output. - + 0.100000000000000 - + 10.000000000000000 - + 0.100000000000000 - + 1.000000000000000 @@ -195,12 +251,12 @@ - - - + + + Qt::Vertical - + 20 40 @@ -211,7 +267,7 @@ - qt_i18n.h + qt_i18n.h -- 2.39.2