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
This commit is contained in:
Pavel Sanda 2010-05-25 11:36:00 +00:00
parent 43939fbb65
commit 9f9104d9c4
7 changed files with 185 additions and 79 deletions

View File

@ -7,8 +7,12 @@ The good example would be 2010-01-10 entry.
-----------------------
2010-05-25 Pavel Sanda <sanda@lyx.org>
* Format incremented to 390: support for ouput sync (forward/reverse)
search. New boolean \forward_search and string \forward_macro.
2010-05-24 Richard Heck <rgheck@comcast.net>
* 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 <uwestoehr@web.de>
* Format incremented to 388: support for page sizes A0-3, A6, B0-3, B6

View File

@ -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]],

View File

@ -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<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > 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];

View File

@ -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

View File

@ -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:
///

View File

@ -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);

View File

@ -1,75 +1,69 @@
<ui version="4.0">
<ui version="4.0" >
<class>OutputUi</class>
<widget class="QWidget" name="OutputUi">
<property name="geometry">
<widget class="QWidget" name="OutputUi" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>310</width>
<height>386</height>
<width>335</width>
<height>310</height>
</rect>
</property>
<property name="windowTitle">
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>9</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="outputFormatGB">
<property name="title">
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QGroupBox" name="outputFormatGB" >
<property name="title" >
<string>Output Format</string>
</property>
<property name="flat">
<property name="flat" >
<bool>true</bool>
</property>
<layout class="QGridLayout">
<property name="margin">
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing">
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0">
<layout class="QHBoxLayout">
<property name="spacing">
<item row="1" column="0" >
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>6</number>
</property>
<property name="margin">
<property name="margin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="defaultFormatLA">
<property name="toolTip">
<widget class="QLabel" name="defaultFormatLA" >
<property name="toolTip" >
<string>Specify the default output format (for view/update)</string>
</property>
<property name="text">
<property name="text" >
<string>De&amp;fault Output Format:</string>
</property>
<property name="buddy">
<property name="buddy" >
<cstring>defaultFormatCO</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="defaultFormatCO">
<property name="toolTip">
<widget class="QComboBox" name="defaultFormatCO" >
<property name="toolTip" >
<string>Specify the default output format (for view/update)</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="xetexCB">
<property name="toolTip">
<item row="0" column="0" >
<widget class="QCheckBox" name="xetexCB" >
<property name="toolTip" >
<string>Use the XeTeX processing engine</string>
</property>
<property name="text">
<property name="text" >
<string>Use &amp;XeTeX</string>
</property>
</widget>
@ -77,117 +71,179 @@
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="xhtmlGB">
<property name="font">
<item>
<widget class="QGroupBox" name="outputsyncCB" >
<property name="toolTip" >
<string>SyncTeX for PDF, srcltx for DVI</string>
</property>
<property name="title" >
<string>Output Sync (Resources for Forward/Backward Search)</string>
</property>
<property name="flat" >
<bool>true</bool>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
<property name="checked" >
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>Custom Macro:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="synccustomCB" >
<property name="toolTip" >
<string>Custom LaTeX preamble macro</string>
</property>
<property name="editable" >
<bool>true</bool>
</property>
<item>
<property name="text" >
<string/>
</property>
</item>
<item>
<property name="text" >
<string>\synctex=1</string>
</property>
</item>
<item>
<property name="text" >
<string>\synctex=-1</string>
</property>
</item>
<item>
<property name="text" >
<string>\usepackage[active]{srcltx}</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="xhtmlGB" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<property name="title" >
<string>XHTML Output Options</string>
</property>
<property name="flat">
<property name="flat" >
<bool>true</bool>
</property>
<layout class="QGridLayout" name="outGridLayout">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="strictCB">
<property name="font">
<layout class="QGridLayout" name="outGridLayout" >
<item row="0" column="0" colspan="2" >
<widget class="QCheckBox" name="strictCB" >
<property name="font" >
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="toolTip">
<property name="toolTip" >
<string>Whether to comply strictly with XHTML 1.1.</string>
</property>
<property name="text">
<property name="text" >
<string>Strict XHTML 1.1</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="mathoutLA">
<property name="font">
<item row="1" column="0" >
<widget class="QLabel" name="mathoutLA" >
<property name="font" >
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<property name="text" >
<string>Math Output</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="mathoutCB">
<property name="font">
<item row="1" column="1" >
<widget class="QComboBox" name="mathoutCB" >
<property name="font" >
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="toolTip">
<property name="toolTip" >
<string>Format to use for math output.</string>
</property>
<item>
<property name="text">
<property name="text" >
<string>MathML</string>
</property>
</item>
<item>
<property name="text">
<property name="text" >
<string>HTML</string>
</property>
</item>
<item>
<property name="text">
<property name="text" >
<string>Images</string>
</property>
</item>
<item>
<property name="text">
<property name="text" >
<string>LaTeX</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="mathimgLA">
<property name="font">
<item row="2" column="0" >
<widget class="QLabel" name="mathimgLA" >
<property name="font" >
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<property name="text" >
<string>Math Image Scaling</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="mathimgSB">
<property name="font">
<item row="2" column="1" >
<widget class="QDoubleSpinBox" name="mathimgSB" >
<property name="font" >
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="toolTip">
<property name="toolTip" >
<string>Scaling factor for images used for math output.</string>
</property>
<property name="minimum">
<property name="minimum" >
<double>0.100000000000000</double>
</property>
<property name="maximum">
<property name="maximum" >
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<property name="singleStep" >
<double>0.100000000000000</double>
</property>
<property name="value">
<property name="value" >
<double>1.000000000000000</double>
</property>
</widget>
@ -195,12 +251,12 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<item>
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
@ -211,7 +267,7 @@
</layout>
</widget>
<includes>
<include location="local">qt_i18n.h</include>
<include location="local" >qt_i18n.h</include>
</includes>
<resources/>
<connections/>