diff options
81 files changed, 1030 insertions, 537 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..74d0ece8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build-ubuntu-latest: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build + run: | + sudo apt-get install libncursesw5-dev + ./autogen.sh + ./configure + make + +# build-macos-latest: +# runs-on: macos-latest +# steps: +# - uses: actions/checkout@v2 +# - name: make +# run: | +# ./autogen.sh +# ./configure +# make @@ -62,7 +62,7 @@ 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; @@ -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; @@ -305,7 +321,7 @@ static Htop_Reaction actionSetAffinity(State* st) { Panel* affinityPanel = AffinityPanel_new(st->pl, affinity); Affinity_delete(affinity); - void* set = Action_pickFromVector(st, affinityPanel, 15); + void* set = Action_pickFromVector(st, affinityPanel, 15, true); if (set) { Affinity* affinity = AffinityPanel_getAffinity(affinityPanel, st->pl); bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (Arg){ .v = affinity }, NULL); @@ -319,7 +335,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 +356,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; @@ -559,6 +575,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; @@ -39,20 +39,20 @@ typedef struct State_ { } State; -Object* Action_pickFromVector(State* st, Panel* list, int x); +extern Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess); // ---------------------------------------- -bool Action_setUserOnly(const char* userName, uid_t* userId); +extern bool Action_setUserOnly(const char* userName, uid_t* userId); -Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey); +extern Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey); // ---------------------------------------- -Htop_Reaction Action_follow(State* st); +extern Htop_Reaction Action_follow(State* st); -void Action_setBindings(Htop_Action* keys); +extern void Action_setBindings(Htop_Action* keys); #endif @@ -1,6 +1,7 @@ /* htop - Affinity.c (C) 2004-2011 Hisham H. Muhammad +(C) 2020 Red Hat, Inc. All Rights Reserved. Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ @@ -79,7 +80,8 @@ Affinity* Affinity_get(Process* proc, ProcessList* pl) { return affinity; } -bool Affinity_set(Process* proc, Affinity* this) { +bool Affinity_set(Process* proc, Arg arg) { + Affinity *this = arg.v; hwloc_cpuset_t cpuset = hwloc_bitmap_alloc(); for (int i = 0; i < this->used; i++) { hwloc_bitmap_set(cpuset, this->cpus[i]); @@ -103,7 +105,8 @@ Affinity* Affinity_get(Process* proc, ProcessList* pl) { return affinity; } -bool Affinity_set(Process* proc, Affinity* this) { +bool Affinity_set(Process* proc, Arg arg) { + Affinity *this = arg.v; cpu_set_t cpuset; CPU_ZERO(&cpuset); for (int i = 0; i < this->used; i++) { @@ -5,6 +5,7 @@ /* htop - Affinity.h (C) 2004-2011 Hisham H. Muhammad +(C) 2020 Red Hat, Inc. All Rights Reserved. Released under the GNU GPL, see the COPYING file in the source distribution for its full text. */ @@ -29,23 +30,23 @@ typedef struct Affinity_ { } Affinity; -Affinity* Affinity_new(ProcessList* pl); +extern Affinity* Affinity_new(ProcessList* pl); -void Affinity_delete(Affinity* this); +extern void Affinity_delete(Affinity* this); -void Affinity_add(Affinity* this, int id); +extern void Affinity_add(Affinity* this, int id); #ifdef HAVE_LIBHWLOC -Affinity* Affinity_get(Process* proc, ProcessList* pl); +extern Affinity* Affinity_get(Process* proc, ProcessList* pl); -bool Affinity_set(Process* proc, Affinity* this); +extern bool Affinity_set(Process* proc, Arg arg); #elif HAVE_LINUX_AFFINITY -Affinity* Affinity_get(Process* proc, ProcessList* pl); +extern Affinity* Affinity_get(Process* proc, ProcessList* pl); -bool Affinity_set(Process* proc, Affinity* this); +extern bool Affinity_set(Process* proc, Arg arg); #endif diff --git a/AffinityPanel.h b/AffinityPanel.h index 2b6059b0..3a9c7807 100644 --- a/AffinityPanel.h +++ b/AffinityPanel.h @@ -16,8 +16,8 @@ in the source distribution for its full text. extern PanelClass AffinityPanel_class; -Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity); +extern Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity); -Affinity* AffinityPanel_getAffinity(Panel* this, ProcessList* pl); +extern Affinity* AffinityPanel_getAffinity(Panel* this, ProcessList* pl); #endif diff --git a/AvailableColumnsPanel.h b/AvailableColumnsPanel.h index 5a8371dd..2d6daf4b 100644 --- a/AvailableColumnsPanel.h +++ b/AvailableColumnsPanel.h @@ -19,6 +19,6 @@ typedef struct AvailableColumnsPanel_ { extern PanelClass AvailableColumnsPanel_class; -AvailableColumnsPanel* AvailableColumnsPanel_new(Panel* columns); +extern AvailableColumnsPanel* AvailableColumnsPanel_new(Panel* columns); #endif diff --git a/AvailableMetersPanel.c b/AvailableMetersPanel.c index ddb55367..40534bb7 100644 --- a/AvailableMetersPanel.c +++ b/AvailableMetersPanel.c @@ -127,7 +127,7 @@ AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* heade Panel_add(super, (Object*) ListItem_new("CPU average", 0)); for (int i = 1; i <= cpus; i++) { char buffer[50]; - xSnprintf(buffer, 50, "%s %d", type->uiName, i); + xSnprintf(buffer, 50, "%s %d", type->uiName, Settings_cpuId(this->settings, i - 1)); Panel_add(super, (Object*) ListItem_new(buffer, i)); } } else { diff --git a/AvailableMetersPanel.h b/AvailableMetersPanel.h index e9b949b0..00e0f596 100644 --- a/AvailableMetersPanel.h +++ b/AvailableMetersPanel.h @@ -27,6 +27,6 @@ typedef struct AvailableMetersPanel_ { extern PanelClass AvailableMetersPanel_class; -AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* header, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr, ProcessList* pl); +extern AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* header, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr, ProcessList* pl); #endif @@ -128,12 +128,15 @@ typedef enum ColorElements_ { CPU_SOFTIRQ, CPU_STEAL, CPU_GUEST, + PRESSURE_STALL_TEN, + PRESSURE_STALL_SIXTY, + PRESSURE_STALL_THREEHUNDRED, LAST_COLORELEMENT } ColorElements; -void CRT_fatalError(const char* note) __attribute__ ((noreturn)); +extern void CRT_fatalError(const char* note) __attribute__ ((noreturn)); -void CRT_handleSIGSEGV(int sgn); +extern void CRT_handleSIGSEGV(int sgn); #define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A')) @@ -232,6 +235,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Magenta,Black), [CPU_STEAL] = ColorPair(Cyan,Black), [CPU_GUEST] = ColorPair(Cyan,Black), + [PRESSURE_STALL_THREEHUNDRED] = ColorPair(Cyan,Black), + [PRESSURE_STALL_SIXTY] = A_BOLD | ColorPair(Cyan,Black), + [PRESSURE_STALL_TEN] = A_BOLD | ColorPair(White,Black), }, [COLORSCHEME_MONOCHROME] = { [RESET_COLOR] = A_NORMAL, @@ -291,6 +297,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = A_BOLD, [CPU_STEAL] = A_REVERSE, [CPU_GUEST] = A_REVERSE, + [PRESSURE_STALL_THREEHUNDRED] = A_DIM, + [PRESSURE_STALL_SIXTY] = A_NORMAL, + [PRESSURE_STALL_TEN] = A_BOLD, }, [COLORSCHEME_BLACKONWHITE] = { [RESET_COLOR] = ColorPair(Black,White), @@ -350,6 +359,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Blue,White), [CPU_STEAL] = ColorPair(Cyan,White), [CPU_GUEST] = ColorPair(Cyan,White), + [PRESSURE_STALL_THREEHUNDRED] = ColorPair(Black,White), + [PRESSURE_STALL_SIXTY] = ColorPair(Black,White), + [PRESSURE_STALL_TEN] = ColorPair(Black,White), }, [COLORSCHEME_LIGHTTERMINAL] = { [RESET_COLOR] = ColorPair(Black,Black), @@ -409,6 +421,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Blue,Black), [CPU_STEAL] = ColorPair(Black,Black), [CPU_GUEST] = ColorPair(Black,Black), + [PRESSURE_STALL_THREEHUNDRED] = ColorPair(Black,Black), + [PRESSURE_STALL_SIXTY] = ColorPair(Black,Black), + [PRESSURE_STALL_TEN] = ColorPair(Black,Black), }, [COLORSCHEME_MIDNIGHT] = { [RESET_COLOR] = ColorPair(White,Blue), @@ -468,6 +483,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Black,Blue), [CPU_STEAL] = ColorPair(White,Blue), [CPU_GUEST] = ColorPair(White,Blue), + [PRESSURE_STALL_THREEHUNDRED] = A_BOLD | ColorPair(Black,Blue), + [PRESSURE_STALL_SIXTY] = A_NORMAL | ColorPair(White,Blue), + [PRESSURE_STALL_TEN] = A_BOLD | ColorPair(White,Blue), }, [COLORSCHEME_BLACKNIGHT] = { [RESET_COLOR] = ColorPair(Cyan,Black), @@ -527,6 +545,9 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = { [CPU_SOFTIRQ] = ColorPair(Blue,Black), [CPU_STEAL] = ColorPair(Cyan,Black), [CPU_GUEST] = ColorPair(Cyan,Black), + [PRESSURE_STALL_THREEHUNDRED] = ColorPair(Green,Black), + [PRESSURE_STALL_SIXTY] = ColorPair(Green,Black), + [PRESSURE_STALL_TEN] = A_BOLD | ColorPair(Green,Black), }, [COLORSCHEME_BROKENGRAY] = { 0 } // dynamically generated. }; @@ -116,12 +116,15 @@ typedef enum ColorElements_ { |