#include "InsetInfo.h"
-#include "LayoutFile.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "BufferView.h"
#include "InsetSpecialChar.h"
#include "KeyMap.h"
#include "LaTeXFeatures.h"
+#include "LayoutFile.h"
#include "LyXAction.h"
#include "LyXRC.h"
#include "Lexer.h"
#include "support/debug.h"
#include "support/docstream.h"
#include "support/docstring_list.h"
+#include "support/ExceptionMessage.h"
#include "support/FileName.h"
#include "support/filetools.h"
#include "support/gettext.h"
#include "support/lstrings.h"
-#include "support/ExceptionMessage.h"
#include <sstream>
}
-bool InsetInfo::validate(docstring const & argument) const
+bool InsetInfo::validate(docstring const & arg) const
{
- // FIXME!
- return true;
+ string type;
+ string name;
+
+ name = trim(split(to_utf8(arg), type, ' '));
+ switch (nameTranslator().find(type)) {
+ case UNKNOWN_INFO:
+ return false;
+ case SHORTCUT_INFO:
+ case SHORTCUTS_INFO:
+ case MENU_INFO:
+ case ICON_INFO: {
+ FuncRequest func = lyxaction.lookupFunc(name);
+ return func.action != LFUN_UNKNOWN_ACTION;
+ }
+ case LYXRC_INFO: {
+ ostringstream oss;
+ lyxrc.write(oss, true, name);
+ return !oss.str().empty();
+ }
+ case PACKAGE_INFO:
+ case TEXTCLASS_INFO:
+ return true;
+ case BUFFER_INFO:
+ return name_ == "name" || name_ == "path" || name_ == "class";
+ }
+ return false;
}
}
KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(func);
if (bindings.empty()) {
- error("No binding for action %1$s");
+ // It is impropriate to use error() for undefined shortcut
+ setText(_("undefined"));
break;
}
if (type_ == SHORTCUT_INFO)
- setText(bindings.rbegin()->print(KeySequence::ForGui));
+ setText(bindings.rbegin()->print(KeySequence::Portable));
else
setText(theTopLevelKeymap().printBindings(func));
break;