From fb37aaa70d2e7e028d4749633b3704cfcd27ef86 Mon Sep 17 00:00:00 2001 From: Quentin Glidic Date: Tue, 30 May 2017 18:41:42 +0200 Subject: [PATCH] view: Use \uFFFC character as icon placeholder Signed-off-by: Quentin Glidic --- source/view.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/source/view.c b/source/view.c index 4745990c..fc5a4fe6 100644 --- a/source/view.c +++ b/source/view.c @@ -906,15 +906,19 @@ static void update_callback ( textbox *t, unsigned int index, void *udata, TextB else{ list = pango_attr_list_new (); } - int icon_height = textbox_get_font_height ( t ); + int icon_height = textbox_get_font_height ( t ); - cairo_surface_t *icon = mode_get_icon ( state->sw, state->line_map[index], icon_height ); - textbox_icon ( t, icon ); - - //AA TODO: Find a better way to position icon than tab char - gchar *firstspace = g_utf8_strchr ( t->text, -1, '\t' ); - textbox_set_icon_index ( t, ( firstspace == NULL ) ? -1 : g_utf8_pointer_to_offset ( t->text, firstspace ) + 1 ); + const gchar *visible_text = textbox_get_visible_text ( t ); + const gchar *icon_placeholder = g_utf8_strchr ( visible_text, -1, 0xFFFC ); + if ( icon_placeholder != NULL ) { + cairo_surface_t *icon = mode_get_icon ( state->sw, state->line_map[index], icon_height ); + textbox_icon ( t, icon ); + textbox_set_icon_index ( t, g_utf8_pointer_to_offset ( visible_text, icon_placeholder ) ); + } + else { + textbox_set_icon_index ( t, -1 ); + } if ( state->tokens && config.show_match ) { ThemeHighlight th = { HL_BOLD | HL_UNDERLINE, { 0.0, 0.0, 0.0, 0.0 } }; th = rofi_theme_get_highlight ( WIDGET ( t ), "highlight", th );