LyX file-format changes
-----------------------
+2007-11-23 Uwe Stöhr <uwestoehr@web.de>
+ * Format incremented to 300: support for \pagebreak
+
2007-11-01 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 299: support for hyperlink types
InsetListingsParams.h
InsetMarginal.h
InsetNewline.h
+ InsetNewpage.h
InsetNomencl.h
InsetNote.h
InsetOptArg.h
- InsetPagebreak.h
InsetQuotes.h
InsetRef.h
InsetSpace.h
InsetListingsParams.cpp
InsetMarginal.cpp
InsetNewline.cpp
+ InsetNewpage.cpp
InsetNomencl.cpp
InsetNote.cpp
InsetOptArg.cpp
- InsetPagebreak.cpp
InsetQuotes.cpp
InsetRef.cpp
InsetSpace.cpp
def checkLatex(dtl_tools):
''' Check latex, return lyx_check_config '''
- path, LATEX = checkProg('a Latex2e program', ['platex $$i', 'latex $$i', 'latex2e $$i'])
- path, PPLATEX = checkProg('a DVI postprocessing program', ['pplatex $$i'])
- # use LATEX to convert from latex to dvi if PPLATEX is not available
- if PPLATEX == '':
- PPLATEX = LATEX
if dtl_tools:
# Windows only: DraftDVI
- addToRC(r'''\converter latex dvi2 "%s" "latex"
-\converter dvi2 dvi "python -tt $$s/scripts/clean_dvi.py $$i $$o" ""''' % PPLATEX)
+ converter_entry = r'''\converter latex dvi2 "%%" "latex"
+\converter dvi2 dvi "python -tt $$s/scripts/clean_dvi.py $$i $$o" ""'''
else:
- addToRC(r'\converter latex dvi "%s" "latex"' % PPLATEX)
+ converter_entry = r'\converter latex dvi "%%" "latex"'
+ path, LATEX = checkProg('a Latex2e program', ['pplatex $$i', 'platex $$i', 'latex $$i', 'latex2e $$i'],
+ rc_entry = [converter_entry])
# no latex
if LATEX != '':
# Check if latex is usable
bool_docbook, bool_linuxdoc)
checkModulesConfig() #lyx_check_config and LATEX != '')
removeTempFiles()
- # The return error code can be 256. Because most systems expect an error code
- # in the range 0-127, 256 can be interpretted as 'success'. Because we expect
- # a None for success, 'ret is not None' is used to exit.
- sys.exit(ret is not None)
+ sys.exit(ret)
("1_3", [221], minor_versions("1.3" , 7)),
("1_4", range(222,246), minor_versions("1.4" , 5)),
("1_5", range(246,277), minor_versions("1.5" , 2)),
- ("1_6", range(277,300), minor_versions("1.6" , 0))] # Uwe: Hyperlink types
+ ("1_6", range(277,301), minor_versions("1.6" , 0))] # Uwe: \pagebreak
def formats_list():
i = i + 1
+def revert_pagebreak(document):
+ 'Reverts pagebreak to newpage'
+ i = 0
+ while True:
+ i = find_token(document.body, "\\pagebreak", i)
+ if i == -1:
+ return
+ document.body[i] = document.body[i].replace("\\pagebreak", "\\newpage")
+ i = i + 1
+
+
##
# Conversion hub
#
[296, [convert_include]],
[297, [convert_usorbian]],
[298, []],
- [299, []]
+ [299, []],
+ [300, []]
]
-revert = [[298, [revert_hyperlinktype]],
+revert = [[299, [revert_pagebreak]],
+ [298, [revert_hyperlinktype]],
[297, [revert_macro_optional_params]],
[296, [revert_albanian, revert_lowersorbian, revert_uppersorbian]],
[295, [revert_include]],
Item "Ligature Break|k" "ligature-break-insert"
Item "Line Break|B" "break-line"
Separator
+ Item "New Page|N" "newpage-insert"
Item "Page Break|a" "pagebreak-insert"
Item "Clear Page|C" "clearpage-insert"
Item "Clear Double Page|D" "cleardoublepage-insert"
namespace {
-int const LYX_FORMAT = 299; // Uwe: Hyperlink types
+int const LYX_FORMAT = 300; // Uwe: \pagebreak
} // namespace anon
{ LFUN_BIBTEX_DATABASE_ADD, "bibtex-database-add", Noop, Edit },
{ LFUN_BIBTEX_DATABASE_DEL, "bibtex-database-del", Noop, Edit },
{ LFUN_LINE_INSERT, "line-insert", Noop, Edit },
+ { LFUN_NEWPAGE_INSERT, "newpage-insert", Noop, Edit },
{ LFUN_PAGEBREAK_INSERT, "pagebreak-insert", Noop, Edit },
{ LFUN_LANGUAGE, "language", Noop, Edit },
{ LFUN_LAYOUT, "layout", Noop, Layout },
insets/InsetListingsParams.cpp \
insets/InsetMarginal.cpp \
insets/InsetNewline.cpp \
+ insets/InsetNewpage.cpp \
insets/InsetNomencl.cpp \
insets/InsetNote.cpp \
insets/InsetOptArg.cpp \
- insets/InsetPagebreak.cpp \
insets/InsetQuotes.cpp \
insets/InsetRef.cpp \
insets/InsetSpace.cpp \
insets/InsetListingsParams.h \
insets/InsetMarginal.h \
insets/InsetNewline.h \
+ insets/InsetNewpage.h \
insets/InsetNomencl.h \
insets/InsetNote.h \
insets/InsetOptArg.h \
- insets/InsetPagebreak.h \
insets/InsetQuotes.h \
insets/InsetRef.h \
insets/InsetSpace.h \
#include "insets/InsetHFill.h"
#include "insets/InsetLine.h"
#include "insets/InsetNewline.h"
-#include "insets/InsetPagebreak.h"
+#include "insets/InsetNewpage.h"
#include "insets/InsetOptArg.h"
#include "insets/InsetSpace.h"
#include "insets/InsetSpecialChar.h"
} else if (token == "\\lyxline") {
par.insertInset(par.size(), new InsetLine, font, change);
} else if (token == "\\newpage") {
+ par.insertInset(par.size(), new InsetNewpage, font, change);
+ } else if (token == "\\pagebreak") {
par.insertInset(par.size(), new InsetPagebreak, font, change);
} else if (token == "\\clearpage") {
par.insertInset(par.size(), new InsetClearPage, font, change);
case LFUN_TOC_INSERT:
case LFUN_HFILL_INSERT:
case LFUN_LINE_INSERT:
+ case LFUN_NEWPAGE_INSERT:
case LFUN_PAGEBREAK_INSERT:
case LFUN_CLEARPAGE_INSERT:
case LFUN_CLEARDOUBLEPAGE_INSERT:
case LFUN_DATE_INSERT:
case LFUN_SELF_INSERT:
case LFUN_LINE_INSERT:
+ case LFUN_NEWPAGE_INSERT:
case LFUN_PAGEBREAK_INSERT:
case LFUN_CLEARPAGE_INSERT:
case LFUN_CLEARDOUBLEPAGE_INSERT:
#include "insets/InsetBox.h"
#include "insets/InsetBranch.h"
#include "insets/InsetOptArg.h"
-#include "insets/InsetPagebreak.h"
+#include "insets/InsetNewpage.h"
#include "insets/InsetRef.h"
#include "insets/InsetSpace.h"
#include "insets/InsetTabular.h"
case LFUN_LINE_INSERT:
return new InsetLine;
+ case LFUN_NEWPAGE_INSERT:
+ return new InsetNewpage;
+
case LFUN_PAGEBREAK_INSERT:
return new InsetPagebreak;
InsetName("listings", LISTINGS_CODE),
InsetName("info", INFO_CODE),
InsetName("collapsable", COLLAPSABLE_CODE),
- InsetName("pagebreak", PAGEBREAK_CODE),
+ InsetName("newpage", NEWPAGE_CODE),
};
std::size_t const insetnames_size =
case TABULAR_CODE:
case WRAP_CODE:
case CAPTION_CODE:
- case PAGEBREAK_CODE:
+ case NEWPAGE_CODE:
return false;
default:
return InsetText::insetAllowed(code);
///
NOMENCL_PRINT_CODE,
///
- PAGEBREAK_CODE,
+ NEWPAGE_CODE,
///
LISTINGS_CODE,
///
case LFUN_LABEL_INSERT:
case LFUN_LIGATURE_BREAK_INSERT:
case LFUN_LINE_INSERT:
+ case LFUN_NEWPAGE_INSERT:
case LFUN_PAGEBREAK_INSERT:
case LFUN_LAYOUT:
case LFUN_LAYOUT_PARAGRAPH:
--- /dev/null
+/**
+ * \file InsetNewpage.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "InsetNewpage.h"
+
+#include "debug.h"
+#include "gettext.h"
+#include "Text.h"
+#include "MetricsInfo.h"
+#include "OutputParams.h"
+#include "TextMetrics.h"
+
+#include "frontends/FontMetrics.h"
+#include "frontends/Painter.h"
+
+#include "support/docstring.h"
+
+
+namespace lyx {
+
+using frontend::Painter;
+
+
+void InsetNewpage::read(Buffer const &, Lexer &)
+{
+ /* Nothing to read */
+}
+
+
+void InsetNewpage::write(Buffer const &, std::ostream & os) const
+{
+ os << "\n" << getCmdName() << '\n';
+}
+
+
+void InsetNewpage::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+ dim.asc = defaultRowHeight();
+ dim.des = defaultRowHeight();
+ dim.wid = mi.base.textwidth;
+ // Cache the inset dimension.
+ setDimCache(mi, dim);
+}
+
+
+void InsetNewpage::draw(PainterInfo & pi, int x, int y) const
+{
+ FontInfo font;
+ font.setColor(Color_pagebreak);
+ font.decSize();
+
+ Dimension const dim = dimension(*pi.base.bv);
+
+ int w = 0;
+ int a = 0;
+ int d = 0;
+ theFontMetrics(font).rectText(insetLabel(), w, a, d);
+
+ int const text_start = int(x + (dim.wid - w) / 2);
+ int const text_end = text_start + w;
+
+ pi.pain.rectText(text_start, y + d, insetLabel(), font,
+ Color_none, Color_none);
+
+ pi.pain.line(x, y, text_start, y,
+ Color_pagebreak, Painter::line_onoffdash);
+ pi.pain.line(text_end, y, int(x + dim.wid), y,
+ Color_pagebreak, Painter::line_onoffdash);
+}
+
+
+int InsetNewpage::latex(Buffer const &, odocstream & os,
+ OutputParams const &) const
+{
+ os << from_ascii(getCmdName()) << "{}";
+ return 0;
+}
+
+
+int InsetNewpage::plaintext(Buffer const &, odocstream & os,
+ OutputParams const &) const
+{
+ os << '\n';
+ return PLAINTEXT_NEWLINE;
+}
+
+
+int InsetNewpage::docbook(Buffer const &, odocstream & os,
+ OutputParams const &) const
+{
+ os << '\n';
+ return 0;
+}
+
+
+} // namespace lyx
--- /dev/null
+// -*- C++ -*-
+/**
+ * \file InsetNewpage.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef INSET_NEWPAGE_H
+#define INSET_NEWPAGE_H
+
+
+#include "Inset.h"
+#include "gettext.h"
+
+
+namespace lyx {
+
+class InsetNewpage : public Inset {
+public:
+ InsetNewpage() {}
+
+ InsetCode lyxCode() const { return NEWPAGE_CODE; }
+
+ void metrics(MetricsInfo &, Dimension &) const;
+
+ void draw(PainterInfo & pi, int x, int y) const;
+
+ int latex(Buffer const &, odocstream &,
+ OutputParams const &) const;
+
+ int plaintext(Buffer const &, odocstream &,
+ OutputParams const &) const;
+
+ int docbook(Buffer const &, odocstream &,
+ OutputParams const &) const;
+
+ void read(Buffer const &, Lexer & lex);
+
+ virtual void write(Buffer const & buf, std::ostream & os) const;
+ /// We don't need \begin_inset and \end_inset
+ bool directWrite() const { return true; }
+
+ DisplayType display() const { return AlignCenter; }
+
+ virtual docstring insetLabel() const { return _("New Page"); }
+
+ virtual std::string getCmdName() const { return "\\newpage"; }
+
+private:
+ virtual Inset * clone() const
+ {
+ return new InsetNewpage;
+ }
+};
+
+
+class InsetPagebreak : public InsetNewpage {
+public:
+ InsetPagebreak() {}
+
+ docstring insetLabel() const { return _("Page Break"); }
+
+ std::string getCmdName() const { return "\\pagebreak"; }
+
+private:
+ virtual Inset * clone() const
+ {
+ return new InsetPagebreak;
+ }
+};
+
+
+class InsetClearPage : public InsetNewpage {
+public:
+ InsetClearPage() {}
+
+ docstring insetLabel() const { return _("Clear Page"); }
+
+ std::string getCmdName() const { return "\\clearpage"; }
+
+private:
+ virtual Inset * clone() const
+ {
+ return new InsetClearPage;
+ }
+};
+
+
+class InsetClearDoublePage : public InsetNewpage {
+public:
+ InsetClearDoublePage() {}
+
+ docstring insetLabel() const { return _("Clear Double Page"); }
+
+ std::string getCmdName() const { return "\\cleardoublepage"; }
+
+private:
+ virtual Inset * clone() const
+ {
+ return new InsetClearDoublePage;
+ }
+};
+
+} // namespace lyx
+
+#endif // INSET_NEWPAGE_H
+++ /dev/null
-/**
- * \file InsetPagebreak.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author André Pönitz
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "InsetPagebreak.h"
-
-#include "debug.h"
-#include "gettext.h"
-#include "Text.h"
-#include "MetricsInfo.h"
-#include "OutputParams.h"
-#include "TextMetrics.h"
-
-#include "frontends/FontMetrics.h"
-#include "frontends/Painter.h"
-
-#include "support/docstring.h"
-
-
-namespace lyx {
-
-using frontend::Painter;
-
-
-void InsetPagebreak::read(Buffer const &, Lexer &)
-{
- /* Nothing to read */
-}
-
-
-void InsetPagebreak::write(Buffer const &, std::ostream & os) const
-{
- os << "\n" << getCmdName() << '\n';
-}
-
-
-void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
-{
- dim.asc = defaultRowHeight();
- dim.des = defaultRowHeight();
- dim.wid = mi.base.textwidth;
- // Cache the inset dimension.
- setDimCache(mi, dim);
-}
-
-
-void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
-{
- FontInfo font;
- font.setColor(Color_pagebreak);
- font.decSize();
-
- Dimension const dim = dimension(*pi.base.bv);
-
- int w = 0;
- int a = 0;
- int d = 0;
- theFontMetrics(font).rectText(insetLabel(), w, a, d);
-
- int const text_start = int(x + (dim.wid - w) / 2);
- int const text_end = text_start + w;
-
- pi.pain.rectText(text_start, y + d, insetLabel(), font,
- Color_none, Color_none);
-
- pi.pain.line(x, y, text_start, y,
- Color_pagebreak, Painter::line_onoffdash);
- pi.pain.line(text_end, y, int(x + dim.wid), y,
- Color_pagebreak, Painter::line_onoffdash);
-}
-
-
-int InsetPagebreak::latex(Buffer const &, odocstream & os,
- OutputParams const &) const
-{
- os << from_ascii(getCmdName()) << "{}";
- return 0;
-}
-
-
-int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
- OutputParams const &) const
-{
- os << '\n';
- return PLAINTEXT_NEWLINE;
-}
-
-
-int InsetPagebreak::docbook(Buffer const &, odocstream & os,
- OutputParams const &) const
-{
- os << '\n';
- return 0;
-}
-
-
-} // namespace lyx
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file InsetPagebreak.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author André Pönitz
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef INSET_PAGEBREAK_H
-#define INSET_PAGEBREAK_H
-
-
-#include "Inset.h"
-#include "gettext.h"
-
-
-namespace lyx {
-
-class InsetPagebreak : public Inset {
-public:
- InsetPagebreak() {}
-
- InsetCode lyxCode() const { return PAGEBREAK_CODE; }
-
- void metrics(MetricsInfo &, Dimension &) const;
-
- void draw(PainterInfo & pi, int x, int y) const;
-
- int latex(Buffer const &, odocstream &,
- OutputParams const &) const;
-
- int plaintext(Buffer const &, odocstream &,
- OutputParams const &) const;
-
- int docbook(Buffer const &, odocstream &,
- OutputParams const &) const;
-
- void read(Buffer const &, Lexer & lex);
-
- virtual void write(Buffer const & buf, std::ostream & os) const;
- /// We don't need \begin_inset and \end_inset
- bool directWrite() const { return true; }
-
- DisplayType display() const { return AlignCenter; }
-
- virtual docstring insetLabel() const { return _("Page Break"); }
-
- virtual std::string getCmdName() const { return "\\newpage"; }
-
-private:
- virtual Inset * clone() const
- {
- return new InsetPagebreak;
- }
-};
-
-
-class InsetClearPage : public InsetPagebreak {
-public:
- InsetClearPage() {}
-
- docstring insetLabel() const { return _("Clear Page"); }
-
- std::string getCmdName() const { return "\\clearpage"; }
-
-private:
- virtual Inset * clone() const
- {
- return new InsetClearPage;
- }
-};
-
-
-class InsetClearDoublePage : public InsetPagebreak {
-public:
- InsetClearDoublePage() {}
-
- docstring insetLabel() const { return _("Clear Double Page"); }
-
- std::string getCmdName() const { return "\\cleardoublepage"; }
-
-private:
- virtual Inset * clone() const
- {
- return new InsetClearDoublePage;
- }
-};
-
-} // namespace lyx
-
-#endif // INSET_PAGEBREAK_H
bool endfoot;
/// row of endlastfoot
bool endlastfoot;
- /// row for a pagebreak
+ /// row for a newpage
bool newpage;
};
///
LFUN_BOX_INSERT,
LFUN_LINE_INSERT,
// 240
+ LFUN_NEWPAGE_INSERT, // uwestoehr 20071124
LFUN_PAGEBREAK_INSERT,
LFUN_REPEAT,
LFUN_FINISHED_LEFT,
InsetMathGrid::RowInfo::RowInfo()
- : lines_(0), skip_(0), allow_pagebreak_(true)
+ : lines_(0), skip_(0), allow_newpage_(true)
{}
if (!rowinfo_[row].crskip_.zero())
eol += '[' + from_utf8(rowinfo_[row].crskip_.asLatexString()) + ']';
- else if(!rowinfo_[row].allow_pagebreak_)
+ else if(!rowinfo_[row].allow_newpage_)
eol += '*';
// make sure an upcoming '[' does not break anything
/// extra distance between lines
int skip_;
/// Is a page break allowed after this row?
- bool allow_pagebreak_;
+ bool allow_newpage_;
};
// additional per-row information
* environments like "equation" that have a fixed number of rows.
*/
bool addRow(InsetMathGrid & grid, InsetMathGrid::row_type & cellrow,
- docstring const & vskip, bool allow_pagebreak = true)
+ docstring const & vskip, bool allow_newpage_ = true)
{
++cellrow;
if (cellrow == grid.nrows()) {
lyxerr << "ignoring extra row";
if (!vskip.empty())
lyxerr << " with extra space " << to_utf8(vskip);
- if (!allow_pagebreak)
+ if (!allow_newpage_)
lyxerr << " with no page break allowed";
lyxerr << '.' << endl;
return false;
}
}
grid.vcrskip(Length(to_utf8(vskip)), cellrow - 1);
- grid.rowinfo(cellrow - 1).allow_pagebreak_ = allow_pagebreak;
+ grid.rowinfo(cellrow - 1).allow_newpage_ = allow_newpage_;
return true;
}
/// These are for longtabulars only
/// row type (head, foot, firsthead etc.)
LTRowType type;
- /// row for a pagebreak
+ /// row for a newpage
bool newpage;
};
}
else if (t.cs() == "newpage" ||
- t.cs() == "clearpage" ||
- t.cs() == "cleardoublepage") {
+ t.cs() == "pagebreak" ||
+ t.cs() == "clearpage" ||
+ t.cs() == "cleardoublepage") {
context.check_layout(os);
- // FIXME: what about \\pagebreak?
os << "\n\\" << t.cs() << "\n";
skip_braces(p); // eat {}
}