Warning: session_start(): open(/var/lib/php/sessions/sess_cmssem57fr6894862sm3f0sril, 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
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
addPopupMenuItem(is, "Run standard function", r {
selectStandardFunction(voidfunc(fS sf) {
thread "Calc" {
O o = callAndMake(sf, is.getImage());
BufferedImage img = toBufferedImageOpt(o);
if (img != null)
showImage(sf, img);
}
});
});
hideConsole();
}
}
void nextFile(int offset) {
L files = asList(listFilesOnly(file.getParentFile()));
int i = indexOfPred(files, func(File f) { eq(f.getName(), file.getName()) });
showFile(get(files, mod(i+offset, l(files))));
}
}