view: Use \uFFFC character as icon placeholder

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
Quentin Glidic 2017-05-30 18:41:42 +02:00
parent 43053cdfc3
commit fb37aaa70d
No known key found for this signature in database
GPG Key ID: AC203F96E2C34BB7
1 changed files with 11 additions and 7 deletions

View File

@ -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 );