diff --git a/src/conky.c b/src/conky.c index 9fbbeded..686f286d 100644 --- a/src/conky.c +++ b/src/conky.c @@ -1264,7 +1264,7 @@ void generate_text_internal(char *p, int p_max_size, new_goto(p, obj->data.i); } OBJ(tab) { - new_tab(p, obj->data.pair.a, obj->data.pair.b); + new_tab(obj, p); } #ifdef X11 OBJ(hr) { diff --git a/src/core.c b/src/core.c index 1843e5dc..444b3e3a 100644 --- a/src/core.c +++ b/src/core.c @@ -518,19 +518,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long END OBJ_ARG(goto, 0, "goto needs arguments") obj->data.i = atoi(arg); END OBJ(tab, 0) - int a = 10, b = 0; - - if (arg) { - if (sscanf(arg, "%d %d", &a, &b) != 2) { - sscanf(arg, "%d", &b); - } - } - if (a <= 0) { - a = 1; - } - obj->data.pair.a = a; - obj->data.pair.b = b; - + scan_tab(obj, arg); #ifdef __linux__ END OBJ_ARG(i2c, 0, "i2c needs arguments") parse_i2c_sensor(obj, arg); diff --git a/src/specials.c b/src/specials.c index 0805a71e..3c6a04c3 100644 --- a/src/specials.c +++ b/src/specials.c @@ -70,6 +70,10 @@ struct graph { char tempgrad; }; +struct tab { + int width, arg; +}; + /* * Scanning arguments to various special text objects */ @@ -485,11 +489,36 @@ void new_goto(char *buf, long c) new_special(buf, GOTO)->arg = c; } -void new_tab(char *buf, int a, int b) +void scan_tab(struct text_object *obj, const char *arg) { - struct special_t *s = new_special(buf, TAB); + struct tab *t; - s->width = a; - s->arg = b; + t = malloc(sizeof(struct tab)); + memset(t, 0, sizeof(struct tab)); + + t->width = 10; + t->arg = 0; + + if (arg) { + if (sscanf(arg, "%d %d", &t->width, &t->arg) != 2) { + sscanf(arg, "%d", &t->arg); + } + } + if (t->width <= 0) { + t->width = 1; + } + obj->special_data = t; } +void new_tab(struct text_object *obj, char *buf) +{ + struct special_t *s = 0; + struct tab *t = obj->special_data; + + if (!t) + return; + + s = new_special(buf, TAB); + s->width = t->width; + s->arg = t->arg; +} diff --git a/src/specials.h b/src/specials.h index 9a986c89..06ea94c2 100644 --- a/src/specials.h +++ b/src/specials.h @@ -104,6 +104,7 @@ const char *scan_bar(struct text_object *, const char *); const char *scan_gauge(struct text_object *, const char *); char *scan_font(const char *); char *scan_graph(struct text_object *, const char *); +void scan_tab(struct text_object *, const char *); /* printing specials */ void new_gauge(struct text_object *, char *, int); @@ -122,6 +123,6 @@ void new_voffset(char *, long); void new_alignr(char *, long); void new_alignc(char *, long); void new_goto(char *, long); -void new_tab(char *, int, int); +void new_tab(struct text_object *, char *); #endif /* _SPECIALS_H */