#include "LaTeX.h"
#include "LaTeXFeatures.h"
#include "Lexer.h"
+#include "LyX.h"
#include "output_latex.h"
#include "output_xhtml.h"
#include "xml.h"
cur.bv().updateDialog("index", params2string(params_));
break;
+ case LFUN_PARAGRAPH_BREAK: {
+ // Since this inset in single-par anyway, let's use
+ // return to enter subentries
+ FuncRequest fr(LFUN_INDEXMACRO_INSERT, "subentry");
+ lyx::dispatch(fr);
+ break;
+ }
+
default:
InsetCollapsible::doDispatch(cur, cmd);
break;
return true;
}
+ case LFUN_PARAGRAPH_BREAK:
+ return macrosPossible("subentry");
+
case LFUN_INDEXMACRO_INSERT:
return macrosPossible(cmd.getArg(0));
if (inset.lyxCode() == INDEXMACRO_CODE) {
InsetIndexMacro const & iim =
static_cast<InsetIndexMacro const &>(inset);
- if (iim.params().type == InsetIndexMacroParams::Subindex) {
+ if (iim.params().type == InsetIndexMacroParams::Subentry) {
++i;
if (i > 2)
return;
}
-std::vector<docstring> InsetIndex::getSubentriesAsText(OutputParams const & runparams) const
+std::vector<docstring> InsetIndex::getSubentriesAsText(OutputParams const & runparams,
+ bool const asLabel) const
{
std::vector<docstring> subentries;
if (inset.lyxCode() == INDEXMACRO_CODE) {
InsetIndexMacro const & iim =
static_cast<InsetIndexMacro const &>(inset);
- if (iim.params().type == InsetIndexMacroParams::Subindex) {
+ if (iim.params().type == InsetIndexMacroParams::Subentry) {
++i;
if (i > 2)
break;
-
- otexstringstream os;
- iim.getLatex(os, runparams);
- subentries.emplace_back(os.str());
+ if (asLabel) {
+ docstring const l;
+ docstring const sl = iim.getNewLabel(l);
+ subentries.emplace_back(sl);
+ } else {
+ otexstringstream os;
+ iim.getLatex(os, runparams);
+ subentries.emplace_back(os.str());
+ }
}
}
}
bool InsetIndex::hasSubentries() const
{
- return hasInsetWithCode(this, INDEXMACRO_CODE, {InsetIndexMacroParams::Subindex});
+ return hasInsetWithCode(this, INDEXMACRO_CODE, {InsetIndexMacroParams::Subentry});
}
bool InsetIndex::macrosPossible(string const type) const
{
if (type != "see" && type != "seealso"
- && type != "sortkey" && type != "subindex")
+ && type != "sortkey" && type != "subentry")
return false;
Paragraph const & par = paragraphs().front();
&& (iim.params().type == InsetIndexMacroParams::See
|| iim.params().type == InsetIndexMacroParams::Seealso))
return false;
- if (type == "subindex"
- && iim.params().type == InsetIndexMacroParams::Subindex) {
+ if (type == "subentry"
+ && iim.params().type == InsetIndexMacroParams::Subentry) {
++subidxs;
if (subidxs > 1)
return false;
docstring res;
if (!il.contentaslabel() || geometry(bv) != ButtonOnly)
res = label;
- else
+ else {
res = getNewLabel(label);
+ OutputParams const rp(0);
+ vector<docstring> sublbls = getSubentriesAsText(rp, true);
+ for (auto const & sublbl : sublbls) {
+ res += " " + docstring(1, char_type(0x2023));// TRIANGULAR BULLET
+ res += " " + sublbl;
+ }
+ }
if (!insetindexpagerangetranslator_latex().find(params_.range).empty())
res += " " + from_ascii(insetindexpagerangetranslator_latex().find(params_.range));
return res;
DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetIndex &>(*this)));
docstring str;
+ InsetLayout const & il = getLayout();
+ docstring label = translateIfPossible(il.labelstring());
+ if (!il.contentaslabel())
+ str = label;
+ else {
+ str = getNewLabel(label);
+ OutputParams const rp(0);
+ vector<docstring> sublbls = getSubentriesAsText(rp, true);
+ for (auto const & sublbl : sublbls) {
+ str += " " + docstring(1, char_type(0x2023));// TRIANGULAR BULLET
+ str += " " + sublbl;
+ }
+ }
string type = "index";
if (buffer().masterBuffer()->params().use_indices)
type += ":" + to_utf8(params_.index);
- // this is unlikely to be terribly long
- text().forOutliner(str, INT_MAX);
TocBuilder & b = backend.builder(type);
b.pushItem(pit, str, output_active);
// Proceed with the rest of the inset.