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
9b4bdfcb
Commit
9b4bdfcb
authored
Apr 05, 2018
by
Daniel Flanagan
Committed by
Hisham Muhammad
Apr 06, 2018
Browse files
Add -t command-line flag for tree view
parent
7a71f9cf
Changes
1
Show whitespace changes
Inline
Side-by-side
htop.c
View file @
9b4bdfcb
...
@@ -42,6 +42,7 @@ static void printHelpFlag() {
...
@@ -42,6 +42,7 @@ static void printHelpFlag() {
"-d --delay=DELAY Set the delay between updates, in tenths of seconds
\n
"
"-d --delay=DELAY Set the delay between updates, in tenths of seconds
\n
"
"-h --help Print this help screen
\n
"
"-h --help Print this help screen
\n
"
"-s --sort-key=COLUMN Sort by COLUMN (try --sort-key=help for a list)
\n
"
"-s --sort-key=COLUMN Sort by COLUMN (try --sort-key=help for a list)
\n
"
"-t --tree Show the tree view by default
\n
"
"-u --user=USERNAME Show only processes of a given user
\n
"
"-u --user=USERNAME Show only processes of a given user
\n
"
"-p --pid=PID,[,PID,PID...] Show only the given PIDs
\n
"
"-p --pid=PID,[,PID,PID...] Show only the given PIDs
\n
"
"-v --version Print version info
\n
"
"-v --version Print version info
\n
"
...
@@ -61,6 +62,7 @@ typedef struct CommandLineSettings_ {
...
@@ -61,6 +62,7 @@ typedef struct CommandLineSettings_ {
int
sortKey
;
int
sortKey
;
int
delay
;
int
delay
;
bool
useColors
;
bool
useColors
;
bool
treeView
;
}
CommandLineSettings
;
}
CommandLineSettings
;
static
CommandLineSettings
parseArguments
(
int
argc
,
char
**
argv
)
{
static
CommandLineSettings
parseArguments
(
int
argc
,
char
**
argv
)
{
...
@@ -71,6 +73,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
...
@@ -71,6 +73,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
.
sortKey
=
0
,
.
sortKey
=
0
,
.
delay
=
-
1
,
.
delay
=
-
1
,
.
useColors
=
true
,
.
useColors
=
true
,
.
treeView
=
false
,
};
};
static
struct
option
long_opts
[]
=
static
struct
option
long_opts
[]
=
...
@@ -82,6 +85,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
...
@@ -82,6 +85,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
{
"user"
,
required_argument
,
0
,
'u'
},
{
"user"
,
required_argument
,
0
,
'u'
},
{
"no-color"
,
no_argument
,
0
,
'C'
},
{
"no-color"
,
no_argument
,
0
,
'C'
},
{
"no-colour"
,
no_argument
,
0
,
'C'
},
{
"no-colour"
,
no_argument
,
0
,
'C'
},
{
"tree"
,
no_argument
,
0
,
't'
},
{
"pid"
,
required_argument
,
0
,
'p'
},
{
"pid"
,
required_argument
,
0
,
'p'
},
{
"io"
,
no_argument
,
0
,
'i'
},
{
"io"
,
no_argument
,
0
,
'i'
},
{
0
,
0
,
0
,
0
}
{
0
,
0
,
0
,
0
}
...
@@ -89,7 +93,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
...
@@ -89,7 +93,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
int
opt
,
opti
=
0
;
int
opt
,
opti
=
0
;
/* Parse arguments */
/* Parse arguments */
while
((
opt
=
getopt_long
(
argc
,
argv
,
"hvCs:d:u:p:i"
,
long_opts
,
&
opti
)))
{
while
((
opt
=
getopt_long
(
argc
,
argv
,
"hvCs
t:
:d:u:p:i"
,
long_opts
,
&
opti
)))
{
if
(
opt
==
EOF
)
break
;
if
(
opt
==
EOF
)
break
;
switch
(
opt
)
{
switch
(
opt
)
{
case
'h'
:
case
'h'
:
...
@@ -127,6 +131,9 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
...
@@ -127,6 +131,9 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
case
'C'
:
case
'C'
:
flags
.
useColors
=
false
;
flags
.
useColors
=
false
;
break
;
break
;
case
't'
:
flags
.
treeView
=
true
;
break
;
case
'p'
:
{
case
'p'
:
{
char
*
argCopy
=
xStrdup
(
optarg
);
char
*
argCopy
=
xStrdup
(
optarg
);
char
*
saveptr
;
char
*
saveptr
;
...
@@ -197,6 +204,8 @@ int main(int argc, char** argv) {
...
@@ -197,6 +204,8 @@ int main(int argc, char** argv) {
settings
->
delay
=
flags
.
delay
;
settings
->
delay
=
flags
.
delay
;
if
(
!
flags
.
useColors
)
if
(
!
flags
.
useColors
)
settings
->
colorScheme
=
COLORSCHEME_MONOCHROME
;
settings
->
colorScheme
=
COLORSCHEME_MONOCHROME
;
if
(
flags
.
treeView
)
settings
->
treeView
=
true
;
CRT_init
(
settings
->
delay
,
settings
->
colorScheme
);
CRT_init
(
settings
->
delay
,
settings
->
colorScheme
);
...
...
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