+LyXFunc::func_status LyXFunc::getStatus(int ac) const
+{
+ kb_action action;
+ func_status flag = LyXFunc::OK;
+ string argument;
+ Buffer * buf = owner->buffer();
+
+ if (lyxaction.isPseudoAction(ac))
+ action = lyxaction.retrieveActionArg(ac, argument);
+ else
+ action = static_cast<kb_action>(ac);
+
+ if (action == LFUN_UNKNOWN_ACTION) {
+ setErrorMessage(N_("Unknown action"));
+ return LyXFunc::Unknown;
+ }
+
+ // Check whether we need a buffer
+ if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
+ // Yes we need a buffer, do we have one?
+ if (buf) {
+ // yes
+ // Can we use a readonly buffer?
+ if (buf->isReadonly() &&
+ !lyxaction.funcHasFlag(action,
+ LyXAction::ReadOnly)) {
+ // no
+ setErrorMessage(N_("Document is read-only"));
+ flag |= LyXFunc::Disabled;
+ }
+ } else {
+ // no
+ setErrorMessage(N_("Command not allowed with"
+ "out any document open"));
+ flag |= LyXFunc::Disabled;
+ }
+ }
+
+ if (flag & LyXFunc::Disabled)
+ return flag;
+
+ // I would really like to avoid having this switch and rather try to
+ // encode this in the function itself.
+ static bool noLaTeX = lyxrc.latex_command == "none";
+ bool disable = false;
+ switch (action) {
+ case LFUN_PREVIEW:
+ disable = noLaTeX || lyxrc.view_dvi_command == "none";
+ break;
+ case LFUN_PREVIEWPS:
+ disable = noLaTeX || lyxrc.view_ps_command == "none";
+ break;
+ case LFUN_RUNLATEX:
+ case LFUN_RUNDVIPS:
+ disable = noLaTeX;
+ break;
+ case LFUN_MENUPRINT:
+ disable = noLaTeX || lyxrc.print_command == "none";
+ break;
+ case LFUN_FAX:
+ disable = noLaTeX || lyxrc.fax_command == "none";
+ break;
+ case LFUN_IMPORT:
+ if (argument == "latex")
+ disable = lyxrc.relyx_command == "none";
+ if (argument == "linuxdoc")
+ disable = lyxrc.linuxdoc_to_lyx_command == "none";
+ break;
+ case LFUN_EXPORT:
+ if (argument == "dvi" || argument == "postscript")
+ disable = noLaTeX;
+ if (argument == "html")
+ disable = lyxrc.html_command == "none";
+ if (argument == "html-linuxdoc")
+ disable = lyxrc.linuxdoc_to_html_command == "none";
+ if (argument == "html-docbook")
+ disable = lyxrc.docbook_to_html_command == "none";
+ break;
+ case LFUN_UNDO:
+ disable = buf->undostack.empty();
+ break;
+ case LFUN_REDO:
+ disable = buf->redostack.empty();
+ break;
+ case LFUN_SPELLCHECK:
+ disable = lyxrc.isp_command == "none";
+ break;
+ case LFUN_RUNCHKTEX:
+ disable = lyxrc.chktex_command == "none";
+ break;
+ case LFUN_LAYOUT_TABLE:
+ disable = ! owner->view()->text->cursor.par->table;
+ break;
+ default:
+ break;
+ }
+ if (disable)
+ flag |= LyXFunc::Disabled;
+
+ if (buf) {
+ func_status box = LyXFunc::ToggleOff;
+ LyXFont font = owner->view()->text->real_current_font;
+ switch (action) {
+ case LFUN_EMPH:
+ if (font.emph() == LyXFont::ON)
+ box = LyXFunc::ToggleOn;
+ break;
+ case LFUN_NOUN:
+ if (font.noun() == LyXFont::ON)
+ box = LyXFunc::ToggleOn;
+ break;
+ case LFUN_BOLD:
+ if (font.series() == LyXFont::BOLD_SERIES)
+ box = LyXFunc::ToggleOn;
+ break;
+ case LFUN_TEX:
+ if (font.latex() == LyXFont::ON)
+ box = LyXFunc::ToggleOn;
+ break;
+ default:
+ box = LyXFunc::OK;
+ break;
+ }
+ flag |= box;
+ }
+
+ return flag;
+}
+
+
+string LyXFunc::Dispatch(string const & s)