From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from wopr.sciops.net ([216.126.196.60]) by ewsd; Sun Jan 20 02:00:53 EST 2019 Received: (qmail 5566 invoked from network); 19 Jan 2019 23:00:44 -0800 Received: from 104.225.154.77.rev.sfr.net (HELO u25.nope) (qwx@77.154.225.104) by wopr.sciops.net with SMTP; 19 Jan 2019 23:00:44 -0800 Message-ID: <9DBA1EB8F5E3CD30FEB84CB69627F0F1@wopr.sciops.net> From: qwx Date: Sun, 20 Jan 2019 08:00:44 +0100 To: 9front@9front.org Subject: paint(1) color picker MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: extension injection dependency-oriented generator Hello, I wrote a patch for paint(1) allowing one to change a palette color by clicking on it with mouse button 3. I know it's sacrilegious to touch the c64 palette, but it's been useful. I'd like to push this. What do you think? Thanks, qwx diff -r eb26bc92b777 sys/src/cmd/paint.c --- a/sys/src/cmd/paint.c Sun Jan 13 17:17:11 2019 +0100 +++ b/sys/src/cmd/paint.c Sun Jan 20 07:54:13 2019 +0100 @@ -523,9 +523,12 @@ return 1; } if(ptinrect(m.xy, palr)){ + int i, n; + char buf[32]; Image *col; - col = pal[(m.xy.x - palr.min.x) * nelem(pal) / Dx(palr)]; + i = (m.xy.x - palr.min.x) * nelem(pal) / Dx(palr); + col = pal[i]; switch(m.buttons & 7){ case 1: ink = col; @@ -536,6 +539,17 @@ drawpal(); update(nil); break; + case 4: + buf[0] = 0; + if(eenter("Color", buf, sizeof(buf), &m) <= 0) + break; + n = strtol(buf, nil, 0); + freeimage(pal[i]); + pal[i] = allocimage(display, Rect(0, 0, 1, 1), RGB24, 1, n << 8 | 0xFF); + if(pal[i] == nil) + sysfatal("allocimage: %r"); + drawpal(); + break; } return 1; }