commit b1a3da7
chld
·
2026-07-13 17:21:56 +0000 UTC
parent eb412e4
add color and config
4 files changed,
+46,
-6
+1,
-0
1@@ -3,3 +3,4 @@
2 *.so
3 *.core
4 xl
5+config.h
M
build.sh
+2,
-0
1@@ -7,6 +7,7 @@ PREFIX=${PREFIX:-/usr/pkg}
2
3 case $1 in
4 make)
5+ [ ! -f config.h ] && cp config.def.h config.h
6 cc $SRC $INC $LIBS -o $OUT
7 ;;
8 install)
9@@ -18,5 +19,6 @@ case $1 in
10 ;;
11 clean)
12 rm $OUT
13+ rm config.h
14 ;;
15 esac
+11,
-0
1@@ -0,0 +1,11 @@
2+#ifndef XLND_CONFIG_H
3+#define XLND_CONFIG_H
4+
5+/* colors */
6+#define XLND_BORDER_COLOR "#222222"
7+#define XLND_BG_COLOR "#080808"
8+#define XLND_INK_COLOR "#aaaaaa"
9+#define XLND_SEC_COLOR "#e74c3c"
10+#define XLND_SEC_FONT_COLOR "#080808"
11+
12+#endif
M
xl.c
+32,
-6
1@@ -8,6 +8,7 @@
2
3 #include <getopt.h>
4
5+#include "config.h"
6 #include "rd.h"
7
8 /*
9@@ -72,8 +73,17 @@ int main(int ac, char **av) {
10 if (XQueryPointer(d, r, &w_r, &w_r, &x, &y, &d1, &d2, &m_r)) {
11 }
12
13- Window w = XCreateSimpleWindow(d, RootWindow(d, s), x, y, wi, hi, 0,
14- BlackPixel(d, s), WhitePixel(d, s));
15+ /*
16+ * TODO:
17+ * handle colors a better way, dear god
18+ */
19+
20+ XColor brd_col;
21+ XParseColor(d, DefaultColormap(d, s), XLND_BG_COLOR, &brd_col);
22+ XAllocColor(d, DefaultColormap(d, s), &brd_col);
23+
24+ Window w = XCreateSimpleWindow(d, RootWindow(d, s), x, y, wi, hi, 1,
25+ brd_col.pixel, WhitePixel(d, s));
26 XStoreName(d, w, "xlnd");
27 XSelectInput(d, w,
28 ExposureMask | KeyPressMask | StructureNotifyMask |
29@@ -127,6 +137,22 @@ int main(int ac, char **av) {
30 t = strtok(NULL, "\n");
31 }
32
33+ XColor bg_col;
34+ XParseColor(d, DefaultColormap(d, s), XLND_BG_COLOR, &bg_col);
35+ XAllocColor(d, DefaultColormap(d, s), &bg_col);
36+
37+ XColor fg_col;
38+ XParseColor(d, DefaultColormap(d, s), XLND_INK_COLOR, &fg_col);
39+ XAllocColor(d, DefaultColormap(d, s), &fg_col);
40+
41+ XColor bg_sel;
42+ XParseColor(d, DefaultColormap(d, s), XLND_SEC_COLOR, &bg_sel);
43+ XAllocColor(d, DefaultColormap(d, s), &bg_sel);
44+
45+ XColor fg_sel;
46+ XParseColor(d, DefaultColormap(d, s), XLND_SEC_FONT_COLOR, &fg_sel);
47+ XAllocColor(d, DefaultColormap(d, s), &fg_sel);
48+
49 while (1) {
50 XEvent ev;
51 XNextEvent(d, &ev);
52@@ -138,9 +164,9 @@ int main(int ac, char **av) {
53
54 for (int j = 0; j < (int)p_i; ++j) {
55 if (sel == j) {
56- XSetForeground(d, gc, WhitePixel(d, s));
57+ XSetForeground(d, gc, bg_sel.pixel);
58 } else {
59- XSetForeground(d, gc, BlackPixel(d, s));
60+ XSetForeground(d, gc, bg_col.pixel);
61 }
62
63 XFillRectangle(d, w, gc, 0, (hi * j) / (int)p_i, wi, hi / (int)p_i);
64@@ -154,9 +180,9 @@ int main(int ac, char **av) {
65 &ov);
66
67 if (sel == i) {
68- XSetForeground(d, gc, BlackPixel(d, s));
69+ XSetForeground(d, gc, fg_sel.pixel);
70 } else {
71- XSetForeground(d, gc, WhitePixel(d, s));
72+ XSetForeground(d, gc, fg_col.pixel);
73 }
74
75 XDrawString(d, w, gc, (wi - ov.width) / 2,