mirror of https://github.com/xzeldon/htop.git
LED Meter: display wide characters and restore non-wide ncurses support
Print wide characters, like degree sign, properly via mvadd_wch(). Ignore attributes when returning value from RichString_getCharVal() in non-wide ncurses mode to test against raw characters.
This commit is contained in:
parent
b9adc30b86
commit
b5a5e83470
7
Meter.c
7
Meter.c
|
@ -414,10 +414,15 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
int c = RichString_getCharVal(out, i);
|
int c = RichString_getCharVal(out, i);
|
||||||
if (c >= '0' && c <= '9') {
|
if (c >= '0' && c <= '9') {
|
||||||
LEDMeterMode_drawDigit(xx, y, c - 48);
|
LEDMeterMode_drawDigit(xx, y, c - '0');
|
||||||
xx += 4;
|
xx += 4;
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef HAVE_LIBNCURSESW
|
||||||
|
out.chptr[i].attr = 0; /* use LED_COLOR from attrset() */
|
||||||
|
mvadd_wch(yText, xx, &out.chptr[i]);
|
||||||
|
#else
|
||||||
mvaddch(yText, xx, c);
|
mvaddch(yText, xx, c);
|
||||||
|
#endif
|
||||||
xx += 1;
|
xx += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,13 @@ in the source distribution for its full text.
|
||||||
#ifdef HAVE_LIBNCURSESW
|
#ifdef HAVE_LIBNCURSESW
|
||||||
#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])
|
||||||
#define RichString_setChar(this, at, ch) do { (this)->chptr[(at)] = (CharType) { .chars = { ch, 0 } }; } 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)
|
||||||
#define RichString_printoffnVal(this, y, x, off, n) mvaddchnstr(y, x, (this).chptr + (off), n)
|
#define RichString_printoffnVal(this, y, x, off, n) mvaddchnstr(y, x, (this).chptr + (off), n)
|
||||||
#define RichString_getCharVal(this, i) ((this).chptr[i])
|
#define RichString_getCharVal(this, i) ((this).chptr[i] & 0xff)
|
||||||
#define RichString_setChar(this, at, ch) do { (this)->chptr[(at)] = ch; } while (0)
|
#define RichString_setChar(this, at, ch) do { (this)->chptr[(at)] = ch; } while (0)
|
||||||
#define CharType chtype
|
#define CharType chtype
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue