mirror of https://github.com/xzeldon/htop.git
Merge pull request #444 from Explorer09/meter-maxitems
Explicit "maxItems" property of meters
This commit is contained in:
commit
c8a735e471
|
@ -75,6 +75,7 @@ MeterClass BatteryMeter_class = {
|
||||||
},
|
},
|
||||||
.setValues = BatteryMeter_setValues,
|
.setValues = BatteryMeter_setValues,
|
||||||
.defaultMode = TEXT_METERMODE,
|
.defaultMode = TEXT_METERMODE,
|
||||||
|
.maxItems = 1,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = BatteryMeter_attributes,
|
.attributes = BatteryMeter_attributes,
|
||||||
.name = "Battery",
|
.name = "Battery",
|
||||||
|
|
|
@ -312,8 +312,8 @@ MeterClass LeftCPUs2Meter_class = {
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "LeftCPUs2",
|
.name = "LeftCPUs2",
|
||||||
.description = "CPUs (1&2/4): first half in 2 shorter columns",
|
|
||||||
.uiName = "CPUs (1&2/4)",
|
.uiName = "CPUs (1&2/4)",
|
||||||
|
.description = "CPUs (1&2/4): first half in 2 shorter columns",
|
||||||
.caption = "CPU",
|
.caption = "CPU",
|
||||||
.draw = DualColCPUsMeter_draw,
|
.draw = DualColCPUsMeter_draw,
|
||||||
.init = AllCPUsMeter_init,
|
.init = AllCPUsMeter_init,
|
||||||
|
|
|
@ -34,6 +34,7 @@ MeterClass ClockMeter_class = {
|
||||||
},
|
},
|
||||||
.setValues = ClockMeter_setValues,
|
.setValues = ClockMeter_setValues,
|
||||||
.defaultMode = TEXT_METERMODE,
|
.defaultMode = TEXT_METERMODE,
|
||||||
|
.maxItems = 1,
|
||||||
.total = 1440, /* 24*60 */
|
.total = 1440, /* 24*60 */
|
||||||
.attributes = ClockMeter_attributes,
|
.attributes = ClockMeter_attributes,
|
||||||
.name = "Clock",
|
.name = "Clock",
|
||||||
|
|
|
@ -31,6 +31,7 @@ MeterClass HostnameMeter_class = {
|
||||||
},
|
},
|
||||||
.setValues = HostnameMeter_setValues,
|
.setValues = HostnameMeter_setValues,
|
||||||
.defaultMode = TEXT_METERMODE,
|
.defaultMode = TEXT_METERMODE,
|
||||||
|
.maxItems = 0,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = HostnameMeter_attributes,
|
.attributes = HostnameMeter_attributes,
|
||||||
.name = "Hostname",
|
.name = "Hostname",
|
||||||
|
|
|
@ -77,6 +77,7 @@ MeterClass LoadMeter_class = {
|
||||||
},
|
},
|
||||||
.setValues = LoadMeter_setValues,
|
.setValues = LoadMeter_setValues,
|
||||||
.defaultMode = TEXT_METERMODE,
|
.defaultMode = TEXT_METERMODE,
|
||||||
|
.maxItems = 1,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = LoadMeter_attributes,
|
.attributes = LoadMeter_attributes,
|
||||||
.name = "Load",
|
.name = "Load",
|
||||||
|
|
9
Meter.c
9
Meter.c
|
@ -132,12 +132,8 @@ Meter* Meter_new(struct ProcessList_* pl, int param, MeterClass* type) {
|
||||||
this->h = 1;
|
this->h = 1;
|
||||||
this->param = param;
|
this->param = param;
|
||||||
this->pl = pl;
|
this->pl = pl;
|
||||||
char maxItems = type->maxItems;
|
type->curItems = type->maxItems;
|
||||||
if (maxItems == 0) {
|
this->values = xCalloc(type->maxItems, sizeof(double));
|
||||||
maxItems = 1;
|
|
||||||
}
|
|
||||||
type->curItems = maxItems;
|
|
||||||
this->values = xCalloc(maxItems, sizeof(double));
|
|
||||||
this->total = type->total;
|
this->total = type->total;
|
||||||
this->caption = xStrdup(type->caption);
|
this->caption = xStrdup(type->caption);
|
||||||
if (Meter_initFn(this))
|
if (Meter_initFn(this))
|
||||||
|
@ -550,6 +546,7 @@ MeterClass BlankMeter_class = {
|
||||||
},
|
},
|
||||||
.setValues = BlankMeter_setValues,
|
.setValues = BlankMeter_setValues,
|
||||||
.defaultMode = TEXT_METERMODE,
|
.defaultMode = TEXT_METERMODE,
|
||||||
|
.maxItems = 0,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = BlankMeter_attributes,
|
.attributes = BlankMeter_attributes,
|
||||||
.name = "Blank",
|
.name = "Blank",
|
||||||
|
|
|
@ -56,6 +56,7 @@ MeterClass SwapMeter_class = {
|
||||||
},
|
},
|
||||||
.setValues = SwapMeter_setValues,
|
.setValues = SwapMeter_setValues,
|
||||||
.defaultMode = BAR_METERMODE,
|
.defaultMode = BAR_METERMODE,
|
||||||
|
.maxItems = 1,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = SwapMeter_attributes,
|
.attributes = SwapMeter_attributes,
|
||||||
.name = "Swap",
|
.name = "Swap",
|
||||||
|
|
|
@ -74,8 +74,8 @@ MeterClass TasksMeter_class = {
|
||||||
},
|
},
|
||||||
.setValues = TasksMeter_setValues,
|
.setValues = TasksMeter_setValues,
|
||||||
.defaultMode = TEXT_METERMODE,
|
.defaultMode = TEXT_METERMODE,
|
||||||
.total = 100.0,
|
|
||||||
.maxItems = 4,
|
.maxItems = 4,
|
||||||
|
.total = 100.0,
|
||||||
.attributes = TasksMeter_attributes,
|
.attributes = TasksMeter_attributes,
|
||||||
.name = "Tasks",
|
.name = "Tasks",
|
||||||
.uiName = "Task counter",
|
.uiName = "Task counter",
|
||||||
|
|
|
@ -51,6 +51,7 @@ MeterClass UptimeMeter_class = {
|
||||||
},
|
},
|
||||||
.setValues = UptimeMeter_setValues,
|
.setValues = UptimeMeter_setValues,
|
||||||
.defaultMode = TEXT_METERMODE,
|
.defaultMode = TEXT_METERMODE,
|
||||||
|
.maxItems = 1,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = UptimeMeter_attributes,
|
.attributes = UptimeMeter_attributes,
|
||||||
.name = "Uptime",
|
.name = "Uptime",
|
||||||
|
|
2
XAlloc.c
2
XAlloc.c
|
@ -29,7 +29,7 @@ void* xMalloc(size_t size) {
|
||||||
|
|
||||||
void* xCalloc(size_t nmemb, size_t size) {
|
void* xCalloc(size_t nmemb, size_t size) {
|
||||||
void* data = calloc(nmemb, size);
|
void* data = calloc(nmemb, size);
|
||||||
if (!data) {
|
if (!data && nmemb > 0 && size > 0) {
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
|
|
Loading…
Reference in New Issue