Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CPUnetLOG
CPUnetLOG
Commits
2f96d5a9
Commit
2f96d5a9
authored
Jul 30, 2014
by
Mario Hock
Browse files
prototypical "inline"-coloring
parent
e5b9ef6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
curses_display.py
View file @
2f96d5a9
...
...
@@ -127,17 +127,30 @@ def display(measurement):
sum_receiving
+=
_recv
stdscr
.
addstr
(
y
,
1
,
'{0}'
.
format
(
nic
),
curses
.
color_pair
(
1
))
stdscr
.
addstr
(
y
,
20
,
'Sent:'
,
curses
.
color_pair
(
2
))
stdscr
.
addstr
(
y
,
26
,
'{0} {1}/s ({2:.2%})'
.
format
(
sending
,
unit
,
send_ratio
),
curses
.
color_pair
(
3
))
stdscr
.
addstr
(
y
,
50
,
'Received:'
,
curses
.
color_pair
(
2
))
stdscr
.
addstr
(
y
,
60
,
'{0} {1}/s ({2:.2%})'
.
format
(
receiving
,
unit
,
receive_ratio
),
curses
.
color_pair
(
3
))
stdscr
.
addstr
(
y
,
20
,
'Sent: |'
,
curses
.
color_pair
(
2
))
stdscr
.
addstr
(
y
,
50
,
'Received: |'
,
curses
.
color_pair
(
2
))
stdscr
.
addstr
(
y
,
47
,
"|"
,
curses
.
color_pair
(
2
))
stdscr
.
addstr
(
y
,
81
,
"|"
,
curses
.
color_pair
(
2
))
## XXX prototypical "inline"-coloring
_snd_str
=
'{0} {1}/s'
.
format
(
sending
,
unit
,
send_ratio
)
_snd_str
+=
" "
*
(
20
-
len
(
_snd_str
))
_load_len
=
int
(
send_ratio
*
20
)
stdscr
.
addstr
(
y
,
27
,
_snd_str
[
0
:
_load_len
],
curses
.
color_pair
(
3
)
|
curses
.
A_REVERSE
)
stdscr
.
addstr
(
y
,
27
+
_load_len
,
_snd_str
[
_load_len
:],
curses
.
color_pair
(
3
))
_recv_str
=
'{0} {1}/s'
.
format
(
receiving
,
unit
,
send_ratio
)
_recv_str
+=
" "
*
(
20
-
len
(
_recv_str
))
_load_len
=
int
(
receive_ratio
*
20
)
stdscr
.
addstr
(
y
,
61
,
_recv_str
[
0
:
_load_len
],
curses
.
color_pair
(
3
)
|
curses
.
A_REVERSE
)
stdscr
.
addstr
(
y
,
61
+
_load_len
,
_recv_str
[
_load_len
:],
curses
.
color_pair
(
3
))
## XXX TESTING
y
+=
1
stdscr
.
addstr
(
y
,
25
,
"|"
+
" "
*
20
+
"|"
,
curses
.
color_pair
(
2
))
stdscr
.
addstr
(
y
,
26
,
" "
*
int
(
send_ratio
*
20
),
curses
.
color_pair
(
3
)
|
curses
.
A_REVERSE
)
stdscr
.
addstr
(
y
,
59
,
"|"
+
" "
*
20
+
"|"
,
curses
.
color_pair
(
2
))
stdscr
.
addstr
(
y
,
60
,
" "
*
int
(
receive_ratio
*
20
),
curses
.
color_pair
(
3
)
|
curses
.
A_REVERSE
)
#
y += 1
#
stdscr.addstr(y, 25, "|" + " "*20 + "|", curses.color_pair(2))
#
stdscr.addstr(y, 26, " " * int(send_ratio * 20), curses.color_pair(3)|curses.A_REVERSE)
#
stdscr.addstr(y, 59, "|" + " "*20 + "|", curses.color_pair(2))
#
stdscr.addstr(y, 60, " " * int(receive_ratio * 20), curses.color_pair(3)|curses.A_REVERSE)
y
+=
1
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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