Merge branch 'multicolumn' of https://github.com/cgzones/htop into cgzones-multicolumn

This commit is contained in:
Nathan Scott 2021-09-20 16:29:44 +10:00
commit e6596cbd69
4 changed files with 18 additions and 1 deletions

View File

@ -381,6 +381,7 @@ const MeterClass AllCPUs2Meter_class = {
}, },
.updateValues = AllCPUsMeter_updateValues, .updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0, .total = 100.0,
.attributes = CPUMeter_attributes, .attributes = CPUMeter_attributes,
.name = "AllCPUs2", .name = "AllCPUs2",
@ -401,6 +402,7 @@ const MeterClass LeftCPUsMeter_class = {
}, },
.updateValues = AllCPUsMeter_updateValues, .updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0, .total = 100.0,
.attributes = CPUMeter_attributes, .attributes = CPUMeter_attributes,
.name = "LeftCPUs", .name = "LeftCPUs",
@ -421,6 +423,7 @@ const MeterClass RightCPUsMeter_class = {
}, },
.updateValues = AllCPUsMeter_updateValues, .updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0, .total = 100.0,
.attributes = CPUMeter_attributes, .attributes = CPUMeter_attributes,
.name = "RightCPUs", .name = "RightCPUs",
@ -441,6 +444,7 @@ const MeterClass LeftCPUs2Meter_class = {
}, },
.updateValues = AllCPUsMeter_updateValues, .updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0, .total = 100.0,
.attributes = CPUMeter_attributes, .attributes = CPUMeter_attributes,
.name = "LeftCPUs2", .name = "LeftCPUs2",
@ -461,6 +465,7 @@ const MeterClass RightCPUs2Meter_class = {
}, },
.updateValues = AllCPUsMeter_updateValues, .updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0, .total = 100.0,
.attributes = CPUMeter_attributes, .attributes = CPUMeter_attributes,
.name = "RightCPUs2", .name = "RightCPUs2",
@ -481,6 +486,7 @@ const MeterClass AllCPUs4Meter_class = {
}, },
.updateValues = AllCPUsMeter_updateValues, .updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0, .total = 100.0,
.attributes = CPUMeter_attributes, .attributes = CPUMeter_attributes,
.name = "AllCPUs4", .name = "AllCPUs4",
@ -501,6 +507,7 @@ const MeterClass LeftCPUs4Meter_class = {
}, },
.updateValues = AllCPUsMeter_updateValues, .updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0, .total = 100.0,
.attributes = CPUMeter_attributes, .attributes = CPUMeter_attributes,
.name = "LeftCPUs4", .name = "LeftCPUs4",
@ -521,6 +528,7 @@ const MeterClass RightCPUs4Meter_class = {
}, },
.updateValues = AllCPUsMeter_updateValues, .updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0, .total = 100.0,
.attributes = CPUMeter_attributes, .attributes = CPUMeter_attributes,
.name = "RightCPUs4", .name = "RightCPUs4",
@ -541,6 +549,7 @@ const MeterClass AllCPUs8Meter_class = {
}, },
.updateValues = AllCPUsMeter_updateValues, .updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0, .total = 100.0,
.attributes = CPUMeter_attributes, .attributes = CPUMeter_attributes,
.name = "AllCPUs8", .name = "AllCPUs8",
@ -561,6 +570,7 @@ const MeterClass LeftCPUs8Meter_class = {
}, },
.updateValues = AllCPUsMeter_updateValues, .updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0, .total = 100.0,
.attributes = CPUMeter_attributes, .attributes = CPUMeter_attributes,
.name = "LeftCPUs8", .name = "LeftCPUs8",
@ -581,6 +591,7 @@ const MeterClass RightCPUs8Meter_class = {
}, },
.updateValues = AllCPUsMeter_updateValues, .updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0, .total = 100.0,
.attributes = CPUMeter_attributes, .attributes = CPUMeter_attributes,
.name = "RightCPUs8", .name = "RightCPUs8",

View File

@ -212,7 +212,10 @@ void Header_draw(const Header* this) {
Meter* meter = (Meter*) Vector_get(meters, i); Meter* meter = (Meter*) Vector_get(meters, i);
float actualWidth = colWidth; float actualWidth = colWidth;
if (meter->mode == TEXT_METERMODE) {
/* Let meters in text mode expand to the right on empty neighbors;
except for multi column meters. */
if (meter->mode == TEXT_METERMODE && !Meter_isMultiColumn(meter)) {
for (int j = 1; j < meter->columnWidthCount; j++) { for (int j = 1; j < meter->columnWidthCount; j++) {
actualWidth += (float)width * HeaderLayout_layouts[this->headerLayout].widths[col + j] / 100.0F; actualWidth += (float)width * HeaderLayout_layouts[this->headerLayout].widths[col + j] / 100.0F;
} }

View File

@ -95,6 +95,7 @@ const MeterClass MemorySwapMeter_class = {
}, },
.updateValues = MemorySwapMeter_updateValues, .updateValues = MemorySwapMeter_updateValues,
.defaultMode = CUSTOM_METERMODE, .defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.name = "MemorySwap", .name = "MemorySwap",
.uiName = "Memory & Swap", .uiName = "Memory & Swap",
.description = "Combined memory and swap usage", .description = "Combined memory and swap usage",

View File

@ -73,6 +73,7 @@ typedef struct MeterClass_ {
const char* const caption; /* prefix in the actual header */ const char* const caption; /* prefix in the actual header */
const char* const description; /* optional meter description in header setup menu */ const char* const description; /* optional meter description in header setup menu */
const uint8_t maxItems; const uint8_t maxItems;
const bool isMultiColumn; /* whether the meter draws multiple sub-columns (defaults to false) */
} MeterClass; } MeterClass;
#define As_Meter(this_) ((const MeterClass*)((this_)->super.klass)) #define As_Meter(this_) ((const MeterClass*)((this_)->super.klass))
@ -92,6 +93,7 @@ typedef struct MeterClass_ {
#define Meter_attributes(this_) As_Meter(this_)->attributes #define Meter_attributes(this_) As_Meter(this_)->attributes
#define Meter_name(this_) As_Meter(this_)->name #define Meter_name(this_) As_Meter(this_)->name
#define Meter_uiName(this_) As_Meter(this_)->uiName #define Meter_uiName(this_) As_Meter(this_)->uiName
#define Meter_isMultiColumn(this_) As_Meter(this_)->isMultiColumn
typedef struct GraphData_ { typedef struct GraphData_ {
struct timeval time; struct timeval time;