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
f019f4cd
Commit
f019f4cd
authored
Aug 20, 2015
by
Hisham Muhammad
Browse files
Merge pull request #221 from eworm-de/define-array-size
use a define for graphical meter array size
parents
ea18a500
a2a34e89
Changes
5
Hide whitespace changes
Inline
Side-by-side
CRT.c
View file @
f019f4cd
...
...
@@ -137,6 +137,8 @@ const char *CRT_treeStrAscii[TREE_STR_COUNT] = {
"-"
,
// TREE_STR_SHUT
};
#ifdef HAVE_LIBNCURSESW
const
char
*
CRT_treeStrUtf8
[
TREE_STR_COUNT
]
=
{
"
\xe2\x94\x80
"
,
// TREE_STR_HORZ ─
"
\xe2\x94\x82
"
,
// TREE_STR_VERT │
...
...
@@ -147,14 +149,16 @@ const char *CRT_treeStrUtf8[TREE_STR_COUNT] = {
"
\xe2\x94\x80
"
,
// TREE_STR_SHUT ─
};
bool
CRT_utf8
=
false
;
#endif
const
char
**
CRT_treeStr
=
CRT_treeStrAscii
;
static
bool
CRT_hasColors
;
int
CRT_delay
=
0
;
bool
CRT_utf8
=
false
;
int
*
CRT_colors
;
int
CRT_colorSchemes
[
LAST_COLORSCHEME
][
LAST_COLORELEMENT
]
=
{
...
...
@@ -603,7 +607,11 @@ void CRT_init(int delay, int colorScheme) {
CRT_utf8
=
false
;
#endif
CRT_treeStr
=
CRT_utf8
?
CRT_treeStrUtf8
:
CRT_treeStrAscii
;
CRT_treeStr
=
#ifdef HAVE_LIBNCURSESW
CRT_utf8
?
CRT_treeStrUtf8
:
#endif
CRT_treeStrAscii
;
#if NCURSES_MOUSE_VERSION > 1
mousemask
(
BUTTON1_RELEASED
|
BUTTON4_PRESSED
|
BUTTON5_PRESSED
,
NULL
);
...
...
CRT.h
View file @
f019f4cd
...
...
@@ -118,14 +118,18 @@ void CRT_handleSIGSEGV(int sgn);
extern
const
char
*
CRT_treeStrAscii
[
TREE_STR_COUNT
];
#ifdef HAVE_LIBNCURSESW
extern
const
char
*
CRT_treeStrUtf8
[
TREE_STR_COUNT
];
extern
bool
CRT_utf8
;
#endif
extern
const
char
**
CRT_treeStr
;
extern
int
CRT_delay
;
extern
bool
CRT_utf8
;
int
*
CRT_colors
;
extern
int
CRT_colorSchemes
[
LAST_COLORSCHEME
][
LAST_COLORELEMENT
];
...
...
ListItem.c
View file @
f019f4cd
...
...
@@ -42,7 +42,11 @@ static void ListItem_display(Object* cast, RichString* out) {
snprintf(buffer, len, "%s", this->value);
*/
if
(
this
->
moving
)
{
RichString_write
(
out
,
CRT_colors
[
DEFAULT_COLOR
],
CRT_utf8
?
"↕ "
:
"+ "
);
RichString_write
(
out
,
CRT_colors
[
DEFAULT_COLOR
],
#ifdef HAVE_LIBNCURSESW
CRT_utf8
?
"↕ "
:
#endif
"+ "
);
}
else
{
RichString_prune
(
out
);
}
...
...
Meter.c
View file @
f019f4cd
...
...
@@ -308,23 +308,28 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
/* ---------- GraphMeterMode ---------- */
static
const
char
*
GraphMeterMode_dotsUtf8
[
5
][
5
]
=
{
{
/*00*/
"⠀"
,
/*01*/
"⢀"
,
/*02*/
"⢠"
,
/*03*/
"⢰"
,
/*04*/
"⢸"
},
{
/*10*/
"⡀"
,
/*11*/
"⣀"
,
/*12*/
"⣠"
,
/*13*/
"⣰"
,
/*14*/
"⣸"
},
{
/*20*/
"⡄"
,
/*21*/
"⣄"
,
/*22*/
"⣤"
,
/*23*/
"⣴"
,
/*24*/
"⣼"
},
{
/*30*/
"⡆"
,
/*31*/
"⣆"
,
/*32*/
"⣦"
,
/*33*/
"⣶"
,
/*34*/
"⣾"
},
{
/*40*/
"⡇"
,
/*41*/
"⣇"
,
/*42*/
"⣧"
,
/*43*/
"⣷"
,
/*44*/
"⣿"
},
#ifdef HAVE_LIBNCURSESW
#define PIXPERROW_UTF8 4
static
const
char
*
GraphMeterMode_dotsUtf8
[]
=
{
/*00*/
"⠀"
,
/*01*/
"⢀"
,
/*02*/
"⢠"
,
/*03*/
"⢰"
,
/*04*/
"⢸"
,
/*10*/
"⡀"
,
/*11*/
"⣀"
,
/*12*/
"⣠"
,
/*13*/
"⣰"
,
/*14*/
"⣸"
,
/*20*/
"⡄"
,
/*21*/
"⣄"
,
/*22*/
"⣤"
,
/*23*/
"⣴"
,
/*24*/
"⣼"
,
/*30*/
"⡆"
,
/*31*/
"⣆"
,
/*32*/
"⣦"
,
/*33*/
"⣶"
,
/*34*/
"⣾"
,
/*40*/
"⡇"
,
/*41*/
"⣇"
,
/*42*/
"⣧"
,
/*43*/
"⣷"
,
/*44*/
"⣿"
};
static
const
char
*
GraphMeterMode_dotsAscii
[
5
][
5
]
=
{
{
/*00*/
" "
,
/*01*/
"."
,
/*02*/
"."
,
/*03*/
":"
,
/*04*/
":"
},
{
/*10*/
"."
,
/*11*/
"."
,
/*12*/
"."
,
/*13*/
":"
,
/*14*/
":"
},
{
/*20*/
"."
,
/*21*/
"."
,
/*22*/
"."
,
/*23*/
":"
,
/*24*/
":"
},
{
/*30*/
":"
,
/*31*/
":"
,
/*32*/
":"
,
/*33*/
":"
,
/*34*/
":"
},
{
/*40*/
":"
,
/*41*/
":"
,
/*42*/
":"
,
/*43*/
":"
,
/*44*/
":"
},
#endif
#define PIXPERROW_ASCII 2
static
const
char
*
GraphMeterMode_dotsAscii
[]
=
{
/*00*/
" "
,
/*01*/
"."
,
/*02*/
":"
,
/*10*/
"."
,
/*11*/
"."
,
/*12*/
":"
,
/*20*/
":"
,
/*21*/
":"
,
/*22*/
":"
};
static
const
char
*
(
*
GraphMeterMode_dots
)[
5
];
static
const
char
**
GraphMeterMode_dots
;
static
int
pixperrow
;
static
void
GraphMeterMode_draw
(
Meter
*
this
,
int
x
,
int
y
,
int
w
)
{
...
...
@@ -332,10 +337,15 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
GraphData
*
data
=
(
GraphData
*
)
this
->
drawData
;
const
int
nValues
=
METER_BUFFER_LEN
;
#ifdef HAVE_LIBNCURSESW
if
(
CRT_utf8
)
{
GraphMeterMode_dots
=
GraphMeterMode_dotsUtf8
;
}
else
{
pixperrow
=
PIXPERROW_UTF8
;
}
else
#endif
{
GraphMeterMode_dots
=
GraphMeterMode_dotsAscii
;
pixperrow
=
PIXPERROW_ASCII
;
}
attrset
(
CRT_colors
[
METER_TEXT
]);
...
...
@@ -365,24 +375,18 @@ 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
/
16
);
int
v1
=
data
->
values
[
i
]
/
dot
;
int
v2
=
data
->
values
[
i
+
1
]
/
dot
;
if
(
v1
==
0
)
v1
=
1
;
if
(
v2
==
0
)
v2
=
1
;
int
level
=
12
;
const
double
dot
=
(
1
.
0
/
(
pixperrow
*
4
));
int
v1
=
MIN
(
pixperrow
*
4
,
MAX
(
1
,
data
->
values
[
i
]
/
dot
));
int
v2
=
MIN
(
pixperrow
*
4
,
MAX
(
1
,
data
->
values
[
i
+
1
]
/
dot
));
int
colorIdx
=
GRAPH_1
;
for
(
int
line
=
0
;
line
<
4
;
line
++
)
{
int
line1
=
MIN
(
4
,
MAX
(
0
,
v1
-
level
));
int
line2
=
MIN
(
4
,
MAX
(
0
,
v2
-
level
));
int
line1
=
MIN
(
pixperrow
,
MAX
(
0
,
v1
-
(
pixperrow
*
(
3
-
line
))));
int
line2
=
MIN
(
pixperrow
,
MAX
(
0
,
v2
-
(
pixperrow
*
(
3
-
line
))));
attrset
(
CRT_colors
[
colorIdx
]);
mvaddstr
(
y
+
line
,
x
+
k
,
GraphMeterMode_dots
[
line1
][
line2
]);
mvaddstr
(
y
+
line
,
x
+
k
,
GraphMeterMode_dots
[
line1
*
(
pixperrow
+
1
)
+
line2
]);
colorIdx
=
GRAPH_2
;
level
-=
4
;
}
}
attrset
(
CRT_colors
[
RESET_COLOR
]);
...
...
@@ -390,33 +394,38 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
/* ---------- LEDMeterMode ---------- */
static
const
char
*
LEDMeterMode_digitsAscii
[
3
][
10
]
=
{
{
" __ "
,
" "
,
" __ "
,
" __ "
,
" "
,
" __ "
,
" __ "
,
" __ "
,
" __ "
,
" __ "
}
,
{
"| |"
,
" |"
,
" __|"
,
" __|"
,
"|__|"
,
"|__ "
,
"|__ "
,
" |"
,
"|__|"
,
"|__|"
}
,
{
"|__|"
,
" |"
,
"|__ "
,
" __|"
,
" |"
,
" __|"
,
"|__|"
,
" |"
,
"|__|"
,
" __|"
},
static
const
char
*
LEDMeterMode_digitsAscii
[]
=
{
" __ "
,
" "
,
" __ "
,
" __ "
,
" "
,
" __ "
,
" __ "
,
" __ "
,
" __ "
,
" __ "
,
"| |"
,
" |"
,
" __|"
,
" __|"
,
"|__|"
,
"|__ "
,
"|__ "
,
" |"
,
"|__|"
,
"|__|"
,
"|__|"
,
" |"
,
"|__ "
,
" __|"
,
" |"
,
" __|"
,
"|__|"
,
" |"
,
"|__|"
,
" __|"
};
static
const
char
*
LEDMeterMode_digitsUtf8
[
3
][
10
]
=
{
{
"┌──┐"
,
" ┐ "
,
"╶──┐"
,
"╶──┐"
,
"╷ ╷"
,
"┌──╴"
,
"┌──╴"
,
"╶──┐"
,
"┌──┐"
,
"┌──┐"
},
{
"│ │"
,
" │ "
,
"┌──┘"
,
" ──┤"
,
"└──┤"
,
"└──┐"
,
"├──┐"
,
" │"
,
"├──┤"
,
"└──┤"
},
{
"└──┘"
,
" ╵ "
,
"└──╴"
,
"╶──┘"
,
" ╵"
,
"╶──┘"
,
"└──┘"
,
" ╵"
,
"└──┘"
,
" ──┘"
},
#ifdef HAVE_LIBNCURSESW
static
const
char
*
LEDMeterMode_digitsUtf8
[]
=
{
"┌──┐"
,
" ┐ "
,
"╶──┐"
,
"╶──┐"
,
"╷ ╷"
,
"┌──╴"
,
"┌──╴"
,
"╶──┐"
,
"┌──┐"
,
"┌──┐"
,
"│ │"
,
" │ "
,
"┌──┘"
,
" ──┤"
,
"└──┤"
,
"└──┐"
,
"├──┐"
,
" │"
,
"├──┤"
,
"└──┤"
,
"└──┘"
,
" ╵ "
,
"└──╴"
,
"╶──┘"
,
" ╵"
,
"╶──┘"
,
"└──┘"
,
" ╵"
,
"└──┘"
,
" ──┘"
};
static
const
char
*
(
*
LEDMeterMode_digits
)[
10
];
#endif
static
const
char
**
LEDMeterMode_digits
;
static
void
LEDMeterMode_drawDigit
(
int
x
,
int
y
,
int
n
)
{
for
(
int
i
=
0
;
i
<
3
;
i
++
)
mvaddstr
(
y
+
i
,
x
,
LEDMeterMode_digits
[
i
][
n
]);
mvaddstr
(
y
+
i
,
x
,
LEDMeterMode_digits
[
i
*
10
+
n
]);
}
static
void
LEDMeterMode_draw
(
Meter
*
this
,
int
x
,
int
y
,
int
w
)
{
(
void
)
w
;
if
(
CRT_utf8
)
{
#ifdef HAVE_LIBNCURSESW
if
(
CRT_utf8
)
LEDMeterMode_digits
=
LEDMeterMode_digitsUtf8
;
}
else
{
else
#endif
LEDMeterMode_digits
=
LEDMeterMode_digitsAscii
;
}
char
buffer
[
METER_BUFFER_LEN
];
Meter_setValues
(
this
,
buffer
,
METER_BUFFER_LEN
-
1
);
...
...
@@ -424,7 +433,11 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
RichString_begin
(
out
);
Meter_displayBuffer
(
this
,
buffer
,
&
out
);
int
yText
=
CRT_utf8
?
y
+
1
:
y
+
2
;
int
yText
=
#ifdef HAVE_LIBNCURSESW
CRT_utf8
?
y
+
1
:
#endif
y
+
2
;
attrset
(
CRT_colors
[
LED_COLOR
]);
mvaddstr
(
yText
,
x
,
this
->
caption
);
int
xx
=
x
+
strlen
(
this
->
caption
);
...
...
Meter.h
View file @
f019f4cd
...
...
@@ -119,8 +119,19 @@ ListItem* Meter_toListItem(Meter* this, bool moving);
/* ---------- GraphMeterMode ---------- */
#ifdef HAVE_LIBNCURSESW
#define PIXPERROW_UTF8 4
#endif
#define PIXPERROW_ASCII 2
/* ---------- LEDMeterMode ---------- */
#ifdef HAVE_LIBNCURSESW
#endif
extern
MeterMode
*
Meter_modes
[];
/* Blank meter */
...
...
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