diff options
author | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:15 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:15 +0200 |
commit | d3c9975943df58e293359b87905d19ff1fd52061 (patch) | |
tree | e416378879f60e8d538b1b25963904f767d30ff4 /TasksMeter.c | |
download | debian_htop-d3c9975943df58e293359b87905d19ff1fd52061.tar.gz debian_htop-d3c9975943df58e293359b87905d19ff1fd52061.tar.bz2 debian_htop-d3c9975943df58e293359b87905d19ff1fd52061.zip |
Imported Upstream version 0.5upstream/0.5
Diffstat (limited to 'TasksMeter.c')
-rw-r--r-- | TasksMeter.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/TasksMeter.c b/TasksMeter.c new file mode 100644 index 0000000..b822172 --- /dev/null +++ b/TasksMeter.c @@ -0,0 +1,56 @@ +/* +htop +(C) 2004 Hisham H. Muhammad +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" + +/*{ + +typedef struct TasksMeter_ TasksMeter; + +struct TasksMeter_ { + Meter super; + ProcessList* pl; +}; + +}*/ + +TasksMeter* TasksMeter_new(ProcessList* pl) { + TasksMeter* this = malloc(sizeof(TasksMeter)); + Meter_init((Meter*)this, String_copy("Tasks"), String_copy("Tasks: "), 1); + ((Meter*)this)->attributes[0] = CRT_colors[TASKS_RUNNING]; + ((Object*)this)->display = TasksMeter_display; + ((Meter*)this)->setValues = TasksMeter_setValues; + this->pl = pl; + Meter_setMode((Meter*)this, TEXT); + return this; +} + +void TasksMeter_setValues(Meter* cast) { + TasksMeter* this = (TasksMeter*)cast; + cast->total = this->pl->totalTasks; + cast->values[0] = this->pl->runningTasks; + snprintf(cast->displayBuffer.c, 20, "%d/%d", (int) cast->values[0], (int) cast->total); +} + +void TasksMeter_display(Object* cast, RichString* out) { + Meter* this = (Meter*)cast; + RichString_prune(out); + char buffer[20]; + sprintf(buffer, "%d", (int)this->total); + RichString_append(out, CRT_colors[METER_VALUE], buffer); + 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"); +} |