ref: a5a88b06fa49cfec4d244db55196dbafd35e3f5f
parent: b65c16714cdd1b11a7cad2e416986e3ffcaa7838
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Feb 17 08:42:48 EST 2020
plan9: rename ptfield to ptclamp
--- a/plan9.c
+++ b/plan9.c
@@ -623,7 +623,7 @@
}
static Point
-ptfield(Point p)
+ptclamp(Point p)
{
p.x = MAX(0, MIN((int)field.width-1, p.x));
p.y = MAX(0, MIN((int)field.height-1, p.y));
@@ -636,9 +636,9 @@
Point xy;
xy = Pt(x, y);
- cur = ptfield(addpt(cur, xy));
- sel.min = ptfield(addpt(sel.min, xy));
- sel.max = ptfield(addpt(sel.max, xy));
+ cur = ptclamp(addpt(cur, xy));
+ sel.min = ptclamp(addpt(sel.min, xy));
+ sel.max = ptclamp(addpt(sel.max, xy));
}
static void
@@ -799,6 +799,13 @@
sel.max.y = MAX(0, MIN((int)field.height-1, sel.max.y));
}
+static void
+usage(void)
+{
+ print("usage: %s [-b]\n", argv0);
+ threadexitsall("usage");
+}
+
void
threadmain(int argc, char **argv)
{
@@ -808,6 +815,7 @@
Mouse m;
char tmp[256];
int oldw, oldh, w, h, n;
+ bool inverse;
int movex, movey;
bool shiftdown, complete, ctldown;
Alt a[Numchan+1] = {
@@ -819,7 +827,14 @@
{ nil, nil, CHANEND },
};
- USED(argc, argv);
+ inverse = false;
+ ARGBEGIN{
+ case 'b':
+ inverse = true;
+ break;
+ default:
+ usage();
+ }ARGEND
srand(time(0));
threadsetname("orca/draw");
@@ -839,8 +854,11 @@
proccreate(kbdproc, a[Ckey].c, mainstacksize);
kctl.c = cchan;
- for (n = 0; n < Numcolors; n++)
+ for (n = 0; n < Numcolors; n++) {
+ if (inverse)
+ theme[n] = ~theme[n] | 0xff;
color[n] = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, setalpha(theme[n] & ~0xff, theme[n] & 0xff));
+ }
glyphsz.x = stringwidth(font, "X");
glyphsz.y = font->height;