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
ea855aef
Commit
ea855aef
authored
May 30, 2006
by
Hisham Muhammad
Browse files
Remove references to ListBox
parent
73de9f1e
Changes
6
Hide whitespace changes
Inline
Side-by-side
AvailableMetersPanel.c
View file @
ea855aef
...
...
@@ -15,8 +15,8 @@ typedef struct AvailableMetersPanel_ {
Panel super;
Settings* settings;
Panel* left
Box
;
Panel* right
Box
;
Panel* left
Panel
;
Panel* right
Panel
;
ScreenManager* scr;
} AvailableMetersPanel;
...
...
@@ -29,8 +29,8 @@ AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Panel* leftMe
((
Object
*
)
this
)
->
delete
=
AvailableMetersPanel_delete
;
this
->
settings
=
settings
;
this
->
left
Box
=
leftMeters
;
this
->
right
Box
=
rightMeters
;
this
->
left
Panel
=
leftMeters
;
this
->
right
Panel
=
rightMeters
;
this
->
scr
=
scr
;
super
->
eventHandler
=
AvailableMetersPanel_EventHandler
;
...
...
@@ -64,9 +64,9 @@ void AvailableMetersPanel_delete(Object* object) {
}
/* private */
inline
void
AvailableMetersPanel_addHeader
(
Header
*
header
,
Panel
*
l
b
,
MeterType
*
type
,
int
param
,
HeaderSide
side
)
{
inline
void
AvailableMetersPanel_addHeader
(
Header
*
header
,
Panel
*
pane
l
,
MeterType
*
type
,
int
param
,
HeaderSide
side
)
{
Meter
*
meter
=
(
Meter
*
)
Header_addMeter
(
header
,
type
,
param
,
side
);
Panel_add
(
l
b
,
(
Object
*
)
Meter_toListItem
(
meter
));
Panel_add
(
pane
l
,
(
Object
*
)
Meter_toListItem
(
meter
));
}
HandlerResult
AvailableMetersPanel_EventHandler
(
Panel
*
super
,
int
ch
)
{
...
...
@@ -83,7 +83,7 @@ HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) {
case
'l'
:
case
'L'
:
{
AvailableMetersPanel_addHeader
(
header
,
this
->
left
Box
,
Meter_types
[
type
],
param
,
LEFT_HEADER
);
AvailableMetersPanel_addHeader
(
header
,
this
->
left
Panel
,
Meter_types
[
type
],
param
,
LEFT_HEADER
);
result
=
HANDLED
;
break
;
}
...
...
@@ -91,7 +91,7 @@ HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) {
case
'r'
:
case
'R'
:
{
AvailableMetersPanel_addHeader
(
header
,
this
->
right
Box
,
Meter_types
[
type
],
param
,
RIGHT_HEADER
);
AvailableMetersPanel_addHeader
(
header
,
this
->
right
Panel
,
Meter_types
[
type
],
param
,
RIGHT_HEADER
);
result
=
HANDLED
;
break
;
}
...
...
AvailableMetersPanel.h
View file @
ea855aef
...
...
@@ -17,8 +17,8 @@ typedef struct AvailableMetersPanel_ {
Panel
super
;
Settings
*
settings
;
Panel
*
left
Box
;
Panel
*
right
Box
;
Panel
*
left
Panel
;
Panel
*
right
Panel
;
ScreenManager
*
scr
;
}
AvailableMetersPanel
;
...
...
ChangeLog
View file @
ea855aef
What's new in version 0.6.3
* Internal change: rename TypedVector to Vector and
ListBox (and related classes) to Panel.
What's new in version 0.6.2
* BUGFIX: Fixed crash when using some .htoprc files from 0.6
...
...
ScreenManager.c
View file @
ea855aef
...
...
@@ -91,11 +91,11 @@ void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int
Panel
*
ScreenManager_remove
(
ScreenManager
*
this
,
int
index
)
{
assert
(
this
->
itemCount
>
index
);
Panel
*
l
b
=
(
Panel
*
)
Vector_remove
(
this
->
items
,
index
);
Panel
*
pane
l
=
(
Panel
*
)
Vector_remove
(
this
->
items
,
index
);
Vector_remove
(
this
->
fuBars
,
index
);
this
->
fuBar
=
NULL
;
this
->
itemCount
--
;
return
l
b
;
return
pane
l
;
}
void
ScreenManager_setFunctionBar
(
ScreenManager
*
this
,
FunctionBar
*
fuBar
)
{
...
...
@@ -112,21 +112,21 @@ void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2) {
int
items
=
this
->
itemCount
;
int
lastX
=
0
;
for
(
int
i
=
0
;
i
<
items
-
1
;
i
++
)
{
Panel
*
l
b
=
(
Panel
*
)
Vector_get
(
this
->
items
,
i
);
Panel_resize
(
lb
,
lb
->
w
,
LINES
-
y1
+
y2
);
Panel_move
(
l
b
,
lastX
,
y1
);
lastX
=
l
b
->
x
+
l
b
->
w
+
1
;
Panel
*
pane
l
=
(
Panel
*
)
Vector_get
(
this
->
items
,
i
);
Panel_resize
(
panel
,
panel
->
w
,
LINES
-
y1
+
y2
);
Panel_move
(
pane
l
,
lastX
,
y1
);
lastX
=
pane
l
->
x
+
pane
l
->
w
+
1
;
}
Panel
*
l
b
=
(
Panel
*
)
Vector_get
(
this
->
items
,
items
-
1
);
Panel_resize
(
l
b
,
COLS
-
x1
+
x2
-
lastX
,
LINES
-
y1
+
y2
);
Panel_move
(
l
b
,
lastX
,
y1
);
Panel
*
pane
l
=
(
Panel
*
)
Vector_get
(
this
->
items
,
items
-
1
);
Panel_resize
(
pane
l
,
COLS
-
x1
+
x2
-
lastX
,
LINES
-
y1
+
y2
);
Panel_move
(
pane
l
,
lastX
,
y1
);
}
void
ScreenManager_run
(
ScreenManager
*
this
,
Panel
**
lastFocus
,
int
*
lastKey
)
{
bool
quit
=
false
;
int
focus
=
0
;
Panel
*
l
b
Focus
=
(
Panel
*
)
Vector_get
(
this
->
items
,
focus
);
Panel
*
pane
lFocus
=
(
Panel
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
this
->
fuBar
)
FunctionBar_draw
(
this
->
fuBar
,
NULL
);
...
...
@@ -134,11 +134,11 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
while
(
!
quit
)
{
int
items
=
this
->
itemCount
;
for
(
int
i
=
0
;
i
<
items
;
i
++
)
{
Panel
*
l
b
=
(
Panel
*
)
Vector_get
(
this
->
items
,
i
);
Panel_draw
(
l
b
,
i
==
focus
);
Panel
*
pane
l
=
(
Panel
*
)
Vector_get
(
this
->
items
,
i
);
Panel_draw
(
pane
l
,
i
==
focus
);
if
(
i
<
items
)
{
if
(
this
->
orientation
==
HORIZONTAL
)
{
mvvline
(
lb
->
y
,
lb
->
x
+
lb
->
w
,
' '
,
l
b
->
h
+
1
);
mvvline
(
panel
->
y
,
panel
->
x
+
panel
->
w
,
' '
,
pane
l
->
h
+
1
);
}
}
}
...
...
@@ -159,12 +159,12 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
ch
=
FunctionBar_synthesizeEvent
(
this
->
fuBar
,
mevent
.
x
);
}
else
{
for
(
int
i
=
0
;
i
<
this
->
itemCount
;
i
++
)
{
Panel
*
l
b
=
(
Panel
*
)
Vector_get
(
this
->
items
,
i
);
if
(
mevent
.
x
>
l
b
->
x
&&
mevent
.
x
<=
lb
->
x
+
lb
->
w
&&
mevent
.
y
>
l
b
->
y
&&
mevent
.
y
<=
lb
->
y
+
lb
->
h
)
{
Panel
*
pane
l
=
(
Panel
*
)
Vector_get
(
this
->
items
,
i
);
if
(
mevent
.
x
>
pane
l
->
x
&&
mevent
.
x
<=
panel
->
x
+
panel
->
w
&&
mevent
.
y
>
pane
l
->
y
&&
mevent
.
y
<=
panel
->
y
+
panel
->
h
)
{
focus
=
i
;
l
b
Focus
=
l
b
;
Panel_setSelected
(
l
b
,
mevent
.
y
-
l
b
->
y
+
l
b
->
scrollV
-
1
);
pane
lFocus
=
pane
l
;
Panel_setSelected
(
pane
l
,
mevent
.
y
-
pane
l
->
y
+
pane
l
->
scrollV
-
1
);
loop
=
true
;
break
;
}
...
...
@@ -174,8 +174,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
}
if
(
loop
)
continue
;
if
(
l
b
Focus
->
eventHandler
)
{
HandlerResult
result
=
l
b
Focus
->
eventHandler
(
l
b
Focus
,
ch
);
if
(
pane
lFocus
->
eventHandler
)
{
HandlerResult
result
=
pane
lFocus
->
eventHandler
(
pane
lFocus
,
ch
);
if
(
result
==
HANDLED
)
{
continue
;
}
else
if
(
result
==
BREAK_LOOP
)
{
...
...
@@ -196,8 +196,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
tryLeft:
if
(
focus
>
0
)
focus
--
;
l
b
Focus
=
(
Panel
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
Panel_getSize
(
l
b
Focus
)
==
0
&&
focus
>
0
)
pane
lFocus
=
(
Panel
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
Panel_getSize
(
pane
lFocus
)
==
0
&&
focus
>
0
)
goto
tryLeft
;
break
;
case
KEY_RIGHT
:
...
...
@@ -205,8 +205,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
tryRight:
if
(
focus
<
this
->
itemCount
-
1
)
focus
++
;
l
b
Focus
=
(
Panel
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
Panel_getSize
(
l
b
Focus
)
==
0
&&
focus
<
this
->
itemCount
-
1
)
pane
lFocus
=
(
Panel
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
Panel_getSize
(
pane
lFocus
)
==
0
&&
focus
<
this
->
itemCount
-
1
)
goto
tryRight
;
break
;
case
KEY_F
(
10
):
...
...
@@ -215,11 +215,11 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
quit
=
true
;
continue
;
default:
Panel_onKey
(
l
b
Focus
,
ch
);
Panel_onKey
(
pane
lFocus
,
ch
);
break
;
}
}
*
lastFocus
=
l
b
Focus
;
*
lastFocus
=
pane
lFocus
;
*
lastKey
=
ch
;
}
TraceScreen.c
View file @
ea855aef
...
...
@@ -81,7 +81,7 @@ void TraceScreen_run(TraceScreen* this) {
}
fcntl
(
fdpair
[
0
],
F_SETFL
,
O_NONBLOCK
);
FILE
*
strace
=
fdopen
(
fdpair
[
0
],
"r"
);
Panel
*
l
b
=
this
->
display
;
Panel
*
pane
l
=
this
->
display
;
int
fd_strace
=
fileno
(
strace
);
TraceScreen_draw
(
this
);
CRT_disableDelay
();
...
...
@@ -105,31 +105,31 @@ void TraceScreen_run(TraceScreen* this) {
if
(
buffer
[
i
]
==
'\n'
)
{
buffer
[
i
]
=
'\0'
;
if
(
contLine
)
{
ListItem_append
((
ListItem
*
)
Panel_get
(
l
b
,
Panel_getSize
(
l
b
)
-
1
),
line
);
ListItem_append
((
ListItem
*
)
Panel_get
(
pane
l
,
Panel_getSize
(
pane
l
)
-
1
),
line
);
contLine
=
false
;
}
else
{
Panel_add
(
l
b
,
(
Object
*
)
ListItem_new
(
line
,
0
));
Panel_add
(
pane
l
,
(
Object
*
)
ListItem_new
(
line
,
0
));
}
line
=
buffer
+
i
+
1
;
}
}
if
(
line
<
buffer
+
nread
)
{
Panel_add
(
l
b
,
(
Object
*
)
ListItem_new
(
line
,
0
));
Panel_add
(
pane
l
,
(
Object
*
)
ListItem_new
(
line
,
0
));
buffer
[
nread
]
=
'\0'
;
contLine
=
true
;
}
if
(
follow
)
Panel_setSelected
(
l
b
,
Panel_getSize
(
l
b
)
-
1
);
Panel_draw
(
l
b
,
true
);
Panel_setSelected
(
pane
l
,
Panel_getSize
(
pane
l
)
-
1
);
Panel_draw
(
pane
l
,
true
);
}
int
ch
=
getch
();
if
(
ch
==
KEY_MOUSE
)
{
MEVENT
mevent
;
int
ok
=
getmouse
(
&
mevent
);
if
(
ok
==
OK
)
if
(
mevent
.
y
>=
l
b
->
y
&&
mevent
.
y
<
LINES
-
1
)
{
Panel_setSelected
(
l
b
,
mevent
.
y
-
l
b
->
y
+
l
b
->
scrollV
);
if
(
mevent
.
y
>=
pane
l
->
y
&&
mevent
.
y
<
LINES
-
1
)
{
Panel_setSelected
(
pane
l
,
mevent
.
y
-
pane
l
->
y
+
pane
l
->
scrollV
);
follow
=
false
;
ch
=
0
;
}
if
(
mevent
.
y
==
LINES
-
1
)
...
...
@@ -147,21 +147,21 @@ void TraceScreen_run(TraceScreen* this) {
case
KEY_F
(
4
):
follow
=
!
follow
;
if
(
follow
)
Panel_setSelected
(
l
b
,
Panel_getSize
(
l
b
)
-
1
);
Panel_setSelected
(
pane
l
,
Panel_getSize
(
pane
l
)
-
1
);
break
;
case
'q'
:
case
27
:
looping
=
false
;
break
;
case
KEY_RESIZE
:
Panel_resize
(
l
b
,
COLS
,
LINES
-
2
);
Panel_resize
(
pane
l
,
COLS
,
LINES
-
2
);
TraceScreen_draw
(
this
);
break
;
default:
follow
=
false
;
Panel_onKey
(
l
b
,
ch
);
Panel_onKey
(
pane
l
,
ch
);
}
Panel_draw
(
l
b
,
true
);
Panel_draw
(
pane
l
,
true
);
}
kill
(
child
,
SIGTERM
);
waitpid
(
child
,
NULL
,
0
);
...
...
htop.c
View file @
ea855aef
...
...
@@ -126,62 +126,62 @@ void showHelp() {
static
void
Setup_run
(
Settings
*
settings
,
int
headerHeight
)
{
ScreenManager
*
scr
=
ScreenManager_new
(
0
,
headerHeight
,
0
,
-
1
,
HORIZONTAL
,
true
);
CategoriesPanel
*
l
b
Categories
=
CategoriesPanel_new
(
settings
,
scr
);
ScreenManager_add
(
scr
,
(
Panel
*
)
l
b
Categories
,
NULL
,
16
);
CategoriesPanel_makeMetersPage
(
l
b
Categories
);
Panel
*
l
b
Focus
;
CategoriesPanel
*
pane
lCategories
=
CategoriesPanel_new
(
settings
,
scr
);
ScreenManager_add
(
scr
,
(
Panel
*
)
pane
lCategories
,
NULL
,
16
);
CategoriesPanel_makeMetersPage
(
pane
lCategories
);
Panel
*
pane
lFocus
;
int
ch
;
ScreenManager_run
(
scr
,
&
l
b
Focus
,
&
ch
);
ScreenManager_run
(
scr
,
&
pane
lFocus
,
&
ch
);
ScreenManager_delete
(
scr
);
}
static
bool
changePriority
(
Panel
*
l
b
,
int
delta
)
{
static
bool
changePriority
(
Panel
*
pane
l
,
int
delta
)
{
bool
anyTagged
=
false
;
for
(
int
i
=
0
;
i
<
Panel_getSize
(
l
b
);
i
++
)
{
Process
*
p
=
(
Process
*
)
Panel_get
(
l
b
,
i
);
for
(
int
i
=
0
;
i
<
Panel_getSize
(
pane
l
);
i
++
)
{
Process
*
p
=
(
Process
*
)
Panel_get
(
pane
l
,
i
);
if
(
p
->
tag
)
{
Process_setPriority
(
p
,
p
->
nice
+
delta
);
anyTagged
=
true
;
}
}
if
(
!
anyTagged
)
{
Process
*
p
=
(
Process
*
)
Panel_getSelected
(
l
b
);
Process
*
p
=
(
Process
*
)
Panel_getSelected
(
pane
l
);
Process_setPriority
(
p
,
p
->
nice
+
delta
);
}
return
anyTagged
;
}
static
HandlerResult
pickWithEnter
(
Panel
*
l
b
,
int
ch
)
{
static
HandlerResult
pickWithEnter
(
Panel
*
pane
l
,
int
ch
)
{
if
(
ch
==
13
)
return
BREAK_LOOP
;
return
IGNORED
;
}
static
Object
*
pickFromList
(
Panel
*
l
b
,
Panel
*
list
,
int
x
,
int
y
,
char
**
keyLabels
,
FunctionBar
*
prevBar
)
{
static
Object
*
pickFromList
(
Panel
*
pane
l
,
Panel
*
list
,
int
x
,
int
y
,
char
**
keyLabels
,
FunctionBar
*
prevBar
)
{
char
*
fuKeys
[
2
]
=
{
"Enter"
,
"Esc"
};
int
fuEvents
[
2
]
=
{
13
,
27
};
if
(
!
l
b
->
eventHandler
)
if
(
!
pane
l
->
eventHandler
)
Panel_setEventHandler
(
list
,
pickWithEnter
);
ScreenManager
*
scr
=
ScreenManager_new
(
0
,
y
,
0
,
-
1
,
HORIZONTAL
,
false
);
ScreenManager_add
(
scr
,
list
,
FunctionBar_new
(
2
,
keyLabels
,
fuKeys
,
fuEvents
),
x
-
1
);
ScreenManager_add
(
scr
,
l
b
,
NULL
,
-
1
);
Panel
*
l
b
Focus
;
ScreenManager_add
(
scr
,
pane
l
,
NULL
,
-
1
);
Panel
*
pane
lFocus
;
int
ch
;
ScreenManager_run
(
scr
,
&
l
b
Focus
,
&
ch
);
ScreenManager_run
(
scr
,
&
pane
lFocus
,
&
ch
);
ScreenManager_delete
(
scr
);
Panel_move
(
l
b
,
0
,
y
);
Panel_resize
(
l
b
,
COLS
,
LINES
-
y
-
1
);
Panel_move
(
pane
l
,
0
,
y
);
Panel_resize
(
pane
l
,
COLS
,
LINES
-
y
-
1
);
FunctionBar_draw
(
prevBar
,
NULL
);
if
(
l
b
Focus
==
list
&&
ch
==
13
)
{
if
(
pane
lFocus
==
list
&&
ch
==
13
)
{
return
Panel_getSelected
(
list
);
}
return
NULL
;
}
void
addUserToList
(
int
key
,
void
*
userCast
,
void
*
l
b
Cast
)
{
void
addUserToList
(
int
key
,
void
*
userCast
,
void
*
pane
lCast
)
{
char
*
user
=
(
char
*
)
userCast
;
Panel
*
l
b
=
(
Panel
*
)
l
b
Cast
;
Panel_add
(
l
b
,
(
Object
*
)
ListItem_new
(
user
,
key
));
Panel
*
pane
l
=
(
Panel
*
)
pane
lCast
;
Panel_add
(
pane
l
,
(
Object
*
)
ListItem_new
(
user
,
key
));
}
void
setUserOnly
(
const
char
*
userName
,
bool
*
userOnly
,
uid_t
*
userId
)
{
...
...
@@ -219,14 +219,14 @@ int main(int argc, char** argv) {
exit
(
1
);
}
Panel
*
l
b
;
Panel
*
pane
l
;
int
quit
=
0
;
int
refreshTimeout
=
0
;
int
resetRefreshTimeout
=
5
;
bool
doRefresh
=
true
;
Settings
*
settings
;
Panel
*
lbk
=
NULL
;
Panel
*
killPanel
=
NULL
;
char
incSearchBuffer
[
INCSEARCH_MAX
];
int
incSearchIndex
=
0
;
...
...
@@ -248,8 +248,8 @@ int main(int argc, char** argv) {
CRT_init
(
settings
->
delay
,
settings
->
colorScheme
);
l
b
=
Panel_new
(
0
,
headerHeight
,
COLS
,
LINES
-
headerHeight
-
2
,
PROCESS_CLASS
,
false
);
Panel_setRichHeader
(
l
b
,
ProcessList_printHeader
(
pl
));
pane
l
=
Panel_new
(
0
,
headerHeight
,
COLS
,
LINES
-
headerHeight
-
2
,
PROCESS_CLASS
,
false
);
Panel_setRichHeader
(
pane
l
,
ProcessList_printHeader
(
pl
));
char
*
searchFunctions
[
3
]
=
{
"Next "
,
"Exit "
,
" Search: "
};
char
*
searchKeys
[
3
]
=
{
"F3"
,
"Esc"
,
" "
};
...
...
@@ -285,9 +285,9 @@ int main(int argc, char** argv) {
if
(
doRefresh
)
{
incSearchIndex
=
0
;
incSearchBuffer
[
0
]
=
0
;
int
currPos
=
Panel_getSelectedIndex
(
l
b
);
int
currPos
=
Panel_getSelectedIndex
(
pane
l
);
int
currPid
=
0
;
int
currScrollV
=
l
b
->
scrollV
;
int
currScrollV
=
pane
l
->
scrollV
;
if
(
follow
)
currPid
=
ProcessList_get
(
pl
,
currPos
)
->
pid
;
if
(
recalculate
)
...
...
@@ -296,18 +296,18 @@ int main(int argc, char** argv) {
ProcessList_sort
(
pl
);
refreshTimeout
=
1
;
}
Panel_prune
(
l
b
);
Panel_prune
(
pane
l
);
int
size
=
ProcessList_size
(
pl
);
int
lbi
=
0
;
int
index
=
0
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
Process
*
p
=
ProcessList_get
(
pl
,
i
);
if
(
!
userOnly
||
(
p
->
st_uid
==
userId
))
{
Panel_set
(
lb
,
lbi
,
(
Object
*
)
p
);
if
((
!
follow
&&
lbi
==
currPos
)
||
(
follow
&&
p
->
pid
==
currPid
))
{
Panel_setSelected
(
lb
,
lbi
);
l
b
->
scrollV
=
currScrollV
;
Panel_set
(
panel
,
index
,
(
Object
*
)
p
);
if
((
!
follow
&&
index
==
currPos
)
||
(
follow
&&
p
->
pid
==
currPid
))
{
Panel_setSelected
(
panel
,
index
);
pane
l
->
scrollV
=
currScrollV
;
}
lbi
++
;
index
++
;
}
}
}
...
...
@@ -315,7 +315,7 @@ int main(int argc, char** argv) {
Header_draw
(
header
);
Panel_draw
(
l
b
,
true
);
Panel_draw
(
pane
l
,
true
);
int
prev
=
ch
;
ch
=
getch
();
...
...
@@ -334,7 +334,7 @@ int main(int argc, char** argv) {
if
(
incSearchMode
)
{
doRefresh
=
false
;
if
(
ch
==
KEY_F
(
3
))
{
int
here
=
Panel_getSelectedIndex
(
l
b
);
int
here
=
Panel_getSelectedIndex
(
pane
l
);
int
size
=
ProcessList_size
(
pl
);
int
i
=
here
+
1
;
while
(
i
!=
here
)
{
...
...
@@ -342,7 +342,7 @@ int main(int argc, char** argv) {
i
=
0
;
Process
*
p
=
ProcessList_get
(
pl
,
i
);
if
(
String_contains_i
(
p
->
comm
,
incSearchBuffer
))
{
Panel_setSelected
(
l
b
,
i
);
Panel_setSelected
(
pane
l
,
i
);
break
;
}
i
++
;
...
...
@@ -367,7 +367,7 @@ int main(int argc, char** argv) {
for
(
int
i
=
0
;
i
<
ProcessList_size
(
pl
);
i
++
)
{
Process
*
p
=
ProcessList_get
(
pl
,
i
);
if
(
String_contains_i
(
p
->
comm
,
incSearchBuffer
))
{
Panel_setSelected
(
l
b
,
i
);
Panel_setSelected
(
pane
l
,
i
);
found
=
true
;
break
;
}
...
...
@@ -381,8 +381,8 @@ int main(int argc, char** argv) {
}
if
(
isdigit
((
char
)
ch
))
{
int
pid
=
ch
-
48
+
acc
;
for
(
int
i
=
0
;
i
<
ProcessList_size
(
pl
)
&&
((
Process
*
)
Panel_getSelected
(
l
b
))
->
pid
!=
pid
;
i
++
)
Panel_setSelected
(
l
b
,
i
);
for
(
int
i
=
0
;
i
<
ProcessList_size
(
pl
)
&&
((
Process
*
)
Panel_getSelected
(
pane
l
))
->
pid
!=
pid
;
i
++
)
Panel_setSelected
(
pane
l
,
i
);
acc
=
pid
*
10
;
if
(
acc
>
100000
)
acc
=
0
;
...
...
@@ -395,8 +395,8 @@ int main(int argc, char** argv) {
MEVENT
mevent
;
int
ok
=
getmouse
(
&
mevent
);
if
(
ok
==
OK
)
{
if
(
mevent
.
y
>=
l
b
->
y
+
1
&&
mevent
.
y
<
LINES
-
1
)
{
Panel_setSelected
(
l
b
,
mevent
.
y
-
l
b
->
y
+
l
b
->
scrollV
-
1
);
if
(
mevent
.
y
>=
pane
l
->
y
+
1
&&
mevent
.
y
<
LINES
-
1
)
{
Panel_setSelected
(
pane
l
,
mevent
.
y
-
pane
l
->
y
+
pane
l
->
scrollV
-
1
);
doRefresh
=
false
;
refreshTimeout
=
resetRefreshTimeout
;
follow
=
true
;
...
...
@@ -413,7 +413,7 @@ int main(int argc, char** argv) {
switch
(
ch
)
{
case
KEY_RESIZE
:
Panel_resize
(
l
b
,
COLS
,
LINES
-
headerHeight
-
1
);
Panel_resize
(
pane
l
,
COLS
,
LINES
-
headerHeight
-
1
);
if
(
incSearchMode
)
FunctionBar_draw
(
searchBar
,
incSearchBuffer
);
else
...
...
@@ -425,7 +425,7 @@ int main(int argc, char** argv) {
pl
->
sortKey
=
PERCENT_MEM
;
pl
->
treeView
=
false
;
settings
->
changed
=
true
;
Panel_setRichHeader
(
l
b
,
ProcessList_printHeader
(
pl
));
Panel_setRichHeader
(
pane
l
,
ProcessList_printHeader
(
pl
));
break
;
}
case
'T'
:
...
...
@@ -434,13 +434,13 @@ int main(int argc, char** argv) {
pl
->
sortKey
=
TIME
;
pl
->
treeView
=
false
;
settings
->
changed
=
true
;
Panel_setRichHeader
(
l
b
,
ProcessList_printHeader
(
pl
));
Panel_setRichHeader
(
pane
l
,
ProcessList_printHeader
(
pl
));
break
;
}
case
'U'
:
{
for
(
int
i
=
0
;
i
<
Panel_getSize
(
l
b
);
i
++
)
{
Process
*
p
=
(
Process
*
)
Panel_get
(
l
b
,
i
);
for
(
int
i
=
0
;
i
<
Panel_getSize
(
pane
l
);
i
++
)
{
Process
*
p
=
(
Process
*
)
Panel_get
(
pane
l
,
i
);
p
->
tag
=
false
;
}
doRefresh
=
true
;
...
...
@@ -452,7 +452,7 @@ int main(int argc, char** argv) {
pl
->
sortKey
=
PERCENT_CPU
;
pl
->
treeView
=
false
;
settings
->
changed
=
true
;
Panel_setRichHeader
(
l
b
,
ProcessList_printHeader
(
pl
));
Panel_setRichHeader
(
pane
l
,
ProcessList_printHeader
(
pl
));
break
;
}
case
KEY_F
(
1
):
...
...
@@ -472,14 +472,14 @@ int main(int argc, char** argv) {
}
case
' '
:
{
Process
*
p
=
(
Process
*
)
Panel_getSelected
(
l
b
);
Process
*
p
=
(
Process
*
)
Panel_getSelected
(
pane
l
);
Process_toggleTag
(
p
);
Panel_onKey
(
l
b
,
KEY_DOWN
);
Panel_onKey
(
pane
l
,
KEY_DOWN
);
break
;
}
case
's'
:
{
TraceScreen
*
ts
=
TraceScreen_new
((
Process
*
)
Panel_getSelected
(
l
b
));
TraceScreen
*
ts
=
TraceScreen_new
((
Process
*
)
Panel_getSelected
(
pane
l
));
TraceScreen_run
(
ts
);
TraceScreen_delete
(
ts
);
clear
();
...
...
@@ -494,10 +494,10 @@ int main(int argc, char** argv) {
{
Setup_run
(
settings
,
headerHeight
);
// TODO: shouldn't need this, colors should be dynamic
Panel_setRichHeader
(
l
b
,
ProcessList_printHeader
(
pl
));
Panel_setRichHeader
(
pane
l
,
ProcessList_printHeader
(
pl
));
headerHeight
=
Header_calculateHeight
(
header
);
Panel_move
(
l
b
,
0
,
headerHeight
);
Panel_resize
(
l
b
,
COLS
,
LINES
-
headerHeight
-
1
);
Panel_move
(
pane
l
,
0
,
headerHeight
);
Panel_resize
(
pane
l
,
COLS
,
LINES
-
headerHeight
-
1
);
FunctionBar_draw
(
defaultBar
,
NULL
);
refreshTimeout
=
0
;
break
;
...
...
@@ -509,14 +509,14 @@ int main(int argc, char** argv) {
}
case
'u'
:
{
Panel
*
lbu
=
Panel_new
(
0
,
0
,
0
,
0
,
LISTITEM_CLASS
,
true
);
Panel_setHeader
(
lbu
,
"Show processes of:"
);
UsersTable_foreach
(
ut
,
addUserToList
,
lbu
);
Vector_sort
(
lbu
->
items
);
Panel
*
usersPanel
=
Panel_new
(
0
,
0
,
0
,
0
,
LISTITEM_CLASS
,
true
);
Panel_setHeader
(
usersPanel
,
"Show processes of:"
);
UsersTable_foreach
(
ut
,
addUserToList
,
usersPanel
);
Vector_sort
(
usersPanel
->
items
);
ListItem
*
allUsers
=
ListItem_new
(
"All users"
,
-
1
);
Panel_insert
(
lbu
,
0
,
(
Object
*
)
allUsers
);
Panel_insert
(
usersPanel
,
0
,
(
Object
*
)
allUsers
);
char
*
fuFunctions
[
2
]
=
{
"Show "
,
"Cancel "
};
ListItem
*
picked
=
(
ListItem
*
)
pickFromList
(
lb
,
lbu
,
20
,
headerHeight
,
fuFunctions
,
defaultBar
);
ListItem
*
picked
=
(
ListItem
*
)
pickFromList
(
panel
,
usersPanel
,
20
,
headerHeight
,
fuFunctions
,
defaultBar
);
if
(
picked
)
{
if
(
picked
==
allUsers
)
{
userOnly
=
false
;
...
...
@@ -530,20 +530,20 @@ int main(int argc, char** argv) {
case
KEY_F
(
9
):
case
'k'
:
{
if
(
!
lbk
)
{
lbk
=
(
Panel
*
)
SignalsPanel_new
(
0
,
0
,
0
,
0
);
if
(
!
killPanel
)
{
killPanel
=
(
Panel
*
)
SignalsPanel_new
(
0
,
0
,
0
,
0
);
}
SignalsPanel_reset
((
SignalsPanel
*
)
lbk
);
SignalsPanel_reset
((
SignalsPanel
*
)
killPanel
);
char
*
fuFunctions
[
2
]
=
{
"Send "
,
"Cancel "
};
Signal
*
signal
=
(
Signal
*
)
pickFromList
(
lb
,
lbk
,
15
,
headerHeight
,
fuFunctions
,
defaultBar
);
Signal
*
signal
=
(
Signal
*
)
pickFromList
(
panel
,
killPanel
,
15
,
headerHeight
,
fuFunctions
,
defaultBar
);
if
(
signal
)
{
if
(
signal
->
number
!=
0
)
{
Panel_setHeader
(
l
b
,
"Sending..."
);
Panel_draw
(
l
b
,
true
);
Panel_setHeader
(
pane
l
,
"Sending..."
);
Panel_draw
(
pane
l
,
true
);
refresh
();
bool
anyTagged
=
false
;
for
(
int
i
=
0
;
i
<
Panel_getSize
(
l
b
);
i
++
)
{
Process
*
p
=
(
Process
*
)
Panel_get
(
l
b
,
i
);
for
(
int
i
=
0
;
i
<
Panel_getSize
(
pane
l
);
i
++
)
{
Process
*
p
=
(
Process
*
)
Panel_get
(
pane
l
,
i
);
if
(
p
->
tag
)
{
Process_sendSignal
(
p
,
signal
->
number
);
Process_toggleTag
(
p
);
...
...
@@ -551,13 +551,13 @@ int main(int argc, char** argv) {
}
}
if
(
!
anyTagged
)
{
Process
*
p
=
(
Process
*
)
Panel_getSelected
(
l
b
);
Process
*
p
=
(
Process
*
)
Panel_getSelected
(
pane
l
);
Process_sendSignal
(
p
,
signal
->
number
);
}
napms
(
500
);
}
}
Panel_setRichHeader
(
l
b
,
ProcessList_printHeader
(
pl
));
Panel_setRichHeader
(
pane
l
,
ProcessList_printHeader
(
pl
));
refreshTimeout
=
0
;
break
;
}
...
...
@@ -572,25 +572,25 @@ int main(int argc, char** argv) {
case
'.'
:
case
KEY_F
(
6
):
{
Panel
*
lbf
=
Panel_new
(
0
,
0
,
0
,
0
,
LISTITEM_CLASS
,
true
);
Panel_setHeader
(
lbf
,
"Sort by"
);
Panel
*
sortPanel
=
Panel_new
(
0
,
0
,
0
,
0
,
LISTITEM_CLASS
,
true
);
Panel_setHeader
(
sortPanel
,
"Sort by"
);
char
*
fuFunctions
[
2
]
=
{
"Sort "
,
"Cancel "
};
ProcessField
*
fields
=
pl
->
fields
;
for
(
int
i
=
0
;
fields
[
i
];
i
++
)
{
char
*
name
=
String_trim
(
Process_printField
(
fields
[
i
]));
Panel_add
(
lbf
,
(
Object
*
)
ListItem_new
(
name
,
fields
[
i
]));
Panel_add
(
sortPanel
,
(
Object
*
)
ListItem_new
(
name
,
fields
[
i
]));
if
(
fields
[
i
]
==
pl
->
sortKey
)
Panel_setSelected
(
lbf
,
i
);
Panel_setSelected
(
sortPanel
,
i
);
free
(
name
);
}
ListItem
*
field
=
(
ListItem
*
)
pickFromList
(
lb
,
lbf
,
15
,
headerHeight
,
fuFunctions
,
defaultBar
);
ListItem
*
field
=
(
ListItem
*
)
pickFromList
(
panel
,
sortPanel
,
15
,
headerHeight
,
fuFunctions
,
defaultBar
);
if
(
field
)
{
pl
->
treeView
=
false
;
settings
->
changed
=
true
;
pl
->
sortKey
=
field
->
key
;
}
((
Object
*
)
lbf
)
->
delete
((
Object
*
)
lbf
);
Panel_setRichHeader
(
l
b
,
ProcessList_printHeader
(
pl
));
((
Object
*
)
sortPanel
)
->
delete
((
Object
*
)
sortPanel
);
Panel_setRichHeader
(
pane
l
,
ProcessList_printHeader
(
pl
));
refreshTimeout
=
0
;
break
;
}
...
...
@@ -607,14 +607,14 @@ int main(int argc, char** argv) {
case
'='
:
case
'+'
:
{
doRefresh
=
changePriority
(
l
b
,
1
);
doRefresh
=
changePriority
(
pane
l
,
1
);
break
;
}
case
KEY_F
(
7
):
case
']'
:
case
'-'
:
{
doRefresh
=
changePriority
(
l
b
,
-
1
);
doRefresh
=
changePriority
(
pane
l
,
-
1
);
break
;
}
case
KEY_F
(
3
):
...
...
@@ -641,7 +641,7 @@ int main(int argc, char** argv) {
default:
doRefresh
=
false
;
refreshTimeout
=
resetRefreshTimeout
;
Panel_onKey
(
l
b
,
ch
);
Panel_onKey
(
pane
l
,
ch
);
break
;
}
follow
=
false
;
...
...
@@ -658,9 +658,9 @@ int main(int argc, char** argv) {
ProcessList_delete
(
pl
);
FunctionBar_delete
((
Object
*
)
searchBar
);
FunctionBar_delete
((
Object
*
)
defaultBar
);
((
Object
*
)
l
b
)
->
delete
((
Object
*
)
l
b
);
if
(
lbk
)
((
Object
*
)
lbk
)
->
delete
((
Object
*
)
lbk
);
((
Object
*
)
pane
l
)
->
delete
((
Object
*
)
pane
l
);
if
(
killPanel
)
((
Object
*
)
killPanel
)
->
delete
((
Object
*
)
killPanel
);
UsersTable_delete
(
ut
);
Settings_delete
(
settings
);
debug_done
();
...
...
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