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
572546f8
Commit
572546f8
authored
May 05, 2016
by
Hisham
Browse files
Auto-follow process after a search.
See #237.
parent
d464be13
Changes
5
Show whitespace changes
Inline
Side-by-side
Action.c
View file @
572546f8
...
...
@@ -328,7 +328,7 @@ static Htop_Reaction actionFilterByUser(State* st) {
return
HTOP_REFRESH
|
HTOP_REDRAW_BAR
|
HTOP_UPDATE_PANELHDR
;
}
static
Htop_Reaction
a
ction
F
ollow
(
State
*
st
)
{
Htop_Reaction
A
ction
_f
ollow
(
State
*
st
)
{
st
->
pl
->
following
=
MainPanel_selectedPid
((
MainPanel
*
)
st
->
panel
);
Panel_setSelectionColor
(
st
->
panel
,
CRT_colors
[
PANEL_SELECTION_FOLLOW
]);
return
HTOP_KEEP_FOLLOWING
;
...
...
@@ -557,7 +557,7 @@ void Action_setBindings(Htop_Action* keys) {
keys
[
'='
]
=
actionExpandOrCollapse
;
keys
[
'-'
]
=
actionExpandOrCollapse
;
keys
[
'u'
]
=
actionFilterByUser
;
keys
[
'F'
]
=
a
ction
F
ollow
;
keys
[
'F'
]
=
A
ction
_f
ollow
;
keys
[
'S'
]
=
actionSetup
;
keys
[
'C'
]
=
actionSetup
;
keys
[
KEY_F
(
2
)]
=
actionSetup
;
...
...
Action.h
View file @
572546f8
...
...
@@ -49,6 +49,8 @@ Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey);
// ----------------------------------------
Htop_Reaction
Action_follow
(
State
*
st
);
void
Action_setBindings
(
Htop_Action
*
keys
);
...
...
IncSet.c
View file @
572546f8
...
...
@@ -40,6 +40,7 @@ typedef struct IncSet_ {
IncMode* active;
FunctionBar* defaultBar;
bool filtering;
bool found;
} IncSet;
typedef const char* (*IncMode_GetPanelValue)(Panel*, int);
...
...
@@ -114,7 +115,7 @@ static void updateWeakPanel(IncSet* this, Panel* panel, Vector* lines) {
}
}
static
void
search
(
IncMode
*
mode
,
Panel
*
panel
,
IncMode_GetPanelValue
getPanelValue
)
{
static
bool
search
(
IncMode
*
mode
,
Panel
*
panel
,
IncMode_GetPanelValue
getPanelValue
)
{
int
size
=
Panel_size
(
panel
);
bool
found
=
false
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
...
...
@@ -128,6 +129,7 @@ static void search(IncMode* mode, Panel* panel, IncMode_GetPanelValue getPanelVa
FunctionBar_draw
(
mode
->
bar
,
mode
->
buffer
);
else
FunctionBar_drawAttr
(
mode
->
bar
,
mode
->
buffer
,
CRT_colors
[
FAILED_SEARCH
]);
return
found
;
}
bool
IncSet_handleKey
(
IncSet
*
this
,
int
ch
,
Panel
*
panel
,
IncMode_GetPanelValue
getPanelValue
,
Vector
*
lines
)
{
...
...
@@ -151,7 +153,8 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
}
}
doSearch
=
false
;
}
else
if
(
ch
<
255
&&
isprint
((
char
)
ch
)
&&
(
mode
->
index
<
INCMODE_MAX
))
{
}
else
if
(
ch
<
255
&&
isprint
((
char
)
ch
))
{
if
(
mode
->
index
<
INCMODE_MAX
)
{
mode
->
buffer
[
mode
->
index
]
=
ch
;
mode
->
index
++
;
mode
->
buffer
[
mode
->
index
]
=
0
;
...
...
@@ -159,7 +162,9 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
filterChanged
=
true
;
if
(
mode
->
index
==
1
)
this
->
filtering
=
true
;
}
}
else
if
((
ch
==
KEY_BACKSPACE
||
ch
==
127
)
&&
(
mode
->
index
>
0
))
{
}
}
else
if
((
ch
==
KEY_BACKSPACE
||
ch
==
127
))
{
if
(
mode
->
index
>
0
)
{
mode
->
index
--
;
mode
->
buffer
[
mode
->
index
]
=
0
;
if
(
mode
->
isFilter
)
{
...
...
@@ -169,6 +174,9 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
IncMode_reset
(
mode
);
}
}
}
else
{
doSearch
=
false
;
}
}
else
if
(
ch
==
KEY_RESIZE
)
{
Panel_resize
(
panel
,
COLS
,
LINES
-
panel
->
y
-
1
);
}
else
{
...
...
@@ -187,7 +195,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
doSearch
=
false
;
}
if
(
doSearch
)
{
search
(
mode
,
panel
,
getPanelValue
);
this
->
found
=
search
(
mode
,
panel
,
getPanelValue
);
}
if
(
filterChanged
&&
lines
)
{
updateWeakPanel
(
this
,
panel
,
lines
);
...
...
IncSet.h
View file @
572546f8
...
...
@@ -35,6 +35,7 @@ typedef struct IncSet_ {
IncMode
*
active
;
FunctionBar
*
defaultBar
;
bool
filtering
;
bool
found
;
}
IncSet
;
typedef
const
char
*
(
*
IncMode_GetPanelValue
)(
Panel
*
,
int
);
...
...
MainPanel.c
View file @
572546f8
...
...
@@ -83,6 +83,9 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
result
=
HANDLED
;
}
else
if
(
ch
!=
ERR
&&
this
->
inc
->
active
)
{
bool
filterChanged
=
IncSet_handleKey
(
this
->
inc
,
ch
,
super
,
(
IncMode_GetPanelValue
)
MainPanel_getValue
,
NULL
);
if
(
this
->
inc
->
found
)
{
reaction
|=
Action_follow
(
this
->
state
);
}
if
(
filterChanged
)
{
this
->
state
->
pl
->
incFilter
=
IncSet_filter
(
this
->
inc
);
reaction
=
HTOP_REFRESH
|
HTOP_REDRAW_BAR
;
...
...
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