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
dcfcae1e
Commit
dcfcae1e
authored
Jan 21, 2016
by
Hisham Muhammad
Browse files
Merge pull request #351 from Explorer09/graph-height
GRAPH_HEIGHT macro and 'dot' variable
parents
09cf369f
040613db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Meter.c
View file @
dcfcae1e
...
...
@@ -25,6 +25,8 @@ in the source distribution for its full text.
#define GRAPH_DELAY (DEFAULT_DELAY/2)
#define GRAPH_HEIGHT 4
/* Unit: rows (lines) */
/*{
#include "ListItem.h"
...
...
@@ -406,14 +408,14 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
}
for
(
int
i
=
nValues
-
(
w
*
2
)
+
2
,
k
=
0
;
i
<
nValues
;
i
+=
2
,
k
++
)
{
const
double
dot
=
(
1
.
0
/
(
GraphMeterMode_pixPerRow
*
4
))
;
int
v1
=
CLAMP
(
data
->
values
[
i
]
/
dot
,
1
,
GraphMeterMode_pixPerRow
*
4
);
int
v2
=
CLAMP
(
data
->
values
[
i
+
1
]
/
dot
,
1
,
GraphMeterMode_pixPerRow
*
4
);
int
pix
=
GraphMeterMode_pixPerRow
*
GRAPH_HEIGHT
;
int
v1
=
CLAMP
(
data
->
values
[
i
]
*
pix
,
1
,
pix
);
int
v2
=
CLAMP
(
data
->
values
[
i
+
1
]
*
pix
,
1
,
pix
);
int
colorIdx
=
GRAPH_1
;
for
(
int
line
=
0
;
line
<
4
;
line
++
)
{
int
line1
=
CLAMP
(
v1
-
(
GraphMeterMode_pixPerRow
*
(
3
-
line
)),
0
,
GraphMeterMode_pixPerRow
);
int
line2
=
CLAMP
(
v2
-
(
GraphMeterMode_pixPerRow
*
(
3
-
line
)),
0
,
GraphMeterMode_pixPerRow
);
for
(
int
line
=
0
;
line
<
GRAPH_HEIGHT
;
line
++
)
{
int
line1
=
CLAMP
(
v1
-
(
GraphMeterMode_pixPerRow
*
(
GRAPH_HEIGHT
-
1
-
line
)),
0
,
GraphMeterMode_pixPerRow
);
int
line2
=
CLAMP
(
v2
-
(
GraphMeterMode_pixPerRow
*
(
GRAPH_HEIGHT
-
1
-
line
)),
0
,
GraphMeterMode_pixPerRow
);
attrset
(
CRT_colors
[
colorIdx
]);
mvaddstr
(
y
+
line
,
x
+
k
,
GraphMeterMode_dots
[
line1
*
(
GraphMeterMode_pixPerRow
+
1
)
+
line2
]);
...
...
@@ -501,7 +503,7 @@ static MeterMode TextMeterMode = {
static
MeterMode
GraphMeterMode
=
{
.
uiName
=
"Graph"
,
.
h
=
4
,
.
h
=
GRAPH_HEIGHT
,
.
draw
=
GraphMeterMode_draw
,
};
...
...
Meter.h
View file @
dcfcae1e
...
...
@@ -13,6 +13,8 @@ in the source distribution for its full text.
#define GRAPH_DELAY (DEFAULT_DELAY/2)
#define GRAPH_HEIGHT 4
/* Unit: rows (lines) */
#include "ListItem.h"
#include <sys/time.h>
...
...
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