blob: 9766ddfa10393a9d8971c66d4ce3ddae03245798 [file] [log] [blame]
Hisham Muhammadd6231ba2006-03-04 18:16:49 +00001/*
2htop
3(C) 2004-2006 Hisham H. Muhammad
4Released under the GNU GPL, see the COPYING file
5in the source distribution for its full text.
6*/
7
8#include "TasksMeter.h"
9#include "Meter.h"
10
11#include "ProcessList.h"
12
13#include "CRT.h"
14
15#include "debug.h"
16
Hisham Muhammad2f1f82e2006-06-06 20:41:01 +000017int TasksMeter_attributes[] = {
18 TASKS_RUNNING
19};
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000020
Hisham Muhammad33113fe2006-04-10 20:40:38 +000021MeterType TasksMeter = {
22 .setValues = TasksMeter_setValues,
23 .display = TasksMeter_display,
24 .mode = TEXT_METERMODE,
25 .items = 1,
26 .total = 100.0,
27 .attributes = TasksMeter_attributes,
28 .name = "Tasks",
29 .uiName = "Task counter",
30 .caption = "Tasks: "
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000031};
32
Hisham Muhammad33113fe2006-04-10 20:40:38 +000033void TasksMeter_setValues(Meter* this, char* buffer, int len) {
34 this->total = this->pl->totalTasks;
35 this->values[0] = this->pl->runningTasks;
36 snprintf(buffer, len, "%d/%d", (int) this->values[0], (int) this->total);
Hisham Muhammadd6231ba2006-03-04 18:16:49 +000037}
38
39void TasksMeter_display(Object* cast, RichString* out) {
40 Meter* this = (Meter*)cast;
41 RichString_prune(out);
42 char buffer[20];
43 sprintf(buffer, "%d", (int)this->total);
44 RichString_append(out, CRT_colors[METER_VALUE], buffer);
45 RichString_append(out, CRT_colors[METER_TEXT], " total, ");
46 sprintf(buffer, "%d", (int)this->values[0]);
47 RichString_append(out, CRT_colors[TASKS_RUNNING], buffer);
48 RichString_append(out, CRT_colors[METER_TEXT], " running");
49}