diff --git a/awesomerc.5.txt b/awesomerc.5.txt index 57f89902..832ba045 100644 --- a/awesomerc.5.txt +++ b/awesomerc.5.txt @@ -49,9 +49,6 @@ List of *awesome* markup elements and their attributes: - image: path to a background image - align: background image alignment - resize: resize background image to text size -* border - - color: border color - - width: border width * margin - left: left margin in pixel - right: right margin in pixel diff --git a/draw.c b/draw.c index 97c245ee..06313a4f 100644 --- a/draw.c +++ b/draw.c @@ -164,58 +164,39 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem, /* hack: markup.c validates tags so we can avoid strcmps here */ switch (*elem) { case 'b': - if(elem[1] == 'g') /* bg? */ - { - if(elem[2] == '_') /* bg_margin */ - for(; *names; names++, values++) - switch(a_tokenize(*names, -1)) - { - case A_TK_LEFT: - data->bg_margin.left = atoi(*values); - break; - case A_TK_TOP: - data->bg_margin.top = atoi(*values); - default: - break; - } - else /* bg */ - for(; *names; names++, values++) - switch(a_tokenize(*names, -1)) - { - case A_TK_COLOR: - reqs[++reqs_nbr] = xcolor_init_unchecked(&data->bg_color, - *values, - a_strlen(*values)); - - bg_color_nbr = reqs_nbr; - break; - case A_TK_IMAGE: - if(data->bg_image) - image_delete(&data->bg_image); - data->bg_image = image_new_from_file(*values); - break; - case A_TK_ALIGN: - data->bg_align = draw_align_fromstr(*values, -1); - break; - case A_TK_RESIZE: - data->bg_resize = a_strtobool(*values, -1); - default: - break; - } - - } - else /* border */ + if(elem[2] == '_') /* bg_margin */ + for(; *names; names++, values++) + switch(a_tokenize(*names, -1)) + { + case A_TK_LEFT: + data->bg_margin.left = atoi(*values); + break; + case A_TK_TOP: + data->bg_margin.top = atoi(*values); + default: + break; + } + else /* bg */ for(; *names; names++, values++) switch(a_tokenize(*names, -1)) { case A_TK_COLOR: - reqs[++reqs_nbr] = xcolor_init_unchecked(&data->border.color, + reqs[++reqs_nbr] = xcolor_init_unchecked(&data->bg_color, *values, a_strlen(*values)); + + bg_color_nbr = reqs_nbr; break; - case A_TK_WIDTH: - data->border.width = atoi(*values); + case A_TK_IMAGE: + if(data->bg_image) + image_delete(&data->bg_image); + data->bg_image = image_new_from_file(*values); break; + case A_TK_ALIGN: + data->bg_align = draw_align_fromstr(*values, -1); + break; + case A_TK_RESIZE: + data->bg_resize = a_strtobool(*values, -1); default: break; } @@ -268,7 +249,7 @@ static bool draw_text_markup_expand(draw_parser_data_t *data, const char *str, ssize_t slen) { - static char const * const elements[] = { "bg", "bg_margin", "text", "margin", "border", NULL }; + static char const * const elements[] = { "bg", "bg_margin", "text", "margin", NULL }; markup_parser_data_t p = { .elements = elements, @@ -366,9 +347,6 @@ draw_text(draw_context_t *ctx, font_t *font, PangoEllipsizeMode ellip, PangoWrap if(pdata->has_bg_color) draw_rectangle(ctx, area, 1.0, true, &pdata->bg_color); - if(pdata->border.width > 0) - draw_rectangle(ctx, area, pdata->border.width, false, &pdata->border.color); - if(pdata->bg_image) { x = area.x; diff --git a/draw.h b/draw.h index 443a1b52..047070ae 100644 --- a/draw.h +++ b/draw.h @@ -170,11 +170,6 @@ typedef struct int offset; xcolor_t color; } shadow; - struct - { - int width; - xcolor_t color; - } border; } draw_parser_data_t; void draw_text(draw_context_t *, font_t *, PangoEllipsizeMode, PangoWrapMode, area_t, const char *, ssize_t len, draw_parser_data_t *, area_t *); diff --git a/widgets/textbox.c b/widgets/textbox.c index 35710d58..6ae01679 100644 --- a/widgets/textbox.c +++ b/widgets/textbox.c @@ -39,6 +39,12 @@ typedef struct PangoWrapMode wrap; /** Draw parser data */ draw_parser_data_t pdata; + /** Border */ + struct + { + int width; + xcolor_t color; + } border; } textbox_data_t; static area_t @@ -76,6 +82,10 @@ textbox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry, int screen, wibox_t *p) { textbox_data_t *d = widget->data; + + if(d->border.width > 0) + draw_rectangle(ctx, geometry, d->border.width, false, &d->border.color); + draw_text(ctx, globalconf.font, d->ellip, d->wrap, geometry, d->text, d->len, &d->pdata, &d->extents); } @@ -100,6 +110,8 @@ textbox_destructor(widget_t *w) * \lfield width The width of the textbox. Set to 0 for auto. * \lfield wrap The wrap mode: word, char, word_char. * \lfield ellipsize The ellipsize mode: start, middle or end. + * \lfield border_width The border width to draw around. + * \lfield border_color The border color. */ static int luaA_textbox_index(lua_State *L, awesome_token_t token) @@ -109,6 +121,12 @@ luaA_textbox_index(lua_State *L, awesome_token_t token) switch(token) { + case A_TK_BORDER_WIDTH: + lua_pushnumber(L, d->border.width); + return 1; + case A_TK_BORDER_COLOR: + luaA_pushcolor(L, &d->border.color); + return 1; case A_TK_TEXT: lua_pushstring(L, d->text); return 1; @@ -163,6 +181,13 @@ luaA_textbox_newindex(lua_State *L, awesome_token_t token) switch(token) { + case A_TK_BORDER_COLOR: + if((buf = luaL_checklstring(L, 3, &len))) + xcolor_init_reply(xcolor_init_unchecked(&d->border.color, buf, len)); + break; + case A_TK_BORDER_WIDTH: + d->border.width = luaL_checknumber(L, 3); + break; case A_TK_TEXT: if(lua_isnil(L, 3) || (buf = luaL_checklstring(L, 3, &len)))