diff options
-rw-r--r-- | completions/tofi | 1 | ||||
-rw-r--r-- | doc/config | 3 | ||||
-rw-r--r-- | doc/tofi.5.md | 6 | ||||
-rw-r--r-- | doc/tofi.5.scd | 5 | ||||
-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 |
9 files changed, 23 insertions, 0 deletions
diff --git a/completions/tofi b/completions/tofi index f20cb33..3ab6c32 100644 --- a/completions/tofi +++ b/completions/tofi @@ -23,6 +23,7 @@ _tofi() --outline-width --outline-color --prompt-text + --prompt-padding --result-spacing --min-input-width --border-width @@ -54,6 +54,9 @@ # Prompt to display. prompt-text = "run: " + # Extra horizontal padding between prompt and input. + prompt-padding = 0 + # Maximum number of results to display. # If 0, tofi will draw as many results as it can fit in the window. num-results = 0 diff --git a/doc/tofi.5.md b/doc/tofi.5.md index ba88c1b..a16ca82 100644 --- a/doc/tofi.5.md +++ b/doc/tofi.5.md @@ -81,6 +81,12 @@ options. > > Default: "run: " +**prompt-padding**=*px* + +> Extra horizontal padding between prompt and input. +> +> Default: 0 + **num-results**=*n* > Maximum number of results to display. If *n* = 0, tofi will draw as diff --git a/doc/tofi.5.scd b/doc/tofi.5.scd index 31f8083..8801799 100644 --- a/doc/tofi.5.scd +++ b/doc/tofi.5.scd @@ -74,6 +74,11 @@ options. Default: "run: " +*prompt-padding*=_px_ + Extra horizontal padding between prompt and input. + + Default: 0 + *num-results*=_n_ Maximum number of results to display. If _n_ = 0, tofi will draw as many results as it can fit in the window. 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}, |