!7 static JFrame frame; static S imageMD5, text; sS title = "AI Clipboard"; p-substance { framesBot(); frame = showFrame(title); // TODO: update less often if a non-text is in clipboard installTimer(frame, 1000, 0, r { update(); }); hideConsoleIfMainProgram(); } svoid update { BufferedImage img = getImageFromClipboard(); if (img != null) { S md5 = md5OfRGBImage(new RGBImage(img)); if (neq(md5, imageMD5)) { imageMD5 = md5; text = null; setFrameContents(frame, jscroll(new ImageSurface(img))); setFrameTitle(frame, title + ": " + img.getWidth() + "*" + img.getHeight() + " px image"); } ret; } imageMD5 = null; S s = getTextFromClipboard(); if (s != null) { if (neq(text, s)) { text = s; JComponent x = explainText(s); JTextArea ta = typeWriterTextArea(s); setFrameContents(frame, x != null ? vsplit(x, ta) : ta); setFrameTitle(frame, title + ": " + quote(escapeNewLines(shorten(s, 256)))); } ret; } text = null; // empty clipboard or unknown contents setFrameContents(frame, new JPanel); Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); setFrameTitle(frame, transferable != null ? "Unknown clipboard contents (" + join(", ", mimeTypes(transferable)) + ")" : "Empty clipboard"); } static JComponent explainText(S s) null on exception { Collection ids = collectPossibleGlobalIDs(s); if (empty(ids)) null; new L l; aiConceptsMap_clearCache(60); for (S id : ids) { S name = conceptToName(id); if (neq(id, name)) l.add(id + " = " + name); } if (empty(l)) null; ret makeBold(jTextArea(lines(l))); }