mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 21:55:29 +00:00
Extend LATEXIFY command param handling and add literal param.
File format change. This allows for the relevant InsetCommand-based dialogs (such as citation text before/after, Bibitem label, hyperlink name etc.) to provide both the input of verbatim code or text that is transformed to proper LaTeX code. Some dialogs (Nomencl, Href) already had some methods (although they could not be toggled), which are now centralized and streamlined. The initial work of this patch has been done by Georg Baum (see http://www.lyx.org/trac/attachment/ticket/2751/x.diff) Fixes: #2751, #8227.
This commit is contained in:
parent
043254a3d7
commit
e15a8f3551
@ -7,6 +7,11 @@ changes happened in particular if possible. A good example would be
|
||||
|
||||
-----------------------
|
||||
|
||||
2017-01-28 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 532: literal command inset parameter.
|
||||
With this, inset command params with ParamInfo::HANDLING_LATEXIFY
|
||||
can be passed to LaTeX either verbatim or latexified.
|
||||
|
||||
2017-01-21 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 531: Support for qualified citation lists.
|
||||
\begin_inset CommandInset citation
|
||||
|
@ -1547,6 +1547,54 @@ def revert_qualicites(document):
|
||||
i += 1
|
||||
|
||||
|
||||
command_insets = ["bibitem", "citation", "href", "index_print", "nomenclature"]
|
||||
def convert_literalparam(document):
|
||||
" Add param literal "
|
||||
|
||||
# These already had some sort of latexify method
|
||||
latexified_insets = ["href", "index_print", "nomenclature"]
|
||||
|
||||
for inset in command_insets:
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, '\\begin_inset CommandInset %s' % inset, i)
|
||||
if i == -1:
|
||||
break
|
||||
j = find_end_of_inset(document.body, i)
|
||||
if j == -1:
|
||||
document.warning("Malformed LyX document: Can't find end of %s inset at line %d" % (inset, i))
|
||||
i += 1
|
||||
continue
|
||||
while i < j and document.body[i].strip() != '':
|
||||
i += 1
|
||||
if inset in latexified_insets:
|
||||
document.body.insert(i, "literal \"false\"")
|
||||
else:
|
||||
document.body.insert(i, "literal \"true\"")
|
||||
|
||||
|
||||
|
||||
def revert_literalparam(document):
|
||||
" Remove param literal "
|
||||
|
||||
for inset in command_insets:
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, '\\begin_inset CommandInset %s' % inset, i)
|
||||
if i == -1:
|
||||
break
|
||||
j = find_end_of_inset(document.body, i)
|
||||
if j == -1:
|
||||
document.warning("Malformed LyX document: Can't find end of %s inset at line %d" % (inset, i))
|
||||
i += 1
|
||||
continue
|
||||
k = find_token(document.body, 'literal', i, j)
|
||||
if k == -1:
|
||||
i += 1
|
||||
continue
|
||||
del document.body[k]
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -1575,10 +1623,12 @@ convert = [
|
||||
[528, []],
|
||||
[529, []],
|
||||
[530, []],
|
||||
[531, []]
|
||||
[531, []],
|
||||
[532, [convert_literalparam]]
|
||||
]
|
||||
|
||||
revert = [
|
||||
[531, [revert_literalparam]],
|
||||
[530, [revert_qualicites]],
|
||||
[529, [revert_bibpackopts]],
|
||||
[528, [revert_citekeyonly]],
|
||||
|
@ -1961,20 +1961,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
|
||||
IndicesList::const_iterator iit = indiceslist().begin();
|
||||
IndicesList::const_iterator iend = indiceslist().end();
|
||||
for (; iit != iend; ++iit) {
|
||||
pair<docstring, docstring> indexname_latex =
|
||||
features.runparams().encoding->latexString(iit->index(),
|
||||
features.runparams().dryrun);
|
||||
if (!indexname_latex.second.empty()) {
|
||||
// issue a warning about omitted characters
|
||||
// FIXME: should be passed to the error dialog
|
||||
frontend::Alert::warning(_("Uncodable characters"),
|
||||
bformat(_("The following characters that are used in an index name are not\n"
|
||||
"representable in the current encoding and therefore have been omitted:\n%1$s."),
|
||||
indexname_latex.second));
|
||||
}
|
||||
os << "\\newindex[";
|
||||
os << indexname_latex.first;
|
||||
os << "]{";
|
||||
os << "\\newindex{";
|
||||
os << escape(iit->shortcut());
|
||||
os << "}\n";
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ GuiBibitem::GuiBibitem(QWidget * parent) : InsetParamsWidget(parent)
|
||||
this, SIGNAL(changed()));
|
||||
connect(labelED, SIGNAL(textChanged(QString)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(literalCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
}
|
||||
|
||||
|
||||
@ -41,6 +43,7 @@ void GuiBibitem::paramsToDialog(Inset const * inset)
|
||||
InsetCommandParams const & params = ic->params();
|
||||
keyED->setText(toqstr(params["key"]));
|
||||
labelED->setText(toqstr(params["label"]));
|
||||
literalCB->setChecked(params["literal"] == "true");
|
||||
}
|
||||
|
||||
|
||||
@ -49,6 +52,8 @@ docstring GuiBibitem::dialogToParams() const
|
||||
InsetCommandParams params(insetCode());
|
||||
params["key"] = qstring_to_ucs4(keyED->text());
|
||||
params["label"] = qstring_to_ucs4(labelED->text());
|
||||
params["literal"] = literalCB->isChecked()
|
||||
? from_ascii("true") : from_ascii("false");
|
||||
return from_utf8(InsetCommand::params2string(params));
|
||||
}
|
||||
|
||||
|
@ -127,6 +127,8 @@ GuiCitation::GuiCitation(GuiView & lv)
|
||||
this, SLOT(on_citationStyleCO_currentIndexChanged(int)));
|
||||
connect(starredCB, SIGNAL(clicked()),
|
||||
this, SLOT(updateStyles()));
|
||||
connect(literalCB, SIGNAL(clicked()),
|
||||
this, SLOT(changed()));
|
||||
connect(forceuppercaseCB, SIGNAL(clicked()),
|
||||
this, SLOT(updateStyles()));
|
||||
connect(textBeforeED, SIGNAL(textChanged(QString)),
|
||||
@ -585,6 +587,7 @@ void GuiCitation::applyParams(int const choice, bool full, bool force,
|
||||
params_["pretextlist"] = getStringFromVector(getPreTexts(), from_ascii("\t"));
|
||||
params_["posttextlist"] = getStringFromVector(getPostTexts(), from_ascii("\t"));
|
||||
}
|
||||
params_["literal"] = literalCB->isChecked() ? from_ascii("true") : from_ascii("false");
|
||||
dispatchParams();
|
||||
}
|
||||
|
||||
@ -726,6 +729,7 @@ void GuiCitation::init()
|
||||
documentBuffer().params().fullAuthorList());
|
||||
textBeforeED->setText(toqstr(params_["before"]));
|
||||
textAfterED->setText(toqstr(params_["after"]));
|
||||
literalCB->setChecked(params_["literal"] == "true");
|
||||
|
||||
setPreTexts(getVectorFromString(params_["pretextlist"], from_ascii("\t")));
|
||||
setPostTexts(getVectorFromString(params_["posttextlist"], from_ascii("\t")));
|
||||
|
@ -40,6 +40,8 @@ GuiHyperlink::GuiHyperlink(QWidget * parent) : InsetParamsWidget(parent)
|
||||
this, SIGNAL(changed()));
|
||||
connect(nameED, SIGNAL(textChanged(const QString &)),
|
||||
this, SIGNAL(changed()));
|
||||
connect(literalCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
connect(webRB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
connect(emailRB, SIGNAL(clicked()),
|
||||
@ -58,6 +60,7 @@ void GuiHyperlink::paramsToDialog(Inset const * inset)
|
||||
|
||||
targetED->setText(toqstr(params["target"]));
|
||||
nameED->setText(toqstr(params["name"]));
|
||||
literalCB->setChecked(params["literal"] == "true");
|
||||
docstring const & type = params["type"];
|
||||
if (type.empty())
|
||||
webRB->setChecked(true);
|
||||
@ -75,6 +78,7 @@ bool GuiHyperlink::initialiseParams(std::string const & data)
|
||||
return false;
|
||||
targetED->setText(toqstr(params["target"]));
|
||||
nameED->setText(toqstr(params["name"]));
|
||||
literalCB->setChecked(params["literal"] == "true");
|
||||
if (params["type"] == from_utf8("mailto:"))
|
||||
emailRB->setChecked(true);
|
||||
else if (params["type"] == from_utf8("file:"))
|
||||
@ -97,6 +101,8 @@ docstring GuiHyperlink::dialogToParams() const
|
||||
params["type"] = from_utf8("mailto:");
|
||||
else if (fileRB->isChecked())
|
||||
params["type"] = from_utf8("file:");
|
||||
params["literal"] = literalCB->isChecked()
|
||||
? from_ascii("true") : from_ascii("false");
|
||||
params.setCmdName("href");
|
||||
return from_utf8(InsetHyperlink::params2string(params));
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ GuiNomenclature::GuiNomenclature(QWidget * parent) : InsetParamsWidget(parent)
|
||||
this, SIGNAL(changed()));
|
||||
connect(descriptionTE, SIGNAL(textChanged()),
|
||||
this, SIGNAL(changed()));
|
||||
connect(literalCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
setFocusProxy(descriptionTE);
|
||||
}
|
||||
@ -41,6 +43,7 @@ void GuiNomenclature::paramsToDialog(Inset const * inset)
|
||||
|
||||
prefixED->setText(toqstr(params["prefix"]));
|
||||
symbolED->setText(toqstr(params["symbol"]));
|
||||
literalCB->setChecked(params["literal"] == "true");
|
||||
QString description = toqstr(params["description"]);
|
||||
description.replace("\\\\","\n");
|
||||
descriptionTE->setPlainText(description);
|
||||
@ -56,6 +59,8 @@ docstring GuiNomenclature::dialogToParams() const
|
||||
QString description = descriptionTE->toPlainText();
|
||||
description.replace('\n',"\\\\");
|
||||
params["description"] = qstring_to_ucs4(description);
|
||||
params["literal"] = literalCB->isChecked()
|
||||
? from_ascii("true") : from_ascii("false");
|
||||
return from_utf8(InsetNomencl::params2string(params));
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ GuiPrintindex::GuiPrintindex(GuiView & lv)
|
||||
connect(cancelPB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
||||
connect(indicesCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
||||
connect(subindexCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
||||
connect(literalCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
|
||||
|
||||
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
||||
bc().setOK(okPB);
|
||||
@ -78,6 +79,7 @@ void GuiPrintindex::updateContents()
|
||||
int const pos = indicesCO->findData(toqstr(cur_index));
|
||||
indicesCO->setCurrentIndex(pos);
|
||||
subindexCB->setChecked(params_.getCmdName() == "printsubindex");
|
||||
literalCB->setChecked(params_["literal"] == "true");
|
||||
}
|
||||
|
||||
|
||||
@ -95,6 +97,8 @@ void GuiPrintindex::applyView()
|
||||
params_["type"] = docstring();
|
||||
else
|
||||
params_["type"] = qstring_to_ucs4(index);
|
||||
params_["literal"] = literalCB->isChecked()
|
||||
? from_ascii("true") : from_ascii("false");
|
||||
}
|
||||
|
||||
|
||||
@ -105,6 +109,7 @@ void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
|
||||
indicesCO->findData(toqstr(params_["type"]));
|
||||
subindexCB->setChecked(params_.getCmdName() == "printsubindex");
|
||||
indicesCO->setCurrentIndex(pos);
|
||||
literalCB->setChecked(params_["literal"] == "true");
|
||||
bc().setValid(isValid());
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BibitemUi</class>
|
||||
<widget class="QWidget" name="BibitemUi">
|
||||
@ -5,71 +6,90 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>211</width>
|
||||
<height>74</height>
|
||||
<width>218</width>
|
||||
<height>121</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="keyED">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The bibliography key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="labelED">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The label as it appears in the document</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelLA">
|
||||
<property name="toolTip">
|
||||
<string>The label as it appears in the document</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Label:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>labelED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="keyLA">
|
||||
<property name="toolTip">
|
||||
<string>The bibliography key</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Key:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>keyED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="keyLA">
|
||||
<property name="toolTip">
|
||||
<string>The bibliography key</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ke&y:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>keyED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelLA">
|
||||
<property name="toolTip">
|
||||
<string>The label as it appears in the document</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Label:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>labelED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="keyED">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The bibliography key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="labelED">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The label as it appears in the document</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="literalCB">
|
||||
<property name="toolTip">
|
||||
<string>Pass content of the `Label' field literally to LaTeX. Check this if you want to enter LaTeX code.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Li&teral</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -359,6 +359,16 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="literalCB">
|
||||
<property name="toolTip">
|
||||
<string>Pass content of `Text before' and `Text after' fields literally to LaTeX. Check this if you want to enter LaTeX code.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Li&teral</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
|
@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>HyperlinkUi</class>
|
||||
<widget class="QWidget" name="HyperlinkUi">
|
||||
@ -5,55 +6,101 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>343</width>
|
||||
<height>130</height>
|
||||
<width>290</width>
|
||||
<height>188</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="targetLA">
|
||||
<property name="toolTip">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Target:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>targetED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="targetED">
|
||||
<property name="toolTip">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="targetLA">
|
||||
<property name="toolTip">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Target:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>targetED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="nameLA">
|
||||
<property name="toolTip">
|
||||
<string>Name associated with the URL</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>nameED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="targetED">
|
||||
<property name="toolTip">
|
||||
<string>URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="nameED">
|
||||
<property name="toolTip">
|
||||
<string>Name associated with the URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="literalCB">
|
||||
<property name="toolTip">
|
||||
<string>Pass content of the `Name' field literally to LaTeX. Check this if you want to enter LaTeX code.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Li&teral</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="nameLA">
|
||||
<property name="toolTip">
|
||||
<string>Name associated with the URL</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>nameED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="nameED">
|
||||
<property name="toolTip">
|
||||
<string>Name associated with the URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QGroupBox" name="typeGB">
|
||||
<property name="toolTip">
|
||||
<string>Specify the link target</string>
|
||||
@ -65,7 +112,16 @@
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -87,7 +143,7 @@
|
||||
<string>Link to an email address</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Email</string>
|
||||
<string>E&mail</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -97,14 +153,14 @@
|
||||
<string>Link to a file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&File</string>
|
||||
<string>Fi&le</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<item row="1" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NomenclUi</class>
|
||||
<widget class="QWidget" name="NomenclUi">
|
||||
@ -6,46 +7,17 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>254</width>
|
||||
<height>172</height>
|
||||
<height>222</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Nomenclature</string>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="prefixED"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="prefixLA">
|
||||
<property name="text">
|
||||
<string>Sort &as:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>prefixED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="descrLA">
|
||||
<property name="text">
|
||||
<string>&Description:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>descriptionTE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="symbolLA">
|
||||
<property name="text">
|
||||
<string>&Symbol:</string>
|
||||
<string>Sy&mbol:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>symbolED</cstring>
|
||||
@ -59,6 +31,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="descrLA">
|
||||
<property name="text">
|
||||
<string>Des&cription:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>descriptionTE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QTextEdit" name="descriptionTE">
|
||||
<property name="acceptRichText">
|
||||
@ -66,6 +48,29 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="prefixLA">
|
||||
<property name="text">
|
||||
<string>Sort &as:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>prefixED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="prefixED"/>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="literalCB">
|
||||
<property name="toolTip">
|
||||
<string>Pass content of the `Symbol' and `Description' fields literally to LaTeX. Check this if you want to enter LaTeX code.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Li&teral</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
|
@ -1,97 +1,119 @@
|
||||
<ui version="4.0" >
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PrintindexUi</class>
|
||||
<widget class="QDialog" name="PrintindexUi" >
|
||||
<property name="geometry" >
|
||||
<widget class="QDialog" name="PrintindexUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>262</width>
|
||||
<height>130</height>
|
||||
<width>287</width>
|
||||
<height>148</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="sizeGripEnabled" >
|
||||
<property name="sizeGripEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="2" >
|
||||
<widget class="QPushButton" name="cancelPB" >
|
||||
<property name="text" >
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QPushButton" name="okPB" >
|
||||
<property name="text" >
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>78</width>
|
||||
<height>29</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3" >
|
||||
<widget class="QCheckBox" name="subindexCB" >
|
||||
<property name="toolTip" >
|
||||
<string>Check if this index should be part (e.g., a section) of the former one.</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Subindex</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="indicesLA" >
|
||||
<property name="text" >
|
||||
<string>A&vailable indexes:</string>
|
||||
<widget class="QLabel" name="indicesLA">
|
||||
<property name="text">
|
||||
<string>Avai&lable indexes:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>indicesCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="indicesCO" >
|
||||
<property name="toolTip" >
|
||||
<widget class="QComboBox" name="indicesCO">
|
||||
<property name="toolTip">
|
||||
<string>Select the index that shall be printed at this place of the document.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="subindexCB">
|
||||
<property name="toolTip">
|
||||
<string>Check if this index should be part (e.g., a section) of the former one.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Subindex</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="literalCB">
|
||||
<property name="toolTip">
|
||||
<string>Pass index names literally to LaTeX. Check this if you want to use LaTeX code in index names.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Li&teral</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>78</width>
|
||||
<height>29</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okPB">
|
||||
<property name="text">
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelPB">
|
||||
<property name="text">
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
@ -100,7 +122,7 @@
|
||||
<tabstop>cancelPB</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="local" >qt_i18n.h</include>
|
||||
<include location="local">qt_i18n.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -108,6 +108,7 @@ ParamInfo const & InsetBibitem::findInfo(string const & /* cmdName */)
|
||||
ParamInfo::HANDLING_LATEXIFY);
|
||||
param_info_.add("key", ParamInfo::LATEX_REQUIRED,
|
||||
ParamInfo::HANDLING_ESCAPE);
|
||||
param_info_.add("literal", ParamInfo::LYX_INTERNAL);
|
||||
}
|
||||
return param_info_;
|
||||
}
|
||||
@ -129,54 +130,24 @@ void InsetBibitem::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
|
||||
docstring const & old_key = params()["key"];
|
||||
docstring const & old_label = params()["label"];
|
||||
docstring const & old_literal = params()["literal"];
|
||||
docstring label = p["label"];
|
||||
|
||||
// definitions for escaping
|
||||
static docstring const backslash = from_ascii("\\");
|
||||
static docstring const lbrace = from_ascii("{");
|
||||
static docstring const rbrace = from_ascii("}");
|
||||
static char_type const chars_escape[6] = {
|
||||
'&', '_', '$', '%', '#', '^'};
|
||||
static char_type const brackets_escape[2] = {'[', ']'};
|
||||
|
||||
if (!label.empty()) {
|
||||
int previous;
|
||||
// The characters in chars_name[] need to be changed to a command when
|
||||
// they are in the name field.
|
||||
for (int k = 0; k < 6; k++)
|
||||
for (size_t i = 0, pos;
|
||||
(pos = label.find(chars_escape[k], i)) != string::npos;
|
||||
i = pos + 2) {
|
||||
if (pos == 0)
|
||||
previous = 0;
|
||||
else
|
||||
previous = pos - 1;
|
||||
// only if not already escaped
|
||||
if (label[previous] != '\\')
|
||||
label.replace(pos, 1, backslash + chars_escape[k] + lbrace + rbrace);
|
||||
}
|
||||
// The characters '[' and ']' need to be put into braces
|
||||
for (int k = 0; k < 2; k++)
|
||||
for (size_t i = 0, pos;
|
||||
(pos = label.find(brackets_escape[k], i)) != string::npos;
|
||||
i = pos + 2) {
|
||||
if (pos == 0)
|
||||
previous = 0;
|
||||
else
|
||||
previous = pos - 1;
|
||||
// only if not already escaped
|
||||
if (label[previous] != '{')
|
||||
label.replace(pos, 1, lbrace + brackets_escape[k] + rbrace);
|
||||
}
|
||||
}
|
||||
docstring literal = p["literal"];
|
||||
|
||||
if (old_label != label) {
|
||||
p["label"] = label;
|
||||
cur.forceBufferUpdate();
|
||||
buffer().invalidateBibinfoCache();
|
||||
}
|
||||
|
||||
setParam("label", p["label"]);
|
||||
|
||||
if (old_literal != literal) {
|
||||
p["literal"] = literal;
|
||||
cur.forceBufferUpdate();
|
||||
buffer().invalidateBibinfoCache();
|
||||
}
|
||||
setParam("literal", p["literal"]);
|
||||
|
||||
if (p["key"] != old_key) {
|
||||
updateCommand(p["key"]);
|
||||
cur.bv().buffer().changeRefsIfUnique(old_key, params()["key"]);
|
||||
@ -301,9 +272,8 @@ docstring bibitemWidest(Buffer const & buffer, OutputParams const & runparams)
|
||||
}
|
||||
|
||||
if (!lbl.empty()) {
|
||||
pair<docstring, docstring> latex_lbl =
|
||||
runparams.encoding->latexString(lbl, runparams.dryrun);
|
||||
return latex_lbl.first;
|
||||
InsetCommandParams p(BIBITEM_CODE);
|
||||
return p.prepareCommand(runparams, lbl, ParamInfo::HANDLING_LATEXIFY);
|
||||
}
|
||||
|
||||
return from_ascii("99");
|
||||
|
@ -66,11 +66,16 @@ ParamInfo const & InsetCitation::findInfo(string const & /* cmdName */)
|
||||
// we have to allow both here. InsetCitation takes care that
|
||||
// LaTeX output is nevertheless correct.
|
||||
if (param_info_.empty()) {
|
||||
param_info_.add("after", ParamInfo::LATEX_OPTIONAL);
|
||||
param_info_.add("before", ParamInfo::LATEX_OPTIONAL);
|
||||
param_info_.add("after", ParamInfo::LATEX_OPTIONAL,
|
||||
ParamInfo::HANDLING_LATEXIFY);
|
||||
param_info_.add("before", ParamInfo::LATEX_OPTIONAL,
|
||||
ParamInfo::HANDLING_LATEXIFY);
|
||||
param_info_.add("key", ParamInfo::LATEX_REQUIRED);
|
||||
param_info_.add("pretextlist", ParamInfo::LATEX_OPTIONAL);
|
||||
param_info_.add("posttextlist", ParamInfo::LATEX_OPTIONAL);
|
||||
param_info_.add("pretextlist", ParamInfo::LATEX_OPTIONAL,
|
||||
ParamInfo::HANDLING_LATEXIFY);
|
||||
param_info_.add("posttextlist", ParamInfo::LATEX_OPTIONAL,
|
||||
ParamInfo::HANDLING_LATEXIFY);
|
||||
param_info_.add("literal", ParamInfo::LYX_INTERNAL);
|
||||
}
|
||||
return param_info_;
|
||||
}
|
||||
@ -568,8 +573,10 @@ void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
|
||||
if (qualified)
|
||||
os << "s";
|
||||
|
||||
docstring before = getParam("before");
|
||||
docstring after = getParam("after");
|
||||
docstring before = params().prepareCommand(runparams, getParam("before"),
|
||||
param_info_["before"].handling());
|
||||
docstring after = params().prepareCommand(runparams, getParam("after"),
|
||||
param_info_["after"].handling());
|
||||
if (!before.empty() && cs.textBefore) {
|
||||
if (qualified)
|
||||
os << '(' << protectArgument(before, '(', ')')
|
||||
@ -592,8 +599,10 @@ void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
|
||||
map<docstring, docstring> pres = getQualifiedLists(getParam("pretextlist"));
|
||||
map<docstring, docstring> posts = getQualifiedLists(getParam("posttextlist"));
|
||||
for (docstring const & k: keys) {
|
||||
docstring bef = pres[k];
|
||||
docstring aft = posts[k];
|
||||
docstring bef = params().prepareCommand(runparams, pres[k],
|
||||
param_info_["pretextlist"].handling());
|
||||
docstring aft = params().prepareCommand(runparams, posts[k],
|
||||
param_info_["posttextlist"].handling());
|
||||
if (!bef.empty())
|
||||
os << '[' << protectArgument(bef)
|
||||
<< "][" << protectArgument(aft) << ']';
|
||||
|
@ -64,8 +64,6 @@ public:
|
||||
///
|
||||
void forOutliner(docstring &, size_t const, bool const) const;
|
||||
///
|
||||
void validate(LaTeXFeatures &) const {}
|
||||
///
|
||||
void updateBuffer(ParIterator const & it, UpdateType);
|
||||
///
|
||||
void addToToc(DocIterator const & di, bool output_active,
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "InsetCommand.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferEncodings.h"
|
||||
#include "BufferView.h"
|
||||
#include "Cursor.h"
|
||||
#include "DispatchResult.h"
|
||||
@ -157,6 +158,25 @@ int InsetCommand::docbook(odocstream &, OutputParams const &) const
|
||||
}
|
||||
|
||||
|
||||
void InsetCommand::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
if (params()["literal"] == "true")
|
||||
return;
|
||||
|
||||
ParamInfo::const_iterator it = params().info().begin();
|
||||
ParamInfo::const_iterator end = params().info().end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->handling() == ParamInfo::HANDLING_LATEXIFY) {
|
||||
docstring const text = params()[it->name()];
|
||||
// Validate the contents (if we LaTeXify, specific
|
||||
// macros might require packages)
|
||||
for (pos_type i = 0; i < int(text.size()) ; ++i)
|
||||
BufferEncodings::validate(text[i], features);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetCommand::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
{
|
||||
switch (cmd.action()) {
|
||||
|
@ -87,6 +87,8 @@ public:
|
||||
///
|
||||
int docbook(odocstream &, OutputParams const & runparams) const;
|
||||
///
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
///
|
||||
bool setMouseHover(BufferView const * bv, bool mouse_hover) const;
|
||||
///
|
||||
bool clickable(BufferView const &, int, int) const { return hasSettings(); }
|
||||
|
@ -422,20 +422,50 @@ docstring InsetCommandParams::prepareCommand(OutputParams const & runparams,
|
||||
docstring const & command,
|
||||
ParamInfo::ParamHandling handling) const
|
||||
{
|
||||
if (handling == ParamInfo::HANDLING_LATEXIFY)
|
||||
if ((*this)["literal"] == "true")
|
||||
handling = ParamInfo::HANDLING_NONE;
|
||||
docstring result;
|
||||
switch (handling) {
|
||||
case ParamInfo::HANDLING_LATEXIFY: {
|
||||
// First handle backslash
|
||||
result = subst(command, from_ascii("\\"), from_ascii("\\textbackslash{}"));
|
||||
// Then get LaTeX macros
|
||||
pair<docstring, docstring> command_latexed =
|
||||
runparams.encoding->latexString(command, runparams.dryrun);
|
||||
runparams.encoding->latexString(result, runparams.dryrun);
|
||||
result = command_latexed.first;
|
||||
if (!command_latexed.second.empty()) {
|
||||
// issue a warning about omitted characters
|
||||
// Issue a warning about omitted characters
|
||||
// FIXME: should be passed to the error dialog
|
||||
frontend::Alert::warning(_("Uncodable characters"),
|
||||
bformat(_("The following characters that are used in the inset %1$s are not\n"
|
||||
"representable in the current encoding and therefore have been omitted:\n%2$s."),
|
||||
from_utf8(insetType()), command_latexed.second));
|
||||
}
|
||||
// Now escape special commands
|
||||
static docstring const backslash = from_ascii("\\");
|
||||
static char_type const chars_escape[6] = {
|
||||
'&', '_', '$', '%', '#', '^'};
|
||||
|
||||
if (!result.empty()) {
|
||||
int previous;
|
||||
// The characters in chars_name[] need to be changed to a command when
|
||||
// they are LaTeXified.
|
||||
for (int k = 0; k < 6; k++)
|
||||
for (size_t i = 0, pos;
|
||||
(pos = result.find(chars_escape[k], i)) != string::npos;
|
||||
i = pos + 2) {
|
||||
//(Only) \\^ needs to be terminated
|
||||
docstring const term = (k == 5) ? from_ascii("{}") : docstring();
|
||||
if (pos == 0)
|
||||
previous = 0;
|
||||
else
|
||||
previous = pos - 1;
|
||||
// only if not already escaped
|
||||
if (result[previous] != '\\')
|
||||
result.replace(pos, 1, backslash + chars_escape[k] + term);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ParamInfo::HANDLING_ESCAPE:
|
||||
@ -470,10 +500,10 @@ docstring InsetCommandParams::getCommand(OutputParams const & runparams) const
|
||||
break;
|
||||
}
|
||||
case ParamInfo::LATEX_OPTIONAL: {
|
||||
docstring const data =
|
||||
docstring data =
|
||||
prepareCommand(runparams, (*this)[name], it->handling());
|
||||
if (!data.empty()) {
|
||||
s += '[' + data + ']';
|
||||
s += '[' + protectArgument(data) + ']';
|
||||
noparam = false;
|
||||
} else if (writeEmptyOptional(it)) {
|
||||
s += "[]";
|
||||
|
@ -48,9 +48,11 @@ ParamInfo const & InsetHyperlink::findInfo(string const & /* cmdName */)
|
||||
{
|
||||
static ParamInfo param_info_;
|
||||
if (param_info_.empty()) {
|
||||
param_info_.add("name", ParamInfo::LATEX_OPTIONAL);
|
||||
param_info_.add("name", ParamInfo::LATEX_OPTIONAL,
|
||||
ParamInfo::HANDLING_LATEXIFY);
|
||||
param_info_.add("target", ParamInfo::LATEX_REQUIRED);
|
||||
param_info_.add("type", ParamInfo::LATEX_REQUIRED);
|
||||
param_info_.add("literal", ParamInfo::LYX_INTERNAL);
|
||||
}
|
||||
return param_info_;
|
||||
}
|
||||
@ -119,11 +121,7 @@ void InsetHyperlink::latex(otexstream & os,
|
||||
{
|
||||
docstring url = getParam("target");
|
||||
docstring name = getParam("name");
|
||||
static docstring const backslash = from_ascii("\\");
|
||||
static docstring const braces = from_ascii("{}");
|
||||
static char_type const chars_url[2] = {'%', '#'};
|
||||
static char_type const chars_name[6] = {
|
||||
'&', '_', '$', '%', '#', '^'};
|
||||
|
||||
// For the case there is no name given, the target is set as name.
|
||||
// Do this before !url.empty() and !name.empty() to handle characters
|
||||
@ -151,7 +149,7 @@ void InsetHyperlink::latex(otexstream & os,
|
||||
for (size_t i = 0, pos;
|
||||
(pos = url.find(chars_url[k], i)) != string::npos;
|
||||
i = pos + 2)
|
||||
url.replace(pos, 1, backslash + chars_url[k]);
|
||||
url.replace(pos, 1, from_ascii("\\") + chars_url[k]);
|
||||
|
||||
// add "http://" when the type is web (type = empty)
|
||||
// and no "://" or "run:" is given
|
||||
@ -163,46 +161,19 @@ void InsetHyperlink::latex(otexstream & os,
|
||||
|
||||
} // end if (!url.empty())
|
||||
|
||||
// The characters in chars_name[] need to be changed to a command when
|
||||
// they are in the name field.
|
||||
if (!name.empty()) {
|
||||
// handle the "\" character, but only when the following character
|
||||
// is not also a "\", because "\\" is valid code
|
||||
docstring const textbackslash = from_ascii("\\textbackslash{}");
|
||||
for (size_t i = 0, pos;
|
||||
(pos = name.find('\\', i)) != string::npos;
|
||||
i = pos + 2) {
|
||||
if (name[pos + 1] != '\\')
|
||||
name.replace(pos, 1, textbackslash);
|
||||
}
|
||||
// The characters in chars_name[] need to be changed to a command
|
||||
// when they are in the name field.
|
||||
// Therefore the treatment of "\" must be the first thing
|
||||
for (int k = 0; k < 6; k++)
|
||||
for (size_t i = 0, pos;
|
||||
(pos = name.find(chars_name[k], i)) != string::npos;
|
||||
i = pos + 2)
|
||||
name.replace(pos, 1, backslash + chars_name[k] + braces);
|
||||
|
||||
name = params().prepareCommand(runparams, getParam("name"),
|
||||
ParamInfo::HANDLING_LATEXIFY);
|
||||
// replace the tilde by the \sim character as suggested in the
|
||||
// LaTeX FAQ for URLs
|
||||
docstring const sim = from_ascii("$\\sim$");
|
||||
for (size_t i = 0, pos;
|
||||
(pos = name.find('~', i)) != string::npos;
|
||||
i = pos + 1)
|
||||
name.replace(pos, 1, sim);
|
||||
pair<docstring, docstring> name_latexed =
|
||||
runparams.encoding->latexString(name, runparams.dryrun);
|
||||
name = name_latexed.first;
|
||||
if (!name_latexed.second.empty() && !runparams.silent) {
|
||||
// issue a warning about omitted characters
|
||||
// FIXME: should be passed to the error dialog
|
||||
frontend::Alert::warning(_("Uncodable characters"),
|
||||
bformat(_("The following characters that are used in the href inset are not\n"
|
||||
"representable in the current encoding and therefore have been omitted:\n%1$s."),
|
||||
name_latexed.second));
|
||||
if (getParam("literal") != from_ascii("true")) {
|
||||
docstring const sim = from_ascii("$\\sim$");
|
||||
for (size_t i = 0, pos;
|
||||
(pos = name.find('~', i)) != string::npos;
|
||||
i = pos + 1)
|
||||
name.replace(pos, 1, sim);
|
||||
}
|
||||
} // end if (!name.empty())
|
||||
}
|
||||
|
||||
if (runparams.moving_arg)
|
||||
os << "\\protect";
|
||||
@ -287,6 +258,7 @@ docstring InsetHyperlink::toolTip(BufferView const & /*bv*/, int /*x*/, int /*y*
|
||||
void InsetHyperlink::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
features.require("hyperref");
|
||||
InsetCommand::validate(features);
|
||||
}
|
||||
|
||||
|
||||
|
@ -436,8 +436,10 @@ ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
|
||||
static ParamInfo param_info_;
|
||||
if (param_info_.empty()) {
|
||||
param_info_.add("type", ParamInfo::LATEX_OPTIONAL,
|
||||
ParamInfo::HANDLING_ESCAPE);
|
||||
param_info_.add("name", ParamInfo::LATEX_REQUIRED);
|
||||
ParamInfo::HANDLING_ESCAPE);
|
||||
param_info_.add("name", ParamInfo::LATEX_OPTIONAL,
|
||||
ParamInfo::HANDLING_LATEXIFY);
|
||||
param_info_.add("literal", ParamInfo::LYX_INTERNAL);
|
||||
}
|
||||
return param_info_;
|
||||
}
|
||||
@ -560,6 +562,15 @@ bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
}
|
||||
|
||||
|
||||
void InsetPrintIndex::updateBuffer(ParIterator const &, UpdateType)
|
||||
{
|
||||
Index const * index =
|
||||
buffer().masterParams().indiceslist().findShortcut(getParam("type"));
|
||||
if (index)
|
||||
setParam("name", index->index());
|
||||
}
|
||||
|
||||
|
||||
void InsetPrintIndex::latex(otexstream & os, OutputParams const & runparams_in) const
|
||||
{
|
||||
if (!buffer().masterBuffer()->params().use_indices) {
|
||||
@ -577,6 +588,7 @@ void InsetPrintIndex::validate(LaTeXFeatures & features) const
|
||||
features.require("makeidx");
|
||||
if (buffer().masterBuffer()->params().use_indices)
|
||||
features.require("splitidx");
|
||||
InsetCommand::validate(features);
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,6 +111,8 @@ public:
|
||||
///
|
||||
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
||||
///
|
||||
void updateBuffer(ParIterator const & it, UpdateType);
|
||||
///
|
||||
std::string contextMenuName() const;
|
||||
/// Updates needed features for this inset.
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
|
@ -68,6 +68,7 @@ ParamInfo const & InsetNomencl::findInfo(string const & /* cmdName */)
|
||||
ParamInfo::HANDLING_LATEXIFY);
|
||||
param_info_.add("description", ParamInfo::LATEX_REQUIRED,
|
||||
ParamInfo::HANDLING_LATEXIFY);
|
||||
param_info_.add("literal", ParamInfo::LYX_INTERNAL);
|
||||
}
|
||||
return param_info_;
|
||||
}
|
||||
@ -134,6 +135,7 @@ int InsetNomencl::docbookGlossary(odocstream & os) const
|
||||
void InsetNomencl::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
features.require("nomencl");
|
||||
InsetCommand::validate(features);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1682,8 +1682,8 @@ void parse_environment(Parser & p, ostream & os, bool outer,
|
||||
p.skip_spaces(true);
|
||||
os << "btprint " << '"' << "btPrintAll" << '"' << "\n";
|
||||
}
|
||||
os << "bibfiles " << '"' << bibfile << '"' << "\n";
|
||||
os << "options " << '"' << bibstyle << '"' << "\n";
|
||||
os << "bibfiles " << '"' << bibfile << "\"\n"
|
||||
<< "options " << '"' << bibstyle << "\"\n";
|
||||
parse_text_in_inset(p, os, FLAG_END, outer, parent_context);
|
||||
end_inset(os);
|
||||
p.skip_spaces();
|
||||
@ -2760,7 +2760,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
} else {
|
||||
begin_command_inset(os, "bibitem", "bibitem");
|
||||
os << "label \"" << label << "\"\n"
|
||||
"key \"" << key << "\"\n";
|
||||
<< "key \"" << key << "\"\n"
|
||||
<< "literal \"true\"\n";
|
||||
end_inset(os);
|
||||
}
|
||||
}
|
||||
@ -3439,6 +3440,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
os << "target \"" << target << "\"\n";
|
||||
if (type == "mailto:" || type == "file:")
|
||||
os << "type \"" << type << "\"\n";
|
||||
os << "literal \"true\"\n";
|
||||
end_inset(os);
|
||||
skip_spaces_braces(p);
|
||||
}
|
||||
@ -3585,7 +3587,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
os << "before " << '"' << before << '"' << "\n";
|
||||
os << "key \""
|
||||
<< convert_command_inset_arg(p.verbatim_item())
|
||||
<< "\"\n";
|
||||
<< "\"\n"
|
||||
<< "literal \"true\"\n";
|
||||
end_inset(os);
|
||||
// Need to set the cite engine if natbib is loaded by
|
||||
// the document class directly
|
||||
@ -3637,9 +3640,10 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
before.erase(before.length() - 1, 1);
|
||||
}
|
||||
begin_command_inset(os, "citation", command);
|
||||
os << "after " << '"' << after << '"' << "\n";
|
||||
os << "before " << '"' << before << '"' << "\n";
|
||||
os << "key " << '"' << citation << '"' << "\n";
|
||||
os << "after " << '"' << after << "\"\n"
|
||||
<< "before " << '"' << before << "\"\n"
|
||||
<< "key " << '"' << citation << "\"\n"
|
||||
<< "literal \"true\"\n";
|
||||
end_inset(os);
|
||||
// Need to set the cite engine if jurabib is loaded by
|
||||
// the document class directly
|
||||
@ -3656,8 +3660,9 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
// the BibTeX inset
|
||||
if (key != "*") {
|
||||
begin_command_inset(os, "citation", t.cs());
|
||||
os << "after " << '"' << after << '"' << "\n";
|
||||
os << "key " << '"' << key << '"' << "\n";
|
||||
os << "after " << '"' << after << "\"\n"
|
||||
<< "key " << '"' << key << "\"\n"
|
||||
<< "literal \"true\"\n";
|
||||
end_inset(os);
|
||||
} else if (t.cs() == "nocite")
|
||||
btprint = key;
|
||||
@ -3687,7 +3692,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
<< convert_command_inset_arg(p.verbatim_item());
|
||||
os << "\"\ndescription \""
|
||||
<< convert_command_inset_arg(p.verbatim_item())
|
||||
<< "\"\n";
|
||||
<< "\"\n"
|
||||
<< "literal \"true\"\n";
|
||||
end_inset(os);
|
||||
preamble.registerAutomaticallyLoadedPackage("nomencl");
|
||||
}
|
||||
@ -3717,6 +3723,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
os << "type \"idx\"\n";
|
||||
else
|
||||
os << "type \"" << indexname << "\"\n";
|
||||
os << "literal \"true\"\n";
|
||||
}
|
||||
end_inset(os);
|
||||
skip_spaces_braces(p);
|
||||
|
@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
#define LYX_FORMAT_LYX 531 // spitz: qualified citation lists
|
||||
#define LYX_FORMAT_TEX2LYX 531
|
||||
#define LYX_FORMAT_LYX 532 // gb/spitz add literal command inset parameter
|
||||
#define LYX_FORMAT_TEX2LYX 532
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user