mirror of https://github.com/xzeldon/htop.git
parent
3f727d4720
commit
b965417bf7
|
@ -52,6 +52,7 @@ myhtopsources = \
|
|||
LoadAverageMeter.c \
|
||||
MainPanel.c \
|
||||
MemoryMeter.c \
|
||||
MemorySwapMeter.c \
|
||||
Meter.c \
|
||||
MetersPanel.c \
|
||||
NetworkIOMeter.c \
|
||||
|
@ -109,6 +110,7 @@ myhtopheaders = \
|
|||
Macros.h \
|
||||
MainPanel.h \
|
||||
MemoryMeter.h \
|
||||
MemorySwapMeter.h \
|
||||
Meter.h \
|
||||
MetersPanel.h \
|
||||
NetworkIOMeter.h \
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
htop - MemorySwapMeter.c
|
||||
(C) 2021 htop dev team
|
||||
Released under the GNU GPLv2, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
#include "MemorySwapMeter.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "CRT.h"
|
||||
#include "MemoryMeter.h"
|
||||
#include "Object.h"
|
||||
#include "Platform.h"
|
||||
#include "RichString.h"
|
||||
#include "SwapMeter.h"
|
||||
|
||||
|
||||
typedef struct MemorySwapMeterData_ {
|
||||
Meter* memoryMeter;
|
||||
Meter* swapMeter;
|
||||
} MemorySwapMeterData;
|
||||
|
||||
static void MemorySwapMeter_updateValues(Meter* this) {
|
||||
MemorySwapMeterData* data = this->meterData;
|
||||
|
||||
Meter_updateValues(data->memoryMeter);
|
||||
Meter_updateValues(data->swapMeter);
|
||||
}
|
||||
|
||||
static void MemorySwapMeter_draw(Meter* this, int x, int y, int w) {
|
||||
MemorySwapMeterData* data = this->meterData;
|
||||
|
||||
int colwidth = (w - 2) / 2 + 1;
|
||||
|
||||
assert(data->memoryMeter->draw);
|
||||
data->memoryMeter->draw(data->memoryMeter, x, y, colwidth);
|
||||
assert(data->swapMeter->draw);
|
||||
data->swapMeter->draw(data->swapMeter, x + w / 2, y, colwidth);
|
||||
}
|
||||
|
||||
static void MemorySwapMeter_init(Meter* this) {
|
||||
MemorySwapMeterData* data = this->meterData;
|
||||
|
||||
if (!data) {
|
||||
data = this->meterData = xMalloc(sizeof(MemorySwapMeterData));
|
||||
data->memoryMeter = NULL;
|
||||
data->swapMeter = NULL;
|
||||
}
|
||||
|
||||
if (!data->memoryMeter)
|
||||
data->memoryMeter = Meter_new(this->pl, 0, (const MeterClass*) Class(MemoryMeter));
|
||||
if (!data->swapMeter)
|
||||
data->swapMeter = Meter_new(this->pl, 0, (const MeterClass*) Class(SwapMeter));
|
||||
|
||||
if (Meter_initFn(data->memoryMeter))
|
||||
Meter_init(data->memoryMeter);
|
||||
if (Meter_initFn(data->swapMeter))
|
||||
Meter_init(data->swapMeter);
|
||||
|
||||
if (this->mode == 0)
|
||||
this->mode = BAR_METERMODE;
|
||||
|
||||
this->h = MAXIMUM(Meter_modes[data->memoryMeter->mode]->h, Meter_modes[data->swapMeter->mode]->h);
|
||||
}
|
||||
|
||||
static void MemorySwapMeter_updateMode(Meter* this, int mode) {
|
||||
MemorySwapMeterData* data = this->meterData;
|
||||
|
||||
this->mode = mode;
|
||||
|
||||
Meter_setMode(data->memoryMeter, mode);
|
||||
Meter_setMode(data->swapMeter, mode);
|
||||
|
||||
this->h = MAXIMUM(Meter_modes[data->memoryMeter->mode]->h, Meter_modes[data->swapMeter->mode]->h);
|
||||
}
|
||||
|
||||
static void MemorySwapMeter_done(Meter* this) {
|
||||
MemorySwapMeterData* data = this->meterData;
|
||||
|
||||
Meter_delete((Object*)data->swapMeter);
|
||||
Meter_delete((Object*)data->memoryMeter);
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
const MeterClass MemorySwapMeter_class = {
|
||||
.super = {
|
||||
.extends = Class(Meter),
|
||||
.delete = Meter_delete,
|
||||
},
|
||||
.updateValues = MemorySwapMeter_updateValues,
|
||||
.defaultMode = CUSTOM_METERMODE,
|
||||
.name = "MemorySwap",
|
||||
.uiName = "Memory & Swap",
|
||||
.description = "Combined memory and swap usage",
|
||||
.caption = "M&S",
|
||||
.draw = MemorySwapMeter_draw,
|
||||
.init = MemorySwapMeter_init,
|
||||
.updateMode = MemorySwapMeter_updateMode,
|
||||
.done = MemorySwapMeter_done
|
||||
};
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef HEADER_MemorySwapMeter
|
||||
#define HEADER_MemorySwapMeter
|
||||
/*
|
||||
htop - MemorySwapMeter.h
|
||||
(C) 2021 htop dev team
|
||||
Released under the GNU GPLv2, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
#include "Meter.h"
|
||||
|
||||
|
||||
extern const MeterClass MemorySwapMeter_class;
|
||||
|
||||
#endif
|
|
@ -28,6 +28,7 @@ in the source distribution for its full text.
|
|||
#include "LoadAverageMeter.h"
|
||||
#include "Macros.h"
|
||||
#include "MemoryMeter.h"
|
||||
#include "MemorySwapMeter.h"
|
||||
#include "ProcessLocksScreen.h"
|
||||
#include "SwapMeter.h"
|
||||
#include "SysArchMeter.h"
|
||||
|
@ -95,6 +96,7 @@ const MeterClass* const Platform_meterTypes[] = {
|
|||
&LoadMeter_class,
|
||||
&MemoryMeter_class,
|
||||
&SwapMeter_class,
|
||||
&MemorySwapMeter_class,
|
||||
&TasksMeter_class,
|
||||
&BatteryMeter_class,
|
||||
&HostnameMeter_class,
|
||||
|
|
|
@ -23,6 +23,7 @@ in the source distribution for its full text.
|
|||
#include "HostnameMeter.h"
|
||||
#include "LoadAverageMeter.h"
|
||||
#include "MemoryMeter.h"
|
||||
#include "MemorySwapMeter.h"
|
||||
#include "ProcessList.h"
|
||||
#include "SwapMeter.h"
|
||||
#include "SysArchMeter.h"
|
||||
|
@ -81,6 +82,7 @@ const MeterClass* const Platform_meterTypes[] = {
|
|||
&LoadAverageMeter_class,
|
||||
&LoadMeter_class,
|
||||
&MemoryMeter_class,
|
||||
&MemorySwapMeter_class,
|
||||
&SwapMeter_class,
|
||||
&TasksMeter_class,
|
||||
&UptimeMeter_class,
|
||||
|
|
|
@ -35,6 +35,7 @@ in the source distribution for its full text.
|
|||
#include "LoadAverageMeter.h"
|
||||
#include "Macros.h"
|
||||
#include "MemoryMeter.h"
|
||||
#include "MemorySwapMeter.h"
|
||||
#include "Meter.h"
|
||||
#include "NetworkIOMeter.h"
|
||||
#include "ProcessList.h"
|
||||
|
@ -100,6 +101,7 @@ const MeterClass* const Platform_meterTypes[] = {
|
|||
&LoadMeter_class,
|
||||
&MemoryMeter_class,
|
||||
&SwapMeter_class,
|
||||
&MemorySwapMeter_class,
|
||||
&TasksMeter_class,
|
||||
&UptimeMeter_class,
|
||||
&BatteryMeter_class,
|
||||
|
|
|
@ -36,6 +36,7 @@ in the source distribution for its full text.
|
|||
#include "MainPanel.h"
|
||||
#include "Meter.h"
|
||||
#include "MemoryMeter.h"
|
||||
#include "MemorySwapMeter.h"
|
||||
#include "NetworkIOMeter.h"
|
||||
#include "Object.h"
|
||||
#include "Panel.h"
|
||||
|
@ -195,6 +196,7 @@ const MeterClass* const Platform_meterTypes[] = {
|
|||
&LoadMeter_class,
|
||||
&MemoryMeter_class,
|
||||
&SwapMeter_class,
|
||||
&MemorySwapMeter_class,
|
||||
&SysArchMeter_class,
|
||||
&HugePageMeter_class,
|
||||
&TasksMeter_class,
|
||||
|
|
|
@ -42,6 +42,7 @@ in the source distribution for its full text.
|
|||
#include "LoadAverageMeter.h"
|
||||
#include "Macros.h"
|
||||
#include "MemoryMeter.h"
|
||||
#include "MemorySwapMeter.h"
|
||||
#include "Meter.h"
|
||||
#include "ProcessList.h"
|
||||
#include "Settings.h"
|
||||
|
@ -149,6 +150,7 @@ const MeterClass* const Platform_meterTypes[] = {
|
|||
&LoadMeter_class,
|
||||
&MemoryMeter_class,
|
||||
&SwapMeter_class,
|
||||
&MemorySwapMeter_class,
|
||||
&TasksMeter_class,
|
||||
&UptimeMeter_class,
|
||||
&BatteryMeter_class,
|
||||
|
|
|
@ -32,6 +32,7 @@ in the source distribution for its full text.
|
|||
#include "LoadAverageMeter.h"
|
||||
#include "Macros.h"
|
||||
#include "MemoryMeter.h"
|
||||
#include "MemorySwapMeter.h"
|
||||
#include "Meter.h"
|
||||
#include "ProcessList.h"
|
||||
#include "Settings.h"
|
||||
|
@ -98,6 +99,7 @@ const MeterClass* const Platform_meterTypes[] = {
|
|||
&LoadMeter_class,
|
||||
&MemoryMeter_class,
|
||||
&SwapMeter_class,
|
||||
&MemorySwapMeter_class,
|
||||
&TasksMeter_class,
|
||||
&UptimeMeter_class,
|
||||
&BatteryMeter_class,
|
||||
|
|
|
@ -29,6 +29,7 @@ in the source distribution for its full text.
|
|||
#include "LoadAverageMeter.h"
|
||||
#include "Macros.h"
|
||||
#include "MemoryMeter.h"
|
||||
#include "MemorySwapMeter.h"
|
||||
#include "Meter.h"
|
||||
#include "NetworkIOMeter.h"
|
||||
#include "ProcessList.h"
|
||||
|
@ -73,6 +74,7 @@ const MeterClass* const Platform_meterTypes[] = {
|
|||
&LoadMeter_class,
|
||||
&MemoryMeter_class,
|
||||
&SwapMeter_class,
|
||||
&MemorySwapMeter_class,
|
||||
&TasksMeter_class,
|
||||
&UptimeMeter_class,
|
||||
&BatteryMeter_class,
|
||||
|
|
|
@ -24,6 +24,7 @@ in the source distribution for its full text.
|
|||
#include "Meter.h"
|
||||
#include "CPUMeter.h"
|
||||
#include "MemoryMeter.h"
|
||||
#include "MemorySwapMeter.h"
|
||||
#include "SwapMeter.h"
|
||||
#include "TasksMeter.h"
|
||||
#include "LoadAverageMeter.h"
|
||||
|
@ -97,6 +98,7 @@ const MeterClass* const Platform_meterTypes[] = {
|
|||
&LoadMeter_class,
|
||||
&MemoryMeter_class,
|
||||
&SwapMeter_class,
|
||||
&MemorySwapMeter_class,
|
||||
&TasksMeter_class,
|
||||
&BatteryMeter_class,
|
||||
&HostnameMeter_class,
|
||||
|
|
|
@ -20,6 +20,7 @@ in the source distribution for its full text.
|
|||
#include "LoadAverageMeter.h"
|
||||
#include "Macros.h"
|
||||
#include "MemoryMeter.h"
|
||||
#include "MemorySwapMeter.h"
|
||||
#include "SwapMeter.h"
|
||||
#include "SysArchMeter.h"
|
||||
#include "TasksMeter.h"
|
||||
|
@ -43,6 +44,7 @@ const MeterClass* const Platform_meterTypes[] = {
|
|||
&LoadMeter_class,
|
||||
&MemoryMeter_class,
|
||||
&SwapMeter_class,
|
||||
&MemorySwapMeter_class,
|
||||
&TasksMeter_class,
|
||||
&BatteryMeter_class,
|
||||
&HostnameMeter_class,
|
||||
|
|
Loading…
Reference in New Issue