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>
* Format incremented to 574: Ruby inset, fixes for Japanese.

View File

@ -1694,6 +1694,15 @@ def revert_utf8_japanese(document):
if lang == "japanese-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
@ -1731,9 +1740,11 @@ convert = [
[572, [convert_notoFonts]], # Added options thin, light, extralight for Noto
[573, [convert_inputencoding_namechange]],
[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]],
[571, [revert_notoFonts]],
[570, [revert_cmidruletrimming]],

View File

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

View File

@ -550,6 +550,10 @@ public:
bool use_refstyle;
/// use minted? or listings?
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,
/// 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(2, qt_("Appears in TOC"));
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
biblioModule = new UiWidget<Ui::BiblioUi>(this);
@ -3282,6 +3287,8 @@ void GuiDocument::applyView()
bp_.tocdepth = numberingModule->tocSL->value();
bp_.secnumdepth = numberingModule->depthSL->value();
}
bp_.use_lineno = numberingModule->linenoGB->isChecked();
bp_.lineno_opts = fromqstr(numberingModule->linenoLE->text());
// bullets
bp_.user_defined_bullet(0) = bulletsModule->bullet(0);
@ -3806,6 +3813,9 @@ void GuiDocument::paramsToDialog()
numberingModule->tocTW->clear();
}
numberingModule->linenoGB->setChecked(bp_.use_lineno);
numberingModule->linenoLE->setText(toqstr(bp_.lineno_opts));
// bullets
bulletsModule->setBullet(0, bp_.user_defined_bullet(0));
bulletsModule->setBullet(1, bp_.user_defined_bullet(1));

View File

@ -90,6 +90,44 @@
</property>
</widget>
</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>
</widget>
<tabstops>

View File

@ -34,6 +34,7 @@ Format LaTeX feature LyX feature
443 unicode-math.sty InsetMath*
453 automatic stmaryrd loading \use_package stmaryrd
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
// independent branches. Instead add your own.
#define LYX_FORMAT_LYX 574 // gm: Japanese fixes
#define LYX_FORMAT_TEX2LYX 574
#define LYX_FORMAT_LYX 575 // ps: lineno
#define LYX_FORMAT_TEX2LYX 575
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER