summaryrefslogtreecommitdiffstats
path: root/ClockMeter.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2006-04-10 20:40:38 +0000
committerHisham Muhammad <hisham@gobolinux.org>2006-04-10 20:40:38 +0000
commit33113fe0d73ea3299843b483f108ef5bcfcc944f (patch)
tree4c6b50b3bc6fbe9e1a44dd3b9c56e63571c83d73 /ClockMeter.c
parent34bcf8050e56fc799efb1013cb92ba1b44bd6df1 (diff)
- Overhaul meters implementation;
- add AllCPUsMeter; - because of that, the new .htoprc is incompatible with previous released versions.
Diffstat (limited to 'ClockMeter.c')
-rw-r--r--ClockMeter.c52
1 files changed, 17 insertions, 35 deletions
diff --git a/ClockMeter.c b/ClockMeter.c
index 699c037a..9e48c295 100644
--- a/ClockMeter.c
+++ b/ClockMeter.c
@@ -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);
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy