X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetCommandParams.h;h=861565a31ec9825d1d48b07ed6b83b72c94af5b3;hb=f365a650686cc27487f686a7803968df1f24e0b8;hp=7e343773c2caa6aecc7e11efe50249bd9879c806;hpb=e9293e28acd5e135e00dbb94992a1952a6a28308;p=lyx.git diff --git a/src/insets/InsetCommandParams.h b/src/insets/InsetCommandParams.h index 7e343773c2..861565a31e 100644 --- a/src/insets/InsetCommandParams.h +++ b/src/insets/InsetCommandParams.h @@ -16,6 +16,8 @@ #include "InsetCode.h" +#include "OutputParams.h" + #include "support/docstring.h" #include @@ -26,29 +28,46 @@ namespace lyx { class Lexer; +class Buffer; class ParamInfo { public: + /// + ParamInfo() {} /// Types of parameters enum ParamType { LATEX_OPTIONAL, /// normal optional argument LATEX_REQUIRED, /// normal required argument LYX_INTERNAL /// a parameter used internally by LyX }; + /// Special handling on output + enum ParamHandling { + HANDLING_NONE, /// no special handling + HANDLING_ESCAPE, /// escape special characters + HANDLING_LATEXIFY /// transform special characters to LaTeX macros + }; /// class ParamData { // No parameter may be named "preview", because that is a required // flag for all commands. public: /// - ParamData(std::string const &, ParamType); + ParamData(std::string const &, ParamType, ParamHandling = HANDLING_NONE, + bool ignore = false, + docstring default_value = docstring()); /// std::string name() const { return name_; } /// ParamType type() const { return type_; } + /// + ParamHandling handling() const { return handling_; } /// whether this is an optional LaTeX argument bool isOptional() const; /// + bool ignore() const { return ignore_; } + /// + docstring const & defaultValue() const { return default_value_; } + /// bool operator==(ParamData const &) const; /// bool operator!=(ParamData const & rhs) const @@ -58,10 +77,20 @@ public: std::string name_; /// ParamType type_; + /// do we need special handling on latex output? + ParamHandling handling_; + /// + bool ignore_; + /// + docstring default_value_; }; /// adds a new parameter - void add(std::string const & name, ParamType type); + /// If ignore is true, then the parameter is never saved, and is always + /// given the default value. + void add(std::string const & name, ParamType type, + ParamHandling = HANDLING_NONE, bool ignore = false, + docstring default_value = docstring()); /// bool empty() const { return info_.empty(); } /// @@ -97,13 +126,16 @@ public: std::string insetType() const; /// InsetCode code() const { return insetCode_; } - /// - void read(Lexer &); /// Parse the command + void read(Lexer &); + /// + void Read(Lexer &, Buffer const *); /// void write(std::ostream &) const; + /// + void Write(std::ostream & os, Buffer const * buf) const; /// Build the complete LaTeX command - docstring getCommand() const; + docstring getCommand(OutputParams const &) const; /// Return the command name std::string const & getCmdName() const { return cmdName_; } /// Set the name to \p n. This must be a known name. All parameters @@ -114,10 +146,10 @@ public: /// ways that make removal hard. docstring getFirstNonOptParam() const; /// get parameter \p name - /// LyX will assert if you attempt to do so. + /// LyX will assert if name is not a valid parameter. docstring const & operator[](std::string const & name) const; /// set parameter \p name - /// LyX will assert if you attempt to do so. + /// LyX will assert if name is not a valid parameter. docstring & operator[](std::string const & name); /// bool preview() const { return preview_; } @@ -127,7 +159,11 @@ public: void clear(); /// static bool isCompatibleCommand(InsetCode code, std::string const & s); - + /// + ParamInfo const & info() const { return info_; } + /// + docstring prepareCommand(OutputParams const & runparams, + docstring const & command, ParamInfo::ParamHandling handling) const; private: std::string getDefaultCmd(InsetCode code); /// checks whether we need to write an empty optional parameter