Libraryless. Click here for Pure Java version (2238L/14K).
1 | sclass _SubModulePrint implements Appendable { |
2 | S prefix; |
3 | bool beginningOfLine = true; |
4 | |
5 | *() {} |
6 | *(S *prefix) {} |
7 | |
8 | public Appendable append(char c) { ret append(str(c)); } |
9 | public Appendable append(CharSequence csq, int start, int end) { ret append(csq.subSequence(start, end)); } |
10 | |
11 | public Appendable append(CharSequence csq) { |
12 | S s = str(csq); |
13 | if (empty(s)) this; |
14 | if (beginningOfLine) print_raw(makePrefix()); |
15 | bool nl = s.endsWith("\n"); |
16 | if (nl) s = dropLast(s); |
17 | if (nempty(prefix) && contains(s, '\n')) |
18 | s = s.replace("\n", "\n" + prefix); |
19 | print_raw(s); |
20 | if (nl) print_raw("\n"); |
21 | beginningOfLine = nl; |
22 | this; |
23 | } |
24 | |
25 | swappable S makePrefix() { ret prefix; } |
26 | } |
Began life as a copy of #1012700
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1016665 |
Snippet name: | _SubModulePrint |
Eternal ID of this version: | #1016665/3 |
Text MD5: | 6aa64cafda2d7761eb6bbe86a6691f91 |
Transpilation MD5: | 4322fa5f75f0451250ee95f8fe538641 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-01-18 17:37:02 |
Source code size: | 743 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 372 / 996 |
Version history: | 2 change(s) |
Referenced in: | [show references] |