summaryrefslogtreecommitdiff
path: root/src/entry.c
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2022-12-20 23:53:20 +0000
committerPhil Jones <philj56@gmail.com>2022-12-21 00:15:16 +0000
commit6c47cf7892d0f212b04e7b798e53c120f51022d7 (patch)
treec44b910e059d5bdcf991b2239de8d29cb007bed6 /src/entry.c
parent108550fcf8d3ed8664c0e05defceaf20b4d2b49e (diff)
Add text cursor support.
This turned out to be much more complex than anticipated, and the potential for bugs is therefore quite high.
Diffstat (limited to 'src/entry.c')
-rw-r--r--src/entry.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/entry.c b/src/entry.c
index 2ea14ac..5ccdb72 100644
--- a/src/entry.c
+++ b/src/entry.c
@@ -59,7 +59,7 @@ static void fixup_padding_sizes(struct directional *padding, uint32_t clip_width
}
}
-void entry_init(struct entry *entry, uint8_t *restrict buffer, uint32_t width, uint32_t height)
+void entry_init(struct entry *entry, uint8_t *restrict buffer, uint32_t width, uint32_t height, uint32_t scale)
{
entry->image.width = width;
entry->image.height = height;
@@ -211,6 +211,25 @@ void entry_init(struct entry *entry, uint8_t *restrict buffer, uint32_t width, u
fixup_padding_sizes(&entry->alternate_result_theme.padding, width, height);
fixup_padding_sizes(&entry->selection_theme.padding, width, height);
+ /* The cursor is a special case, as it just needs the input colours. */
+ if (!entry->cursor_theme.color_specified) {
+ entry->cursor_theme.color = entry->input_theme.foreground_color;
+ }
+ if (!entry->cursor_theme.text_color_specified) {
+ entry->cursor_theme.text_color = entry->background_color;
+ }
+
+ /*
+ * TODO:
+ * This is a dirty hack. The proper thing to do is probably just to
+ * stop scaling everything manually, set cairo_scale and have done
+ * with. The reason that isn't how things are currently done is due to
+ * historic scaling behaviour of tofi.
+ */
+ if (!entry->cursor_theme.thickness_specified) {
+ entry->cursor_theme.thickness *= scale;
+ }
+
/*
* Perform an initial render of the text.
* This is done here rather than by calling entry_update to avoid the