summaryrefslogtreecommitdiff
path: root/Meter.c
diff options
context:
space:
mode:
authorloderunner <loderunner@63cc0a6c-1f0e-0410-841e-f6a342073da8>2010-11-22 12:40:20 +0000
committerloderunner <loderunner@63cc0a6c-1f0e-0410-841e-f6a342073da8>2010-11-22 12:40:20 +0000
commitf5734ba123fdda32a283ef8bfe75f11c4de0c0c1 (patch)
treee32ebba1c4d7abba3dc8be6e0e0863e778e660ba /Meter.c
parent24cf45c0ec292297571fa61ba92b9d1303d758a4 (diff)
downloadhtop-f5734ba123fdda32a283ef8bfe75f11c4de0c0c1.tar.gz
Remove arbitrary limit from rich strings
Fix subtree hiding Fix reading of CPU values in hidden threads Fix hiding of zombie processes as kernel threads Remove "debug proc" code Code cleanup in processElements git-svn-id: svn://svn.code.sf.net/p/htop/code/trunk@206 63cc0a6c-1f0e-0410-841e-f6a342073da8
Diffstat (limited to 'Meter.c')
-rw-r--r--Meter.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/Meter.c b/Meter.c
index b65b0ee..341be72 100644
--- a/Meter.c
+++ b/Meter.c
@@ -128,8 +128,6 @@ MeterType* Meter_types[] = {
NULL
};
-static RichString Meter_stringBuffer;
-
Meter* Meter_new(ProcessList* pl, int param, MeterType* type) {
Meter* this = calloc(sizeof(Meter), 1);
Object_setClass(this, METER_CLASS);
@@ -166,14 +164,13 @@ void Meter_setCaption(Meter* this, const char* caption) {
this->caption = strdup(caption);
}
-static inline void Meter_displayToStringBuffer(Meter* this, char* buffer) {
+static inline void Meter_displayBuffer(Meter* this, char* buffer, RichString* out) {
MeterType* type = this->type;
Object_Display display = ((Object*)this)->display;
if (display) {
- display((Object*)this, &Meter_stringBuffer);
+ display((Object*)this, out);
} else {
- RichString_initVal(Meter_stringBuffer);
- RichString_append(&Meter_stringBuffer, CRT_colors[type->attributes[0]], buffer);
+ RichString_write(out, CRT_colors[type->attributes[0]], buffer);
}
}
@@ -229,10 +226,12 @@ static void TextMeterMode_draw(Meter* this, int x, int y, int w) {
int captionLen = strlen(this->caption);
w -= captionLen;
x += captionLen;
- Meter_displayToStringBuffer(this, buffer);
mvhline(y, x, ' ', CRT_colors[DEFAULT_COLOR]);
attrset(CRT_colors[RESET_COLOR]);
- RichString_printVal(Meter_stringBuffer, y, x);
+ RichString_begin(out);
+ Meter_displayBuffer(this, buffer, &out);
+ RichString_printVal(out, y, x);
+ RichString_end(out);
}
/* ---------- BarMeterMode ---------- */
@@ -378,14 +377,16 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
MeterType* type = this->type;
char buffer[METER_BUFFER_LEN];
type->setValues(this, buffer, METER_BUFFER_LEN - 1);
-
- Meter_displayToStringBuffer(this, buffer);
+
+ RichString_begin(out);
+ Meter_displayBuffer(this, buffer, &out);
attrset(CRT_colors[LED_COLOR]);
mvaddstr(y+2, x, this->caption);
int xx = x + strlen(this->caption);
- for (int i = 0; i < Meter_stringBuffer.len; i++) {
- char c = RichString_getCharVal(Meter_stringBuffer, i);
+ int len = RichString_sizeVal(out);
+ for (int i = 0; i < len; i++) {
+ char c = RichString_getCharVal(out, i);
if (c >= '0' && c <= '9') {
LEDMeterMode_drawDigit(xx, y, c-48);
xx += 4;
@@ -395,6 +396,7 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
}
}
attrset(CRT_colors[RESET_COLOR]);
+ RichString_end(out);
}
#endif