static S javaTokWordWrap(S s) { ret javaTokWordWrap(120, s); } // TODO: complete trimming static S javaTokWordWrap(int cols, S s) { int col = 0; L<S> tok = javaTok(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); }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney
No comments. add comment
Snippet ID: | #1005532 |
Snippet name: | javaTokWordWrap - word-wrap a text preserving javaTok tokens |
Eternal ID of this version: | #1005532/4 |
Text MD5: | 5f44e074f27482ca3f68b3ce05d27abf |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-05-07 17:19:36 |
Source code size: | 467 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 659 / 703 |
Version history: | 3 change(s) |
Referenced in: | [show references] |