diff options
author | Phil Jones <philj56@gmail.com> | 2022-08-22 10:49:19 +0100 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-08-22 10:49:19 +0100 |
commit | 226b063306291642b9bc9d5df0e54f2886d18486 (patch) | |
tree | 4e9bd295f0558c2e5cdc490a09c7821f9fa867bd /src | |
parent | faf685ca266d9cd3e2bb42d2ef105a5577cfcaf1 (diff) |
Add --prompt-padding option.
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 3 | ||||
-rw-r--r-- | src/entry.h | 1 | ||||
-rw-r--r-- | src/entry_backend/harfbuzz.c | 1 | ||||
-rw-r--r-- | src/entry_backend/pango.c | 1 | ||||
-rw-r--r-- | src/main.c | 2 |
5 files changed, 8 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c index 5dff7f2..e1a30b8 100644 --- a/src/config.c +++ b/src/config.c @@ -258,6 +258,8 @@ bool parse_option(struct tofi *tofi, const char *filename, size_t lineno, const tofi->window.entry.outline_color = parse_color(filename, lineno, value, &err); } else if (strcasecmp(option, "prompt-text") == 0) { snprintf(tofi->window.entry.prompt_text, N_ELEM(tofi->window.entry.prompt_text), "%s", value); + } else if (strcasecmp(option, "prompt-padding") == 0) { + tofi->window.entry.prompt_padding = parse_uint32(filename, lineno, value, &err); } else if (strcasecmp(option, "min-input-width") == 0) { tofi->window.entry.input_width = parse_uint32(filename, lineno, value, &err); } else if (strcasecmp(option, "result-spacing") == 0) { @@ -378,6 +380,7 @@ void config_fixup_values(struct tofi *tofi) if (tofi->use_scale) { struct entry *entry = &tofi->window.entry; + entry->prompt_padding *= scale; entry->corner_radius *= scale; entry->selection_background_padding *= scale; entry->result_spacing *= scale; diff --git a/src/entry.h b/src/entry.h index 2dfa47e..46ec65f 100644 --- a/src/entry.h +++ b/src/entry.h @@ -56,6 +56,7 @@ struct entry { uint32_t font_size; char font_name[MAX_FONT_NAME_LENGTH]; char prompt_text[MAX_PROMPT_LENGTH]; + uint32_t prompt_padding; uint32_t corner_radius; uint32_t padding_top; uint32_t padding_bottom; diff --git a/src/entry_backend/harfbuzz.c b/src/entry_backend/harfbuzz.c index b90936f..2834d9d 100644 --- a/src/entry_backend/harfbuzz.c +++ b/src/entry_backend/harfbuzz.c @@ -225,6 +225,7 @@ void entry_backend_harfbuzz_update(struct entry *entry) extents = render_hb_buffer(cr, buffer); cairo_translate(cr, extents.x_advance, 0); + cairo_translate(cr, entry->prompt_padding, 0); /* Render the entry text */ hb_buffer_clear_contents(buffer); diff --git a/src/entry_backend/pango.c b/src/entry_backend/pango.c index 3173d6f..d4737a1 100644 --- a/src/entry_backend/pango.c +++ b/src/entry_backend/pango.c @@ -82,6 +82,7 @@ void entry_backend_pango_update(struct entry *entry) pango_layout_get_pixel_extents(entry->pango.layout, &ink_rect, &logical_rect); cairo_translate(cr, logical_rect.width + logical_rect.x, 0); + cairo_translate(cr, entry->prompt_padding, 0); /* Render the entry text */ pango_layout_set_text(layout, entry->input_mb, -1); @@ -784,6 +784,7 @@ static void usage() " --border-color <color> Color of the border.\n" " --text-color <color> Color of text.\n" " --prompt-text <string> Prompt text.\n" +" --prompt-padding <px> Padding between prompt and input.\n" " --num-results <n> Maximum number of results to display.\n" " --selection-color <color> Color of selected result.\n" " --selection-match-color <color> Color of the matching portion of the\n" @@ -840,6 +841,7 @@ const struct option long_options[] = { {"outline-width", required_argument, NULL, 0}, {"outline-color", required_argument, NULL, 0}, {"prompt-text", required_argument, NULL, 0}, + {"prompt-padding", required_argument, NULL, 0}, {"result-spacing", required_argument, NULL, 0}, {"min-input-width", required_argument, NULL, 0}, {"border-width", required_argument, NULL, 0}, |