Libraryless. Click here for Pure Java version (4144L/26K).
1 | // result can be used in coloredTextToTextPane |
2 | static L lineCompedSingleLevelsAsColoredText(LineCompedSingle<Char> lc) {
|
3 | // each matrix element is the symbol starting position for the character+1 (or 0 for empty) |
4 | int[][] rows = renderLineCompedSingleLevels_raw_v2(lc); |
5 | S text = uncompressLineCompedSingle(lc); |
6 | printVars(+rows); |
7 | int n = l(first(rows)); |
8 | new L out; |
9 | forEach(rows, row -> {
|
10 | var color = Color.white; |
11 | out.add(color); |
12 | var lastSymbol = 0; |
13 | for i to n: {
|
14 | if (row[i] == 0) {
|
15 | if (color != Color.white) out.add(color = Color.white); |
16 | lastSymbol = 0; |
17 | out.add(' ');
|
18 | } else {
|
19 | if (row[i] != lastSymbol) {
|
20 | color = color == Color.yellow ? lightBlue() : Color.yellow; |
21 | out.add(color); |
22 | lastSymbol = row[i]; |
23 | } |
24 | out.add(text.charAt(i)); |
25 | } |
26 | } |
27 | out.add("\n");
|
28 | }); |
29 | ret out; |
30 | } |
Began life as a copy of #1031203
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1031206 |
| Snippet name: | lineCompedSingleLevelsAsColoredText |
| Eternal ID of this version: | #1031206/3 |
| Text MD5: | 3c4a4afde7c82925104c3f0c8b428b3b |
| Transpilation MD5: | cc78c266768bfb65676427acc99a2f28 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-05-20 15:28:22 |
| Source code size: | 929 bytes / 30 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 314 / 427 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |