Merge branch 'master' into freebsd

This commit is contained in:
Hisham Muhammad 2014-11-27 19:19:54 -02:00
commit 79662291fa
12 changed files with 94 additions and 71 deletions

View File

@ -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));
}

View File

@ -8,16 +8,8 @@ in the source distribution for its full text.
#include "Header.h"
#include "CRT.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 "String.h"
#include "Platform.h"
#include <assert.h>
#include <time.h>
@ -75,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;
@ -138,23 +130,6 @@ MeterModeId Header_readMeterMode(Header* this, int i, HeaderSide side) {
return meter->mode;
}
void Header_defaultMeters(Header* this, int cpuCount) {
if (cpuCount > 8) {
Vector_add(this->leftMeters, Meter_new(this->pl, 0, (MeterClass*) Class(LeftCPUs2Meter)));
Vector_add(this->rightMeters, Meter_new(this->pl, 0, (MeterClass*) Class(RightCPUs2Meter)));
} else if (cpuCount > 4) {
Vector_add(this->leftMeters, Meter_new(this->pl, 0, (MeterClass*) Class(LeftCPUsMeter)));
Vector_add(this->rightMeters, Meter_new(this->pl, 0, (MeterClass*) Class(RightCPUsMeter)));
} else {
Vector_add(this->leftMeters, Meter_new(this->pl, 0, (MeterClass*) Class(AllCPUsMeter)));
}
Vector_add(this->leftMeters, Meter_new(this->pl, 0, (MeterClass*) Class(MemoryMeter)));
Vector_add(this->leftMeters, Meter_new(this->pl, 0, (MeterClass*) Class(SwapMeter)));
Vector_add(this->rightMeters, Meter_new(this->pl, 0, (MeterClass*) Class(TasksMeter)));
Vector_add(this->rightMeters, Meter_new(this->pl, 0, (MeterClass*) Class(LoadAverageMeter)));
Vector_add(this->rightMeters, Meter_new(this->pl, 0, (MeterClass*) Class(UptimeMeter)));
}
void Header_reinit(Header* this) {
for (int i = 0; i < Vector_size(this->leftMeters); i++) {
Meter* meter = (Meter*) Vector_get(this->leftMeters, i);

View File

@ -47,8 +47,6 @@ char* Header_readMeterName(Header* this, int i, HeaderSide side);
MeterModeId Header_readMeterMode(Header* this, int i, HeaderSide side);
void Header_defaultMeters(Header* this, int cpuCount);
void Header_reinit(Header* this);
void Header_draw(const Header* this);

View File

@ -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_FREEBSD

30
Meter.c
View File

@ -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);

View File

@ -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);

View File

@ -61,6 +61,23 @@ static void Settings_readMeterModes(Settings* this, char* line, HeaderSide side)
String_freeArray(ids);
}
static void Settings_defaultMeters(Header* header, int cpuCount) {
if (cpuCount > 8) {
Header_createMeter(header, "LeftCPUs2", LEFT_HEADER);
Header_createMeter(header, "RightCPUs2", RIGHT_HEADER);
} else if (cpuCount > 4) {
Header_createMeter(header, "LeftCPUs", LEFT_HEADER);
Header_createMeter(header, "RightCPUs", RIGHT_HEADER);
} else {
Header_createMeter(header, "AllCPUs", LEFT_HEADER);
}
Header_createMeter(header, "Memory", LEFT_HEADER);
Header_createMeter(header, "Swap", LEFT_HEADER);
Header_createMeter(header, "Tasks", RIGHT_HEADER);
Header_createMeter(header, "LoadAverage", RIGHT_HEADER);
Header_createMeter(header, "Uptime", RIGHT_HEADER);
}
static bool Settings_read(Settings* this, const char* fileName, int cpuCount) {
FILE* fd = fopen(fileName, "r");
if (!fd)
@ -153,7 +170,7 @@ static bool Settings_read(Settings* this, const char* fileName, int cpuCount) {
}
fclose(fd);
if (!readMeters) {
Header_defaultMeters(this->header, cpuCount);
Settings_defaultMeters(this->header, cpuCount);
}
return true;
}
@ -273,7 +290,7 @@ Settings* Settings_new(ProcessList* pl, Header* header, int cpuCount) {
ok = Settings_read(this, systemSettings, cpuCount);
free(systemSettings);
if (!ok) {
Header_defaultMeters(this->header, cpuCount);
Settings_defaultMeters(this->header, cpuCount);
pl->hideKernelThreads = true;
pl->highlightMegabytes = true;
pl->highlightThreads = false;

View File

@ -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
};

View File

@ -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
};

View File

@ -13,5 +13,7 @@ in the source distribution for its full text.
void Platform_setBindings(Htop_Action* keys);
extern MeterClass* Platform_meterTypes[];
#endif