commit 0bec62b
chld
·
2026-07-14 15:47:36 +0000 UTC
parent dc7474a
text writing and a box
3 files changed,
+20,
-2
+1,
-0
1@@ -4,3 +4,4 @@
2 *.core
3 xl
4 config.h
5+xtr
M
xtr
+0,
-0
M
xtr.c
+19,
-2
1@@ -12,7 +12,7 @@
2 #include "config.h"
3
4 int main(int ac, char **av) {
5- int wi = 600, hi = 150, x = 0, y = 0;
6+ int wi = 350, hi = 75, x = 0, y = 0;
7
8 char path[128];
9 snprintf(path, sizeof path, "%s/%s", getenv("HOME"), ".xlrc");
10@@ -114,8 +114,22 @@ int main(int ac, char **av) {
11 if (ev.xexpose.count != 0)
12 break;
13
14+ int direction, as, des;
15+ XCharStruct ov;
16+
17+ XTextExtents(font, cmd, strlen(cmd), &direction, &as, &des, &ov);
18+
19 XSetForeground(d, gc, col[1].pixel);
20 XFillRectangle(d, w, gc, 0, 0, wi, hi);
21+ XSetForeground(d, gc, col[2].pixel);
22+ XFillRectangle(d, w, gc, 10, 30, wi - 20, hi - 30 - 10);
23+
24+ XSetForeground(d, gc, col[1].pixel);
25+ XFillRectangle(d, w, gc, 10 + 1, 30 + 1, wi - 20 - (1 * 2),
26+ hi - 30 - 10 - (1 * 2));
27+
28+ XSetForeground(d, gc, col[2].pixel);
29+ XDrawString(d, w, gc, 15, 30 + (as + des), cmd, strlen(cmd));
30
31 break;
32 case ConfigureNotify:
33@@ -130,7 +144,9 @@ int main(int ac, char **av) {
34 case KeyPress: {
35 KeySym k = XLookupKeysym(&ev.xkey, 0);
36 if (k == XK_Escape) {
37- puts(cmd);
38+ goto q;
39+ }
40+ if (k == XK_Return) {
41 goto q;
42 }
43
44@@ -139,6 +155,7 @@ int main(int ac, char **av) {
45 if (l > 0) {
46 // printf("%s\n", buf);
47 cmd[idx++] = buf[0];
48+ XClearArea(d, w, 0, 0, 0, 0, True);
49 }
50
51 break;