mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-24 11:55:43 +00:00
specials: convert tab object to new style
This commit is contained in:
parent
50e2b5961a
commit
3458db80aa
@ -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) {
|
||||
|
14
src/core.c
14
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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user