From 041059f1c2ec512663fd3e0154606ba47ef421f1 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 29 Oct 2009 03:22:58 +0100 Subject: [PATCH] specials: convert stippled_hr object to new style --- src/conky.c | 2 +- src/core.c | 13 +------------ src/specials.c | 35 ++++++++++++++++++++++++++++++++--- src/specials.h | 3 ++- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/conky.c b/src/conky.c index 686f286d..4d434164 100644 --- a/src/conky.c +++ b/src/conky.c @@ -1606,7 +1606,7 @@ void generate_text_internal(char *p, int p_max_size, new_bg(p, obj->data.l); } OBJ(stippled_hr) { - new_stippled_hr(p, obj->data.pair.a, obj->data.pair.b); + new_stippled_hr(obj, p); } #endif /* X11 */ OBJ(swap) { diff --git a/src/core.c b/src/core.c index 444b3e3a..0c314df5 100644 --- a/src/core.c +++ b/src/core.c @@ -669,18 +669,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long #endif /* X11 */ END OBJ(stippled_hr, 0) #ifdef X11 - int a = get_stippled_borders(), b = 1; - - 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_stippled_hr(obj, arg); #endif /* X11 */ END OBJ(swap, &update_meminfo) END OBJ(swapfree, &update_meminfo) diff --git a/src/specials.c b/src/specials.c index 3c6a04c3..f604154d 100644 --- a/src/specials.c +++ b/src/specials.c @@ -70,6 +70,10 @@ struct graph { char tempgrad; }; +struct stippled_hr { + int height, arg; +}; + struct tab { int width, arg; }; @@ -387,17 +391,42 @@ void new_hr(char *buf, int a) new_special(buf, HORIZONTAL_LINE)->height = a; } -void new_stippled_hr(char *buf, int a, int b) +void scan_stippled_hr(struct text_object *obj, const char *arg) +{ + struct stippled_hr *sh; + + sh = malloc(sizeof(struct stippled_hr)); + memset(sh, 0, sizeof(struct stippled_hr)); + + sh->arg = get_stippled_borders(); + sh->height = 1; + + if (arg) { + if (sscanf(arg, "%d %d", &sh->arg, &sh->height) != 2) { + sscanf(arg, "%d", &sh->height); + } + } + if (sh->arg <= 0) { + sh->arg = 1; + } + obj->special_data = sh; +} + +void new_stippled_hr(struct text_object *obj, char *buf) { struct special_t *s = 0; + struct stippled_hr *sh = obj->special_data; if ((output_methods & TO_X) == 0) return; + if (!sh) + return; + s = new_special(buf, STIPPLED_HR); - s->height = b; - s->arg = a; + s->height = sh->height; + s->arg = sh->arg; } #endif /* X11 */ diff --git a/src/specials.h b/src/specials.h index 06ea94c2..24aa3308 100644 --- a/src/specials.h +++ b/src/specials.h @@ -105,6 +105,7 @@ 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 *); +void scan_stippled_hr(struct text_object *, const char*); /* printing specials */ void new_gauge(struct text_object *, char *, int); @@ -112,7 +113,7 @@ void new_bar(struct text_object *, char *, int); void new_font(char *, char *); void new_graph(struct text_object *, char *, double); void new_hr(char *, int); -void new_stippled_hr(char *, int, int); +void new_stippled_hr(struct text_object *, char *); #endif void new_bar_in_shell(struct text_object *, char *, int, double); void new_fg(char *, long);