Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
19f0f4db
Commit
19f0f4db
authored
May 04, 2016
by
Hisham Muhammad
Browse files
Merge pull request #488 from Explorer09/func-naming
Rename Meter.setValues() functions to updateValues()
parents
2ea4bee6
9dea20e0
Changes
11
Hide whitespace changes
Inline
Side-by-side
BatteryMeter.c
View file @
19f0f4db
...
...
@@ -32,7 +32,7 @@ int BatteryMeter_attributes[] = {
BATTERY
};
static
void
BatteryMeter_
set
Values
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
static
void
BatteryMeter_
update
Values
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
ACPresence
isOnAC
;
double
percent
;
...
...
@@ -73,7 +73,7 @@ MeterClass BatteryMeter_class = {
.
extends
=
Class
(
Meter
),
.
delete
=
Meter_delete
},
.
set
Values
=
BatteryMeter_
set
Values
,
.
update
Values
=
BatteryMeter_
update
Values
,
.
defaultMode
=
TEXT_METERMODE
,
.
maxItems
=
1
,
.
total
=
100
.
0
,
...
...
CPUMeter.c
View file @
19f0f4db
...
...
@@ -55,7 +55,7 @@ static void CPUMeter_init(Meter* this) {
Meter_setCaption
(
this
,
"Avg"
);
}
static
void
CPUMeter_
set
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
static
void
CPUMeter_
update
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
int
cpu
=
this
->
param
;
if
(
cpu
>
this
->
pl
->
cpuCount
)
{
snprintf
(
buffer
,
size
,
"absent"
);
...
...
@@ -215,7 +215,7 @@ MeterClass CPUMeter_class = {
.
delete
=
Meter_delete
,
.
display
=
CPUMeter_display
},
.
set
Values
=
CPUMeter_
set
Values
,
.
update
Values
=
CPUMeter_
update
Values
,
.
defaultMode
=
BAR_METERMODE
,
.
maxItems
=
CPU_METER_ITEMCOUNT
,
.
total
=
100
.
0
,
...
...
ClockMeter.c
View file @
19f0f4db
...
...
@@ -19,7 +19,7 @@ int ClockMeter_attributes[] = {
CLOCK
};
static
void
ClockMeter_
set
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
static
void
ClockMeter_
update
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
time_t
t
=
time
(
NULL
);
struct
tm
result
;
struct
tm
*
lt
=
localtime_r
(
&
t
,
&
result
);
...
...
@@ -32,7 +32,7 @@ MeterClass ClockMeter_class = {
.
extends
=
Class
(
Meter
),
.
delete
=
Meter_delete
},
.
set
Values
=
ClockMeter_
set
Values
,
.
update
Values
=
ClockMeter_
update
Values
,
.
defaultMode
=
TEXT_METERMODE
,
.
maxItems
=
1
,
.
total
=
1440
,
/* 24*60 */
...
...
HostnameMeter.c
View file @
19f0f4db
...
...
@@ -19,7 +19,7 @@ int HostnameMeter_attributes[] = {
HOSTNAME
};
static
void
HostnameMeter_
set
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
static
void
HostnameMeter_
update
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
(
void
)
this
;
gethostname
(
buffer
,
size
-
1
);
}
...
...
@@ -29,7 +29,7 @@ MeterClass HostnameMeter_class = {
.
extends
=
Class
(
Meter
),
.
delete
=
Meter_delete
},
.
set
Values
=
HostnameMeter_
set
Values
,
.
update
Values
=
HostnameMeter_
update
Values
,
.
defaultMode
=
TEXT_METERMODE
,
.
maxItems
=
0
,
.
total
=
100
.
0
,
...
...
LoadAverageMeter.c
View file @
19f0f4db
...
...
@@ -20,7 +20,7 @@ int LoadAverageMeter_attributes[] = {
int
LoadMeter_attributes
[]
=
{
LOAD
};
static
void
LoadAverageMeter_
set
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
static
void
LoadAverageMeter_
update
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
Platform_getLoadAverage
(
&
this
->
values
[
0
],
&
this
->
values
[
1
],
&
this
->
values
[
2
]);
snprintf
(
buffer
,
size
,
"%.2f/%.2f/%.2f"
,
this
->
values
[
0
],
this
->
values
[
1
],
this
->
values
[
2
]);
}
...
...
@@ -36,7 +36,7 @@ static void LoadAverageMeter_display(Object* cast, RichString* out) {
RichString_append
(
out
,
CRT_colors
[
LOAD_AVERAGE_FIFTEEN
],
buffer
);
}
static
void
LoadMeter_
set
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
static
void
LoadMeter_
update
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
double
five
,
fifteen
;
Platform_getLoadAverage
(
&
this
->
values
[
0
],
&
five
,
&
fifteen
);
if
(
this
->
values
[
0
]
>
this
->
total
)
{
...
...
@@ -58,7 +58,7 @@ MeterClass LoadAverageMeter_class = {
.
delete
=
Meter_delete
,
.
display
=
LoadAverageMeter_display
,
},
.
set
Values
=
LoadAverageMeter_
set
Values
,
.
update
Values
=
LoadAverageMeter_
update
Values
,
.
defaultMode
=
TEXT_METERMODE
,
.
maxItems
=
3
,
.
total
=
100
.
0
,
...
...
@@ -75,7 +75,7 @@ MeterClass LoadMeter_class = {
.
delete
=
Meter_delete
,
.
display
=
LoadMeter_display
,
},
.
set
Values
=
LoadMeter_
set
Values
,
.
update
Values
=
LoadMeter_
update
Values
,
.
defaultMode
=
TEXT_METERMODE
,
.
maxItems
=
1
,
.
total
=
100
.
0
,
...
...
MemoryMeter.c
View file @
19f0f4db
...
...
@@ -24,7 +24,7 @@ int MemoryMeter_attributes[] = {
MEMORY_USED
,
MEMORY_BUFFERS
,
MEMORY_CACHE
};
static
void
MemoryMeter_
set
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
static
void
MemoryMeter_
update
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
int
written
;
Platform_setMemoryValues
(
this
);
...
...
@@ -60,7 +60,7 @@ MeterClass MemoryMeter_class = {
.
delete
=
Meter_delete
,
.
display
=
MemoryMeter_display
,
},
.
set
Values
=
MemoryMeter_
set
Values
,
.
update
Values
=
MemoryMeter_
update
Values
,
.
defaultMode
=
BAR_METERMODE
,
.
maxItems
=
3
,
.
total
=
100
.
0
,
...
...
Meter.c
View file @
19f0f4db
...
...
@@ -37,7 +37,7 @@ typedef struct Meter_ Meter;
typedef void(*Meter_Init)(Meter*);
typedef void(*Meter_Done)(Meter*);
typedef void(*Meter_UpdateMode)(Meter*, int);
typedef void(*Meter_
Set
Values)(Meter*, char*, int);
typedef void(*Meter_
Update
Values)(Meter*, char*, int);
typedef void(*Meter_Draw)(Meter*, int, int, int);
typedef struct MeterClass_ {
...
...
@@ -46,7 +46,7 @@ typedef struct MeterClass_ {
const Meter_Done done;
const Meter_UpdateMode updateMode;
const Meter_Draw draw;
const Meter_
Set
Values
set
Values;
const Meter_
Update
Values
update
Values;
const int defaultMode;
const double total;
const int* attributes;
...
...
@@ -66,7 +66,8 @@ typedef struct MeterClass_ {
#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_setValues(this_, c_, i_) As_Meter(this_)->setValues((Meter*)(this_), c_, i_)
#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_)
...
...
@@ -245,7 +246,7 @@ ListItem* Meter_toListItem(Meter* this, bool moving) {
static
void
TextMeterMode_draw
(
Meter
*
this
,
int
x
,
int
y
,
int
w
)
{
char
buffer
[
METER_BUFFER_LEN
];
Meter_
set
Values
(
this
,
buffer
,
METER_BUFFER_LEN
-
1
);
Meter_
update
Values
(
this
,
buffer
,
METER_BUFFER_LEN
-
1
);
(
void
)
w
;
attrset
(
CRT_colors
[
METER_TEXT
]);
...
...
@@ -265,7 +266,7 @@ static char BarMeterMode_characters[] = "|#*@$%&.";
static
void
BarMeterMode_draw
(
Meter
*
this
,
int
x
,
int
y
,
int
w
)
{
char
buffer
[
METER_BUFFER_LEN
];
Meter_
set
Values
(
this
,
buffer
,
METER_BUFFER_LEN
-
1
);
Meter_
update
Values
(
this
,
buffer
,
METER_BUFFER_LEN
-
1
);
w
-=
2
;
attrset
(
CRT_colors
[
METER_TEXT
]);
...
...
@@ -390,7 +391,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
data
->
values
[
i
]
=
data
->
values
[
i
+
1
];
char
buffer
[
nValues
];
Meter_
set
Values
(
this
,
buffer
,
nValues
-
1
);
Meter_
update
Values
(
this
,
buffer
,
nValues
-
1
);
double
value
=
0
.
0
;
int
items
=
Meter_getItems
(
this
);
...
...
@@ -459,7 +460,7 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
LEDMeterMode_digits
=
LEDMeterMode_digitsAscii
;
char
buffer
[
METER_BUFFER_LEN
];
Meter_
set
Values
(
this
,
buffer
,
METER_BUFFER_LEN
-
1
);
Meter_
update
Values
(
this
,
buffer
,
METER_BUFFER_LEN
-
1
);
RichString_begin
(
out
);
Meter_displayBuffer
(
this
,
buffer
,
&
out
);
...
...
@@ -522,7 +523,7 @@ MeterMode* Meter_modes[] = {
/* Blank meter */
static
void
BlankMeter_
set
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
static
void
BlankMeter_
update
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
(
void
)
this
;
(
void
)
buffer
;
(
void
)
size
;
}
...
...
@@ -541,7 +542,7 @@ MeterClass BlankMeter_class = {
.
delete
=
Meter_delete
,
.
display
=
BlankMeter_display
,
},
.
set
Values
=
BlankMeter_
set
Values
,
.
update
Values
=
BlankMeter_
update
Values
,
.
defaultMode
=
TEXT_METERMODE
,
.
maxItems
=
0
,
.
total
=
100
.
0
,
...
...
Meter.h
View file @
19f0f4db
...
...
@@ -24,7 +24,7 @@ typedef struct Meter_ Meter;
typedef
void
(
*
Meter_Init
)(
Meter
*
);
typedef
void
(
*
Meter_Done
)(
Meter
*
);
typedef
void
(
*
Meter_UpdateMode
)(
Meter
*
,
int
);
typedef
void
(
*
Meter_
Set
Values
)(
Meter
*
,
char
*
,
int
);
typedef
void
(
*
Meter_
Update
Values
)(
Meter
*
,
char
*
,
int
);
typedef
void
(
*
Meter_Draw
)(
Meter
*
,
int
,
int
,
int
);
typedef
struct
MeterClass_
{
...
...
@@ -33,7 +33,7 @@ typedef struct MeterClass_ {
const
Meter_Done
done
;
const
Meter_UpdateMode
updateMode
;
const
Meter_Draw
draw
;
const
Meter_
Set
Values
set
Values
;
const
Meter_
Update
Values
update
Values
;
const
int
defaultMode
;
const
double
total
;
const
int
*
attributes
;
...
...
@@ -53,7 +53,8 @@ typedef struct MeterClass_ {
#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_setValues(this_, c_, i_) As_Meter(this_)->setValues((Meter*)(this_), c_, i_)
#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_)
...
...
SwapMeter.c
View file @
19f0f4db
...
...
@@ -24,7 +24,7 @@ int SwapMeter_attributes[] = {
SWAP
};
static
void
SwapMeter_
set
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
static
void
SwapMeter_
update
Values
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
int
written
;
Platform_setSwapValues
(
this
);
...
...
@@ -54,7 +54,7 @@ MeterClass SwapMeter_class = {
.
delete
=
Meter_delete
,
.
display
=
SwapMeter_display
,
},
.
set
Values
=
SwapMeter_
set
Values
,
.
update
Values
=
SwapMeter_
update
Values
,
.
defaultMode
=
BAR_METERMODE
,
.
maxItems
=
1
,
.
total
=
100
.
0
,
...
...
TasksMeter.c
View file @
19f0f4db
...
...
@@ -18,7 +18,7 @@ int TasksMeter_attributes[] = {
CPU_KERNEL
,
PROCESS_THREAD
,
PROCESS
,
TASKS_RUNNING
};
static
void
TasksMeter_
set
Values
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
static
void
TasksMeter_
update
Values
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
ProcessList
*
pl
=
this
->
pl
;
this
->
values
[
0
]
=
pl
->
kernelThreads
;
this
->
values
[
1
]
=
pl
->
userlandThreads
;
...
...
@@ -72,7 +72,7 @@ MeterClass TasksMeter_class = {
.
delete
=
Meter_delete
,
.
display
=
TasksMeter_display
,
},
.
set
Values
=
TasksMeter_
set
Values
,
.
update
Values
=
TasksMeter_
update
Values
,
.
defaultMode
=
TEXT_METERMODE
,
.
maxItems
=
4
,
.
total
=
100
.
0
,
...
...
UptimeMeter.c
View file @
19f0f4db
...
...
@@ -17,7 +17,7 @@ int UptimeMeter_attributes[] = {
UPTIME
};
static
void
UptimeMeter_
set
Values
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
static
void
UptimeMeter_
update
Values
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
int
totalseconds
=
Platform_getUptime
();
if
(
totalseconds
==
-
1
)
{
snprintf
(
buffer
,
len
,
"(unknown)"
);
...
...
@@ -49,7 +49,7 @@ MeterClass UptimeMeter_class = {
.
extends
=
Class
(
Meter
),
.
delete
=
Meter_delete
},
.
set
Values
=
UptimeMeter_
set
Values
,
.
update
Values
=
UptimeMeter_
update
Values
,
.
defaultMode
=
TEXT_METERMODE
,
.
maxItems
=
1
,
.
total
=
100
.
0
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment