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
c2cdcd0c
Commit
c2cdcd0c
authored
May 30, 2006
by
Hisham Muhammad
Browse files
Rename ListBox to Panel, matching dit.
parent
a853faaa
Changes
26
Hide whitespace changes
Inline
Side-by-side
SignalsListBox.c
View file @
c2cdcd0c
#include "Signals
ListBox
.h"
#include "
ListBox
.h"
#include "Signals
Panel
.h"
#include "
Panel
.h"
#include "SignalItem.h"
#include "RichString.h"
...
...
@@ -11,56 +11,56 @@
/*{
typedef struct Signals
ListBox
_ {
ListBox
super;
typedef struct Signals
Panel
_ {
Panel
super;
int state;
Signal** signals;
} Signals
ListBox
;
} Signals
Panel
;
}*/
Signals
ListBox
*
Signals
ListBox
_new
(
int
x
,
int
y
,
int
w
,
int
h
)
{
Signals
ListBox
*
this
=
(
Signals
ListBox
*
)
malloc
(
sizeof
(
Signals
ListBox
));
ListBox
*
super
=
(
ListBox
*
)
this
;
ListBox
_init
(
super
,
x
,
y
,
w
,
h
,
SIGNAL_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
Signals
ListBox
_delete
;
Signals
Panel
*
Signals
Panel
_new
(
int
x
,
int
y
,
int
w
,
int
h
)
{
Signals
Panel
*
this
=
(
Signals
Panel
*
)
malloc
(
sizeof
(
Signals
Panel
));
Panel
*
super
=
(
Panel
*
)
this
;
Panel
_init
(
super
,
x
,
y
,
w
,
h
,
SIGNAL_CLASS
,
true
);
((
Object
*
)
this
)
->
delete
=
Signals
Panel
_delete
;
this
->
signals
=
Signal_getSignalTable
();
super
->
eventHandler
=
Signals
ListBox
_EventHandler
;
super
->
eventHandler
=
Signals
Panel
_EventHandler
;
int
sigCount
=
Signal_getSignalCount
();
for
(
int
i
=
0
;
i
<
sigCount
;
i
++
)
ListBox
_set
(
super
,
i
,
(
Object
*
)
this
->
signals
[
i
]);
Signals
ListBox
_reset
(
this
);
Panel
_set
(
super
,
i
,
(
Object
*
)
this
->
signals
[
i
]);
Signals
Panel
_reset
(
this
);
return
this
;
}
void
Signals
ListBox
_delete
(
Object
*
object
)
{
ListBox
*
super
=
(
ListBox
*
)
object
;
Signals
ListBox
*
this
=
(
Signals
ListBox
*
)
object
;
ListBox
_done
(
super
);
void
Signals
Panel
_delete
(
Object
*
object
)
{
Panel
*
super
=
(
Panel
*
)
object
;
Signals
Panel
*
this
=
(
Signals
Panel
*
)
object
;
Panel
_done
(
super
);
free
(
this
->
signals
);
free
(
this
);
}
void
Signals
ListBox
_reset
(
Signals
ListBox
*
this
)
{
ListBox
*
super
=
(
ListBox
*
)
this
;
void
Signals
Panel
_reset
(
Signals
Panel
*
this
)
{
Panel
*
super
=
(
Panel
*
)
this
;
ListBox
_setHeader
(
super
,
"Send signal:"
);
ListBox
_setSelected
(
super
,
16
);
// 16th item is SIGTERM
Panel
_setHeader
(
super
,
"Send signal:"
);
Panel
_setSelected
(
super
,
16
);
// 16th item is SIGTERM
this
->
state
=
0
;
}
HandlerResult
Signals
ListBox
_EventHandler
(
ListBox
*
super
,
int
ch
)
{
Signals
ListBox
*
this
=
(
Signals
ListBox
*
)
super
;
HandlerResult
Signals
Panel
_EventHandler
(
Panel
*
super
,
int
ch
)
{
Signals
Panel
*
this
=
(
Signals
Panel
*
)
super
;
int
size
=
ListBox
_getSize
(
super
);
int
size
=
Panel
_getSize
(
super
);
if
(
ch
<=
255
&&
isdigit
(
ch
))
{
int
signal
=
ch
-
48
+
this
->
state
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
if
(((
Signal
*
)
ListBox
_get
(
super
,
i
))
->
number
==
signal
)
{
ListBox
_setSelected
(
super
,
i
);
if
(((
Signal
*
)
Panel
_get
(
super
,
i
))
->
number
==
signal
)
{
Panel
_setSelected
(
super
,
i
);
break
;
}
this
->
state
=
signal
*
10
;
...
...
SignalsListBox.h
View file @
c2cdcd0c
/* Do not edit this file. It was automatically genarated. */
#ifndef HEADER_Signals
ListBox
#define HEADER_Signals
ListBox
#ifndef HEADER_Signals
Panel
#define HEADER_Signals
Panel
#include "
ListBox
.h"
#include "
Panel
.h"
#include "SignalItem.h"
#include "RichString.h"
...
...
@@ -13,20 +13,20 @@
#include <ctype.h>
typedef
struct
Signals
ListBox
_
{
ListBox
super
;
typedef
struct
Signals
Panel
_
{
Panel
super
;
int
state
;
Signal
**
signals
;
}
Signals
ListBox
;
}
Signals
Panel
;
Signals
ListBox
*
Signals
ListBox
_new
(
int
x
,
int
y
,
int
w
,
int
h
);
Signals
Panel
*
Signals
Panel
_new
(
int
x
,
int
y
,
int
w
,
int
h
);
void
Signals
ListBox
_delete
(
Object
*
object
);
void
Signals
Panel
_delete
(
Object
*
object
);
void
Signals
ListBox
_reset
(
Signals
ListBox
*
this
);
void
Signals
Panel
_reset
(
Signals
Panel
*
this
);
HandlerResult
Signals
ListBox
_EventHandler
(
ListBox
*
super
,
int
ch
);
HandlerResult
Signals
Panel
_EventHandler
(
Panel
*
super
,
int
ch
);
#endif
TraceScreen.c
View file @
c2cdcd0c
...
...
@@ -18,14 +18,14 @@ in the source distribution for its full text.
#include "ProcessList.h"
#include "Process.h"
#include "ListItem.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "FunctionBar.h"
/*{
typedef struct TraceScreen_ {
Process* process;
ListBox
* display;
Panel
* display;
FunctionBar* bar;
bool tracing;
} TraceScreen;
...
...
@@ -44,14 +44,14 @@ static int tbEvents[3] = {KEY_F(4), KEY_F(5), 27};
TraceScreen
*
TraceScreen_new
(
Process
*
process
)
{
TraceScreen
*
this
=
(
TraceScreen
*
)
malloc
(
sizeof
(
TraceScreen
));
this
->
process
=
process
;
this
->
display
=
ListBox
_new
(
0
,
1
,
COLS
,
LINES
-
2
,
LISTITEM_CLASS
,
true
);
this
->
display
=
Panel
_new
(
0
,
1
,
COLS
,
LINES
-
2
,
LISTITEM_CLASS
,
true
);
this
->
bar
=
FunctionBar_new
(
3
,
tbFunctions
,
tbKeys
,
tbEvents
);
this
->
tracing
=
true
;
return
this
;
}
void
TraceScreen_delete
(
TraceScreen
*
this
)
{
ListBox
_delete
((
Object
*
)
this
->
display
);
Panel
_delete
((
Object
*
)
this
->
display
);
FunctionBar_delete
((
Object
*
)
this
->
bar
);
free
(
this
);
}
...
...
@@ -81,7 +81,7 @@ void TraceScreen_run(TraceScreen* this) {
}
fcntl
(
fdpair
[
0
],
F_SETFL
,
O_NONBLOCK
);
FILE
*
strace
=
fdopen
(
fdpair
[
0
],
"r"
);
ListBox
*
lb
=
this
->
display
;
Panel
*
lb
=
this
->
display
;
int
fd_strace
=
fileno
(
strace
);
TraceScreen_draw
(
this
);
CRT_disableDelay
();
...
...
@@ -105,23 +105,23 @@ void TraceScreen_run(TraceScreen* this) {
if
(
buffer
[
i
]
==
'\n'
)
{
buffer
[
i
]
=
'\0'
;
if
(
contLine
)
{
ListItem_append
((
ListItem
*
)
ListBox
_get
(
lb
,
ListBox
_getSize
(
lb
)
-
1
),
line
);
ListItem_append
((
ListItem
*
)
Panel
_get
(
lb
,
Panel
_getSize
(
lb
)
-
1
),
line
);
contLine
=
false
;
}
else
{
ListBox
_add
(
lb
,
(
Object
*
)
ListItem_new
(
line
,
0
));
Panel
_add
(
lb
,
(
Object
*
)
ListItem_new
(
line
,
0
));
}
line
=
buffer
+
i
+
1
;
}
}
if
(
line
<
buffer
+
nread
)
{
ListBox
_add
(
lb
,
(
Object
*
)
ListItem_new
(
line
,
0
));
Panel
_add
(
lb
,
(
Object
*
)
ListItem_new
(
line
,
0
));
buffer
[
nread
]
=
'\0'
;
contLine
=
true
;
}
if
(
follow
)
ListBox
_setSelected
(
lb
,
ListBox
_getSize
(
lb
)
-
1
);
ListBox
_draw
(
lb
,
true
);
Panel
_setSelected
(
lb
,
Panel
_getSize
(
lb
)
-
1
);
Panel
_draw
(
lb
,
true
);
}
int
ch
=
getch
();
if
(
ch
==
KEY_MOUSE
)
{
...
...
@@ -129,7 +129,7 @@ void TraceScreen_run(TraceScreen* this) {
int
ok
=
getmouse
(
&
mevent
);
if
(
ok
==
OK
)
if
(
mevent
.
y
>=
lb
->
y
&&
mevent
.
y
<
LINES
-
1
)
{
ListBox
_setSelected
(
lb
,
mevent
.
y
-
lb
->
y
+
lb
->
scrollV
);
Panel
_setSelected
(
lb
,
mevent
.
y
-
lb
->
y
+
lb
->
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
)
ListBox
_setSelected
(
lb
,
ListBox
_getSize
(
lb
)
-
1
);
Panel
_setSelected
(
lb
,
Panel
_getSize
(
lb
)
-
1
);
break
;
case
'q'
:
case
27
:
looping
=
false
;
break
;
case
KEY_RESIZE
:
ListBox
_resize
(
lb
,
COLS
,
LINES
-
2
);
Panel
_resize
(
lb
,
COLS
,
LINES
-
2
);
TraceScreen_draw
(
this
);
break
;
default:
follow
=
false
;
ListBox
_onKey
(
lb
,
ch
);
Panel
_onKey
(
lb
,
ch
);
}
ListBox
_draw
(
lb
,
true
);
Panel
_draw
(
lb
,
true
);
}
kill
(
child
,
SIGTERM
);
waitpid
(
child
,
NULL
,
0
);
...
...
TraceScreen.h
View file @
c2cdcd0c
...
...
@@ -15,12 +15,12 @@ in the source distribution for its full text.
#include <fcntl.h>
#include "ProcessList.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "FunctionBar.h"
typedef
struct
TraceScreen_
{
Process
*
process
;
ListBox
*
display
;
Panel
*
display
;
FunctionBar
*
bar
;
bool
tracing
;
}
TraceScreen
;
...
...
htop.c
View file @
c2cdcd0c
...
...
@@ -14,7 +14,7 @@ in the source distribution for its full text.
#include "ProcessList.h"
#include "CRT.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "UsersTable.h"
#include "SignalItem.h"
#include "RichString.h"
...
...
@@ -22,8 +22,8 @@ in the source distribution for its full text.
#include "ScreenManager.h"
#include "FunctionBar.h"
#include "ListItem.h"
#include "Categories
ListBox
.h"
#include "Signals
ListBox
.h"
#include "Categories
Panel
.h"
#include "Signals
Panel
.h"
#include "TraceScreen.h"
#include "config.h"
...
...
@@ -126,62 +126,62 @@ void showHelp() {
static
void
Setup_run
(
Settings
*
settings
,
int
headerHeight
)
{
ScreenManager
*
scr
=
ScreenManager_new
(
0
,
headerHeight
,
0
,
-
1
,
HORIZONTAL
,
true
);
Categories
ListBox
*
lbCategories
=
Categories
ListBox
_new
(
settings
,
scr
);
ScreenManager_add
(
scr
,
(
ListBox
*
)
lbCategories
,
NULL
,
16
);
Categories
ListBox
_makeMetersPage
(
lbCategories
);
ListBox
*
lbFocus
;
Categories
Panel
*
lbCategories
=
Categories
Panel
_new
(
settings
,
scr
);
ScreenManager_add
(
scr
,
(
Panel
*
)
lbCategories
,
NULL
,
16
);
Categories
Panel
_makeMetersPage
(
lbCategories
);
Panel
*
lbFocus
;
int
ch
;
ScreenManager_run
(
scr
,
&
lbFocus
,
&
ch
);
ScreenManager_delete
(
scr
);
}
static
bool
changePriority
(
ListBox
*
lb
,
int
delta
)
{
static
bool
changePriority
(
Panel
*
lb
,
int
delta
)
{
bool
anyTagged
=
false
;
for
(
int
i
=
0
;
i
<
ListBox
_getSize
(
lb
);
i
++
)
{
Process
*
p
=
(
Process
*
)
ListBox
_get
(
lb
,
i
);
for
(
int
i
=
0
;
i
<
Panel
_getSize
(
lb
);
i
++
)
{
Process
*
p
=
(
Process
*
)
Panel
_get
(
lb
,
i
);
if
(
p
->
tag
)
{
Process_setPriority
(
p
,
p
->
nice
+
delta
);
anyTagged
=
true
;
}
}
if
(
!
anyTagged
)
{
Process
*
p
=
(
Process
*
)
ListBox
_getSelected
(
lb
);
Process
*
p
=
(
Process
*
)
Panel
_getSelected
(
lb
);
Process_setPriority
(
p
,
p
->
nice
+
delta
);
}
return
anyTagged
;
}
static
HandlerResult
pickWithEnter
(
ListBox
*
lb
,
int
ch
)
{
static
HandlerResult
pickWithEnter
(
Panel
*
lb
,
int
ch
)
{
if
(
ch
==
13
)
return
BREAK_LOOP
;
return
IGNORED
;
}
static
Object
*
pickFromList
(
ListBox
*
lb
,
ListBox
*
list
,
int
x
,
int
y
,
char
**
keyLabels
,
FunctionBar
*
prevBar
)
{
static
Object
*
pickFromList
(
Panel
*
lb
,
Panel
*
list
,
int
x
,
int
y
,
char
**
keyLabels
,
FunctionBar
*
prevBar
)
{
char
*
fuKeys
[
2
]
=
{
"Enter"
,
"Esc"
};
int
fuEvents
[
2
]
=
{
13
,
27
};
if
(
!
lb
->
eventHandler
)
ListBox
_setEventHandler
(
list
,
pickWithEnter
);
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
,
lb
,
NULL
,
-
1
);
ListBox
*
lbFocus
;
Panel
*
lbFocus
;
int
ch
;
ScreenManager_run
(
scr
,
&
lbFocus
,
&
ch
);
ScreenManager_delete
(
scr
);
ListBox
_move
(
lb
,
0
,
y
);
ListBox
_resize
(
lb
,
COLS
,
LINES
-
y
-
1
);
Panel
_move
(
lb
,
0
,
y
);
Panel
_resize
(
lb
,
COLS
,
LINES
-
y
-
1
);
FunctionBar_draw
(
prevBar
,
NULL
);
if
(
lbFocus
==
list
&&
ch
==
13
)
{
return
ListBox
_getSelected
(
list
);
return
Panel
_getSelected
(
list
);
}
return
NULL
;
}
void
addUserToList
(
int
key
,
void
*
userCast
,
void
*
lbCast
)
{
char
*
user
=
(
char
*
)
userCast
;
ListBox
*
lb
=
(
ListBox
*
)
lbCast
;
ListBox
_add
(
lb
,
(
Object
*
)
ListItem_new
(
user
,
key
));
Panel
*
lb
=
(
Panel
*
)
lbCast
;
Panel
_add
(
lb
,
(
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
);
}
ListBox
*
lb
;
Panel
*
lb
;
int
quit
=
0
;
int
refreshTimeout
=
0
;
int
resetRefreshTimeout
=
5
;
bool
doRefresh
=
true
;
Settings
*
settings
;
ListBox
*
lbk
=
NULL
;
Panel
*
lbk
=
NULL
;
char
incSearchBuffer
[
INCSEARCH_MAX
];
int
incSearchIndex
=
0
;
...
...
@@ -248,8 +248,8 @@ int main(int argc, char** argv) {
CRT_init
(
settings
->
delay
,
settings
->
colorScheme
);
lb
=
ListBox
_new
(
0
,
headerHeight
,
COLS
,
LINES
-
headerHeight
-
2
,
PROCESS_CLASS
,
false
);
ListBox
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
lb
=
Panel
_new
(
0
,
headerHeight
,
COLS
,
LINES
-
headerHeight
-
2
,
PROCESS_CLASS
,
false
);
Panel
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
char
*
searchFunctions
[
3
]
=
{
"Next "
,
"Exit "
,
" Search: "
};
char
*
searchKeys
[
3
]
=
{
"F3"
,
"Esc"
,
" "
};
...
...
@@ -285,7 +285,7 @@ int main(int argc, char** argv) {
if
(
doRefresh
)
{
incSearchIndex
=
0
;
incSearchBuffer
[
0
]
=
0
;
int
currPos
=
ListBox
_getSelectedIndex
(
lb
);
int
currPos
=
Panel
_getSelectedIndex
(
lb
);
int
currPid
=
0
;
int
currScrollV
=
lb
->
scrollV
;
if
(
follow
)
...
...
@@ -296,15 +296,15 @@ int main(int argc, char** argv) {
ProcessList_sort
(
pl
);
refreshTimeout
=
1
;
}
ListBox
_prune
(
lb
);
Panel
_prune
(
lb
);
int
size
=
ProcessList_size
(
pl
);
int
lbi
=
0
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
Process
*
p
=
ProcessList_get
(
pl
,
i
);
if
(
!
userOnly
||
(
p
->
st_uid
==
userId
))
{
ListBox
_set
(
lb
,
lbi
,
(
Object
*
)
p
);
Panel
_set
(
lb
,
lbi
,
(
Object
*
)
p
);
if
((
!
follow
&&
lbi
==
currPos
)
||
(
follow
&&
p
->
pid
==
currPid
))
{
ListBox
_setSelected
(
lb
,
lbi
);
Panel
_setSelected
(
lb
,
lbi
);
lb
->
scrollV
=
currScrollV
;
}
lbi
++
;
...
...
@@ -315,7 +315,7 @@ int main(int argc, char** argv) {
Header_draw
(
header
);
ListBox
_draw
(
lb
,
true
);
Panel
_draw
(
lb
,
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
=
ListBox
_getSelectedIndex
(
lb
);
int
here
=
Panel
_getSelectedIndex
(
lb
);
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
))
{
ListBox
_setSelected
(
lb
,
i
);
Panel
_setSelected
(
lb
,
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
))
{
ListBox
_setSelected
(
lb
,
i
);
Panel
_setSelected
(
lb
,
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
*
)
ListBox
_getSelected
(
lb
))
->
pid
!=
pid
;
i
++
)
ListBox
_setSelected
(
lb
,
i
);
for
(
int
i
=
0
;
i
<
ProcessList_size
(
pl
)
&&
((
Process
*
)
Panel
_getSelected
(
lb
))
->
pid
!=
pid
;
i
++
)
Panel
_setSelected
(
lb
,
i
);
acc
=
pid
*
10
;
if
(
acc
>
100000
)
acc
=
0
;
...
...
@@ -396,7 +396,7 @@ int main(int argc, char** argv) {
int
ok
=
getmouse
(
&
mevent
);
if
(
ok
==
OK
)
{
if
(
mevent
.
y
>=
lb
->
y
+
1
&&
mevent
.
y
<
LINES
-
1
)
{
ListBox
_setSelected
(
lb
,
mevent
.
y
-
lb
->
y
+
lb
->
scrollV
-
1
);
Panel
_setSelected
(
lb
,
mevent
.
y
-
lb
->
y
+
lb
->
scrollV
-
1
);
doRefresh
=
false
;
refreshTimeout
=
resetRefreshTimeout
;
follow
=
true
;
...
...
@@ -413,7 +413,7 @@ int main(int argc, char** argv) {
switch
(
ch
)
{
case
KEY_RESIZE
:
ListBox
_resize
(
lb
,
COLS
,
LINES
-
headerHeight
-
1
);
Panel
_resize
(
lb
,
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
;
ListBox
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
Panel
_setRichHeader
(
lb
,
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
;
ListBox
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
Panel
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
break
;
}
case
'U'
:
{
for
(
int
i
=
0
;
i
<
ListBox
_getSize
(
lb
);
i
++
)
{
Process
*
p
=
(
Process
*
)
ListBox
_get
(
lb
,
i
);
for
(
int
i
=
0
;
i
<
Panel
_getSize
(
lb
);
i
++
)
{
Process
*
p
=
(
Process
*
)
Panel
_get
(
lb
,
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
;
ListBox
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
Panel
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
break
;
}
case
KEY_F
(
1
):
...
...
@@ -472,14 +472,14 @@ int main(int argc, char** argv) {
}
case
' '
:
{
Process
*
p
=
(
Process
*
)
ListBox
_getSelected
(
lb
);
Process
*
p
=
(
Process
*
)
Panel
_getSelected
(
lb
);
Process_toggleTag
(
p
);
ListBox
_onKey
(
lb
,
KEY_DOWN
);
Panel
_onKey
(
lb
,
KEY_DOWN
);
break
;
}
case
's'
:
{
TraceScreen
*
ts
=
TraceScreen_new
((
Process
*
)
ListBox
_getSelected
(
lb
));
TraceScreen
*
ts
=
TraceScreen_new
((
Process
*
)
Panel
_getSelected
(
lb
));
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
ListBox
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
Panel
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
headerHeight
=
Header_calculateHeight
(
header
);
ListBox
_move
(
lb
,
0
,
headerHeight
);
ListBox
_resize
(
lb
,
COLS
,
LINES
-
headerHeight
-
1
);
Panel
_move
(
lb
,
0
,
headerHeight
);
Panel
_resize
(
lb
,
COLS
,
LINES
-
headerHeight
-
1
);
FunctionBar_draw
(
defaultBar
,
NULL
);
refreshTimeout
=
0
;
break
;
...
...
@@ -509,12 +509,12 @@ int main(int argc, char** argv) {
}
case
'u'
:
{
ListBox
*
lbu
=
ListBox
_new
(
0
,
0
,
0
,
0
,
LISTITEM_CLASS
,
true
);
ListBox
_setHeader
(
lbu
,
"Show processes of:"
);
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
);
ListItem
*
allUsers
=
ListItem_new
(
"All users"
,
-
1
);
ListBox
_insert
(
lbu
,
0
,
(
Object
*
)
allUsers
);
Panel
_insert
(
lbu
,
0
,
(
Object
*
)
allUsers
);
char
*
fuFunctions
[
2
]
=
{
"Show "
,
"Cancel "
};
ListItem
*
picked
=
(
ListItem
*
)
pickFromList
(
lb
,
lbu
,
20
,
headerHeight
,
fuFunctions
,
defaultBar
);
if
(
picked
)
{
...
...
@@ -531,19 +531,19 @@ int main(int argc, char** argv) {
case
'k'
:
{
if
(
!
lbk
)
{
lbk
=
(
ListBox
*
)
Signals
ListBox
_new
(
0
,
0
,
0
,
0
);
lbk
=
(
Panel
*
)
Signals
Panel
_new
(
0
,
0
,
0
,
0
);
}
Signals
ListBox
_reset
((
Signals
ListBox
*
)
lbk
);
Signals
Panel
_reset
((
Signals
Panel
*
)
lbk
);
char
*
fuFunctions
[
2
]
=
{
"Send "
,
"Cancel "
};
Signal
*
signal
=
(
Signal
*
)
pickFromList
(
lb
,
lbk
,
15
,
headerHeight
,
fuFunctions
,
defaultBar
);
if
(
signal
)
{
if
(
signal
->
number
!=
0
)
{
ListBox
_setHeader
(
lb
,
"Sending..."
);
ListBox
_draw
(
lb
,
true
);
Panel
_setHeader
(
lb
,
"Sending..."
);
Panel
_draw
(
lb
,
true
);
refresh
();
bool
anyTagged
=
false
;
for
(
int
i
=
0
;
i
<
ListBox
_getSize
(
lb
);
i
++
)
{
Process
*
p
=
(
Process
*
)
ListBox
_get
(
lb
,
i
);
for
(
int
i
=
0
;
i
<
Panel
_getSize
(
lb
);
i
++
)
{
Process
*
p
=
(
Process
*
)
Panel
_get
(
lb
,
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
*
)
ListBox
_getSelected
(
lb
);
Process
*
p
=
(
Process
*
)
Panel
_getSelected
(
lb
);
Process_sendSignal
(
p
,
signal
->
number
);
}
napms
(
500
);
}
}
ListBox
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
Panel
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
refreshTimeout
=
0
;
break
;
}
...
...
@@ -572,15 +572,15 @@ int main(int argc, char** argv) {
case
'.'
:
case
KEY_F
(
6
):
{
ListBox
*
lbf
=
ListBox
_new
(
0
,
0
,
0
,
0
,
LISTITEM_CLASS
,
true
);
ListBox
_setHeader
(
lbf
,
"Sort by"
);
Panel
*
lbf
=
Panel
_new
(
0
,
0
,
0
,
0
,
LISTITEM_CLASS
,
true
);
Panel
_setHeader
(
lbf
,
"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
]));
ListBox
_add
(
lbf
,
(
Object
*
)
ListItem_new
(
name
,
fields
[
i
]));
Panel
_add
(
lbf
,
(
Object
*
)
ListItem_new
(
name
,
fields
[
i
]));
if
(
fields
[
i
]
==
pl
->
sortKey
)
ListBox
_setSelected
(
lbf
,
i
);
Panel
_setSelected
(
lbf
,
i
);
free
(
name
);
}
ListItem
*
field
=
(
ListItem
*
)
pickFromList
(
lb
,
lbf
,
15
,
headerHeight
,
fuFunctions
,
defaultBar
);
...
...
@@ -590,7 +590,7 @@ int main(int argc, char** argv) {
pl
->
sortKey
=
field
->
key
;
}
((
Object
*
)
lbf
)
->
delete
((
Object
*
)
lbf
);
ListBox
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
Panel
_setRichHeader
(
lb
,
ProcessList_printHeader
(
pl
));
refreshTimeout
=
0
;
break
;
}
...
...
@@ -641,7 +641,7 @@ int main(int argc, char** argv) {
default:
doRefresh
=
false
;
refreshTimeout
=
resetRefreshTimeout
;
ListBox
_onKey
(
lb
,
ch
);
Panel
_onKey
(
lb
,
ch
);
break
;
}
follow
=
false
;
...
...
htop.h
View file @
c2cdcd0c
...
...
@@ -11,7 +11,7 @@ in the source distribution for its full text.
#include "ProcessList.h"
#include "CRT.h"
#include "
ListBox
.h"
#include "
Panel
.h"
#include "UsersTable.h"
#include "SignalItem.h"
#include "RichString.h"
...
...
@@ -19,8 +19,8 @@ in the source distribution for its full text.
#include "ScreenManager.h"
#include "FunctionBar.h"
#include "ListItem.h"
#include "Categories
ListBox
.h"
#include "Signals
ListBox
.h"
#include "Categories
Panel
.h"
#include "Signals
Panel
.h"
#include "config.h"
#include "debug.h"
...
...
Prev
1
2
Next
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