#include "insetcommandparams.h"
#include "debug.h"
+#include "gettext.h"
#include "lyxlex.h"
+#include "support/ExceptionMessage.h"
#include "support/lstrings.h"
#include <boost/assert.hpp>
using std::endl;
using std::ostream;
+using support::ExceptionMessage;
+using support::WarningException;
InsetCommandParams::InsetCommandParams(string const & name)
: name_(name), preview_(false)
return &info;
}
+ // InsetNomencl
+ if (name == "nomenclature") {
+ static const char * const paramnames[] = {"prefix", "symbol", "description", ""};
+ static const bool isoptional[] = {true, false, false};
+ static const CommandInfo info = {3, paramnames, isoptional};
+ return &info;
+ }
+
+ // InsetPrintNomencl
+ if (name == "printnomenclature") {
+ static const char * const paramnames[] = {"labelwidth", ""};
+ static const bool isoptional[] = {true};
+ static const CommandInfo info = {1, paramnames, isoptional};
+ return &info;
+ }
+
// InsetRef
if (name == "eqref" || name == "pageref" || name == "vpageref" ||
name == "vref" || name == "prettyref" || name == "ref") {
if (!tsecoptions.empty()) setSecOptions(tsecoptions);
if (!tcontents.empty()) setContents(tcontents);
- if (lyxerr.debugging(Debug::PARSER))
- lyxerr << "Command <" << cmd
- << "> == <" << to_utf8(getCommand())
- << "> == <" << getCmdName()
- << '|' << getContents()
- << '|' << getOptions()
- << '|' << getSecOptions() << '>' << endl;
+ LYXERR(Debug::PARSER) << "Command <" << cmd
+ << "> == <" << to_utf8(getCommand())
+ << "> == <" << getCmdName()
+ << '|' << getContents()
+ << '|' << getOptions()
+ << '|' << getSecOptions() << '>' << endl;
}
lex.next();
name_ = lex.getString();
info_ = findInfo(name_);
- if (!info_)
+ if (!info_) {
lex.printError("InsetCommand: Unknown inset name `$$Token'");
+ throw ExceptionMessage(WarningException,
+ _("Unknown inset name: "),
+ from_utf8(name_));
+ }
}
string token;
if (i >= 0) {
lex.next(true);
params_[i] = lex.getDocString();
- } else
+ } else {
lex.printError("Unknown parameter name `$$Token' for command " + name_);
+ throw ExceptionMessage(WarningException,
+ _("Inset Command :") + from_ascii(name_),
+ _("Unknown parameter name: ") + from_utf8(token));
+ }
}
if (token != "\\end_inset") {
lex.printError("Missing \\end_inset at this point. "
"Read: `$$Token'");
+ throw ExceptionMessage(WarningException,
+ _("Missing \\end_inset at this point."),
+ from_utf8(token));
}
}
docstring const InsetCommandParams::getCommand() const
{
docstring s = '\\' + from_ascii(name_);
+ bool noparam = true;
for (size_t i = 0; i < info_->n; ++i) {
if (info_->optional[i]) {
if (params_[i].empty()) {
break;
if (!params_[j].empty()) {
s += "[]";
+ noparam = false;
break;
}
}
- } else
+ } else {
s += '[' + params_[i] + ']';
- } else
+ noparam = false;
+ }
+ } else {
s += '{' + params_[i] + '}';
+ noparam = false;
+ }
}
- if (info_->n == 0)
+ if (noparam)
// Make sure that following stuff does not change the
// command name.
s += "{}";