1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-29 05:12:41 +00:00

convert blink to callbacks.print

This commit is contained in:
Phil Sutter 2009-11-29 12:56:09 +01:00
parent dc0af635d6
commit 3ed82a34dd
4 changed files with 23 additions and 13 deletions

View File

@ -760,3 +760,24 @@ void print_to_bytes(struct text_object *obj, char *p, int p_max_size)
}
snprintf(p, p_max_size, "%s", buf);
}
void print_blink(struct text_object *obj, char *p, int p_max_size)
{
//blinking like this can look a bit ugly if the chars in the font don't have the same width
char buf[max_user_text];
static int visible = 1;
static int last_len = 0;
memset(buf, 0, max_user_text);
if (visible) {
generate_text_internal(buf, max_user_text, *obj->sub, &info);
last_len = strlen(buf);
} else {
for (int i = 0; i < last_len; i++)
buf[i] = ' ';
}
snprintf(p, p_max_size, "%s", buf);
visible = !visible;
}

View File

@ -126,5 +126,6 @@ void print_battery_short(struct text_object *, char *, int);
#endif /* !__OpenBSD__ */
void print_to_bytes(struct text_object *, char *, int);
void print_blink(struct text_object *, char *, int);
#endif /* _COMMON_H */

View File

@ -1153,19 +1153,6 @@ void generate_text_internal(char *p, int p_max_size,
p[0] = 0;
}
}
OBJ(blink) {
//blinking like this can look a bit ugly if the chars in the font don't have the same width
char buf[max_user_text];
unsigned int j;
generate_text_internal(buf, max_user_text, *obj->sub, cur);
snprintf(p, p_max_size, "%s", buf);
if(total_updates % 2) {
for(j=0; p[j] != 0; j++) {
p[j] = ' ';
}
}
}
break;
}
#undef DO_JUMP

View File

@ -1458,6 +1458,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
END OBJ_ARG(blink, 0, "blink needs a argument")
obj->sub = malloc(sizeof(struct text_object));
extract_variable_text_internal(obj->sub, arg);
obj->callbacks.print = &print_blink;
END OBJ_ARG(to_bytes, 0, "to_bytes needs a argument")
obj->sub = malloc(sizeof(struct text_object));
extract_variable_text_internal(obj->sub, arg);