Libraryless. Click here for Pure Java version (3826L/25K/87K).
1 | !752 |
2 | |
3 | !include #1004828 // Java Analysis |
4 | |
5 | static new JTextArea infoArea; |
6 | |
7 | p { |
8 | loadConceptsFrom("#1004820"); |
9 | SSnippet snippet = conceptOfType(SSnippet.class); |
10 | L<Substring> substrings = sortedByField(findBackRefs(snippet, Substring.class), "startIndex"); |
11 | print("substrings: " + l(substrings)); |
12 | new StringBuilder buf; |
13 | int i = 0, iCol = 0; |
14 | for (Substring s : substrings) { |
15 | //print("s/e= " + s.startIndex + "/" + s.endIndex); |
16 | buf.append(htmlencode(substring(snippet.text, i, s.startIndex))); |
17 | S col = odd(iCol++) |
18 | //? "#b8d1f3" : "#dae5f4"; |
19 | ? "#CC0000" : "#0000CC"; // Coder Colors! |
20 | buf.append(span(b(href(str(s.id), htmlencode(s.text()))), "style", "color: " + col)); |
21 | i = s.endIndex; |
22 | } |
23 | buf.append(htmlencode(substring(snippet.text, i))); |
24 | |
25 | S html = hhtml(pre(buf)); |
26 | JEditorPane editorPane = new JEditorPane("text/html", html); |
27 | editorPane.setEditable(false); |
28 | editorPane.addHyperlinkListener(new HyperlinkListener { |
29 | public void hyperlinkUpdate(HyperlinkEvent e) { |
30 | S link = e.getDescription(); |
31 | HyperlinkEvent.EventType type = e.getEventType(); |
32 | |
33 | //print("Event! " + e.getEventType() + " " + link); |
34 | |
35 | if (type == HyperlinkEvent.EventType.ENTERED) |
36 | showInfo(link); |
37 | else if (type == HyperlinkEvent.EventType.EXITED) |
38 | showInfo(null); |
39 | } |
40 | }); |
41 | showFrame(vgrid(editorPane, infoArea)); |
42 | } |
43 | |
44 | static void showInfo(S id) { |
45 | new StringBuilder buf; |
46 | Concept c = getConcept(id); |
47 | if (c != null) { |
48 | buf.append(shortClassName(c)); |
49 | if (c instanceof Substring) |
50 | buf.append(" " + quote(((Substring) c).text())); |
51 | } |
52 | infoArea.setText(str(buf)); |
53 | infoArea.setCaretPosition(0); |
54 | } |
Began life as a copy of #1004829
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004836 |
Snippet name: | Show Tokens |
Eternal ID of this version: | #1004836/1 |
Text MD5: | 74049aca8993a32aaedd52c1c4d235e8 |
Transpilation MD5: | 8e224104d3f5dfb9d577b3c987389496 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-09-05 15:28:23 |
Source code size: | 1741 bytes / 54 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 622 / 739 |
Referenced in: | [show references] |