public LineWrapper append(CharSequence cs) {
			Mode mode = Mode.INIT;
			int b = 0;
			for (int f = 0; f < cs.length(); f++) {
				char c = cs.charAt(f);
				if (c == '\n') {
					if (mode == Mode.SPACE) {
						appendSpace(cs.subSequence(b, f));
					}
					else if (mode == Mode.WORD) {
						appendWord(cs.subSequence(b, f));
					}
					mode = Mode.INIT;
					appendLinesep();
					b = f + 1;
				}
				else if (Character.isWhitespace(c)) {
					if (mode == Mode.WORD) {
						appendWord(cs.subSequence(b, f));
						b = f;
					}
					mode = Mode.SPACE;
				}
				else {
					if (mode == Mode.SPACE) {
						appendSpace(cs.subSequence(b, f));
						b = f;
					}
					mode = Mode.WORD;
				}
			}
			if (mode == Mode.WORD) {
				appendWord(cs.subSequence(b, cs.length()));
			}
			else if (mode == Mode.SPACE) {
				appendSpace(cs.subSequence(b, cs.length()));
			}
			return this;
		}
About the worst way to wrap lines ever
Ghidra/Framework/Generic/src/main/java/ghidra/util/StringUtilities.java