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
109 },109 },
110};110};
111 111
112static char *menu2i[nelem(spaces)+3] = {112static char *menu2i[nelem(spaces)+4];
113 "snarf",
114 "snarf all",
115};
116static Menu menu2 = { .item = menu2i };113static Menu menu2 = { .item = menu2i };
117 114
118static Color *colors;115static Color *colors;
@@ -396,7 +393,10 @@ threadmain(int argc, char **argv) · 277 unmodified lines
396 }393 }
397 394
398 for (i = 0; i < nelem(spaces); i++)395 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";
400 400
401 if (initdraw(nil, nil, "picker") < 0)401 if (initdraw(nil, nil, "picker") < 0)
402 sysfatal("initdraw: %r");402 sysfatal("initdraw: %r");
@@ -466,9 +466,11 @@ changed: · 63 unmodified lines
466 goto next;466 goto next;
467 }467 }
468 }468 }
469 } else if (m.buttons == 2 && (i = menuhit(2, mctl, &menu2, nil)) >= 0) {469 } else if (m.buttons == 4 && (i = menuhit(3, mctl, &menu2, nil)) >= 0) {
470 if (i >= 2) {470 if (i == nelem(spaces)+2)
471 space = &spaces[i-2];471 goto end;
472 if (i < nelem(spaces)) {
473 space = &spaces[i];
472 space->fromrgb(c->rgba, c->v);474 space->fromrgb(c->rgba, c->v);
473 for (i = 0; i < 3; i++)475 for (i = 0; i < 3; i++)
474 c->v[i] = MAX(0.0, MIN(space->max[i], c->v[i]));476 c->v[i] = MAX(0.0, MIN(space->max[i], c->v[i]));
@@ -477,7 +479,7 @@ changed: · 2 unmodified lines
477 479
478 int f;480 int f;
479 if ((f = open("/dev/snarf", OWRITE)) >= 0) {481 if ((f = open("/dev/snarf", OWRITE)) >= 0) {
480 if (i == 0) {482 if (i == nelem(spaces)) {
481 write(f, hex, strlen(hex));483 write(f, hex, strlen(hex));
482 } else {484 } else {
483 for (i = 0; i < ncolors; i++) {485 for (i = 0; i < ncolors; i++) {
@@ -488,7 +490,7 @@ changed: · 4 unmodified lines
488 }490 }
489 close(f);491 close(f);
490 }492 }
491 } else if (m.buttons == 4) {493 } else if (m.buttons == 2) {
492 strcpy(buf, hex);494 strcpy(buf, hex);
493 if (enter(nchan < 4 ? "rgb:" : "rgba:", buf, sizeof(buf), mctl, kctl, nil) > 0) {495 if (enter(nchan < 4 ? "rgb:" : "rgba:", buf, sizeof(buf), mctl, kctl, nil) > 0) {
494 u = c->u;496 u = c->u;
picker.man+3−3
@@ -32,8 +32,8 @@ in · 31 unmodified lines
32.I RGBA32.I RGBA
33mode.33mode.
34.PP34.PP
35Different color spaces are provided and accessible through middle35Different color spaces are accessible through right button menu, or as
36button menu, or as command line arguments:36command line arguments:
37.TP37.TP
38.B -s38.B -s
39HSLuv.39HSLuv.
@@ -45,7 +45,7 @@ HPLuv. · 5 unmodified lines
45RGB.45RGB.
46.PP46.PP
47Switching between palette can be done by either a mouse click, or47Switching between palette can be done by either a mouse click, or
48left/right arrows on the keyboard. With the right button click you48left/right arrows on the keyboard. With the middle button click you
49can enter color as49can enter color as
50.I RGB(A)50.I RGB(A)
51manually.51manually.

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