mirror of https://github.com/xzeldon/htop.git
Portability: make list of default screens per-platform
This commit is contained in:
parent
657836a2ae
commit
6fe06fb7e5
19
Settings.c
19
Settings.c
|
@ -23,6 +23,12 @@ in the source distribution for its full text.
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char* name;
|
||||||
|
const char* columns;
|
||||||
|
const char* sortKey;
|
||||||
|
} ScreenDefaults;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int len;
|
int len;
|
||||||
char** names;
|
char** names;
|
||||||
|
@ -266,14 +272,11 @@ ScreenSettings* Settings_newScreen(Settings* this, const char* name, const char*
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Settings_defaultScreens(Settings* this) {
|
static void Settings_defaultScreens(Settings* this) {
|
||||||
Settings_newScreen(this, "Default", "PID USER PRIORITY NICE M_SIZE M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command");
|
for (unsigned int i = 0; i < Platform_numberOfDefaultScreens; i++) {
|
||||||
this->screens[0]->sortKey = toFieldIndex("PERCENT_CPU");
|
ScreenDefaults* defaults = &Platform_defaultScreens[i];
|
||||||
Settings_newScreen(this, "I/O", "PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command");
|
Settings_newScreen(this, defaults->name, defaults->columns);
|
||||||
this->screens[1]->sortKey = toFieldIndex("IO_RATE");
|
this->screens[0]->sortKey = toFieldIndex(defaults->sortKey);
|
||||||
Settings_newScreen(this, "Perf Counters", "PID USER PERCENT_CPU PROCESSOR MCYCLE MINSTR IPC PERCENT_MISS PERCENT_BMISS Command");
|
}
|
||||||
this->screens[2]->sortKey = toFieldIndex("MCYCLE");
|
|
||||||
Settings_newScreen(this, "L1 Data Cache", "PID USER PERCENT_CPU L1DREADS L1DRMISSES L1DWRITES L1DWMISSES Command");
|
|
||||||
this->screens[3]->sortKey = toFieldIndex("L1DREADS");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool Settings_read(Settings* this, const char* fileName) {
|
static bool Settings_read(Settings* this, const char* fileName) {
|
||||||
|
|
|
@ -14,6 +14,12 @@ in the source distribution for its full text.
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char* name;
|
||||||
|
const char* columns;
|
||||||
|
const char* sortKey;
|
||||||
|
} ScreenDefaults;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int len;
|
int len;
|
||||||
char** names;
|
char** names;
|
||||||
|
|
|
@ -36,7 +36,15 @@ typedef enum DarwinProcessFields {
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
ScreenDefaults Platform_defaultScreens[] = {
|
||||||
|
{
|
||||||
|
.name = "Default",
|
||||||
|
.columns = "PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||||
|
.sortKey = "PERCENT_CPU",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned int Platform_numberOfDefaultScreens = sizeof(Platform_defaultScreens)/sizeof(ScreenDefaults);
|
||||||
|
|
||||||
const SignalItem Platform_signals[] = {
|
const SignalItem Platform_signals[] = {
|
||||||
{ .name = " 0 Cancel", .number = 0 },
|
{ .name = " 0 Cancel", .number = 0 },
|
||||||
|
|
|
@ -20,11 +20,14 @@ typedef enum DarwinProcessFields {
|
||||||
LAST_PROCESSFIELD = 100,
|
LAST_PROCESSFIELD = 100,
|
||||||
} DarwinProcessField;
|
} DarwinProcessField;
|
||||||
|
|
||||||
|
|
||||||
#ifndef CLAMP
|
#ifndef CLAMP
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern ProcessField Platform_defaultFields[];
|
extern ScreenDefaults Platform_defaultScreens[];
|
||||||
|
|
||||||
|
extern const unsigned int Platform_numberOfDefaultScreens;
|
||||||
|
|
||||||
extern const SignalItem Platform_signals[];
|
extern const SignalItem Platform_signals[];
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,15 @@ extern ProcessFieldData Process_fields[];
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
ScreenDefaults Platform_defaultScreens[] = {
|
||||||
|
{
|
||||||
|
.name = "Default",
|
||||||
|
.columns = "PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||||
|
.sortKey = "PERCENT_CPU",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned int Platform_numberOfDefaultScreens = sizeof(Platform_defaultScreens)/sizeof(ScreenDefaults);
|
||||||
|
|
||||||
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,9 @@ extern ProcessFieldData Process_fields[];
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern ProcessField Platform_defaultFields[];
|
extern ScreenDefaults Platform_defaultScreens[];
|
||||||
|
|
||||||
|
extern const unsigned int Platform_numberOfDefaultScreens;
|
||||||
|
|
||||||
extern int Platform_numberOfFields;
|
extern int Platform_numberOfFields;
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,16 @@ extern ProcessFieldData Process_fields[];
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ScreenDefaults Platform_defaultScreens[] = {
|
||||||
|
{
|
||||||
|
.name = "Default",
|
||||||
|
.columns = "PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||||
|
.sortKey = "PERCENT_CPU",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned int Platform_numberOfDefaultScreens = sizeof(Platform_defaultScreens)/sizeof(ScreenDefaults);
|
||||||
|
|
||||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
||||||
|
|
||||||
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
||||||
|
|
|
@ -20,6 +20,10 @@ extern ProcessFieldData Process_fields[];
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern ScreenDefaults Platform_defaultScreens[];
|
||||||
|
|
||||||
|
extern const unsigned int Platform_numberOfDefaultScreens;
|
||||||
|
|
||||||
extern ProcessField Platform_defaultFields[];
|
extern ProcessField Platform_defaultFields[];
|
||||||
|
|
||||||
extern int Platform_numberOfFields;
|
extern int Platform_numberOfFields;
|
||||||
|
|
|
@ -36,16 +36,13 @@ in the source distribution for its full text.
|
||||||
#include "BatteryMeter.h"
|
#include "BatteryMeter.h"
|
||||||
#include "LinuxProcess.h"
|
#include "LinuxProcess.h"
|
||||||
#include "SignalsPanel.h"
|
#include "SignalsPanel.h"
|
||||||
|
#include "Settings.h"
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
#ifndef CLAMP
|
#ifndef CLAMP
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
|
||||||
|
|
||||||
//static ProcessField defaultIoFields[] = { PID, IO_PRIORITY, USER, IO_READ_RATE, IO_WRITE_RATE, IO_RATE, COMM, 0 };
|
|
||||||
|
|
||||||
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
||||||
|
|
||||||
const SignalItem Platform_signals[] = {
|
const SignalItem Platform_signals[] = {
|
||||||
|
@ -85,6 +82,31 @@ const SignalItem Platform_signals[] = {
|
||||||
{ .name = "31 SIGSYS", .number = 31 },
|
{ .name = "31 SIGSYS", .number = 31 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ScreenDefaults Platform_defaultScreens[] = {
|
||||||
|
{
|
||||||
|
.name = "Default",
|
||||||
|
.columns = "PID USER PRIORITY NICE M_SIZE M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||||
|
.sortKey = "PERCENT_CPU",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "I/O",
|
||||||
|
.columns = "PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command",
|
||||||
|
.sortKey = "IO_RATE",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "Perf Counters",
|
||||||
|
.columns = "PID USER PERCENT_CPU PROCESSOR MCYCLE MINSTR IPC PERCENT_MISS PERCENT_BMISS Command",
|
||||||
|
.sortKey = "MCYCLE",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.name = "L1 Data Cache",
|
||||||
|
.columns = "PID USER PERCENT_CPU L1DREADS L1DRMISSES L1DWRITES L1DWMISSES Command",
|
||||||
|
.sortKey = "LD1READS",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned int Platform_numberOfDefaultScreens = sizeof(Platform_defaultScreens)/sizeof(ScreenDefaults);
|
||||||
|
|
||||||
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
|
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
|
||||||
|
|
||||||
static Htop_Reaction Platform_actionSetIOPriority(State* st) {
|
static Htop_Reaction Platform_actionSetIOPriority(State* st) {
|
||||||
|
|
|
@ -14,17 +14,20 @@ in the source distribution for its full text.
|
||||||
#include "BatteryMeter.h"
|
#include "BatteryMeter.h"
|
||||||
#include "LinuxProcess.h"
|
#include "LinuxProcess.h"
|
||||||
#include "SignalsPanel.h"
|
#include "SignalsPanel.h"
|
||||||
|
#include "Settings.h"
|
||||||
|
|
||||||
#ifndef CLAMP
|
#ifndef CLAMP
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern ProcessField Platform_defaultFields[];
|
|
||||||
|
|
||||||
extern int Platform_numberOfFields;
|
extern int Platform_numberOfFields;
|
||||||
|
|
||||||
extern const SignalItem Platform_signals[];
|
extern const SignalItem Platform_signals[];
|
||||||
|
|
||||||
|
extern ScreenDefaults Platform_defaultScreens[];
|
||||||
|
|
||||||
|
extern const unsigned int Platform_numberOfDefaultScreens;
|
||||||
|
|
||||||
extern const unsigned int Platform_numberOfSignals;
|
extern const unsigned int Platform_numberOfSignals;
|
||||||
|
|
||||||
void Platform_setBindings(Htop_Action* keys);
|
void Platform_setBindings(Htop_Action* keys);
|
||||||
|
|
|
@ -12,5 +12,4 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
void Battery_getData(double* level, ACPresence* isOnAC);
|
void Battery_getData(double* level, ACPresence* isOnAC);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -92,7 +92,15 @@ static int percentages(int cnt, int64_t *out, int64_t *new, int64_t *old, int64_
|
||||||
return (total_change);
|
return (total_change);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
ScreenDefaults Platform_defaultScreens[] = {
|
||||||
|
{
|
||||||
|
.name = "Default",
|
||||||
|
.columns = "PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||||
|
.sortKey = "PERCENT_CPU",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned int Platform_numberOfDefaultScreens = sizeof(Platform_defaultScreens)/sizeof(ScreenDefaults);
|
||||||
|
|
||||||
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
int Platform_numberOfFields = LAST_PROCESSFIELD;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,9 @@ extern ProcessFieldData Process_fields[];
|
||||||
* The routine assumes modulo arithmetic. This function is especially
|
* The routine assumes modulo arithmetic. This function is especially
|
||||||
* useful on BSD machines for calculating cpu state percentages.
|
* useful on BSD machines for calculating cpu state percentages.
|
||||||
*/
|
*/
|
||||||
extern ProcessField Platform_defaultFields[];
|
extern ScreenDefaults Platform_defaultScreens[];
|
||||||
|
|
||||||
|
extern const unsigned int Platform_numberOfDefaultScreens;
|
||||||
|
|
||||||
extern int Platform_numberOfFields;
|
extern int Platform_numberOfFields;
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,15 @@ const SignalItem Platform_signals[] = {
|
||||||
|
|
||||||
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
|
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
|
||||||
|
|
||||||
ProcessField Platform_defaultFields[] = { PID, LWPID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
ScreenDefaults Platform_defaultScreens[] = {
|
||||||
|
{
|
||||||
|
.name = "Default",
|
||||||
|
.columns = "PID LWPID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||||
|
.sortKey = "PERCENT_CPU",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned int Platform_numberOfDefaultScreens = sizeof(Platform_defaultScreens)/sizeof(ScreenDefaults);
|
||||||
|
|
||||||
MeterClass* Platform_meterTypes[] = {
|
MeterClass* Platform_meterTypes[] = {
|
||||||
&CPUMeter_class,
|
&CPUMeter_class,
|
||||||
|
|
|
@ -38,7 +38,9 @@ extern const SignalItem Platform_signals[];
|
||||||
|
|
||||||
extern const unsigned int Platform_numberOfSignals;
|
extern const unsigned int Platform_numberOfSignals;
|
||||||
|
|
||||||
extern ProcessField Platform_defaultFields[];
|
extern ScreenDefaults Platform_defaultScreens[];
|
||||||
|
|
||||||
|
extern const unsigned int Platform_numberOfDefaultScreens;
|
||||||
|
|
||||||
extern MeterClass* Platform_meterTypes[];
|
extern MeterClass* Platform_meterTypes[];
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,15 @@ const SignalItem Platform_signals[] = {
|
||||||
|
|
||||||
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
|
const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
|
||||||
|
|
||||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
ScreenDefaults Platform_defaultScreens[] = {
|
||||||
|
{
|
||||||
|
.name = "Default",
|
||||||
|
.columns = "PID LWPID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||||
|
.sortKey = "PERCENT_CPU",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned int Platform_numberOfDefaultScreens = sizeof(Platform_defaultScreens)/sizeof(ScreenDefaults);
|
||||||
|
|
||||||
ProcessFieldData Process_fields[] = {
|
ProcessFieldData Process_fields[] = {
|
||||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
||||||
|
|
|
@ -19,7 +19,9 @@ extern const SignalItem Platform_signals[];
|
||||||
|
|
||||||
extern const unsigned int Platform_numberOfSignals;
|
extern const unsigned int Platform_numberOfSignals;
|
||||||
|
|
||||||
extern ProcessField Platform_defaultFields[];
|
extern ScreenDefaults Platform_defaultScreens[];
|
||||||
|
|
||||||
|
extern const unsigned int Platform_numberOfDefaultScreens;
|
||||||
|
|
||||||
extern ProcessFieldData Process_fields[];
|
extern ProcessFieldData Process_fields[];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue