summaryrefslogtreecommitdiffstats
path: root/RichString.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-01-13 19:22:33 +0100
committerChristian Göttsche <cgzones@googlemail.com>2021-01-13 19:22:33 +0100
commit5fde0e012762b07e4955306b743afcf43fe237c6 (patch)
tree9cafb88fd46fc8b9c9a59e0ce948107f1f6becd9 /RichString.c
parent78b993dbb4d58aec8cb5b32f23014eeabd900f2f (diff)
RichString_appendChr: add parameter to set attributes
Allows to set attributes when padding process fields in non-wide ncurses mode. Closes: #475
Diffstat (limited to 'RichString.c')
-rw-r--r--RichString.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/RichString.c b/RichString.c
index ee06dce3..86344eac 100644
--- a/RichString.c
+++ b/RichString.c
@@ -80,6 +80,15 @@ inline void RichString_setAttrn(RichString* this, int attrs, int start, int char
}
}
+void RichString_appendChr(RichString* this, int attrs, char c, int count) {
+ int from = this->chlen;
+ int newLen = from + count;
+ RichString_setLen(this, newLen);
+ for (int i = from; i < newLen; i++) {
+ this->chptr[i] = (CharType) { .attr = attrs, .chars = { c, 0 } };
+ }
+}
+
int RichString_findChar(const RichString* this, char c, int start) {
const wchar_t wc = btowc(c);
const cchar_t* ch = this->chptr + start;
@@ -115,6 +124,15 @@ void RichString_setAttrn(RichString* this, int attrs, int start, int charcount)
}
}
+void RichString_appendChr(RichString* this, int attrs, char c, int count) {
+ int from = this->chlen;
+ int newLen = from + count;
+ RichString_setLen(this, newLen);
+ for (int i = from; i < newLen; i++) {
+ this->chptr[i] = c | attrs;
+ }
+}
+
int RichString_findChar(const RichString* this, char c, int start) {
const chtype* ch = this->chptr + start;
for (int i = start; i < this->chlen; i++) {
@@ -134,15 +152,6 @@ 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);
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy