1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-29 13:39:10 +00:00

Added lower_case and upper_case commands

This commit is contained in:
AlexApps99 2020-01-14 17:10:19 +13:00 committed by Brenden Matthews
parent 6ad788b78d
commit 1bb8754dce
4 changed files with 45 additions and 1 deletions

View File

@ -3847,7 +3847,27 @@
</command>
<option>text</option>
</term>
<listitem>All words capitalized regardless.
<listitem>Capitalises the start of each word.
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>lower_case</option>
</command>
<option>text</option>
</term>
<listitem>Converts all letters into lowercase.
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>upper_case</option>
</command>
<option>text</option>
</term>
<listitem>Converts all letters into uppercase.
<para /></listitem>
</varlistentry>
<varlistentry>

View File

@ -886,6 +886,12 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
END OBJ(start_case, 0) obj->data.s = STRNDUP_ARG;
obj->callbacks.print = &print_cap;
obj->callbacks.free = &gen_free_opaque;
END OBJ(lower_case, 0) obj->data.s = STRNDUP_ARG;
obj->callbacks.print = &print_lower;
obj->callbacks.free = &gen_free_opaque;
END OBJ(upper_case, 0) obj->data.s = STRNDUP_ARG;
obj->callbacks.print = &print_upper;
obj->callbacks.free = &gen_free_opaque;
END OBJ(catp, 0) obj->data.s = STRNDUP_ARG;
obj->callbacks.print = &print_catp;
obj->callbacks.free = &gen_free_opaque;

View File

@ -108,6 +108,22 @@ void print_cap(struct text_object *obj, char *p, unsigned int p_max_size) {
snprintf(p, p_max_size, "%s", buf);
}
void print_lower(struct text_object *obj, char *p, unsigned int p_max_size) {
evaluate(obj->data.s, p, p_max_size);
for (unsigned int x = 0; x < p_max_size-1 && p[x]; x++) {
p[x] = tolower(p[x]);
}
p[p_max_size-1] = '\0';
}
void print_upper(struct text_object *obj, char *p, unsigned int p_max_size) {
evaluate(obj->data.s, p, p_max_size);
for (unsigned int x = 0; x < p_max_size-1 && p[x]; x++) {
p[x] = toupper(p[x]);
}
p[p_max_size-1] = '\0';
}
long long int apply_base_multiplier(const char *s, long long int num) {
long long int base = 1024LL;
if (*s && (0 == (strcmp(s, "si")))) { base = 1000LL; }

View File

@ -36,5 +36,7 @@
void print_cat(struct text_object *, char *, unsigned int);
void print_catp(struct text_object *, char *, unsigned int);
void print_cap(struct text_object *, char *, unsigned int);
void print_lower(struct text_object *, char *, unsigned int);
void print_upper(struct text_object *, char *, unsigned int);
long long apply_base_multiplier(const char *, long long int);
#endif /* _MISC_H */