ref: 120c11d47e0505a831c68d146869cf872c648c60
parent: d209801c8cf1e45950557b9fcff09a826f6c6030
author: phil9 <[email protected]>
date: Fri Nov 19 16:24:06 EST 2021
allow running view without loading any image make the image command line argument optional
--- a/view.c
+++ b/view.c
@@ -107,7 +107,8 @@
{
lockdisplay(display);
draw(screen, screen->r, bg, nil, ZP);
- draw(screen, rectaddpt(img->r, addpt(pos, screen->r.min)), img, nil, img->r.min);
+ if(img != nil)
+ draw(screen, rectaddpt(img->r, addpt(pos, screen->r.min)), img, nil, img->r.min);
flushimage(display, 1);
unlockdisplay(display);
}
@@ -117,6 +118,8 @@
{
Rectangle r, ir;
+ if(img == nil)
+ return;
if(Δ.x == 0 && Δ.y == 0)
return;
r = rectaddpt(img->r, addpt(pos, screen->r.min));
@@ -243,7 +246,12 @@
{ nil, nil, CHANEND },
};
- ARGBEGIN{}ARGEND;
+ img = nil;
+ ARGBEGIN{
+ default:
+ usage();
+ break;
+ }ARGEND;
if(argc > 1)
usage();
if(initdraw(nil, nil, argv0) < 0)
@@ -262,8 +270,10 @@
alts[Eplumb].c = plumbc;
initbg();
proccreate(plumbproc, plumbc, 8192);
- img = load(*argv);
- pos = subpt(ZP, img->r.min);
+ if(*argv != nil){
+ img = load(*argv);
+ pos = subpt(ZP, img->r.min);
+ }
evtresize(0);
for(;;){
switch(alt(alts)){