Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
iftop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul Warren
iftop
Commits
69ca7bac
Commit
69ca7bac
authored
Jan 05, 2017
by
Paul Warren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add colours to iftop David Heidelberger <david.heidelberger@ixit.cz>
parent
3fae1acf
Pipeline
#84
skipped
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
ui.c
ui.c
+18
-7
No files found.
ui.c
View file @
69ca7bac
...
...
@@ -53,6 +53,9 @@
"\n"\
"iftop, version " PACKAGE_VERSION
#define COLOR_SENT 1
#define COLOR_RECV 2
#define COLOR_BOTH 3
extern
hash_type
*
history
;
extern
int
history_pos
;
...
...
@@ -201,12 +204,13 @@ void draw_line_total(float sent, float recv, int y, int x, option_linedisplay_t
}
}
void
draw_bar
(
float
n
,
int
y
)
{
void
draw_bar
(
float
n
,
int
y
,
short
colorpair
)
{
int
L
;
colorpair
=
has_colors
()
?
colorpair
:
0
;
/* set 0 if terminal is not color capable*/
mvchgat
(
y
,
0
,
-
1
,
A_NORMAL
,
0
,
NULL
);
L
=
get_bar_length
(
8
*
n
);
if
(
L
>
0
)
mvchgat
(
y
,
0
,
L
+
1
,
A_REVERSE
,
0
,
NULL
);
mvchgat
(
y
,
0
,
L
+
1
,
A_REVERSE
,
colorpair
,
NULL
);
}
void
draw_line_totals
(
int
y
,
host_pair_line
*
line
,
option_linedisplay_t
linedisplay
)
{
...
...
@@ -221,17 +225,17 @@ void draw_line_totals(int y, host_pair_line* line, option_linedisplay_t linedisp
if
(
options
.
showbars
)
{
switch
(
linedisplay
)
{
case
OPTION_LINEDISPLAY_TWO_LINE
:
draw_bar
(
line
->
sent
[
options
.
bar_interval
],
y
);
draw_bar
(
line
->
recv
[
options
.
bar_interval
],
y
+
1
);
draw_bar
(
line
->
sent
[
options
.
bar_interval
],
y
,
COLOR_SENT
);
draw_bar
(
line
->
recv
[
options
.
bar_interval
],
y
+
1
,
COLOR_RECV
);
break
;
case
OPTION_LINEDISPLAY_ONE_LINE_SENT
:
draw_bar
(
line
->
sent
[
options
.
bar_interval
],
y
);
draw_bar
(
line
->
sent
[
options
.
bar_interval
],
y
,
COLOR_SENT
);
break
;
case
OPTION_LINEDISPLAY_ONE_LINE_RECV
:
draw_bar
(
line
->
recv
[
options
.
bar_interval
],
y
);
draw_bar
(
line
->
recv
[
options
.
bar_interval
],
y
,
COLOR_RECV
);
break
;
case
OPTION_LINEDISPLAY_ONE_LINE_BOTH
:
draw_bar
(
line
->
recv
[
options
.
bar_interval
]
+
line
->
sent
[
options
.
bar_interval
],
y
);
draw_bar
(
line
->
recv
[
options
.
bar_interval
]
+
line
->
sent
[
options
.
bar_interval
],
y
,
COLOR_BOTH
);
break
;
}
}
...
...
@@ -437,6 +441,13 @@ void ui_tick(int print) {
void
ui_curses_init
()
{
(
void
)
initscr
();
/* initialize the curses library */
if
(
has_colors
())
{
start_color
();
use_default_colors
();
init_pair
(
COLOR_RECV
,
COLOR_GREEN
,
-
1
);
init_pair
(
COLOR_SENT
,
COLOR_BLUE
,
-
1
);
init_pair
(
COLOR_BOTH
,
COLOR_MAGENTA
,
-
1
);
}
keypad
(
stdscr
,
TRUE
);
/* enable keyboard mapping */
(
void
)
nonl
();
/* tell curses not to do NL->CR/NL on output */
(
void
)
cbreak
();
/* take input chars one at a time, no wait for \n */
...
...
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