Warning: session_start(): open(/var/lib/php/sessions/sess_6rrmoe2p26vogu1i2ul6d83juk, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
static JFrame frame;
static S imageMD5, text;
p-substance {
frame = showFrame("Clipboard");
// 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, "Clipboard: " + 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(ta, x) : ta);
setFrameTitle(frame, "Clipboard: " + 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 typeWriterTextArea(lines(l));
}