InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params)
- : InsetCollapsable(buf), params_(params)
+ : InsetCollapsible(buf), params_(params)
{}
-void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
+void InsetIndex::latex(otexstream & ios, OutputParams const & runparams_in) const
{
OutputParams runparams(runparams_in);
runparams.inIndexEntry = true;
+ otexstringstream os;
+
if (buffer().masterBuffer()->params().use_indices && !params_.index.empty()
&& params_.index != "idx") {
os << "\\sindex[";
os << '{';
}
- // get contents of InsetText as LaTeX and plaintext
odocstringstream ourlatex;
- // FIXME: do Tex/Row correspondence (I don't currently understand what is
- // being generated from latexstr below)
otexstream ots(ourlatex);
InsetText::latex(ots, runparams);
+ if (runparams.for_search) {
+ // No need for special handling, if we are only searching for some patterns
+ os << ourlatex.str() << "}";
+ return;
+ }
+ // get contents of InsetText as LaTeX and plaintext
odocstringstream ourplain;
InsetText::plaintext(ourplain, runparams);
+ // FIXME: do Tex/Row correspondence (I don't currently understand what is
+ // being generated from latexstr below)
docstring latexstr = ourlatex.str();
docstring plainstr = ourplain.str();
os << "|" << cmd;
}
os << '}';
+
+ // In macros with moving arguments, such as \section,
+ // we store the index and output it after the macro (#2154)
+ if (runparams_in.postpone_fragile_stuff)
+ runparams_in.post_macro += os.str();
+ else
+ ios << os.release();
}
break;
default:
- InsetCollapsable::doDispatch(cur, cmd);
+ InsetCollapsible::doDispatch(cur, cmd);
break;
}
}
from_utf8(cmd.getArg(1)) == params_.index);
return true;
}
- return InsetCollapsable::getStatus(cur, cmd, flag);
+ return InsetCollapsible::getStatus(cur, cmd, flag);
case LFUN_INSET_DIALOG_UPDATE: {
Buffer const & realbuffer = *buffer().masterBuffer();
}
default:
- return InsetCollapsable::getStatus(cur, cmd, flag);
+ return InsetCollapsible::getStatus(cur, cmd, flag);
}
}
ColorCode InsetIndex::labelColor() const
{
if (params_.index.empty() || params_.index == from_ascii("idx"))
- return InsetCollapsable::labelColor();
+ return InsetCollapsible::labelColor();
// FIXME UNICODE
ColorCode c = lcolor.getFromLyXName(to_utf8(params_.index));
if (c == Color_none)
- c = InsetCollapsable::labelColor();
+ c = InsetCollapsible::labelColor();
return c;
}
{
os << to_utf8(layoutName());
params_.write(os);
- InsetCollapsable::write(os);
+ InsetCollapsible::write(os);
}
void InsetIndex::read(Lexer & lex)
{
params_.read(lex);
- InsetCollapsable::read(lex);
+ InsetCollapsible::read(lex);
}
TocBuilder & b = backend.builder(type);
b.pushItem(pit, str, output_active);
// Proceed with the rest of the inset.
- InsetCollapsable::addToToc(cpit, output_active, utype, backend);
+ InsetCollapsible::addToToc(cpit, output_active, utype, backend);
b.pop();
}
&& !params_.index.empty()
&& params_.index != "idx")
features.require("splitidx");
- InsetCollapsable::validate(features);
+ InsetCollapsible::validate(features);
}
case LFUN_INSET_MODIFY: {
if (cmd.argument() == from_ascii("toggle-subindex")) {
- string cmd = getCmdName();
- if (contains(cmd, "printindex"))
- cmd = subst(cmd, "printindex", "printsubindex");
+ string scmd = getCmdName();
+ if (contains(scmd, "printindex"))
+ scmd = subst(scmd, "printindex", "printsubindex");
else
- cmd = subst(cmd, "printsubindex", "printindex");
+ scmd = subst(scmd, "printsubindex", "printindex");
cur.recordUndo();
- setCmdName(cmd);
+ setCmdName(scmd);
break;
} else if (cmd.argument() == from_ascii("check-printindex*")) {
- string cmd = getCmdName();
- if (suffixIs(cmd, '*'))
+ string scmd = getCmdName();
+ if (suffixIs(scmd, '*'))
break;
- cmd += '*';
+ scmd += '*';
cur.recordUndo();
setParam("type", docstring());
- setCmdName(cmd);
+ setCmdName(scmd);
break;
}
InsetCommandParams p(INDEX_PRINT_CODE);
return (comp < 0);
}
-} // anon namespace
+} // namespace
docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const & op) const