X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetListings.h;h=d75f96851e95c0aeda8d021f600388fc3c9c3644;hb=b198a36a363bb6a084407d476942d68ef5fb5e86;hp=3e5fbd54e21b3e7b3503129414575f20378ffa51;hpb=1c830e744f3f844f84df8150bac2539446c5769d;p=lyx.git diff --git a/src/insets/InsetListings.h b/src/insets/InsetListings.h index 3e5fbd54e2..d75f96851e 100644 --- a/src/insets/InsetListings.h +++ b/src/insets/InsetListings.h @@ -9,93 +9,87 @@ * Full author contact details are available in file CREDITS. */ -#ifndef INSETLISTINGS_H -#define INSETLISTINGS_H +#ifndef INSET_LISTINGS_H +#define INSET_LISTINGS_H -#include "LaTeXFeatures.h" -#include "InsetERT.h" #include "InsetListingsParams.h" -#include "MailInset.h" namespace lyx { -/** A collapsable text inset for program listings. - */ +class LaTeXFeatures; +struct TexString; +///////////////////////////////////////////////////////////////////////// +// +// InsetListings +// +///////////////////////////////////////////////////////////////////////// -class InsetListings : public InsetCollapsable { +/// A captionable and collapsible text inset for program listings. +class InsetListings : public InsetCaptionable +{ public: /// - InsetListings(BufferParams const &, InsetListingsParams const & par = InsetListingsParams()); + InsetListings(Buffer *, InsetListingsParams const & par = InsetListingsParams()); /// ~InsetListings(); /// - InsetCode lyxCode() const { return LISTINGS_CODE; } - /// lstinline is inlined, normal listing is displayed - virtual DisplayType display() const; + static void string2params(std::string const &, InsetListingsParams &); /// - docstring name() const { return from_ascii("Listings"); } - // Update the counters of this inset and of its contents - virtual void updateLabels(Buffer const &, ParIterator const &); + static std::string params2string(InsetListingsParams const &); /// - void write(Buffer const & buf, std::ostream & os) const; + bool isEnvironment() const override { return !params().isInline(); } +private: /// - void read(Buffer const & buf, Lexer & lex); + bool isLabeled() const override { return true; } + /// false is needed since listings do their own font handling. + bool inheritFont() const override { return false; } /// - virtual docstring const editMessage() const; + InsetCode lyxCode() const override { return LISTINGS_CODE; } + /// lstinline is inlined, normal listing is displayed + int rowFlags() const override; /// - bool isMacroScope(Buffer const &) const { return true; } + docstring layoutName() const override; /// - int latex(Buffer const &, odocstream &, OutputParams const &) const; + void write(std::ostream & os) const override; /// - void validate(LaTeXFeatures &) const; + void read(Lexer & lex) override; /// - bool showInsetDialog(BufferView *) const; + void latex(otexstream &, OutputParams const &) const override; /// - InsetListingsParams const & params() const { return params_; } + docstring xhtml(XMLStream &, OutputParams const &) const override; /// - InsetListingsParams & params() { return params_; } -protected: - InsetListings(InsetListings const &); + void docbook(XMLStream &, OutputParams const &) const override; /// - virtual void doDispatch(Cursor & cur, FuncRequest & cmd); + void validate(LaTeXFeatures &) const override; /// - bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const; -private: - virtual Inset * clone() const; + bool showInsetDialog(BufferView *) const override; /// - void setButtonLabel(); + InsetListingsParams const & params() const { return params_; } /// - docstring getCaption(Buffer const &, OutputParams const &) const; + InsetListingsParams & params() { return params_; } /// - InsetListingsParams params_; -}; - - -class InsetListingsMailer : public MailInset { -public: + std::string contextMenuName() const override; /// - InsetListingsMailer(InsetListings & inset); + void doDispatch(Cursor & cur, FuncRequest & cmd) override; /// - virtual Inset & inset() const { return inset_; } + bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const override; /// - virtual std::string const & name() const { return name_; } + Inset * clone() const override { return new InsetListings(*this); } /// - virtual std::string const inset2string(Buffer const &) const; + docstring const buttonLabel(BufferView const & bv) const override; /// - static void string2params(std::string const &, - InsetListingsParams &); + TexString getCaption(OutputParams const &) const; /// - static std::string const params2string(InsetListingsParams const &); -private: + bool insetAllowed(InsetCode c) const override { return c == CAPTION_CODE || c == QUOTE_CODE; } /// - static std::string const name_; + Encoding const * forcedEncoding(Encoding const *, Encoding const *) const override; + /// - InsetListings & inset_; + InsetListingsParams params_; }; - } // namespace lyx -#endif +#endif // INSET_LISTINGS_H