3
(C) 2004 Hisham H. Muhammad
4
Released under the GNU GPL, see the COPYING file
5
in the source distribution for its full text.
8
#include "TasksMeter.h"
11
#include "ProcessList.h"
19
typedef struct TasksMeter_ TasksMeter;
28
TasksMeter* TasksMeter_new(ProcessList* pl) {
29
TasksMeter* this = malloc(sizeof(TasksMeter));
30
Meter_init((Meter*)this, String_copy("Tasks"), String_copy("Tasks: "), 1);
31
((Meter*)this)->attributes[0] = CRT_colors[TASKS_RUNNING];
32
((Object*)this)->display = TasksMeter_display;
33
((Meter*)this)->setValues = TasksMeter_setValues;
35
Meter_setMode((Meter*)this, TEXT);
39
void TasksMeter_setValues(Meter* cast) {
40
TasksMeter* this = (TasksMeter*)cast;
41
cast->total = this->pl->totalTasks;
42
cast->values[0] = this->pl->runningTasks;
43
snprintf(cast->displayBuffer.c, 20, "%d/%d", (int) cast->values[0], (int) cast->total);
46
void TasksMeter_display(Object* cast, RichString* out) {
47
Meter* this = (Meter*)cast;
48
RichString_prune(out);
50
sprintf(buffer, "%d", (int)this->total);
51
RichString_append(out, CRT_colors[METER_VALUE], buffer);
52
RichString_append(out, CRT_colors[METER_TEXT], " total, ");
53
sprintf(buffer, "%d", (int)this->values[0]);
54
RichString_append(out, CRT_colors[TASKS_RUNNING], buffer);
55
RichString_append(out, CRT_colors[METER_TEXT], " running");