[PATCH] Support \\*

2022-06-06 Thread Chris Spiegel
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

Line Breaking Problem

2022-06-06 Thread Richard Kimberly Heck
I'm still seeing a bug where quotes cause line-breaking problems. E.g., 
I can see things like this:


This is an interesting quote: "I am not sure what you mean"
. The period ends up on the following line.

The quotes there would be LyX quotes.

Riki


--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel