diff --git a/AvailableMetersPanel.c b/AvailableMetersPanel.c index f5828516..80b2ebee 100644 --- a/AvailableMetersPanel.c +++ b/AvailableMetersPanel.c @@ -10,6 +10,7 @@ in the source distribution for its full text. #include "CPUMeter.h" #include "Header.h" #include "ListItem.h" +#include "Platform.h" #include #include @@ -56,7 +57,7 @@ static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) { case 'l': case 'L': { - AvailableMetersPanel_addHeader(header, this->leftPanel, Meter_types[type], param, LEFT_HEADER); + AvailableMetersPanel_addHeader(header, this->leftPanel, Platform_meterTypes[type], param, LEFT_HEADER); result = HANDLED; break; } @@ -64,7 +65,7 @@ static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) { case 'r': case 'R': { - AvailableMetersPanel_addHeader(header, this->rightPanel, Meter_types[type], param, RIGHT_HEADER); + AvailableMetersPanel_addHeader(header, this->rightPanel, Platform_meterTypes[type], param, RIGHT_HEADER); result = HANDLED; break; } @@ -97,8 +98,8 @@ AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Panel* leftMe this->scr = scr; Panel_setHeader(super, "Available meters"); - for (int i = 1; Meter_types[i]; i++) { - MeterClass* type = Meter_types[i]; + for (int i = 1; Platform_meterTypes[i]; i++) { + MeterClass* type = Platform_meterTypes[i]; if (type != &CPUMeter_class) { Panel_add(super, (Object*) ListItem_new(type->uiName, i << 16)); } diff --git a/Header.c b/Header.c index 68249909..e3ab7f29 100644 --- a/Header.c +++ b/Header.c @@ -9,6 +9,7 @@ in the source distribution for its full text. #include "CRT.h" #include "String.h" +#include "Platform.h" #include #include @@ -66,7 +67,7 @@ void Header_createMeter(Header* this, char* name, HeaderSide side) { if (!ok) param = 0; *paren = '\0'; } - for (MeterClass** type = Meter_types; *type; type++) { + for (MeterClass** type = Platform_meterTypes; *type; type++) { if (String_eq(name, (*type)->name)) { Vector_add(meters, Meter_new(this->pl, param, *type)); break; diff --git a/Makefile.am b/Makefile.am index d3b68662..6374fafa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,7 @@ 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 String.c SwapMeter.c TasksMeter.c TraceScreen.c \ -UptimeMeter.c UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c \ +UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c \ HostnameMeter.c OpenFilesScreen.c Affinity.c IncSet.c Action.c myhtopheaders = AvailableColumnsPanel.h AvailableMetersPanel.h \ @@ -30,15 +30,17 @@ CPUMeter.h CRT.h DisplayOptionsPanel.h FunctionBar.h \ Hashtable.h Header.h htop.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 String.h SwapMeter.h TasksMeter.h \ -TraceScreen.h UptimeMeter.h UsersTable.h Vector.h Process.h AffinityPanel.h \ +TraceScreen.h UsersTable.h Vector.h Process.h AffinityPanel.h \ HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h if HTOP_LINUX myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c linux/IOPriority.c \ -linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c +linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c \ +linux/UptimeMeter.c myhtopplatheaders = linux/Platform.h linux/IOPriorityPanel.h linux/IOPriority.h \ -linux/LinuxProcess.h linux/LinuxProcessList.h linux/LinuxCRT.h +linux/LinuxProcess.h linux/LinuxProcessList.h linux/LinuxCRT.h \ +linux/UptimeMeter.h endif if HTOP_UNSUPPORTED diff --git a/Meter.c b/Meter.c index 3abd7083..77458949 100644 --- a/Meter.c +++ b/Meter.c @@ -7,15 +7,6 @@ in the source distribution for its full text. #include "Meter.h" -#include "CPUMeter.h" -#include "MemoryMeter.h" -#include "SwapMeter.h" -#include "TasksMeter.h" -#include "LoadAverageMeter.h" -#include "UptimeMeter.h" -#include "BatteryMeter.h" -#include "ClockMeter.h" -#include "HostnameMeter.h" #include "RichString.h" #include "Object.h" #include "CRT.h" @@ -126,27 +117,6 @@ MeterClass Meter_class = { } }; -MeterClass* Meter_types[] = { - &CPUMeter_class, - &ClockMeter_class, - &LoadAverageMeter_class, - &LoadMeter_class, - &MemoryMeter_class, - &SwapMeter_class, - &TasksMeter_class, - &UptimeMeter_class, - &BatteryMeter_class, - &HostnameMeter_class, - &AllCPUsMeter_class, - &AllCPUs2Meter_class, - &LeftCPUsMeter_class, - &RightCPUsMeter_class, - &LeftCPUs2Meter_class, - &RightCPUs2Meter_class, - &BlankMeter_class, - NULL -}; - Meter* Meter_new(ProcessList* pl, int param, MeterClass* type) { Meter* this = calloc(1, sizeof(Meter)); Object_setClass(this, type); diff --git a/Meter.h b/Meter.h index 2f58b8fc..bfd6ebbb 100644 --- a/Meter.h +++ b/Meter.h @@ -99,8 +99,6 @@ typedef struct GraphData_ { extern MeterClass Meter_class; -extern MeterClass* Meter_types[]; - Meter* Meter_new(ProcessList* pl, int param, MeterClass* type); void Meter_delete(Object* cast); diff --git a/linux/Platform.c b/linux/Platform.c index 5e62dc05..d39e2e96 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -9,6 +9,16 @@ in the source distribution for its full text. #include "IOPriority.h" #include "IOPriorityPanel.h" #include "LinuxProcess.h" +#include "Meter.h" +#include "CPUMeter.h" +#include "MemoryMeter.h" +#include "SwapMeter.h" +#include "TasksMeter.h" +#include "LoadAverageMeter.h" +#include "UptimeMeter.h" +#include "BatteryMeter.h" +#include "ClockMeter.h" +#include "HostnameMeter.h" /*{ #include "Action.h" @@ -35,3 +45,25 @@ static Htop_Reaction Platform_actionSetIOPriority(Panel* panel, ProcessList* pl, void Platform_setBindings(Htop_Action* keys) { keys['i'] = Platform_actionSetIOPriority; } + +MeterClass* Platform_meterTypes[] = { + &CPUMeter_class, + &ClockMeter_class, + &LoadAverageMeter_class, + &LoadMeter_class, + &MemoryMeter_class, + &SwapMeter_class, + &TasksMeter_class, + &UptimeMeter_class, + &BatteryMeter_class, + &HostnameMeter_class, + &AllCPUsMeter_class, + &AllCPUs2Meter_class, + &LeftCPUsMeter_class, + &RightCPUsMeter_class, + &LeftCPUs2Meter_class, + &RightCPUs2Meter_class, + &BlankMeter_class, + NULL +}; + diff --git a/UptimeMeter.c b/linux/UptimeMeter.c similarity index 100% rename from UptimeMeter.c rename to linux/UptimeMeter.c diff --git a/UptimeMeter.h b/linux/UptimeMeter.h similarity index 100% rename from UptimeMeter.h rename to linux/UptimeMeter.h diff --git a/unsupported/Platform.c b/unsupported/Platform.c index b65fec40..5e568025 100644 --- a/unsupported/Platform.c +++ b/unsupported/Platform.c @@ -6,6 +6,14 @@ in the source distribution for its full text. */ #include "Platform.h" +#include "CPUMeter.h" +#include "MemoryMeter.h" +#include "SwapMeter.h" +#include "TasksMeter.h" +#include "LoadAverageMeter.h" +#include "BatteryMeter.h" +#include "ClockMeter.h" +#include "HostnameMeter.h" /*{ #include "Action.h" @@ -15,3 +23,23 @@ void Platform_setBindings(Htop_Action* keys) { (void) keys; } +MeterClass* Platform_meterTypes[] = { + &CPUMeter_class, + &ClockMeter_class, + &LoadAverageMeter_class, + &LoadMeter_class, + &MemoryMeter_class, + &SwapMeter_class, + &TasksMeter_class, + &BatteryMeter_class, + &HostnameMeter_class, + &AllCPUsMeter_class, + &AllCPUs2Meter_class, + &LeftCPUsMeter_class, + &RightCPUsMeter_class, + &LeftCPUs2Meter_class, + &RightCPUs2Meter_class, + &BlankMeter_class, + NULL +}; + diff --git a/unsupported/Platform.h b/unsupported/Platform.h index 65a31993..1a2b81f0 100644 --- a/unsupported/Platform.h +++ b/unsupported/Platform.h @@ -13,5 +13,7 @@ in the source distribution for its full text. void Platform_setBindings(Htop_Action* keys); +extern MeterClass* Platform_meterTypes[]; + #endif