+ if (cmd.getArg(0) == "toggleparam") {
+ string cmdname = getCmdName();
+ string const alias =
+ buffer().masterParams().getCiteAlias(cmdname);
+ if (!alias.empty())
+ cmdname = alias;
+ string const par = cmd.getArg(1);
+ string newcmdname = cmdname;
+ if (par == "star") {
+ if (suffixIs(cmdname, "*"))
+ newcmdname = rtrim(cmdname, "*");
+ else
+ newcmdname = cmdname + "*";
+ } else if (par == "casing") {
+ if (isUpperCase(cmdname[0]))
+ newcmdname[0] = lowercase(cmdname[0]);
+ else
+ newcmdname[0] = uppercase(newcmdname[0]);
+ }
+ cmd = FuncRequest(LFUN_INSET_MODIFY, "changetype " + newcmdname);
+ }
+ }
+ default:
+ InsetCommand::doDispatch(cur, cmd);
+ }
+}
+
+
+bool InsetCitation::getStatus(Cursor & cur, FuncRequest const & cmd,
+ FuncStatus & status) const
+{
+ switch (cmd.action()) {
+ // Handle the alias case
+ case LFUN_INSET_MODIFY:
+ if (cmd.getArg(0) == "changetype") {
+ string cmdname = getCmdName();
+ string const alias =
+ buffer().masterParams().getCiteAlias(cmdname);
+ if (!alias.empty())
+ cmdname = alias;
+ if (suffixIs(cmdname, "*"))
+ cmdname = rtrim(cmdname, "*");
+ string const newtype = cmd.getArg(1);
+ status.setEnabled(isCompatibleCommand(newtype));
+ status.setOnOff(newtype == cmdname);
+ }
+ if (cmd.getArg(0) == "toggleparam") {
+ string cmdname = getCmdName();
+ string const alias =
+ buffer().masterParams().getCiteAlias(cmdname);
+ if (!alias.empty())
+ cmdname = alias;
+ vector<CitationStyle> citation_styles =
+ buffer().masterParams().citeStyles();
+ CitationStyle cs = getCitationStyle(buffer().masterParams(),
+ cmdname, citation_styles);
+ if (cmd.getArg(1) == "star") {
+ status.setEnabled(cs.hasStarredVersion);
+ status.setOnOff(suffixIs(cmdname, "*"));
+ }
+ else if (cmd.getArg(1) == "casing") {
+ status.setEnabled(cs.forceUpperCase);
+ status.setOnOff(isUpperCase(cmdname[0]));
+ }
+ }
+ return true;
+ default:
+ return InsetCommand::getStatus(cur, cmd, status);