aboutsummaryrefslogtreecommitdiffstats
path: root/Action.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2020-08-27 07:48:10 +0200
committerDaniel Lange <DLange@git.local>2020-08-27 07:48:10 +0200
commitf3147ea2d1598914c2db53e8cfb34c8ff81e2ff4 (patch)
tree3ee82b2af2ab3d38b6e4b07f3994516aac72f742 /Action.c
parentdf568a576f7b44ac5a2b9b7222c7f39d9932f626 (diff)
downloaddebian_htop-f3147ea2d1598914c2db53e8cfb34c8ff81e2ff4.tar.gz
debian_htop-f3147ea2d1598914c2db53e8cfb34c8ff81e2ff4.tar.bz2
debian_htop-f3147ea2d1598914c2db53e8cfb34c8ff81e2ff4.zip
New upstream version 3.0.0upstream/3.0.0
Diffstat (limited to 'Action.c')
-rw-r--r--Action.c69
1 files changed, 44 insertions, 25 deletions
diff --git a/Action.c b/Action.c
index 518d103..d9cc5ab 100644
--- a/Action.c
+++ b/Action.c
@@ -62,11 +62,11 @@ typedef struct State_ {
}*/
-Object* Action_pickFromVector(State* st, Panel* list, int x) {
+Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess) {
Panel* panel = st->panel;
Header* header = st->header;
Settings* settings = st->settings;
-
+
int y = panel->y;
ScreenManager* scr = ScreenManager_new(0, header->height, 0, -1, HORIZONTAL, header, settings, false);
scr->allowFocusChange = false;
@@ -75,8 +75,8 @@ Object* Action_pickFromVector(State* st, Panel* list, int x) {
Panel* panelFocus;
int ch;
bool unfollow = false;
- int pid = MainPanel_selectedPid((MainPanel*)panel);
- if (header->pl->following == -1) {
+ int pid = followProcess ? MainPanel_selectedPid((MainPanel*)panel) : -1;
+ if (followProcess && header->pl->following == -1) {
header->pl->following = pid;
unfollow = true;
}
@@ -88,11 +88,16 @@ Object* Action_pickFromVector(State* st, Panel* list, int x) {
Panel_move(panel, 0, y);
Panel_resize(panel, COLS, LINES-y-1);
if (panelFocus == list && ch == 13) {
- Process* selected = (Process*)Panel_getSelected(panel);
- if (selected && selected->pid == pid)
+ if (followProcess) {
+ Process* selected = (Process*)Panel_getSelected(panel);
+ if (selected && selected->pid == pid)
+ return Panel_getSelected(list);
+ else
+ beep();
+ } else {
return Panel_getSelected(list);
- else
- beep();
+ }
+
}
return NULL;
}
@@ -189,7 +194,7 @@ static Htop_Reaction sortBy(State* st) {
Panel_setSelected(sortPanel, i);
free(name);
}
- ListItem* field = (ListItem*) Action_pickFromVector(st, sortPanel, 15);
+ ListItem* field = (ListItem*) Action_pickFromVector(st, sortPanel, 15, false);
if (field) {
reaction |= Action_setSortKey(st->settings, field->key);
}
@@ -248,10 +253,21 @@ static Htop_Reaction actionIncFilter(State* st) {
}
static Htop_Reaction actionIncSearch(State* st) {
+ IncSet_reset(((MainPanel*)st->panel)->inc, INC_SEARCH);
IncSet_activate(((MainPanel*)st->panel)->inc, INC_SEARCH, st->panel);
return HTOP_REFRESH | HTOP_KEEP_FOLLOWING;
}
+static Htop_Reaction actionIncNext(State* st) {
+ IncSet_next(((MainPanel*)st->panel)->inc, INC_SEARCH, st->panel, (IncMode_GetPanelValue) MainPanel_getValue);
+ return HTOP_REFRESH | HTOP_KEEP_FOLLOWING;
+}
+
+static Htop_Reaction actionIncPrev(State* st) {
+ IncSet_prev(((MainPanel*)st->panel)->inc, INC_SEARCH, st->panel, (IncMode_GetPanelValue) MainPanel_getValue);
+ return HTOP_REFRESH | HTOP_KEEP_FOLLOWING;
+}
+
static Htop_Reaction actionHigherPriority(State* st) {
bool changed = changePriority((MainPanel*)st->panel, -1);
return changed ? HTOP_REFRESH : HTOP_OK;
@@ -297,20 +313,22 @@ static Htop_Reaction actionSetAffinity(State* st) {
return HTOP_OK;
#if (HAVE_LIBHWLOC || HAVE_LINUX_AFFINITY)
Panel* panel = st->panel;
-
+
Process* p = (Process*) Panel_getSelected(panel);
if (!p) return HTOP_OK;
- Affinity* affinity = Affinity_get(p, st->pl);
- if (!affinity) return HTOP_OK;
- Panel* affinityPanel = AffinityPanel_new(st->pl, affinity);
- Affinity_delete(affinity);
-
- void* set = Action_pickFromVector(st, affinityPanel, 15);
+ Affinity* affinity1 = Affinity_get(p, st->pl);
+ if (!affinity1) return HTOP_OK;
+ int width;
+ Panel* affinityPanel = AffinityPanel_new(st->pl, affinity1, &width);
+ width += 1; /* we add a gap between the panels */
+ Affinity_delete(affinity1);
+
+ void* set = Action_pickFromVector(st, affinityPanel, width, true);
if (set) {
- Affinity* affinity = AffinityPanel_getAffinity(affinityPanel, st->pl);
- bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (Arg){ .v = affinity }, NULL);
+ Affinity* affinity2 = AffinityPanel_getAffinity(affinityPanel, st->pl);
+ bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (Arg){ .v = affinity2 }, NULL);
if (!ok) beep();
- Affinity_delete(affinity);
+ Affinity_delete(affinity2);
}
Panel_delete((Object*)affinityPanel);
#endif
@@ -319,7 +337,7 @@ static Htop_Reaction actionSetAffinity(State* st) {
static Htop_Reaction actionKill(State* st) {
Panel* signalsPanel = (Panel*) SignalsPanel_new();
- ListItem* sgn = (ListItem*) Action_pickFromVector(st, signalsPanel, 15);
+ ListItem* sgn = (ListItem*) Action_pickFromVector(st, signalsPanel, 15, true);
if (sgn) {
if (sgn->key != 0) {
Panel_setHeader(st->panel, "Sending...");
@@ -340,7 +358,7 @@ static Htop_Reaction actionFilterByUser(State* st) {
Vector_insertionSort(usersPanel->items);
ListItem* allUsers = ListItem_new("All users", -1);
Panel_insert(usersPanel, 0, (Object*) allUsers);
- ListItem* picked = (ListItem*) Action_pickFromVector(st, usersPanel, 20);
+ ListItem* picked = (ListItem*) Action_pickFromVector(st, usersPanel, 20, false);
if (picked) {
if (picked == allUsers) {
st->pl->userId = -1;
@@ -463,7 +481,7 @@ static Htop_Reaction actionHelp(State* st) {
if (settings->detailedCPUTime) {
addattrstr(CRT_colors[CPU_NICE_TEXT], "low"); addstr("/");
addattrstr(CRT_colors[CPU_NORMAL], "normal"); addstr("/");
- addattrstr(CRT_colors[CPU_KERNEL], "kernel"); addstr("/");
+ addattrstr(CRT_colors[CPU_SYSTEM], "kernel"); addstr("/");
addattrstr(CRT_colors[CPU_IRQ], "irq"); addstr("/");
addattrstr(CRT_colors[CPU_SOFTIRQ], "soft-irq"); addstr("/");
addattrstr(CRT_colors[CPU_STEAL], "steal"); addstr("/");
@@ -473,8 +491,8 @@ static Htop_Reaction actionHelp(State* st) {
} else {
addattrstr(CRT_colors[CPU_NICE_TEXT], "low-priority"); addstr("/");
addattrstr(CRT_colors[CPU_NORMAL], "normal"); addstr("/");
- addattrstr(CRT_colors[CPU_KERNEL], "kernel"); addstr("/");
- addattrstr(CRT_colors[CPU_STEAL], "virtualiz");
+ addattrstr(CRT_colors[CPU_SYSTEM], "kernel"); addstr("/");
+ addattrstr(CRT_colors[CPU_GUEST], "virtualiz");
addattrstr(CRT_colors[BAR_SHADOW], " used%");
}
addattrstr(CRT_colors[BAR_BORDER], "]");
@@ -559,6 +577,8 @@ void Action_setBindings(Htop_Action* keys) {
keys['\\'] = actionIncFilter;
keys[KEY_F(3)] = actionIncSearch;
keys['/'] = actionIncSearch;
+ keys['n'] = actionIncNext;
+ keys['N'] = actionIncPrev;
keys[']'] = actionHigherPriority;
keys[KEY_F(7)] = actionHigherPriority;
@@ -597,4 +617,3 @@ void Action_setBindings(Htop_Action* keys) {
keys['c'] = actionTagAllChildren;
keys['e'] = actionShowEnvScreen;
}
-

© 2014-2024 Faster IT GmbH | imprint | privacy policy