modified: ../bin/color
modified: color.c
This commit is contained in:
parent
ee39e60edd
commit
6b16f4a8ad
29
src/color.c
29
src/color.c
@ -13,8 +13,6 @@
|
||||
|
||||
int add_color(update_info *color, int key) {
|
||||
XFreeColors(color->display, color->colormap, &color->background.pixel, 1, 0);
|
||||
XFreeColors(color->display, color->colormap, &color->foreground.pixel, 1, 0);
|
||||
printf("%i\n", color->channel_step);
|
||||
switch(key){
|
||||
case X_Q_KEY:
|
||||
color->background.red += color->channel_step;
|
||||
@ -39,14 +37,15 @@ int add_color(update_info *color, int key) {
|
||||
printf("what the actual fuck is wrong with your program you cunt\n");
|
||||
break;
|
||||
}
|
||||
color->foreground.red = 0xffff - color->background.red;
|
||||
color->foreground.green = 0xffff - color->background.green;
|
||||
color->foreground.blue = 0xffff - color->background.blue;
|
||||
XAllocColor(color->display, color->colormap, &color->foreground);
|
||||
XAllocColor(color->display, color->colormap, &color->background);
|
||||
}
|
||||
|
||||
int redraw_display(update_info *display_summary, XTextItem *text_prompt, GC *gc, unsigned int textpos_y) {
|
||||
XFreeColors(display_summary->display, display_summary->colormap, &display_summary->foreground.pixel, 1, 0);
|
||||
display_summary->foreground.red = 0xffff - display_summary->background.red;
|
||||
display_summary->foreground.green = 0xffff - display_summary->background.green;
|
||||
display_summary->foreground.blue = 0xffff - display_summary->background.blue;
|
||||
XAllocColor(display_summary->display, display_summary->colormap, &display_summary->foreground);
|
||||
XClearWindow(display_summary->display, display_summary->window);
|
||||
XSetWindowBackground(display_summary->display, display_summary->window, display_summary->background.pixel);
|
||||
XSetForeground(display_summary->display, *gc, display_summary->foreground.pixel);
|
||||
@ -102,7 +101,6 @@ int main(void) {
|
||||
foreground_color.green = 0xffff - background_color.green;
|
||||
foreground_color.blue = 0xffff - background_color.blue;
|
||||
|
||||
unsigned long live_pixels[2] = {foreground_color.pixel, foreground_color.pixel};
|
||||
|
||||
XAllocColor(display, colormap, &background_color);
|
||||
XAllocColor(display, colormap, &foreground_color);
|
||||
@ -153,10 +151,8 @@ int main(void) {
|
||||
XNextEvent(display, &event);
|
||||
switch (event.type) {
|
||||
case KeyPress:
|
||||
printf("%i\n", event.xkey.keycode);
|
||||
if(is_prompt) {
|
||||
XClearWindow(display, window);
|
||||
|
||||
XClearWindow(display, window);
|
||||
text_buffer_space = PROMPT_BUFSIZE - text_prompt.nchars;
|
||||
switch(event.xkey.keycode) {
|
||||
case X_BACKSPACE:
|
||||
@ -168,6 +164,14 @@ int main(void) {
|
||||
text_prompt.nchars = 0;
|
||||
is_prompt = 0;
|
||||
break;
|
||||
case X_ENTER_KEY:
|
||||
text_prompt_buffer[text_prompt.nchars + 1] = '\0';
|
||||
printf("%i: %s\n", strlen(text_prompt_buffer), text_prompt_buffer);
|
||||
XParseColor(display, colormap, text_prompt_buffer, &background_color);
|
||||
is_prompt = 0;
|
||||
text_prompt.nchars = 0;
|
||||
redraw_display(&display_summary, &text_prompt, &text_prompt_gc, textpos_y);
|
||||
break;
|
||||
default:
|
||||
if(text_buffer_space > 0) {
|
||||
text_prompt.nchars += XLookupString(&event.xkey, text_prompt_buffer + text_prompt.nchars, text_buffer_space, NULL, NULL);
|
||||
@ -179,7 +183,10 @@ int main(void) {
|
||||
else {
|
||||
switch(event.xkey.keycode) {
|
||||
case X_ENTER_KEY:
|
||||
break;
|
||||
is_prompt = 1;
|
||||
text_prompt.nchars = 4;
|
||||
strcpy(text_prompt_buffer, "rgb:");
|
||||
break;
|
||||
case X_Q_KEY: //if anyone is reading this, on a scale from 1-10,
|
||||
case X_W_KEY: //just how ugly is this?
|
||||
case X_E_KEY: //I don't know why, but it feels gross.
|
||||
|
Loading…
x
Reference in New Issue
Block a user