!7 do not include function list. p-substance { if (l(args) != 0) new Viewer().showFile(new File(join(" ", args))); else inputFilePath("Image to view", voidfunc(File file) { new Viewer().showFile(file) }); } sclass Viewer { ImageSurface is; File file; void showFile(final File file) { assertTrue("File not found: " + absolutePath(file), file.exists()); this.file = file; bool first = is == null; is = showImage_centered(is, file.getName(), loadBufferedImage(file)); awt { is.zoomToWindow(); } if (first) { // will be in AWT pcallF(is.onZoom = r { setFrameTitle(is, Viewer.this.file.getName() + " (" + toint(is.zoomX*100) + "%)") }); // dragger (scroll around by mouse) new ImageSurfaceDragger(is); // register keys registerLeftKey(getFrame(is), r { nextFile(-1) }); registerRightKey(getFrame(is), r { nextFile(1) }); registerMinusKeys(is, r { is.zoomOut(1.5) }); registerPlusKeys(is, r { is.zoomIn(1.5) }); registerKey(is, KeyEvent.VK_A, "A", r { is.setZoom(1.0) }); registerKey(is, KeyEvent.VK_W, "W", r { is.zoomToWindow() }); // fancy componentPopupMenuItem(is, "Run standard function...", r { selectStandardFunction(voidfunc(fS sf) { thread "Calc" { pcall-messagebox { O o = callAndMake(sf, is.getImage()); BufferedImage img = toBufferedImageOpt(o); if (img != null) showImage(sf, img); else infoBox("Result is not an image: " + className(o)); } } }); }); hideConsole(); } } void nextFile(int offset) { L files = asList(sortFilesAlphaNum(listImageFiles(file.getParentFile()))); int i = indexOfPred(files, func(File f) { eq(f.getName(), file.getName()) }); showFile(get(files, mod(i+offset, l(files)))); } }