]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetInfo.cpp
Move isMultiCell() to Cursor, and use it.
[lyx.git] / src / insets / InsetInfo.cpp
index 5e6eba7251814ff31b5b4ce7617caf3f9d76b601..e99f7afd39d5526a19fe1d3ea1b135979463fe27 100644 (file)
@@ -11,7 +11,6 @@
 
 #include "InsetInfo.h"
 
-#include "LayoutFile.h"
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "BufferView.h"
@@ -21,6 +20,7 @@
 #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>
 
@@ -147,10 +147,34 @@ void InsetInfo::write(ostream & os) const
 }
 
 
-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;
 }
 
 
@@ -254,11 +278,12 @@ void InsetInfo::updateInfo()
                }
                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;