#include <sstream>
+
+namespace lyx {
+
using std::string;
using std::auto_ptr;
using std::istringstream;
void InsetBranch::init()
{
- setInsetName("Branch");
+ setInsetName(from_utf8("Branch"));
setButtonLabel();
}
}
-string const InsetBranch::editMessage() const
+docstring const InsetBranch::editMessage() const
{
return _("Opened Branch Inset");
}
font.decSize();
font.decSize();
- string s = _("Branch: ") + params_.branch;
- setLabel(isOpen() ? s : getNewLabel(s) );
+ docstring s = _("Branch: ") + params_.branch;
font.setColor(LColor::foreground);
- if (!params_.branch.empty())
- setBackgroundColor(lcolor.getFromLyXName(params_.branch));
- else
+ if (!params_.branch.empty()) {
+ // FIXME UNICODE
+ LColor_color c = lcolor.getFromLyXName(to_utf8(params_.branch));
+ if (c == LColor::none) {
+ c = LColor::error;
+ s = _("Undef: ") + s;
+ }
+ setBackgroundColor(c);
+ } else
setBackgroundColor(LColor::background);
+ setLabel(isOpen() ? s : getNewLabel(s) );
setLabelFont(font);
}
switch (cmd.action) {
case LFUN_INSET_MODIFY: {
InsetBranchParams params;
- InsetBranchMailer::string2params(cmd.argument, params);
+ InsetBranchMailer::string2params(to_utf8(cmd.argument()), params);
params_.branch = params.branch;
setButtonLabel();
break;
case LFUN_INSET_TOGGLE:
- if (cmd.argument == "assign" || cmd.argument.empty()) {
+ if (cmd.argument() == "assign" || cmd.argument().empty()) {
// The branch inset uses "assign".
- BranchList const & branchlist =
- cur.buffer().params().branchlist();
- if (isBranchSelected(branchlist)) {
+ if (isBranchSelected(cur.buffer())) {
if (status() != Open)
setStatus(cur, Open);
else
break;
case LFUN_INSET_TOGGLE:
- if (cmd.argument == "open" || cmd.argument == "close" ||
- cmd.argument == "toggle")
+ if (cmd.argument() == "open" || cmd.argument() == "close" ||
+ cmd.argument() == "toggle")
flag.enabled(true);
- else if (cmd.argument == "assign"
- || cmd.argument.empty()) {
- BranchList const & branchlist =
- cur.buffer().params().branchlist();
- if (isBranchSelected(branchlist))
+ else if (cmd.argument() == "assign"
+ || cmd.argument().empty()) {
+ if (isBranchSelected(cur.buffer()))
flag.enabled(status() != Open);
else
flag.enabled(status() != Collapsed);
}
-bool InsetBranch::isBranchSelected(BranchList const & branchlist) const
+bool InsetBranch::isBranchSelected(Buffer const & buffer) const
{
+ Buffer const & realbuffer = *buffer.getMasterBuffer();
+ BranchList const & branchlist = realbuffer.params().branchlist();
BranchList::const_iterator const end = branchlist.end();
BranchList::const_iterator it =
std::find_if(branchlist.begin(), end,
}
-int InsetBranch::latex(Buffer const & buf, ostream & os,
+int InsetBranch::latex(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
- return isBranchSelected(buf.params().branchlist()) ?
+ return isBranchSelected(buf) ?
InsetText::latex(buf, os, runparams) : 0;
}
-int InsetBranch::linuxdoc(Buffer const & buf, std::ostream & os,
- OutputParams const & runparams) const
-{
- return isBranchSelected(buf.params().branchlist()) ?
- InsetText::linuxdoc(buf, os, runparams) : 0;
-}
-
-
-int InsetBranch::docbook(Buffer const & buf, std::ostream & os,
+int InsetBranch::docbook(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
- return isBranchSelected(buf.params().branchlist()) ?
+ return isBranchSelected(buf) ?
InsetText::docbook(buf, os, runparams) : 0;
}
-int InsetBranch::plaintext(Buffer const & buf, std::ostream & os,
+int InsetBranch::plaintext(Buffer const & buf, odocstream & os,
OutputParams const & runparams) const
{
- return isBranchSelected(buf.params().branchlist()) ?
+ return isBranchSelected(buf) ?
InsetText::plaintext(buf, os, runparams): 0;
}
void InsetBranchParams::write(ostream & os) const
{
- os << "Branch " << branch << '\n';
+ os << "Branch " << to_utf8(branch) << '\n';
}
{
lex >> branch;
}
+
+} // namespace lyx