+ InsetListingsParams lstparams(opt);
+ string parameters = lstparams.params();
+ string language;
+ string caption;
+ string label;
+ string placement;
+ bool isfloat = lstparams.isFloat();
+ if (use_minted) {
+ // Get float placement, language, caption, and
+ // label, then remove the relative options.
+ vector<string> opts =
+ getVectorFromString(parameters, ",", false);
+ for (size_t i = 0; i < opts.size(); ++i) {
+ if (prefixIs(opts[i], "float")) {
+ if (prefixIs(opts[i], "float="))
+ placement = opts[i].substr(6);
+ opts.erase(opts.begin() + i--);
+ } else if (prefixIs(opts[i], "language=")) {
+ language = opts[i].substr(9);
+ opts.erase(opts.begin() + i--);
+ } else if (prefixIs(opts[i], "caption=")) {
+ caption = opts[i].substr(8);
+ opts.erase(opts.begin() + i--);
+ } else if (prefixIs(opts[i], "label=")) {
+ label = opts[i].substr(6);
+ opts.erase(opts.begin() + i--);
+ }
+ }
+ if (!label.empty()) {
+ if (isfloat || !caption.empty())
+ label = trim(label, "{}");
+ else
+ opts.push_back("label=" + label);
+ }
+ parameters = getStringFromVector(opts, ",");
+ }
+ if (language.empty())
+ language = "TeX";
+ if (use_minted && isfloat) {
+ os << breakln << "\\begin{listing}";
+ if (!placement.empty())
+ os << '[' << placement << "]";
+ os << breakln;
+ } else if (use_minted && !caption.empty()) {
+ os << breakln << "\\lyxmintcaption[t]{" << caption;
+ if (!label.empty())
+ os << "\\label{" << label << "}";
+ os << "}\n";
+ }
+ os << (use_minted ? "\\inputminted" : "\\lstinputlisting");
+ if (!parameters.empty())
+ os << "[" << parameters << "]";
+ if (use_minted)
+ os << '{' << ascii_lowercase(language) << '}';
+ os << '{' << incfile << '}';
+ if (use_minted && isfloat) {
+ if (!caption.empty())
+ os << breakln << "\\caption{" << caption << "}";
+ if (!label.empty())
+ os << breakln << "\\label{" << label << "}";
+ os << breakln << "\\end{listing}\n";
+ }