}
+docstring InsetListings::layoutName() const
+{
+ if (buffer().params().use_minted)
+ return from_ascii("MintedListings");
+ else
+ return from_ascii("Listings");
+}
+
+
void InsetListings::write(ostream & os) const
{
os << "listings" << "\n";
encoding_switched = true;
}
+ bool const captionfirst = !isfloat && par->isInset(0)
+ && par->getInset(0)->lyxCode() == CAPTION_CODE;
+
while (par != end) {
pos_type siz = par->size();
bool captionline = false;
}
os << delim << code << delim;
} else if (use_minted) {
+ OutputParams rp = runparams;
+ rp.moving_arg = true;
+ TexString caption = getCaption(rp);
if (isfloat) {
os << breakln << "\\begin{listing}";
if (!float_placement.empty())
os << '[' << float_placement << "]";
+ } else if (captionfirst && !caption.str.empty()) {
+ os << breakln << "\\lyxmintcaption[t]{"
+ << move(caption) << "}\n";
}
os << breakln << "\\begin{minted}";
if (!param_string.empty())
os << "{" << minted_language << "}\n"
<< code << breakln << "\\end{minted}\n";
if (isfloat) {
- OutputParams rp = runparams;
- rp.moving_arg = true;
- TexString caption = getCaption(rp);
if (!caption.str.empty())
os << "\\caption{" << move(caption) << "}\n";
os << "\\end{listing}\n";
+ } else if (!captionfirst && !caption.str.empty()) {
+ os << breakln << "\\lyxmintcaption[b]{"
+ << move(caption) << "}";
}
} else {
OutputParams rp = runparams;
void InsetListings::validate(LaTeXFeatures & features) const
{
- if (buffer().params().use_minted)
- features.require("minted");
- else
- features.require("listings");
features.useInsetLayout(getLayout());
string param_string = params().params();
- if (param_string.find("\\color") != string::npos)
- features.require("color");
+ if (buffer().params().use_minted) {
+ features.require("minted");
+ OutputParams rp = features.runparams();
+ if (!params().isFloat() && !getCaption(rp).str.empty())
+ features.require("lyxmintcaption");
+ } else {
+ features.require("listings");
+ if (contains(param_string, "\\color"))
+ features.require("color");
+ }
InsetCaptionable::validate(features);
}