I'm attaching two patches, one against git master, the other against the 2.3.x branch. These patches add a starred new line break formatting option (\\*) to complement "Ragged line break", i.e. the \\ macro.
My specific use case for this is for short stanzas in a verse environment: \\* will prevent a page break in the middle of a stanza. For lack of a better term I've called this "Starred line break" though I'm sure it can be renamed to something more appropriate. I've also given it the keyboard shortcut of meta-shift-enter, which is in the ballpark of the other newline-style formatting options. I've been using this patch at least since the LyX 1.6.0 days, with no problems. Whether this is the best way to support \\* I'm not sure, but I do think having the ability to add \\* directly, rather than via ERT, is very useful. -- Chris Spiegel
diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index 2ba0064c41..7bbdc9dd87 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -229,6 +229,7 @@ Format 5 \bind "M-Return" "paragraph-break inverse" \bind "C-Return" "newline-insert newline" \bind "C-S-Return" "newline-insert linebreak" +\bind "M-S-Return" "newline-insert newlinestar" \bind "C-k" "line-delete-forward" \bind "C-space" "command-alternatives math-space ; space-insert protected" \bind "nobreakspace" "space-insert protected" diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index ec5c5c0ed6..9af5f6a322 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -464,6 +464,7 @@ Menuset Item "Optional Line Break|B" "specialchar-insert allowbreak" Item "Ragged Line Break|R" "newline-insert newline" Item "Justified Line Break|J" "newline-insert linebreak" + Item "Starred Line Break|e" "newline-insert newlinestar" Separator Item "New Page|N" "newpage-insert newpage" Item "Page Break|a" "newpage-insert pagebreak" diff --git a/src/Color.cpp b/src/Color.cpp index 7cb520d278..2f88a7d60d 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -336,6 +336,7 @@ ColorSet::ColorSet() { Color_bottomarea, N_("bottom area"), "bottomarea", grey40, grey80, "bottomarea" }, { Color_newpage, N_("new page"), "newpage", blue, "#86a4ff", "newpage" }, { Color_pagebreak, N_("page break / line break"), "pagebreak", RoyalBlue, RoyalBlue, "pagebreak" }, + { Color_newlinestar, N_("starred newline"), "newlinestar", Green, Green, "newlinestar" }, { Color_buttonframe, N_("button frame"), "buttonframe", "#dcd2c8", "#dcd2c8", "buttonframe" }, { Color_buttonbg, N_("button background"), "buttonbg", "#dcd2c8", "#dcd2c8", "buttonbg" }, { Color_buttonhoverbg, N_("button background under focus"), "buttonhoverbg", "#C7C7CA", "#C7C7CA", "buttonhoverbg" }, diff --git a/src/ColorCode.h b/src/ColorCode.h index e1a6b0aaa1..34a3862459 100644 --- a/src/ColorCode.h +++ b/src/ColorCode.h @@ -208,6 +208,8 @@ enum ColorCode { Color_newpage, /// Page break color Color_pagebreak, + /// Non-page breaking line break (\\*) color + Color_newlinestar, // FIXME: why are the next four separate ?? /// Color used for button frame diff --git a/src/Text3.cpp b/src/Text3.cpp index 5bfde06679..e38971f054 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1146,6 +1146,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) docstring const & arg = cmd.argument(); if (arg == "linebreak") inp.kind = InsetNewlineParams::LINEBREAK; + else if (arg == "newlinestar") + inp.kind = InsetNewlineParams::NEWLINESTAR; else inp.kind = InsetNewlineParams::NEWLINE; cap::replaceSelection(cur); diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index ecfacf47ce..19aef273f5 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -57,6 +57,9 @@ void InsetNewlineParams::write(ostream & os) const case InsetNewlineParams::LINEBREAK: os << "linebreak"; break; + case InsetNewlineParams::NEWLINESTAR: + os << "newlinestar"; + break; } } @@ -70,6 +73,8 @@ void InsetNewlineParams::read(Lexer & lex) kind = InsetNewlineParams::NEWLINE; else if (token == "linebreak") kind = InsetNewlineParams::LINEBREAK; + else if (token == "newlinestar") + kind = InsetNewlineParams::NEWLINESTAR; else lex.printError("Unknown kind: `$$Token'"); } @@ -145,6 +150,9 @@ ColorCode InsetNewline::ColorName() const case InsetNewlineParams::LINEBREAK: return Color_pagebreak; break; + case InsetNewlineParams::NEWLINESTAR: + return Color_newlinestar; + break; } // not really useful, but to avoids gcc complaints return Color_eolmarker; @@ -165,6 +173,9 @@ void InsetNewline::latex(otexstream & os, OutputParams const & rp) const case InsetNewlineParams::LINEBREAK: os << "\\linebreak{}\n"; break; + case InsetNewlineParams::NEWLINESTAR: + os << "\\\\*\n"; + break; default: os << "\\\\\n"; break; diff --git a/src/insets/InsetNewline.h b/src/insets/InsetNewline.h index c85a97df66..b7bc0762ac 100644 --- a/src/insets/InsetNewline.h +++ b/src/insets/InsetNewline.h @@ -25,7 +25,9 @@ public: /// NEWLINE, /// - LINEBREAK + LINEBREAK, + /// + NEWLINESTAR }; /// InsetNewlineParams() : kind(NEWLINE) {}
diff --git a/lib/bind/cua.bind b/lib/bind/cua.bind index d9b134d97e..10feb9801a 100644 --- a/lib/bind/cua.bind +++ b/lib/bind/cua.bind @@ -227,6 +227,7 @@ Format 4 \bind "M-Return" "paragraph-break inverse" \bind "C-Return" "newline-insert newline" \bind "C-S-Return" "newline-insert linebreak" +\bind "M-S-Return" "newline-insert newlinestar" \bind "C-k" "line-delete-forward" \bind "C-space" "command-alternatives math-space ; space-insert protected" \bind "nobreakspace" "space-insert protected" diff --git a/lib/ui/stdmenus.inc b/lib/ui/stdmenus.inc index d1f145c878..dc6e4f46c3 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -441,6 +441,7 @@ Menuset Item "Optional Line Break|B" "specialchar-insert allowbreak" Item "Ragged Line Break|R" "newline-insert newline" Item "Justified Line Break|J" "newline-insert linebreak" + Item "Starred Line Break|e" "newline-insert newlinestar" Separator Item "New Page|N" "newpage-insert newpage" Item "Page Break|a" "newpage-insert pagebreak" diff --git a/src/Color.cpp b/src/Color.cpp index d9933ce34e..6f885739c2 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -292,6 +292,7 @@ ColorSet::ColorSet() { Color_bottomarea, N_("bottom area"), "bottomarea", grey40, "bottomarea" }, { Color_newpage, N_("new page"), "newpage", "Blue", "newpage" }, { Color_pagebreak, N_("page break / line break"), "pagebreak", "RoyalBlue", "pagebreak" }, + { Color_newlinestar, N_("starred newline"), "newlinestar", "Green", "newlinestar" }, { Color_buttonframe, N_("button frame"), "buttonframe", "#dcd2c8", "buttonframe" }, { Color_buttonbg, N_("button background"), "buttonbg", "#dcd2c8", "buttonbg" }, { Color_buttonhoverbg, N_("button background under focus"), "buttonhoverbg", "#C7C7CA", "buttonhoverbg" }, diff --git a/src/ColorCode.h b/src/ColorCode.h index d0973852f8..403a516c6a 100644 --- a/src/ColorCode.h +++ b/src/ColorCode.h @@ -201,6 +201,8 @@ enum ColorCode { Color_newpage, /// Page break color Color_pagebreak, + /// Non-page breaking line break (\\*) color + Color_newlinestar, // FIXME: why are the next four separate ?? /// Color used for button frame diff --git a/src/Text3.cpp b/src/Text3.cpp index 7ec8947d64..0efba220b7 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -1055,6 +1055,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) docstring arg = cmd.argument(); if (arg == "linebreak") inp.kind = InsetNewlineParams::LINEBREAK; + else if (arg == "newlinestar") + inp.kind = InsetNewlineParams::NEWLINESTAR; else inp.kind = InsetNewlineParams::NEWLINE; cap::replaceSelection(cur); diff --git a/src/insets/InsetNewline.cpp b/src/insets/InsetNewline.cpp index b10954d4da..df8aa92a04 100644 --- a/src/insets/InsetNewline.cpp +++ b/src/insets/InsetNewline.cpp @@ -48,6 +48,9 @@ void InsetNewlineParams::write(ostream & os) const case InsetNewlineParams::LINEBREAK: os << "linebreak"; break; + case InsetNewlineParams::NEWLINESTAR: + os << "newlinestar"; + break; } } @@ -61,6 +64,8 @@ void InsetNewlineParams::read(Lexer & lex) kind = InsetNewlineParams::NEWLINE; else if (token == "linebreak") kind = InsetNewlineParams::LINEBREAK; + else if (token == "newlinestar") + kind = InsetNewlineParams::NEWLINESTAR; else lex.printError("Unknown kind: `$$Token'"); } @@ -136,6 +141,9 @@ ColorCode InsetNewline::ColorName() const case InsetNewlineParams::LINEBREAK: return Color_pagebreak; break; + case InsetNewlineParams::NEWLINESTAR: + return Color_newlinestar; + break; } // not really useful, but to avoids gcc complaints return Color_eolmarker; @@ -154,6 +162,9 @@ void InsetNewline::latex(otexstream & os, OutputParams const & rp) const case InsetNewlineParams::LINEBREAK: os << "\\linebreak{}\n"; break; + case InsetNewlineParams::NEWLINESTAR: + os << "\\\\*\n"; + break; default: os << "\\\\\n"; break; diff --git a/src/insets/InsetNewline.h b/src/insets/InsetNewline.h index 2dc9c553ed..5959e6627a 100644 --- a/src/insets/InsetNewline.h +++ b/src/insets/InsetNewline.h @@ -25,7 +25,9 @@ public: /// NEWLINE, /// - LINEBREAK + LINEBREAK, + /// + NEWLINESTAR }; /// InsetNewlineParams() : kind(NEWLINE) {}
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel