mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-20 11:35:42 +02:00
particles/string: rewrite truncation code, show three dots only for max>3
This commit is contained in:
parent
d5823bcc4c
commit
176ed4a6f3
1 changed files with 4 additions and 14 deletions
|
@ -180,20 +180,10 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
||||||
|
|
||||||
/* Truncate, if necessary */
|
/* Truncate, if necessary */
|
||||||
if (p->max_len > 0 && chars > p->max_len) {
|
if (p->max_len > 0 && chars > p->max_len) {
|
||||||
size_t end = p->max_len;
|
chars = p->max_len;
|
||||||
if (end >= 1) {
|
if (p->max_len > 3)
|
||||||
/* "allocate" room for three dots at the end */
|
wtext[p->max_len - 1] = U'…';
|
||||||
end -= 1;
|
wtext[p->max_len] = U'\0';
|
||||||
}
|
|
||||||
|
|
||||||
if (p->max_len > 1) {
|
|
||||||
wtext[end] = U'…';
|
|
||||||
wtext[end + 1] = U'\0';
|
|
||||||
chars = end + 1;
|
|
||||||
} else {
|
|
||||||
wtext[end] = U'\0';
|
|
||||||
chars = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e->kern_x = calloc(chars, sizeof(e->kern_x[0]));
|
e->kern_x = calloc(chars, sizeof(e->kern_x[0]));
|
||||||
|
|
Loading…
Add table
Reference in a new issue