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
623}623}
624 624
625static Point625static Point
626ptfield(Point p)626ptclamp(Point p)
627{627{
628 p.x = MAX(0, MIN((int)field.width-1, p.x));628 p.x = MAX(0, MIN((int)field.width-1, p.x));
629 p.y = MAX(0, MIN((int)field.height-1, p.y));629 p.y = MAX(0, MIN((int)field.height-1, p.y));
@@ -636,9 +636,9 @@ curmove(int x, int y) · 6 unmodified lines
636 Point xy;636 Point xy;
637 637
638 xy = Pt(x, y);638 xy = Pt(x, y);
639 cur = ptfield(addpt(cur, xy));639 cur = ptclamp(addpt(cur, xy));
640 sel.min = ptfield(addpt(sel.min, xy));640 sel.min = ptclamp(addpt(sel.min, xy));
641 sel.max = ptfield(addpt(sel.max, xy));641 sel.max = ptclamp(addpt(sel.max, xy));
642}642}
643 643
644static void644static void
@@ -799,6 +799,13 @@ selext(int xdt, int ydt) · 154 unmodified lines
799 sel.max.y = MAX(0, MIN((int)field.height-1, sel.max.y));799 sel.max.y = MAX(0, MIN((int)field.height-1, sel.max.y));
800}800}
801 801
802static void
803usage(void)
804{
805 print("usage: %s [-b]\n", argv0);
806 threadexitsall("usage");
807}
808
802void809void
803threadmain(int argc, char **argv)810threadmain(int argc, char **argv)
804{811{
@@ -808,6 +815,7 @@ threadmain(int argc, char **argv) · 3 unmodified lines
808 Mouse m;815 Mouse m;
809 char tmp[256];816 char tmp[256];
810 int oldw, oldh, w, h, n;817 int oldw, oldh, w, h, n;
818 bool inverse;
811 int movex, movey;819 int movex, movey;
812 bool shiftdown, complete, ctldown;820 bool shiftdown, complete, ctldown;
813 Alt a[Numchan+1] = {821 Alt a[Numchan+1] = {
@@ -819,7 +827,14 @@ threadmain(int argc, char **argv) · 5 unmodified lines
819 { nil, nil, CHANEND },827 { nil, nil, CHANEND },
820 };828 };
821 829
822 USED(argc, argv);830 inverse = false;
831 ARGBEGIN{
832 case 'b':
833 inverse = true;
834 break;
835 default:
836 usage();
837 }ARGEND
823 838
824 srand(time(0));839 srand(time(0));
825 threadsetname("orca/draw");840 threadsetname("orca/draw");
@@ -839,8 +854,11 @@ threadmain(int argc, char **argv) · 13 unmodified lines
839 proccreate(kbdproc, a[Ckey].c, mainstacksize);854 proccreate(kbdproc, a[Ckey].c, mainstacksize);
840 kctl.c = cchan;855 kctl.c = cchan;
841 856
842 for (n = 0; n < Numcolors; n++)857 for (n = 0; n < Numcolors; n++) {
858 if (inverse)
859 theme[n] = ~theme[n] | 0xff;
843 color[n] = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, setalpha(theme[n] & ~0xff, theme[n] & 0xff));860 color[n] = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, setalpha(theme[n] & ~0xff, theme[n] & 0xff));
861 }
844 glyphsz.x = stringwidth(font, "X");862 glyphsz.x = stringwidth(font, "X");
845 glyphsz.y = font->height;863 glyphsz.y = font->height;
846 864

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