htop/TasksMeter.c

49 lines
1.2 KiB
C
Raw Normal View History

2006-03-04 18:16:49 +00:00
/*
htop
2010-02-25 02:08:18 +00:00
(C) 2004-2010 Hisham H. Muhammad
2006-03-04 18:16:49 +00:00
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "TasksMeter.h"
#include "Meter.h"
#include "ProcessList.h"
#include "CRT.h"
#include "debug.h"
int TasksMeter_attributes[] = {
TASKS_RUNNING
};
static void TasksMeter_setValues(Meter* this, char* buffer, int len) {
this->total = this->pl->totalTasks;
this->values[0] = this->pl->runningTasks;
snprintf(buffer, len, "%d/%d", (int) this->values[0], (int) this->total);
2006-03-04 18:16:49 +00:00
}
static void TasksMeter_display(Object* cast, RichString* out) {
2006-03-04 18:16:49 +00:00
Meter* this = (Meter*)cast;
char buffer[20];
sprintf(buffer, "%d", (int)this->total);
RichString_write(out, CRT_colors[METER_VALUE], buffer);
2006-03-04 18:16:49 +00:00
RichString_append(out, CRT_colors[METER_TEXT], " total, ");
sprintf(buffer, "%d", (int)this->values[0]);
RichString_append(out, CRT_colors[TASKS_RUNNING], buffer);
RichString_append(out, CRT_colors[METER_TEXT], " running");
}
MeterType TasksMeter = {
.setValues = TasksMeter_setValues,
.display = TasksMeter_display,
.mode = TEXT_METERMODE,
.items = 1,
.total = 100.0,
.attributes = TasksMeter_attributes,
.name = "Tasks",
.uiName = "Task counter",
.caption = "Tasks: "
};