X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetListings.cpp;h=d3deadb6242df1fc3a51a4cf5b6cef0c2fe46098;hb=2c357c1d23b7b83839a9beb8225d4f1ae4f793b4;hp=e9007fa14df732d1c878077975fea60dd7842d98;hpb=6725b2db59fbc23f08962c187c5aac283fe9efbb;p=lyx.git diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index e9007fa14d..d3deadb624 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -21,55 +21,34 @@ #include "DispatchResult.h" #include "FuncRequest.h" #include "FuncStatus.h" -#include "gettext.h" +#include "support/gettext.h" #include "InsetList.h" #include "Language.h" #include "MetricsInfo.h" +#include "TextClass.h" +#include "support/docstream.h" #include "support/lstrings.h" #include -namespace lyx { +using namespace std; +using namespace lyx::support; -using support::token; -using support::contains; -using support::subst; +namespace lyx { -using std::istringstream; -using std::ostream; -using std::ostringstream; -using std::string; char const lstinline_delimiters[] = "!*()-=+|;:'\"`,<.>/?QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm"; -void InsetListings::init() -{ - setButtonLabel(); - Font font(Font::ALL_SANE); - font.decSize(); - font.decSize(); - font.setColor(Color::none); - setLabelFont(font); - // FIXME: what to do with those? - //text_.current_font.setLanguage(latex_language); - //text_.real_current_font.setLanguage(latex_language); -} - - InsetListings::InsetListings(BufferParams const & bp, InsetListingsParams const & par) - : InsetERT(bp, par.status()) -{ - init(); -} + : InsetCollapsable(bp, par.status()) +{} InsetListings::InsetListings(InsetListings const & in) - : InsetERT(in), params_(in.params_) -{ - init(); -} + : InsetCollapsable(in), params_(in.params_) +{} Inset * InsetListings::clone() const @@ -139,7 +118,7 @@ void InsetListings::read(Buffer const & buf, Lexer & lex) break; } } - InsetERT::read(buf, lex); + InsetCollapsable::read(buf, lex); } @@ -219,8 +198,7 @@ int InsetListings::latex(Buffer const & buf, odocstream & os, os << from_utf8(param_string) << "]\n"; } lines += 4; - os << code - << "\n\\end{lstlisting}\n\\endgroup\n"; + os << code << "\n\\end{lstlisting}\n\\endgroup\n"; lines += 3; } @@ -244,11 +222,11 @@ void InsetListings::doDispatch(Cursor & cur, FuncRequest & cmd) InsetListingsMailer(*this).showDialog(&cur.bv()); break; } - InsetERT::doDispatch(cur, cmd); + InsetCollapsable::doDispatch(cur, cmd); break; } default: - InsetERT::doDispatch(cur, cmd); + InsetCollapsable::doDispatch(cur, cmd); break; } } @@ -265,7 +243,7 @@ bool InsetListings::getStatus(Cursor & cur, FuncRequest const & cmd, status.enabled(!params().isInline()); return true; default: - return InsetERT::getStatus(cur, cmd, status); + return InsetCollapsable::getStatus(cur, cmd, status); } } @@ -273,34 +251,17 @@ bool InsetListings::getStatus(Cursor & cur, FuncRequest const & cmd, void InsetListings::setButtonLabel() { // FIXME UNICODE - setLabel(isOpen() ? _("Listing") : getNewLabel(_("Listing"))); -} - - -void InsetListings::metrics(MetricsInfo & mi, Dimension & dim) const -{ - Font tmpfont = mi.base.font; - getDrawFont(mi.base.font); - mi.base.font.realize(tmpfont); - InsetCollapsable::metrics(mi, dim); - mi.base.font = tmpfont; -} - - -void InsetListings::draw(PainterInfo & pi, int x, int y) const -{ - Font tmpfont = pi.base.font; - getDrawFont(pi.base.font); - pi.base.font.realize(tmpfont); - InsetCollapsable::draw(pi, x, y); - pi.base.font = tmpfont; + if (decoration() == Deco_Classic) + setLabel(isOpen() ? _("Listing") : getNewLabel(_("Listing"))); + else + setLabel(getNewLabel(_("Listing"))); } void InsetListings::validate(LaTeXFeatures & features) const { features.require("listings"); - InsetERT::validate(features); + InsetCollapsable::validate(features); } @@ -311,17 +272,8 @@ bool InsetListings::showInsetDialog(BufferView * bv) const } -void InsetListings::getDrawFont(Font & font) const -{ - font = Font(Font::ALL_INHERIT, latex_language); - font.setFamily(Font::TYPEWRITER_FAMILY); - // FIXME: define Color::listing? - font.setColor(Color::foreground); -} - - docstring InsetListings::getCaption(Buffer const & buf, - OutputParams const & runparams) const + OutputParams const & runparams) const { if (paragraphs().empty()) return docstring();