Libraryless. Click here for Pure Java version (8033L/45K).
static S structTokWordWrap(S s) { ret structTokWordWrap(120, s); } // TODO: complete trimming static S structTokWordWrap(int cols, S s) { int col = 0; L<S> tok = structTok(s); for (int i = 0; i < l(tok); i++) { S t = tok.get(i); if (odd(i) && col >= cols && !containsNewLine(t)) tok.set(i, t = rtrimSpaces(t) + "\n"); int idx = t.lastIndexOf('\n'); if (idx >= 0) col = l(t)-(idx+1); else col += l(t); } ret join(tok); }
Began life as a copy of #1005532
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1035410 |
| Snippet name: | structTokWordWrap - word-wrap a structure string |
| Eternal ID of this version: | #1035410/1 |
| Text MD5: | 343576267b7a4f970d560a2803acb2a0 |
| Transpilation MD5: | 284964398f68fe2fdd0abb3bb8b1f908 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-05-06 16:01:09 |
| Source code size: | 475 bytes / 18 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 376 / 479 |
| Referenced in: | [show references] |