diff options
82 files changed, 990 insertions, 636 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e468efa1..3346966e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,16 +31,16 @@ jobs: build-ubuntu-latest-minimal-clang: runs-on: ubuntu-latest env: - CC: clang-11 + CC: clang-12 steps: - uses: actions/checkout@v2 - name: install clang repo run: | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key 2>/dev/null | sudo apt-key add - - sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main' -y + sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main' -y sudo apt-get update -q - name: Install Dependencies - run: sudo apt-get install clang-11 libncursesw5-dev + run: sudo apt-get install clang-12 libncursesw5-dev - name: Bootstrap run: ./autogen.sh - name: Configure @@ -63,33 +63,33 @@ jobs: - name: Bootstrap run: ./autogen.sh - name: Configure - run: ./configure --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct --enable-sensors --enable-capabilities + run: ./configure --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --enable-hwloc --enable-delayacct --enable-sensors --enable-capabilities - name: Build run: make -k - name: Distcheck - run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct --enable-sensors --enable-capabilities' + run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --enable-hwloc --enable-delayacct --enable-sensors --enable-capabilities' build-ubuntu-latest-full-featured-clang: runs-on: ubuntu-latest env: - CC: clang-11 + CC: clang-12 steps: - uses: actions/checkout@v2 - name: install clang repo run: | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key 2>/dev/null | sudo apt-key add - - sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main' -y + sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main' -y sudo apt-get update -q - name: Install Dependencies - run: sudo apt-get install clang-11 libncursesw5-dev libhwloc-dev libnl-3-dev libnl-genl-3-dev libsensors4-dev libcap-dev + run: sudo apt-get install clang-12 libncursesw5-dev libhwloc-dev libnl-3-dev libnl-genl-3-dev libsensors4-dev libcap-dev - name: Bootstrap run: ./autogen.sh - name: Configure - run: ./configure --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct --enable-sensors --enable-capabilities + run: ./configure --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --enable-hwloc --enable-delayacct --enable-sensors --enable-capabilities - name: Build run: make -k - name: Distcheck - run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct --enable-sensors --enable-capabilities' + run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --enable-hwloc --enable-delayacct --enable-sensors --enable-capabilities' build-ubuntu-latest-gcc-static: runs-on: ubuntu-latest @@ -104,31 +104,31 @@ jobs: - name: Bootstrap run: ./autogen.sh - name: Configure - run: ./configure --enable-static --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --disable-hwloc --enable-setuid --disable-delayacct --enable-sensors --enable-capabilities + run: ./configure --enable-static --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --disable-hwloc --disable-delayacct --enable-sensors --enable-capabilities - name: Build run: make -k - name: Distcheck - run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-static --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --disable-hwloc --enable-setuid --disable-delayacct --enable-sensors --enable-capabilities' + run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-static --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --disable-hwloc --disable-delayacct --enable-sensors --enable-capabilities' build-ubuntu-latest-clang-analyzer: runs-on: ubuntu-latest env: - CC: clang-11 + CC: clang-12 steps: - uses: actions/checkout@v2 - name: install clang repo run: | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key 2>/dev/null | sudo apt-key add - - sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main' -y + sudo add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main' -y sudo apt-get update -q - name: Install Dependencies - run: sudo apt-get install clang-11 clang-tools-11 libncursesw5-dev libhwloc-dev libnl-3-dev libnl-genl-3-dev libsensors4-dev libcap-dev + run: sudo apt-get install clang-12 clang-tools-12 libncursesw5-dev libhwloc-dev libnl-3-dev libnl-genl-3-dev libsensors4-dev libcap-dev - name: Bootstrap run: ./autogen.sh - name: Configure - run: scan-build-11 -analyze-headers --status-bugs ./configure --enable-debug --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --enable-hwloc --enable-setuid --enable-delayacct --enable-sensors --enable-capabilities + run: scan-build-12 -analyze-headers --status-bugs ./configure --enable-debug --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --enable-hwloc --enable-delayacct --enable-sensors --enable-capabilities - name: Build - run: scan-build-11 -analyze-headers --status-bugs make -j"$(nproc)" + run: scan-build-12 -analyze-headers --status-bugs make -j"$(nproc)" build-macos-latest-clang: runs-on: macOS-latest @@ -206,12 +206,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) { @@ -226,14 +226,20 @@ 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 = (st->mainPanel)->inc; IncSet_activate(inc, INC_FILTER, (Panel*)st->mainPanel); @@ -261,7 +267,7 @@ 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) { @@ -319,14 +325,12 @@ static Htop_Reaction actionSetAffinity(State* st) { static Htop_Reaction actionKill(State* st) { Panel* signalsPanel = SignalsPanel_new(); const ListItem* sgn = (ListItem*) Action_pickFromVector(st, signalsPanel, 15, true); - if (sgn) { - if (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); - } + 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; @@ -441,7 +445,7 @@ static const struct { { .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 = " + - *: ", .info = "expand/collapse tree/toggle all" }, { .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" }, @@ -576,7 +580,7 @@ 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) { @@ -624,6 +628,7 @@ static Htop_Reaction actionShowCommandScreen(State* st) { void Action_setBindings(Htop_Action* keys) { keys[' '] = actionTag; + keys['*'] = actionExpandOrCollapseAllBranches; keys['+'] = actionExpandOrCollapse; keys[','] = actionSetSortColumn; keys['-'] = actionExpandOrCollapse; diff --git a/AvailableMetersPanel.c b/AvailableMetersPanel.c index 0e16147d..5e5af67c 100644 --- a/AvailableMetersPanel.c +++ b/AvailableMetersPanel.c @@ -76,6 +76,7 @@ static HandlerResult AvailableMetersPanel_eventHandler(Panel* super, int ch) { if (update) { this->settings->changed = true; Header_calculateHeight(header); + Header_updateData(header); Header_draw(header); ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2); } diff --git a/BatteryMeter.c b/BatteryMeter.c index 2c808c72..26a5ac48 100644 --- a/BatteryMeter.c +++ b/BatteryMeter.c @@ -21,7 +21,7 @@ static const int BatteryMeter_attributes[] = { BATTERY }; -static void BatteryMeter_updateValues(Meter* this, char* buffer, size_t len) { +static void BatteryMeter_updateValues(Meter* this) { ACPresence isOnAC; double percent; @@ -29,7 +29,7 @@ static void BatteryMeter_updateValues(Meter* this, char* buffer, size_t len) { if (isnan(percent)) { this->values[0] = NAN; - xSnprintf(buffer, len, "N/A"); + xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "N/A"); return; } @@ -49,7 +49,7 @@ static void BatteryMeter_updateValues(Meter* this, char* buffer, size_t len) { break; } - xSnprintf(buffer, len, "%.1f%%%s", percent, text); + xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.1f%%%s", percent, text); } const MeterClass BatteryMeter_class = { @@ -41,19 +41,19 @@ typedef struct CPUMeterData_ { static void CPUMeter_init(Meter* this) { int cpu = this->param; - if (this->pl->cpuCount > 1) { + if (cpu == 0) { + Meter_setCaption(this, "Avg"); + } else if (this->pl->cpuCount > 1) { char caption[10]; xSnprintf(caption, sizeof(caption), "%3d", Settings_cpuId(this->pl->settings, cpu - 1)); Meter_setCaption(this, caption); } - if (this->param == 0) - Meter_setCaption(this, "Avg"); } -static void CPUMeter_updateValues(Meter* this, char* buffer, size_t size) { +static void CPUMeter_updateValues(Meter* this) { int cpu = this->param; if (cpu > this->pl->cpuCount) { - xSnprintf(buffer, size, "absent"); + xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "absent"); for (uint8_t i = 0; i < this->curItems; i++) this->values[i] = 0; return; @@ -91,7 +91,7 @@ static void CPUMeter_updateValues(Meter* this, char* buffer, size_t size) { } #endif - xSnprintf(buffer, size, "%s%s%s%s%s", + xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s%s%s%s%s", cpuUsageBuffer, (cpuUsageBuffer[0] && (cpuFrequencyBuffer[0] || cpuTemperatureBuffer[0])) ? " " : "", cpuFrequencyBuffer, @@ -187,6 +187,15 @@ static void AllCPUsMeter_getRange(const Meter* this, int* start, int* count) { } } +static void AllCPUsMeter_updateValues(Meter* this) { + CPUMeterData* data = this->meterData; + Meter** meters = data->meters; + int start, count; + AllCPUsMeter_getRange(this, &start, &count); + for (int i = 0; i < count; i++) + Meter_updateValues(meters[i]); +} + static void CPUMeterCommonInit(Meter* this, int ncol) { int cpus = this->pl->cpuCount; CPUMeterData* data = this->meterData; @@ -332,6 +341,7 @@ const MeterClass AllCPUsMeter_class = { .delete = Meter_delete, .display = CPUMeter_display }, + .updateValues = AllCPUsMeter_updateValues, .defaultMode = CUSTOM_METERMODE, .total = 100.0, .attributes = CPUMeter_attributes, @@ -351,6 +361,7 @@ const MeterClass AllCPUs2Meter_class = { .delete = Meter_delete, .display = CPUMeter_display }, + .updateValues = AllCPUsMeter_updateValues, .defaultMode = CUSTOM_METERMODE, .total = 100.0, .attributes = CPUMeter_attributes, @@ -370,6 +381,7 @@ const MeterClass LeftCPUsMeter_class = { .delete = Meter_delete, .display = CPUMeter_display }, + .updateValues = AllCPUsMeter_updateValues, .defaultMode = CUSTOM_METERMODE, .total = 100.0, .attributes = CPUMeter_attributes, @@ -389,6 +401,7 @@ const MeterClass RightCPUsMeter_class = { .delete = Meter_delete, .display = CPUMeter_display }, + .updateValues = AllCPUsMeter_updateValues, .defaultMode = CUSTOM_METERMODE, .total = 100.0, .attributes = CPUMeter_attributes, @@ -408,6 +421,7 @@ const MeterClass LeftCPUs2Meter_class = { |