History

switch buttons, move menu options, add "exit" menu option

Sigrid Haflínudóttir committed 6 years ago

Commit 6dac36c1 parent 2dc7bd12 files · +15 −13Browse files

Unified · Split

2 files
  1. picker.c +12 −10
  2. picker.man +3 −3
picker.c+12−10
@@ -109,10 +109,7 @@ static Space spaces[] = { · 108 unmodified lines
109109 },
110110 };
111111
112−static char *menu2i[nelem(spaces)+3] = {
113− "snarf",
114− "snarf all",
115−};
112+static char *menu2i[nelem(spaces)+4];
116113 static Menu menu2 = { .item = menu2i };
117114
118115 static Color *colors;
@@ -396,7 +393,10 @@ threadmain(int argc, char **argv) · 277 unmodified lines
396393 }
397394
398395 for (i = 0; i < nelem(spaces); i++)
399− menu2i[i+2] = spaces[i].name;
396+ menu2i[i] = spaces[i].name;
397+ menu2i[i++] = "snarf";
398+ menu2i[i++] = "snarf all";
399+ menu2i[i] = "exit";
400400
401401 if (initdraw(nil, nil, "picker") < 0)
402402 sysfatal("initdraw: %r");
@@ -466,9 +466,11 @@ changed: · 63 unmodified lines
466466 goto next;
467467 }
468468 }
469− } else if (m.buttons == 2 && (i = menuhit(2, mctl, &menu2, nil)) >= 0) {
470− if (i >= 2) {
471− space = &spaces[i-2];
469+ } else if (m.buttons == 4 && (i = menuhit(3, mctl, &menu2, nil)) >= 0) {
470+ if (i == nelem(spaces)+2)
471+ goto end;
472+ if (i < nelem(spaces)) {
473+ space = &spaces[i];
472474 space->fromrgb(c->rgba, c->v);
473475 for (i = 0; i < 3; i++)
474476 c->v[i] = MAX(0.0, MIN(space->max[i], c->v[i]));
@@ -477,7 +479,7 @@ changed: · 2 unmodified lines
477479
478480 int f;
479481 if ((f = open("/dev/snarf", OWRITE)) >= 0) {
480− if (i == 0) {
482+ if (i == nelem(spaces)) {
481483 write(f, hex, strlen(hex));
482484 } else {
483485 for (i = 0; i < ncolors; i++) {
@@ -488,7 +490,7 @@ changed: · 4 unmodified lines
488490 }
489491 close(f);
490492 }
491− } else if (m.buttons == 4) {
493+ } else if (m.buttons == 2) {
492494 strcpy(buf, hex);
493495 if (enter(nchan < 4 ? "rgb:" : "rgba:", buf, sizeof(buf), mctl, kctl, nil) > 0) {
494496 u = c->u;
picker.man+3−3
@@ -32,8 +32,8 @@ in · 31 unmodified lines
3232 .I RGBA
3333 mode.
3434 .PP
35−Different color spaces are provided and accessible through middle
36−button menu, or as command line arguments:
35+Different color spaces are accessible through right button menu, or as
36+command line arguments:
3737 .TP
3838 .B -s
3939 HSLuv.
@@ -45,7 +45,7 @@ HPLuv. · 5 unmodified lines
4545 RGB.
4646 .PP
4747 Switching between palette can be done by either a mouse click, or
48−left/right arrows on the keyboard. With the right button click you
48+left/right arrows on the keyboard. With the middle button click you
4949 can enter color as
5050 .I RGB(A)
5151 manually.

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