diff options
-rw-r--r-- | src/color.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/color.c b/src/color.c index 01f093f..cc4e4ef 100644 --- a/src/color.c +++ b/src/color.c @@ -9,6 +9,7 @@ #define PROMPT_BUFSIZE 32 #define X_ENTER_KEY 36 +#define X_BACKSPACE 22 #define X_Q_KEY 24 #define X_W_KEY 25 @@ -19,6 +20,9 @@ #define X_D_KEY 40 +#define TEXT_CORNER_OFFSET 100 + + int main(void) { @@ -38,10 +42,11 @@ int main(void) { int text_buffer_space; unsigned int channel_step; - int is_prompt = 0; + int is_prompt = 1; + + + unsigned int textpos_y; - unsigned int winsize_x; - unsigned int winsize_y; XFontStruct* font; @@ -99,22 +104,22 @@ int main(void) { text_prompt_gc = XCreateGC(display, window, GCForeground | GCLineWidth, &text_prompt_formatting); font = XLoadQueryFont(display, "-*-helvetica-medium-r-normal-*-20-*"); XSetFont(display, text_prompt_gc, font->fid); + + XGetWindowAttributes(display, window, &win_info); + textpos_y = win_info.height - TEXT_CORNER_OFFSET; for(;;) { XNextEvent(display, &event); - XGetWindowAttributes(display, window, &win_info); - winsize_x = win_info.width; - winsize_y = win_info.height; switch (event.type) { case KeyPress: - printf("%i\n", event.xkey.keycode); + printf("-->%i\n", event.xkey.keycode); if(is_prompt) { XClearWindow(display, window); text_buffer_space = PROMPT_BUFSIZE - text_prompt.nchars; - if(event.xkey.keycode == X_ENTER_KEY) { + if(event.xkey.keycode == X_BACKSPACE) { if(text_buffer_space < PROMPT_BUFSIZE) { text_prompt.nchars--; } @@ -122,6 +127,7 @@ int main(void) { else if(text_buffer_space > 0) { text_prompt.nchars += XLookupString(&event.xkey, text_prompt_buffer + text_prompt.nchars, text_buffer_space, NULL, NULL); } + XDrawText(display, window, text_prompt_gc, TEXT_CORNER_OFFSET, textpos_y, &text_prompt, 1); } else { printf("%i\n", win_info.depth); @@ -129,12 +135,6 @@ int main(void) { case X_ENTER_KEY: break; case X_Q_KEY: - printf("Before: %i\n", background_color.red); - XFreeColors(display, colormap, &background_color.pixel, 1, NULL); - printf("Step: %i\n", channel_step); - background_color.red += channel_step; //TODO: change me to depth - printf("After: %i\n", background_color.red); - XAllocColor(display, colormap, &background_color); break; case X_W_KEY: break; @@ -153,15 +153,18 @@ int main(void) { - XDrawText(display, window, text_prompt_gc, 10, winsize_y - 10, &text_prompt, 1); + XDrawText(display, window, text_prompt_gc, TEXT_CORNER_OFFSET, textpos_y, &text_prompt, 1); break; case Expose: - XDrawText(display, window, text_prompt_gc, 10, winsize_y - 10, &text_prompt, 1); - printf("exposed\n"); + XGetWindowAttributes(display, window, &win_info); + textpos_y = win_info.height - TEXT_CORNER_OFFSET; + XDrawText(display, window, text_prompt_gc, TEXT_CORNER_OFFSET, textpos_y, &text_prompt, 1); + printf("%i\n", textpos_y); break; default: + printf("testing\n"); break; - } + } } |