specials: convert stippled_hr object to new style
authorPhil Sutter <phil@nwl.cc>
Thu, 29 Oct 2009 02:22:58 +0000 (03:22 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 3 Nov 2009 22:23:23 +0000 (23:23 +0100)
src/conky.c
src/core.c
src/specials.c
src/specials.h

index 686f286..4d43416 100644 (file)
@@ -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) {
index 444b3e3..0c314df 100644 (file)
@@ -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)
index 3c6a04c..f604154 100644 (file)
@@ -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 */
 
index 06ea94c..24aa330 100644 (file)
@@ -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);