mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
Use a combo box instead of a check box for selecting the listings package
This commit is contained in:
parent
95c6781112
commit
ae56167718
@ -1203,6 +1203,8 @@ def checkOtherEntries():
|
||||
'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
|
||||
@ -1756,7 +1758,7 @@ if __name__ == '__main__':
|
||||
lyx_check_config = True
|
||||
lyx_kpsewhich = True
|
||||
outfile = 'lyxrc.defaults'
|
||||
lyxrc_fileformat = 21
|
||||
lyxrc_fileformat = 22
|
||||
rc_entries = ''
|
||||
lyx_keep_temps = False
|
||||
version_suffix = ''
|
||||
|
@ -40897,17 +40897,10 @@ s
|
||||
\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
|
||||
|
@ -90,6 +90,10 @@
|
||||
# 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.
|
||||
|
||||
@ -387,5 +391,6 @@ conversions = [
|
||||
[ 18, []],
|
||||
[ 19, [remove_print_support]],
|
||||
[ 20, []],
|
||||
[ 21, []]
|
||||
[ 21, []],
|
||||
[ 22, []]
|
||||
]
|
||||
|
@ -59,7 +59,7 @@ namespace {
|
||||
|
||||
// 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[] = {
|
||||
@ -158,6 +158,7 @@ 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 },
|
||||
@ -241,6 +242,7 @@ void LyXRC::setDefaults()
|
||||
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;
|
||||
@ -544,6 +546,12 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
|
||||
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();
|
||||
@ -1501,6 +1509,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
}
|
||||
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).
|
||||
@ -2809,6 +2824,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
||||
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:
|
||||
@ -3067,6 +3083,10 @@ string const LyXRC::getDescription(LyXRCTags tag)
|
||||
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;
|
||||
|
||||
|
@ -133,6 +133,7 @@ public:
|
||||
RC_PRINTLANDSCAPEFLAG,
|
||||
RC_PRINTPAPERDIMENSIONFLAG,
|
||||
RC_PRINTPAPERFLAG,
|
||||
RC_PYGMENTIZE_COMMAND,
|
||||
RC_SAVE_COMPRESSED,
|
||||
RC_SAVE_ORIGIN,
|
||||
RC_SCREEN_DPI,
|
||||
@ -253,6 +254,8 @@ public:
|
||||
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;
|
||||
///
|
||||
|
@ -135,6 +135,12 @@ char const * backref_opts_gui[] =
|
||||
};
|
||||
|
||||
|
||||
char const * lst_packages[] =
|
||||
{
|
||||
"Listings", "Minted", ""
|
||||
};
|
||||
|
||||
|
||||
vector<string> engine_types_;
|
||||
vector<pair<string, QString> > pagestyles;
|
||||
|
||||
@ -1461,13 +1467,18 @@ GuiDocument::GuiDocument(GuiView & lv)
|
||||
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"));
|
||||
@ -1550,9 +1561,11 @@ QString GuiDocument::validateListingsParameters()
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
@ -1578,6 +1591,22 @@ void GuiDocument::setListingsMessage()
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@ -3074,7 +3103,8 @@ void GuiDocument::applyView()
|
||||
|
||||
// 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();
|
||||
|
||||
@ -3592,7 +3622,9 @@ void GuiDocument::paramsToDialog()
|
||||
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
|
||||
@ -3676,7 +3708,7 @@ void GuiDocument::paramsToDialog()
|
||||
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);
|
||||
|
||||
|
@ -92,6 +92,7 @@ private Q_SLOTS:
|
||||
void change_adaptor();
|
||||
void includeonlyClicked(QTreeWidgetItem * item, int);
|
||||
void setListingsMessage();
|
||||
void listingsPackageChanged(int);
|
||||
void saveDefaultClicked();
|
||||
void useDefaultsClicked();
|
||||
void setLSpacing(int);
|
||||
|
@ -5,8 +5,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>219</width>
|
||||
<height>256</height>
|
||||
<width>281</width>
|
||||
<height>282</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -73,16 +73,6 @@
|
||||
</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">
|
||||
@ -93,6 +83,41 @@
|
||||
</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>
|
||||
|
Loading…
Reference in New Issue
Block a user