forked from hishamhm/htop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Meter.h
164 lines (129 loc) · 4.27 KB
/
Meter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Meter
#define HEADER_Meter
/*
htop - Meter.h
(C) 2004-2011 Hisham H. Muhammad
Copyright 2015-2024 Rivoreo
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
#include "ProcessList.h"
#include "ListItem.h"
#include <sys/time.h>
#define METER_BUFFER_LEN 256
typedef struct Meter_ Meter;
typedef void(*Meter_Init)(Meter*);
typedef void(*Meter_Done)(Meter*);
typedef void(*Meter_UpdateMode)(Meter*, int);
typedef void(*Meter_UpdateValues)(Meter*, char*, int);
typedef void(*Meter_Draw)(Meter*, int, int, int);
typedef double (*MeterGetDoubleFunction)(Meter *);
typedef int (*MeterGetAttributeFunction)(Meter *, int);
typedef struct MeterClass_ {
ObjectClass super;
Meter_Init init;
Meter_Done done;
Meter_UpdateMode updateMode;
Meter_Draw draw;
Meter_UpdateValues updateValues;
MeterGetDoubleFunction getMaximum;
MeterGetAttributeFunction getAttribute;
int defaultMode;
double total;
const int* attributes;
// For internal use only
const char* name;
// For display in setup screen
const char* uiName;
// For Text mode and LED mode display
const char* caption;
// For Bar mode and Graph mode display, default to caption if NULL
const char *short_caption;
const char* description;
const char maxItems;
char curItems;
bool values_are_overlapped;
} MeterClass;
#define As_Meter(this_) ((MeterClass*)((this_)->super.klass))
#define Meter_initFn(this_) As_Meter(this_)->init
#define Meter_init(this_) As_Meter(this_)->init((Meter*)(this_))
#define Meter_done(this_) As_Meter(this_)->done((Meter*)(this_))
#define Meter_updateModeFn(this_) As_Meter(this_)->updateMode
#define Meter_updateMode(this_, m_) As_Meter(this_)->updateMode((Meter*)(this_), (m_))
#define Meter_drawFn(this_) As_Meter(this_)->draw
#define Meter_doneFn(this_) As_Meter(this_)->done
#define Meter_updateValues(this_, buf_, sz_) \
As_Meter(this_)->updateValues((Meter*)(this_), (buf_), (sz_))
#define Meter_defaultMode(this_) As_Meter(this_)->defaultMode
#define Meter_getItems(this_) As_Meter(this_)->curItems
#define Meter_setItems(this_, n_) As_Meter(this_)->curItems = (n_)
#define Meter_attributes(this_) As_Meter(this_)->attributes
#define Meter_name(this_) As_Meter(this_)->name
#define Meter_uiName(this_) As_Meter(this_)->uiName
#define Meter_getMaximum(this_) As_Meter(this_)->getMaximum(this_)
#define Meter_getAttribute(this_,n_) As_Meter(this_)->getAttribute((this_),(n_))
struct Meter_ {
Object super;
Meter_Draw draw;
char* caption;
char *short_caption;
int mode;
int param;
void* drawData;
int h;
ProcessList *pl;
double* values;
double total;
};
typedef struct MeterMode_ {
Meter_Draw draw;
const char* uiName;
int h;
} MeterMode;
typedef enum {
CUSTOM_METERMODE = 0,
BAR_METERMODE,
TEXT_METERMODE,
GRAPH_METERMODE,
LED_METERMODE,
LAST_METERMODE
} MeterModeId;
typedef struct GraphData_ {
struct timeval time;
double values[METER_BUFFER_LEN];
} GraphData;
#define GRAPH_HEIGHT 4 /* Unit: rows (lines) */
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#ifndef CLAMP
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
#ifndef HAVE_LROUND
#endif
extern MeterClass Meter_class;
Meter* Meter_new(ProcessList *pl, int param, MeterClass* type);
int Meter_humanUnit(char* buffer, unsigned long int value, int size);
void Meter_delete(Object* cast);
void Meter_setCaption(Meter* this, const char* caption);
void Meter_setShortCaption(Meter *this, const char *caption);
void Meter_setMode(Meter* this, int modeIndex);
ListItem* Meter_toListItem(Meter* this, bool moving);
/* ---------- TextMeterMode ---------- */
/* ---------- BarMeterMode ---------- */
/* ---------- GraphMeterMode ---------- */
#ifdef HAVE_LIBNCURSESW
#define PIXPERROW_UTF8 4
#endif
#define PIXPERROW_ASCII 2
/* ---------- LEDMeterMode ---------- */
#ifdef HAVE_LIBNCURSESW
#endif
extern MeterMode* Meter_modes[];
/* Blank meter */
extern MeterClass BlankMeter_class;
#endif