]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetInclude.cpp
pimpl not needed here
[lyx.git] / src / insets / InsetInclude.cpp
index 0fc1549e40167f180884d351b17858a71bc2d11c..e236ad70367405cc2122adee361712b635720dfd 100644 (file)
@@ -42,6 +42,7 @@
 #include "insets/RenderPreview.h"
 #include "insets/InsetListingsParams.h"
 
+#include "support/docstream.h"
 #include "support/filetools.h"
 #include "support/lstrings.h" // contains
 #include "support/lyxalgo.h"
@@ -96,27 +97,29 @@ docstring const uniqueID()
 
 /// the type of inclusion
 enum Types {
-       INCLUDE = 0,
-       VERB = 1,
-       INPUT = 2,
-       VERBAST = 3,
-       LISTINGS = 4,
+       INCLUDE, VERB, INPUT, VERBAST, LISTINGS, NONE
 };
 
 
-Types type(InsetCommandParams const & params)
-{
-       string const command_name = params.getCmdName();
-
-       if (command_name == "input")
+Types type(std::string const & s) {
+       if (s == "input")
                return INPUT;
-       if  (command_name == "verbatiminput")
+       if (s == "verbatiminput")
                return VERB;
-       if  (command_name == "verbatiminput*")
+       if (s == "verbatiminput*")
                return VERBAST;
-       if  (command_name == "lstinputlisting")
+       if (s == "lstinputlisting")
                return LISTINGS;
-       return INCLUDE;
+       if (s == "include")
+               return INCLUDE;
+       return NONE;
+}
+
+
+Types type(InsetCommandParams const & params)
+{
+       string const command_name = params.getCmdName();
+       return type(command_name);
 }
 
 
@@ -158,6 +161,22 @@ InsetInclude::InsetInclude(InsetInclude const & other)
 }
 
 
+CommandInfo const * InsetInclude::findInfo(std::string const & /* cmdName */)
+{
+       //This is only correct for the case of listings, but it'll do for now.
+       //In the other cases, this second parameter should just be empty.
+       static const char * const paramnames[] = {"filename", "lstparams", ""};
+       static const bool isoptional[] = {false, true};
+       static const CommandInfo info = {2, paramnames, isoptional};
+       return &info;
+}
+
+
+bool InsetInclude::isCompatibleCommand(std::string const & s) {
+       return type(s) != NONE;
+}
+
+
 void InsetInclude::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
@@ -255,9 +274,10 @@ docstring const InsetInclude::getScreenLabel(Buffer const & buf) const
                case INCLUDE:
                        temp = buf.B_("Include");
                        break;
-               case LISTINGS: {
+               case LISTINGS:
                        temp = listings_label_;
-               }
+               case NONE:
+                       BOOST_ASSERT(false);
        }
 
        temp += ": ";