LyX file-format changes
-----------------------
+2007-11-24 Uwe Stöhr <uwestoehr@web.de>
+ * Format incremented to 301: support for \linebreak
+
2007-11-23 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 300: support for \pagebreak
\bind "M-~S-i s p" "hyphenation-point-insert"
\bind "M-~S-i s k" "ligature-break-insert"
\bind "M-~S-i s b" "protected-space-insert"
-\bind "M-~S-i s l" "break-line"
+\bind "M-~S-i s l" "new-line"
+\bind "M-~S-i s r" "line-break"
\bind "M-~S-i s i" "dots-insert"
\bind "M-~S-i s e" "end-of-sentence-period-insert"
\bind "M-~S-i s q" "self-insert \""
\bind "C-Delete" "word-delete-forward"
\bind "C-BackSpace" "word-delete-backward"
\bind "M-Return" "break-paragraph inverse"
-\bind "C-Return" "break-line"
+\bind "C-Return" "new-line"
+\bind "C-S-Return" "line-break"
\bind "C-k" "line-delete-forward"
\bind "C-space" "space-insert protected"
\bind "C-M-space" "space-insert normal"
\bind "M-d" "word-delete-forward"
\bind "C-BackSpace" "word-delete-backward"
\bind "M-Return" "break-paragraph inverse"
-\bind "C-Return" "break-line"
+\bind "C-Return" "new-line"
+\bind "C-S-Return" "line-break"
\bind "C-S-L" "ligature-break-insert"
\bind "C-space" "space-insert protected"
\bind "C-M-space" "space-insert normal"
\bind "M-Delete" "word-delete-forward"
\bind "M-BackSpace" "word-delete-backward"
\bind "M-Return" "break-paragraph inverse"
-\bind "C-Return" "break-line"
+\bind "C-Return" "new-line"
+\bind "C-S-Return" "line-break"
\bind "C-k" "line-delete-forward"
\bind "M-space" "space-insert protected"
\bind "C-M-space" "space-insert normal"
\bind "M-d" "word-delete-forward"
\bind "C-BackSpace" "word-delete-backward"
\bind "M-Return" "break-paragraph inverse"
-\bind "C-Return" "break-line"
+\bind "C-Return" "new-line"
+\bind "C-S-Return" "line-break"
\bind "C-S-L" "ligature-break-insert"
\bind "C-space" "space-insert protected"
\bind "C-M-space" "space-insert normal"
("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,301), minor_versions("1.6" , 0))] # Uwe: \pagebreak
+ ("1_6", range(277,302), minor_versions("1.6" , 0))] # Uwe: \linebreak
def formats_list():
i = i + 1
+def revert_linebreak(document):
+ 'Reverts linebreak to newline'
+ i = 0
+ while True:
+ i = find_token(document.body, "\\linebreak", i)
+ if i == -1:
+ return
+ document.body[i] = document.body[i].replace("\\linebreak", "\\newline")
+ i = i + 1
+
+
##
# Conversion hub
#
[297, [convert_usorbian]],
[298, []],
[299, []],
- [300, []]
+ [300, []],
+ [301, []]
]
-revert = [[299, [revert_pagebreak]],
+revert = [[300, [revert_linebreak]],
+ [299, [revert_pagebreak]],
[298, [revert_hyperlinktype]],
[297, [revert_macro_optional_params]],
[296, [revert_albanian, revert_lowersorbian, revert_uppersorbian]],
Separator
Item "Hyphenation Point|H" "hyphenation-point-insert"
Item "Ligature Break|k" "ligature-break-insert"
- Item "Line Break|B" "break-line"
+ Item "New Line|w" "new-line"
+ Item "Line Break|B" "line-break"
Separator
Item "New Page|N" "newpage-insert"
Item "Page Break|a" "pagebreak-insert"
namespace {
-int const LYX_FORMAT = 300; // Uwe: \pagebreak
+int const LYX_FORMAT = 301; // Uwe: \linebreak
} // namespace anon
{ LFUN_BOOKMARK_GOTO, "bookmark-goto", NoBuffer, Edit },
{ LFUN_BOOKMARK_SAVE, "bookmark-save", ReadOnly, Edit },
{ LFUN_BOOKMARK_CLEAR, "bookmark-clear", NoBuffer, Edit },
- { LFUN_BREAK_LINE, "break-line", Noop, Edit },
{ LFUN_BREAK_PARAGRAPH, "break-paragraph", Noop, Edit },
{ LFUN_BREAK_PARAGRAPH_SKIP, "break-paragraph-skip", Noop, Edit },
{ LFUN_BUILD_PROGRAM, "build-program", ReadOnly, Buffer },
{ LFUN_LAYOUT_TABULAR, "layout-tabular", Noop, Layout },
{ LFUN_LINE_BEGIN, "line-begin", ReadOnly | NoUpdate, Edit },
{ LFUN_LINE_BEGIN_SELECT, "line-begin-select", ReadOnly | SingleParUpdate, Edit },
+ { LFUN_LINE_BREAK, "line-break", Noop, Edit },
{ LFUN_LINE_DELETE, "line-delete-forward", Noop, Edit }, // there is no line-delete-backward
{ LFUN_LINE_END, "line-end", ReadOnly | NoUpdate, Edit },
{ LFUN_LINE_END_SELECT, "line-end-select", ReadOnly | SingleParUpdate, Edit },
{ LFUN_MENU_OPEN, "menu-open", NoBuffer, Buffer },
{ LFUN_MENU_SEPARATOR_INSERT, "menu-separator-insert", Noop, Edit },
{ LFUN_META_PREFIX, "meta-prefix", NoBuffer, System },
- { LFUN_BRANCH_INSERT, "branch-insert", Noop, Edit },
- { LFUN_FLEX_INSERT, "flex-insert", Noop, Edit },
+ { LFUN_NEW_LINE, "new-line", Noop, Edit },
+ { LFUN_NEXT_INSET_TOGGLE, "next-inset-toggle", ReadOnly, Edit },
{ LFUN_NOTE_INSERT, "note-insert", Noop, Edit },
- { LFUN_BOX_INSERT, "box-insert", Noop, Edit },
{ LFUN_NOTE_NEXT, "note-next", ReadOnly, Edit },
+ { LFUN_BRANCH_INSERT, "branch-insert", Noop, Edit },
+ { LFUN_BOX_INSERT, "box-insert", Noop, Edit },
+ { LFUN_FLEX_INSERT, "flex-insert", Noop, Edit },
{ LFUN_INSET_TOGGLE, "", ReadOnly, Hidden },
- { LFUN_NEXT_INSET_TOGGLE, "next-inset-toggle", ReadOnly, Edit },
{ LFUN_ALL_INSETS_TOGGLE, "all-insets-toggle", ReadOnly, Edit },
{ LFUN_PARAGRAPH_DOWN, "paragraph-down", ReadOnly | NoUpdate, Edit },
{ LFUN_PARAGRAPH_DOWN_SELECT, "paragraph-down-select", ReadOnly, Edit },
if (runparams.moving_arg)
os << "\\protect ";
- os << "\\\\\n";
}
texrow.newline();
texrow.start(owner_->id(), i + 1);
}
} else if (token == "\\backslash") {
par.appendChar('\\', font, change);
+ } else if (token == "\\linebreak") {
+ auto_ptr<Inset> inset(new InsetLinebreak);
+ inset->read(buf, lex);
+ par.insertInset(par.size(), inset.release(), font, change);
} else if (token == "\\newline") {
auto_ptr<Inset> inset(new InsetNewline);
inset->read(buf, lex);
break;
}
- case LFUN_BREAK_LINE: {
+ case LFUN_NEW_LINE: {
// Not allowed by LaTeX (labels or empty par)
if (cur.pos() > cur.paragraph().beginOfBody()) {
// this avoids a double undo
}
break;
}
+
+ case LFUN_LINE_BREAK: {
+ // Not allowed by LaTeX (labels or empty par)
+ if (cur.pos() > cur.paragraph().beginOfBody()) {
+ // this avoids a double undo
+ // FIXME: should not be needed, ideally
+ if (!cur.selection())
+ cur.recordUndo();
+ cap::replaceSelection(cur);
+ cur.insert(new InsetLinebreak);
+ cur.posForward();
+ moveCursor(cur, false);
+ }
+ break;
+ }
case LFUN_CHAR_DELETE_FORWARD:
if (!cur.selection()) {
case LFUN_PARAGRAPH_UP:
case LFUN_PARAGRAPH_DOWN:
case LFUN_LINE_BEGIN:
+ case LFUN_LINE_BREAK:
case LFUN_LINE_END:
- case LFUN_BREAK_LINE:
+ case LFUN_NEW_LINE:
case LFUN_CHAR_DELETE_FORWARD:
case LFUN_DELETE_FORWARD_SKIP:
case LFUN_CHAR_DELETE_BACKWARD:
case LFUN_BIBITEM_INSERT:
case LFUN_BOX_INSERT:
case LFUN_BRANCH_INSERT:
- case LFUN_BREAK_LINE:
+ case LFUN_NEW_LINE:
case LFUN_CAPTION_INSERT:
case LFUN_CLEARPAGE_INSERT:
case LFUN_CLEARDOUBLEPAGE_INSERT:
#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
+#include "support/docstring.h"
+
namespace lyx {
void InsetNewline::write(Buffer const &, ostream & os) const
{
- os << "\n\\newline\n";
+ os << "\n" << getLyXName() << '\n';
}
}
-int InsetNewline::latex(Buffer const &, odocstream &,
+int InsetNewline::latex(Buffer const &, odocstream & os,
OutputParams const &) const
{
- lyxerr << "Eek, calling InsetNewline::latex !" << endl;
+ os << from_ascii(getCmdName()) << '\n';
return 0;
}
void InsetNewline::draw(PainterInfo & pi, int x, int y) const
{
+ FontInfo font;
+ font.setColor(ColorName());
+
frontend::FontMetrics const & fm = theFontMetrics(pi.base.font);
int const wid = fm.width('n');
int const asc = fm.maxAscent();
xp[2] = int(x + wid * 0.625);
}
- pi.pain.lines(xp, yp, 3, Color_eolmarker);
+ pi.pain.lines(xp, yp, 3, ColorName());
yp[0] = int(y - 0.500 * asc * 0.75);
yp[1] = int(y - 0.500 * asc * 0.75);
xp[2] = int(x);
}
- pi.pain.lines(xp, yp, 3, Color_eolmarker);
+ pi.pain.lines(xp, yp, 3, ColorName());
+
+ // add label text behind the newline marker to divide from \newline
+ int w = 0;
+ int a = 0;
+ int d = 0;
+ theFontMetrics(font).rectText(insetLabel(), w, a, d);
+
+ int const text_start = int(x + 2 * wid);
+
+ pi.pain.rectText(text_start, yp[0] + d, insetLabel(), font,
+ Color_none, Color_none);
}
#include "Inset.h"
+#include "gettext.h"
namespace lyx {
virtual void read(Buffer const &, Lexer & lex);
- virtual void write(Buffer const & buf, std::ostream & os) const;
+ virtual void write(Buffer const &, std::ostream & os) const;
/// We don't need \begin_inset and \end_inset
virtual bool directWrite() const { return true; }
/// is this equivalent to a space (which is BTW different from
// a line separator)?
bool isSpace() const;
+
+ virtual docstring insetLabel() const { return _(""); }
+
+ virtual std::string getLyXName() const { return "\\newline"; }
+
+ virtual std::string getCmdName() const { return "\\\\"; }
+
+ virtual ColorCode ColorName() const { return Color_eolmarker; }
+
private:
virtual Inset * clone() const
{
}
};
+class InsetLinebreak : public InsetNewline {
+public:
+ InsetLinebreak() {}
+
+ docstring insetLabel() const { return _("line break"); }
+
+ std::string getLyXName() const { return "\\linebreak"; }
+
+ std::string getCmdName() const { return "\\linebreak{}"; }
+
+ ColorCode ColorName() const { return Color_pagebreak; }
+
+private:
+ virtual Inset * clone() const
+ {
+ return new InsetLinebreak;
+ }
+};
+
} // namespace lyx
}
// disable in non-fixed-width cells
- case LFUN_BREAK_LINE:
+ case LFUN_NEW_LINE:
case LFUN_BREAK_PARAGRAPH:
case LFUN_BREAK_PARAGRAPH_SKIP: {
if (tabular.getPWidth(cur.idx()).zero()) {
// 60
LFUN_CHAR_DELETE_FORWARD,
LFUN_CHAR_DELETE_BACKWARD,
- LFUN_BREAK_LINE,
+ LFUN_NEW_LINE,
+ LFUN_LINE_BREAK,
LFUN_BREAK_PARAGRAPH,
LFUN_QUOTE_INSERT,
// 65
}
break;
- case LFUN_BREAK_LINE: {
+ case LFUN_NEW_LINE: {
cur.recordUndoInset();
row_type const r = cur.row();
addRow(r);
// just swallow this
break;
- case LFUN_BREAK_LINE:
+ case LFUN_NEW_LINE:
// some magic for the common case
if (type_ == hullSimple || type_ == hullEquation) {
cur.recordUndoInset();
case LFUN_DOWN:
status.enabled(true);
return true;
- case LFUN_BREAK_LINE:
+ case LFUN_NEW_LINE:
case LFUN_MATH_NUMBER:
case LFUN_MATH_NONUMBER:
case LFUN_MATH_EXTERN:
}
}
- else if (t.cs() == "newline") {
+ else if (t.cs() == "newline" ||
+ t.cs() == "linebreak") {
context.check_layout(os);
os << "\n\\" << t.cs() << "\n";
skip_braces(p); // eat {}