[draw] Do inline UTF-8 conversion
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
1049393840
commit
aa6bfc560a
4
client.c
4
client.c
|
@ -188,7 +188,7 @@ client_updatetitle(client_t *c)
|
|||
return;
|
||||
|
||||
p_delete(&c->name);
|
||||
c->name = name;
|
||||
a_iso2utf8(name, &c->name);
|
||||
|
||||
/* call hook */
|
||||
luaA_client_userdata_new(c);
|
||||
|
@ -1178,7 +1178,7 @@ luaA_client_name_set(lua_State *L)
|
|||
client_t **c = luaA_checkudata(L, 1, "client");
|
||||
const char *name = luaL_checkstring(L, 2);
|
||||
p_delete(&(*c)->name);
|
||||
(*c)->name = a_strdup(name);
|
||||
a_iso2utf8(name, &(*c)->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
* \param iso the ISO string to convert
|
||||
* \return NULL if error, otherwise pointer to the new converted string
|
||||
*/
|
||||
static char *
|
||||
char *
|
||||
draw_iso2utf8(const char *iso)
|
||||
{
|
||||
iconv_t iso2utf8;
|
||||
|
@ -304,11 +304,7 @@ draw_text(draw_context_t *ctx, font_t *font,
|
|||
if(!(len = a_strlen(text)))
|
||||
return;
|
||||
|
||||
/* try to convert it to UTF-8 */
|
||||
if((utf8 = draw_iso2utf8(text)))
|
||||
len = a_strlen(utf8);
|
||||
else
|
||||
utf8 = a_strdup(text);
|
||||
utf8 = a_strdup(text);
|
||||
|
||||
p_clear(&parser_data, 1);
|
||||
parser_data.connection = ctx->connection;
|
||||
|
@ -1033,10 +1029,7 @@ draw_text_extents(xcb_connection_t *conn, int phys_screen, font_t *font, const c
|
|||
return geom;
|
||||
|
||||
/* try to convert it to UTF-8 */
|
||||
if((utf8 = draw_iso2utf8(text)))
|
||||
len = a_strlen(utf8);
|
||||
else
|
||||
utf8 = a_strdup(text);
|
||||
utf8 = a_strdup(text);
|
||||
|
||||
p_clear(&parser_data, 1);
|
||||
parser_data.connection = conn;
|
||||
|
|
|
@ -139,6 +139,21 @@ draw_context_delete(draw_context_t **ctx)
|
|||
font_t *draw_font_new(xcb_connection_t *, int, const char *);
|
||||
void draw_font_delete(font_t **);
|
||||
|
||||
char * draw_iso2utf8(const char *);
|
||||
|
||||
static inline bool
|
||||
a_iso2utf8(const char *str, char **res)
|
||||
{
|
||||
char *utf8;
|
||||
if((utf8 = draw_iso2utf8(str)))
|
||||
{
|
||||
*res = utf8;
|
||||
return true;
|
||||
}
|
||||
*res = a_strdup(str);
|
||||
return false;
|
||||
}
|
||||
|
||||
void draw_text(draw_context_t *, font_t *, area_t, const char *);
|
||||
void draw_rectangle(draw_context_t *, area_t, float, bool, xcolor_t);
|
||||
void draw_rectangle_gradient(draw_context_t *, area_t, float, bool, area_t, xcolor_t *, xcolor_t *, xcolor_t *);
|
||||
|
|
4
tag.c
4
tag.c
|
@ -65,7 +65,7 @@ tag_new(const char *name, layout_t *layout, double mwfact, int nmaster, int ncol
|
|||
tag_t *tag;
|
||||
|
||||
tag = p_new(tag_t, 1);
|
||||
tag->name = a_strdup(name);
|
||||
a_iso2utf8(name, &tag->name);
|
||||
tag->layout = layout;
|
||||
|
||||
tag->mwfact = mwfact;
|
||||
|
@ -473,7 +473,7 @@ luaA_tag_name_set(lua_State *L)
|
|||
tag_t **tag = luaA_checkudata(L, 1, "tag");
|
||||
const char *name = luaL_checkstring(L, 2);
|
||||
p_delete(&(*tag)->name);
|
||||
(*tag)->name = a_strdup(name);
|
||||
a_iso2utf8(name, &(*tag)->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ textbox_tell(widget_t *widget, const char *property, const char *new_value)
|
|||
if(!a_strcmp(property, "text"))
|
||||
{
|
||||
p_delete(&d->text);
|
||||
d->text = a_strdup(new_value);
|
||||
a_iso2utf8(new_value, &d->text);
|
||||
}
|
||||
else if(!a_strcmp(property, "width"))
|
||||
d->width = atoi(new_value);
|
||||
|
|
Loading…
Reference in New Issue