mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-01 06:11:49 +00:00
convert blink to callbacks.print
This commit is contained in:
parent
dc0af635d6
commit
3ed82a34dd
21
src/common.c
21
src/common.c
@ -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);
|
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;
|
||||||
|
}
|
||||||
|
@ -126,5 +126,6 @@ void print_battery_short(struct text_object *, char *, int);
|
|||||||
#endif /* !__OpenBSD__ */
|
#endif /* !__OpenBSD__ */
|
||||||
|
|
||||||
void print_to_bytes(struct text_object *, char *, int);
|
void print_to_bytes(struct text_object *, char *, int);
|
||||||
|
void print_blink(struct text_object *, char *, int);
|
||||||
|
|
||||||
#endif /* _COMMON_H */
|
#endif /* _COMMON_H */
|
||||||
|
13
src/conky.c
13
src/conky.c
@ -1153,19 +1153,6 @@ void generate_text_internal(char *p, int p_max_size,
|
|||||||
p[0] = 0;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
#undef DO_JUMP
|
#undef DO_JUMP
|
||||||
|
@ -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")
|
END OBJ_ARG(blink, 0, "blink needs a argument")
|
||||||
obj->sub = malloc(sizeof(struct text_object));
|
obj->sub = malloc(sizeof(struct text_object));
|
||||||
extract_variable_text_internal(obj->sub, arg);
|
extract_variable_text_internal(obj->sub, arg);
|
||||||
|
obj->callbacks.print = &print_blink;
|
||||||
END OBJ_ARG(to_bytes, 0, "to_bytes needs a argument")
|
END OBJ_ARG(to_bytes, 0, "to_bytes needs a argument")
|
||||||
obj->sub = malloc(sizeof(struct text_object));
|
obj->sub = malloc(sizeof(struct text_object));
|
||||||
extract_variable_text_internal(obj->sub, arg);
|
extract_variable_text_internal(obj->sub, arg);
|
||||||
|
Loading…
Reference in New Issue
Block a user