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