mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
* xargs export support. No parser support yet.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23615 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d589af0c1a
commit
c8c5fc65d0
@ -549,6 +549,7 @@ char const * simplefeatures[] = {
|
||||
"amsthm",
|
||||
"listings",
|
||||
"bm"
|
||||
"xargs"
|
||||
};
|
||||
|
||||
int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
|
||||
|
@ -1133,10 +1133,16 @@ void MathMacroTemplate::write(WriteStream & os) const
|
||||
|
||||
void MathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition) const
|
||||
{
|
||||
bool xargs = false;
|
||||
// newcommand or renewcommand
|
||||
if (os.latex() && optionals_ > 1)
|
||||
os << "\\newlyxcommand";
|
||||
else {
|
||||
if (os.latex() && optionals_ > 1) {
|
||||
if (redefinition_ && !overwriteRedefinition)
|
||||
os << "\\renewcommandx";
|
||||
else
|
||||
os << "\\newcommandx";
|
||||
xargs = true;
|
||||
//os << "\\newcommandx";
|
||||
} else {
|
||||
if (redefinition_ && !overwriteRedefinition)
|
||||
os << "\\renewcommand";
|
||||
else
|
||||
@ -1147,14 +1153,30 @@ void MathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition) cons
|
||||
os << '[' << numargs_ << ']';
|
||||
|
||||
// optional values
|
||||
for (int i = 0; i < optionals_; ++i) {
|
||||
docstring optValue = asString(cell(optIdx(i)));
|
||||
if (optValue.find(']') != docstring::npos)
|
||||
os << "[{" << cell(optIdx(i)) << "}]";
|
||||
else
|
||||
os << "[" << cell(optIdx(i)) << "]";
|
||||
if (xargs) {
|
||||
os << "[usedefault";
|
||||
for (int i = 0; i < optionals_; ++i) {
|
||||
docstring optValue = asString(cell(optIdx(i)));
|
||||
if (optValue.find(']') != docstring::npos
|
||||
|| optValue.find('=') != docstring::npos)
|
||||
os << ", " << i + 1 << "="
|
||||
<< "{" << cell(optIdx(i)) << "}";
|
||||
else
|
||||
os << ", " << i + 1 << "="
|
||||
<< cell(optIdx(i));
|
||||
}
|
||||
os << "]";
|
||||
} else {
|
||||
for (int i = 0; i < optionals_; ++i) {
|
||||
docstring optValue = asString(cell(optIdx(i)));
|
||||
if (optValue.find(']') != docstring::npos)
|
||||
os << "[{" << cell(optIdx(i)) << "}]";
|
||||
else
|
||||
os << "[" << cell(optIdx(i)) << "]";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
os << "{" << cell(defIdx()) << "}";
|
||||
|
||||
if (os.latex()) {
|
||||
@ -1239,7 +1261,8 @@ bool MathMacroTemplate::fixNameAndCheckIfValid()
|
||||
void MathMacroTemplate::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
if (optionals_ > 1) {
|
||||
features.require("newlyxcommand");
|
||||
//features.require("newlyxcommand");
|
||||
features.require("xargs");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user