Libraryless. Click here for Pure Java version (3826L/25K/87K).
!752 !include #1004828 // Java Analysis static new JTextArea infoArea; p { loadConceptsFrom("#1004820"); SSnippet snippet = conceptOfType(SSnippet.class); L<Substring> substrings = sortedByField(findBackRefs(snippet, Substring.class), "startIndex"); print("substrings: " + l(substrings)); new StringBuilder buf; int i = 0, iCol = 0; for (Substring s : substrings) { //print("s/e= " + s.startIndex + "/" + s.endIndex); buf.append(htmlencode(substring(snippet.text, i, s.startIndex))); S col = odd(iCol++) //? "#b8d1f3" : "#dae5f4"; ? "#CC0000" : "#0000CC"; // Coder Colors! buf.append(span(b(href(str(s.id), htmlencode(s.text()))), "style", "color: " + col)); i = s.endIndex; } buf.append(htmlencode(substring(snippet.text, i))); S html = hhtml(pre(buf)); JEditorPane editorPane = new JEditorPane("text/html", html); editorPane.setEditable(false); editorPane.addHyperlinkListener(new HyperlinkListener { public void hyperlinkUpdate(HyperlinkEvent e) { S link = e.getDescription(); HyperlinkEvent.EventType type = e.getEventType(); //print("Event! " + e.getEventType() + " " + link); if (type == HyperlinkEvent.EventType.ENTERED) showInfo(link); else if (type == HyperlinkEvent.EventType.EXITED) showInfo(null); } }); showFrame(vgrid(editorPane, infoArea)); } static void showInfo(S id) { new StringBuilder buf; Concept c = getConcept(id); if (c != null) { buf.append(shortClassName(c)); if (c instanceof Substring) buf.append(" " + quote(((Substring) c).text())); } infoArea.setText(str(buf)); infoArea.setCaretPosition(0); }
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: | 623 / 741 |
Referenced in: | #1004837 - Test Loading Unknown Concepts [WORKS] |