From 4d7f2e720d502d7df099dfa014afc567df95b4c2 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Mon, 23 Nov 2009 23:36:57 +0100 Subject: [PATCH] merge lua_bar to callbacks.barval --- src/core.c | 2 +- src/llua.c | 5 +++-- src/llua.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core.c b/src/core.c index 1b1f6fb1..842709a0 100644 --- a/src/core.c +++ b/src/core.c @@ -1330,7 +1330,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long } else { CRIT_ERR(obj, free_at_crash, "lua_bar needs arguments: , [function parameters]"); } - obj->callbacks.print = &print_lua_bar; + obj->callbacks.barval = &lua_barval; obj->callbacks.free = &gen_free_opaque; #ifdef X11 END OBJ_ARG(lua_graph, 0, "lua_graph needs arguments: [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]") diff --git a/src/llua.c b/src/llua.c index bb9b2d32..8c12a2f7 100644 --- a/src/llua.c +++ b/src/llua.c @@ -546,12 +546,13 @@ void print_lua_parse(struct text_object *obj, char *p, int p_max_size) } } -void print_lua_bar(struct text_object *obj, char *p, int p_max_size) +uint8_t lua_barval(struct text_object *obj) { double per; if (llua_getnumber(obj->data.s, &per)) { - new_bar(obj, p, p_max_size, (per/100.0 * 255)); + return round_to_int(per * 2.55); } + return 0; } #ifdef X11 diff --git a/src/llua.h b/src/llua.h index 0c940342..291b2e77 100644 --- a/src/llua.h +++ b/src/llua.h @@ -67,7 +67,7 @@ void llua_update_info(struct information *i, double u_interval); void print_lua(struct text_object *, char *, int); void print_lua_parse(struct text_object *, char *, int); -void print_lua_bar(struct text_object *, char *, int); +uint8_t lua_barval(struct text_object *); #ifdef X11 void print_lua_graph(struct text_object *, char *, int); #endif /* X11 */