Uses 108K of libraries. Click here for Pure Java version (16089L/113K).
!7 sclass ClipboardContents > DynSCP { S imageMD5, text; JComponent visualize() { ret awtEvery(super.visualize(), 3000, 0, r actualUpdate); } void actualUpdate { temp enter(); Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); S mimeTypes = joinWithNewLine(mimeTypes(transferable)); L<File> f = getFilesFromClipboard(); if (nempty(f)) { S s = lines(map f2s(f)); if (eq(s, getText(componentOfType(JTextArea, getComponent())))) ret; setModuleName("Clipboard: " + n2(f, "file")); setComponent(typeWriterTextArea(s)); ret; } BufferedImage img = getImageFromClipboard(); if (img != null) { S md5 = md5OfRGBImage(new RGBImage(img)); if (neq(md5, imageMD5)) { setFields(imageMD5 := md5, text := null); setComponent(scrollableImageSurface(img)); setModuleName("Clipboard: " + img.getWidth() + "*" + img.getHeight() + " px image"); } ret; } setField(imageMD5 := null); S s = getTextFromClipboard(); if (s != null) { if (neq(text, s)) { setField(text := s); setComponent(typeWriterTextArea(mimeTypes + "\n\n" + s)); setModuleName("Clipboard: " + quote(escapeNewLines(shorten(s, 256)))); } ret; } setField(text := null); // empty clipboard or unknown contents setComponent(jpanel()); setModuleName(transferable != null ? "Unknown clipboard contents (" + mimeTypes + ")" : "Empty clipboard"); } }
Began life as a copy of #1006099
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016902 |
Snippet name: | Clipboard Contents [Dyn Module] |
Eternal ID of this version: | #1016902/10 |
Text MD5: | 4b7a3c32f2bf9c6cd8840b3323be6086 |
Transpilation MD5: | e85a1177774cf62eadfd1e9c1f126fbf |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-27 12:37:36 |
Source code size: | 1626 bytes / 56 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 414 / 996 |
Version history: | 9 change(s) |
Referenced in: | -