Commit 7ca10817 authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Mega-commit with features and tweaks for 1.0:

* Performance improvements
* Support for splitting CPU meters into two or four columns
  (thanks to Wim Heirman)
* Switch from PLPA, which is now deprecated, to HWLOC.
* Bring back support for native Linux sched_setaffinity,
  so we don't have to use HWLOC where we don't need to.
* Support for typing in user names and column fields in selection panels.
parent 38856488
...@@ -193,44 +193,11 @@ static bool changePriority(Panel* panel, int delta) { ...@@ -193,44 +193,11 @@ static bool changePriority(Panel* panel, int delta) {
return anyTagged; return anyTagged;
} }
static HandlerResult pickWithEnter(Panel* panel, int ch) {
int size = Panel_size(panel);
if (isalnum(ch)) {
int len = strlen(panel->eventHandlerBuffer);
if (len < 99) {
panel->eventHandlerBuffer[len] = ch;
panel->eventHandlerBuffer[len+1] = '\0';
}
for (int try = 0; try < 2; try++) {
len = strlen(panel->eventHandlerBuffer);
for (int i = 0; i < size; i++) {
char* cur = ((ListItem*) Panel_get(panel, i))->value;
while (*cur == ' ') cur++;
if (strncasecmp(cur, panel->eventHandlerBuffer, len) == 0) {
Panel_setSelected(panel, i);
return HANDLED;
}
}
panel->eventHandlerBuffer[0] = ch;
panel->eventHandlerBuffer[1] = '\0';
}
return HANDLED;
} else if (ch != ERR) {
panel->eventHandlerBuffer[0] = '\0';
}
if (ch == 13) {
return BREAK_LOOP;
}
return IGNORED;
}
static Object* pickFromVector(Panel* panel, Panel* list, int x, int y, const char** keyLabels, FunctionBar* prevBar, Header* header) { static Object* pickFromVector(Panel* panel, Panel* list, int x, int y, const char** keyLabels, FunctionBar* prevBar, Header* header) {
const char* fuKeys[] = {"Enter", "Esc", NULL}; const char* fuKeys[] = {"Enter", "Esc", NULL};
int fuEvents[] = {13, 27}; int fuEvents[] = {13, 27};
list->eventHandlerBuffer = calloc(100, 1);
if (!list->eventHandler) if (!list->eventHandler)
Panel_setEventHandler(list, pickWithEnter); Panel_setEventHandler(list, Panel_selectByTyping);
ScreenManager* scr = ScreenManager_new(0, y, 0, -1, HORIZONTAL, header, false); ScreenManager* scr = ScreenManager_new(0, y, 0, -1, HORIZONTAL, header, false);
ScreenManager_add(scr, list, FunctionBar_new(keyLabels, fuKeys, fuEvents), x - 1); ScreenManager_add(scr, list, FunctionBar_new(keyLabels, fuKeys, fuEvents), x - 1);
ScreenManager_add(scr, panel, NULL, -1); ScreenManager_add(scr, panel, NULL, -1);
...@@ -238,8 +205,6 @@ static Object* pickFromVector(Panel* panel, Panel* list, int x, int y, const cha ...@@ -238,8 +205,6 @@ static Object* pickFromVector(Panel* panel, Panel* list, int x, int y, const cha
int ch; int ch;
ScreenManager_run(scr, &panelFocus, &ch); ScreenManager_run(scr, &panelFocus, &ch);
ScreenManager_delete(scr); ScreenManager_delete(scr);
free(list->eventHandlerBuffer);
list->eventHandlerBuffer = NULL;
Panel_move(panel, 0, y); Panel_move(panel, 0, y);
Panel_resize(panel, COLS, LINES-y-1); Panel_resize(panel, COLS, LINES-y-1);
FunctionBar_draw(prevBar, NULL); FunctionBar_draw(prevBar, NULL);
...@@ -383,7 +348,7 @@ int main(int argc, char** argv) { ...@@ -383,7 +348,7 @@ int main(int argc, char** argv) {
Process_getMaxPid(); Process_getMaxPid();
Header* header = Header_new(pl); Header* header = Header_new(pl);
settings = Settings_new(pl, header); settings = Settings_new(pl, header, pl->cpuCount);
int headerHeight = Header_calculateHeight(header); int headerHeight = Header_calculateHeight(header);
// FIXME: move delay code to settings // FIXME: move delay code to settings
...@@ -750,7 +715,7 @@ int main(int argc, char** argv) { ...@@ -750,7 +715,7 @@ int main(int argc, char** argv) {
Panel* usersPanel = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true, ListItem_compare); Panel* usersPanel = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true, ListItem_compare);
Panel_setHeader(usersPanel, "Show processes of:"); Panel_setHeader(usersPanel, "Show processes of:");
UsersTable_foreach(ut, addUserToVector, usersPanel); UsersTable_foreach(ut, addUserToVector, usersPanel);
Vector_sort(usersPanel->items); Vector_insertionSort(usersPanel->items);
ListItem* allUsers = ListItem_new("All users", -1); ListItem* allUsers = ListItem_new("All users", -1);
Panel_insert(usersPanel, 0, (Object*) allUsers); Panel_insert(usersPanel, 0, (Object*) allUsers);
const char* fuFunctions[] = {"Show ", "Cancel ", NULL}; const char* fuFunctions[] = {"Show ", "Cancel ", NULL};
...@@ -808,7 +773,7 @@ int main(int argc, char** argv) { ...@@ -808,7 +773,7 @@ int main(int argc, char** argv) {
refreshTimeout = 0; refreshTimeout = 0;
break; break;
} }
#ifdef HAVE_HWLOC #if (HAVE_HWLOC || HAVE_NATIVE_AFFINITY)
case 'a': case 'a':
{ {
if (pl->cpuCount == 1) if (pl->cpuCount == 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment