Rename is_markup to pango_markup.
This commit is contained in:
parent
82dc747396
commit
fec61791e1
@ -49,7 +49,7 @@ struct status_block {
|
||||
|
||||
bool urgent;
|
||||
bool no_separator;
|
||||
bool is_markup;
|
||||
bool pango_markup;
|
||||
|
||||
/* The amount of pixels necessary to render a separater after the block. */
|
||||
uint32_t sep_block_width;
|
||||
|
@ -206,7 +206,7 @@ static int stdin_string(void *context, const unsigned char *val, size_t len) {
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp(ctx->last_map_key, "markup") == 0) {
|
||||
ctx->block.is_markup = (len == strlen("pango") && !strncasecmp((const char *)val, "pango", strlen("pango")));
|
||||
ctx->block.pango_markup = (len == strlen("pango") && !strncasecmp((const char *)val, "pango", strlen("pango")));
|
||||
return 1;
|
||||
}
|
||||
if (strcasecmp(ctx->last_map_key, "align") == 0) {
|
||||
@ -275,15 +275,15 @@ static int stdin_end_map(void *context) {
|
||||
|
||||
if (new_block->min_width_str) {
|
||||
i3String *text = i3string_from_utf8(new_block->min_width_str);
|
||||
i3string_set_markup(text, new_block->is_markup);
|
||||
i3string_set_markup(text, new_block->pango_markup);
|
||||
new_block->min_width = (uint32_t)predict_text_width(text);
|
||||
i3string_free(text);
|
||||
}
|
||||
|
||||
i3string_set_markup(new_block->full_text, new_block->is_markup);
|
||||
i3string_set_markup(new_block->full_text, new_block->pango_markup);
|
||||
|
||||
if (new_block->short_text != NULL)
|
||||
i3string_set_markup(new_block->short_text, new_block->is_markup);
|
||||
i3string_set_markup(new_block->short_text, new_block->pango_markup);
|
||||
|
||||
TAILQ_INSERT_TAIL(&statusline_buffer, new_block, blocks);
|
||||
return 1;
|
||||
|
@ -243,7 +243,7 @@ bool i3string_is_markup(i3String *str);
|
||||
/**
|
||||
* Set whether the i3String should use Pango markup.
|
||||
*/
|
||||
void i3string_set_markup(i3String *str, bool is_markup);
|
||||
void i3string_set_markup(i3String *str, bool pango_markup);
|
||||
|
||||
/**
|
||||
* Escape pango markup characters in the given string.
|
||||
|
@ -103,7 +103,7 @@ static bool load_pango_font(i3Font *font, const char *desc) {
|
||||
*/
|
||||
static void draw_text_pango(const char *text, size_t text_len,
|
||||
xcb_drawable_t drawable, xcb_visualtype_t *visual, int x, int y,
|
||||
int max_width, bool is_markup) {
|
||||
int max_width, bool pango_markup) {
|
||||
/* Create the Pango layout */
|
||||
/* root_visual_type is cached in load_pango_font */
|
||||
cairo_surface_t *surface = cairo_xcb_surface_create(conn, drawable,
|
||||
@ -117,7 +117,7 @@ static void draw_text_pango(const char *text, size_t text_len,
|
||||
pango_layout_set_wrap(layout, PANGO_WRAP_CHAR);
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||
|
||||
if (is_markup)
|
||||
if (pango_markup)
|
||||
pango_layout_set_markup(layout, text, text_len);
|
||||
else
|
||||
pango_layout_set_text(layout, text, text_len);
|
||||
@ -143,7 +143,7 @@ static void draw_text_pango(const char *text, size_t text_len,
|
||||
* Calculate the text width using Pango rendering.
|
||||
*
|
||||
*/
|
||||
static int predict_text_width_pango(const char *text, size_t text_len, bool is_markup) {
|
||||
static int predict_text_width_pango(const char *text, size_t text_len, bool pango_markup) {
|
||||
/* Create a dummy Pango layout */
|
||||
/* root_visual_type is cached in load_pango_font */
|
||||
cairo_surface_t *surface = cairo_xcb_surface_create(conn, root_screen->root, root_visual_type, 1, 1);
|
||||
@ -154,7 +154,7 @@ static int predict_text_width_pango(const char *text, size_t text_len, bool is_m
|
||||
gint width;
|
||||
pango_layout_set_font_description(layout, savedFont->specific.pango_desc);
|
||||
|
||||
if (is_markup)
|
||||
if (pango_markup)
|
||||
pango_layout_set_markup(layout, text, text_len);
|
||||
else
|
||||
pango_layout_set_text(layout, text, text_len);
|
||||
|
@ -24,7 +24,7 @@ struct _i3String {
|
||||
xcb_char2b_t *ucs2;
|
||||
size_t num_glyphs;
|
||||
size_t num_bytes;
|
||||
bool is_markup;
|
||||
bool pango_markup;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -52,7 +52,7 @@ i3String *i3string_from_markup(const char *from_markup) {
|
||||
i3String *str = i3string_from_utf8(from_markup);
|
||||
|
||||
/* Set the markup flag */
|
||||
str->is_markup = true;
|
||||
str->pango_markup = true;
|
||||
|
||||
return str;
|
||||
}
|
||||
@ -86,7 +86,7 @@ i3String *i3string_from_markup_with_length(const char *from_markup, size_t num_b
|
||||
i3String *str = i3string_from_utf8_with_length(from_markup, num_bytes);
|
||||
|
||||
/* set the markup flag */
|
||||
str->is_markup = true;
|
||||
str->pango_markup = true;
|
||||
|
||||
return str;
|
||||
}
|
||||
@ -118,7 +118,7 @@ i3String *i3string_from_ucs2(const xcb_char2b_t *from_ucs2, size_t num_glyphs) {
|
||||
*/
|
||||
i3String *i3string_copy(i3String *str) {
|
||||
i3String *copy = i3string_from_utf8(i3string_as_utf8(str));
|
||||
copy->is_markup = str->is_markup;
|
||||
copy->pango_markup = str->pango_markup;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@ -178,14 +178,14 @@ size_t i3string_get_num_bytes(i3String *str) {
|
||||
* Whether the given i3String is in Pango markup.
|
||||
*/
|
||||
bool i3string_is_markup(i3String *str) {
|
||||
return str->is_markup;
|
||||
return str->pango_markup;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set whether the i3String should use Pango markup.
|
||||
*/
|
||||
void i3string_set_markup(i3String *str, bool is_markup) {
|
||||
str->is_markup = is_markup;
|
||||
void i3string_set_markup(i3String *str, bool pango_markup) {
|
||||
str->pango_markup = pango_markup;
|
||||
}
|
||||
|
||||
/*
|
||||
|
10
src/window.c
10
src/window.c
@ -342,7 +342,7 @@ void window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, bo
|
||||
i3String *window_parse_title_format(i3Window *win) {
|
||||
/* We need to ensure that we only escape the window title if pango
|
||||
* is used by the current font. */
|
||||
const bool is_markup = font_is_pango();
|
||||
const bool pango_markup = font_is_pango();
|
||||
|
||||
char *format = win->title_format;
|
||||
if (format == NULL)
|
||||
@ -359,19 +359,19 @@ i3String *window_parse_title_format(i3Window *win) {
|
||||
for (char *walk = format; *walk != '\0'; walk++) {
|
||||
if (STARTS_WITH(walk, "%title")) {
|
||||
if (escaped_title == NULL)
|
||||
escaped_title = win->name == NULL ? "" : i3string_as_utf8(is_markup ? i3string_escape_markup(win->name) : win->name);
|
||||
escaped_title = win->name == NULL ? "" : i3string_as_utf8(pango_markup ? i3string_escape_markup(win->name) : win->name);
|
||||
|
||||
buffer_len = buffer_len - strlen("%title") + strlen(escaped_title);
|
||||
walk += strlen("%title") - 1;
|
||||
} else if (STARTS_WITH(walk, "%class")) {
|
||||
if (escaped_class == NULL)
|
||||
escaped_class = is_markup ? g_markup_escape_text(win->class_class, -1) : win->class_class;
|
||||
escaped_class = pango_markup ? g_markup_escape_text(win->class_class, -1) : win->class_class;
|
||||
|
||||
buffer_len = buffer_len - strlen("%class") + strlen(escaped_class);
|
||||
walk += strlen("%class") - 1;
|
||||
} else if (STARTS_WITH(walk, "%instance")) {
|
||||
if (escaped_instance == NULL)
|
||||
escaped_instance = is_markup ? g_markup_escape_text(win->class_instance, -1) : win->class_instance;
|
||||
escaped_instance = pango_markup ? g_markup_escape_text(win->class_instance, -1) : win->class_instance;
|
||||
|
||||
buffer_len = buffer_len - strlen("%instance") + strlen(escaped_instance);
|
||||
walk += strlen("%instance") - 1;
|
||||
@ -403,6 +403,6 @@ i3String *window_parse_title_format(i3Window *win) {
|
||||
*outwalk = '\0';
|
||||
|
||||
i3String *formatted = i3string_from_utf8(buffer);
|
||||
i3string_set_markup(formatted, is_markup);
|
||||
i3string_set_markup(formatted, pango_markup);
|
||||
return formatted;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user