summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CRT.c10
-rw-r--r--CRT.h2
-rw-r--r--DateMeter.c47
-rw-r--r--DateMeter.h16
-rw-r--r--DateTimeMeter.c47
-rw-r--r--DateTimeMeter.h16
-rw-r--r--Makefile.am120
-rw-r--r--darwin/Platform.c4
-rw-r--r--dragonflybsd/Platform.c4
-rw-r--r--freebsd/Platform.c4
-rw-r--r--linux/Platform.c4
-rw-r--r--openbsd/Platform.c4
-rw-r--r--solaris/Platform.c4
-rw-r--r--unsupported/Platform.c4
14 files changed, 267 insertions, 19 deletions
diff --git a/CRT.c b/CRT.c
index 374e1721..d3874043 100644
--- a/CRT.c
+++ b/CRT.c
@@ -122,6 +122,8 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[LOAD] = A_BOLD,
[HELP_BOLD] = A_BOLD | ColorPair(Cyan,Black),
[CLOCK] = A_BOLD,
+ [DATE] = A_BOLD,
+ [DATETIME] = A_BOLD,
[CHECK_BOX] = ColorPair(Cyan,Black),
[CHECK_MARK] = A_BOLD,
[CHECK_TEXT] = A_NORMAL,
@@ -195,6 +197,8 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[LOAD] = A_BOLD,
[HELP_BOLD] = A_BOLD,
[CLOCK] = A_BOLD,
+ [DATE] = A_BOLD,
+ [DATETIME] = A_BOLD,
[CHECK_BOX] = A_BOLD,
[CHECK_MARK] = A_NORMAL,
[CHECK_TEXT] = A_NORMAL,
@@ -268,6 +272,8 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[LOAD] = ColorPair(Black,White),
[HELP_BOLD] = ColorPair(Blue,White),
[CLOCK] = ColorPair(Black,White),
+ [DATE] = ColorPair(Black,White),
+ [DATETIME] = ColorPair(Black,White),
[CHECK_BOX] = ColorPair(Blue,White),
[CHECK_MARK] = ColorPair(Black,White),
[CHECK_TEXT] = ColorPair(Black,White),
@@ -341,6 +347,8 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[LOAD] = ColorPair(Yellow,Black),
[HELP_BOLD] = ColorPair(Blue,Black),
[CLOCK] = ColorPair(Yellow,Black),
+ [DATE] = ColorPair(White,Black),
+ [DATETIME] = ColorPair(White,Black),
[CHECK_BOX] = ColorPair(Blue,Black),
[CHECK_MARK] = ColorPair(Blue,Black),
[CHECK_TEXT] = ColorPair(Blue,Black),
@@ -414,6 +422,8 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[LOAD] = A_BOLD | ColorPair(White,Blue),
[HELP_BOLD] = A_BOLD | ColorPair(Cyan,Blue),
[CLOCK] = ColorPair(White,Blue),
+ [DATE] = ColorPair(White,Blue),
+ [DATETIME] = ColorPair(White,Blue),
[CHECK_BOX] = ColorPair(Cyan,Blue),
[CHECK_MARK] = A_BOLD | ColorPair(White,Blue),
[CHECK_TEXT] = A_NORMAL | ColorPair(White,Blue),
diff --git a/CRT.h b/CRT.h
index 4eeb9a46..13fe66d7 100644
--- a/CRT.h
+++ b/CRT.h
@@ -85,6 +85,8 @@ typedef enum ColorElements_ {
CHECK_MARK,
CHECK_TEXT,
CLOCK,
+ DATE,
+ DATETIME,
HELP_BOLD,
HOSTNAME,
CPU_NICE,
diff --git a/DateMeter.c b/DateMeter.c
new file mode 100644
index 00000000..6fd93373
--- /dev/null
+++ b/DateMeter.c
@@ -0,0 +1,47 @@
+/*
+htop - DateMeter.c
+(C) 2004-2020 Hisham H. Muhammad, Michael Schönitzer
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "DateMeter.h"
+
+#include "CRT.h"
+
+#include <time.h>
+
+
+int DateMeter_attributes[] = {
+ DATE
+};
+
+static void DateMeter_updateValues(Meter* this, char* buffer, int size) {
+ time_t t = time(NULL);
+ struct tm result;
+ struct tm *lt = localtime_r(&t, &result);
+ this->values[0] = lt->tm_yday;
+ int year = lt->tm_year + 1900;
+ if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0)) {
+ this->total = 366;
+ }
+ else {
+ this->total = 365;
+ }
+ strftime(buffer, size, "%F", lt);
+}
+
+MeterClass DateMeter_class = {
+ .super = {
+ .extends = Class(Meter),
+ .delete = Meter_delete
+ },
+ .updateValues = DateMeter_updateValues,
+ .defaultMode = TEXT_METERMODE,
+ .maxItems = 1,
+ .total = 365,
+ .attributes = DateMeter_attributes,
+ .name = "Date",
+ .uiName = "Date",
+ .caption = "Date: ",
+};
diff --git a/DateMeter.h b/DateMeter.h
new file mode 100644
index 00000000..6cb899dd
--- /dev/null
+++ b/DateMeter.h
@@ -0,0 +1,16 @@
+#ifndef HEADER_DateMeter
+#define HEADER_DateMeter
+/*
+htop - DateMeter.h
+(C) 2004-2011 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "Meter.h"
+
+extern int DateMeter_attributes[];
+
+extern MeterClass DateMeter_class;
+
+#endif
diff --git a/DateTimeMeter.c b/DateTimeMeter.c
new file mode 100644
index 00000000..5c60884a
--- /dev/null
+++ b/DateTimeMeter.c
@@ -0,0 +1,47 @@
+/*
+htop - DateTimeMeter.c
+(C) 2004-2020 Hisham H. Muhammad, Michael Schönitzer
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "DateTimeMeter.h"
+
+#include "CRT.h"
+
+#include <time.h>
+
+
+int DateTimeMeter_attributes[] = {
+ DATETIME
+};
+
+static void DateTimeMeter_updateValues(Meter* this, char* buffer, int size) {
+ time_t t = time(NULL);
+ struct tm result;
+ struct tm *lt = localtime_r(&t, &result);
+ int year = lt->tm_year + 1900;
+ if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0)) {
+ this->total = 366;
+ }
+ else {
+ this->total = 365;
+ }
+ this->values[0] = lt->tm_yday;
+ strftime(buffer, size, "%F %H:%M:%S", lt);
+}
+
+MeterClass DateTimeMeter_class = {
+ .super = {
+ .extends = Class(Meter),
+ .delete = Meter_delete
+ },
+ .updateValues = DateTimeMeter_updateValues,
+ .defaultMode = TEXT_METERMODE,
+ .maxItems = 1,
+ .total = 365,
+ .attributes = DateTimeMeter_attributes,
+ .name = "DateTime",
+ .uiName = "Date and Time",
+ .caption = "Date & Time: ",
+};
diff --git a/DateTimeMeter.h b/DateTimeMeter.h
new file mode 100644
index 00000000..6d1e3a68
--- /dev/null
+++ b/DateTimeMeter.h
@@ -0,0 +1,16 @@
+#ifndef HEADER_DateTimeMeter
+#define HEADER_DateTimeMeter
+/*
+htop - DateTimeMeter.h
+(C) 2004-2011 Hisham H. Muhammad
+Released under the GNU GPL, see the COPYING file
+in the source distribution for its full text.
+*/
+
+#include "Meter.h"
+
+extern int DateTimeMeter_attributes[];
+
+extern MeterClass DateTimeMeter_class;
+
+#endif
diff --git a/Makefile.am b/Makefile.am
index 1ef92364..9bfe007a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -13,25 +13,107 @@ pixmap_DATA = htop.png
AM_CFLAGS += -pedantic -std=c99 -D_XOPEN_SOURCE_EXTENDED -DSYSCONFDIR=\"$(sysconfdir)\" -I"$(top_srcdir)/$(my_htop_platform)"
AM_LDFLAGS =
-myhtopsources = AvailableMetersPanel.c CategoriesPanel.c CheckItem.c \
-ClockMeter.c ColorsPanel.c ColumnsPanel.c CPUMeter.c CRT.c DiskIOMeter.c DiskIOMeter.h \
-MainPanel.c DisplayOptionsPanel.c FunctionBar.c Hashtable.c Header.c htop.c ListItem.c \
-LoadAverageMeter.c MemoryMeter.c Meter.c MetersPanel.c Object.c Panel.c \
-BatteryMeter.c Process.c ProcessList.c RichString.c ScreenManager.c Settings.c \
-SignalsPanel.c StringUtils.c SwapMeter.c TasksMeter.c UptimeMeter.c \
-TraceScreen.c UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c \
-HostnameMeter.c OpenFilesScreen.c Affinity.c IncSet.c Action.c EnvScreen.c \
-InfoScreen.c CommandScreen.c XAlloc.c
-
-myhtopheaders = AvailableColumnsPanel.h AvailableMetersPanel.h \
-CategoriesPanel.h CheckItem.h ClockMeter.h ColorsPanel.h ColumnsPanel.h \
-CPUMeter.h CRT.h MainPanel.h DisplayOptionsPanel.h FunctionBar.h \
-Hashtable.h Header.h ListItem.h LoadAverageMeter.h MemoryMeter.h \
-BatteryMeter.h Meter.h MetersPanel.h Object.h Panel.h ProcessList.h RichString.h \
-ScreenManager.h Settings.h SignalsPanel.h StringUtils.h SwapMeter.h \
-TasksMeter.h UptimeMeter.h TraceScreen.h UsersTable.h Vector.h Process.h \
-AffinityPanel.h HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h \
-EnvScreen.h InfoScreen.h CommandScreen.h XAlloc.h Macros.h
+myhtopsources = \
+ Action.c \
+ Affinity.c \
+ AffinityPanel.c \
+ AvailableColumnsPanel.c \
+ AvailableMetersPanel.c \
+ BatteryMeter.c \
+ CategoriesPanel.c \
+ CheckItem.c \
+ ClockMeter.c \
+ ColorsPanel.c \
+ ColumnsPanel.c \
+ CommandScreen.c \
+ CPUMeter.c \
+ CRT.c \
+ DateMeter.c \
+ DateTimeMeter.c \
+ DiskIOMeter.c \
+ DiskIOMeter.h \
+ DisplayOptionsPanel.c \
+ EnvScreen.c \
+ FunctionBar.c \
+ Hashtable.c \
+ Header.c \
+ HostnameMeter.c \
+ htop.c \
+ IncSet.c \
+ InfoScreen.c \
+ ListItem.c \
+ LoadAverageMeter.c \
+ MainPanel.c \
+ MemoryMeter.c \
+ Meter.c \
+ MetersPanel.c \
+ Object.c \
+ OpenFilesScreen.c \
+ Panel.c \
+ Process.c \
+ ProcessList.c \
+ RichString.c \
+ ScreenManager.c \
+ Settings.c \
+ SignalsPanel.c \
+ StringUtils.c \
+ SwapMeter.c \
+ TasksMeter.c \
+ TraceScreen.c \
+ UptimeMeter.c \
+ UsersTable.c \
+ Vector.c \
+ XAlloc.c
+
+myhtopheaders = \
+ Action.h \
+ Affinity.h \
+ AffinityPanel.h \
+ AvailableColumnsPanel.h \
+ AvailableMetersPanel.h \
+ BatteryMeter.h \
+ CPUMeter.h \
+ CRT.h \
+ CategoriesPanel.h \
+ CheckItem.h \
+ ClockMeter.h \
+ ColorsPanel.h \
+ ColumnsPanel.h \
+ CommandScreen.h \
+ DateMeter.h \
+ DateTimeMeter.h \
+ DisplayOptionsPanel.h \
+ EnvScreen.h \
+ FunctionBar.h \
+ Hashtable.h \
+ Header.h \
+ HostnameMeter.h \
+ IncSet.h \
+ InfoScreen.h \
+ ListItem.h \
+ LoadAverageMeter.h \
+ Macros.h \
+ MainPanel.h \
+ MemoryMeter.h \
+ Meter.h \
+ MetersPanel.h \
+ Object.h \
+ OpenFilesScreen.h \
+ Panel.h \
+ Process.h \
+ ProcessList.h \
+ RichString.h \
+ ScreenManager.h \
+ Settings.h \
+ SignalsPanel.h \
+ StringUtils.h \
+ SwapMeter.h \
+ TasksMeter.h \
+ TraceScreen.h \
+ UptimeMeter.h \
+ UsersTable.h \
+ Vector.h \
+ XAlloc.h
# Linux
# -----
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 5aa50a65..8ca8d2c6 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -13,6 +13,8 @@ in the source distribution for its full text.
#include "TasksMeter.h"
#include "LoadAverageMeter.h"
#include "ClockMeter.h"
+#include "DateMeter.h"
+#include "DateTimeMeter.h"
#include "HostnameMeter.h"
#include "UptimeMeter.h"
#include "zfs/ZfsArcMeter.h"
@@ -95,6 +97,8 @@ ProcessFieldData Process_fields[] = {
MeterClass* Platform_meterTypes[] = {
&CPUMeter_class,
&ClockMeter_class,
+ &DateMeter_class,
+ &DateTimeMeter_class,
&LoadAverageMeter_class,
&LoadMeter_class,
&MemoryMeter_class,
diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c
index 36ab2c21..61fe25b6 100644
--- a/dragonflybsd/Platform.c
+++ b/dragonflybsd/Platform.c
@@ -15,6 +15,8 @@ in the source distribution for its full text.
#include "LoadAverageMeter.h"
#include "UptimeMeter.h"
#include "ClockMeter.h"
+#include "DateMeter.h"
+#include "DateTimeMeter.h"
#include "HostnameMeter.h"
#include "DragonFlyBSDProcess.h"
#include "DragonFlyBSDProcessList.h"
@@ -78,6 +80,8 @@ void Platform_setBindings(Htop_Action* keys) {
MeterClass* Platform_meterTypes[] = {
&CPUMeter_class,
&ClockMeter_class,
+ &DateMeter_class,
+ &DateTimeMeter_class,
&LoadAverageMeter_class,
&LoadMeter_class,
&MemoryMeter_class,
diff --git a/freebsd/Platform.c b/freebsd/Platform.c
index 36256f9a..2c1d72e6 100644
--- a/freebsd/Platform.c
+++ b/freebsd/Platform.c
@@ -14,6 +14,8 @@ in the source distribution for its full text.
#include "LoadAverageMeter.h"
#include "UptimeMeter.h"
#include "ClockMeter.h"
+#include "DateMeter.h"
+#include "DateTimeMeter.h"
#include "HostnameMeter.h"
#include "zfs/ZfsArcMeter.h"
#include "zfs/ZfsCompressedArcMeter.h"
@@ -79,6 +81,8 @@ void Platform_setBindings(Htop_Action* keys) {
MeterClass* Platform_meterTypes[] = {
&CPUMeter_class,
&ClockMeter_class,
+ &DateMeter_class,
+ &DateTimeMeter_class,
&LoadAverageMeter_class,
&LoadMeter_class,
&MemoryMeter_class,
diff --git a/linux/Platform.c b/linux/Platform.c
index 2d325864..ef5015d1 100644
--- a/linux/Platform.c
+++ b/linux/Platform.c
@@ -22,6 +22,8 @@ in the source distribution for its full text.
#include "UptimeMeter.h"
#include "PressureStallMeter.h"
#include "ClockMeter.h"
+#include "DateMeter.h"
+#include "DateTimeMeter.h"
#include "HostnameMeter.h"
#include "zfs/ZfsArcMeter.h"
#include "zfs/ZfsCompressedArcMeter.h"
@@ -106,6 +108,8 @@ void Platform_setBindings(Htop_Action* keys) {
MeterClass* Platform_meterTypes[] = {
&CPUMeter_class,
&ClockMeter_class,
+ &DateMeter_class,
+ &DateTimeMeter_class,
&LoadAverageMeter_class,
&LoadMeter_class,
&MemoryMeter_class,
diff --git a/openbsd/Platform.c b/openbsd/Platform.c
index ce370994..574b573c 100644
--- a/openbsd/Platform.c
+++ b/openbsd/Platform.c
@@ -15,6 +15,8 @@ in the source distribution for its full text.
#include "LoadAverageMeter.h"
#include "UptimeMeter.h"
#include "ClockMeter.h"
+#include "DateMeter.h"
+#include "DateTimeMeter.h"
#include "HostnameMeter.h"
#include "SignalsPanel.h"
#include "OpenBSDProcess.h"
@@ -91,6 +93,8 @@ void Platform_setBindings(Htop_Action* keys) {
MeterClass* Platform_meterTypes[] = {
&CPUMeter_class,
&ClockMeter_class,
+ &DateMeter_class,
+ &DateTimeMeter_class,
&LoadAverageMeter_class,
&LoadMeter_class,
&MemoryMeter_class,
diff --git a/solaris/Platform.c b/solaris/Platform.c
index 2114215e..07f57517 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -15,6 +15,8 @@ in the source distribution for its full text.
#include "TasksMeter.h"
#include "LoadAverageMeter.h"
#include "ClockMeter.h"
+#include "DateMeter.h"
+#include "DateTimeMeter.h"
#include "HostnameMeter.h"
#include "UptimeMeter.h"
#include "zfs/ZfsArcMeter.h"
@@ -88,6 +90,8 @@ ProcessField Platform_defaultFields[] = { PID, LWPID, USER, PRIORITY, NICE, M_SI
MeterClass* Platform_meterTypes[] = {
&CPUMeter_class,
&ClockMeter_class,
+ &DateMeter_class,
+ &DateTimeMeter_class,
&LoadAverageMeter_class,
&LoadMeter_class,
&MemoryMeter_class,
diff --git a/unsupported/Platform.c b/unsupported/Platform.c
index 6a6b0131..fbcf6431 100644
--- a/unsupported/Platform.c
+++ b/unsupported/Platform.c
@@ -15,6 +15,8 @@ in the source distribution for its full text.
#include "TasksMeter.h"
#include "LoadAverageMeter.h"
#include "ClockMeter.h"
+#include "DateMeter.h"
+#include "DateTimeMeter.h"
#include "HostnameMeter.h"
#include "UptimeMeter.h"
@@ -59,6 +61,8 @@ ProcessFieldData Process_fields[] = {
MeterClass* Platform_meterTypes[] = {
&CPUMeter_class,
&ClockMeter_class,
+ &DateMeter_class,
+ &DateTimeMeter_class,
&LoadAverageMeter_class,
&LoadMeter_class,
&MemoryMeter_class,