Introduce doc preference for line numbering.

https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg208781.html
This commit is contained in:
Pavel Sanda 2019-05-23 15:13:27 +02:00
parent e3707f1331
commit 7f125f62d2
8 changed files with 90 additions and 3 deletions

View File

@ -7,6 +7,9 @@ changes happened in particular if possible. A good example would be
----------------------- -----------------------
2019-05-21 Pavel Sanda <sanda@lyx.org>
* Format incremented to 575: add line numbering via lineno package
2019-04-16 Günter Milde <milde@lyx.org> 2019-04-16 Günter Milde <milde@lyx.org>
* Format incremented to 574: Ruby inset, fixes for Japanese. * Format incremented to 574: Ruby inset, fixes for Japanese.

View File

@ -1694,6 +1694,15 @@ def revert_utf8_japanese(document):
if lang == "japanese-cjk": if lang == "japanese-cjk":
document.set_parameter("inputencoding", "utf8-cjk") document.set_parameter("inputencoding", "utf8-cjk")
def revert_lineno(document):
" Remove lineno package use."
i = find_token(document.header, "\\use_lineno", 0)
if i != -1:
del document.header[i]
i = find_token(document.header, "\\lineno_options", 0)
if i != -1:
del document.header[i]
## ##
# Conversion hub # Conversion hub
@ -1731,9 +1740,11 @@ convert = [
[572, [convert_notoFonts]], # Added options thin, light, extralight for Noto [572, [convert_notoFonts]], # Added options thin, light, extralight for Noto
[573, [convert_inputencoding_namechange]], [573, [convert_inputencoding_namechange]],
[574, [convert_ruby_module, convert_utf8_japanese]], [574, [convert_ruby_module, convert_utf8_japanese]],
[575, []],
] ]
revert = [[573, [revert_ruby_module, revert_utf8_japanese]], revert = [[574, [revert_lineno]],
[573, [revert_ruby_module, revert_utf8_japanese]],
[572, [revert_inputencoding_namechange]], [572, [revert_inputencoding_namechange]],
[571, [revert_notoFonts]], [571, [revert_notoFonts]],
[570, [revert_cmidruletrimming]], [570, [revert_cmidruletrimming]],

View File

@ -475,6 +475,7 @@ BufferParams::BufferParams()
output_sync = false; output_sync = false;
use_refstyle = true; use_refstyle = true;
use_minted = false; use_minted = false;
use_lineno = false;
// map current author // map current author
author_map_[pimpl_->authorlist.get(0).bufferId()] = 0; author_map_[pimpl_->authorlist.get(0).bufferId()] = 0;
@ -1118,6 +1119,11 @@ string BufferParams::readToken(Lexer & lex, string const & token,
lex >> use_refstyle; lex >> use_refstyle;
} else if (token == "\\use_minted") { } else if (token == "\\use_minted") {
lex >> use_minted; lex >> use_minted;
} else if (token == "\\use_lineno") {
lex >> use_lineno;
} else if (token == "\\lineno_options") {
lex.eatLine();
lineno_opts = trim(lex.getString());
} else { } else {
lyxerr << "BufferParams::readToken(): Unknown token: " << lyxerr << "BufferParams::readToken(): Unknown token: " <<
token << endl; token << endl;
@ -1321,6 +1327,12 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
<< "\n\\use_refstyle " << use_refstyle << "\n\\use_refstyle " << use_refstyle
<< "\n\\use_minted " << use_minted << "\n\\use_minted " << use_minted
<< '\n'; << '\n';
if (use_lineno)
os << "\\use_lineno " << use_lineno << '\n';
if (!lineno_opts.empty())
os << "\\lineno_options " << lineno_opts << '\n';
if (isbackgroundcolor == true) if (isbackgroundcolor == true)
os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n'; os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
if (isfontcolor == true) if (isfontcolor == true)
@ -2132,6 +2144,14 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
// hyperref loads this automatically // hyperref loads this automatically
os << "\\usepackage{nameref}\n"; os << "\\usepackage{nameref}\n";
if (use_lineno){
os << "\\usepackage";
if (!lineno_opts.empty())
os << "[" << lineno_opts << "]";
os << "{lineno}\n";
os << "\\linenumbers\n";
}
// bibtopic needs to be loaded after hyperref. // bibtopic needs to be loaded after hyperref.
// the dot provides the aux file naming which LyX can detect. // the dot provides the aux file naming which LyX can detect.
if (features.mustProvide("bibtopic")) if (features.mustProvide("bibtopic"))

View File

@ -550,6 +550,10 @@ public:
bool use_refstyle; bool use_refstyle;
/// use minted? or listings? /// use minted? or listings?
bool use_minted; bool use_minted;
//output line numbering
bool use_lineno;
//optional params for lineno package
std::string lineno_opts;
/// Return true if language could be set to lang, /// Return true if language could be set to lang,
/// otherwise return false and do not change language /// otherwise return false and do not change language

View File

@ -1253,6 +1253,11 @@ GuiDocument::GuiDocument(GuiView & lv)
numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered")); numberingModule->tocTW->headerItem()->setText(1, qt_("Numbered"));
numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC")); numberingModule->tocTW->headerItem()->setText(2, qt_("Appears in TOC"));
setSectionResizeMode(numberingModule->tocTW->header(), QHeaderView::ResizeToContents); setSectionResizeMode(numberingModule->tocTW->header(), QHeaderView::ResizeToContents);
connect(numberingModule->linenoGB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
connect(numberingModule->linenoLE, SIGNAL(textChanged(QString)),
this, SLOT(change_adaptor()));
// biblio // biblio
biblioModule = new UiWidget<Ui::BiblioUi>(this); biblioModule = new UiWidget<Ui::BiblioUi>(this);
@ -3282,6 +3287,8 @@ void GuiDocument::applyView()
bp_.tocdepth = numberingModule->tocSL->value(); bp_.tocdepth = numberingModule->tocSL->value();
bp_.secnumdepth = numberingModule->depthSL->value(); bp_.secnumdepth = numberingModule->depthSL->value();
} }
bp_.use_lineno = numberingModule->linenoGB->isChecked();
bp_.lineno_opts = fromqstr(numberingModule->linenoLE->text());
// bullets // bullets
bp_.user_defined_bullet(0) = bulletsModule->bullet(0); bp_.user_defined_bullet(0) = bulletsModule->bullet(0);
@ -3806,6 +3813,9 @@ void GuiDocument::paramsToDialog()
numberingModule->tocTW->clear(); numberingModule->tocTW->clear();
} }
numberingModule->linenoGB->setChecked(bp_.use_lineno);
numberingModule->linenoLE->setText(toqstr(bp_.lineno_opts));
// bullets // bullets
bulletsModule->setBullet(0, bp_.user_defined_bullet(0)); bulletsModule->setBullet(0, bp_.user_defined_bullet(0));
bulletsModule->setBullet(1, bp_.user_defined_bullet(1)); bulletsModule->setBullet(1, bp_.user_defined_bullet(1));

View File

@ -90,6 +90,44 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0">
<widget class="QGroupBox" name="linenoGB">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>L&amp;ines numbering</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Additional O&amp;ptions:</string>
</property>
<property name="buddy">
<cstring>linenoLE</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="linenoLE">
<property name="toolTip">
<string>lineno package options (e.g. right, modulo, switch, displaymath, mathlines,...)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>

View File

@ -34,6 +34,7 @@ Format LaTeX feature LyX feature
443 unicode-math.sty InsetMath* 443 unicode-math.sty InsetMath*
453 automatic stmaryrd loading \use_package stmaryrd 453 automatic stmaryrd loading \use_package stmaryrd
457 automatic stackrel loading \use_package stackrel 457 automatic stackrel loading \use_package stackrel
575 numbering of lines (lineno) \use_lineno, \lineno_options

View File

@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in // Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own. // independent branches. Instead add your own.
#define LYX_FORMAT_LYX 574 // gm: Japanese fixes #define LYX_FORMAT_LYX 575 // ps: lineno
#define LYX_FORMAT_TEX2LYX 574 #define LYX_FORMAT_TEX2LYX 575
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER #ifndef _MSC_VER