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
0dbedf95
Commit
0dbedf95
authored
Apr 05, 2018
by
Hisham Muhammad
Browse files
Collapse current subtree pressing Backspace
parent
42c3a1fc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Action.c
View file @
0dbedf95
...
...
@@ -155,6 +155,21 @@ static bool expandCollapse(Panel* panel) {
return
true
;
}
static
bool
collapseIntoParent
(
Panel
*
panel
)
{
Process
*
p
=
(
Process
*
)
Panel_getSelected
(
panel
);
if
(
!
p
)
return
false
;
pid_t
ppid
=
Process_getParentPid
(
p
);
for
(
int
i
=
0
;
i
<
Panel_size
(
panel
);
i
++
)
{
Process
*
q
=
(
Process
*
)
Panel_get
(
panel
,
i
);
if
(
q
->
pid
==
ppid
)
{
q
->
showChildren
=
false
;
Panel_setSelected
(
panel
,
i
);
return
true
;
}
}
return
false
;
}
Htop_Reaction
Action_setSortKey
(
Settings
*
settings
,
ProcessField
sortKey
)
{
settings
->
sortKey
=
sortKey
;
settings
->
direction
=
1
;
...
...
@@ -261,6 +276,14 @@ static Htop_Reaction actionExpandOrCollapse(State* st) {
return
changed
?
HTOP_RECALCULATE
:
HTOP_OK
;
}
static
Htop_Reaction
actionCollapseIntoParent
(
State
*
st
)
{
if
(
!
st
->
settings
->
treeView
)
{
return
HTOP_OK
;
}
bool
changed
=
collapseIntoParent
(
st
->
panel
);
return
changed
?
HTOP_RECALCULATE
:
HTOP_OK
;
}
static
Htop_Reaction
actionExpandCollapseOrSortColumn
(
State
*
st
)
{
return
st
->
settings
->
treeView
?
actionExpandOrCollapse
(
st
)
:
actionSetSortColumn
(
st
);
}
...
...
@@ -557,6 +580,7 @@ void Action_setBindings(Htop_Action* keys) {
keys
[
'+'
]
=
actionExpandOrCollapse
;
keys
[
'='
]
=
actionExpandOrCollapse
;
keys
[
'-'
]
=
actionExpandOrCollapse
;
keys
[
'\177'
]
=
actionCollapseIntoParent
;
keys
[
'u'
]
=
actionFilterByUser
;
keys
[
'F'
]
=
Action_follow
;
keys
[
'S'
]
=
actionSetup
;
...
...
Process.c
View file @
0dbedf95
...
...
@@ -178,6 +178,8 @@ typedef struct ProcessClass_ {
#define As_Process(this_) ((ProcessClass*)((this_)->super.klass))
#define Process_getParentPid(process_) (process_->tgid == process_->pid ? process_->ppid : process_->tgid)
#define Process_isChildOf(process_, pid_) (process_->tgid == pid_ || (process_->tgid == process_->pid && process_->ppid == pid_))
#define Process_sortState(state) ((state) == 'I' ? 0x100 : (state))
...
...
Process.h
View file @
0dbedf95
...
...
@@ -156,6 +156,8 @@ typedef struct ProcessClass_ {
#define As_Process(this_) ((ProcessClass*)((this_)->super.klass))
#define Process_getParentPid(process_) (process_->tgid == process_->pid ? process_->ppid : process_->tgid)
#define Process_isChildOf(process_, pid_) (process_->tgid == pid_ || (process_->tgid == process_->pid && process_->ppid == pid_))
#define Process_sortState(state) ((state) == 'I' ? 0x100 : (state))
...
...
ProcessList.c
View file @
0dbedf95
...
...
@@ -228,7 +228,7 @@ void ProcessList_sort(ProcessList* this) {
ProcessList_buildTree
(
this
,
process
->
pid
,
0
,
0
,
direction
,
false
);
break
;
}
pid_t
ppid
=
p
rocess
->
tgid
==
process
->
pid
?
process
->
ppid
:
process
->
tgid
;
pid_t
ppid
=
P
rocess
_getParentPid
(
process
)
;
// Bisect the process vector to find parent
int
l
=
0
,
r
=
size
;
// If PID corresponds with PPID (e.g. "kernel_task" (PID:0, PPID:0)
...
...
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