mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Add inset for \nopagebreak.
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg213388.html
This commit is contained in:
parent
4aee447af1
commit
0ea9df7467
@ -7,6 +7,9 @@ changes happened in particular if possible. A good example would be
|
||||
|
||||
-----------------------
|
||||
|
||||
2020-10-10 Pavel Sanda <sanda@lyx.org>
|
||||
* Format incremented to 599: Add inset for \nopagebreak macro (part of InseNewPage now).
|
||||
|
||||
2020-07-14 Thibaut Cuvelier <tcuvelier@lyx.org>
|
||||
* Format incremented to 598: DocBook can export to HTML and CALS tables, with the parameter
|
||||
\docbook_table_output (0: HTML, only choice previously; CALS: 1).
|
||||
|
@ -3958,6 +3958,19 @@ def revert_docbook_table_output(document):
|
||||
del document.header[i]
|
||||
|
||||
|
||||
def revert_nopagebreak(document):
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset Newpage nopagebreak")
|
||||
if i == -1:
|
||||
return
|
||||
end = find_end_of_inset(document.body, i)
|
||||
if end == 1:
|
||||
document.warning("Malformed LyX document: Could not find end of Newpage inset.")
|
||||
continue
|
||||
subst = put_cmd_in_ert("\\nopagebreak{}")
|
||||
document.body[i : end + 1] = subst
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -4017,10 +4030,12 @@ convert = [
|
||||
[595, []],
|
||||
[596, [convert_parskip]],
|
||||
[597, [convert_libertinus_rm_fonts]],
|
||||
[598, []]
|
||||
[598, []],
|
||||
[599, []]
|
||||
]
|
||||
|
||||
revert = [[597, [revert_docbook_table_output]],
|
||||
revert = [[598, [revert_nopagebreak]],
|
||||
[597, [revert_docbook_table_output]],
|
||||
[596, [revert_libertinus_rm_fonts,revert_libertinus_sftt_fonts]],
|
||||
[595, [revert_parskip,revert_line_vspaces]],
|
||||
[594, [revert_ams_spaces]],
|
||||
|
@ -322,6 +322,7 @@ Menuset
|
||||
Menu "context-newpage"
|
||||
Item "New Page|N" "inset-modify newpage newpage"
|
||||
Item "Page Break|a" "inset-modify newpage pagebreak"
|
||||
Item "No Page Break|g" "inset-modify newpage nopagebreak"
|
||||
Item "Clear Page|C" "inset-modify newpage clearpage"
|
||||
Item "Clear Double Page|D" "inset-modify newpage cleardoublepage"
|
||||
End
|
||||
|
@ -467,6 +467,7 @@ Menuset
|
||||
Separator
|
||||
Item "New Page|N" "newpage-insert newpage"
|
||||
Item "Page Break|a" "newpage-insert pagebreak"
|
||||
Item "No Page Break|g" "newpage-insert nopagebreak"
|
||||
Item "Clear Page|C" "newpage-insert clearpage"
|
||||
Item "Clear Double Page|D" "newpage-insert cleardoublepage"
|
||||
End
|
||||
|
@ -99,6 +99,8 @@ Inset * createInsetHelper(Buffer * buf, FuncRequest const & cmd)
|
||||
inp.kind = InsetNewpageParams::CLEARPAGE;
|
||||
else if (name == "cleardoublepage")
|
||||
inp.kind = InsetNewpageParams::CLEARDOUBLEPAGE;
|
||||
else if (name == "nopagebreak")
|
||||
inp.kind = InsetNewpageParams::NOPAGEBREAK;
|
||||
return new InsetNewpage(inp);
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,9 @@ void InsetNewpageParams::write(ostream & os) const
|
||||
case InsetNewpageParams::CLEARDOUBLEPAGE:
|
||||
os << "cleardoublepage";
|
||||
break;
|
||||
case InsetNewpageParams::NOPAGEBREAK:
|
||||
os << "nopagebreak";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,6 +82,8 @@ void InsetNewpageParams::read(Lexer & lex)
|
||||
kind = InsetNewpageParams::CLEARPAGE;
|
||||
else if (token == "cleardoublepage")
|
||||
kind = InsetNewpageParams::CLEARDOUBLEPAGE;
|
||||
else if (token == "nopagebreak")
|
||||
kind = InsetNewpageParams::NOPAGEBREAK;
|
||||
else
|
||||
lex.printError("Unknown kind");
|
||||
}
|
||||
@ -100,6 +105,14 @@ void InsetNewpage::read(Lexer & lex)
|
||||
|
||||
void InsetNewpage::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
if (params_.kind == InsetNewpageParams::NOPAGEBREAK) {
|
||||
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
|
||||
dim.asc = fm.maxAscent();
|
||||
dim.des = fm.maxDescent();
|
||||
dim.wid = 3 * fm.width('n');
|
||||
return;
|
||||
}
|
||||
|
||||
dim.asc = defaultRowHeight();
|
||||
dim.des = defaultRowHeight();
|
||||
dim.wid = mi.base.textwidth;
|
||||
@ -108,6 +121,54 @@ void InsetNewpage::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetNewpage::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
if (params_.kind == InsetNewpageParams::NOPAGEBREAK) {
|
||||
|
||||
FontInfo font;
|
||||
font.setColor(ColorName());
|
||||
|
||||
frontend::FontMetrics const & fm = theFontMetrics(pi.base.font);
|
||||
int const wid = 3 * fm.width('n');
|
||||
int const asc = fm.maxAscent();
|
||||
|
||||
int xp[3];
|
||||
int yp[3];
|
||||
|
||||
//left side arrow
|
||||
yp[0] = int(y - 0.875 * asc * 0.75);
|
||||
yp[1] = int(y - 0.500 * asc * 0.75);
|
||||
yp[2] = int(y - 0.125 * asc * 0.75);
|
||||
xp[0] = int(x + wid * 0.25);
|
||||
xp[1] = int(x + wid * 0.4);
|
||||
xp[2] = int(x + wid * 0.25);
|
||||
pi.pain.lines(xp, yp, 3, ColorName());
|
||||
|
||||
yp[0] = yp[1] = int(y - 0.500 * asc * 0.75);
|
||||
xp[0] = int(x + wid * 0.03);
|
||||
xp[1] = int(x + wid * 0.4);
|
||||
pi.pain.lines(xp, yp, 2, ColorName());
|
||||
|
||||
//right side arrow
|
||||
yp[0] = int(y - 0.875 * asc * 0.75);
|
||||
yp[1] = int(y - 0.500 * asc * 0.75);
|
||||
yp[2] = int(y - 0.125 * asc * 0.75);
|
||||
xp[0] = int(x + wid * 0.75);
|
||||
xp[1] = int(x + wid * 0.6);
|
||||
xp[2] = int(x + wid * 0.75);
|
||||
pi.pain.lines(xp, yp, 3, ColorName());
|
||||
|
||||
yp[0] = yp[1] = int(y - 0.500 * asc * 0.75);
|
||||
xp[0] = int(x + wid * 0.97);
|
||||
xp[1] = int(x + wid * 0.6);
|
||||
pi.pain.lines(xp, yp, 2, ColorName());
|
||||
|
||||
//mid-rule
|
||||
xp[0] = xp[1] = int(x + wid * 0.5);;
|
||||
yp[0] = int(y - 0.875 * asc * 0.75);
|
||||
yp[1] = int(y - 0.125 * asc * 0.75);
|
||||
pi.pain.lines(xp, yp, 2, ColorName());
|
||||
return;
|
||||
}
|
||||
|
||||
using frontend::Painter;
|
||||
|
||||
FontInfo font;
|
||||
@ -187,6 +248,9 @@ docstring InsetNewpage::insetLabel() const
|
||||
case InsetNewpageParams::CLEARDOUBLEPAGE:
|
||||
return _("Clear Double Page");
|
||||
break;
|
||||
case InsetNewpageParams::NOPAGEBREAK:
|
||||
return _("No Page Break");
|
||||
break;
|
||||
default:
|
||||
return _("New Page");
|
||||
break;
|
||||
@ -198,6 +262,7 @@ ColorCode InsetNewpage::ColorName() const
|
||||
{
|
||||
switch (params_.kind) {
|
||||
case InsetNewpageParams::PAGEBREAK:
|
||||
case InsetNewpageParams::NOPAGEBREAK:
|
||||
return Color_pagebreak;
|
||||
break;
|
||||
case InsetNewpageParams::NEWPAGE:
|
||||
@ -232,6 +297,9 @@ void InsetNewpage::latex(otexstream & os, OutputParams const & runparams) const
|
||||
case InsetNewpageParams::CLEARDOUBLEPAGE:
|
||||
os << "\\cleardoublepage" << termcmd;
|
||||
break;
|
||||
case InsetNewpageParams::NOPAGEBREAK:
|
||||
os << "\\nopagebreak" << termcmd;
|
||||
break;
|
||||
default:
|
||||
os << "\\newpage" << termcmd;
|
||||
break;
|
||||
@ -243,6 +311,8 @@ void InsetNewpage::latex(otexstream & os, OutputParams const & runparams) const
|
||||
int InsetNewpage::plaintext(odocstringstream & os,
|
||||
OutputParams const &, size_t) const
|
||||
{
|
||||
if (params_.kind == InsetNewpageParams::NOPAGEBREAK)
|
||||
return 0;
|
||||
os << '\n';
|
||||
return PLAINTEXT_NEWLINE;
|
||||
}
|
||||
@ -250,13 +320,15 @@ int InsetNewpage::plaintext(odocstringstream & os,
|
||||
|
||||
void InsetNewpage::docbook(XMLStream & os, OutputParams const &) const
|
||||
{
|
||||
os << xml::CR();
|
||||
if (params_.kind != InsetNewpageParams::NOPAGEBREAK)
|
||||
os << xml::CR();
|
||||
}
|
||||
|
||||
|
||||
docstring InsetNewpage::xhtml(XMLStream & xs, OutputParams const &) const
|
||||
{
|
||||
xs << xml::CompTag("br");
|
||||
if (params_.kind != InsetNewpageParams::NOPAGEBREAK)
|
||||
xs << xml::CompTag("br");
|
||||
return docstring();
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,9 @@ public:
|
||||
///
|
||||
CLEARPAGE,
|
||||
///
|
||||
CLEARDOUBLEPAGE
|
||||
CLEARDOUBLEPAGE,
|
||||
///
|
||||
NOPAGEBREAK
|
||||
};
|
||||
///
|
||||
InsetNewpageParams() : kind(NEWPAGE) {}
|
||||
@ -74,7 +76,7 @@ private:
|
||||
///
|
||||
void write(std::ostream & os) const override;
|
||||
///
|
||||
RowFlags rowFlags() const override { return Display; }
|
||||
RowFlags rowFlags() const override { return (params_.kind == InsetNewpageParams::NOPAGEBREAK) ? Inline : Display; }
|
||||
///
|
||||
docstring insetLabel() const;
|
||||
///
|
||||
|
@ -5593,7 +5593,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
||||
if (t.cs() == "newpage" ||
|
||||
(t.cs() == "pagebreak" && !p.hasOpt()) ||
|
||||
t.cs() == "clearpage" ||
|
||||
t.cs() == "cleardoublepage") {
|
||||
t.cs() == "cleardoublepage" ||
|
||||
t.cs() == "nopagebreak") {
|
||||
context.check_layout(os);
|
||||
begin_inset(os, "Newpage ");
|
||||
os << t.cs();
|
||||
|
@ -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 598 // tcuvelier: DocBook tables
|
||||
#define LYX_FORMAT_TEX2LYX 598
|
||||
#define LYX_FORMAT_LYX 599 // sanda: nobreakpage
|
||||
#define LYX_FORMAT_TEX2LYX 599
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user