diff options
author | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:20 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:20 +0200 |
commit | ea859f50d9438bc61ae96721a4d255b49de78653 (patch) | |
tree | bfb52a5f403ad1e86c562b2f4d608d1268fe8fcf /ClockMeter.c | |
parent | 266ab52b3a741a58fb17c48b0f7939d7c5d266de (diff) | |
download | debian_htop-ea859f50d9438bc61ae96721a4d255b49de78653.tar.gz debian_htop-ea859f50d9438bc61ae96721a4d255b49de78653.tar.bz2 debian_htop-ea859f50d9438bc61ae96721a4d255b49de78653.zip |
Imported Upstream version 0.6.2upstream/0.6.2
Diffstat (limited to 'ClockMeter.c')
-rw-r--r-- | ClockMeter.c | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/ClockMeter.c b/ClockMeter.c index 2a27906..9e48c29 100644 --- a/ClockMeter.c +++ b/ClockMeter.c @@ -1,6 +1,6 @@ /* htop -(C) 2004 Hisham H. Muhammad +(C) 2004-2006 Hisham H. Muhammad Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ @@ -8,47 +8,29 @@ in the source distribution for its full text. #include "ClockMeter.h" #include "Meter.h" -#include "ProcessList.h" - -#include <curses.h> #include <time.h> #include "debug.h" -/*{ - -typedef struct ClockMeter_ ClockMeter; - -struct ClockMeter_ { - Meter super; - ProcessList* pl; - char clock[10]; +/* private */ +static int ClockMeter_attributes[] = { CLOCK }; + +/* private */ +MeterType ClockMeter = { + .setValues = ClockMeter_setValues, + .display = NULL, + .mode = TEXT_METERMODE, + .total = 100.0, + .items = 1, + .attributes = ClockMeter_attributes, + .name = "Clock", + .uiName = "Clock", + .caption = "Time: ", }; -}*/ - -ClockMeter* ClockMeter_new() { - ClockMeter* this = malloc(sizeof(ClockMeter)); - Meter_init((Meter*)this, String_copy("Clock"), String_copy("Time: "), 1); - ((Meter*)this)->attributes[0] = CLOCK; - ((Meter*)this)->setValues = ClockMeter_setValues; - ((Object*)this)->display = ClockMeter_display; - ((Meter*)this)->total = 24 * 60; - Meter_setMode((Meter*)this, TEXT); - return this; -} - -void ClockMeter_setValues(Meter* cast) { - ClockMeter* this = (ClockMeter*) cast; +void ClockMeter_setValues(Meter* this, char* buffer, int size) { time_t t = time(NULL); struct tm *lt = localtime(&t); - cast->values[0] = lt->tm_hour * 60 + lt->tm_min; - strftime(this->clock, 9, "%H:%M:%S", lt); - snprintf(cast->displayBuffer.c, 9, "%s", this->clock); -} - -void ClockMeter_display(Object* cast, RichString* out) { - Meter* super = (Meter*) cast; - ClockMeter* this = (ClockMeter*) cast; - RichString_write(out, CRT_colors[super->attributes[0]], this->clock); + this->values[0] = lt->tm_hour * 60 + lt->tm_min; + strftime(buffer, size, "%H:%M:%S", lt); } |