mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Move UptimeMeter into platform-dependent area.
Set up environment to move other meters.
This commit is contained in:
parent
b192af006f
commit
357e7a3243
@ -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 <assert.h>
|
||||
#include <stdlib.h>
|
||||
@ -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));
|
||||
}
|
||||
|
3
Header.c
3
Header.c
@ -9,6 +9,7 @@ in the source distribution for its full text.
|
||||
|
||||
#include "CRT.h"
|
||||
#include "String.h"
|
||||
#include "Platform.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
@ -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;
|
||||
|
10
Makefile.am
10
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
|
||||
|
30
Meter.c
30
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);
|
||||
|
2
Meter.h
2
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);
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
|
@ -13,5 +13,7 @@ in the source distribution for its full text.
|
||||
|
||||
void Platform_setBindings(Htop_Action* keys);
|
||||
|
||||
extern MeterClass* Platform_meterTypes[];
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user