aboutsummaryrefslogtreecommitdiff
path: root/swt.c
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-04-11 10:38:06 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2023-04-11 10:38:06 +0200
commitceb2880f91b79de5024b3884991419d74466dec6 (patch)
treec921ebbd77edfaff356a35906f2ac8b3e560785b /swt.c
parent65745aff10ec35dfcae8e2909715156db6d653f2 (diff)
add font weights
Diffstat (limited to 'swt.c')
-rw-r--r--swt.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/swt.c b/swt.c
index 60d9e9a..10d4109 100644
--- a/swt.c
+++ b/swt.c
@@ -26,6 +26,8 @@ char *argv0;
#define TRUERED(x) (((x) & 0xff0000) >> 16)
#define TRUEGREEN(x) (((x) & 0xff00) >> 8)
#define TRUEBLUE(x) (((x) & 0xff))
+#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
+#define FONTMODE(mode) (mode & ATTR_ITALIC ? (mode & ATTR_BOLD ? FONT_BOLD_ITALIC : FONT_ITALIC) : (mode & ATTR_BOLD ? FONT_BOLD : FONT_NORMAL))
#define match_then_bind(obj, inter, ver) \
if (strcmp(interface, inter.name) == 0) { \
obj = wl_registry_bind(registry, name, &inter, ver);
@@ -166,6 +168,7 @@ void wdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) {
win.fontcache->box.height,
colors[og.bg]
);
+ win.fontcache->fonttype = FONTMODE(og.mode);
draw_char(
win.canvas,
win.fontcache,
@@ -182,6 +185,7 @@ void wdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) {
win.fontcache->box.height,
colors[g.fg]
);
+ win.fontcache->fonttype = FONTMODE(g.mode);
draw_char(
win.canvas,
win.fontcache,
@@ -206,6 +210,7 @@ void wdrawline(Line line, int x1, int y1, int x2) {
);
for (x = x1; x < x2; x++) {
+ win.fontcache->fonttype = FONTMODE(line[x].mode);
draw_rect(
win.canvas,
borderpx + x * win.fontcache->box.width,
@@ -294,8 +299,11 @@ wsetcursor(int cursor) {
}
-void wsetmode(int set, unsigned int flag) {
- fprintf(stderr, "SET MODE: %i, %u\n", set, flag);
+void wsetmode(int set, unsigned int flags) {
+ int mode = win.mode;
+ MODBIT(win.mode, set, flags);
+ if ((win.mode & MODE_REVERSE) != (mode & MODE_REVERSE))
+ redraw();
}
@@ -310,8 +318,7 @@ void wsetsel(char *str) {
int wstartdraw() {
- return 1;
- //return IS_SET(MODE_VISIBLE);
+ return IS_SET(MODE_VISIBLE);
}
@@ -612,6 +619,7 @@ pointer_axis(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axi
void
setup()
{
+ win.mode = MODE_VISIBLE;
win.fontcache = create_font_cache(fonts, sizeof(fonts) / sizeof(FontPath), fontsize);
wloadcols();
client.kb.repeat.timer = timerfd_create(CLOCK_MONOTONIC, 0);
@@ -637,7 +645,8 @@ setup()
}
-void run()
+void
+run()
{
struct itimerspec spec = { 0 };
struct pollfd fds[3];