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
a839c3f2
Commit
a839c3f2
authored
Dec 17, 2007
by
Hisham Muhammad
Browse files
Adding affinity panel
parent
807df036
Changes
2
Hide whitespace changes
Inline
Side-by-side
AffinityPanel.c
0 → 100644
View file @
a839c3f2
#include "AffinityPanel.h"
#include "Panel.h"
#include "CheckItem.h"
#include "debug.h"
#include <assert.h>
Panel
*
AffinityPanel_new
(
int
processorCount
,
unsigned
long
mask
)
{
Panel
*
this
=
Panel_new
(
1
,
1
,
1
,
1
,
CHECKITEM_CLASS
,
true
,
ListItem_compare
);
this
->
eventHandler
=
AffinityPanel_eventHandler
;
Panel_setHeader
(
this
,
"Use CPUs:"
);
for
(
int
i
=
0
;
i
<
processorCount
;
i
++
)
{
char
number
[
10
];
snprintf
(
number
,
9
,
"%d"
,
i
+
1
);
Panel_add
(
this
,
(
Object
*
)
CheckItem_new
(
String_copy
(
number
),
NULL
,
mask
&
(
1
<<
i
)));
}
return
this
;
}
unsigned
long
AffinityPanel_getAffinity
(
Panel
*
this
)
{
int
size
=
Panel_getSize
(
this
);
unsigned
long
mask
=
0
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
if
(
CheckItem_get
((
CheckItem
*
)
Panel_get
(
this
,
i
)))
mask
=
mask
|
(
1
<<
i
);
}
return
mask
;
}
HandlerResult
AffinityPanel_eventHandler
(
Panel
*
this
,
int
ch
)
{
HandlerResult
result
=
IGNORED
;
CheckItem
*
selected
=
(
CheckItem
*
)
Panel_getSelected
(
this
);
switch
(
ch
)
{
case
' '
:
CheckItem_set
(
selected
,
!
(
CheckItem_get
(
selected
))
);
result
=
HANDLED
;
break
;
case
0x0a
:
case
0x0d
:
case
KEY_ENTER
:
result
=
BREAK_LOOP
;
break
;
}
return
result
;
}
AffinityPanel.h
0 → 100644
View file @
a839c3f2
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_AffinityPanel
#define HEADER_AffinityPanel
#include "Panel.h"
#include "CheckItem.h"
#include "debug.h"
#include <assert.h>
Panel
*
AffinityPanel_new
(
int
processorCount
,
unsigned
long
mask
);
unsigned
long
AffinityPanel_getAffinity
(
Panel
*
this
);
HandlerResult
AffinityPanel_eventHandler
(
Panel
*
this
,
int
ch
);
#endif
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