]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCommandParams.h
Handle the case of TeX fonts LuaTeX
[lyx.git] / src / insets / InsetCommandParams.h
index 7e343773c2caa6aecc7e11efe50249bd9879c806..4107378487d0f8195454ea34860d3497888dc06c 100644 (file)
@@ -16,6 +16,8 @@
 
 #include "InsetCode.h"
 
+#include "OutputParams.h"
+
 #include "support/docstring.h"
 
 #include <string>
 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);
                ///
                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;
                ///
@@ -58,10 +71,13 @@ public:
                std::string name_;
                ///
                ParamType type_;
+               /// do we need special handling on latex output?
+               ParamHandling handling_;
        };
 
        /// adds a new parameter
-       void add(std::string const & name, ParamType type);
+       void add(std::string const & name, ParamType type,
+                ParamHandling = HANDLING_NONE);
        ///
        bool empty() const { return info_.empty(); }
        ///
@@ -97,13 +113,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 +133,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 +146,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