# HG changeset patch # User Mike Becker # Date 1705694614 -3600 # Node ID 4bf47ea3fc643adb3ba6a4807efbc0cec86a7e8b # Parent 1af1bfacd25a27baa1c81a5d6056f10541a13f77 allow custom line breaks in help text relates to #315 diff -r 1af1bfacd25a -r 4bf47ea3fc64 src/main/java/de/unixwork/uwproj/Feature.java --- a/src/main/java/de/unixwork/uwproj/Feature.java Fri Jan 19 20:48:26 2024 +0100 +++ b/src/main/java/de/unixwork/uwproj/Feature.java Fri Jan 19 21:03:34 2024 +0100 @@ -144,7 +144,6 @@ // Prepare the description by replacing some unwanted spaces final var hdesc = desc.trim() .replaceAll("\\r", "") - .replaceAll("\\n", " ") .replaceAll("\\t", " "); // Declare our frame where the description shall be placed @@ -165,6 +164,9 @@ // get the next word and see where we would end int s = hdesc.indexOf(' ', i); if (s < 0) s = hdesc.length(); + int n = hdesc.indexOf('\n', i); + if (n < 0) n = hdesc.length(); + s = Math.min(s, n); int l = s-i; if (x + l > endx) { // does not fit, break into next line @@ -177,11 +179,27 @@ x += l; i += l; // append the next spaces - while (i < hdesc.length() && hdesc.charAt(i) == ' ') { - i++; - x++; - // as long as we don't need to break, add the spaces - if (x < endx) builder.append(' '); + while (i < hdesc.length()) { + int c = hdesc.charAt(i); + if (c == ' ') { + // as long as we don't need to break, add the spaces + i++; + x++; + if (x < endx) builder.append(' '); + } else if (c == '\n') { + // if user wants us to break, comply + i++; + // if we have still space, just move to the end of the line + if (x < endx) { + x = endx; + } else { + // otherwise, we need to add an extra blank line + builder.append('\n'); + } + } else { + // we have found the next word, so continue with the outer loop + break; + } } // break to new line, when spaces moved us outside the frame if (x > endx) { diff -r 1af1bfacd25a -r 4bf47ea3fc64 test/configure2 --- a/test/configure2 Fri Jan 19 20:48:26 2024 +0100 +++ b/test/configure2 Fri Jan 19 21:03:34 2024 +0100 @@ -76,8 +76,11 @@ --toolkit=(gtk3|cli|gtk2|wpf) Optional Features: - --disable-db Needlessly adds a completely useless SQLite - database. + --disable-db Needlessly adds a completely useless SQLite database + by default. + Here another line to test tabs and line + + breaks. --enable-gui __EOF__ diff -r 1af1bfacd25a -r 4bf47ea3fc64 test/make/project2.xml --- a/test/make/project2.xml Fri Jan 19 20:48:26 2024 +0100 +++ b/test/make/project2.xml Fri Jan 19 21:03:34 2024 +0100 @@ -47,8 +47,10 @@ - Needlessly adds a completely - useless SQLite database. + Needlessly adds a completely useless SQLite database by default. + Here another line to test tabs and line + + breaks. sqlite