#include "Lexer.h"
#include "OutputParams.h"
#include "TextClass.h"
+#include "TocBackend.h"
#include "support/debug.h"
#include "support/gettext.h"
if (!params_.branch.empty()) {
// FIXME UNICODE
ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));
- if (c == Color_none) {
+ if (c == Color_none)
s = _("Undef: ") + s;
- }
}
if (decoration() == InsetLayout::Classic)
setLabel(isOpen() ? s : getNewLabel(s) );
ColorCode InsetBranch::backgroundColor() const
{
- if (!params_.branch.empty()) {
- // FIXME UNICODE
- ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));
- if (c == Color_none) {
- c = Color_error;
- }
- return c;
- } else
+ if (params_.branch.empty())
return Inset::backgroundColor();
+ // FIXME UNICODE
+ ColorCode c = lcolor.getFromLyXName(to_utf8(params_.branch));
+ if (c == Color_none)
+ c = Color_error;
+ return c;
}
switch (cmd.action) {
case LFUN_INSET_MODIFY:
case LFUN_INSET_DIALOG_UPDATE:
- flag.enabled(true);
+ flag.setEnabled(true);
break;
case LFUN_INSET_TOGGLE:
if (cmd.argument() == "open" || cmd.argument() == "close" ||
cmd.argument() == "toggle")
- flag.enabled(true);
+ flag.setEnabled(true);
else if (cmd.argument() == "assign" || cmd.argument().empty()) {
if (isBranchSelected())
- flag.enabled(status() != Open);
+ flag.setEnabled(status() != Open);
else
- flag.enabled(status() != Collapsed);
+ flag.setEnabled(status() != Collapsed);
} else
- flag.enabled(true);
+ flag.setEnabled(true);
break;
default:
{
Buffer const & realbuffer = *buffer().masterBuffer();
BranchList const & branchlist = realbuffer.params().branchlist();
- BranchList::const_iterator const end = branchlist.end();
- BranchList::const_iterator it =
- find_if(branchlist.begin(), end,
- BranchNamesEqual(params_.branch));
- if (it == end)
+ Branch const * ourBranch = branchlist.find(params_.branch);
+ if (!ourBranch)
return false;
- return it->getSelected();
-}
-
-
-void InsetBranch::updateLabels(ParIterator const & it)
-{
- if (isBranchSelected())
- InsetCollapsable::updateLabels(it);
- else {
- DocumentClass const & tclass = buffer().params().documentClass();
- Counters savecnt = tclass.counters();
- InsetCollapsable::updateLabels(it);
- tclass.counters() = savecnt;
- }
+ return ourBranch->getSelected();
}
void InsetBranch::textString(odocstream & os) const
{
if (isBranchSelected())
- os << paragraphs().begin()->asString(true);
+ os << paragraphs().begin()->asString(AS_STR_LABEL | AS_STR_INSETS);
}
}
+void InsetBranch::addToToc(DocIterator const & cpit)
+{
+ DocIterator pit = cpit;
+ pit.push_back(CursorSlice(*this));
+
+ Toc & toc = buffer().tocBackend().toc("branch");
+ docstring const str = params_.branch + ": " + text_.getPar(0).asString();
+ toc.push_back(TocItem(pit, 0, str));
+}
+
+
void InsetBranchParams::write(ostream & os) const
{
os << "Branch " << to_utf8(branch) << '\n';