#include "LaTeXFeatures.h"
#include "Lexer.h"
#include "MetricsInfo.h"
+#include "output_latex.h"
#include "sgml.h"
#include "TocBackend.h"
///////////////////////////////////////////////////////////////////////
-InsetIndex::InsetIndex(Buffer const & buf, InsetIndexParams const & params)
+InsetIndex::InsetIndex(Buffer * buf, InsetIndexParams const & params)
: InsetCollapsable(buf), params_(params)
{}
int InsetIndex::latex(odocstream & os,
- OutputParams const & runparams) const
+ OutputParams const & runparams_in) const
{
+ OutputParams runparams(runparams_in);
+ runparams.inIndexEntry = true;
+
if (buffer().masterBuffer()->params().use_indices && !params_.index.empty()
&& params_.index != "idx") {
os << "\\sindex[";
}
+docstring InsetIndex::xhtml(XHTMLStream &, OutputParams const &) const
+{
+ return docstring();
+}
+
+
bool InsetIndex::showInsetDialog(BufferView * bv) const
{
bv->showDialog("index", params2string(params_),
case LFUN_INSET_MODIFY: {
if (cmd.getArg(0) == "changetype") {
params_.index = from_utf8(cmd.getArg(1));
- setLayout(cur.buffer()->params());
break;
}
InsetIndexParams params;
InsetIndex::string2params(to_utf8(cmd.argument()), params);
params_.index = params.index;
- setLayout(cur.buffer()->params());
break;
}
flag.setEnabled(true);
return true;
- case LFUN_INSET_DIALOG_UPDATE:
- case LFUN_INSET_SETTINGS: {
+ case LFUN_INSET_DIALOG_UPDATE: {
Buffer const & realbuffer = *buffer().masterBuffer();
flag.setEnabled(realbuffer.params().use_indices);
return true;
}
-docstring const InsetIndex::buttonLabel(BufferView const & bv) const
+ColorCode InsetIndex::labelColor() const
{
- docstring s = _("Idx");
- if (decoration() == InsetLayout::CLASSIC)
- return isOpen(bv) ? s : getNewLabel(s);
- else
- return getNewLabel(s);
+ if (params_.index.empty() || params_.index == from_ascii("idx"))
+ return InsetCollapsable::labelColor();
+ // FIXME UNICODE
+ ColorCode c = lcolor.getFromLyXName(to_utf8(params_.index));
+ if (c == Color_none)
+ c = InsetCollapsable::labelColor();
+ return c;
}
odocstringstream ods;
InsetText::plaintext(ods, rp);
tip += ods.str();
- // shorten it if necessary
- if (tip.size() > 200)
- tip = tip.substr(0, 200) + "...";
- return tip;
+ return wrapParas(tip);
}
}
+bool InsetIndex::hasSettings() const
+{
+ return buffer().masterBuffer()->params().use_indices;
+}
+
+
+
+
+/////////////////////////////////////////////////////////////////////
+//
+// InsetIndexParams
+//
+///////////////////////////////////////////////////////////////////////
+
+
void InsetIndexParams::write(ostream & os) const
{
os << ' ';
//
///////////////////////////////////////////////////////////////////////
-InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p)
- : InsetCommand(p, "index_print")
+InsetPrintIndex::InsetPrintIndex(Buffer * buf, InsetCommandParams const & p)
+ : InsetCommand(buf, p, "index_print")
{}
docstring InsetPrintIndex::screenLabel() const
{
- if ((!buffer().masterBuffer()->params().use_indices
+ bool const printall = suffixIs(getCmdName(), '*');
+ bool const multind = buffer().masterBuffer()->params().use_indices;
+ if ((!multind
&& getParam("type") == from_ascii("idx"))
- || getParam("type").empty())
+ || (getParam("type").empty() && !printall))
return _("Index");
Buffer const & realbuffer = *buffer().masterBuffer();
IndicesList const & indiceslist = realbuffer.params().indiceslist();
Index const * index = indiceslist.findShortcut(getParam("type"));
- if (!index)
+ if (!index && !printall)
return _("Unknown index type!");
- docstring res = index->index();
- if (!buffer().masterBuffer()->params().use_indices)
+ docstring res = printall ? _("All indices") : index->index();
+ if (!multind)
res += " (" + _("non-active") + ")";
+ else if (contains(getCmdName(), "printsubindex"))
+ res += " (" + _("subindex") + ")";
return res;
}
+bool InsetPrintIndex::isCompatibleCommand(string const & s)
+{
+ return s == "printindex" || s == "printsubindex"
+ || s == "printindex*" || s == "printsubindex*";
+}
+
+
void InsetPrintIndex::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
+ if (cmd.argument() == from_ascii("toggle-subindex")) {
+ string cmd = getCmdName();
+ if (contains(cmd, "printindex"))
+ cmd = subst(cmd, "printindex", "printsubindex");
+ else
+ cmd = subst(cmd, "printsubindex", "printindex");
+ setCmdName(cmd);
+ break;
+ } else if (cmd.argument() == from_ascii("check-printindex*")) {
+ string cmd = getCmdName();
+ if (suffixIs(cmd, '*'))
+ break;
+ cmd += '*';
+ setParam("type", docstring());
+ setCmdName(cmd);
+ break;
+ }
InsetCommandParams p(INDEX_PRINT_CODE);
// FIXME UNICODE
InsetCommand::string2params("index_print",
cur.noUpdate();
break;
}
- setParam("type", p["type"]);
+ setParams(p);
break;
}
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
- if (cmd.getArg(0) == "index_print"
- && cmd.getArg(1) == "InsetCommand") {
+ if (cmd.argument() == from_ascii("toggle-subindex")) {
+ status.setEnabled(buffer().masterBuffer()->params().use_indices);
+ status.setOnOff(contains(getCmdName(), "printsubindex"));
+ return true;
+ } else if (cmd.argument() == from_ascii("check-printindex*")) {
+ status.setEnabled(buffer().masterBuffer()->params().use_indices);
+ status.setOnOff(suffixIs(getCmdName(), '*'));
+ return true;
+ } if (cmd.getArg(0) == "index_print"
+ && cmd.getArg(1) == "CommandInset") {
InsetCommandParams p(INDEX_PRINT_CODE);
InsetCommand::string2params("index_print",
to_utf8(cmd.argument()), p);
+ if (suffixIs(p.getCmdName(), '*')) {
+ status.setEnabled(true);
+ status.setOnOff(false);
+ return true;
+ }
Buffer const & realbuffer = *buffer().masterBuffer();
IndicesList const & indiceslist =
realbuffer.params().indiceslist();
status.setEnabled(index != 0);
status.setOnOff(p["type"] == getParam("type"));
return true;
- }
+ } else
+ return InsetCommand::getStatus(cur, cmd, status);
}
- case LFUN_INSET_DIALOG_UPDATE:
- case LFUN_INSET_SETTINGS: {
- Buffer const & realbuffer = *buffer().masterBuffer();
- status.setEnabled(realbuffer.params().use_indices);
+ case LFUN_INSET_DIALOG_UPDATE: {
+ status.setEnabled(buffer().masterBuffer()->params().use_indices);
return true;
}
}
-Inset::EDITABLE InsetPrintIndex::editable() const
+bool InsetPrintIndex::hasSettings() const
{
- return buffer().masterBuffer()->params().use_indices ?
- IS_EDITABLE : NOT_EDITABLE;
+ return buffer().masterBuffer()->params().use_indices;
}
+docstring InsetPrintIndex::xhtml(XHTMLStream &, OutputParams const &) const
+{
+ return docstring();
+}
+
} // namespace lyx