aboutsummaryrefslogtreecommitdiff
path: root/swt.c
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-04-11 12:05:47 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2023-04-11 12:05:47 +0200
commitc7ebccb81d7a31b5bbfabdb533e665eb2ddb929c (patch)
tree3654acce2f53cb499cd0fe5d2c691bc1586edab4 /swt.c
parentceb2880f91b79de5024b3884991419d74466dec6 (diff)
config add default cursor color
Diffstat (limited to 'swt.c')
-rw-r--r--swt.c86
1 files changed, 68 insertions, 18 deletions
diff --git a/swt.c b/swt.c
index 10d4109..201c3a5 100644
--- a/swt.c
+++ b/swt.c
@@ -48,6 +48,7 @@ typedef struct {
Canvas *canvas;
FontCache *fontcache;
int mode;
+ int cursor;
} Window;
@@ -177,23 +178,70 @@ void wdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) {
borderpx + oy * win.fontcache->box.height + win.fontcache->fontsize,
colors[og.fg]
);
- draw_rect(
- win.canvas,
- borderpx + cx * win.fontcache->box.width,
- borderpx + cy * win.fontcache->box.height,
- win.fontcache->box.width,
- win.fontcache->box.height,
- colors[g.fg]
- );
- win.fontcache->fonttype = FONTMODE(g.mode);
- draw_char(
- win.canvas,
- win.fontcache,
- g.u,
- borderpx + cx * win.fontcache->box.width,
- borderpx + cy * win.fontcache->box.height + win.fontcache->fontsize,
- colors[g.bg]
- );
+
+ switch(win.cursor) {
+ case 0:
+ case 1:
+ case 2:
+ draw_rect(
+ win.canvas,
+ borderpx + cx * win.fontcache->box.width,
+ borderpx + cy * win.fontcache->box.height,
+ win.fontcache->box.width,
+ win.fontcache->box.height,
+ colors[defaultcursorcolor]
+ );
+ win.fontcache->fonttype = FONTMODE(g.mode);
+ draw_char(
+ win.canvas,
+ win.fontcache,
+ g.u,
+ borderpx + cx * win.fontcache->box.width,
+ borderpx + cy * win.fontcache->box.height + win.fontcache->fontsize,
+ colors[g.bg]
+ );
+ break;
+ case 3:
+ case 4:
+ draw_rect(
+ win.canvas,
+ borderpx + cx * win.fontcache->box.width,
+ borderpx + cy * win.fontcache->box.height + win.fontcache->box.height - cursorthickness,
+ win.fontcache->box.width,
+ cursorthickness,
+ colors[defaultcursorcolor]
+ );
+ win.fontcache->fonttype = FONTMODE(g.mode);
+ draw_char(
+ win.canvas,
+ win.fontcache,
+ g.u,
+ borderpx + cx * win.fontcache->box.width,
+ borderpx + cy * win.fontcache->box.height + win.fontcache->fontsize,
+ colors[g.fg]
+ );
+ break;
+ case 5:
+ case 6:
+ draw_rect(
+ win.canvas,
+ borderpx + cx * win.fontcache->box.width,
+ borderpx + cy * win.fontcache->box.height,
+ cursorthickness,
+ win.fontcache->box.height,
+ colors[defaultcursorcolor]
+ );
+ win.fontcache->fonttype = FONTMODE(g.mode);
+ draw_char(
+ win.canvas,
+ win.fontcache,
+ g.u,
+ borderpx + cx * win.fontcache->box.width,
+ borderpx + cy * win.fontcache->box.height + win.fontcache->fontsize,
+ colors[g.fg]
+ );
+ break;
+ }
}
@@ -294,7 +342,9 @@ void wsettitle(char *title) {
int
wsetcursor(int cursor) {
- fprintf(stderr, "SET CURSOR: %i\n", cursor);
+ if (!BETWEEN(cursor, 0, 7))
+ return 0;
+ win.cursor = cursor;
return 1;
}