draw: Stop using a_tokenize
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
f61dca7068
commit
56fd77139e
24
draw.c
24
draw.c
|
@ -32,7 +32,6 @@
|
|||
#include "globalconf.h"
|
||||
#include "screen.h"
|
||||
|
||||
#include "common/tokenize.h"
|
||||
#include "common/xutil.h"
|
||||
|
||||
/** Convert text from any charset to UTF-8 using iconv.
|
||||
|
@ -366,21 +365,22 @@ draw_text_extents(draw_text_context_t *data)
|
|||
/** Transform a string to a alignment_t type.
|
||||
* Recognized string are flex, fixed, left, center, middle or right.
|
||||
* \param align A string with align text.
|
||||
* \param len The string length.
|
||||
* \return An alignment_t type.
|
||||
*/
|
||||
alignment_t
|
||||
draw_align_fromstr(const char *align, ssize_t len)
|
||||
draw_align_fromstr(const char *align)
|
||||
{
|
||||
switch(a_tokenize(align, len))
|
||||
{
|
||||
case A_TK_CENTER: return AlignCenter;
|
||||
case A_TK_RIGHT: return AlignRight;
|
||||
case A_TK_TOP: return AlignTop;
|
||||
case A_TK_BOTTOM: return AlignBottom;
|
||||
case A_TK_MIDDLE: return AlignMiddle;
|
||||
default: return AlignLeft;
|
||||
}
|
||||
if(a_strcmp(align, "center") == 0)
|
||||
return AlignCenter;
|
||||
if(a_strcmp(align, "right") == 0)
|
||||
return AlignRight;
|
||||
if(a_strcmp(align, "top") == 0)
|
||||
return AlignTop;
|
||||
if(a_strcmp(align, "bottom") == 0)
|
||||
return AlignBottom;
|
||||
if(a_strcmp(align, "middle") == 0)
|
||||
return AlignMiddle;
|
||||
return AlignLeft;
|
||||
}
|
||||
|
||||
/** Transform an alignment to a string.
|
||||
|
|
2
draw.h
2
draw.h
|
@ -130,7 +130,7 @@ void draw_rectangle(draw_context_t *, area_t, float, bool, const color_t *);
|
|||
void draw_image(draw_context_t *, int, int, double, image_t *);
|
||||
void draw_rotate(draw_context_t *, xcb_drawable_t, xcb_drawable_t, int, int, int, int, double, int, int);
|
||||
area_t draw_text_extents(draw_text_context_t *);
|
||||
alignment_t draw_align_fromstr(const char *, ssize_t);
|
||||
alignment_t draw_align_fromstr(const char *);
|
||||
const char *draw_align_tostr(alignment_t);
|
||||
|
||||
static inline void
|
||||
|
|
|
@ -332,8 +332,8 @@ luaA_textbox_newindex(lua_State *L, const char *prop)
|
|||
|
||||
if(a_strcmp(prop, "bg_align") == 0)
|
||||
{
|
||||
buf = luaL_checklstring(L, 3, &len);
|
||||
d->bg_align = draw_align_fromstr(buf, len);
|
||||
buf = luaL_checkstring(L, 3);
|
||||
d->bg_align = draw_align_fromstr(buf);
|
||||
}
|
||||
else if(a_strcmp(prop, "bg_resize") == 0)
|
||||
d->bg_resize = luaA_checkboolean(L, 3);
|
||||
|
@ -352,13 +352,13 @@ luaA_textbox_newindex(lua_State *L, const char *prop)
|
|||
}
|
||||
else if(a_strcmp(prop, "align") == 0)
|
||||
{
|
||||
if((buf = luaL_checklstring(L, 3, &len)))
|
||||
d->align = draw_align_fromstr(buf, len);
|
||||
if((buf = luaL_checkstring(L, 3)))
|
||||
d->align = draw_align_fromstr(buf);
|
||||
}
|
||||
else if(a_strcmp(prop, "valign") == 0)
|
||||
{
|
||||
if((buf = luaL_checklstring(L, 3, &len)))
|
||||
d->valign = draw_align_fromstr(buf, len);
|
||||
if((buf = luaL_checkstring(L, 3)))
|
||||
d->valign = draw_align_fromstr(buf);
|
||||
}
|
||||
else if(a_strcmp(prop, "border_color") == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue