@@ 441,6 441,7 @@ quit(void)
void
domouse(SDL_Event *event)
{
+ int ctrl = SDL_GetModState() & KMOD_LCTRL || SDL_GetModState() & KMOD_RCTRL;
switch(event->type) {
case SDL_MOUSEBUTTONUP:
if(event->button.button == SDL_BUTTON_LEFT)
@@ 461,10 462,11 @@ domouse(SDL_Event *event)
line(brush.px, brush.py, screenpos(event->motion.x, brush.vx), screenpos(event->motion.y, brush.vy), brush.erase ? 0 : brush.color);
brush.px = screenpos(event->motion.x, brush.vx);
brush.py = screenpos(event->motion.y, brush.vy);
- if(!BIGPIXEL) {
+ if(!BIGPIXEL)
lookat((brush.px / 8) * 8, (brush.py / 8) * 8);
- }
- if(brush.down) {
+ if(ctrl) /* color picker */
+ savemode(&brush.color, getchr(brush.px, brush.py));
+ else if(brush.down) {
if(brush.mode == 0)
putchr(brush.px, brush.py, brush.erase ? 0 : brush.color);
else
@@ 476,7 478,9 @@ domouse(SDL_Event *event)
if(brush.down) {
brush.x = screenpos(event->motion.x, brush.vx);
brush.y = screenpos(event->motion.y, brush.vy);
- if(!brush.mode)
+ if(ctrl) /* color picker */
+ savemode(&brush.color, getchr(brush.px, brush.py));
+ else if(!brush.mode)
line(brush.px, brush.py, brush.x, brush.y, brush.erase ? 0 : brush.color);
else
fill(brush.x, brush.y, brush.mode, brush.size, brush.erase ? 0 : brush.color);
@@ 515,7 519,6 @@ dokey(SDL_Event *event)
case SDLK_b: savemode(&BIGPIXEL, !BIGPIXEL); break;
case SDLK_z: savemode(&brush.size, brush.size + (brush.size > 1 ? -1 : 0)); break;
case SDLK_x: savemode(&brush.size, brush.size + (brush.size < 30 ? 1 : 0)); break;
-
case SDLK_UP: lookat(brush.vx, brush.vy - 1); break;
case SDLK_DOWN: lookat(brush.vx, brush.vy + 1); break;
case SDLK_LEFT: lookat(brush.vx - 1, brush.vy); break;