aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriamcheeseman <[hidden email]>2026-02-28 17:59:15 -0500
committeriamcheeseman <[hidden email]>2026-02-28 17:59:15 -0500
commit62569083ce2422a0554d514a0a4dee5c85b89d4e (patch)
tree6e863468ab38b89b938697d614ba73acf022d162
init
-rw-r--r--Makefile25
-rw-r--r--src/tsar.c118
-rwxr-xr-xtsarbarbin0 -> 21552 bytes
-rwxr-xr-xtsarc3
4 files changed, 146 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..79a4243
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,25 @@
+CC=cc
+CFLAGS+=-std=c99 -pedantic -Wall -Wextra -O2
+LDFLAGS+=-lX11 -lxcb
+
+TSAR_OUT=tsarbar
+
+HEADERS=
+SRC=src/tsar.c
+
+.PHONY: default run clean
+
+default: $(TSAR_OUT)
+
+# Project should be small enough that we should be able to ignore incremental
+# compilation
+$(TSAR_OUT): $(SRC)
+ $(CC) $(SRC) -o $(TSAR_OUT) $(CFLAGS) $(LDFLAGS)
+
+%.c:
+
+run: $(TSAR_OUT)
+ ./$(TSAR_OUT)
+
+clean:
+ rm $(TSAR_OUT)
diff --git a/src/tsar.c b/src/tsar.c
new file mode 100644
index 0000000..67b9e07
--- /dev/null
+++ b/src/tsar.c
@@ -0,0 +1,118 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include <xcb/xcb.h>
+// #include <X11/Xft/Xft.h>
+
+xcb_connection_t* connection;
+xcb_screen_t* screen;
+xcb_window_t win;
+xcb_gc_t rect_gc;
+xcb_gc_t text_gc;
+
+static int height = 16;
+static float width = 1;
+
+static int err_code = 1;
+
+void die(const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+
+ putc('\n', stderr);
+
+ exit(err_code);
+}
+
+void draw_bar(void) {
+}
+
+void init(void) {
+ connection = xcb_connect(NULL, NULL);
+ screen = xcb_setup_roots_iterator(
+ xcb_get_setup(connection)
+ ).data;
+ win = xcb_generate_id(connection);
+
+ xcb_create_window(
+ connection,
+ XCB_COPY_FROM_PARENT,
+ win,
+ screen->root,
+ 0, 0,
+ 100, height,
+ 0,
+ XCB_WINDOW_CLASS_INPUT_OUTPUT,
+ screen->root_visual,
+ XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK,
+ (uint32_t[]){0x000000, XCB_EVENT_MASK_EXPOSURE}
+ );
+
+ xcb_font_t font = xcb_generate_id(connection);
+ const char font_name[] = "commit";
+ xcb_open_font(
+ connection,
+ font,
+ strlen(font_name),
+ font_name
+ );
+
+ text_gc = xcb_generate_id(connection);
+ xcb_create_gc(
+ connection,
+ text_gc,
+ win,
+ XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT,
+ (uint32_t[]){0x000000, 0xFFFFFF, font}
+ );
+
+ xcb_close_font(connection, font);
+
+ rect_gc = xcb_generate_id(connection);
+ xcb_create_gc(
+ connection,
+ rect_gc,
+ win,
+ XCB_GC_FOREGROUND | XCB_GC_GRAPHICS_EXPOSURES,
+ (uint32_t[]){0xFF0000, 0}
+ );
+
+ xcb_map_window(connection, win);
+ xcb_flush(connection);
+}
+
+void deinit(void) {
+ xcb_disconnect(connection);
+}
+
+int main(void) {
+ init();
+
+ xcb_generic_event_t* ev;
+ while ((ev = xcb_wait_for_event(connection))) {
+ switch (ev->response_type & ~0x80) {
+ case XCB_EXPOSE: {
+ xcb_rectangle_t rect = {10, 50, 200, 200};
+ xcb_poly_rectangle(connection, win, rect_gc, 1, &rect);
+
+
+ const char text[] = "hello, world!";
+ xcb_image_text_8(connection, strlen(text), win, text_gc, 50, 50, text);
+
+ xcb_flush(connection);
+ break;
+ }
+ }
+
+ free(ev);
+ }
+
+ deinit();
+ return 0;
+}
diff --git a/tsarbar b/tsarbar
new file mode 100755
index 0000000..9422e2a
--- /dev/null
+++ b/tsarbar
Binary files differ
diff --git a/tsarc b/tsarc
new file mode 100755
index 0000000..8c3a87d
--- /dev/null
+++ b/tsarc
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+echo "This is a future config cli yadayada"