bool InsetCaption::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const { switch (cmd.action()) { case LFUN_INSET_MODIFY: { string const first_arg = cmd.getArg(0); if (first_arg == "changetype") { string const type = cmd.getArg(1); status.setOnOff(type == type_); bool varia = type != "Unnumbered"; // check if the immediate parent inset allows caption variation if (cur.depth() > 1) { varia = cur[cur.depth() - 2].inset().allowsCaptionVariation(type); } status.setEnabled(varia && buffer().params().documentClass().hasInsetLayout( from_ascii("Caption:" + type))); return true; } return InsetText::getStatus(cur, cmd, status); } case LFUN_INSET_TOGGLE: // pass back to owner cur.undispatched(); return false; default: return InsetText::getStatus(cur, cmd, status); } }
bool InsetCommand::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const { switch (cmd.action()) { // suppress these case LFUN_ERT_INSERT: status.setEnabled(false); return true; // we handle these case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "changetype") { string const newtype = cmd.getArg(1); status.setEnabled(p_.isCompatibleCommand(p_.code(), newtype)); status.setOnOff(newtype == p_.getCmdName()); } status.setEnabled(true); return true; case LFUN_INSET_DIALOG_UPDATE: status.setEnabled(true); return true; default: return Inset::getStatus(cur, cmd, status); } }
bool Inset::getStatus(Cursor &, FuncRequest const & cmd, FuncStatus & flag) const { // LFUN_INSET_APPLY is sent from the dialogs when the data should // be applied. This is either changed to LFUN_INSET_MODIFY (if the // dialog belongs to us) or LFUN_INSET_INSERT (if the dialog does // not belong to us, i. e. the dialog was open, and the user moved // the cursor in our inset) in lyx::getStatus(). // Dialogs::checkStatus() ensures that the dialog is deactivated if // LFUN_INSET_APPLY is disabled. switch (cmd.action()) { case LFUN_INSET_MODIFY: // Allow modification of our data. // This needs to be handled in the doDispatch method of our // instantiatable children. // FIXME: Why don't we let the insets determine whether this // should be enabled or not ? Now we need this check for // the tabular features. (vfr) if (cmd.getArg(0) == "tabular") return false; flag.setEnabled(true); return true; case LFUN_INSET_INSERT: // Don't allow insertion of new insets. // Every inset that wants to allow new insets from open // dialogs needs to override this. flag.setEnabled(false); return true; case LFUN_INSET_SETTINGS: if (cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode())) { bool const enable = hasSettings(); flag.setEnabled(enable); return true; } else { return false; } case LFUN_IN_MATHMACROTEMPLATE: // By default we're not in a MathMacroTemplate inset flag.setEnabled(false); return true; case LFUN_IN_IPA: // By default we're not in an IPA inset flag.setEnabled(false); return true; default: break; } return false; }
bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const { switch (cmd.action()) { case LFUN_INSET_DISSOLVE: { bool const main_inset = text_.isMainText(); bool const target_inset = cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode()); // cur.inset() is the tabular when this is a single cell (bug #9954) bool const one_cell = cur.inset().nargs() == 1; if (target_inset) status.setEnabled(!main_inset && one_cell); return target_inset; } case LFUN_ARGUMENT_INSERT: { string const arg = cmd.getArg(0); if (arg.empty()) { status.setEnabled(false); return true; } if (text_.isMainText() || !cur.paragraph().layout().args().empty()) return text_.getStatus(cur, cmd, status); Layout::LaTeXArgMap args = getLayout().args(); Layout::LaTeXArgMap::const_iterator const lait = args.find(arg); if (lait != args.end()) { status.setEnabled(true); for (Paragraph const & par : paragraphs()) for (auto const & table : par.insetList()) if (InsetArgument const * ins = table.inset->asInsetArgument()) if (ins->name() == arg) { // we have this already status.setEnabled(false); return true; } } else status.setEnabled(false); return true; } default: // Dispatch only to text_ if the cursor is inside // the text_. It is not for context menus (bug 5797). bool ret = false; if (cur.text() == &text_) ret = text_.getStatus(cur, cmd, status); if (!ret) ret = Inset::getStatus(cur, cmd, status); return ret; } }
bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const { switch (cmd.action()) { case LFUN_INSET_DISSOLVE: { bool const main_inset = &buffer().inset() == this; bool const target_inset = cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode()); bool const one_cell = nargs() == 1; if (target_inset) status.setEnabled(!main_inset && one_cell); return target_inset; } default: // Dispatch only to text_ if the cursor is inside // the text_. It is not for context menus (bug 5797). bool ret = false; if (cur.text() == &text_) ret = text_.getStatus(cur, cmd, status); if (!ret) ret = Inset::getStatus(cur, cmd, status); return ret; } }
void Inset::doDispatch(Cursor & cur, FuncRequest &cmd) { switch (cmd.action()) { case LFUN_MOUSE_RELEASE: // if the derived inset did not explicitly handle mouse_release, // we assume we request the settings dialog if (!cur.selection() && cmd.button() == mouse_button::button1 && hasSettings()) { FuncRequest tmpcmd(LFUN_INSET_SETTINGS); dispatch(cur, tmpcmd); } break; case LFUN_INSET_SETTINGS: if (cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode())) { showInsetDialog(&cur.bv()); cur.dispatched(); } else cur.undispatched(); break; default: cur.noScreenUpdate(); cur.undispatched(); break; } }
void InsetCaption::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action()) { case LFUN_INSET_MODIFY: { if (cmd.getArg(0) == "changetype") { cur.recordUndoInset(ATOMIC_UNDO, this); type_ = cmd.getArg(1); cur.forceBufferUpdate(); break; } } default: InsetText::doDispatch(cur, cmd); break; } }
void InsetText::doDispatch(Cursor & cur, FuncRequest & cmd) { LYXERR(Debug::ACTION, "InsetText::doDispatch(): cmd: " << cmd); // See bug #9042, for instance. if (isPassThru()) { // Force any new text to latex_language FIXME: This // should only be necessary in constructor, but new // paragraphs that are created by pressing enter at // the start of an existing paragraph get the buffer // language and not latex_language, so we take this // brute force approach. cur.current_font.setLanguage(latex_language); cur.real_current_font.setLanguage(latex_language); } switch (cmd.action()) { case LFUN_PASTE: case LFUN_CLIPBOARD_PASTE: case LFUN_SELECTION_PASTE: case LFUN_PRIMARY_SELECTION_PASTE: text_.dispatch(cur, cmd); // If we we can only store plain text, we must reset all // attributes. // FIXME: Change only the pasted paragraphs fixParagraphsFont(); break; case LFUN_INSET_DISSOLVE: { bool const main_inset = text_.isMainText(); bool const target_inset = cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode()); // cur.inset() is the tabular when this is a single cell (bug #9954) bool const one_cell = cur.inset().nargs() == 1; if (!main_inset && target_inset && one_cell) { // Text::dissolveInset assumes that the cursor // is inside the Inset. if (&cur.inset() != this) cur.pushBackward(*this); cur.beginUndoGroup(); text_.dispatch(cur, cmd); cur.endUndoGroup(); } else cur.undispatched(); break; } default: text_.dispatch(cur, cmd); } if (!cur.result().dispatched()) Inset::doDispatch(cur, cmd); }
void InsetCommand::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action()) { case LFUN_INSET_MODIFY: { if (cmd.getArg(0) == "changetype") { cur.recordUndo(); p_.setCmdName(cmd.getArg(1)); cur.forceBufferUpdate(); initView(); break; } InsetCommandParams p(p_.code()); InsetCommand::string2params(to_utf8(cmd.argument()), p); if (p.getCmdName().empty()) cur.noScreenUpdate(); else { cur.recordUndo(); setParams(p); } // FIXME We might also want to check here if this one is in the TOC. // But I think most of those are labeled. if (isLabeled()) cur.forceBufferUpdate(); break; } case LFUN_INSET_DIALOG_UPDATE: { string const name = to_utf8(cmd.argument()); cur.bv().updateDialog(name, params2string(params())); break; } default: Inset::doDispatch(cur, cmd); break; } }
bool InsetERT::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const { switch (cmd.action()) { case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "ert") { status.setEnabled(true); return true; } //fall through default: return InsetCollapsable::getStatus(cur, cmd, status); } }
bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & flag) const { switch (cmd.action()) { case LFUN_INSET_MODIFY: // disallow comment and greyed out in commands flag.setEnabled(!cur.paragraph().layout().isCommand() || cmd.getArg(2) == "Note"); if (cmd.getArg(0) == "note") { InsetNoteParams params; string2params(to_utf8(cmd.argument()), params); flag.setOnOff(params_.type == params.type); } return true; case LFUN_INSET_DIALOG_UPDATE: flag.setEnabled(true); return true; default: return InsetCollapsable::getStatus(cur, cmd, flag); } }
void InsetERT::doDispatch(Cursor & cur, FuncRequest & cmd) { switch (cmd.action()) { case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "ert") { cur.recordUndoInset(ATOMIC_UNDO, this); setStatus(cur, string2params(to_utf8(cmd.argument()))); break; } //fall-through default: InsetCollapsable::doDispatch(cur, cmd); break; } }
bool InsetMathAMSArray::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & flag) const { switch (cmd.action()) { case LFUN_TABULAR_FEATURE: { string s = cmd.getArg(0); if (s == "add-vline-left" || s == "add-vline-right") { flag.message(bformat( from_utf8(N_("Can't add vertical grid lines in '%1$s'")), name_)); flag.setEnabled(false); return true; } break; } default: break; } return InsetMathGrid::getStatus(cur, cmd, flag); }
bool InsetText::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const { switch (cmd.action()) { case LFUN_INSET_DISSOLVE: { bool const main_inset = &buffer().inset() == this; bool const target_inset = cmd.argument().empty() || cmd.getArg(0) == insetName(lyxCode()); bool const one_cell = nargs() == 1; if (target_inset) status.setEnabled(!main_inset && one_cell); return target_inset; } case LFUN_ARGUMENT_INSERT: { string const arg = cmd.getArg(0); if (arg.empty()) { status.setEnabled(false); return true; } if (&buffer().inset() == this || !cur.paragraph().layout().args().empty()) return text_.getStatus(cur, cmd, status); Layout::LaTeXArgMap args = getLayout().args(); Layout::LaTeXArgMap::const_iterator const lait = args.find(arg); if (lait != args.end()) { status.setEnabled(true); ParagraphList::const_iterator pit = paragraphs().begin(); for (; pit != paragraphs().end(); ++pit) { InsetList::const_iterator it = pit->insetList().begin(); InsetList::const_iterator end = pit->insetList().end(); for (; it != end; ++it) { if (it->inset->lyxCode() == ARG_CODE) { InsetArgument const * ins = static_cast<InsetArgument const *>(it->inset); if (ins->name() == arg) { // we have this already status.setEnabled(false); return true; } } } } } else status.setEnabled(false); return true; } default: // Dispatch only to text_ if the cursor is inside // the text_. It is not for context menus (bug 5797). bool ret = false; if (cur.text() == &text_) ret = text_.getStatus(cur, cmd, status); if (!ret) ret = Inset::getStatus(cur, cmd, status); return ret; } }