Add default output format for pLaTeX

Fixes: #10747
This commit is contained in:
Juergen Spitzmueller 2017-09-09 08:53:08 +02:00
parent 177331a07f
commit 242f543e01
7 changed files with 141 additions and 46 deletions

View File

@ -70,6 +70,10 @@
* \pygmentize_command
holds the name of the driver command used by the Pygments python module.
* \default_platex_view_format
Determine the default output format for Japanese documents that use the
pLaTeX backend [default: "pdf3" == "PDF (dvipdfm)"]
!!!The following pref variables were changed in 2.3:
@ -79,6 +83,10 @@
!!!The following new LyX functions have been introduced in 2.3:
* buffer-zoom
Zooms the screen fonts to a given value or resets to the default zoom
when no argument is given.
* branch-invert
Toggles inversion status of branch inset.

View File

@ -94,6 +94,11 @@
# Add pygmentize_command for the python pygments syntax highlighter
# No conversion necessary.
# Incremented to format 23, by spitz
# Add default_platex_view_format, a default output format for
# Japanese documents via pLaTeX.
# No conversion necessary.
# NOTE: The format should also be updated in LYXRC.cpp and
# in configure.py.
@ -364,6 +369,18 @@ def remove_print_support(line):
# End conversions for LyX 2.1 to 2.2
####################################
#################################
# Conversions from LyX 2.2 to 2.3
# Only format changes that don't require conversion
# End conversions for LyX 2.2 to 2.3
####################################
############################################################
# Format-conversion map. Also add empty format changes here.
conversions = [
[ 1, [ # there were several conversions for format 1
export_menu,
@ -392,5 +409,6 @@ conversions = [
[ 19, [remove_print_support]],
[ 20, []],
[ 21, []],
[ 22, []]
[ 22, []],
[ 23, []]
]

View File

@ -2695,14 +2695,15 @@ string BufferParams::getDefaultOutputFormat() const
if (!default_output_format.empty()
&& default_output_format != "default")
return default_output_format;
if (isDocBook()
|| encoding().package() == Encoding::japanese) {
if (isDocBook()) {
FormatList const & formats = exportableFormats(true);
if (formats.empty())
return string();
// return the first we find
return formats.front()->name();
}
if (encoding().package() == Encoding::japanese)
return lyxrc.default_platex_view_format;
if (useNonTeXFonts)
return lyxrc.default_otf_view_format;
return lyxrc.default_view_format;

View File

@ -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 = 22; // ef: pygmentize_command
static unsigned int const LYXRC_FILEFORMAT = 23; // spitz: default_platex_view_format
// when adding something to this array keep it sorted!
LexerKeyword lyxrcTags[] = {
@ -98,6 +98,7 @@ LexerKeyword lyxrcTags[] = {
{ "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
{ "\\default_length_unit", LyXRC::RC_DEFAULT_LENGTH_UNIT },
{ "\\default_otf_view_format", LyXRC::RC_DEFAULT_OTF_VIEW_FORMAT },
{ "\\default_platex_view_format", LyXRC::RC_DEFAULT_PLATEX_VIEW_FORMAT },
{ "\\default_view_format", LyXRC::RC_DEFAULT_VIEW_FORMAT },
{ "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
{ "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
@ -237,6 +238,7 @@ void LyXRC::setDefaults()
view_dvi_paper_option.erase();
default_view_format = "pdf2";
default_otf_view_format = "pdf4";
default_platex_view_format = "pdf3";
chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
bibtex_command = "automatic";
fontenc = "default";
@ -1082,6 +1084,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
lexrc >> default_otf_view_format;
break;
case RC_DEFAULT_PLATEX_VIEW_FORMAT:
lexrc >> default_platex_view_format;
break;
case RC_DEFAULT_VIEW_FORMAT:
lexrc >> default_view_format;
break;
@ -2786,6 +2792,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
if (tag != RC_LAST)
break;
// fall through
case RC_DEFAULT_PLATEX_VIEW_FORMAT:
if ((ignore_system_lyxrc ||
default_platex_view_format != system_lyxrc.default_platex_view_format)
&& !default_platex_view_format.empty()) {
os << "\\default_platex_view_format " << default_platex_view_format << '\n';
}
if (tag != RC_LAST)
break;
// fall through
case RC_DEFAULT_VIEW_FORMAT:
if (ignore_system_lyxrc ||
default_view_format != system_lyxrc.default_view_format) {
@ -2912,6 +2927,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
case LyXRC::RC_DATE_INSERT_FORMAT:
case LyXRC::RC_GUI_LANGUAGE:
case LyXRC::RC_DEFAULT_OTF_VIEW_FORMAT:
case LyXRC::RC_DEFAULT_PLATEX_VIEW_FORMAT:
case LyXRC::RC_DEFAULT_VIEW_FORMAT:
case LyXRC::RC_DEFFILE:
case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:

View File

@ -70,6 +70,7 @@ public:
RC_DEFAULT_DECIMAL_POINT,
RC_DEFAULT_LENGTH_UNIT,
RC_DEFAULT_OTF_VIEW_FORMAT,
RC_DEFAULT_PLATEX_VIEW_FORMAT,
RC_DEFAULT_VIEW_FORMAT,
RC_DEFFILE,
RC_DIALOGS_ICONIFY_WITH_MAIN,
@ -392,6 +393,8 @@ public:
///
std::string default_otf_view_format;
///
std::string default_platex_view_format;
///
std::string default_view_format;
/// all available viewers
Alternatives viewer_alternatives;

View File

@ -2033,6 +2033,8 @@ PrefFileformats::PrefFileformats(GuiPreferences * form)
this, SIGNAL(changed()));
connect(defaultOTFFormatCB, SIGNAL(activated(QString)),
this, SIGNAL(changed()));
connect(defaultPlatexFormatCB, SIGNAL(activated(QString)),
this, SIGNAL(changed()));
connect(viewerCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
connect(editorCO, SIGNAL(activated(int)),
@ -2063,6 +2065,9 @@ void PrefFileformats::applyRC(LyXRC & rc) const
QString const default_otf_format = defaultOTFFormatCB->itemData(
defaultOTFFormatCB->currentIndex()).toString();
rc.default_otf_view_format = fromqstr(default_otf_format);
QString const default_platex_format = defaultPlatexFormatCB->itemData(
defaultPlatexFormatCB->currentIndex()).toString();
rc.default_platex_view_format = fromqstr(default_platex_format);
}
@ -2079,6 +2084,9 @@ void PrefFileformats::updateRC(LyXRC const & rc)
pos = defaultOTFFormatCB->findData(toqstr(rc.default_otf_view_format));
defaultOTFFormatCB->setCurrentIndex(pos);
defaultOTFFormatCB->setCurrentIndex(pos);
pos = defaultPlatexFormatCB->findData(toqstr(rc.default_platex_view_format));
defaultPlatexFormatCB->setCurrentIndex(pos);
defaultPlatexFormatCB->setCurrentIndex(pos);
}
}
@ -2088,14 +2096,17 @@ void PrefFileformats::updateView()
QString const current = formatsCB->currentText();
QString const current_def = defaultFormatCB->currentText();
QString const current_def_otf = defaultOTFFormatCB->currentText();
QString const current_def_platex = defaultPlatexFormatCB->currentText();
// update comboboxes with formats
formatsCB->blockSignals(true);
defaultFormatCB->blockSignals(true);
defaultOTFFormatCB->blockSignals(true);
defaultPlatexFormatCB->blockSignals(true);
formatsCB->clear();
defaultFormatCB->clear();
defaultOTFFormatCB->clear();
defaultPlatexFormatCB->clear();
form_->formats().sort();
for (Format const & f : form_->formats()) {
QString const prettyname = toqstr(translateIfPossible(f.prettyname()));
@ -2111,10 +2122,15 @@ void PrefFileformats::updateView()
QVariant(toqstr(f.name())));
defaultOTFFormatCB->addItem(prettyname,
QVariant(toqstr(f.name())));
} else if (form_->converters().isReachable("latex", f.name())
|| form_->converters().isReachable("pdflatex", f.name()))
defaultFormatCB->addItem(prettyname,
} else {
if (form_->converters().isReachable("latex", f.name())
|| form_->converters().isReachable("pdflatex", f.name()))
defaultFormatCB->addItem(prettyname,
QVariant(toqstr(f.name())));
if (form_->converters().isReachable("platex", f.name()))
defaultPlatexFormatCB->addItem(prettyname,
QVariant(toqstr(f.name())));
}
}
// restore selections
@ -2125,9 +2141,12 @@ void PrefFileformats::updateView()
defaultFormatCB->setCurrentIndex(item < 0 ? 0 : item);
item = defaultOTFFormatCB->findText(current_def_otf, Qt::MatchExactly);
defaultOTFFormatCB->setCurrentIndex(item < 0 ? 0 : item);
item = defaultPlatexFormatCB->findText(current_def_platex, Qt::MatchExactly);
defaultPlatexFormatCB->setCurrentIndex(item < 0 ? 0 : item);
formatsCB->blockSignals(false);
defaultFormatCB->blockSignals(false);
defaultOTFFormatCB->blockSignals(false);
defaultPlatexFormatCB->blockSignals(false);
}

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>386</width>
<height>417</height>
<width>496</width>
<height>584</height>
</rect>
</property>
<property name="windowTitle">
@ -199,7 +199,7 @@
<item row="11" column="0" colspan="5">
<widget class="QGroupBox" name="defaultFormatGB">
<property name="toolTip">
<string>Specify the default output format when using (PDF)LaTeX</string>
<string>Specification of the default output formats when using specific LaTeX variants</string>
</property>
<property name="title">
<string>Default Output Formats</string>
@ -208,23 +208,6 @@
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="defaultFormatLA">
<property name="text">
<string>With &amp;TeX fonts:</string>
</property>
<property name="buddy">
<cstring>defaultFormatCB</cstring>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="defaultFormatCB">
<property name="toolTip">
<string>The default output format for documents (except with non-TeX fonts)</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
@ -238,24 +221,7 @@
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="defaultOTFFormatLA">
<property name="text">
<string>With n&amp;on-TeX fonts:</string>
</property>
<property name="buddy">
<cstring>defaultFormatCB</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="defaultOTFFormatCB">
<property name="toolTip">
<string>The default output format for documents using non-TeX fonts</string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<item row="2" column="3">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -268,10 +234,74 @@
</property>
</spacer>
</item>
<item row="2" column="1" colspan="2">
<widget class="QComboBox" name="defaultOTFFormatCB">
<property name="toolTip">
<string>The default output format for documents using non-TeX fonts</string>
</property>
</widget>
</item>
<item row="0" column="6">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>148</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="defaultFormatCB">
<property name="toolTip">
<string>This is the default output format for LyX documents, except for DocBook classes, documents that use non-TeX fonts and Japanese documents</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QComboBox" name="defaultPlatexFormatCB">
<property name="toolTip">
<string>The default output format for Japanese documents (using pLaTeX)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="defaultOTFFormatLA">
<property name="text">
<string>With n&amp;on-TeX fonts:</string>
</property>
<property name="buddy">
<cstring>defaultFormatCB</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="defaultFormatLA">
<property name="text">
<string>With &amp;TeX fonts:</string>
</property>
<property name="buddy">
<cstring>defaultFormatCB</cstring>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="defaultPLatexFormatLA">
<property name="text">
<string>&amp;Japanese:</string>
</property>
<property name="buddy">
<cstring>defaultPlatexFormatCB</cstring>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="12" column="1" colspan="2">
<item row="12" column="1" colspan="3">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>