summaryrefslogtreecommitdiffstats
path: root/ClockMeter.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2006-03-04 18:16:49 +0000
committerHisham Muhammad <hisham@gobolinux.org>2006-03-04 18:16:49 +0000
commitd6231bab89d634da5564491196b7c478db038505 (patch)
treebfc0bf00b138763eb41132fd27a8f389a78bf3a4 /ClockMeter.c
Initial import.
Diffstat (limited to 'ClockMeter.c')
-rw-r--r--ClockMeter.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/ClockMeter.c b/ClockMeter.c
new file mode 100644
index 00000000..699c037a
--- /dev/null
+++ b/ClockMeter.c
@@ -0,0 +1,54 @@
+/*
+htop
+(C) 2004-2006 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+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];
+};
+
+}*/
+
+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;
+ 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);
+}

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