aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--swt.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/swt.c b/swt.c
index 53e419f..6a9b5b3 100644
--- a/swt.c
+++ b/swt.c
@@ -73,7 +73,7 @@ static int execshortcut();
static char *kmap();
static void buffer_release(void *data, struct wl_buffer *buffer);
static void draw_frame();
-static uint32_t get_color(uint32_t i);
+static uint32_t get_color(uint32_t i, ushort mode);
static void draw_glyph(Glyph g, int x, int y);
static void commit_surface();
static void surface_configure(void *data, struct xdg_surface *surface, uint32_t serial);
@@ -218,11 +218,18 @@ paste()
uint32_t
-get_color(uint32_t i)
+get_color(uint32_t i, ushort mode)
{
if (!BETWEEN(i, 0, sizeof(colors) / sizeof(uint32_t))) {
return i;
}
+
+ if ((mode & ATTR_BOLD) && i >= 0 && i < 8) {
+ if (!BETWEEN(i + 8, 0, sizeof(colors) / sizeof(uint32_t))) {
+ return i;
+ }
+ return colors[i + 8];
+ }
return colors[i];
}
@@ -239,8 +246,8 @@ draw_glyph(Glyph g, int x, int y)
g.mode ^= ATTR_REVERSE;
}
- bg = (g.mode & ATTR_REVERSE) ? get_color(g.fg) : get_color(g.bg);
- fg = (g.mode & ATTR_REVERSE) ? get_color(g.bg) : get_color(g.fg);
+ bg = (g.mode & ATTR_REVERSE) ? get_color(g.fg, 0) : get_color(g.bg, 0);
+ fg = (g.mode & ATTR_REVERSE) ? get_color(g.bg, g.mode) : get_color(g.fg, g.mode);
win.fontcache->fonttype = FONTMODE(g.mode);
draw_rect(
@@ -293,7 +300,7 @@ wdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) {
borderpx + oy * win.fontcache->box.height,
win.fontcache->box.width,
win.fontcache->box.height,
- get_color(og.bg)
+ get_color(og.bg, 0)
);
draw_glyph(og, ox, oy);
@@ -316,7 +323,7 @@ wdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) {
borderpx + cy * win.fontcache->box.height + win.fontcache->box.height - cursorthickness,
win.fontcache->box.width,
cursorthickness,
- get_color(defaultcursorcolor)
+ get_color(defaultcursorcolor, 0)
);
break;
case 5: /* Bar */
@@ -328,7 +335,7 @@ wdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) {
borderpx + cy * win.fontcache->box.height,
cursorthickness,
win.fontcache->box.height,
- get_color(defaultcursorcolor)
+ get_color(defaultcursorcolor, 0)
);
break;
}
@@ -392,9 +399,9 @@ wgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b) {
if (!BETWEEN(x, 0, sizeof(colors) / sizeof(uint32_t)))
return 1;
- *r = (get_color(x) & 0xff0000) >> 16;
- *g = (get_color(x) & 0x00ff00) >> 8;
- *b = (get_color(x) & 0x0000ff);
+ *r = (get_color(x, 0) & 0xff0000) >> 16;
+ *g = (get_color(x, 0) & 0x00ff00) >> 8;
+ *b = (get_color(x, 0) & 0x0000ff);
return 0;
}
@@ -478,7 +485,7 @@ buffer_release(void *data, struct wl_buffer *buffer)
void
draw_frame()
{
- draw_rect(win.canvas, 0, 0, win.width, win.height, get_color(defaultbg));
+ draw_rect(win.canvas, 0, 0, win.width, win.height, get_color(defaultbg, 0));
}