X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetCommandParams.h;h=eb976c28d7ce612ae5372bf2120d8400c0108ccf;hb=7986ac2f322aeb9c764d1c518cedd159d62f32d7;hp=7dc59fa5ee764fc0e46cf65d4d5a6008ee5fdb42;hpb=bfa9991f9308c414357810cb1d1152929e96b70b;p=lyx.git diff --git a/src/insets/InsetCommandParams.h b/src/insets/InsetCommandParams.h index 7dc59fa5ee..eb976c28d7 100644 --- a/src/insets/InsetCommandParams.h +++ b/src/insets/InsetCommandParams.h @@ -28,9 +28,12 @@ namespace lyx { class Lexer; +class Buffer; class ParamInfo { public: + /// + ParamInfo() {} /// Types of parameters enum ParamType { LATEX_OPTIONAL, /// normal optional argument @@ -39,9 +42,11 @@ public: }; /// Special handling on output enum ParamHandling { - HANDLING_NONE, /// no special handling - HANDLING_ESCAPE, /// escape special characters - HANDLING_LATEXIFY /// transform special characters to LaTeX macros + HANDLING_NONE = 1, /// no special handling + HANDLING_ESCAPE = 2, /// escape special characters + HANDLING_LATEXIFY = 4, /// transform special characters to LaTeX macros + HANDLING_LTRIM = 8, /// trim blanks on the left + HANDLING_INDEX_ESCAPE = 16, /// escape makeindex special chars }; /// class ParamData { @@ -49,7 +54,9 @@ public: // flag for all commands. public: /// - ParamData(std::string const &, ParamType, ParamHandling = HANDLING_NONE); + ParamData(std::string const &, ParamType, ParamHandling = HANDLING_NONE, + bool ignore = false, + docstring default_value = docstring()); /// std::string name() const { return name_; } /// @@ -59,8 +66,12 @@ public: /// 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 { return !(*this == rhs); } private: @@ -70,11 +81,18 @@ public: ParamType type_; /// do we need special handling on latex output? ParamHandling handling_; + /// + bool ignore_; + /// + docstring default_value_; }; /// adds a new parameter + /// 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); + ParamHandling = HANDLING_NONE, bool ignore = false, + docstring default_value = docstring()); /// bool empty() const { return info_.empty(); } /// @@ -86,7 +104,7 @@ public: /// const_iterator const end() const { return info_.end(); } /// \return true if name corresponds to a parameter of some sort. - /// \return false if the parameter does not exist at all of it it + /// \return false if the parameter does not exist at all of it it bool hasParam(std::string const & name) const; /// ParamData const & operator[](std::string const & name) const; @@ -110,11 +128,14 @@ 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(OutputParams const &) const; /// Return the command name @@ -123,7 +144,7 @@ public: /// are cleared except those that exist also in the new command. /// What matters here is the parameter name, not position. void setCmdName(std::string const & n); - /// FIXME Would be better removed, but is used in BufferView.cpp in + /// FIXME Would be better removed, but is used in BufferView.cpp in /// ways that make removal hard. docstring getFirstNonOptParam() const; /// get parameter \p name @@ -140,8 +161,8 @@ public: void clear(); /// static bool isCompatibleCommand(InsetCode code, std::string const & s); - /// - ParamInfo const & info() const { return info_; }; + /// + ParamInfo const & info() const { return info_; } /// docstring prepareCommand(OutputParams const & runparams, docstring const & command, ParamInfo::ParamHandling handling) const;