mirror of https://github.com/xzeldon/htop.git
Fixes for color glitches in ncurses ABI6.
Could no longer reproduce #244 after these fixes.
This commit is contained in:
parent
bdadd45a88
commit
7985724933
11
RichString.c
11
RichString.c
|
@ -44,7 +44,7 @@ in the source distribution for its full text.
|
||||||
#define RichString_printVal(this, y, x) mvadd_wchstr(y, x, (this).chptr)
|
#define RichString_printVal(this, y, x) mvadd_wchstr(y, x, (this).chptr)
|
||||||
#define RichString_printoffnVal(this, y, x, off, n) mvadd_wchnstr(y, x, (this).chptr + off, n)
|
#define RichString_printoffnVal(this, y, x, off, n) mvadd_wchnstr(y, x, (this).chptr + off, n)
|
||||||
#define RichString_getCharVal(this, i) ((this).chptr[i].chars[0] & 255)
|
#define RichString_getCharVal(this, i) ((this).chptr[i].chars[0] & 255)
|
||||||
#define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)].chars[0] = ch; } while(0)
|
#define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)] = (CharType) { .chars = { ch, 0 } }; } while(0)
|
||||||
#define CharType cchar_t
|
#define CharType cchar_t
|
||||||
#else
|
#else
|
||||||
#define RichString_printVal(this, y, x) mvaddchstr(y, x, (this).chptr)
|
#define RichString_printVal(this, y, x) mvaddchstr(y, x, (this).chptr)
|
||||||
|
@ -72,11 +72,11 @@ static void RichString_extendLen(RichString* this, int len) {
|
||||||
if (this->chlen <= RICHSTRING_MAXLEN) {
|
if (this->chlen <= RICHSTRING_MAXLEN) {
|
||||||
if (len > RICHSTRING_MAXLEN) {
|
if (len > RICHSTRING_MAXLEN) {
|
||||||
this->chptr = malloc(charBytes(len + 1));
|
this->chptr = malloc(charBytes(len + 1));
|
||||||
memcpy(this->chptr, this->chstr, charBytes(this->chlen+1));
|
memcpy(this->chptr, this->chstr, charBytes(this->chlen));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (len <= RICHSTRING_MAXLEN) {
|
if (len <= RICHSTRING_MAXLEN) {
|
||||||
memcpy(this->chstr, this->chptr, charBytes(this->chlen));
|
memcpy(this->chstr, this->chptr, charBytes(len));
|
||||||
free(this->chptr);
|
free(this->chptr);
|
||||||
this->chptr = this->chstr;
|
this->chptr = this->chstr;
|
||||||
} else {
|
} else {
|
||||||
|
@ -101,11 +101,8 @@ static inline void RichString_writeFrom(RichString* this, int attrs, const char*
|
||||||
RichString_setLen(this, newLen);
|
RichString_setLen(this, newLen);
|
||||||
for (int i = from, j = 0; i < newLen; i++, j++) {
|
for (int i = from, j = 0; i < newLen; i++, j++) {
|
||||||
CharType* c = &(this->chptr[i]);
|
CharType* c = &(this->chptr[i]);
|
||||||
c->attr = attrs;
|
*c = (CharType) { .attr = attrs, .chars = { (iswprint(data[j]) ? data[j] : '?') } };
|
||||||
c->chars[0] = (iswprint(data[j]) ? data[j] : '?');
|
|
||||||
c->chars[1] = 0;
|
|
||||||
}
|
}
|
||||||
this->chptr[newLen].chars[0] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
|
inline void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
|
||||||
|
|
|
@ -42,7 +42,7 @@ in the source distribution for its full text.
|
||||||
#define RichString_printVal(this, y, x) mvadd_wchstr(y, x, (this).chptr)
|
#define RichString_printVal(this, y, x) mvadd_wchstr(y, x, (this).chptr)
|
||||||
#define RichString_printoffnVal(this, y, x, off, n) mvadd_wchnstr(y, x, (this).chptr + off, n)
|
#define RichString_printoffnVal(this, y, x, off, n) mvadd_wchnstr(y, x, (this).chptr + off, n)
|
||||||
#define RichString_getCharVal(this, i) ((this).chptr[i].chars[0] & 255)
|
#define RichString_getCharVal(this, i) ((this).chptr[i].chars[0] & 255)
|
||||||
#define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)].chars[0] = ch; } while(0)
|
#define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)] = (CharType) { .chars = { ch, 0 } }; } while(0)
|
||||||
#define CharType cchar_t
|
#define CharType cchar_t
|
||||||
#else
|
#else
|
||||||
#define RichString_printVal(this, y, x) mvaddchstr(y, x, (this).chptr)
|
#define RichString_printVal(this, y, x) mvaddchstr(y, x, (this).chptr)
|
||||||
|
|
Loading…
Reference in New Issue