summaryrefslogtreecommitdiff
path: root/src/entry_backend/harfbuzz.c
diff options
context:
space:
mode:
authorPhil Jones <philj56@gmail.com>2022-11-16 13:36:25 +0000
committerPhil Jones <philj56@gmail.com>2022-11-16 13:36:25 +0000
commitca75d29bd2208ea7e2f5ccdb2b146953419be9b2 (patch)
treeaf56f7530f756a4d7ed96ca37a1d35bdceb83f7c /src/entry_backend/harfbuzz.c
parent25c0035ed0614ae334ae034ee90d7898c15e779f (diff)
Add placeholder text options.
Diffstat (limited to 'src/entry_backend/harfbuzz.c')
-rw-r--r--src/entry_backend/harfbuzz.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/entry_backend/harfbuzz.c b/src/entry_backend/harfbuzz.c
index 5d9ba99..fd3c3d7 100644
--- a/src/entry_backend/harfbuzz.c
+++ b/src/entry_backend/harfbuzz.c
@@ -231,7 +231,11 @@ void entry_backend_harfbuzz_update(struct entry *entry)
/* Render the entry text */
hb_buffer_clear_contents(buffer);
setup_hb_buffer(buffer);
- if (entry->hide_input) {
+ if (entry->input_utf8_length == 0) {
+ color = entry->placeholder_color;
+ cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a);
+ hb_buffer_add_utf8(buffer, entry->placeholder_text, -1, 0, -1);
+ } else if (entry->hide_input) {
size_t char_len = N_ELEM(entry->hidden_character_utf8);
for (size_t i = 0; i < entry->input_utf32_length; i++) {
hb_buffer_add_utf8(buffer, entry->hidden_character_utf8, char_len, 0, char_len);
@@ -246,6 +250,9 @@ void entry_backend_harfbuzz_update(struct entry *entry)
cairo_font_extents_t font_extents;
cairo_font_extents(cr, &font_extents);
+ color = entry->foreground_color;
+ cairo_set_source_rgba(cr, color.r, color.g, color.b, color.a);
+
uint32_t num_results;
if (entry->num_results == 0) {
num_results = entry->results.count;