aboutsummaryrefslogtreecommitdiffstats
path: root/Action.c
diff options
context:
space:
mode:
Diffstat (limited to 'Action.c')
-rw-r--r--Action.c275
1 files changed, 155 insertions, 120 deletions
diff --git a/Action.c b/Action.c
index 88ccf6d..1d373ef 100644
--- a/Action.c
+++ b/Action.c
@@ -13,9 +13,10 @@ in the source distribution for its full text.
#include <stdbool.h>
#include <stdlib.h>
+#include "CRT.h"
#include "CategoriesPanel.h"
#include "CommandScreen.h"
-#include "CRT.h"
+#include "DynamicColumn.h"
#include "EnvScreen.h"
#include "FunctionBar.h"
#include "Hashtable.h"
@@ -34,26 +35,25 @@ in the source distribution for its full text.
#include "Vector.h"
#include "XUtils.h"
-#if (defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY))
+#if (defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY))
#include "Affinity.h"
#include "AffinityPanel.h"
#endif
Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess) {
- Panel* panel = st->panel;
+ MainPanel* mainPanel = st->mainPanel;
Header* header = st->header;
- Settings* settings = st->settings;
- int y = panel->y;
- ScreenManager* scr = ScreenManager_new(header, settings, st, false);
+ int y = ((Panel*)mainPanel)->y;
+ ScreenManager* scr = ScreenManager_new(header, st->settings, st, false);
scr->allowFocusChange = false;
- ScreenManager_add(scr, list, x - 1);
- ScreenManager_add(scr, panel, -1);
+ ScreenManager_add(scr, list, x);
+ ScreenManager_add(scr, (Panel*)mainPanel, -1);
Panel* panelFocus;
int ch;
bool unfollow = false;
- int pid = followProcess ? MainPanel_selectedPid((MainPanel*)panel) : -1;
+ int pid = followProcess ? MainPanel_selectedPid(mainPanel) : -1;
if (followProcess && header->pl->following == -1) {
header->pl->following = pid;
unfollow = true;
@@ -63,11 +63,11 @@ Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess)
header->pl->following = -1;
}
ScreenManager_delete(scr);
- Panel_move(panel, 0, y);
- Panel_resize(panel, COLS, LINES - y - 1);
+ Panel_move((Panel*)mainPanel, 0, y);
+ Panel_resize((Panel*)mainPanel, COLS, LINES - y - 1);
if (panelFocus == list && ch == 13) {
if (followProcess) {
- Process* selected = (Process*)Panel_getSelected(panel);
+ const Process* selected = (const Process*)Panel_getSelected((Panel*)mainPanel);
if (selected && selected->pid == pid)
return Panel_getSelected(list);
@@ -84,12 +84,8 @@ Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess)
static void Action_runSetup(State* st) {
ScreenManager* scr = ScreenManager_new(st->header, st->settings, st, true);
- CategoriesPanel* panelCategories = CategoriesPanel_new(scr, st->settings, st->header, st->pl);
- ScreenManager_add(scr, (Panel*) panelCategories, 16);
- CategoriesPanel_makeMetersPage(panelCategories);
- Panel* panelFocus;
- int ch;
- ScreenManager_run(scr, &panelFocus, &ch);
+ CategoriesPanel_new(scr, st->settings, st->header, st->pl);
+ ScreenManager_run(scr, NULL, NULL);
ScreenManager_delete(scr);
if (st->settings->changed) {
Header_writeBackToSettings(st->header);
@@ -141,7 +137,7 @@ static bool expandCollapse(Panel* panel) {
}
static bool collapseIntoParent(Panel* panel) {
- Process* p = (Process*) Panel_getSelected(panel);
+ const Process* p = (Process*) Panel_getSelected(panel);
if (!p)
return false;
@@ -168,16 +164,25 @@ static Htop_Reaction actionSetSortColumn(State* st) {
Htop_Reaction reaction = HTOP_OK;
Panel* sortPanel = Panel_new(0, 0, 0, 0, Class(ListItem), true, FunctionBar_newEnterEsc("Sort ", "Cancel "));
Panel_setHeader(sortPanel, "Sort by");
- ProcessField* fields = st->settings->fields;
+ const ProcessField* fields = st->settings->fields;
+ Hashtable* dynamicColumns = st->settings->dynamicColumns;
for (int i = 0; fields[i]; i++) {
- char* name = String_trim(Process_fields[fields[i]].name);
+ char* name = NULL;
+ if (fields[i] >= LAST_PROCESSFIELD) {
+ DynamicColumn* column = Hashtable_get(dynamicColumns, fields[i]);
+ if (!column)
+ continue;
+ name = xStrdup(column->caption ? column->caption : column->name);
+ } else {
+ name = String_trim(Process_fields[fields[i]].name);
+ }
Panel_add(sortPanel, (Object*) ListItem_new(name, fields[i]));
if (fields[i] == Settings_getActiveSortKey(st->settings))
Panel_setSelected(sortPanel, i);
free(name);
}
- ListItem* field = (ListItem*) Action_pickFromVector(st, sortPanel, 15, false);
+ const ListItem* field = (const ListItem*) Action_pickFromVector(st, sortPanel, 14, false);
if (field) {
reaction |= Action_setSortKey(st->settings, field->key);
}
@@ -207,12 +212,12 @@ static Htop_Reaction actionSortByTime(State* st) {
static Htop_Reaction actionToggleKernelThreads(State* st) {
st->settings->hideKernelThreads = !st->settings->hideKernelThreads;
- return HTOP_RECALCULATE | HTOP_SAVE_SETTINGS;
+ return HTOP_RECALCULATE | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction actionToggleUserlandThreads(State* st) {
st->settings->hideUserlandThreads = !st->settings->hideUserlandThreads;
- return HTOP_RECALCULATE | HTOP_SAVE_SETTINGS;
+ return HTOP_RECALCULATE | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction actionToggleProgramPath(State* st) {
@@ -227,34 +232,47 @@ static Htop_Reaction actionToggleMergedCommand(State* st) {
static Htop_Reaction actionToggleTreeView(State* st) {
st->settings->treeView = !st->settings->treeView;
- if (st->settings->treeView) {
- st->settings->treeDirection = 1;
- }
- ProcessList_expandTree(st->pl);
+ if (!st->settings->allBranchesCollapsed)
+ ProcessList_expandTree(st->pl);
return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
}
+static Htop_Reaction actionExpandOrCollapseAllBranches(State* st) {
+ st->settings->allBranchesCollapsed = !st->settings->allBranchesCollapsed;
+ if (st->settings->allBranchesCollapsed)
+ ProcessList_collapseAllBranches(st->pl);
+ else
+ ProcessList_expandTree(st->pl);
+ return HTOP_REFRESH | HTOP_SAVE_SETTINGS;
+}
+
static Htop_Reaction actionIncFilter(State* st) {
- IncSet* inc = ((MainPanel*)st->panel)->inc;
- IncSet_activate(inc, INC_FILTER, st->panel);
+ IncSet* inc = (st->mainPanel)->inc;
+ IncSet_activate(inc, INC_FILTER, (Panel*)st->mainPanel);
st->pl->incFilter = IncSet_filter(inc);
return HTOP_REFRESH | HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction actionIncSearch(State* st) {
- IncSet_reset(((MainPanel*)st->panel)->inc, INC_SEARCH);
- IncSet_activate(((MainPanel*)st->panel)->inc, INC_SEARCH, st->panel);
+ IncSet_reset(st->mainPanel->inc, INC_SEARCH);
+ IncSet_activate(st->mainPanel->inc, INC_SEARCH, (Panel*)st->mainPanel);
return HTOP_REFRESH | HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction actionHigherPriority(State* st) {
- bool changed = changePriority((MainPanel*)st->panel, -1);
+ if (Settings_isReadonly())
+ return HTOP_OK;
+
+ bool changed = changePriority(st->mainPanel, -1);
return changed ? HTOP_REFRESH : HTOP_OK;
}
static Htop_Reaction actionLowerPriority(State* st) {
- bool changed = changePriority((MainPanel*)st->panel, 1);
+ if (Settings_isReadonly())
+ return HTOP_OK;
+
+ bool changed = changePriority(st->mainPanel, 1);
return changed ? HTOP_REFRESH : HTOP_OK;
}
@@ -262,11 +280,11 @@ static Htop_Reaction actionInvertSortOrder(State* st) {
Settings_invertSortOrder(st->settings);
if (st->pauseProcessUpdate)
ProcessList_sort(st->pl);
- return HTOP_REFRESH | HTOP_SAVE_SETTINGS;
+ return HTOP_REFRESH | HTOP_SAVE_SETTINGS | HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction actionExpandOrCollapse(State* st) {
- bool changed = expandCollapse(st->panel);
+ bool changed = expandCollapse((Panel*)st->mainPanel);
return changed ? HTOP_RECALCULATE : HTOP_OK;
}
@@ -274,7 +292,7 @@ static Htop_Reaction actionCollapseIntoParent(State* st) {
if (!st->settings->treeView) {
return HTOP_OK;
}
- bool changed = collapseIntoParent(st->panel);
+ bool changed = collapseIntoParent((Panel*)st->mainPanel);
return changed ? HTOP_RECALCULATE : HTOP_OK;
}
@@ -287,13 +305,14 @@ static Htop_Reaction actionQuit(ATTR_UNUSED State* st) {
}
static Htop_Reaction actionSetAffinity(State* st) {
- if (st->pl->cpuCount == 1)
+ if (Settings_isReadonly())
return HTOP_OK;
-#if (defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY))
- Panel* panel = st->panel;
+ if (st->pl->activeCPUs == 1)
+ return HTOP_OK;
- Process* p = (Process*) Panel_getSelected(panel);
+#if (defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY))
+ const Process* p = (const Process*) Panel_getSelected((Panel*)st->mainPanel);
if (!p)
return HTOP_OK;
@@ -303,33 +322,36 @@ static Htop_Reaction actionSetAffinity(State* st) {
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);
+ const void* set = Action_pickFromVector(st, affinityPanel, width, true);
if (set) {
Affinity* affinity2 = AffinityPanel_getAffinity(affinityPanel, st->pl);
- bool ok = MainPanel_foreachProcess((MainPanel*)panel, Affinity_set, (Arg) { .v = affinity2 }, NULL);
+ bool ok = MainPanel_foreachProcess(st->mainPanel, Affinity_set, (Arg) { .v = affinity2 }, NULL);
if (!ok)
beep();
Affinity_delete(affinity2);
}
Object_delete(affinityPanel);
-#endif
return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
+#else
+ return HTOP_OK;
+#endif
+
}
static Htop_Reaction actionKill(State* st) {
+ if (Settings_isReadonly())
+ return HTOP_OK;
+
Panel* signalsPanel = SignalsPanel_new();
- ListItem* sgn = (ListItem*) Action_pickFromVector(st, signalsPanel, 15, true);
- if (sgn) {
- if (sgn->key != 0) {
- Panel_setHeader(st->panel, "Sending...");
- Panel_draw(st->panel, false, true, true, State_hideFunctionBar(st));
- refresh();
- MainPanel_foreachProcess((MainPanel*)st->panel, Process_sendSignal, (Arg) { .i = sgn->key }, NULL);
- napms(500);
- }
+ const ListItem* sgn = (ListItem*) Action_pickFromVector(st, signalsPanel, 14, true);
+ if (sgn && sgn->key != 0) {
+ Panel_setHeader((Panel*)st->mainPanel, "Sending...");
+ Panel_draw((Panel*)st->mainPanel, false, true, true, State_hideFunctionBar(st));
+ refresh();
+ MainPanel_foreachProcess(st->mainPanel, Process_sendSignal, (Arg) { .i = sgn->key }, NULL);
+ napms(500);
}
Panel_delete((Object*)signalsPanel);
return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
@@ -342,7 +364,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, false);
+ const ListItem* picked = (ListItem*) Action_pickFromVector(st, usersPanel, 19, false);
if (picked) {
if (picked == allUsers) {
st->pl->userId = (uid_t)-1;
@@ -355,22 +377,21 @@ static Htop_Reaction actionFilterByUser(State* st) {
}
Htop_Reaction Action_follow(State* st) {
- st->pl->following = MainPanel_selectedPid((MainPanel*)st->panel);
- Panel_setSelectionColor(st->panel, PANEL_SELECTION_FOLLOW);
+ st->pl->following = MainPanel_selectedPid(st->mainPanel);
+ Panel_setSelectionColor((Panel*)st->mainPanel, PANEL_SELECTION_FOLLOW);
return HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction actionSetup(State* st) {
Action_runSetup(st);
- // TODO: shouldn't need this, colors should be dynamic
- int headerHeight = Header_calculateHeight(st->header);
- Panel_move(st->panel, 0, headerHeight);
- Panel_resize(st->panel, COLS, LINES-headerHeight-1);
- return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR;
+ return HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR | HTOP_RESIZE;
}
static Htop_Reaction actionLsof(State* st) {
- Process* p = (Process*) Panel_getSelected(st->panel);
+ if (Settings_isReadonly())
+ return HTOP_OK;
+
+ const Process* p = (Process*) Panel_getSelected((Panel*)st->mainPanel);
if (!p)
return HTOP_OK;
@@ -383,8 +404,9 @@ static Htop_Reaction actionLsof(State* st) {
}
static Htop_Reaction actionShowLocks(State* st) {
- Process* p = (Process*) Panel_getSelected(st->panel);
- if (!p) return HTOP_OK;
+ const Process* p = (Process*) Panel_getSelected((Panel*)st->mainPanel);
+ if (!p)
+ return HTOP_OK;
ProcessLocksScreen* pls = ProcessLocksScreen_new(p);
InfoScreen_run((InfoScreen*)pls);
ProcessLocksScreen_delete((Object*)pls);
@@ -394,7 +416,10 @@ static Htop_Reaction actionShowLocks(State* st) {
}
static Htop_Reaction actionStrace(State* st) {
- Process* p = (Process*) Panel_getSelected(st->panel);
+ if (Settings_isReadonly())
+ return HTOP_OK;
+
+ const Process* p = (Process*) Panel_getSelected((Panel*)st->mainPanel);
if (!p)
return HTOP_OK;
@@ -410,12 +435,12 @@ static Htop_Reaction actionStrace(State* st) {
}
static Htop_Reaction actionTag(State* st) {
- Process* p = (Process*) Panel_getSelected(st->panel);
+ Process* p = (Process*) Panel_getSelected((Panel*)st->mainPanel);
if (!p)
return HTOP_OK;
Process_toggleTag(p);
- Panel_onKey(st->panel, KEY_DOWN);
+ Panel_onKey((Panel*)st->mainPanel, KEY_DOWN);
return HTOP_OK;
}
@@ -431,49 +456,51 @@ static Htop_Reaction actionTogglePauseProcessUpdate(State* st) {
static const struct {
const char* key;
+ bool roInactive;
const char* info;
} helpLeft[] = {
- { .key = " Arrows: ", .info = "scroll process list" },
- { .key = " Digits: ", .info = "incremental PID search" },
- { .key = " F3 /: ", .info = "incremental name search" },
- { .key = " F4 \\: ",.info = "incremental name filtering" },
- { .key = " F5 t: ", .info = "tree view" },
- { .key = " p: ", .info = "toggle program path" },
- { .key = " m: ", .info = "toggle merged command" },
- { .key = " Z: ", .info = "pause/resume process updates" },
- { .key = " u: ", .info = "show processes of a single user" },
- { .key = " H: ", .info = "hide/show user process threads" },
- { .key = " K: ", .info = "hide/show kernel threads" },
- { .key = " F: ", .info = "cursor follows process" },
- { .key = " + -: ", .info = "expand/collapse tree" },
- { .key = "N P M T: ", .info = "sort by PID, CPU%, MEM% or TIME" },
- { .key = " I: ", .info = "invert sort order" },
- { .key = " F6 > .: ", .info = "select sort column" },
+ { .key = " Arrows: ", .roInactive = false, .info = "scroll process list" },
+ { .key = " Digits: ", .roInactive = false, .info = "incremental PID search" },
+ { .key = " F3 /: ", .roInactive = false, .info = "incremental name search" },
+ { .key = " F4 \\: ", .roInactive = false, .info = "incremental name filtering" },
+ { .key = " F5 t: ", .roInactive = false, .info = "tree view" },
+ { .key = " p: ", .roInactive = false, .info = "toggle program path" },
+ { .key = " m: ", .roInactive = false, .info = "toggle merged command" },
+ { .key = " Z: ", .roInactive = false, .info = "pause/resume process updates" },
+ { .key = " u: ", .roInactive = false, .info = "show processes of a single user" },
+ { .key = " H: ", .roInactive = false, .info = "hide/show user process threads" },
+ { .key = " K: ", .roInactive = false, .info = "hide/show kernel threads" },
+ { .key = " F: ", .roInactive = false, .info = "cursor follows process" },
+ { .key = " + - *: ", .roInactive = false, .info = "expand/collapse tree/toggle all" },
+ { .key = "N P M T: ", .roInactive = false, .info = "sort by PID, CPU%, MEM% or TIME" },
+ { .key = " I: ", .roInactive = false, .info = "invert sort order" },
+ { .key = " F6 > .: ", .roInactive = false, .info = "select sort column" },
{ .key = NULL, .info = NULL }
};
static const struct {
const char* key;
+ bool roInactive;
const char* info;
} helpRight[] = {
- { .key = " Space: ", .info = "tag process" },
- { .key = " c: ", .info = "tag process and its children" },
- { .key = " U: ", .info = "untag all processes" },
- { .key = " F9 k: ", .info = "kill process/tagged processes" },
- { .key = " F7 ]: ", .info = "higher priority (root only)" },
- { .key = " F8 [: ", .info = "lower priority (+ nice)" },
-#if (defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY))
- { .key = " a: ", .info = "set CPU affinity" },
+ { .key = " Space: ", .roInactive = false, .info = "tag process" },
+ { .key = " c: ", .roInactive = false, .info = "tag process and its children" },
+ { .key = " U: ", .roInactive = false, .info = "untag all processes" },
+ { .key = " F9 k: ", .roInactive = true, .info = "kill process/tagged processes" },
+ { .key = " F7 ]: ", .roInactive = true, .info = "higher priority (root only)" },
+ { .key = " F8 [: ", .roInactive = false, .info = "lower priority (+ nice)" },
+#if (defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY))
+ { .key = " a: ", .roInactive = true, .info = "set CPU affinity" },
#endif
- { .key = " e: ", .info = "show process environment" },
- { .key = " i: ", .info = "set IO priority" },
- { .key = " l: ", .info = "list open files with lsof" },
- { .key = " x: ", .info = "list file locks of process" },
- { .key = " s: ", .info = "trace syscalls with strace" },
- { .key = " w: ", .info = "wrap process command in multiple lines" },
- { .key = " F2 C S: ", .info = "setup" },
- { .key = " F1 h: ", .info = "show this help screen" },
- { .key = " F10 q: ", .info = "quit" },
+ { .key = " e: ", .roInactive = false, .info = "show process environment" },
+ { .key = " i: ", .roInactive = true, .info = "set IO priority" },
+ { .key = " l: ", .roInactive = true, .info = "list open files with lsof" },
+ { .key = " x: ", .roInactive = false, .info = "list file locks of process" },
+ { .key = " s: ", .roInactive = true, .info = "trace syscalls with strace" },
+ { .key = " w: ", .roInactive = false, .info = "wrap process command in multiple lines" },
+ { .key = " F2 C S: ", .roInactive = false, .info = "setup" },
+ { .key = " F1 h ?: ", .roInactive = false, .info = "show this help screen" },
+ { .key = " F10 q: ", .roInactive = false, .info = "quit" },
{ .key = NULL, .info = NULL }
};
@@ -483,8 +510,6 @@ static inline void addattrstr( int attr, const char* str) {
}
static Htop_Reaction actionHelp(State* st) {
- Settings* settings = st->settings;
-
clear();
attrset(CRT_colors[HELP_BOLD]);
@@ -501,7 +526,7 @@ static Htop_Reaction actionHelp(State* st) {
mvaddstr(line++, 0, "CPU usage bar: ");
addattrstr(CRT_colors[BAR_BORDER], "[");
- if (settings->detailedCPUTime) {
+ if (st->settings->detailedCPUTime) {
addattrstr(CRT_colors[CPU_NICE_TEXT], "low"); addstr("/");
addattrstr(CRT_colors[CPU_NORMAL], "normal"); addstr("/");
addattrstr(CRT_colors[CPU_SYSTEM], "kernel"); addstr("/");
@@ -515,8 +540,8 @@ static Htop_Reaction actionHelp(State* st) {
addattrstr(CRT_colors[CPU_NICE_TEXT], "low-priority"); addstr("/");
addattrstr(CRT_colors[CPU_NORMAL], "normal"); addstr("/");
addattrstr(CRT_colors[CPU_SYSTEM], "kernel"); addstr("/");
- addattrstr(CRT_colors[CPU_GUEST], "virtualiz");
- addattrstr(CRT_colors[BAR_SHADOW], " used%");
+ addattrstr(CRT_colors[CPU_GUEST], "virtualized");
+ addattrstr(CRT_colors[BAR_SHADOW], " used%");
}
addattrstr(CRT_colors[BAR_BORDER], "]");
attrset(CRT_colors[DEFAULT_COLOR]);
@@ -524,14 +549,21 @@ static Htop_Reaction actionHelp(State* st) {
addattrstr(CRT_colors[BAR_BORDER], "[");
addattrstr(CRT_colors[MEMORY_USED], "used"); addstr("/");
addattrstr(CRT_colors[MEMORY_BUFFERS_TEXT], "buffers"); addstr("/");
+ addattrstr(CRT_colors[MEMORY_SHARED], "shared"); addstr("/");
addattrstr(CRT_colors[MEMORY_CACHE], "cache");
- addattrstr(CRT_colors[BAR_SHADOW], " used/total");
+ addattrstr(CRT_colors[BAR_SHADOW], " used/total");
addattrstr(CRT_colors[BAR_BORDER], "]");
attrset(CRT_colors[DEFAULT_COLOR]);
mvaddstr(line++, 0, "Swap bar: ");
addattrstr(CRT_colors[BAR_BORDER], "[");
addattrstr(CRT_colors[SWAP], "used");
+#ifdef HTOP_LINUX
+ addattrstr(CRT_colors[BAR_SHADOW], "/");
+ addattrstr(CRT_colors[SWAP_CACHE], "cache");
+ addattrstr(CRT_colors[BAR_SHADOW], " used/total");
+#else
addattrstr(CRT_colors[BAR_SHADOW], " used/total");
+#endif
addattrstr(CRT_colors[BAR_BORDER], "]");
attrset(CRT_colors[DEFAULT_COLOR]);
mvaddstr(line++, 0, "Type and layout of header meters are configurable in the setup screen.");
@@ -544,26 +576,28 @@ static Htop_Reaction actionHelp(State* st) {
line++;
+ const bool readonly = Settings_isReadonly();
+
int item;
for (item = 0; helpLeft[item].key; item++) {
- attrset(CRT_colors[DEFAULT_COLOR]);
+ attrset((helpLeft[item].roInactive && readonly) ? CRT_colors[HELP_SHADOW] : CRT_colors[DEFAULT_COLOR]);
mvaddstr(line + item, 10, helpLeft[item].info);
- attrset(CRT_colors[HELP_BOLD]);
+ attrset((helpLeft[item].roInactive && readonly) ? CRT_colors[HELP_SHADOW] : CRT_colors[HELP_BOLD]);
mvaddstr(line + item, 1, helpLeft[item].key);
if (String_eq(helpLeft[item].key, " H: ")) {
- attrset(CRT_colors[PROCESS_THREAD]);
+ attrset((helpLeft[item].roInactive && readonly) ? CRT_colors[HELP_SHADOW] : CRT_colors[PROCESS_THREAD]);
mvaddstr(line + item, 33, "threads");
} else if (String_eq(helpLeft[item].key, " K: ")) {
- attrset(CRT_colors[PROCESS_THREAD]);
+ attrset((helpLeft[item].roInactive && readonly) ? CRT_colors[HELP_SHADOW] : CRT_colors[PROCESS_THREAD]);
mvaddstr(line + item, 27, "threads");
}
}
int leftHelpItems = item;
for (item = 0; helpRight[item].key; item++) {
- attrset(CRT_colors[HELP_BOLD]);
+ attrset((helpRight[item].roInactive && readonly) ? CRT_colors[HELP_SHADOW] : CRT_colors[HELP_BOLD]);
mvaddstr(line + item, 41, helpRight[item].key);
- attrset(CRT_colors[DEFAULT_COLOR]);
+ attrset((helpRight[item].roInactive && readonly) ? CRT_colors[HELP_SHADOW] : CRT_colors[DEFAULT_COLOR]);
mvaddstr(line + item, 50, helpRight[item].info);
}
line += MAXIMUM(leftHelpItems, item);
@@ -576,28 +610,28 @@ static Htop_Reaction actionHelp(State* st) {
CRT_readKey();
clear();
- return HTOP_RECALCULATE | HTOP_REDRAW_BAR;
+ return HTOP_RECALCULATE | HTOP_REDRAW_BAR | HTOP_KEEP_FOLLOWING;
}
static Htop_Reaction actionUntagAll(State* st) {
- for (int i = 0; i < Panel_size(st->panel); i++) {
- Process* p = (Process*) Panel_get(st->panel, i);
+ for (int i = 0; i < Panel_size((Panel*)st->mainPanel); i++) {
+ Process* p = (Process*) Panel_get((Panel*)st->mainPanel, i);
p->tag = false;
}
return HTOP_REFRESH;
}
static Htop_Reaction actionTagAllChildren(State* st) {
- Process* p = (Process*) Panel_getSelected(st->panel);
+ Process* p = (Process*) Panel_getSelected((Panel*)st->mainPanel);
if (!p)
return HTOP_OK;
- tagAllChildren(st->panel, p);
+ tagAllChildren((Panel*)st->mainPanel, p);
return HTOP_OK;
}
static Htop_Reaction actionShowEnvScreen(State* st) {
- Process* p = (Process*) Panel_getSelected(st->panel);
+ Process* p = (Process*) Panel_getSelected((Panel*)st->mainPanel);
if (!p)
return HTOP_OK;
@@ -610,7 +644,7 @@ static Htop_Reaction actionShowEnvScreen(State* st) {
}
static Htop_Reaction actionShowCommandScreen(State* st) {
- Process* p = (Process*) Panel_getSelected(st->panel);
+ Process* p = (Process*) Panel_getSelected((Panel*)st->mainPanel);
if (!p)
return HTOP_OK;
@@ -624,6 +658,7 @@ static Htop_Reaction actionShowCommandScreen(State* st) {
void Action_setBindings(Htop_Action* keys) {
keys[' '] = actionTag;
+ keys['*'] = actionExpandOrCollapseAllBranches;
keys['+'] = actionExpandOrCollapse;
keys[','] = actionSetSortColumn;
keys['-'] = actionExpandOrCollapse;

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