mirror of https://github.com/xzeldon/htop.git
Final fixes to make "All CPUs" the default CPU display mode.
This commit is contained in:
parent
c3d757f606
commit
57a17420e0
12
CPUMeter.c
12
CPUMeter.c
|
@ -46,6 +46,7 @@ MeterType AllCPUsMeter = {
|
||||||
.caption = "CPU",
|
.caption = "CPU",
|
||||||
.draw = AllCPUsMeter_draw,
|
.draw = AllCPUsMeter_draw,
|
||||||
.init = AllCPUsMeter_init,
|
.init = AllCPUsMeter_init,
|
||||||
|
.setMode = AllCPUsMeter_setMode,
|
||||||
.done = AllCPUsMeter_done
|
.done = AllCPUsMeter_done
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -110,12 +111,19 @@ void AllCPUsMeter_done(Meter* this) {
|
||||||
Meter_delete((Object*)meters[i]);
|
Meter_delete((Object*)meters[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AllCPUsMeter_setMode(Meter* this, int mode) {
|
||||||
|
this->mode = mode;
|
||||||
|
int processors = this->pl->processorCount;
|
||||||
|
int h = Meter_modes[this->mode]->h;
|
||||||
|
this->h = h * processors;
|
||||||
|
}
|
||||||
|
|
||||||
void AllCPUsMeter_draw(Meter* this, int x, int y, int w) {
|
void AllCPUsMeter_draw(Meter* this, int x, int y, int w) {
|
||||||
int processors = this->pl->processorCount;
|
int processors = this->pl->processorCount;
|
||||||
Meter** meters = (Meter**) this->drawBuffer;
|
Meter** meters = (Meter**) this->drawBuffer;
|
||||||
this->h = Meter_modes[this->mode]->h * processors;
|
|
||||||
for (int i = 0; i < processors; i++) {
|
for (int i = 0; i < processors; i++) {
|
||||||
Meter_setMode(meters[i], this->mode);
|
Meter_setMode(meters[i], this->mode);
|
||||||
meters[i]->draw(meters[i], x, y+i, w);
|
meters[i]->draw(meters[i], x, y, w);
|
||||||
|
y += meters[i]->h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,8 @@ void AllCPUsMeter_init(Meter* this);
|
||||||
|
|
||||||
void AllCPUsMeter_done(Meter* this);
|
void AllCPUsMeter_done(Meter* this);
|
||||||
|
|
||||||
|
void AllCPUsMeter_setMode(Meter* this, int mode);
|
||||||
|
|
||||||
void AllCPUsMeter_draw(Meter* this, int x, int y, int w);
|
void AllCPUsMeter_draw(Meter* this, int x, int y, int w);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
3
Header.c
3
Header.c
|
@ -122,8 +122,7 @@ MeterModeId Header_readMeterMode(Header* this, int i, HeaderSide side) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Header_defaultMeters(Header* this) {
|
void Header_defaultMeters(Header* this) {
|
||||||
for (int i = 1; i <= this->pl->processorCount; i++)
|
TypedVector_add(this->leftMeters, Meter_new(this->pl, 0, &AllCPUsMeter));
|
||||||
TypedVector_add(this->leftMeters, Meter_new(this->pl, i, &CPUMeter));
|
|
||||||
TypedVector_add(this->leftMeters, Meter_new(this->pl, 0, &MemoryMeter));
|
TypedVector_add(this->leftMeters, Meter_new(this->pl, 0, &MemoryMeter));
|
||||||
TypedVector_add(this->leftMeters, Meter_new(this->pl, 0, &SwapMeter));
|
TypedVector_add(this->leftMeters, Meter_new(this->pl, 0, &SwapMeter));
|
||||||
TypedVector_add(this->rightMeters, Meter_new(this->pl, 0, &TasksMeter));
|
TypedVector_add(this->rightMeters, Meter_new(this->pl, 0, &TasksMeter));
|
||||||
|
|
5
Meter.c
5
Meter.c
|
@ -36,6 +36,7 @@ typedef struct MeterMode_ MeterMode;
|
||||||
|
|
||||||
typedef void(*MeterType_Init)(Meter*);
|
typedef void(*MeterType_Init)(Meter*);
|
||||||
typedef void(*MeterType_Done)(Meter*);
|
typedef void(*MeterType_Done)(Meter*);
|
||||||
|
typedef void(*MeterType_SetMode)(Meter*, int);
|
||||||
typedef void(*Meter_SetValues)(Meter*, char*, int);
|
typedef void(*Meter_SetValues)(Meter*, char*, int);
|
||||||
typedef void(*Meter_Draw)(Meter*, int, int, int);
|
typedef void(*Meter_Draw)(Meter*, int, int, int);
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ struct MeterType_ {
|
||||||
char* caption;
|
char* caption;
|
||||||
MeterType_Init init;
|
MeterType_Init init;
|
||||||
MeterType_Done done;
|
MeterType_Done done;
|
||||||
|
MeterType_SetMode setMode;
|
||||||
Meter_Draw draw;
|
Meter_Draw draw;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -226,6 +228,8 @@ void Meter_setMode(Meter* this, int modeIndex) {
|
||||||
assert(modeIndex < LAST_METERMODE);
|
assert(modeIndex < LAST_METERMODE);
|
||||||
if (this->type->mode == 0) {
|
if (this->type->mode == 0) {
|
||||||
this->draw = this->type->draw;
|
this->draw = this->type->draw;
|
||||||
|
if (this->type->setMode)
|
||||||
|
this->type->setMode(this, modeIndex);
|
||||||
} else {
|
} else {
|
||||||
assert(modeIndex >= 1);
|
assert(modeIndex >= 1);
|
||||||
if (this->drawBuffer)
|
if (this->drawBuffer)
|
||||||
|
@ -382,7 +386,6 @@ void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
|
||||||
value += this->values[i];
|
value += this->values[i];
|
||||||
value /= this->total;
|
value /= this->total;
|
||||||
drawBuffer[METER_BUFFER_LEN - 1] = value;
|
drawBuffer[METER_BUFFER_LEN - 1] = value;
|
||||||
mvprintw(0,0,"%f ",value);
|
|
||||||
for (int i = METER_BUFFER_LEN - w, k = 0; i < METER_BUFFER_LEN; i++, k++) {
|
for (int i = METER_BUFFER_LEN - w, k = 0; i < METER_BUFFER_LEN; i++, k++) {
|
||||||
double value = drawBuffer[i];
|
double value = drawBuffer[i];
|
||||||
DrawDot( CRT_colors[DEFAULT_COLOR], y, ' ' );
|
DrawDot( CRT_colors[DEFAULT_COLOR], y, ' ' );
|
||||||
|
|
4
Meter.h
4
Meter.h
|
@ -38,6 +38,7 @@ typedef struct MeterMode_ MeterMode;
|
||||||
|
|
||||||
typedef void(*MeterType_Init)(Meter*);
|
typedef void(*MeterType_Init)(Meter*);
|
||||||
typedef void(*MeterType_Done)(Meter*);
|
typedef void(*MeterType_Done)(Meter*);
|
||||||
|
typedef void(*MeterType_SetMode)(Meter*, int);
|
||||||
typedef void(*Meter_SetValues)(Meter*, char*, int);
|
typedef void(*Meter_SetValues)(Meter*, char*, int);
|
||||||
typedef void(*Meter_Draw)(Meter*, int, int, int);
|
typedef void(*Meter_Draw)(Meter*, int, int, int);
|
||||||
|
|
||||||
|
@ -59,6 +60,7 @@ struct MeterType_ {
|
||||||
char* caption;
|
char* caption;
|
||||||
MeterType_Init init;
|
MeterType_Init init;
|
||||||
MeterType_Done done;
|
MeterType_Done done;
|
||||||
|
MeterType_SetMode setMode;
|
||||||
Meter_Draw draw;
|
Meter_Draw draw;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,7 +101,7 @@ typedef enum {
|
||||||
LAST_METERMODE
|
LAST_METERMODE
|
||||||
} MeterModeId;
|
} MeterModeId;
|
||||||
|
|
||||||
extern MeterType* Meter_types[9];
|
extern MeterType* Meter_types[];
|
||||||
extern MeterMode* Meter_modes[];
|
extern MeterMode* Meter_modes[];
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue