summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Weiland <techcrazybsw@gmail.com>2020-07-22 00:55:49 -0500
committerBrett Weiland <techcrazybsw@gmail.com>2020-07-22 00:55:49 -0500
commit0724dd34334c3ba5ae4d127bd4b23d872a0aa273 (patch)
tree345fef312f707a9a5bf327b38b21d04bad3601be
parente4d8e8004267c45174706def0316162526a4872a (diff)
modified: Makefile
modified: color modified: color.c
-rw-r--r--Makefile2
-rwxr-xr-xcolorbin16968 -> 17160 bytes
-rw-r--r--color.c76
3 files changed, 67 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 44479c0..cbc04cd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
make:
gcc color.c -lX11 -o color
debug:
- gcc color.c -lX11 -o color -ggdb
+ gcc color.c -lX11 -Wall -o color -ggdb
diff --git a/color b/color
index 00dc18a..f6751bb 100755
--- a/color
+++ b/color
Binary files differ
diff --git a/color.c b/color.c
index d82a142..e05e177 100644
--- a/color.c
+++ b/color.c
@@ -2,27 +2,83 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
+#include <errno.h>
+
+//TODO: fix your ugly ass vim colors, I don't care if it's part of the code
+
+
int main(void) {
+
+ char text_prompt_buffer[32] = "testing"; //TODO: everything
+
Display *display;
Window window;
XEvent event;
+ Colormap colormap;
int screen;
+
+ XColor background_color;
+ XTextItem text_prompt;
+ XGCValues text_prompt_formatting;
+ GC text_prompt_gc;
+
+
+
+
- d = XOpenDisplay(NULL);
- if (d == NULL) {
- fprintf(stderr, "Cannot open display\n");
- exit(1);
+ if((display = XOpenDisplay(NULL)) == NULL) {
+ printf("Couldn't open display due to fatal error: %s\n", strerror(errno));
+ exit(errno);
}
screen = DefaultScreen(display);
- w = XCreateSimpleWindow(display, RootWindow(display, screen),
+ colormap = DefaultColormap(display, screen);
+
+ background_color.red = 0;
+ background_color.green = 65535;
+ background_color.blue = 0;
+
+ XAllocColor(display, colormap, &background_color);
+
+
+ window = XCreateSimpleWindow(display, RootWindow(display, screen),
10, 10,
100, 100,
- 1,
- BlackPixel(d, s),
- WhitePixel(d, s)); //last arg is color
+ 0,
+ background_color.pixel,
+ background_color.pixel); //last arg is color
+
+ XMapWindow(display, window);
+ XSelectInput(display, window, KeyPressMask | ExposureMask);
+
+
+ //text struct
+ text_prompt.chars = text_prompt_buffer;
+ text_prompt.nchars = strlen(text_prompt_buffer);
+ text_prompt.delta = 0; //what?
+ text_prompt.font = None;
+
+ //text formatting struct
+ text_prompt_formatting.foreground = BlackPixel(display, screen);
+ text_prompt_formatting.background = WhitePixel(display, screen);
+ text_prompt_gc = XCreateGC(display, window, GCForeground | GCBackground, &text_prompt_formatting);
+
+
+ for(;;) {
+ XNextEvent(display, &event);
+ switch (event.type) {
+ case KeyPress:
+ printf("Key press\n");
+ break;
+ case Expose:
+ XDrawText(display, window, text_prompt_gc, 10, 10, &text_prompt, 1); //TODO formatting, textprompt
+ break;
+ default:
+ printf("wot\n");
+ break;
+ }
+ }
return 0;
-}
+}