From c7ebccb81d7a31b5bbfabdb533e665eb2ddb929c Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Tue, 11 Apr 2023 12:05:47 +0200 Subject: config add default cursor color --- swt.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 18 deletions(-) (limited to 'swt.c') 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; } -- cgit v1.2.3-70-g09d2