1 | sclass _PrintFlexIndent extends F1<S, Bool> { |
2 | F1<S, S> makeIndent; |
3 | bool beginningOfLine = true; |
4 | |
5 | *() {} |
6 | *(F1<S, S> *makeIndent) {} |
7 | |
8 | Bool get(S s) { |
9 | if (empty(s)) false; |
10 | S prefix = null; |
11 | if (beginningOfLine) { |
12 | if (prefix == null) prefix = unnull(callF(makeIndent, s)); |
13 | print_raw(prefix); |
14 | } |
15 | bool nl = s.endsWith("\n"); |
16 | if (nl) s = dropLast(s); |
17 | if (contains(s, '\n')) { |
18 | if (prefix == null) prefix = unnull(callF(makeIndent, s)); |
19 | if (nempty(prefix)) s = s.replace("\n", "\n" + prefix); |
20 | } |
21 | print_raw(s); |
22 | if (nl) print_raw("\n"); |
23 | beginningOfLine = nl; |
24 | false; |
25 | } |
26 | } |
Began life as a copy of #1008514
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1012700 |
Snippet name: | _PrintFlexIndent |
Eternal ID of this version: | #1012700/3 |
Text MD5: | 9b9fce834dd8ea450e985241c11b36fb |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-12-10 17:35:36 |
Source code size: | 668 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 428 / 1015 |
Version history: | 2 change(s) |
Referenced in: | [show references] |