mirror of https://github.com/xzeldon/htop.git
Meter: limit LED mode by width
Stop displaying LED-mode if maximum width is reached.
This commit is contained in:
parent
b965417bf7
commit
f886759022
7
Meter.c
7
Meter.c
|
@ -379,7 +379,7 @@ static void LEDMeterMode_drawDigit(int x, int y, int n) {
|
||||||
mvaddstr(y + i, x, LEDMeterMode_digits[i * 10 + n]);
|
mvaddstr(y + i, x, LEDMeterMode_digits[i * 10 + n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LEDMeterMode_draw(Meter* this, int x, int y, ATTR_UNUSED int w) {
|
static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
|
||||||
#ifdef HAVE_LIBNCURSESW
|
#ifdef HAVE_LIBNCURSESW
|
||||||
if (CRT_utf8)
|
if (CRT_utf8)
|
||||||
LEDMeterMode_digits = LEDMeterMode_digitsUtf8;
|
LEDMeterMode_digits = LEDMeterMode_digitsUtf8;
|
||||||
|
@ -403,9 +403,14 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, ATTR_UNUSED 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') {
|
||||||
|
if (xx - x + 4 > w)
|
||||||
|
break;
|
||||||
|
|
||||||
LEDMeterMode_drawDigit(xx, y, c - '0');
|
LEDMeterMode_drawDigit(xx, y, c - '0');
|
||||||
xx += 4;
|
xx += 4;
|
||||||
} else {
|
} else {
|
||||||
|
if (xx - x + 1 > w)
|
||||||
|
break;
|
||||||
#ifdef HAVE_LIBNCURSESW
|
#ifdef HAVE_LIBNCURSESW
|
||||||
const cchar_t wc = { .chars = { c, '\0' }, .attr = 0 }; /* use LED_COLOR from attrset() */
|
const cchar_t wc = { .chars = { c, '\0' }, .attr = 0 }; /* use LED_COLOR from attrset() */
|
||||||
mvadd_wch(yText, xx, &wc);
|
mvadd_wch(yText, xx, &wc);
|
||||||
|
|
Loading…
Reference in New Issue