static new ThreadLocal ai_tokenizationToTextPane_charsWritten; static JTextPane ai_tokenizationToTextPane(LS tok) { ret ai_tokenizationToTextPane(fontSizePlus(7, jtextpane()), tok); } static JTextPane ai_tokenizationToTextPane(JTextPane tp, LS tok) { bool spaced = true; int chars = 0; for i over tok: { if (!spaced) { appendToTextPane(tp, " "); ++chars; spaced = true; } S t = tok.get(i); if (empty(t)) continue; SimpleAttributeSet style; if (odd(i)) // C token style = style_background(Color.yellow, style_foreground(Color.black)); else // N token (whitespace) style = style_foreground(Color.gray, style_background(colorFromHex("#E0E0E0"))); appendToTextPane(tp, t, style); chars += l(t); spaced = false; } setTL(ai_tokenizationToTextPane_charsWritten, chars); ret tp; }