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
57a17420
Commit
57a17420
authored
May 09, 2006
by
Hisham Muhammad
Browse files
Final fixes to make "All CPUs" the default CPU display mode.
parent
c3d757f6
Changes
5
Hide whitespace changes
Inline
Side-by-side
CPUMeter.c
View file @
57a17420
...
...
@@ -46,6 +46,7 @@ MeterType AllCPUsMeter = {
.
caption
=
"CPU"
,
.
draw
=
AllCPUsMeter_draw
,
.
init
=
AllCPUsMeter_init
,
.
setMode
=
AllCPUsMeter_setMode
,
.
done
=
AllCPUsMeter_done
};
...
...
@@ -110,12 +111,19 @@ void AllCPUsMeter_done(Meter* this) {
Meter_delete
((
Object
*
)
meters
[
i
]);
}
void
AllCPUsMeter_setMode
(
Meter
*
this
,
int
mode
)
{
this
->
mode
=
mode
;
int
processors
=
this
->
pl
->
processorCount
;
int
h
=
Meter_modes
[
this
->
mode
]
->
h
;
this
->
h
=
h
*
processors
;
}
void
AllCPUsMeter_draw
(
Meter
*
this
,
int
x
,
int
y
,
int
w
)
{
int
processors
=
this
->
pl
->
processorCount
;
Meter
**
meters
=
(
Meter
**
)
this
->
drawBuffer
;
this
->
h
=
Meter_modes
[
this
->
mode
]
->
h
*
processors
;
for
(
int
i
=
0
;
i
<
processors
;
i
++
)
{
Meter_setMode
(
meters
[
i
],
this
->
mode
);
meters
[
i
]
->
draw
(
meters
[
i
],
x
,
y
+
i
,
w
);
meters
[
i
]
->
draw
(
meters
[
i
],
x
,
y
,
w
);
y
+=
meters
[
i
]
->
h
;
}
}
CPUMeter.h
View file @
57a17420
...
...
@@ -41,6 +41,8 @@ void AllCPUsMeter_init(Meter* this);
void
AllCPUsMeter_done
(
Meter
*
this
);
void
AllCPUsMeter_setMode
(
Meter
*
this
,
int
mode
);
void
AllCPUsMeter_draw
(
Meter
*
this
,
int
x
,
int
y
,
int
w
);
#endif
Header.c
View file @
57a17420
...
...
@@ -122,8 +122,7 @@ MeterModeId Header_readMeterMode(Header* this, int i, HeaderSide side) {
}
void
Header_defaultMeters
(
Header
*
this
)
{
for
(
int
i
=
1
;
i
<=
this
->
pl
->
processorCount
;
i
++
)
TypedVector_add
(
this
->
leftMeters
,
Meter_new
(
this
->
pl
,
i
,
&
CPUMeter
));
TypedVector_add
(
this
->
leftMeters
,
Meter_new
(
this
->
pl
,
0
,
&
AllCPUsMeter
));
TypedVector_add
(
this
->
leftMeters
,
Meter_new
(
this
->
pl
,
0
,
&
MemoryMeter
));
TypedVector_add
(
this
->
leftMeters
,
Meter_new
(
this
->
pl
,
0
,
&
SwapMeter
));
TypedVector_add
(
this
->
rightMeters
,
Meter_new
(
this
->
pl
,
0
,
&
TasksMeter
));
...
...
Meter.c
View file @
57a17420
...
...
@@ -36,6 +36,7 @@ typedef struct MeterMode_ MeterMode;
typedef void(*MeterType_Init)(Meter*);
typedef void(*MeterType_Done)(Meter*);
typedef void(*MeterType_SetMode)(Meter*, int);
typedef void(*Meter_SetValues)(Meter*, char*, int);
typedef void(*Meter_Draw)(Meter*, int, int, int);
...
...
@@ -57,6 +58,7 @@ struct MeterType_ {
char* caption;
MeterType_Init init;
MeterType_Done done;
MeterType_SetMode setMode;
Meter_Draw draw;
};
...
...
@@ -226,6 +228,8 @@ void Meter_setMode(Meter* this, int modeIndex) {
assert
(
modeIndex
<
LAST_METERMODE
);
if
(
this
->
type
->
mode
==
0
)
{
this
->
draw
=
this
->
type
->
draw
;
if
(
this
->
type
->
setMode
)
this
->
type
->
setMode
(
this
,
modeIndex
);
}
else
{
assert
(
modeIndex
>=
1
);
if
(
this
->
drawBuffer
)
...
...
@@ -382,7 +386,6 @@ void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
value
+=
this
->
values
[
i
];
value
/=
this
->
total
;
drawBuffer
[
METER_BUFFER_LEN
-
1
]
=
value
;
mvprintw
(
0
,
0
,
"%f "
,
value
);
for
(
int
i
=
METER_BUFFER_LEN
-
w
,
k
=
0
;
i
<
METER_BUFFER_LEN
;
i
++
,
k
++
)
{
double
value
=
drawBuffer
[
i
];
DrawDot
(
CRT_colors
[
DEFAULT_COLOR
],
y
,
' '
);
...
...
Meter.h
View file @
57a17420
...
...
@@ -38,6 +38,7 @@ typedef struct MeterMode_ MeterMode;
typedef
void
(
*
MeterType_Init
)(
Meter
*
);
typedef
void
(
*
MeterType_Done
)(
Meter
*
);
typedef
void
(
*
MeterType_SetMode
)(
Meter
*
,
int
);
typedef
void
(
*
Meter_SetValues
)(
Meter
*
,
char
*
,
int
);
typedef
void
(
*
Meter_Draw
)(
Meter
*
,
int
,
int
,
int
);
...
...
@@ -59,6 +60,7 @@ struct MeterType_ {
char
*
caption
;
MeterType_Init
init
;
MeterType_Done
done
;
MeterType_SetMode
setMode
;
Meter_Draw
draw
;
};
...
...
@@ -99,7 +101,7 @@ typedef enum {
LAST_METERMODE
}
MeterModeId
;
extern
MeterType
*
Meter_types
[
9
];
extern
MeterType
*
Meter_types
[];
extern
MeterMode
*
Meter_modes
[];
...
...
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