History

plan9: rename ptfield to ptclamp

Sigrid Haflínudóttir committed 6 years ago

Commit a5a88b01 parent b65c1671 file · +24 −6Browse files

Unified · Split

plan9.c+24−6
@@ -623,7 +623,7 @@ selpaste(void) · 622 unmodified lines
623623 }
624624
625625 static Point
626−ptfield(Point p)
626+ptclamp(Point p)
627627 {
628628 p.x = MAX(0, MIN((int)field.width-1, p.x));
629629 p.y = MAX(0, MIN((int)field.height-1, p.y));
@@ -636,9 +636,9 @@ curmove(int x, int y) · 6 unmodified lines
636636 Point xy;
637637
638638 xy = Pt(x, y);
639− cur = ptfield(addpt(cur, xy));
640− sel.min = ptfield(addpt(sel.min, xy));
641− sel.max = ptfield(addpt(sel.max, xy));
639+ cur = ptclamp(addpt(cur, xy));
640+ sel.min = ptclamp(addpt(sel.min, xy));
641+ sel.max = ptclamp(addpt(sel.max, xy));
642642 }
643643
644644 static void
@@ -799,6 +799,13 @@ selext(int xdt, int ydt) · 154 unmodified lines
799799 sel.max.y = MAX(0, MIN((int)field.height-1, sel.max.y));
800800 }
801801
802+static void
803+usage(void)
804+{
805+ print("usage: %s [-b]\n", argv0);
806+ threadexitsall("usage");
807+}
808+
802809 void
803810 threadmain(int argc, char **argv)
804811 {
@@ -808,6 +815,7 @@ threadmain(int argc, char **argv) · 3 unmodified lines
808815 Mouse m;
809816 char tmp[256];
810817 int oldw, oldh, w, h, n;
818+ bool inverse;
811819 int movex, movey;
812820 bool shiftdown, complete, ctldown;
813821 Alt a[Numchan+1] = {
@@ -819,7 +827,14 @@ threadmain(int argc, char **argv) · 5 unmodified lines
819827 { nil, nil, CHANEND },
820828 };
821829
822− USED(argc, argv);
830+ inverse = false;
831+ ARGBEGIN{
832+ case 'b':
833+ inverse = true;
834+ break;
835+ default:
836+ usage();
837+ }ARGEND
823838
824839 srand(time(0));
825840 threadsetname("orca/draw");
@@ -839,8 +854,11 @@ threadmain(int argc, char **argv) · 13 unmodified lines
839854 proccreate(kbdproc, a[Ckey].c, mainstacksize);
840855 kctl.c = cchan;
841856
842− for (n = 0; n < Numcolors; n++)
857+ for (n = 0; n < Numcolors; n++) {
858+ if (inverse)
859+ theme[n] = ~theme[n] | 0xff;
843860 color[n] = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, setalpha(theme[n] & ~0xff, theme[n] & 0xff));
861+ }
844862 glyphsz.x = stringwidth(font, "X");
845863 glyphsz.y = font->height;
846864

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t