#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"
/// 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);
}
}
+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) {
case INCLUDE:
temp = buf.B_("Include");
break;
- case LISTINGS: {
+ case LISTINGS:
temp = listings_label_;
- }
+ case NONE:
+ BOOST_ASSERT(false);
}
temp += ": ";