Skip to content

Commit

Permalink
Merge pull request #6053 from IllianiCBT/wordWrap_html
Browse files Browse the repository at this point in the history
Enhance `wordWrap` with HTML Tags for Line Breaks
  • Loading branch information
HammerGS authored Oct 4, 2024
2 parents fd25189 + bc96356 commit 181bca3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion megamek/src/megamek/client/ui/WrapLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,22 @@ public static String wordWrap(String input) {
public static String wordWrap(String input, int maximumCharacters) {
StringTokenizer token = new StringTokenizer(input, " ");
StringBuilder output = new StringBuilder(input.length());
output.append("<html>");

int lineLen = 0;

while (token.hasMoreTokens()) {
String word = token.nextToken();

if (lineLen + word.length() > maximumCharacters) {
output.append('\n');
output.append("<br>");
lineLen = 0;
}
output.append(word).append(' ');
lineLen += word.length();
}

output.append("</html>");
return output.toString();
}
}

0 comments on commit 181bca3

Please sign in to comment.