'splitindex.class'], rc_entry = [ r'\splitindex_command "%%"' ])
checkProg('a nomenclature processor', ['makeindex'],
rc_entry = [ r'\nomencl_command "makeindex -s nomencl.ist"' ])
+ checkProg('a python-pygments driver command', ['pygmentize'],
+ rc_entry = [ r'\pygmentize_command "%%"' ])
## FIXME: OCTAVE is not used anywhere
# path, OCTAVE = checkProg('Octave', ['octave'])
## FIXME: MAPLE is not used anywhere
lyx_check_config = True
lyx_kpsewhich = True
outfile = 'lyxrc.defaults'
- lyxrc_fileformat = 21
+ lyxrc_fileformat = 22
rc_entries = ''
lyx_keep_temps = False
version_suffix = ''
\change_unchanged
a powerful and flexible way to insert program source code into your document.
-\change_inserted 5863344 1497178383
+\change_inserted 5863344 1497280755
You can use either one in a document, but listings is used by default.
- In order to use minted, you need to check the box
-\begin_inset Quotes eld
-\end_inset
-
-Use minted
-\begin_inset Quotes erd
-\end_inset
-
- in Document\SpecialChar menuseparator
+ In order to use minted, you need to select it as the syntax highlighting
+ package in Document\SpecialChar menuseparator
Settings\SpecialChar menuseparator
Listings.
However, note that minted requires additional software (the pygments python
# default now)
# No conversion necessary.
+# Incremented to format 22, by ef
+# Add pygmentize_command for the python pygments syntax highlighter
+# No conversion necessary.
+
# NOTE: The format should also be updated in LYXRC.cpp and
# in configure.py.
[ 18, []],
[ 19, [remove_print_support]],
[ 20, []],
- [ 21, []]
+ [ 21, []],
+ [ 22, []]
]
// The format should also be updated in configure.py, and conversion code
// should be added to prefs2prefs_prefs.py.
-static unsigned int const LYXRC_FILEFORMAT = 21; // spitz: jbibtex_alternatives
+static unsigned int const LYXRC_FILEFORMAT = 22; // ef: pygmentize_command
// when adding something to this array keep it sorted!
LexerKeyword lyxrcTags[] = {
{ "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
{ "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
{ "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
+ { "\\pygmentize_command", LyXRC::RC_PYGMENTIZE_COMMAND },
{ "\\save_compressed", LyXRC::RC_SAVE_COMPRESSED },
{ "\\save_origin", LyXRC::RC_SAVE_ORIGIN },
{ "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
fontenc = "default";
index_command = "makeindex -c -q";
nomencl_command = "makeindex -s nomencl.ist";
+ pygmentize_command = string();
dpi = 75;
// Because a screen is typically wider than a piece of paper:
zoom = 150;
lexrc >> print_paper_flag;
break;
+ case RC_PYGMENTIZE_COMMAND:
+ if (lexrc.next(true)) {
+ pygmentize_command = lexrc.getString();
+ }
+ break;
+
case RC_VIEWDVI_PAPEROPTION:
if (lexrc.next())
view_dvi_paper_option = lexrc.getString();
}
if (tag != RC_LAST)
break;
+ case RC_PYGMENTIZE_COMMAND:
+ if (ignore_system_lyxrc ||
+ pygmentize_command != system_lyxrc.pygmentize_command) {
+ os << "\\pygmentize_command \"" << escapeCommand(pygmentize_command) << "\"\n";
+ }
+ if (tag != RC_LAST)
+ break;
case RC_TEX_EXPECTS_WINDOWS_PATHS:
// Don't write this setting to the preferences file,
// but allow temporary changes (bug 7557).
case LyXRC::RC_JBIBTEX_ALTERNATIVES:
case LyXRC::RC_JINDEX_COMMAND:
case LyXRC::RC_NOMENCL_COMMAND:
+ case LyXRC::RC_PYGMENTIZE_COMMAND:
case LyXRC::RC_INPUT:
case LyXRC::RC_KBMAP:
case LyXRC::RC_KBMAP_PRIMARY:
str = _("Define the options of makeindex (cf. man makeindex) to be used for nomenclatures. This might differ from the index processing options.");
break;
+ case RC_PYGMENTIZE_COMMAND:
+ str = _("The command to run the python pygments syntax highlighter.");
+ break;
+
case RC_INPUT:
break;
RC_PRINTLANDSCAPEFLAG,
RC_PRINTPAPERDIMENSIONFLAG,
RC_PRINTPAPERFLAG,
+ RC_PYGMENTIZE_COMMAND,
RC_SAVE_COMPRESSED,
RC_SAVE_ORIGIN,
RC_SCREEN_DPI,
std::string splitindex_command;
/// command to run makeindex incl. options for nomencl
std::string nomencl_command;
+ /// command to run the python pygments syntax highlighter
+ std::string pygmentize_command;
///
std::string document_path;
///
};
+char const * lst_packages[] =
+{
+ "Listings", "Minted", ""
+};
+
+
vector<string> engine_types_;
vector<pair<string, QString> > pagestyles;
this, SLOT(change_adaptor()));
connect(listingsModule->bypassCB, SIGNAL(clicked()),
this, SLOT(setListingsMessage()));
- connect(listingsModule->mintedCB, SIGNAL(clicked()),
+ connect(listingsModule->packageCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
+ connect(listingsModule->packageCO, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(listingsPackageChanged(int)));
connect(listingsModule->listingsED, SIGNAL(textChanged()),
this, SLOT(setListingsMessage()));
listingsModule->listingsTB->setPlainText(
qt_("Input listings parameters below. Enter ? for a list of parameters."));
+ for (int i = 0; lst_packages[i][0]; ++i)
+ listingsModule->packageCO->addItem(lst_packages[i]);
+
// add the panels
docPS->addPanel(latexModule, N_("Document Class"));
{
if (listingsModule->bypassCB->isChecked())
return QString();
+ string const package =
+ lst_packages[listingsModule->packageCO->currentIndex()];
string params = fromqstr(listingsModule->listingsED->toPlainText());
InsetListingsParams lstparams(params);
- lstparams.setMinted(listingsModule->mintedCB->isChecked());
+ lstparams.setMinted(package == "Minted");
return toqstr(lstparams.validate());
}
}
+void GuiDocument::listingsPackageChanged(int index)
+{
+ string const package = lst_packages[index];
+ if (package == "Minted" && lyxrc.pygmentize_command.empty()) {
+ Alert::warning(_("Pygments driver command not found!"),
+ _("The driver command necessary to use the minted package\n"
+ "(pygmentize) has not been found. Make sure you have\n"
+ "the python-pygments module installed or, if the driver\n"
+ "is named differently, to add the following line to the\n"
+ "document preamble:\n\n"
+ "\\AtBeginDocument{\\renewcommand{\\MintedPygmentize}{driver}}\n\n"
+ "where 'driver' is name of the driver command."));
+ }
+}
+
+
void GuiDocument::setLSpacing(int item)
{
textLayoutModule->lspacingLE->setEnabled(item == 3);
// Listings
// text should have passed validation
- bp_.use_minted = listingsModule->mintedCB->isChecked();
+ idx = listingsModule->packageCO->currentIndex();
+ bp_.use_minted = string(lst_packages[idx]) == "Minted";
bp_.listings_params =
InsetListingsParams(fromqstr(listingsModule->listingsED->toPlainText())).params();
string lstparams =
InsetListingsParams(bp_.listings_params).separatedParams();
listingsModule->listingsED->setPlainText(toqstr(lstparams));
- listingsModule->mintedCB->setChecked(bp_.use_minted);
+ int nn = findToken(lst_packages, bp_.use_minted ? "Minted" : "Listings");
+ if (nn >= 0)
+ listingsModule->packageCO->setCurrentIndex(nn);
// Fonts
fontModule->scaleTypewriterSB->setValue(bp_.fontsTypewriterScale());
fontModule->font_tt_scale = bp_.fonts_typewriter_scale[!bp_.useNonTeXFonts];
- int nn = findToken(GuiDocument::fontfamilies, bp_.fonts_default_family);
+ nn = findToken(GuiDocument::fontfamilies, bp_.fonts_default_family);
if (nn >= 0)
fontModule->fontsDefaultCO->setCurrentIndex(nn);
void change_adaptor();
void includeonlyClicked(QTreeWidgetItem * item, int);
void setListingsMessage();
+ void listingsPackageChanged(int);
void saveDefaultClicked();
void useDefaultsClicked();
void setLSpacing(int);
<rect>
<x>0</x>
<y>0</y>
- <width>219</width>
- <height>256</height>
+ <width>281</width>
+ <height>282</height>
</rect>
</property>
<property name="windowTitle">
</property>
</widget>
</item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="mintedCB">
- <property name="toolTip">
- <string>Use the minted package instead of the listings one</string>
- </property>
- <property name="text">
- <string>Use &minted</string>
- </property>
- </widget>
- </item>
<item row="2" column="0">
<widget class="QCheckBox" name="bypassCB">
<property name="toolTip">
</property>
</widget>
</item>
+ <item row="3" column="0" rowspan="2">
+ <widget class="QGroupBox" name="packageGB">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="packageLBL">
+ <property name="toolTip">
+ <string>Choose the LaTeX package for code syntax highlighting</string>
+ </property>
+ <property name="text">
+ <string>&Syntax Highlighting Package:</string>
+ </property>
+ <property name="buddy">
+ <cstring>packageCO</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="packageCO"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
</layout>
</widget>
<includes>