summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrett Weiland <techcrazybsw@gmail.com>2020-07-22 01:02:56 -0500
committerBrett Weiland <techcrazybsw@gmail.com>2020-07-22 01:02:56 -0500
commit7d40fa903908f7854710a2a278eaf5ca3f97bd14 (patch)
treeccac860d1ff4433dc3aea2bda77d2c24aad48e4e /src
parent727cb1420c171dfed8213aa1b47ec3c542968b43 (diff)
new file: src/Makefile
new file: src/color.c
Diffstat (limited to 'src')
-rw-r--r--src/Makefile4
-rw-r--r--src/color.c83
2 files changed, 87 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..5a84d7c
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,4 @@
+make:
+ gcc color.c -lX11 -o ../color
+debug:
+ gcc color.c -lX11 -Wall -o ../color -ggdb
diff --git a/src/color.c b/src/color.c
new file mode 100644
index 0000000..8721140
--- /dev/null
+++ b/src/color.c
@@ -0,0 +1,83 @@
+#include <X11/Xlib.h>
+#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;
+
+
+
+
+
+ if((display = XOpenDisplay(NULL)) == NULL) {
+ printf("Couldn't open display due to fatal error: %s\n", strerror(errno));
+ exit(errno);
+ }
+
+ screen = DefaultScreen(display);
+ 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,
+ 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_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 learn inverting math, move to bottom right of window
+ break;
+ default:
+ printf("wot\n");
+ break;
+ }
+ }
+
+
+ return 0;
+}