Fully support non-ascii characters in Meter-Bar

Currently the code does not handle multi-byte characters, so length-
computations take the raw count of C characters and not the to displayed
size into account.

An example is the degree sign for temperatures.

Closes: #329
This commit is contained in:
Christian Göttsche
2020-11-23 20:12:11 +01:00
committed by cgzones
parent c038326a70
commit adf9185209
3 changed files with 28 additions and 8 deletions

View File

@ -119,6 +119,15 @@ void RichString_prune(RichString* this) {
this->chptr = this->chstr;
}
void RichString_appendChr(RichString* this, char c, int count) {
int from = this->chlen;
int newLen = from + count;
RichString_setLen(this, newLen);
for (int i = from; i < newLen; i++) {
RichString_setChar(this, i, c);
}
}
void RichString_setAttr(RichString* this, int attrs) {
RichString_setAttrn(this, attrs, 0, this->chlen - 1);
}