110 Commits

Author SHA1 Message Date
da62b44b16 Bump version, changelog for minor htop-3.0.2 release 2020-09-15 09:43:36 +10:00
c9ecd0fa74 Revert the vim_mode setting for now, needs a rethink
There have been too many bugs reported in vim_mode, and
the proposed fixes are increasingly fragile - hence we
have decided to back it out for now.  For reference:

   https://github.com/htop-dev/htop/issues/69
   https://github.com/htop-dev/htop/pull/37
   https://github.com/htop-dev/htop/pull/106

The whitespace changes also arrived in commit 12805f61d
not sure what that was about, but backed out as well.
2020-09-15 09:33:58 +10:00
f6662f97fd Merge pull request #120 from cgzones/null
Drop always true condition
2020-09-15 09:21:46 +10:00
ccf0960d5c Merge pull request #123 from hugomg/header-duplicates
Clean up some code duplication in the header files
2020-09-14 17:46:18 +10:00
313d7c980c Merge pull request #127 from gh-fork-dump/openbsd-fix
fix building on openbsd due to remaining WhiteList
2020-09-14 17:42:23 +10:00
fd4ada416d fix building on openbsd due to remaining WhiteList 2020-09-14 13:18:40 +10:00
b6828d7b86 Remove some unused #includes
As suggested by cppclean.
2020-09-12 23:32:31 -03:00
a2ef400e43 Merge identical ifdefs in Affinity.h 2020-09-12 19:21:27 -03:00
5ad3c11eaa Alignment tweak 2020-09-12 19:21:27 -03:00
9207401f97 Clean up some code duplication in the header files
PR htop-dev/htop#70 got rid of the infrastructure for generating header
files, but it left behind some code duplication.

Some of cases are things that belong in the header file and don't need
to be repeated in the C file. Other cases are things that belong in the
C file and don't need to be in the header file.

In this commit I tried to fix all of these that I could find. When given
a choice I preferred keeping things out of the header file, unless they
were being used by someone else.
2020-09-12 19:20:44 -03:00
d5eb72e64d Drop always true condition
`env` is allocated by checked allocation functions and can not be NULL.

This checks confuses clang analyzer and causes a null-dereference
warning on `env[size-1]`.
2020-09-12 18:14:39 +02:00
cd55cfd6d2 Merge branch 'BenBE-avoid-shadowing' 2020-09-09 19:41:16 +10:00
35c3a95ff9 Merge branch 'avoid-shadowing' of https://github.com/BenBE/htop into BenBE-avoid-shadowing 2020-09-09 19:40:50 +10:00
06ba81beec Merge branch 'rgouicem-master' 2020-09-09 19:38:59 +10:00
4d6e4ef53c Merge branch 'master' of https://github.com/rgouicem/htop into rgouicem-master 2020-09-09 19:38:53 +10:00
4597332959 Switch variable/field naming from WhiteList to MatchList 2020-09-09 19:38:15 +10:00
c5808c56db Consolidate repeated macro definitions into one header
The MIN, MAX, CLAMP, MINIMUM, and MAXIMUM macros appear
throughout the codebase with many re-definitions.  Make
a single copy of each in a common header file, and use
the BSD variants of MINIMUM/MAXIMUM due to conflicts in
the system <sys/param.h> headers.
2020-09-09 16:56:04 +10:00
8ec5d4a3a0 Further, minor cleanups to headers post-MakeHeaders
Remove leftover empty ifdef/endif pairs, whitespace.
The generated htop.h file was also unused - removed.
2020-09-08 17:33:50 +10:00
eede79b29a Merge branch 'noheadergen' of https://github.com/zevweiss/htop into zevweiss-noheadergen 2020-09-08 16:45:11 +10:00
13b1e96b12 Avoid shadowing of variables 2020-09-07 17:36:01 +02:00
85ff6960ed Merge branch 't6-patch-freebsd-ci' 2020-09-07 10:25:50 +10:00
a1f2532630 Merge branch 'patch-freebsd-ci' of https://github.com/t6/htop-1 into t6-patch-freebsd-ci 2020-09-07 10:25:44 +10:00
7805575114 fix for double symbol link error on solaris 2020-09-05 15:34:27 +10:00
f884beda97 htop should report the nice level properly 2020-09-05 15:29:15 +10:00
0750ff7e76 Fix regression in -u optional-argument handling
Resolves https://github.com/htop-dev/htop/issues/91
2020-09-04 09:50:18 +10:00
7758ffcdea Remove duplicate jail_errmsg declaration.
Fixes: 11ecc65ebb
2020-09-03 12:00:21 -05:00
7b7822b896 Remove superfluous 'extern's from function declarations.
Applied via:

  $ find * -name '*.h' -exec sed -i -r 's/^extern (.+\()/\1/;' {} +

Suggested-by: Bert Wesarg <bert.wesarg@googlemail.com>
2020-09-03 11:59:26 -05:00
a1a027b9bd Axe automated header generation.
Reasoning:
 - implementation was unsound -- broke down when I added a fairly
   basic macro definition expanding to a struct initializer in a *.c
   file.

 - made it way too easy (e.g. via otherwise totally innocuous git
   commands) to end up with timestamps such that it always ran
   MakeHeader.py but never used its output, leading to overbuild noise
   when running what should be a null 'make'.

 - but mostly: it's just an awkward way of dealing with C code.
2020-09-03 11:58:58 -05:00
35d7e42b88 Add FreeBSD to Travis
Signed-off-by: Tobias Kortkamp <t@tobik.me>
2020-09-03 09:00:17 +02:00
7734dfe55d Merge pull request #86 from t6/patch-freebsd-fno-common
Unbreak with -fno-common on FreeBSD
2020-09-03 16:47:30 +10:00
11ecc65ebb Unbreak with -fno-common on FreeBSD
GCC10 and Clang11 now default to -fno-common.

ld: error: duplicate symbol: jail_errmsg
>>> defined at Platform.c
>>>            freebsd/Platform.o:(jail_errmsg)
>>> defined at FreeBSDProcessList.c
>>>            freebsd/FreeBSDProcessList.o:(.bss+0x90)

Signed-off-by: Tobias Kortkamp <t@tobik.me>
2020-09-03 08:42:18 +02:00
dace850fa6 Bump version, changelog for minor htop-3.0.1 release 2020-09-03 13:23:43 +10:00
4f00a95364 Merge pull request #66 from ioquatix/patch-1
Fix image logo and titles.
2020-09-03 08:35:19 +10:00
0ab508e42b Merge pull request #57 from matthiasbeyer/patch-1
Do not link INSTALL file, because link target does not exist
2020-09-03 08:20:36 +10:00
f79591ef1b Merge branch 'eworm-de-unicode-runtime' 2020-09-02 15:09:58 +10:00
746a5f279a Fix image logo and titles. 2020-09-02 11:54:17 +12:00
8ee7d58cb0 Do not link INSTALL file, because link target does not exist 2020-09-01 14:47:00 +02:00
db5adbeae0 add option (-U, --no-unicode) to disable unicode at runtime 2020-09-01 10:09:00 +02:00
f5b3e8d2a3 Merge branch 'cgzones-oom2' 2020-09-01 15:17:32 +10:00
809e4db672 Merge branch 'oom2' of https://github.com/cgzones/htop into cgzones-oom2 2020-09-01 15:17:23 +10:00
e1e60f38dc CRT: note about possible use of replacement for + glyph in tree 2020-08-31 22:35:09 +02:00
19359cec5a affinity panel: use the tree collapsing as in the process list
With one exception, the root node does also have a `-`/`+` as a prefix.
2020-08-31 22:22:22 +02:00
b0f1336f79 affinity panel: show CPUs in the topology tree as CPU x
As it is in the non-topology list.
2020-08-31 22:18:18 +02:00
f861a2c616 Revert "Use UTF-8 for check buttons and tree open/closed"
This reverts commit 5d5913d355b3a9f03da589b3542b8f55467b4ed6.
2020-08-31 22:12:46 +02:00
d0e8ff9319 fix unit (GHz -> MHz) 2020-08-31 14:09:22 +02:00
0f5d2cd1e4 fixed compilation error 2020-08-31 13:32:29 +02:00
293e3a2931 remove unused variable 2020-08-31 13:29:24 +02:00
e7f6d1ce5f Reduce oom cast from long to int
Oom values should never be greater then INT_MAX, they should be in the
range 0 - 1000.

Improves: d9a5dd4b91
2020-08-31 11:55:53 +02:00
47a7d0bd74 Merge branch 'configure' of https://github.com/cgzones/htop into cgzones-configure 2020-08-31 17:13:37 +10:00
b321177b08 Merge branch 'master' of github.com:htop-dev/htop 2020-08-31 16:57:46 +10:00
800d8c735d Merge branch 'cov_fixes' of https://github.com/cgzones/htop into cgzones-cov_fixes 2020-08-31 16:56:32 +10:00
f14173038e Merge branch 'oom' of https://github.com/cgzones/htop
Closes: #18, #22
2020-08-31 08:32:39 +02:00
fdf8a28e60 Merge branch 'Ckath-vim_mode_setting' 2020-08-31 16:14:48 +10:00
244630f67f Merge branch 'vim_mode_setting' of https://github.com/Ckath/htop into Ckath-vim_mode_setting 2020-08-31 16:14:40 +10:00
0a835e13bf Simplify the --version output, old dates are confusing people
Drop the copyright notice from the version output as a number
of people seem to be confused by what this means, and we can
do without all the (well intentioned) bug reports.
2020-08-31 16:14:23 +10:00
4bd0859b80 Add a badge/link to the released source tarballs 2020-08-31 16:12:44 +10:00
338bd829b0 add toggle for vim mode in options 2020-08-29 15:15:52 +02:00
5c99c6e942 Check btime sscanf parse from /proc/stat
Found by Coverity
2020-08-28 16:46:50 +02:00
a850d81bf5 Avoid use of uninitialized variables
Found by Coverity
2020-08-28 16:46:50 +02:00
05a5fdc47f Ignore sscanf return value of /proc/stat
Found by Coverity
2020-08-28 16:46:50 +02:00
af84d3dfa9 Fail on out-of-range CPU number
Found by Coverity
2020-08-28 16:46:50 +02:00
df41979afc Ignore wmove return value
Found by Coverity
2020-08-28 16:46:50 +02:00
d9a5dd4b91 Improve OOM output
* Fix sort by adding cast
* Shrink column size to 4
* Drop unnecessary maximum field width specifier in sscanf
2020-08-28 14:24:59 +02:00
a48ce9d103 Really tell gcc to ignore return value of fscanf 2020-08-28 13:10:41 +02:00
3f5784a3f0 Convert hwlock CI run to a full featured one 2020-08-28 13:10:41 +02:00
3b084db1c4 Print configured state 2020-08-28 13:10:41 +02:00
979d004214 Improve indent 2020-08-28 13:10:16 +02:00
5bee902665 Drop configure option --enable-proc
Move to HTOP_LINUX, as --enable-proc implies my_htop_platform=linux, and
the Linux features do not work without a proc fs.
2020-08-28 13:10:16 +02:00
3ef5df25bc always display frequency in MHz 2020-08-28 12:15:32 +02:00
2d14269bcd Merge pull request #14 from zdykstra/master
Normalize ZFS ARC caption
2020-08-28 16:58:06 +10:00
b992d52bcf Increae the size of sysfs power supply path buffers
Resolves https://github.com/htop-dev/htop/issues/15
2020-08-28 16:57:21 +10:00
f97fbd668a Normalize ZFS ARC caption
Other captions take the form of LABEL:<space>. This moves the
uncompressed ZFS ARC caption into the same style.
2020-08-28 00:02:35 -05:00
b5e6952cc6 Update link to Coverity project, still pending. 2020-08-27 10:42:40 +10:00
4a8ae4b5d4 Merge branch 'bertwesarg-affinity-fix-panel-width' 2020-08-27 09:36:56 +10:00
94b8c2e714 fix width of AffinitPanel
The panel size of 15 includes the gap to the next panel, thus use 14 as
the minimum size and let the caller of `AffinityPanel_new` handle the
gap.
2020-08-26 22:03:11 +02:00
df7e4fcdc0 Update changelog with Berts latest addition 2020-08-26 10:44:22 +10:00
728b04bbb5 Merge branch 'ci-hwloc-job' of https://github.com/bertwesarg/htop into bertwesarg-ci-hwloc-job 2020-08-26 10:39:43 +10:00
d0f31ede56 Merge branch 'ci-hwloc-job' of https://github.com/bertwesarg/htop into bertwesarg-ci-hwloc-job 2020-08-26 10:15:00 +10:00
ba94e0dfda Merge branch 'ci2' of https://github.com/cgzones/htop into cgzones-ci2 2020-08-26 10:08:50 +10:00
fc4f74aa47 ci: add clang build 2020-08-25 12:01:56 +02:00
4e2b9f0965 Avoid shadowing warnings 2020-08-25 12:01:56 +02:00
b4ceb83d76 MakeHeader.py.in: remove unused import 2020-08-25 12:00:08 +02:00
1130ad8b73 MakeHeader.py.in: remove executable bit 2020-08-25 12:00:08 +02:00
11f558f934 Avoid discarding const qualifiers 2020-08-25 12:00:03 +02:00
7457bfe9f3 Avoid string overflow warning
Use xStrdup instead of xMallow and strncpy

    StringUtils.c: In function ‘String_split’:
    StringUtils.c:86:7: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
       86 |       strncpy(token, s, size + 1);
          |       ^
    StringUtils.c:84:18: note: length computed here
       84 |       int size = strlen(s);
          |                  ^
2020-08-25 11:59:59 +02:00
21fb56e1e2 Avoid string overflow warning
Enough memory is allocated.

    Header.c: In function ‘Header_readMeterName’:
    Header.c:157:4: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
      157 |    strncpy(name, Meter_name(meter), nameLen);
          |    ^
    Header.c:154:18: note: length computed here
      154 |    int nameLen = strlen(Meter_name(meter));
          |                  ^
2020-08-25 11:59:59 +02:00
6b11769448 Avoid conversion warning
linux/Platform.c:47:90: error: implicit conversion from ‘enum LinuxProcessFields’ to ‘enum ProcessFields’ [-Werror=enum-conversion]
       47 | ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
          |
2020-08-25 11:59:53 +02:00
d64a6a2453 CI: Add a HWLOC enabled job 2020-08-25 11:42:21 +02:00
345d415537 Do not include the generated config.h header into the package 2020-08-25 11:42:16 +02:00
054b7f2801 Fix out-of-tree builds 2020-08-25 10:36:27 +02:00
e172282002 Fix in AC_CONFIG_FILES, try #2 2020-08-24 21:37:28 +02:00
0bac7c9d94 Nope, configure works but make breaks.
This reverts commit dad62b6c9e.
2020-08-24 21:08:07 +02:00
dad62b6c9e Put Makeheader.py.in into AC_CONFIG_FILES 2020-08-24 21:01:50 +02:00
9eb9064fbd Cleanup unused CI build notes and whitespace 2020-08-24 10:22:44 +10:00
9e57b5c3f4 Generate an appropriate shebang line for MakeHeader script
Use configure.ac to handle platform differences where some
build hosts have only a python3, or only python, binary.

Related to https://github.com/htop-dev/htop/pull/6
2020-08-23 11:24:52 +10:00
b3aef4ea3a Revert "MakeHeader.py: use python3 shebang"
This reverts commit 40ac7a88af.
as it causes build failure on non-python3 platforms.
2020-08-23 09:42:11 +10:00
6900e57efd Updates to project URLs in docs and embedded in source code 2020-08-22 15:47:11 +10:00
5dad65ac2a Update header files to match whitespace changes in source files 2020-08-22 15:46:31 +10:00
6315f10725 Merge branch 'ginggs-patch-1' 2020-08-22 15:36:02 +10:00
45062b26d6 Merge branch 'patch-1' of https://github.com/ginggs/htop-1 into ginggs-patch-1 2020-08-22 15:35:55 +10:00
ada780c867 Merge branch 'cgzones-ci2' 2020-08-22 15:35:02 +10:00
6aed2be247 Fix build on FreeBSD 2020-08-21 16:49:28 +02:00
9fde0835ed Avoid empty translation unit warning
zfs/ZfsArcStats.c:22: error: ISO C forbids an empty translation unit [-Werror=pedantic]
       22 | }*/
          |
2020-08-21 10:38:44 +02:00
b92f62f912 Remove trailing whitespaces 2020-08-21 10:37:33 +02:00
3856bf574b Introduce xAsprintf as checked version of asprintf 2020-08-21 10:37:29 +02:00
40ac7a88af MakeHeader.py: use python3 shebang
Also drop unused import
2020-08-21 10:37:27 +02:00
d6adc2b681 github/ci: improve ci
- split steps for readability
- fail on compiler warnings
- add whitespace check
- run on all branches
- run `make distcheck`
2020-08-21 10:37:25 +02:00
57254cdd05 configure: add option --enable-werror
Adds the compiler flag -Werror to fail on warnings.
Useful for CI runs.
2020-08-21 10:37:20 +02:00
0b276f80f1 Mention change of maintainership in ChangeLog
Related to https://github.com/hishamhm/htop/issues/992
2020-08-21 16:42:16 +10:00
bba8c3bb2e Update the changelog to reflect content in the 3.0.0 release 2020-08-21 12:10:11 +10:00
181 changed files with 1137 additions and 3192 deletions

View File

@ -1,29 +1,63 @@
name: CI name: CI
on: on: [ push, pull_request ]
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs: jobs:
build-ubuntu-latest: build-ubuntu-latest:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install Dependencies
run: sudo apt-get install libncursesw5-dev
- name: Bootstrap
run: ./autogen.sh
- name: Configure
run: ./configure --enable-werror
- name: Build - name: Build
run: | run: make
sudo apt-get install libncursesw5-dev - name: Distcheck
./autogen.sh run: make distcheck DISTCHECK_CONFIGURE_FLAGS=--enable-werror
./configure
make
# build-macos-latest: build-ubuntu-clang-latest:
# runs-on: macos-latest runs-on: ubuntu-latest
# steps: env:
# - uses: actions/checkout@v2 CC: clang-10
# - name: make steps:
# run: | - uses: actions/checkout@v2
# ./autogen.sh - name: install clang repo
# ./configure run: |
# make 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-10 main' -y
sudo apt-get update -q
- name: Install Dependencies
run: sudo apt-get install clang-10 libncursesw5-dev
- name: Bootstrap
run: ./autogen.sh
- name: Configure
run: ./configure --enable-werror
- name: Build
run: make
- name: Distcheck
run: make distcheck DISTCHECK_CONFIGURE_FLAGS=--enable-werror
build-ubuntu-latest-full-featured:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
run: sudo apt-get install libncursesw5-dev libhwloc-dev libnl-3-dev libnl-genl-3-dev
- name: Bootstrap
run: ./autogen.sh
- name: Configure
run: ./configure --enable-werror --enable-openvz --enable-cgroup --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-linux-affinity --enable-hwloc --enable-setuid --enable-delayacct
- name: Build
run: make
- name: Distcheck
run: make distcheck DISTCHECK_CONFIGURE_FLAGS='--enable-werror --enable-openvz --enable-cgroup --enable-vserver --enable-ancient-vserver --enable-taskstats --enable-unicode --enable-linux-affinity --enable-hwloc --enable-setuid --enable-delayacct'
whitespace_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: check-whitespaces
run: git diff-tree --check $(git hash-object -t tree /dev/null) HEAD

View File

@ -5,6 +5,7 @@ compiler:
- gcc - gcc
os: os:
- freebsd
- linux - linux
- osx - osx

View File

@ -30,38 +30,6 @@ in the source distribution for its full text.
#include <sys/param.h> #include <sys/param.h>
#include <sys/time.h> #include <sys/time.h>
/*{
#include "IncSet.h"
#include "Settings.h"
#include "Header.h"
#include "UsersTable.h"
#include "ProcessList.h"
#include "Panel.h"
typedef enum {
HTOP_OK = 0x00,
HTOP_REFRESH = 0x01,
HTOP_RECALCULATE = 0x03, // implies HTOP_REFRESH
HTOP_SAVE_SETTINGS = 0x04,
HTOP_KEEP_FOLLOWING = 0x08,
HTOP_QUIT = 0x10,
HTOP_REDRAW_BAR = 0x20,
HTOP_UPDATE_PANELHDR = 0x41, // implies HTOP_REFRESH
} Htop_Reaction;
typedef Htop_Reaction (*Htop_Action)();
typedef struct State_ {
Settings* settings;
UsersTable* ut;
ProcessList* pl;
Panel* panel;
Header* header;
} State;
}*/
Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess) { Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess) {
Panel* panel = st->panel; Panel* panel = st->panel;
Header* header = st->header; Header* header = st->header;
@ -316,17 +284,19 @@ static Htop_Reaction actionSetAffinity(State* st) {
Process* p = (Process*) Panel_getSelected(panel); Process* p = (Process*) Panel_getSelected(panel);
if (!p) return HTOP_OK; if (!p) return HTOP_OK;
Affinity* affinity = Affinity_get(p, st->pl); Affinity* affinity1 = Affinity_get(p, st->pl);
if (!affinity) return HTOP_OK; if (!affinity1) return HTOP_OK;
Panel* affinityPanel = AffinityPanel_new(st->pl, affinity); int width;
Affinity_delete(affinity); 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, 15, true); void* set = Action_pickFromVector(st, affinityPanel, width, true);
if (set) { if (set) {
Affinity* affinity = AffinityPanel_getAffinity(affinityPanel, st->pl); Affinity* affinity2 = AffinityPanel_getAffinity(affinityPanel, st->pl);
bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (Arg){ .v = affinity }, NULL); bool ok = MainPanel_foreachProcess((MainPanel*)panel, (MainPanel_ForeachProcessFn) Affinity_set, (Arg){ .v = affinity2 }, NULL);
if (!ok) beep(); if (!ok) beep();
Affinity_delete(affinity); Affinity_delete(affinity2);
} }
Panel_delete((Object*)affinityPanel); Panel_delete((Object*)affinityPanel);
#endif #endif
@ -615,4 +585,3 @@ void Action_setBindings(Htop_Action* keys) {
keys['c'] = actionTagAllChildren; keys['c'] = actionTagAllChildren;
keys['e'] = actionShowEnvScreen; keys['e'] = actionShowEnvScreen;
} }

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Action #ifndef HEADER_Action
#define HEADER_Action #define HEADER_Action
/* /*
@ -9,13 +7,11 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
#include "IncSet.h"
#include "Settings.h"
#include "Header.h" #include "Header.h"
#include "UsersTable.h"
#include "ProcessList.h"
#include "Panel.h" #include "Panel.h"
#include "ProcessList.h"
#include "Settings.h"
#include "UsersTable.h"
typedef enum { typedef enum {
HTOP_OK = 0x00, HTOP_OK = 0x00,
@ -38,21 +34,14 @@ typedef struct State_ {
Header* header; Header* header;
} State; } State;
Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess);
extern Object* Action_pickFromVector(State* st, Panel* list, int x, bool followProcess); bool Action_setUserOnly(const char* userName, uid_t* userId);
// ---------------------------------------- Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey);
extern bool Action_setUserOnly(const char* userName, uid_t* userId); Htop_Reaction Action_follow(State* st);
extern Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey);
// ----------------------------------------
extern Htop_Reaction Action_follow(State* st);
extern void Action_setBindings(Htop_Action* keys);
void Action_setBindings(Htop_Action* keys);
#endif #endif

View File

@ -21,18 +21,6 @@ in the source distribution for its full text.
#include <sched.h> #include <sched.h>
#endif #endif
/*{
#include "Process.h"
#include "ProcessList.h"
typedef struct Affinity_ {
ProcessList* pl;
int size;
int used;
int* cpus;
} Affinity;
}*/
Affinity* Affinity_new(ProcessList* pl) { Affinity* Affinity_new(ProcessList* pl) {
Affinity* this = xCalloc(1, sizeof(Affinity)); Affinity* this = xCalloc(1, sizeof(Affinity));

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Affinity #ifndef HEADER_Affinity
#define HEADER_Affinity #define HEADER_Affinity
/* /*
@ -10,15 +8,6 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
#ifdef HAVE_LIBHWLOC
#if __linux__
#define HTOP_HWLOC_CPUBIND_FLAG HWLOC_CPUBIND_THREAD
#else
#define HTOP_HWLOC_CPUBIND_FLAG HWLOC_CPUBIND_PROCESS
#endif
#elif HAVE_LINUX_AFFINITY
#endif
#include "Process.h" #include "Process.h"
#include "ProcessList.h" #include "ProcessList.h"
@ -29,24 +18,17 @@ typedef struct Affinity_ {
int* cpus; int* cpus;
} 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); #if defined(HAVE_LIBHWLOC) || defined(HAVE_LINUX_AFFINITY)
#ifdef HAVE_LIBHWLOC Affinity* Affinity_get(Process* proc, ProcessList* pl);
extern Affinity* Affinity_get(Process* proc, ProcessList* pl); bool Affinity_set(Process* proc, Arg arg);
extern bool Affinity_set(Process* proc, Arg arg);
#elif HAVE_LINUX_AFFINITY
extern Affinity* Affinity_get(Process* proc, ProcessList* pl);
extern bool Affinity_set(Process* proc, Arg arg);
#endif #endif

View File

@ -8,69 +8,411 @@ in the source distribution for its full text.
#include "AffinityPanel.h" #include "AffinityPanel.h"
#include "CRT.h" #include "CRT.h"
#include "CheckItem.h" #include "Vector.h"
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
/*{ #ifdef HAVE_LIBHWLOC
#include "Panel.h" #include <hwloc.h>
#include "Affinity.h" #endif
#include "ProcessList.h"
#include "ListItem.h" typedef struct MaskItem_ {
}*/ Object super;
const char* text;
const char* indent; /* used also as an condition whether this is a tree node */
int value; /* tri-state: 0 - off, 1 - some set, 2 - all set */
int sub_tree; /* tri-state: 0 - no sub-tree, 1 - open sub-tree, 2 - closed sub-tree */
Vector *children;
#ifdef HAVE_LIBHWLOC
bool ownCpuset;
hwloc_bitmap_t cpuset;
#else
int cpu;
#endif
} MaskItem;
static void MaskItem_delete(Object* cast) {
MaskItem* this = (MaskItem*) cast;
free((void*)this->text);
if (this->indent)
free((void*)this->indent);
Vector_delete(this->children);
#ifdef HAVE_LIBHWLOC
if (this->ownCpuset)
hwloc_bitmap_free(this->cpuset);
#endif
free(this);
}
static void MaskItem_display(Object* cast, RichString* out) {
MaskItem* this = (MaskItem*)cast;
assert (this != NULL);
RichString_append(out, CRT_colors[CHECK_BOX], "[");
if (this->value == 2)
RichString_append(out, CRT_colors[CHECK_MARK], "x");
else if (this->value == 1)
RichString_append(out, CRT_colors[CHECK_MARK], "o");
else
RichString_append(out, CRT_colors[CHECK_MARK], " ");
RichString_append(out, CRT_colors[CHECK_BOX], "]");
RichString_append(out, CRT_colors[CHECK_TEXT], " ");
if (this->indent) {
RichString_append(out, CRT_colors[PROCESS_TREE], this->indent);
RichString_append(out, CRT_colors[PROCESS_TREE],
this->sub_tree == 2
? CRT_treeStr[TREE_STR_OPEN]
: CRT_treeStr[TREE_STR_SHUT]);
RichString_append(out, CRT_colors[CHECK_TEXT], " ");
}
RichString_append(out, CRT_colors[CHECK_TEXT], this->text);
}
static ObjectClass MaskItem_class = {
.display = MaskItem_display,
.delete = MaskItem_delete
};
#ifdef HAVE_LIBHWLOC
static MaskItem* MaskItem_newMask(const char* text, const char* indent, hwloc_bitmap_t cpuset, bool owner) {
MaskItem* this = AllocThis(MaskItem);
this->text = xStrdup(text);
this->indent = xStrdup(indent); /* nonnull for tree node */
this->value = 0;
this->ownCpuset = owner;
this->cpuset = cpuset;
this->sub_tree = hwloc_bitmap_weight(cpuset) > 1 ? 1 : 0;
this->children = Vector_new(Class(MaskItem), true, DEFAULT_SIZE);
return this;
}
#endif
static MaskItem* MaskItem_newSingleton(const char* text, int cpu, bool isSet) {
MaskItem* this = AllocThis(MaskItem);
this->text = xStrdup(text);
this->indent = NULL; /* not a tree node */
this->sub_tree = 0;
this->children = Vector_new(Class(MaskItem), true, DEFAULT_SIZE);
#ifdef HAVE_LIBHWLOC
this->ownCpuset = true;
this->cpuset = hwloc_bitmap_alloc();
hwloc_bitmap_set(this->cpuset, cpu);
(void)isSet;
#else
this->cpu = cpu;
#endif
this->value = 2 * isSet;
return this;
}
typedef struct AffinityPanel_ {
Panel super;
ProcessList* pl;
bool topoView;
Vector *cpuids;
unsigned width;
#ifdef HAVE_LIBHWLOC
MaskItem *topoRoot;
hwloc_const_cpuset_t allCpuset;
hwloc_bitmap_t workCpuset;
#endif
} AffinityPanel;
static void AffinityPanel_delete(Object* cast) {
AffinityPanel* this = (AffinityPanel*) cast;
Panel* super = (Panel*) this;
Panel_done(super);
Vector_delete(this->cpuids);
#ifdef HAVE_LIBHWLOC
hwloc_bitmap_free(this->workCpuset);
MaskItem_delete((Object*) this->topoRoot);
#endif
free(this);
}
#ifdef HAVE_LIBHWLOC
static void AffinityPanel_updateItem(AffinityPanel* this, MaskItem* item) {
Panel* super = (Panel*) this;
item->value = hwloc_bitmap_isincluded(item->cpuset, this->workCpuset) ? 2 :
hwloc_bitmap_intersects(item->cpuset, this->workCpuset) ? 1 : 0;
Panel_add(super, (Object*) item);
}
static void AffinityPanel_updateTopo(AffinityPanel* this, MaskItem* item) {
AffinityPanel_updateItem(this, item);
if (item->sub_tree == 2)
return;
for (int i = 0; i < Vector_size(item->children); i++)
AffinityPanel_updateTopo(this, (MaskItem*) Vector_get(item->children, i));
}
#endif
static void AffinityPanel_update(AffinityPanel* this, bool keepSelected) {
Panel* super = (Panel*) this;
FunctionBar_setLabel(super->currentBar, KEY_F(3), this->topoView ? "Collapse/Expand" : "");
FunctionBar_draw(super->currentBar, NULL);
int oldSelected = Panel_getSelectedIndex(super);
Panel_prune(super);
#ifdef HAVE_LIBHWLOC
if (this->topoView)
AffinityPanel_updateTopo(this, this->topoRoot);
else {
for (int i = 0; i < Vector_size(this->cpuids); i++)
AffinityPanel_updateItem(this, (MaskItem*) Vector_get(this->cpuids, i));
}
#else
Panel_splice(super, this->cpuids);
#endif
if (keepSelected)
Panel_setSelected(super, oldSelected);
super->needsRedraw = true;
}
static HandlerResult AffinityPanel_eventHandler(Panel* super, int ch) {
AffinityPanel* this = (AffinityPanel*) super;
HandlerResult result = IGNORED;
MaskItem* selected = (MaskItem*) Panel_getSelected(super);
bool keepSelected = true;
static HandlerResult AffinityPanel_eventHandler(Panel* this, int ch) {
CheckItem* selected = (CheckItem*) Panel_getSelected(this);
switch(ch) { switch(ch) {
case KEY_MOUSE: case KEY_MOUSE:
case KEY_RECLICK: case KEY_RECLICK:
case ' ': case ' ':
CheckItem_set(selected, ! (CheckItem_get(selected)) ); #ifdef HAVE_LIBHWLOC
return HANDLED; if (selected->value == 2) {
/* Item was selected, so remove this mask from the top cpuset. */
hwloc_bitmap_andnot(this->workCpuset, this->workCpuset, selected->cpuset);
selected->value = 0;
} else {
/* Item was not or only partial selected, so set all bits from this object
in the top cpuset. */
hwloc_bitmap_or(this->workCpuset, this->workCpuset, selected->cpuset);
selected->value = 2;
}
#else
selected->value = 2 * !selected->value; /* toggle between 0 and 2 */
#endif
result = HANDLED;
break;
#ifdef HAVE_LIBHWLOC
case KEY_F(1):
hwloc_bitmap_copy(this->workCpuset, this->allCpuset);
result = HANDLED;
break;
case KEY_F(2):
this->topoView = !this->topoView;
keepSelected = false;
result = HANDLED;
break;
case KEY_F(3):
case '-':
case '+':
if (selected->sub_tree)
selected->sub_tree = 1 + !(selected->sub_tree - 1); /* toggle between 1 and 2 */
result = HANDLED;
break;
#endif
case 0x0a: case 0x0a:
case 0x0d: case 0x0d:
case KEY_ENTER: case KEY_ENTER:
return BREAK_LOOP; result = BREAK_LOOP;
break;
} }
return IGNORED;
if (HANDLED == result)
AffinityPanel_update(this, keepSelected);
return result;
} }
#ifdef HAVE_LIBHWLOC
static MaskItem *AffinityPanel_addObject(AffinityPanel* this, hwloc_obj_t obj, unsigned indent, MaskItem *parent) {
const char* type_name = hwloc_obj_type_string(obj->type);
const char* index_prefix = "#";
unsigned depth = obj->depth;
unsigned index = obj->logical_index;
size_t off = 0, left = 10 * depth;
char buf[64], indent_buf[left + 1];
if (obj->type == HWLOC_OBJ_PU) {
index = Settings_cpuId(this->pl->settings, obj->os_index);
type_name = "CPU";
index_prefix = "";
}
indent_buf[0] = '\0';
if (depth > 0) {
for (unsigned i = 1; i < depth; i++) {
xSnprintf(&indent_buf[off], left, "%s ", (indent & (1u << i)) ? CRT_treeStr[TREE_STR_VERT] : " ");
size_t len = strlen(&indent_buf[off]);
off += len, left -= len;
}
xSnprintf(&indent_buf[off], left, "%s",
obj->next_sibling ? CRT_treeStr[TREE_STR_RTEE] : CRT_treeStr[TREE_STR_BEND]);
size_t len = strlen(&indent_buf[off]);
off += len, left -= len;
}
xSnprintf(buf, 64, "%s %s%u", type_name, index_prefix, index);
MaskItem *item = MaskItem_newMask(buf, indent_buf, obj->complete_cpuset, false);
if (parent)
Vector_add(parent->children, item);
if (item->sub_tree && parent && parent->sub_tree == 1) {
/* if obj is fully included or fully excluded, collapse the item */
hwloc_bitmap_t result = hwloc_bitmap_alloc();
hwloc_bitmap_and(result, obj->complete_cpuset, this->workCpuset);
int weight = hwloc_bitmap_weight(result);
hwloc_bitmap_free(result);
if (weight == 0 || weight == (hwloc_bitmap_weight(this->workCpuset) + hwloc_bitmap_weight(obj->complete_cpuset)))
item->sub_tree = 2;
}
/* "[x] " + "|- " * depth + ("- ")?(if root node) + name */
unsigned width = 4 + 3 * depth + (2 * !depth) + strlen(buf);
if (width > this->width)
this->width = width;
return item;
}
static MaskItem *AffinityPanel_buildTopology(AffinityPanel* this, hwloc_obj_t obj, unsigned indent, MaskItem *parent) {
MaskItem *item = AffinityPanel_addObject(this, obj, indent, parent);
if (obj->next_sibling) {
indent |= (1u << obj->depth);
} else {
indent &= ~(1u << obj->depth);
}
for (unsigned i = 0; i < obj->arity; i++)
AffinityPanel_buildTopology(this, obj->children[i], indent, item);
return parent == NULL ? item : NULL;
}
#endif
PanelClass AffinityPanel_class = { PanelClass AffinityPanel_class = {
.super = { .super = {
.extends = Class(Panel), .extends = Class(Panel),
.delete = Panel_delete .delete = AffinityPanel_delete
}, },
.eventHandler = AffinityPanel_eventHandler .eventHandler = AffinityPanel_eventHandler
}; };
Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity) { static const char* const AffinityPanelFunctions[] = {
Panel* this = Panel_new(1, 1, 1, 1, true, Class(CheckItem), FunctionBar_newEnterEsc("Set ", "Cancel ")); "Set ",
Object_setClass(this, Class(AffinityPanel)); "Cancel ",
#ifdef HAVE_LIBHWLOC
"All",
"Topology",
" ",
#endif
NULL
};
static const char* const AffinityPanelKeys[] = {"Enter", "Esc", "F1", "F2", "F3"};
static const int AffinityPanelEvents[] = {13, 27, KEY_F(1), KEY_F(2), KEY_F(3)};
Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity, int* width) {
AffinityPanel* this = AllocThis(AffinityPanel);
Panel* super = (Panel*) this;
Panel_init(super, 1, 1, 1, 1, Class(MaskItem), false, FunctionBar_new(AffinityPanelFunctions, AffinityPanelKeys, AffinityPanelEvents));
this->pl = pl;
/* defaults to 15, this also includes the gap between the panels,
* but this will be added by the caller */
this->width = 14;
this->cpuids = Vector_new(Class(MaskItem), true, DEFAULT_SIZE);
#ifdef HAVE_LIBHWLOC
this->topoView = pl->settings->topologyAffinity;
#else
this->topoView = false;
#endif
#ifdef HAVE_LIBHWLOC
this->allCpuset = hwloc_topology_get_complete_cpuset(pl->topology);
this->workCpuset = hwloc_bitmap_alloc();
#endif
Panel_setHeader(super, "Use CPUs:");
Panel_setHeader(this, "Use CPUs:");
int curCpu = 0; int curCpu = 0;
for (int i = 0; i < pl->cpuCount; i++) { for (int i = 0; i < pl->cpuCount; i++) {
char number[10]; char number[16];
xSnprintf(number, 9, "%d", Settings_cpuId(pl->settings, i)); xSnprintf(number, 9, "CPU %d", Settings_cpuId(pl->settings, i));
bool mode; unsigned cpu_width = 4 + strlen(number);
if (cpu_width > this->width)
this->width = cpu_width;
bool isSet = false;
if (curCpu < affinity->used && affinity->cpus[curCpu] == i) { if (curCpu < affinity->used && affinity->cpus[curCpu] == i) {
mode = true; #ifdef HAVE_LIBHWLOC
hwloc_bitmap_set(this->workCpuset, i);
#endif
isSet = true;
curCpu++; curCpu++;
} else {
mode = false;
} }
Panel_add(this, (Object*) CheckItem_newByVal(xStrdup(number), mode));
MaskItem* cpuItem = MaskItem_newSingleton(number, i, isSet);
Vector_add(this->cpuids, (Object*) cpuItem);
} }
return this;
#ifdef HAVE_LIBHWLOC
this->topoRoot = AffinityPanel_buildTopology(this, hwloc_get_root_obj(pl->topology), 0, NULL);
#endif
if (width)
*width = this->width;
AffinityPanel_update(this, false);
return super;
} }
Affinity* AffinityPanel_getAffinity(Panel* this, ProcessList* pl) { Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) {
AffinityPanel* this = (AffinityPanel*) super;
Affinity* affinity = Affinity_new(pl); Affinity* affinity = Affinity_new(pl);
int size = Panel_size(this);
for (int i = 0; i < size; i++) { #ifdef HAVE_LIBHWLOC
if (CheckItem_get((CheckItem*)Panel_get(this, i))) int i;
Affinity_add(affinity, i); hwloc_bitmap_foreach_begin(i, this->workCpuset)
Affinity_add(affinity, i);
hwloc_bitmap_foreach_end();
#else
for (int i = 0; i < this->pl->cpuCount; i++) {
MaskItem* item = (MaskItem*)Vector_get(this->cpuids, i);
if (item->value)
Affinity_add(affinity, item->cpu);
} }
#endif
return affinity; return affinity;
} }

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_AffinityPanel #ifndef HEADER_AffinityPanel
#define HEADER_AffinityPanel #define HEADER_AffinityPanel
/* /*
@ -12,12 +10,11 @@ in the source distribution for its full text.
#include "Panel.h" #include "Panel.h"
#include "Affinity.h" #include "Affinity.h"
#include "ProcessList.h" #include "ProcessList.h"
#include "ListItem.h"
extern PanelClass AffinityPanel_class; extern PanelClass AffinityPanel_class;
extern Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity); Panel* AffinityPanel_new(ProcessList* pl, Affinity* affinity, int* width);
extern Affinity* AffinityPanel_getAffinity(Panel* this, ProcessList* pl); Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl);
#endif #endif

View File

@ -16,15 +16,6 @@ in the source distribution for its full text.
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
/*{
#include "Panel.h"
typedef struct AvailableColumnsPanel_ {
Panel super;
Panel* columns;
} AvailableColumnsPanel;
}*/
static const char* const AvailableColumnsFunctions[] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done ", NULL}; static const char* const AvailableColumnsFunctions[] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done ", NULL};

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_AvailableColumnsPanel #ifndef HEADER_AvailableColumnsPanel
#define HEADER_AvailableColumnsPanel #define HEADER_AvailableColumnsPanel
/* /*
@ -16,9 +14,8 @@ typedef struct AvailableColumnsPanel_ {
Panel* columns; Panel* columns;
} AvailableColumnsPanel; } AvailableColumnsPanel;
extern PanelClass AvailableColumnsPanel_class; extern PanelClass AvailableColumnsPanel_class;
extern AvailableColumnsPanel* AvailableColumnsPanel_new(Panel* columns); AvailableColumnsPanel* AvailableColumnsPanel_new(Panel* columns);
#endif #endif

View File

@ -16,23 +16,6 @@ in the source distribution for its full text.
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
/*{
#include "Settings.h"
#include "Panel.h"
#include "ScreenManager.h"
#include "ProcessList.h"
typedef struct AvailableMetersPanel_ {
Panel super;
ScreenManager* scr;
Settings* settings;
Header* header;
Panel* leftPanel;
Panel* rightPanel;
} AvailableMetersPanel;
}*/
static void AvailableMetersPanel_delete(Object* object) { static void AvailableMetersPanel_delete(Object* object) {
Panel* super = (Panel*) object; Panel* super = (Panel*) object;

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_AvailableMetersPanel #ifndef HEADER_AvailableMetersPanel
#define HEADER_AvailableMetersPanel #define HEADER_AvailableMetersPanel
/* /*
@ -24,9 +22,8 @@ typedef struct AvailableMetersPanel_ {
Panel* rightPanel; Panel* rightPanel;
} AvailableMetersPanel; } AvailableMetersPanel;
extern PanelClass AvailableMetersPanel_class; extern PanelClass AvailableMetersPanel_class;
extern AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* header, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr, ProcessList* pl); AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Header* header, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr, ProcessList* pl);
#endif #endif

View File

@ -18,15 +18,6 @@ This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com).
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
/*{
#include "Meter.h"
typedef enum ACPresence_ {
AC_ABSENT,
AC_PRESENT,
AC_ERROR
} ACPresence;
}*/
int BatteryMeter_attributes[] = { int BatteryMeter_attributes[] = {
BATTERY BATTERY

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_BatteryMeter #ifndef HEADER_BatteryMeter
#define HEADER_BatteryMeter #define HEADER_BatteryMeter
/* /*

View File

@ -1,56 +1,34 @@
Contributing Guide Contributing Guide
================== ==================
Hello, and thank you so much for taking your time to contribute in any way to Thank you so much for taking the time to contribute in to htop!
htop! There are many ways to contribute, and I'll try to list them below. The
support from the free software community has been amazing over the years and
it is the number one thing that keeps me going, maintaining and improving
something that started as a tiny pet project back in 2004 and that nowadays is
a piece of software used all over the world, in both reality [and
fiction!](http://hisham.hm/htop/index.php?page=sightings). Cheers!
-- Hisham Muhammad
Bug Reports Bug Reports
----------- -----------
Bug reports should be posted in the [Github issue Bug reports should be posted in the [Github issue
tracker](http://github.com/hishamhm/htop/issues). (I reply to them all, but I tracker](https://github.com/htop-dev/htop/issues).
usually do it in batches! :) ) Bug reports are extremely important since it's Bug reports are extremely important since it's impossible for us to test
impossible for me to test htop in every possible system, distribution and htop in every possible system, distribution and scenario. Your feedback
scenario. Your feedback is what keeps the tool stable and always improving! is what keeps the tool stable and always improving! Thank you!
Thank you!
Pull Requests Pull Requests
------------- -------------
Code contributions are most welcome! Just [fork the Code contributions are most welcome! Just [fork the
repo](http://github.com/hishamhm/htop) and send a [pull repo](https://github.com/htop-dev/htop) and send a [pull
request](https://github.com/hishamhm/htop/pulls). Help is especially request](https://github.com/htop-dev/htop/pulls). Help is especially
appreciated for support of platforms other than Linux. If proposing new appreciated for support of platforms other than Linux. If proposing new
features, please be mindful that htop is a system tool that needs to keep a features, please be mindful that htop is a system tool that needs to keep a
small footprint and perform well on systems under stress -- so unfortunately I small footprint and perform well on systems under stress -- so unfortunately
can't accept every new feature proposed, as I need to keep the tool slim and we can't accept every new feature proposed, as we need to keep the tool slim
maintainable. Great ideas backed by a PR are always carefully considered for and maintainable. Great ideas backed by a PR are always carefully considered
inclusion, though! Also, PRs containing bug fixes and portability tweaks are a for inclusion though! Also, PRs containing bug fixes and portability tweaks
no-brainer, please send those in! are always included, please send those in!
Feature Requests Feature Requests
---------------- ----------------
Back when htop was hosted in SourceForge, there used to be separate Bug Please label Github issues that are feature requests with the [`feature
Tracker and Feature Request pages. These go all lumped together under "Issues" request`](https://github.com/htop-dev/htop/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22feature+request%22+)
in Github, which is a bit confusing. For this reason, I close Feature Requests label.
and file them with the [`feature
request`](https://github.com/hishamhm/htop/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22feature+request%22+)
label, where they remain accessible, but not mixed with actual bug reports.
This doesn't mean I'm dismissing or ignoring feature requests right away! It's
just an organizational issue (with Github, really!).
Donations
---------
If you like htop, feel free to [buy the author a
beer](http://hisham.hm/htop/index.php?page=donate). :-)

View File

@ -353,4 +353,3 @@ Public License instead of this License.
applicable licenses of the version of PLPA used in your combined work, applicable licenses of the version of PLPA used in your combined work,
provided that you include the source code of such version of PLPA when provided that you include the source code of such version of PLPA when
and as the GNU GPL requires distribution of source code. and as the GNU GPL requires distribution of source code.

View File

@ -16,35 +16,10 @@ in the source distribution for its full text.
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
/*{
#include "Meter.h"
typedef enum {
CPU_METER_NICE = 0,
CPU_METER_NORMAL = 1,
CPU_METER_KERNEL = 2,
CPU_METER_IRQ = 3,
CPU_METER_SOFTIRQ = 4,
CPU_METER_STEAL = 5,
CPU_METER_GUEST = 6,
CPU_METER_IOWAIT = 7,
CPU_METER_FREQUENCY = 8,
CPU_METER_ITEMCOUNT = 9, // number of entries in this enum
} CPUMeterValues;
}*/
int CPUMeter_attributes[] = { int CPUMeter_attributes[] = {
CPU_NICE, CPU_NORMAL, CPU_SYSTEM, CPU_IRQ, CPU_SOFTIRQ, CPU_STEAL, CPU_GUEST, CPU_IOWAIT CPU_NICE, CPU_NORMAL, CPU_SYSTEM, CPU_IRQ, CPU_SOFTIRQ, CPU_STEAL, CPU_GUEST, CPU_IOWAIT
}; };
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
static void CPUMeter_init(Meter* this) { static void CPUMeter_init(Meter* this) {
int cpu = this->param; int cpu = this->param;
if (this->pl->cpuCount > 1) { if (this->pl->cpuCount > 1) {
@ -65,18 +40,12 @@ static void CPUMeter_updateValues(Meter* this, char* buffer, int size) {
memset(this->values, 0, sizeof(double) * CPU_METER_ITEMCOUNT); memset(this->values, 0, sizeof(double) * CPU_METER_ITEMCOUNT);
double percent = Platform_setCPUValues(this, cpu); double percent = Platform_setCPUValues(this, cpu);
if (this->pl->settings->showCPUFrequency) { if (this->pl->settings->showCPUFrequency) {
/* Initial frequency is in MHz. Emit it as GHz if it's larger than 1000MHz */
double cpuFrequency = this->values[CPU_METER_FREQUENCY]; double cpuFrequency = this->values[CPU_METER_FREQUENCY];
char unit = 'M';
char cpuFrequencyBuffer[16]; char cpuFrequencyBuffer[16];
if (cpuFrequency < 0) { if (cpuFrequency < 0) {
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "N/A"); xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "N/A");
} else { } else {
if (cpuFrequency > 1000) { xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%.0fMHz", cpuFrequency);
cpuFrequency /= 1000;
unit = 'G';
}
xSnprintf(cpuFrequencyBuffer, sizeof(cpuFrequencyBuffer), "%.3f%cHz", cpuFrequency, unit);
} }
if (this->pl->settings->showCPUUsage) { if (this->pl->settings->showCPUUsage) {
xSnprintf(buffer, size, "%5.1f%% %s", percent, cpuFrequencyBuffer); xSnprintf(buffer, size, "%5.1f%% %s", percent, cpuFrequencyBuffer);

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_CPUMeter #ifndef HEADER_CPUMeter
#define HEADER_CPUMeter #define HEADER_CPUMeter
/* /*
@ -24,16 +22,8 @@ typedef enum {
CPU_METER_ITEMCOUNT = 9, // number of entries in this enum CPU_METER_ITEMCOUNT = 9, // number of entries in this enum
} CPUMeterValues; } CPUMeterValues;
extern int CPUMeter_attributes[]; extern int CPUMeter_attributes[];
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
extern MeterClass CPUMeter_class; extern MeterClass CPUMeter_class;
extern MeterClass AllCPUsMeter_class; extern MeterClass AllCPUsMeter_class;

127
CRT.c
View File

@ -39,116 +39,6 @@ in the source distribution for its full text.
#define ColorPairGrayBlack ColorPair(Magenta,Magenta) #define ColorPairGrayBlack ColorPair(Magenta,Magenta)
#define ColorIndexGrayBlack ColorIndex(Magenta,Magenta) #define ColorIndexGrayBlack ColorIndex(Magenta,Magenta)
#define KEY_WHEELUP KEY_F(20)
#define KEY_WHEELDOWN KEY_F(21)
#define KEY_RECLICK KEY_F(22)
//#link curses
/*{
#include <stdbool.h>
typedef enum TreeStr_ {
TREE_STR_HORZ,
TREE_STR_VERT,
TREE_STR_RTEE,
TREE_STR_BEND,
TREE_STR_TEND,
TREE_STR_OPEN,
TREE_STR_SHUT,
TREE_STR_COUNT
} TreeStr;
typedef enum ColorSchemes_ {
COLORSCHEME_DEFAULT = 0,
COLORSCHEME_MONOCHROME = 1,
COLORSCHEME_BLACKONWHITE = 2,
COLORSCHEME_LIGHTTERMINAL = 3,
COLORSCHEME_MIDNIGHT = 4,
COLORSCHEME_BLACKNIGHT = 5,
COLORSCHEME_BROKENGRAY = 6,
LAST_COLORSCHEME = 7,
} ColorSchemes;
typedef enum ColorElements_ {
RESET_COLOR,
DEFAULT_COLOR,
FUNCTION_BAR,
FUNCTION_KEY,
FAILED_SEARCH,
PANEL_HEADER_FOCUS,
PANEL_HEADER_UNFOCUS,
PANEL_SELECTION_FOCUS,
PANEL_SELECTION_FOLLOW,
PANEL_SELECTION_UNFOCUS,
LARGE_NUMBER,
METER_TEXT,
METER_VALUE,
LED_COLOR,
UPTIME,
BATTERY,
TASKS_RUNNING,
SWAP,
PROCESS,
PROCESS_SHADOW,
PROCESS_TAG,
PROCESS_MEGABYTES,
PROCESS_TREE,
PROCESS_R_STATE,
PROCESS_D_STATE,
PROCESS_BASENAME,
PROCESS_HIGH_PRIORITY,
PROCESS_LOW_PRIORITY,
PROCESS_THREAD,
PROCESS_THREAD_BASENAME,
BAR_BORDER,
BAR_SHADOW,
GRAPH_1,
GRAPH_2,
MEMORY_USED,
MEMORY_BUFFERS,
MEMORY_BUFFERS_TEXT,
MEMORY_CACHE,
LOAD,
LOAD_AVERAGE_FIFTEEN,
LOAD_AVERAGE_FIVE,
LOAD_AVERAGE_ONE,
CHECK_BOX,
CHECK_MARK,
CHECK_TEXT,
CLOCK,
HELP_BOLD,
HOSTNAME,
CPU_NICE,
CPU_NICE_TEXT,
CPU_NORMAL,
CPU_SYSTEM,
CPU_IOWAIT,
CPU_IRQ,
CPU_SOFTIRQ,
CPU_STEAL,
CPU_GUEST,
PRESSURE_STALL_TEN,
PRESSURE_STALL_SIXTY,
PRESSURE_STALL_THREEHUNDRED,
ZFS_MFU,
ZFS_MRU,
ZFS_ANON,
ZFS_HEADER,
ZFS_OTHER,
ZFS_COMPRESSED,
ZFS_RATIO,
LAST_COLORELEMENT
} ColorElements;
extern void CRT_fatalError(const char* note) __attribute__ ((noreturn));
extern void CRT_handleSIGSEGV(int sgn);
#define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A'))
}*/
const char *CRT_treeStrAscii[TREE_STR_COUNT] = { const char *CRT_treeStrAscii[TREE_STR_COUNT] = {
"-", // TREE_STR_HORZ "-", // TREE_STR_HORZ
"|", // TREE_STR_VERT "|", // TREE_STR_VERT
@ -167,7 +57,9 @@ const char *CRT_treeStrUtf8[TREE_STR_COUNT] = {
"\xe2\x94\x9c", // TREE_STR_RTEE ├ "\xe2\x94\x9c", // TREE_STR_RTEE ├
"\xe2\x94\x94", // TREE_STR_BEND └ "\xe2\x94\x94", // TREE_STR_BEND └
"\xe2\x94\x8c", // TREE_STR_TEND ┌ "\xe2\x94\x8c", // TREE_STR_TEND ┌
"+", // TREE_STR_OPEN + "+", // TREE_STR_OPEN +, TODO use 🮯 'BOX DRAWINGS LIGHT HORIZONTAL
// WITH VERTICAL STROKE' (U+1FBAF, "\xf0\x9f\xae\xaf") when
// Unicode 13 is common
"\xe2\x94\x80", // TREE_STR_SHUT ─ "\xe2\x94\x80", // TREE_STR_SHUT ─
}; };
@ -654,18 +546,13 @@ void CRT_restorePrivileges() {
#else #else
/* Turn setuid operations into NOPs */ // In this case, the setuid operations are defined as macros in CRT.h
#ifndef CRT_dropPrivileges
#define CRT_dropPrivileges()
#define CRT_restorePrivileges()
#endif
#endif #endif
// TODO: pass an instance of Settings instead. // TODO: pass an instance of Settings instead.
void CRT_init(int delay, int colorScheme) { void CRT_init(int delay, int colorScheme, bool allowUnicode) {
initscr(); initscr();
noecho(); noecho();
CRT_delay = delay; CRT_delay = delay;
@ -731,10 +618,12 @@ void CRT_init(int delay, int colorScheme) {
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
#ifdef HAVE_LIBNCURSESW #ifdef HAVE_LIBNCURSESW
if(strcmp(nl_langinfo(CODESET), "UTF-8") == 0) if (allowUnicode && strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
CRT_utf8 = true; CRT_utf8 = true;
else else
CRT_utf8 = false; CRT_utf8 = false;
#else
(void) allowUnicode;
#endif #endif
CRT_treeStr = CRT_treeStr =

59
CRT.h
View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_CRT #ifndef HEADER_CRT
#define HEADER_CRT #define HEADER_CRT
/* /*
@ -9,33 +7,12 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
#if HAVE_SETUID_ENABLED
#endif
#define ColorIndex(i,j) ((7-i)*8+j)
#define ColorPair(i,j) COLOR_PAIR(ColorIndex(i,j))
#define Black COLOR_BLACK
#define Red COLOR_RED
#define Green COLOR_GREEN
#define Yellow COLOR_YELLOW
#define Blue COLOR_BLUE
#define Magenta COLOR_MAGENTA
#define Cyan COLOR_CYAN
#define White COLOR_WHITE
#define ColorPairGrayBlack ColorPair(Magenta,Magenta)
#define ColorIndexGrayBlack ColorIndex(Magenta,Magenta)
#define KEY_WHEELUP KEY_F(20)
#define KEY_WHEELDOWN KEY_F(21)
#define KEY_RECLICK KEY_F(22)
//#link curses
#include <stdbool.h> #include <stdbool.h>
#define KEY_WHEELUP KEY_F(20)
#define KEY_WHEELDOWN KEY_F(21)
#define KEY_RECLICK KEY_F(22)
typedef enum TreeStr_ { typedef enum TreeStr_ {
TREE_STR_HORZ, TREE_STR_HORZ,
TREE_STR_VERT, TREE_STR_VERT,
@ -129,9 +106,9 @@ typedef enum ColorElements_ {
LAST_COLORELEMENT LAST_COLORELEMENT
} ColorElements; } ColorElements;
extern void CRT_fatalError(const char* note) __attribute__ ((noreturn)); void CRT_fatalError(const char* note) __attribute__ ((noreturn));
extern void CRT_handleSIGSEGV(int sgn); void CRT_handleSIGSEGV(int sgn);
#define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A')) #define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A'))
@ -162,19 +139,15 @@ extern int CRT_scrollWheelVAmount;
extern char* CRT_termType; extern char* CRT_termType;
// TODO move color scheme to Settings, perhaps?
extern int CRT_colorScheme; extern int CRT_colorScheme;
extern void *backtraceArray[128]; extern void *backtraceArray[128];
#if HAVE_SETUID_ENABLED #if HAVE_SETUID_ENABLED
#define DIE(msg) do { CRT_done(); fprintf(stderr, msg); exit(1); } while(0) void CRT_dropPrivileges();
extern void CRT_dropPrivileges(); void CRT_restorePrivileges();
extern void CRT_restorePrivileges();
#else #else
@ -187,20 +160,18 @@ extern void CRT_restorePrivileges();
#endif #endif
// TODO: pass an instance of Settings instead. void CRT_init(int delay, int colorScheme, bool allowUnicode);
extern void CRT_init(int delay, int colorScheme); void CRT_done();
extern void CRT_done(); void CRT_fatalError(const char* note);
extern void CRT_fatalError(const char* note); int CRT_readKey();
extern int CRT_readKey(); void CRT_disableDelay();
extern void CRT_disableDelay(); void CRT_enableDelay();
extern void CRT_enableDelay(); void CRT_setColors(int colorScheme);
extern void CRT_setColors(int colorScheme);
#endif #endif

View File

@ -17,22 +17,6 @@ in the source distribution for its full text.
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
/*{
#include "Panel.h"
#include "Settings.h"
#include "ScreenManager.h"
#include "ProcessList.h"
typedef struct CategoriesPanel_ {
Panel super;
ScreenManager* scr;
Settings* settings;
Header* header;
ProcessList* pl;
} CategoriesPanel;
}*/
static const char* const CategoriesFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; static const char* const CategoriesFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_CategoriesPanel #ifndef HEADER_CategoriesPanel
#define HEADER_CategoriesPanel #define HEADER_CategoriesPanel
/* /*
@ -23,11 +21,10 @@ typedef struct CategoriesPanel_ {
ProcessList* pl; ProcessList* pl;
} CategoriesPanel; } CategoriesPanel;
void CategoriesPanel_makeMetersPage(CategoriesPanel* this);
extern void CategoriesPanel_makeMetersPage(CategoriesPanel* this);
extern PanelClass CategoriesPanel_class; extern PanelClass CategoriesPanel_class;
extern CategoriesPanel* CategoriesPanel_new(ScreenManager* scr, Settings* settings, Header* header, ProcessList* pl); CategoriesPanel* CategoriesPanel_new(ScreenManager* scr, Settings* settings, Header* header, ProcessList* pl);
#endif #endif

View File

@ -1,3 +1,89 @@
What's new in version 3.0.2
* BUGFIX: Drop 'vim_mode' - several issues, needs rethink
* BUGFIX: fix regression in -u optional-argument handling
* Build system rework to remove python, header generation
(thanks to Zev Weiss and Hugo Musso Gualandi)
* BUGFIX: report nice level correctly on Solaris
(thanks to Dominik Hassler)
* CI, code quality improvements
(thanks to Tobias Kortkamp, Christian Hesse, Benny Baumann)
What's new in version 3.0.1
* Coverity fixes, CI improvements, documentation updates
* BUGFIX: Fix early exit with longer sysfs battery paths
* BUGFIX: Improve OOM output, fix sorting
(thanks to Christian Göttsche)
* Rework check buttons and tree open/closed
(thanks to Bert Wesarg)
* Add -U/--no-unicode option to disable unicode
(thanks to Christian Hesse)
* Improvements to the affinity panel
(thanks to Bert Wesarg)
What's new in version 3.0.0
* New maintainers - after a prolonged period of inactivity
from Hisham, the creator and original maintainer, a team
of community maintainers have volunteered to take over a
fork at https://htop.dev and https://github.com/htop-dev
to keep the project going.
* Support ZFS ARC statistics
(thanks to Ross Williams)
* Support more than 2 smaller CPU meter columns
(thanks to Christoph Budziszewski)
* Support Linux proportional set size metrics
(thanks to @linvinus, @ntninja and @himikof)
* Support Linux pressure stall information metrics
(thanks to Ran Benita)
* New display option to show CPU frequency in CPU meters
(thanks to Arnav Singh)
* Update Linux sysfs battery discovery for recent kernels
(thanks to @smattie)
* Add hardware topology information in the affinity panel
(thanks to Bert Wesarg)
* Add timestamp reporting to the strace screen
(thanks to Mario Harjac)
* Add simple, optional vim key mapping mode
(thanks to Daniel Flanagan)
* Added an option to disable the mouse
(thanks to MartinJM)
* Add Solaris11 compatibility
(thanks to Jan Senolt)
* Without an argument -u uses $USER value automatically
(thanks to @solanav)
* Support less(1) search navigation shortcuts
(thanks to @syrrim)
* Update the FreeBSD maximum PID to match FreeBSD change
(thanks to @multiplexd)
* Report values larger than 100 terabytes
(thanks to @adrien1018)
* Widen ST_UID (UID) column to allow for UIDs > 9999
(thanks to DLange)
* BUGFIX: fix makefiles for building with clang
(thanks to Jorge Pereira)
* BUGFIX: fix <sys/sysmacros.h> major() usage
(thanks to @wataash and Kang-Che Sung)
* BUGFIX: fix the STARTTIME column on FreeBSD
(thanks to Rob Crowston)
* BUGFIX: truncate overwide jail names on FreeBSD
(thanks to Rob Crowston)
* BUGFIX: fix reported memory values on FreeBSD
(thanks to Tobias Kortkamp)
* BUGFIX: fix reported CPU meter values on OpenBSD
(thanks to @motet-a)
* BUGFIX: correctly identify other types of zombie process
(thanks to @joder)
* BUGFIX: improve follow-process handling in some situations
(thanks to @wangqr)
* BUGFIX: fix custom meters reverting to unexpected setting
(thanks to @wangqr)
* BUGFIX: close pipe after running lsof(1)
(thanks to Jesin)
* BUGFIX: meters honour setting of counting CPUs from 0/1
(thanks to @rnsanchez)
What's new in version 2.2.0 What's new in version 2.2.0
* Solaris/Illumos/OpenIndiana support * Solaris/Illumos/OpenIndiana support
@ -158,7 +244,7 @@ What's new in version 1.0.2
What's new in version 1.0.1 What's new in version 1.0.1
* Move .htoprc to XDG-compliant path ~/.config/htop/htoprc, * Move .htoprc to XDG-compliant path ~/.config/htop/htoprc,
respecting $XDG_CONFIG_HOME respecting $XDG_CONFIG_HOME
(thanks to Hadzhimurad Ustarkhan for the suggestion.) (thanks to Hadzhimurad Ustarkhan for the suggestion.)
* Safer behavior on the kill screen, to make it harder to kill the wrong process. * Safer behavior on the kill screen, to make it harder to kill the wrong process.
* Fix for building in FreeBSD 8.2 * Fix for building in FreeBSD 8.2
@ -546,7 +632,7 @@ What's new in version 0.3.1
What's new in version 0.3 What's new in version 0.3
* BUGFIX: no dirt left on screen on horizontal scrolling * BUGFIX: no dirt left on screen on horizontal scrolling
* Signal selection on "kill" command * Signal selection on "kill" command
* Color-coding for users, nice and process status * Color-coding for users, nice and process status
* "Follow" function * "Follow" function

View File

@ -12,17 +12,6 @@ in the source distribution for its full text.
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
/*{
#include "Object.h"
typedef struct CheckItem_ {
Object super;
char* text;
bool* ref;
bool value;
} CheckItem;
}*/
static void CheckItem_delete(Object* cast) { static void CheckItem_delete(Object* cast) {
CheckItem* this = (CheckItem*)cast; CheckItem* this = (CheckItem*)cast;

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_CheckItem #ifndef HEADER_CheckItem
#define HEADER_CheckItem #define HEADER_CheckItem
/* /*
@ -18,15 +16,14 @@ typedef struct CheckItem_ {
bool value; bool value;
} CheckItem; } CheckItem;
extern ObjectClass CheckItem_class; extern ObjectClass CheckItem_class;
extern CheckItem* CheckItem_newByRef(char* text, bool* ref); CheckItem* CheckItem_newByRef(char* text, bool* ref);
extern CheckItem* CheckItem_newByVal(char* text, bool value); CheckItem* CheckItem_newByVal(char* text, bool value);
extern void CheckItem_set(CheckItem* this, bool value); void CheckItem_set(CheckItem* this, bool value);
extern bool CheckItem_get(CheckItem* this); bool CheckItem_get(CheckItem* this);
#endif #endif

View File

@ -11,9 +11,6 @@ in the source distribution for its full text.
#include <time.h> #include <time.h>
/*{
#include "Meter.h"
}*/
int ClockMeter_attributes[] = { int ClockMeter_attributes[] = {
CLOCK CLOCK

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_ClockMeter #ifndef HEADER_ClockMeter
#define HEADER_ClockMeter #define HEADER_ClockMeter
/* /*

View File

@ -20,19 +20,6 @@ in the source distribution for its full text.
// * Add a define in CRT.h that matches the order of the array // * Add a define in CRT.h that matches the order of the array
// * Add the colors in CRT_setColors // * Add the colors in CRT_setColors
/*{
#include "Panel.h"
#include "Settings.h"
#include "ScreenManager.h"
typedef struct ColorsPanel_ {
Panel super;
Settings* settings;
ScreenManager* scr;
} ColorsPanel;
}*/
static const char* const ColorsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; static const char* const ColorsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_ColorsPanel #ifndef HEADER_ColorsPanel
#define HEADER_ColorsPanel #define HEADER_ColorsPanel
/* /*
@ -9,12 +7,6 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
// TO ADD A NEW SCHEME:
// * Increment the size of bool check in ColorsPanel.h
// * Add the entry in the ColorSchemeNames array below in the file
// * Add a define in CRT.h that matches the order of the array
// * Add the colors in CRT_setColors
#include "Panel.h" #include "Panel.h"
#include "Settings.h" #include "Settings.h"
#include "ScreenManager.h" #include "ScreenManager.h"
@ -26,9 +18,8 @@ typedef struct ColorsPanel_ {
ScreenManager* scr; ScreenManager* scr;
} ColorsPanel; } ColorsPanel;
extern PanelClass ColorsPanel_class; extern PanelClass ColorsPanel_class;
extern ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr); ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr);
#endif #endif

View File

@ -16,18 +16,6 @@ in the source distribution for its full text.
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
/*{
#include "Panel.h"
#include "Settings.h"
typedef struct ColumnsPanel_ {
Panel super;
Settings* settings;
bool moving;
} ColumnsPanel;
}*/
static const char* const ColumnsFunctions[] = {" ", " ", " ", " ", " ", " ", "MoveUp", "MoveDn", "Remove", "Done ", NULL}; static const char* const ColumnsFunctions[] = {" ", " ", " ", " ", " ", " ", "MoveUp", "MoveDn", "Remove", "Done ", NULL};
@ -164,4 +152,3 @@ void ColumnsPanel_update(Panel* super) {
} }
this->settings->fields[size] = 0; this->settings->fields[size] = 0;
} }

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_ColumnsPanel #ifndef HEADER_ColumnsPanel
#define HEADER_ColumnsPanel #define HEADER_ColumnsPanel
/* /*
@ -19,14 +17,12 @@ typedef struct ColumnsPanel_ {
bool moving; bool moving;
} ColumnsPanel; } ColumnsPanel;
extern PanelClass ColumnsPanel_class; extern PanelClass ColumnsPanel_class;
extern ColumnsPanel* ColumnsPanel_new(Settings* settings); ColumnsPanel* ColumnsPanel_new(Settings* settings);
extern int ColumnsPanel_fieldNameToIndex(const char* name); int ColumnsPanel_fieldNameToIndex(const char* name);
extern void ColumnsPanel_update(Panel* super);
void ColumnsPanel_update(Panel* super);
#endif #endif

View File

@ -14,19 +14,6 @@ in the source distribution for its full text.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
/*{
#include "Panel.h"
#include "Settings.h"
#include "ScreenManager.h"
typedef struct DisplayOptionsPanel_ {
Panel super;
Settings* settings;
ScreenManager* scr;
} DisplayOptionsPanel;
}*/
static const char* const DisplayOptionsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; static const char* const DisplayOptionsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL};
@ -100,5 +87,8 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Also show CPU percentage numerically"), &(settings->showCPUUsage))); Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Also show CPU percentage numerically"), &(settings->showCPUUsage)));
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Also show CPU frequency"), &(settings->showCPUFrequency))); Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Also show CPU frequency"), &(settings->showCPUFrequency)));
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Enable the mouse"), &(settings->enableMouse))); Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Enable the mouse"), &(settings->enableMouse)));
#ifdef HAVE_LIBHWLOC
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Show topology when selecting affinity by default"), &(settings->topologyAffinity)));
#endif
return this; return this;
} }

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_DisplayOptionsPanel #ifndef HEADER_DisplayOptionsPanel
#define HEADER_DisplayOptionsPanel #define HEADER_DisplayOptionsPanel
/* /*
@ -20,9 +18,8 @@ typedef struct DisplayOptionsPanel_ {
ScreenManager* scr; ScreenManager* scr;
} DisplayOptionsPanel; } DisplayOptionsPanel;
extern PanelClass DisplayOptionsPanel_class; extern PanelClass DisplayOptionsPanel_class;
extern DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr); DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr);
#endif #endif

View File

@ -11,13 +11,6 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
/*{
#include "InfoScreen.h"
typedef struct EnvScreen_ {
InfoScreen super;
} EnvScreen;
}*/
InfoScreenClass EnvScreen_class = { InfoScreenClass EnvScreen_class = {
.super = { .super = {
@ -44,7 +37,7 @@ void EnvScreen_draw(InfoScreen* this) {
void EnvScreen_scan(InfoScreen* this) { void EnvScreen_scan(InfoScreen* this) {
Panel* panel = this->display; Panel* panel = this->display;
int idx = MAX(Panel_getSelectedIndex(panel), 0); int idx = MAXIMUM(Panel_getSelectedIndex(panel), 0);
Panel_prune(panel); Panel_prune(panel);

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_EnvScreen #ifndef HEADER_EnvScreen
#define HEADER_EnvScreen #define HEADER_EnvScreen
@ -11,12 +9,12 @@ typedef struct EnvScreen_ {
extern InfoScreenClass EnvScreen_class; extern InfoScreenClass EnvScreen_class;
extern EnvScreen* EnvScreen_new(Process* process); EnvScreen* EnvScreen_new(Process* process);
extern void EnvScreen_delete(Object* this); void EnvScreen_delete(Object* this);
extern void EnvScreen_draw(InfoScreen* this); void EnvScreen_draw(InfoScreen* this);
extern void EnvScreen_scan(InfoScreen* this); void EnvScreen_scan(InfoScreen* this);
#endif #endif

View File

@ -14,19 +14,6 @@ in the source distribution for its full text.
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
/*{
#include <stdbool.h>
typedef struct FunctionBar_ {
int size;
char** functions;
char** keys;
int* events;
bool staticData;
} FunctionBar;
}*/
static const char* const FunctionBar_FKeys[] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", NULL}; static const char* const FunctionBar_FKeys[] = {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", NULL};

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_FunctionBar #ifndef HEADER_FunctionBar
#define HEADER_FunctionBar #define HEADER_FunctionBar
/* /*
@ -9,7 +7,6 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
#include <stdbool.h> #include <stdbool.h>
typedef struct FunctionBar_ { typedef struct FunctionBar_ {
@ -20,20 +17,18 @@ typedef struct FunctionBar_ {
bool staticData; bool staticData;
} FunctionBar; } FunctionBar;
FunctionBar* FunctionBar_newEnterEsc(const char* enter, const char* esc);
FunctionBar* FunctionBar_new(const char* const* functions, const char* const* keys, const int* events);
extern FunctionBar* FunctionBar_newEnterEsc(const char* enter, const char* esc); void FunctionBar_delete(FunctionBar* this);
extern FunctionBar* FunctionBar_new(const char* const* functions, const char* const* keys, const int* events); void FunctionBar_setLabel(FunctionBar* this, int event, const char* text);
extern void FunctionBar_delete(FunctionBar* this); void FunctionBar_draw(const FunctionBar* this, char* buffer);
extern void FunctionBar_setLabel(FunctionBar* this, int event, const char* text); void FunctionBar_drawAttr(const FunctionBar* this, char* buffer, int attr);
extern void FunctionBar_draw(const FunctionBar* this, char* buffer); int FunctionBar_synthesizeEvent(const FunctionBar* this, int pos);
extern void FunctionBar_drawAttr(const FunctionBar* this, char* buffer, int attr);
extern int FunctionBar_synthesizeEvent(const FunctionBar* this, int pos);
#endif #endif

View File

@ -11,26 +11,6 @@ in the source distribution for its full text.
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
/*{
#include <stdbool.h>
typedef struct Hashtable_ Hashtable;
typedef void(*Hashtable_PairFunction)(int, void*, void*);
typedef struct HashtableItem {
unsigned int key;
void* value;
struct HashtableItem* next;
} HashtableItem;
struct Hashtable_ {
int size;
HashtableItem** buckets;
int items;
bool owner;
};
}*/
#ifdef DEBUG #ifdef DEBUG

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Hashtable #ifndef HEADER_Hashtable
#define HEADER_Hashtable #define HEADER_Hashtable
/* /*
@ -30,20 +28,20 @@ struct Hashtable_ {
#ifdef DEBUG #ifdef DEBUG
extern int Hashtable_count(Hashtable* this); int Hashtable_count(Hashtable* this);
#endif #endif
extern Hashtable* Hashtable_new(int size, bool owner); Hashtable* Hashtable_new(int size, bool owner);
extern void Hashtable_delete(Hashtable* this); void Hashtable_delete(Hashtable* this);
extern void Hashtable_put(Hashtable* this, unsigned int key, void* value); void Hashtable_put(Hashtable* this, unsigned int key, void* value);
extern void* Hashtable_remove(Hashtable* this, unsigned int key); void* Hashtable_remove(Hashtable* this, unsigned int key);
extern void* Hashtable_get(Hashtable* this, unsigned int key); void* Hashtable_get(Hashtable* this, unsigned int key);
extern void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData); void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData);
#endif #endif

View File

@ -16,30 +16,6 @@ in the source distribution for its full text.
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
/*{
#include "Meter.h"
#include "Settings.h"
#include "Vector.h"
typedef struct Header_ {
Vector** columns;
Settings* settings;
struct ProcessList_* pl;
int nrColumns;
int pad;
int height;
} Header;
}*/
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#ifndef Header_forEachColumn
#define Header_forEachColumn(this_, i_) for (int (i_)=0; (i_) < (this_)->nrColumns; ++(i_))
#endif
Header* Header_new(struct ProcessList_* pl, Settings* settings, int nrColumns) { Header* Header_new(struct ProcessList_* pl, Settings* settings, int nrColumns) {
Header* this = xCalloc(1, sizeof(Header)); Header* this = xCalloc(1, sizeof(Header));
this->columns = xCalloc(nrColumns, sizeof(Vector*)); this->columns = xCalloc(nrColumns, sizeof(Vector*));
@ -154,7 +130,7 @@ char* Header_readMeterName(Header* this, int i, int column) {
int nameLen = strlen(Meter_name(meter)); int nameLen = strlen(Meter_name(meter));
int len = nameLen + 100; int len = nameLen + 100;
char* name = xMalloc(len); char* name = xMalloc(len);
strncpy(name, Meter_name(meter), nameLen); memcpy(name, Meter_name(meter), nameLen);
name[nameLen] = '\0'; name[nameLen] = '\0';
if (meter->param) if (meter->param)
xSnprintf(name + nameLen, len - nameLen, "(%d)", meter->param); xSnprintf(name + nameLen, len - nameLen, "(%d)", meter->param);
@ -211,7 +187,7 @@ int Header_calculateHeight(Header* this) {
Meter* meter = (Meter*) Vector_get(meters, i); Meter* meter = (Meter*) Vector_get(meters, i);
height += meter->h; height += meter->h;
} }
maxHeight = MAX(maxHeight, height); maxHeight = MAXIMUM(maxHeight, height);
} }
this->height = maxHeight; this->height = maxHeight;
this->pad = pad; this->pad = pad;

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Header #ifndef HEADER_Header
#define HEADER_Header #define HEADER_Header
/* /*
@ -22,39 +20,32 @@ typedef struct Header_ {
int height; int height;
} Header; } Header;
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#ifndef Header_forEachColumn
#define Header_forEachColumn(this_, i_) for (int (i_)=0; (i_) < (this_)->nrColumns; ++(i_)) #define Header_forEachColumn(this_, i_) for (int (i_)=0; (i_) < (this_)->nrColumns; ++(i_))
#endif
extern Header* Header_new(struct ProcessList_* pl, Settings* settings, int nrColumns); Header* Header_new(struct ProcessList_* pl, Settings* settings, int nrColumns);
extern void Header_delete(Header* this); void Header_delete(Header* this);
extern void Header_populateFromSettings(Header* this); void Header_populateFromSettings(Header* this);
extern void Header_writeBackToSettings(const Header* this); void Header_writeBackToSettings(const Header* this);
extern MeterModeId Header_addMeterByName(Header* this, char* name, int column); MeterModeId Header_addMeterByName(Header* this, char* name, int column);
extern void Header_setMode(Header* this, int i, MeterModeId mode, int column); void Header_setMode(Header* this, int i, MeterModeId mode, int column);
extern Meter* Header_addMeterByClass(Header* this, MeterClass* type, int param, int column); Meter* Header_addMeterByClass(Header* this, MeterClass* type, int param, int column);
extern int Header_size(Header* this, int column); int Header_size(Header* this, int column);
extern char* Header_readMeterName(Header* this, int i, int column); char* Header_readMeterName(Header* this, int i, int column);
extern MeterModeId Header_readMeterMode(Header* this, int i, int column); MeterModeId Header_readMeterMode(Header* this, int i, int column);
extern void Header_reinit(Header* this); void Header_reinit(Header* this);
extern void Header_draw(const Header* this); void Header_draw(const Header* this);
extern int Header_calculateHeight(Header* this); int Header_calculateHeight(Header* this);
#endif #endif

View File

@ -11,9 +11,6 @@ in the source distribution for its full text.
#include <unistd.h> #include <unistd.h>
/*{
#include "Meter.h"
}*/
int HostnameMeter_attributes[] = { int HostnameMeter_attributes[] = {
HOSTNAME HOSTNAME

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_HostnameMeter #ifndef HEADER_HostnameMeter
#define HEADER_HostnameMeter #define HEADER_HostnameMeter
/* /*

View File

@ -7,45 +7,11 @@ in the source distribution for its full text.
#include "IncSet.h" #include "IncSet.h"
#include "StringUtils.h" #include "StringUtils.h"
#include "Panel.h"
#include "ListItem.h" #include "ListItem.h"
#include "CRT.h" #include "CRT.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
/*{
#include "FunctionBar.h"
#include "Panel.h"
#include <stdbool.h>
#define INCMODE_MAX 40
typedef enum {
INC_SEARCH = 0,
INC_FILTER = 1
} IncType;
#define IncSet_filter(inc_) (inc_->filtering ? inc_->modes[INC_FILTER].buffer : NULL)
typedef struct IncMode_ {
char buffer[INCMODE_MAX+1];
int index;
FunctionBar* bar;
bool isFilter;
} IncMode;
typedef struct IncSet_ {
IncMode modes[2];
IncMode* active;
FunctionBar* defaultBar;
bool filtering;
bool found;
} IncSet;
typedef const char* (*IncMode_GetPanelValue)(Panel*, int);
}*/
static void IncMode_reset(IncMode* mode) { static void IncMode_reset(IncMode* mode) {
mode->index = 0; mode->index = 0;

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_IncSet #ifndef HEADER_IncSet
#define HEADER_IncSet #define HEADER_IncSet
/* /*
@ -9,7 +7,6 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
#include "FunctionBar.h" #include "FunctionBar.h"
#include "Panel.h" #include "Panel.h"
#include <stdbool.h> #include <stdbool.h>
@ -40,25 +37,24 @@ typedef struct IncSet_ {
typedef const char* (*IncMode_GetPanelValue)(Panel*, int); typedef const char* (*IncMode_GetPanelValue)(Panel*, int);
void IncSet_reset(IncSet* this, IncType type);
extern void IncSet_reset(IncSet* this, IncType type); IncSet* IncSet_new(FunctionBar* bar);
extern IncSet* IncSet_new(FunctionBar* bar); void IncSet_delete(IncSet* this);
extern void IncSet_delete(IncSet* this); bool IncSet_next(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue getPanelValue);
extern bool IncSet_next(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue getPanelValue); bool IncSet_prev(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue getPanelValue);
extern bool IncSet_prev(IncSet* this, IncType type, Panel* panel, IncMode_GetPanelValue getPanelValue); bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue getPanelValue, Vector* lines);
extern bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue getPanelValue, Vector* lines); const char* IncSet_getListItemValue(Panel* panel, int i);
extern const char* IncSet_getListItemValue(Panel* panel, int i); void IncSet_activate(IncSet* this, IncType type, Panel* panel);
extern void IncSet_activate(IncSet* this, IncType type, Panel* panel); void IncSet_drawBar(IncSet* this);
extern void IncSet_drawBar(IncSet* this); int IncSet_synthesizeEvent(IncSet* this, int x);
extern int IncSet_synthesizeEvent(IncSet* this, int x);
#endif #endif

View File

@ -13,42 +13,6 @@
#include <unistd.h> #include <unistd.h>
#include <stdarg.h> #include <stdarg.h>
/*{
#include "Process.h"
#include "Panel.h"
#include "FunctionBar.h"
#include "IncSet.h"
typedef struct InfoScreen_ InfoScreen;
typedef void(*InfoScreen_Scan)(InfoScreen*);
typedef void(*InfoScreen_Draw)(InfoScreen*);
typedef void(*InfoScreen_OnErr)(InfoScreen*);
typedef bool(*InfoScreen_OnKey)(InfoScreen*, int);
typedef struct InfoScreenClass_ {
ObjectClass super;
const InfoScreen_Scan scan;
const InfoScreen_Draw draw;
const InfoScreen_OnErr onErr;
const InfoScreen_OnKey onKey;
} InfoScreenClass;
#define As_InfoScreen(this_) ((InfoScreenClass*)(((InfoScreen*)(this_))->super.klass))
#define InfoScreen_scan(this_) As_InfoScreen(this_)->scan((InfoScreen*)(this_))
#define InfoScreen_draw(this_) As_InfoScreen(this_)->draw((InfoScreen*)(this_))
#define InfoScreen_onErr(this_) As_InfoScreen(this_)->onErr((InfoScreen*)(this_))
#define InfoScreen_onKey(this_, ch_) As_InfoScreen(this_)->onKey((InfoScreen*)(this_), ch_)
struct InfoScreen_ {
Object super;
Process* process;
Panel* display;
FunctionBar* bar;
IncSet* inc;
Vector* lines;
};
}*/
static const char* const InfoScreenFunctions[] = {"Search ", "Filter ", "Refresh", "Done ", NULL}; static const char* const InfoScreenFunctions[] = {"Search ", "Filter ", "Refresh", "Done ", NULL};
@ -56,7 +20,7 @@ static const char* const InfoScreenKeys[] = {"F3", "F4", "F5", "Esc"};
static int InfoScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(5), 27}; static int InfoScreenEvents[] = {KEY_F(3), KEY_F(4), KEY_F(5), 27};
InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, char* panelHeader) { InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, const char* panelHeader) {
this->process = process; this->process = process;
if (!bar) { if (!bar) {
bar = FunctionBar_new(InfoScreenFunctions, InfoScreenKeys, InfoScreenEvents); bar = FunctionBar_new(InfoScreenFunctions, InfoScreenKeys, InfoScreenEvents);
@ -75,12 +39,12 @@ InfoScreen* InfoScreen_done(InfoScreen* this) {
return this; return this;
} }
void InfoScreen_drawTitled(InfoScreen* this, char* fmt, ...) { void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
attrset(CRT_colors[METER_TEXT]); attrset(CRT_colors[METER_TEXT]);
mvhline(0, 0, ' ', COLS); mvhline(0, 0, ' ', COLS);
wmove(stdscr, 0, 0); (void) wmove(stdscr, 0, 0);
vw_printw(stdscr, fmt, ap); vw_printw(stdscr, fmt, ap);
attrset(CRT_colors[DEFAULT_COLOR]); attrset(CRT_colors[DEFAULT_COLOR]);
this->display->needsRedraw = true; this->display->needsRedraw = true;

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_InfoScreen #ifndef HEADER_InfoScreen
#define HEADER_InfoScreen #define HEADER_InfoScreen
@ -38,16 +36,16 @@ struct InfoScreen_ {
Vector* lines; Vector* lines;
}; };
extern InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, char* panelHeader); InfoScreen* InfoScreen_init(InfoScreen* this, Process* process, FunctionBar* bar, int height, const char* panelHeader);
extern InfoScreen* InfoScreen_done(InfoScreen* this); InfoScreen* InfoScreen_done(InfoScreen* this);
extern void InfoScreen_drawTitled(InfoScreen* this, char* fmt, ...); void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...);
extern void InfoScreen_addLine(InfoScreen* this, const char* line); void InfoScreen_addLine(InfoScreen* this, const char* line);
extern void InfoScreen_appendLine(InfoScreen* this, const char* line); void InfoScreen_appendLine(InfoScreen* this, const char* line);
extern void InfoScreen_run(InfoScreen* this); void InfoScreen_run(InfoScreen* this);
#endif #endif

View File

@ -15,17 +15,6 @@ in the source distribution for its full text.
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
/*{
#include "Object.h"
typedef struct ListItem_ {
Object super;
char* value;
int key;
bool moving;
} ListItem;
}*/
static void ListItem_delete(Object* cast) { static void ListItem_delete(Object* cast) {
ListItem* this = (ListItem*)cast; ListItem* this = (ListItem*)cast;
@ -85,4 +74,3 @@ long ListItem_compare(const void* cast1, const void* cast2) {
ListItem* obj2 = (ListItem*) cast2; ListItem* obj2 = (ListItem*) cast2;
return strcmp(obj1->value, obj2->value); return strcmp(obj1->value, obj2->value);
} }

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_ListItem #ifndef HEADER_ListItem
#define HEADER_ListItem #define HEADER_ListItem
/* /*
@ -18,16 +16,14 @@ typedef struct ListItem_ {
bool moving; bool moving;
} ListItem; } ListItem;
extern ObjectClass ListItem_class; extern ObjectClass ListItem_class;
extern ListItem* ListItem_new(const char* value, int key); ListItem* ListItem_new(const char* value, int key);
extern void ListItem_append(ListItem* this, const char* text); void ListItem_append(ListItem* this, const char* text);
extern const char* ListItem_getRef(ListItem* this); const char* ListItem_getRef(ListItem* this);
extern long ListItem_compare(const void* cast1, const void* cast2);
long ListItem_compare(const void* cast1, const void* cast2);
#endif #endif

View File

@ -10,9 +10,6 @@ in the source distribution for its full text.
#include "CRT.h" #include "CRT.h"
#include "Platform.h" #include "Platform.h"
/*{
#include "Meter.h"
}*/
int LoadAverageMeter_attributes[] = { int LoadAverageMeter_attributes[] = {
LOAD_AVERAGE_ONE, LOAD_AVERAGE_FIVE, LOAD_AVERAGE_FIFTEEN LOAD_AVERAGE_ONE, LOAD_AVERAGE_FIVE, LOAD_AVERAGE_FIFTEEN

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_LoadAverageMeter #ifndef HEADER_LoadAverageMeter
#define HEADER_LoadAverageMeter #define HEADER_LoadAverageMeter
/* /*

16
Macros.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef HEADER_Macros
#define HEADER_Macros
#ifndef MINIMUM
#define MINIMUM(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAXIMUM
#define MAXIMUM(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef CLAMP
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : MAXIMUM(x, low))
#endif
#endif

View File

@ -13,25 +13,6 @@ in the source distribution for its full text.
#include <stdlib.h> #include <stdlib.h>
/*{
#include "Panel.h"
#include "Action.h"
#include "Settings.h"
typedef struct MainPanel_ {
Panel super;
State* state;
IncSet* inc;
Htop_Action *keys;
pid_t pidSearch;
} MainPanel;
typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg);
#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar)
}*/
static const char* const MainFunctions[] = {"Help ", "Setup ", "Search ", "Filter ", "Tree ", "SortBy ", "Nice - ", "Nice + ", "Kill ", "Quit ", NULL}; static const char* const MainFunctions[] = {"Help ", "Setup ", "Search ", "Filter ", "Tree ", "SortBy ", "Nice - ", "Nice + ", "Kill ", "Quit ", NULL};
void MainPanel_updateTreeFunctions(MainPanel* this, bool mode) { void MainPanel_updateTreeFunctions(MainPanel* this, bool mode) {

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_MainPanel #ifndef HEADER_MainPanel
#define HEADER_MainPanel #define HEADER_MainPanel
/* /*
@ -10,9 +8,9 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
#include "Panel.h"
#include "Action.h" #include "Action.h"
#include "Settings.h" #include "IncSet.h"
#include "Panel.h"
typedef struct MainPanel_ { typedef struct MainPanel_ {
Panel super; Panel super;
@ -26,23 +24,22 @@ typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg);
#define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar) #define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar)
void MainPanel_updateTreeFunctions(MainPanel* this, bool mode);
extern void MainPanel_updateTreeFunctions(MainPanel* this, bool mode); void MainPanel_pidSearch(MainPanel* this, int ch);
extern void MainPanel_pidSearch(MainPanel* this, int ch); int MainPanel_selectedPid(MainPanel* this);
extern int MainPanel_selectedPid(MainPanel* this); const char* MainPanel_getValue(MainPanel* this, int i);
extern const char* MainPanel_getValue(MainPanel* this, int i); bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, Arg arg, bool* wasAnyTagged);
extern bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, Arg arg, bool* wasAnyTagged);
extern PanelClass MainPanel_class; extern PanelClass MainPanel_class;
extern MainPanel* MainPanel_new(); MainPanel* MainPanel_new();
extern void MainPanel_setState(MainPanel* this, State* state); void MainPanel_setState(MainPanel* this, State* state);
extern void MainPanel_delete(Object* object); void MainPanel_delete(Object* object);
#endif #endif

View File

@ -5,14 +5,14 @@ AUTOMAKE_OPTIONS = subdir-objects
bin_PROGRAMS = htop bin_PROGRAMS = htop
dist_man_MANS = htop.1 dist_man_MANS = htop.1
EXTRA_DIST = $(dist_man_MANS) htop.desktop htop.png scripts/MakeHeader.py \ EXTRA_DIST = $(dist_man_MANS) htop.desktop htop.png \
install-sh autogen.sh missing install-sh autogen.sh missing
applicationsdir = $(datadir)/applications applicationsdir = $(datadir)/applications
applications_DATA = htop.desktop applications_DATA = htop.desktop
pixmapdir = $(datadir)/pixmaps pixmapdir = $(datadir)/pixmaps
pixmap_DATA = htop.png pixmap_DATA = htop.png
AM_CFLAGS = -pedantic -Wall $(wextra_flag) -std=c99 -D_XOPEN_SOURCE_EXTENDED -DSYSCONFDIR=\"$(sysconfdir)\" -I"$(top_srcdir)/$(my_htop_platform)" AM_CFLAGS += -pedantic -Wall $(wextra_flag) -std=c99 -D_XOPEN_SOURCE_EXTENDED -DSYSCONFDIR=\"$(sysconfdir)\" -I"$(top_srcdir)/$(my_htop_platform)"
AM_LDFLAGS = AM_LDFLAGS =
AM_CPPFLAGS = -DNDEBUG AM_CPPFLAGS = -DNDEBUG
@ -29,14 +29,12 @@ InfoScreen.c XAlloc.c
myhtopheaders = AvailableColumnsPanel.h AvailableMetersPanel.h \ myhtopheaders = AvailableColumnsPanel.h AvailableMetersPanel.h \
CategoriesPanel.h CheckItem.h ClockMeter.h ColorsPanel.h ColumnsPanel.h \ CategoriesPanel.h CheckItem.h ClockMeter.h ColorsPanel.h ColumnsPanel.h \
CPUMeter.h CRT.h MainPanel.h DisplayOptionsPanel.h FunctionBar.h \ CPUMeter.h CRT.h MainPanel.h DisplayOptionsPanel.h FunctionBar.h \
Hashtable.h Header.h htop.h ListItem.h LoadAverageMeter.h MemoryMeter.h \ Hashtable.h Header.h ListItem.h LoadAverageMeter.h MemoryMeter.h \
BatteryMeter.h Meter.h MetersPanel.h Object.h Panel.h ProcessList.h RichString.h \ BatteryMeter.h Meter.h MetersPanel.h Object.h Panel.h ProcessList.h RichString.h \
ScreenManager.h Settings.h SignalsPanel.h StringUtils.h SwapMeter.h \ ScreenManager.h Settings.h SignalsPanel.h StringUtils.h SwapMeter.h \
TasksMeter.h UptimeMeter.h TraceScreen.h UsersTable.h Vector.h Process.h \ TasksMeter.h UptimeMeter.h TraceScreen.h UsersTable.h Vector.h Process.h \
AffinityPanel.h HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h \ AffinityPanel.h HostnameMeter.h OpenFilesScreen.h Affinity.h IncSet.h Action.h \
EnvScreen.h InfoScreen.h XAlloc.h EnvScreen.h InfoScreen.h XAlloc.h Macros.h
all_platform_headers =
# Linux # Linux
# ----- # -----
@ -54,11 +52,9 @@ linux_platform_headers = \
zfs/ZfsCompressedArcMeter.h \ zfs/ZfsCompressedArcMeter.h \
zfs/ZfsArcStats.h zfs/ZfsArcStats.h
all_platform_headers += $(linux_platform_headers)
if HTOP_LINUX if HTOP_LINUX
AM_LDFLAGS += -rdynamic AM_LDFLAGS += -rdynamic
myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c linux/IOPriority.c \ myhtopplatsources = linux/Platform.c linux/IOPriorityPanel.c \
linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c linux/Battery.c \ linux/LinuxProcess.c linux/LinuxProcessList.c linux/LinuxCRT.c linux/Battery.c \
linux/PressureStallMeter.c \ linux/PressureStallMeter.c \
zfs/ZfsArcMeter.c zfs/ZfsCompressedArcMeter.c zfs/ZfsArcStats.c zfs/ZfsArcMeter.c zfs/ZfsCompressedArcMeter.c zfs/ZfsArcStats.c
@ -80,8 +76,6 @@ freebsd_platform_headers = \
zfs/ZfsArcStats.h \ zfs/ZfsArcStats.h \
zfs/openzfs_sysctl.h zfs/openzfs_sysctl.h
all_platform_headers += $(freebsd_platform_headers)
if HTOP_FREEBSD if HTOP_FREEBSD
myhtopplatsources = freebsd/Platform.c freebsd/FreeBSDProcessList.c \ myhtopplatsources = freebsd/Platform.c freebsd/FreeBSDProcessList.c \
freebsd/FreeBSDProcess.c freebsd/FreeBSDCRT.c freebsd/Battery.c \ freebsd/FreeBSDProcess.c freebsd/FreeBSDCRT.c freebsd/Battery.c \
@ -100,8 +94,6 @@ dragonflybsd_platform_headers = \
dragonflybsd/DragonFlyBSDCRT.h \ dragonflybsd/DragonFlyBSDCRT.h \
dragonflybsd/Battery.h dragonflybsd/Battery.h
all_platform_headers += $(dragonflybsd_platform_headers)
if HTOP_DRAGONFLYBSD if HTOP_DRAGONFLYBSD
AM_LDFLAGS += -lkvm -lkinfo -lexecinfo AM_LDFLAGS += -lkvm -lkinfo -lexecinfo
myhtopplatsources = dragonflybsd/Platform.c dragonflybsd/DragonFlyBSDProcessList.c \ myhtopplatsources = dragonflybsd/Platform.c dragonflybsd/DragonFlyBSDProcessList.c \
@ -120,8 +112,6 @@ openbsd_platform_headers = \
openbsd/OpenBSDCRT.h \ openbsd/OpenBSDCRT.h \
openbsd/Battery.h openbsd/Battery.h
all_platform_headers += $(openbsd_platform_headers)
if HTOP_OPENBSD if HTOP_OPENBSD
myhtopplatsources = openbsd/Platform.c openbsd/OpenBSDProcessList.c \ myhtopplatsources = openbsd/Platform.c openbsd/OpenBSDProcessList.c \
openbsd/OpenBSDProcess.c openbsd/OpenBSDCRT.c openbsd/Battery.c openbsd/OpenBSDProcess.c openbsd/OpenBSDCRT.c openbsd/Battery.c
@ -143,8 +133,6 @@ darwin_platform_headers = \
zfs/ZfsArcStats.h \ zfs/ZfsArcStats.h \
zfs/openzfs_sysctl.h zfs/openzfs_sysctl.h
all_platform_headers += $(darwin_platform_headers)
if HTOP_DARWIN if HTOP_DARWIN
AM_LDFLAGS += -framework IOKit -framework CoreFoundation AM_LDFLAGS += -framework IOKit -framework CoreFoundation
myhtopplatsources = darwin/Platform.c darwin/DarwinProcess.c \ myhtopplatsources = darwin/Platform.c darwin/DarwinProcess.c \
@ -167,8 +155,6 @@ solaris_platform_headers = \
zfs/ZfsCompressedArcMeter.h \ zfs/ZfsCompressedArcMeter.h \
zfs/ZfsArcStats.h zfs/ZfsArcStats.h
all_platform_headers += $(solaris_platform_headers)
if HTOP_SOLARIS if HTOP_SOLARIS
myhtopplatsources = solaris/Platform.c \ myhtopplatsources = solaris/Platform.c \
solaris/SolarisProcess.c solaris/SolarisProcessList.c \ solaris/SolarisProcess.c solaris/SolarisProcessList.c \
@ -188,8 +174,6 @@ unsupported_platform_headers = \
unsupported/UnsupportedCRT.h \ unsupported/UnsupportedCRT.h \
unsupported/Battery.h unsupported/Battery.h
all_platform_headers += $(unsupported_platform_headers)
if HTOP_UNSUPPORTED if HTOP_UNSUPPORTED
myhtopplatsources = unsupported/Platform.c \ myhtopplatsources = unsupported/Platform.c \
unsupported/UnsupportedProcess.c unsupported/UnsupportedProcessList.c \ unsupported/UnsupportedProcess.c unsupported/UnsupportedProcessList.c \
@ -200,17 +184,8 @@ endif
# ---- # ----
SUFFIXES = .h htop_SOURCES = $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources)
nodist_htop_SOURCES = config.h
BUILT_SOURCES = $(myhtopheaders) $(myhtopplatheaders)
htop_SOURCES = $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources) config.h
.PHONY: htop-headers clean-htop-headers
htop-headers: $(myhtopheaders) $(all_platform_headers)
clean-htop-headers:
-rm -f $(myhtopheaders) $(all_platform_headers)
target: target:
echo $(htop_SOURCES) echo $(htop_SOURCES)
@ -224,9 +199,6 @@ debug:
coverage: coverage:
$(MAKE) all CFLAGS="" AM_CPPFLAGS="-fprofile-arcs -ftest-coverage -DDEBUG" LDFLAGS="-lgcov" $(MAKE) all CFLAGS="" AM_CPPFLAGS="-fprofile-arcs -ftest-coverage -DDEBUG" LDFLAGS="-lgcov"
.c.h:
@srcdir@/scripts/MakeHeader.py $<
cppcheck: cppcheck:
cppcheck -q -v . --enable=all -DHAVE_CGROUP -DHAVE_OPENVZ -DHAVE_TASKSTATS cppcheck -q -v . --enable=all -DHAVE_CGROUP -DHAVE_OPENVZ -DHAVE_TASKSTATS

View File

@ -16,9 +16,6 @@ in the source distribution for its full text.
#include <sys/param.h> #include <sys/param.h>
#include <assert.h> #include <assert.h>
/*{
#include "Meter.h"
}*/
int MemoryMeter_attributes[] = { int MemoryMeter_attributes[] = {
MEMORY_USED, MEMORY_BUFFERS, MEMORY_CACHE MEMORY_USED, MEMORY_BUFFERS, MEMORY_CACHE

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_MemoryMeter #ifndef HEADER_MemoryMeter
#define HEADER_MemoryMeter #define HEADER_MemoryMeter
/* /*

98
Meter.c
View File

@ -11,7 +11,6 @@ in the source distribution for its full text.
#include "Object.h" #include "Object.h"
#include "CRT.h" #include "CRT.h"
#include "StringUtils.h" #include "StringUtils.h"
#include "ListItem.h"
#include "Settings.h" #include "Settings.h"
#include <math.h> #include <math.h>
@ -19,108 +18,11 @@ in the source distribution for its full text.
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <assert.h> #include <assert.h>
#include <sys/time.h>
#define METER_BUFFER_LEN 256
#define GRAPH_DELAY (DEFAULT_DELAY/2) #define GRAPH_DELAY (DEFAULT_DELAY/2)
#define GRAPH_HEIGHT 4 /* Unit: rows (lines) */ #define GRAPH_HEIGHT 4 /* Unit: rows (lines) */
/*{
#include "ListItem.h"
#include <sys/time.h>
typedef struct Meter_ Meter;
typedef void(*Meter_Init)(Meter*);
typedef void(*Meter_Done)(Meter*);
typedef void(*Meter_UpdateMode)(Meter*, int);
typedef void(*Meter_UpdateValues)(Meter*, char*, int);
typedef void(*Meter_Draw)(Meter*, int, int, int);
typedef struct MeterClass_ {
ObjectClass super;
const Meter_Init init;
const Meter_Done done;
const Meter_UpdateMode updateMode;
const Meter_Draw draw;
const Meter_UpdateValues updateValues;
const int defaultMode;
const double total;
const int* attributes;
const char* name;
const char* uiName;
const char* caption;
const char* description;
const char maxItems;
char curItems;
} MeterClass;
#define As_Meter(this_) ((MeterClass*)((this_)->super.klass))
#define Meter_initFn(this_) As_Meter(this_)->init
#define Meter_init(this_) As_Meter(this_)->init((Meter*)(this_))
#define Meter_done(this_) As_Meter(this_)->done((Meter*)(this_))
#define Meter_updateModeFn(this_) As_Meter(this_)->updateMode
#define Meter_updateMode(this_, m_) As_Meter(this_)->updateMode((Meter*)(this_), m_)
#define Meter_drawFn(this_) As_Meter(this_)->draw
#define Meter_doneFn(this_) As_Meter(this_)->done
#define Meter_updateValues(this_, buf_, sz_) \
As_Meter(this_)->updateValues((Meter*)(this_), buf_, sz_)
#define Meter_defaultMode(this_) As_Meter(this_)->defaultMode
#define Meter_getItems(this_) As_Meter(this_)->curItems
#define Meter_setItems(this_, n_) As_Meter(this_)->curItems = (n_)
#define Meter_attributes(this_) As_Meter(this_)->attributes
#define Meter_name(this_) As_Meter(this_)->name
#define Meter_uiName(this_) As_Meter(this_)->uiName
struct Meter_ {
Object super;
Meter_Draw draw;
char* caption;
int mode;
int param;
void* drawData;
int h;
struct ProcessList_* pl;
double* values;
double total;
};
typedef struct MeterMode_ {
Meter_Draw draw;
const char* uiName;
int h;
} MeterMode;
typedef enum {
CUSTOM_METERMODE = 0,
BAR_METERMODE,
TEXT_METERMODE,
GRAPH_METERMODE,
LED_METERMODE,
LAST_METERMODE
} MeterModeId;
typedef struct GraphData_ {
struct timeval time;
double values[METER_BUFFER_LEN];
} GraphData;
}*/
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#ifndef CLAMP
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
MeterClass Meter_class = { MeterClass Meter_class = {
.super = { .super = {
.extends = Class(Object) .extends = Class(Object)

55
Meter.h
View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Meter #ifndef HEADER_Meter
#define HEADER_Meter #define HEADER_Meter
/* /*
@ -9,16 +7,11 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
#define METER_BUFFER_LEN 256
#define GRAPH_DELAY (DEFAULT_DELAY/2)
#define GRAPH_HEIGHT 4 /* Unit: rows (lines) */
#include "ListItem.h" #include "ListItem.h"
#include <sys/time.h> #include <sys/time.h>
#define METER_BUFFER_LEN 256
typedef struct Meter_ Meter; typedef struct Meter_ Meter;
typedef void(*Meter_Init)(Meter*); typedef void(*Meter_Init)(Meter*);
@ -96,54 +89,22 @@ typedef struct GraphData_ {
double values[METER_BUFFER_LEN]; double values[METER_BUFFER_LEN];
} GraphData; } GraphData;
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#ifndef CLAMP
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
extern MeterClass Meter_class; extern MeterClass Meter_class;
extern Meter* Meter_new(struct ProcessList_* pl, int param, MeterClass* type); Meter* Meter_new(struct ProcessList_* pl, int param, MeterClass* type);
extern int Meter_humanUnit(char* buffer, unsigned long int value, int size); int Meter_humanUnit(char* buffer, unsigned long int value, int size);
extern void Meter_delete(Object* cast); void Meter_delete(Object* cast);
extern void Meter_setCaption(Meter* this, const char* caption); void Meter_setCaption(Meter* this, const char* caption);
extern void Meter_setMode(Meter* this, int modeIndex); void Meter_setMode(Meter* this, int modeIndex);
extern ListItem* Meter_toListItem(Meter* this, bool moving); ListItem* Meter_toListItem(Meter* this, bool moving);
/* ---------- TextMeterMode ---------- */
/* ---------- BarMeterMode ---------- */
/* ---------- GraphMeterMode ---------- */
#ifdef HAVE_LIBNCURSESW
#define PIXPERROW_UTF8 4
#endif
#define PIXPERROW_ASCII 2
/* ---------- LEDMeterMode ---------- */
#ifdef HAVE_LIBNCURSESW
#endif
extern MeterMode* Meter_modes[]; extern MeterMode* Meter_modes[];
/* Blank meter */
extern int BlankMeter_attributes[]; extern int BlankMeter_attributes[];
extern MeterClass BlankMeter_class; extern MeterClass BlankMeter_class;

View File

@ -11,25 +11,6 @@ in the source distribution for its full text.
#include <assert.h> #include <assert.h>
#include "CRT.h" #include "CRT.h"
/*{
#include "Panel.h"
#include "Settings.h"
#include "ScreenManager.h"
typedef struct MetersPanel_ MetersPanel;
struct MetersPanel_ {
Panel super;
Settings* settings;
Vector* meters;
ScreenManager* scr;
MetersPanel* leftNeighbor;
MetersPanel* rightNeighbor;
bool moving;
};
}*/
// Note: In code the meters are known to have bar/text/graph "Modes", but in UI // Note: In code the meters are known to have bar/text/graph "Modes", but in UI
// we call them "Styles". // we call them "Styles".

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_MetersPanel #ifndef HEADER_MetersPanel
#define HEADER_MetersPanel #define HEADER_MetersPanel
/* /*
@ -26,18 +24,10 @@ struct MetersPanel_ {
bool moving; bool moving;
}; };
void MetersPanel_setMoving(MetersPanel* this, bool moving);
// Note: In code the meters are known to have bar/text/graph "Modes", but in UI
// we call them "Styles".
// We avoid UTF-8 arrows ← → here as they might display full-width on Chinese
// terminals, breaking our aligning.
// In <http://unicode.org/reports/tr11/>, arrows (U+2019..U+2199) are
// considered "Ambiguous characters".
extern void MetersPanel_setMoving(MetersPanel* this, bool moving);
extern PanelClass MetersPanel_class; extern PanelClass MetersPanel_class;
extern MetersPanel* MetersPanel_new(Settings* settings, const char* header, Vector* meters, ScreenManager* scr); MetersPanel* MetersPanel_new(Settings* settings, const char* header, Vector* meters, ScreenManager* scr);
#endif #endif

1
NEWS
View File

@ -2,4 +2,3 @@
See the commit history for news of the past. See the commit history for news of the past.
See the bug tracker for news of the future. See the bug tracker for news of the future.
Run the program for news of the present. Run the program for news of the present.

View File

@ -8,46 +8,6 @@ in the source distribution for its full text.
#include "Object.h" #include "Object.h"
/*{
#include "RichString.h"
#include "XAlloc.h"
typedef struct Object_ Object;
typedef void(*Object_Display)(Object*, RichString*);
typedef long(*Object_Compare)(const void*, const void*);
typedef void(*Object_Delete)(Object*);
#define Object_getClass(obj_) ((Object*)(obj_))->klass
#define Object_setClass(obj_, class_) Object_getClass(obj_) = (ObjectClass*) class_
#define Object_delete(obj_) Object_getClass(obj_)->delete((Object*)(obj_))
#define Object_displayFn(obj_) Object_getClass(obj_)->display
#define Object_display(obj_, str_) Object_getClass(obj_)->display((Object*)(obj_), str_)
#define Object_compare(obj_, other_) Object_getClass(obj_)->compare((const void*)(obj_), other_)
#define Class(class_) ((ObjectClass*)(&(class_ ## _class)))
#define AllocThis(class_) (class_*) xMalloc(sizeof(class_)); Object_setClass(this, Class(class_));
typedef struct ObjectClass_ {
const void* extends;
const Object_Display display;
const Object_Delete delete;
const Object_Compare compare;
} ObjectClass;
struct Object_ {
ObjectClass* klass;
};
typedef union {
int i;
void* v;
} Arg;
}*/
ObjectClass Object_class = { ObjectClass Object_class = {
.extends = NULL .extends = NULL
}; };

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Object #ifndef HEADER_Object
#define HEADER_Object #define HEADER_Object
/* /*
@ -12,6 +10,7 @@ in the source distribution for its full text.
#include "RichString.h" #include "RichString.h"
#include "XAlloc.h" #include "XAlloc.h"
#include "Macros.h"
typedef struct Object_ Object; typedef struct Object_ Object;
@ -47,12 +46,11 @@ typedef union {
void* v; void* v;
} Arg; } Arg;
extern ObjectClass Object_class; extern ObjectClass Object_class;
#ifdef DEBUG #ifdef DEBUG
extern bool Object_isA(Object* o, const ObjectClass* klass); bool Object_isA(Object* o, const ObjectClass* klass);
#endif #endif

View File

@ -23,30 +23,6 @@ in the source distribution for its full text.
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
/*{
#include "InfoScreen.h"
typedef struct OpenFiles_Data_ {
char* data[256];
} OpenFiles_Data;
typedef struct OpenFiles_ProcessData_ {
OpenFiles_Data data;
int error;
struct OpenFiles_FileData_* files;
} OpenFiles_ProcessData;
typedef struct OpenFiles_FileData_ {
OpenFiles_Data data;
struct OpenFiles_FileData_* next;
} OpenFiles_FileData;
typedef struct OpenFilesScreen_ {
InfoScreen super;
pid_t pid;
} OpenFilesScreen;
}*/
InfoScreenClass OpenFilesScreen_class = { InfoScreenClass OpenFilesScreen_class = {
.super = { .super = {

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_OpenFilesScreen #ifndef HEADER_OpenFilesScreen
#define HEADER_OpenFilesScreen #define HEADER_OpenFilesScreen
/* /*
@ -31,15 +29,14 @@ typedef struct OpenFilesScreen_ {
pid_t pid; pid_t pid;
} OpenFilesScreen; } OpenFilesScreen;
extern InfoScreenClass OpenFilesScreen_class; extern InfoScreenClass OpenFilesScreen_class;
extern OpenFilesScreen* OpenFilesScreen_new(Process* process); OpenFilesScreen* OpenFilesScreen_new(Process* process);
extern void OpenFilesScreen_delete(Object* this); void OpenFilesScreen_delete(Object* this);
extern void OpenFilesScreen_draw(InfoScreen* this); void OpenFilesScreen_draw(InfoScreen* this);
extern void OpenFilesScreen_scan(InfoScreen* this); void OpenFilesScreen_scan(InfoScreen* this);
#endif #endif

94
Panel.c
View File

@ -19,72 +19,6 @@ in the source distribution for its full text.
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
//#link curses
/*{
#include "Object.h"
#include "Vector.h"
#include "FunctionBar.h"
typedef struct Panel_ Panel;
typedef enum HandlerResult_ {
HANDLED = 0x01,
IGNORED = 0x02,
BREAK_LOOP = 0x04,
REDRAW = 0x08,
RESCAN = 0x10,
SYNTH_KEY = 0x20,
} HandlerResult;
#define EVENT_SET_SELECTED -1
#define EVENT_HEADER_CLICK(x_) (-10000 + x_)
#define EVENT_IS_HEADER_CLICK(ev_) (ev_ >= -10000 && ev_ <= -9000)
#define EVENT_HEADER_CLICK_GET_X(ev_) (ev_ + 10000)
typedef HandlerResult(*Panel_EventHandler)(Panel*, int);
typedef struct PanelClass_ {
const ObjectClass super;
const Panel_EventHandler eventHandler;
} PanelClass;
#define As_Panel(this_) ((PanelClass*)((this_)->super.klass))
#define Panel_eventHandlerFn(this_) As_Panel(this_)->eventHandler
#define Panel_eventHandler(this_, ev_) As_Panel(this_)->eventHandler((Panel*)(this_), ev_)
struct Panel_ {
Object super;
int x, y, w, h;
WINDOW* window;
Vector* items;
int selected;
int oldSelected;
int selectedLen;
void* eventHandlerState;
int scrollV;
short scrollH;
bool needsRedraw;
FunctionBar* currentBar;
FunctionBar* defaultBar;
RichString header;
int selectionColor;
};
#define Panel_setDefaultBar(this_) do{ (this_)->currentBar = (this_)->defaultBar; }while(0)
}*/
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#define KEY_CTRL(l) ((l)-'A'+1)
PanelClass Panel_class = { PanelClass Panel_class = {
.super = { .super = {
.extends = Class(Object), .extends = Class(Object),
@ -264,6 +198,14 @@ void Panel_setSelected(Panel* this, int selected) {
} }
} }
void Panel_splice(Panel *this, Vector* from) {
assert (this != NULL);
assert (from != NULL);
Vector_splice(this->items, from);
this->needsRedraw = true;
}
void Panel_draw(Panel* this, bool focus) { void Panel_draw(Panel* this, bool focus) {
assert (this != NULL); assert (this != NULL);
@ -282,7 +224,7 @@ void Panel_draw(Panel* this, bool focus) {
mvhline(y, x, ' ', this->w); mvhline(y, x, ' ', this->w);
if (scrollH < headerLen) { if (scrollH < headerLen) {
RichString_printoffnVal(this->header, y, x, scrollH, RichString_printoffnVal(this->header, y, x, scrollH,
MIN(headerLen - scrollH, this->w)); MINIMUM(headerLen - scrollH, this->w));
} }
attrset(CRT_colors[RESET_COLOR]); attrset(CRT_colors[RESET_COLOR]);
y++; y++;
@ -293,7 +235,7 @@ void Panel_draw(Panel* this, bool focus) {
this->scrollV = 0; this->scrollV = 0;
this->needsRedraw = true; this->needsRedraw = true;
} else if (this->scrollV >= size) { } else if (this->scrollV >= size) {
this->scrollV = MAX(size - 1, 0); this->scrollV = MAXIMUM(size - 1, 0);
this->needsRedraw = true; this->needsRedraw = true;
} }
// ensure selection is on screen // ensure selection is on screen
@ -306,7 +248,7 @@ void Panel_draw(Panel* this, bool focus) {
} }
int first = this->scrollV; int first = this->scrollV;
int upTo = MIN(first + h, size); int upTo = MINIMUM(first + h, size);
int selectionColor = focus int selectionColor = focus
? this->selectionColor ? this->selectionColor
@ -320,7 +262,7 @@ void Panel_draw(Panel* this, bool focus) {
RichString_begin(item); RichString_begin(item);
Object_display(itemObj, &item); Object_display(itemObj, &item);
int itemLen = RichString_sizeVal(item); int itemLen = RichString_sizeVal(item);
int amt = MIN(itemLen - scrollH, this->w); int amt = MINIMUM(itemLen - scrollH, this->w);
bool selected = (i == this->selected); bool selected = (i == this->selected);
if (selected) { if (selected) {
attrset(selectionColor); attrset(selectionColor);
@ -355,13 +297,13 @@ void Panel_draw(Panel* this, bool focus) {
mvhline(y+ this->oldSelected - first, x+0, ' ', this->w); mvhline(y+ this->oldSelected - first, x+0, ' ', this->w);
if (scrollH < oldLen) if (scrollH < oldLen)
RichString_printoffnVal(old, y+this->oldSelected - first, x, RichString_printoffnVal(old, y+this->oldSelected - first, x,
scrollH, MIN(oldLen - scrollH, this->w)); scrollH, MINIMUM(oldLen - scrollH, this->w));
attrset(selectionColor); attrset(selectionColor);
mvhline(y+this->selected - first, x+0, ' ', this->w); mvhline(y+this->selected - first, x+0, ' ', this->w);
RichString_setAttr(&new, selectionColor); RichString_setAttr(&new, selectionColor);
if (scrollH < newLen) if (scrollH < newLen)
RichString_printoffnVal(new, y+this->selected - first, x, RichString_printoffnVal(new, y+this->selected - first, x,
scrollH, MIN(newLen - scrollH, this->w)); scrollH, MINIMUM(newLen - scrollH, this->w));
attrset(CRT_colors[RESET_COLOR]); attrset(CRT_colors[RESET_COLOR]);
RichString_end(new); RichString_end(new);
RichString_end(old); RichString_end(old);
@ -396,7 +338,7 @@ bool Panel_onKey(Panel* this, int key) {
case KEY_LEFT: case KEY_LEFT:
case KEY_CTRL('B'): case KEY_CTRL('B'):
if (this->scrollH > 0) { if (this->scrollH > 0) {
this->scrollH -= MAX(CRT_scrollHAmount, 0); this->scrollH -= MAXIMUM(CRT_scrollHAmount, 0);
this->needsRedraw = true; this->needsRedraw = true;
} }
break; break;
@ -407,12 +349,12 @@ bool Panel_onKey(Panel* this, int key) {
break; break;
case KEY_PPAGE: case KEY_PPAGE:
this->selected -= (this->h - 1); this->selected -= (this->h - 1);
this->scrollV = MAX(0, this->scrollV - this->h + 1); this->scrollV = MAXIMUM(0, this->scrollV - this->h + 1);
this->needsRedraw = true; this->needsRedraw = true;
break; break;
case KEY_NPAGE: case KEY_NPAGE:
this->selected += (this->h - 1); this->selected += (this->h - 1);
this->scrollV = MAX(0, MIN(Vector_size(this->items) - this->h, this->scrollV = MAXIMUM(0, MINIMUM(Vector_size(this->items) - this->h,
this->scrollV + this->h - 1)); this->scrollV + this->h - 1));
this->needsRedraw = true; this->needsRedraw = true;
break; break;
@ -444,7 +386,7 @@ bool Panel_onKey(Panel* this, int key) {
break; break;
case KEY_CTRL('E'): case KEY_CTRL('E'):
case '$': case '$':
this->scrollH = MAX(this->selectedLen - this->w, 0); this->scrollH = MAXIMUM(this->selectedLen - this->w, 0);
this->needsRedraw = true; this->needsRedraw = true;
break; break;
default: default:

62
Panel.h
View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Panel #ifndef HEADER_Panel
#define HEADER_Panel #define HEADER_Panel
/* /*
@ -9,8 +7,6 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
//#link curses
#include "Object.h" #include "Object.h"
#include "Vector.h" #include "Vector.h"
#include "FunctionBar.h" #include "FunctionBar.h"
@ -63,64 +59,58 @@ struct Panel_ {
#define Panel_setDefaultBar(this_) do{ (this_)->currentBar = (this_)->defaultBar; }while(0) #define Panel_setDefaultBar(this_) do{ (this_)->currentBar = (this_)->defaultBar; }while(0)
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef MAX
#define MAX(a,b) ((a)>(b)?(a):(b))
#endif
#define KEY_CTRL(l) ((l)-'A'+1) #define KEY_CTRL(l) ((l)-'A'+1)
extern PanelClass Panel_class; extern PanelClass Panel_class;
extern Panel* Panel_new(int x, int y, int w, int h, bool owner, ObjectClass* type, FunctionBar* fuBar); Panel* Panel_new(int x, int y, int w, int h, bool owner, ObjectClass* type, FunctionBar* fuBar);
extern void Panel_delete(Object* cast); void Panel_delete(Object* cast);
extern void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool owner, FunctionBar* fuBar); void Panel_init(Panel* this, int x, int y, int w, int h, ObjectClass* type, bool owner, FunctionBar* fuBar);
extern void Panel_done(Panel* this); void Panel_done(Panel* this);
extern void Panel_setSelectionColor(Panel* this, int color); void Panel_setSelectionColor(Panel* this, int color);
extern RichString* Panel_getHeader(Panel* this); RichString* Panel_getHeader(Panel* this);
extern void Panel_setHeader(Panel* this, const char* header); void Panel_setHeader(Panel* this, const char* header);
extern void Panel_move(Panel* this, int x, int y); void Panel_move(Panel* this, int x, int y);
extern void Panel_resize(Panel* this, int w, int h); void Panel_resize(Panel* this, int w, int h);
extern void Panel_prune(Panel* this); void Panel_prune(Panel* this);
extern void Panel_add(Panel* this, Object* o); void Panel_add(Panel* this, Object* o);
extern void Panel_insert(Panel* this, int i, Object* o); void Panel_insert(Panel* this, int i, Object* o);
extern void Panel_set(Panel* this, int i, Object* o); void Panel_set(Panel* this, int i, Object* o);
extern Object* Panel_get(Panel* this, int i); Object* Panel_get(Panel* this, int i);
extern Object* Panel_remove(Panel* this, int i); Object* Panel_remove(Panel* this, int i);
extern Object* Panel_getSelected(Panel* this); Object* Panel_getSelected(Panel* this);
extern void Panel_moveSelectedUp(Panel* this); void Panel_moveSelectedUp(Panel* this);
extern void Panel_moveSelectedDown(Panel* this); void Panel_moveSelectedDown(Panel* this);
extern int Panel_getSelectedIndex(Panel* this); int Panel_getSelectedIndex(Panel* this);
extern int Panel_size(Panel* this); int Panel_size(Panel* this);
extern void Panel_setSelected(Panel* this, int selected); void Panel_setSelected(Panel* this, int selected);
extern void Panel_draw(Panel* this, bool focus); void Panel_draw(Panel* this, bool focus);
extern bool Panel_onKey(Panel* this, int key); void Panel_splice(Panel *this, Vector* from);
extern HandlerResult Panel_selectByTyping(Panel* this, int ch); bool Panel_onKey(Panel* this, int key);
HandlerResult Panel_selectByTyping(Panel* this, int ch);
#endif #endif

162
Process.c
View File

@ -21,7 +21,6 @@ in the source distribution for its full text.
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
@ -37,169 +36,8 @@ in the source distribution for its full text.
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#endif #endif
#ifdef __ANDROID__
#define SYS_ioprio_get __NR_ioprio_get
#define SYS_ioprio_set __NR_ioprio_set
#endif
// On Linux, this works only with glibc 2.1+. On earlier versions
// the behavior is similar to have a hardcoded page size.
#ifndef PAGE_SIZE
#define PAGE_SIZE ( sysconf(_SC_PAGESIZE) )
#endif
#define PAGE_SIZE_KB ( PAGE_SIZE / ONE_K )
/*{
#include "Object.h"
#include <sys/types.h>
#define PROCESS_FLAG_IO 0x0001
typedef enum ProcessFields {
NULL_PROCESSFIELD = 0,
PID = 1,
COMM = 2,
STATE = 3,
PPID = 4,
PGRP = 5,
SESSION = 6,
TTY_NR = 7,
TPGID = 8,
MINFLT = 10,
MAJFLT = 12,
PRIORITY = 18,
NICE = 19,
STARTTIME = 21,
PROCESSOR = 38,
M_SIZE = 39,
M_RESIDENT = 40,
ST_UID = 46,
PERCENT_CPU = 47,
PERCENT_MEM = 48,
USER = 49,
TIME = 50,
NLWP = 51,
TGID = 52,
} ProcessField;
typedef struct ProcessPidColumn_ {
int id;
char* label;
} ProcessPidColumn;
typedef struct Process_ {
Object super;
struct Settings_* settings;
unsigned long long int time;
pid_t pid;
pid_t ppid;
pid_t tgid;
char* comm;
int commLen;
int indent;
int basenameOffset;
bool updated;
char state;
bool tag;
bool showChildren;
bool show;
unsigned int pgrp;
unsigned int session;
unsigned int tty_nr;
int tpgid;
uid_t st_uid;
unsigned long int flags;
int processor;
float percent_cpu;
float percent_mem;
char* user;
long int priority;
long int nice;
long int nlwp;
char starttime_show[8];
time_t starttime_ctime;
long m_size;
long m_resident;
int exit_signal;
unsigned long int minflt;
unsigned long int majflt;
#ifdef DEBUG
long int itrealvalue;
unsigned long int vsize;
long int rss;
unsigned long int rlim;
unsigned long int startcode;
unsigned long int endcode;
unsigned long int startstack;
unsigned long int kstkesp;
unsigned long int kstkeip;
unsigned long int signal;
unsigned long int blocked;
unsigned long int sigignore;
unsigned long int sigcatch;
unsigned long int wchan;
unsigned long int nswap;
unsigned long int cnswap;
#endif
} Process;
typedef struct ProcessFieldData_ {
const char* name;
const char* title;
const char* description;
int flags;
} ProcessFieldData;
// Implemented in platform-specific code:
void Process_writeField(Process* this, RichString* str, ProcessField field);
long Process_compare(const void* v1, const void* v2);
void Process_delete(Object* cast);
bool Process_isThread(Process* this);
extern ProcessFieldData Process_fields[];
extern ProcessPidColumn Process_pidColumns[];
extern char Process_pidFormat[20];
typedef Process*(*Process_New)(struct Settings_*);
typedef void (*Process_WriteField)(Process*, RichString*, ProcessField);
typedef struct ProcessClass_ {
const ObjectClass super;
const Process_WriteField writeField;
} ProcessClass;
#define As_Process(this_) ((ProcessClass*)((this_)->super.klass))
#define Process_getParentPid(process_) (process_->tgid == process_->pid ? process_->ppid : process_->tgid)
#define Process_isChildOf(process_, pid_) (process_->tgid == pid_ || (process_->tgid == process_->pid && process_->ppid == pid_))
#define Process_sortState(state) ((state) == 'I' ? 0x100 : (state))
}*/
static int Process_getuid = -1; static int Process_getuid = -1;
#define ONE_K 1024L
#define ONE_M (ONE_K * ONE_K)
#define ONE_G (ONE_M * ONE_K)
#define ONE_T ((long long)ONE_G * ONE_K)
#define ONE_DECIMAL_K 1000L
#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K)
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
#define ONE_DECIMAL_T ((long long)ONE_DECIMAL_G * ONE_DECIMAL_K)
char Process_pidFormat[20] = "%7d "; char Process_pidFormat[20] = "%7d ";
static char Process_titleBuffer[20][20]; static char Process_titleBuffer[20][20];

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Process #ifndef HEADER_Process
#define HEADER_Process #define HEADER_Process
/* /*
@ -10,10 +8,6 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
#ifdef MAJOR_IN_MKDEV
#elif defined(MAJOR_IN_SYSMACROS)
#endif
#ifdef __ANDROID__ #ifdef __ANDROID__
#define SYS_ioprio_get __NR_ioprio_get #define SYS_ioprio_get __NR_ioprio_get
#define SYS_ioprio_set __NR_ioprio_set #define SYS_ioprio_set __NR_ioprio_set
@ -61,7 +55,7 @@ typedef enum ProcessFields {
typedef struct ProcessPidColumn_ { typedef struct ProcessPidColumn_ {
int id; int id;
char* label; const char* label;
} ProcessPidColumn; } ProcessPidColumn;
typedef struct Process_ { typedef struct Process_ {
@ -175,36 +169,36 @@ typedef struct ProcessClass_ {
extern char Process_pidFormat[20]; extern char Process_pidFormat[20];
extern void Process_setupColumnWidths(); void Process_setupColumnWidths();
extern void Process_humanNumber(RichString* str, unsigned long number, bool coloring); void Process_humanNumber(RichString* str, unsigned long number, bool coloring);
extern void Process_colorNumber(RichString* str, unsigned long long number, bool coloring); void Process_colorNumber(RichString* str, unsigned long long number, bool coloring);
extern void Process_printTime(RichString* str, unsigned long long totalHundredths); void Process_printTime(RichString* str, unsigned long long totalHundredths);
extern void Process_outputRate(RichString* str, char* buffer, int n, double rate, int coloring); void Process_outputRate(RichString* str, char* buffer, int n, double rate, int coloring);
extern void Process_writeField(Process* this, RichString* str, ProcessField field); void Process_writeField(Process* this, RichString* str, ProcessField field);
extern void Process_display(Object* cast, RichString* out); void Process_display(Object* cast, RichString* out);
extern void Process_done(Process* this); void Process_done(Process* this);
extern ProcessClass Process_class; extern ProcessClass Process_class;
extern void Process_init(Process* this, struct Settings_* settings); void Process_init(Process* this, struct Settings_* settings);
extern void Process_toggleTag(Process* this); void Process_toggleTag(Process* this);
extern bool Process_setPriority(Process* this, int priority); bool Process_setPriority(Process* this, int priority);
extern bool Process_changePriorityBy(Process* this, Arg delta); bool Process_changePriorityBy(Process* this, Arg delta);
extern bool Process_sendSignal(Process* this, Arg sgn); bool Process_sendSignal(Process* this, Arg sgn);
extern long Process_pidCompare(const void* v1, const void* v2); long Process_pidCompare(const void* v1, const void* v2);
extern long Process_compare(const void* v1, const void* v2); long Process_compare(const void* v1, const void* v2);
#endif #endif

View File

@ -14,75 +14,12 @@ in the source distribution for its full text.
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
/*{
#include "Vector.h"
#include "Hashtable.h"
#include "UsersTable.h"
#include "Panel.h"
#include "Process.h"
#include "Settings.h"
#ifdef HAVE_LIBHWLOC ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId) {
#include <hwloc.h>
#endif
#ifndef MAX_NAME
#define MAX_NAME 128
#endif
#ifndef MAX_READ
#define MAX_READ 2048
#endif
typedef struct ProcessList_ {
Settings* settings;
Vector* processes;
Vector* processes2;
Hashtable* processTable;
UsersTable* usersTable;
Panel* panel;
int following;
uid_t userId;
const char* incFilter;
Hashtable* pidWhiteList;
#ifdef HAVE_LIBHWLOC
hwloc_topology_t topology;
bool topologyOk;
#endif
int totalTasks;
int runningTasks;
int userlandThreads;
int kernelThreads;
unsigned long long int totalMem;
unsigned long long int usedMem;
unsigned long long int freeMem;
unsigned long long int sharedMem;
unsigned long long int buffersMem;
unsigned long long int cachedMem;
unsigned long long int totalSwap;
unsigned long long int usedSwap;
unsigned long long int freeSwap;
int cpuCount;
} ProcessList;
ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidWhiteList, uid_t userId);
void ProcessList_delete(ProcessList* pl);
void ProcessList_goThroughEntries(ProcessList* pl);
}*/
ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
this->processes = Vector_new(klass, true, DEFAULT_SIZE); this->processes = Vector_new(klass, true, DEFAULT_SIZE);
this->processTable = Hashtable_new(140, false); this->processTable = Hashtable_new(140, false);
this->usersTable = usersTable; this->usersTable = usersTable;
this->pidWhiteList = pidWhiteList; this->pidMatchList = pidMatchList;
this->userId = userId; this->userId = userId;
// tree-view auxiliary buffer // tree-view auxiliary buffer
@ -93,12 +30,19 @@ ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable*
#ifdef HAVE_LIBHWLOC #ifdef HAVE_LIBHWLOC
this->topologyOk = false; this->topologyOk = false;
int topoErr = hwloc_topology_init(&this->topology); if (hwloc_topology_init(&this->topology) == 0) {
if (topoErr == 0) { this->topologyOk =
topoErr = hwloc_topology_load(this->topology); #if HWLOC_API_VERSION < 0x00020000
} /* try to ignore the top-level machine object type */
if (topoErr == 0) { 0 == hwloc_topology_ignore_type_keep_structure(this->topology, HWLOC_OBJ_MACHINE) &&
this->topologyOk = true; /* ignore caches, which don't add structure */
0 == hwloc_topology_ignore_type_keep_structure(this->topology, HWLOC_OBJ_CORE) &&
0 == hwloc_topology_ignore_type_keep_structure(this->topology, HWLOC_OBJ_CACHE) &&
0 == hwloc_topology_set_flags(this->topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM) &&
#else
0 == hwloc_topology_set_all_types_filter(this->topology, HWLOC_TYPE_FILTER_KEEP_STRUCTURE) &&
#endif
0 == hwloc_topology_load(this->topology);
} }
#endif #endif
@ -310,7 +254,7 @@ void ProcessList_rebuildPanel(ProcessList* this) {
if ( (!p->show) if ( (!p->show)
|| (this->userId != (uid_t) -1 && (p->st_uid != this->userId)) || (this->userId != (uid_t) -1 && (p->st_uid != this->userId))
|| (incFilter && !(String_contains_i(p->comm, incFilter))) || (incFilter && !(String_contains_i(p->comm, incFilter)))
|| (this->pidWhiteList && !Hashtable_get(this->pidWhiteList, p->tgid)) ) || (this->pidMatchList && !Hashtable_get(this->pidMatchList, p->tgid)) )
hidden = true; hidden = true;
if (!hidden) { if (!hidden) {

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_ProcessList #ifndef HEADER_ProcessList
#define HEADER_ProcessList #define HEADER_ProcessList
/* /*
@ -40,7 +38,7 @@ typedef struct ProcessList_ {
int following; int following;
uid_t userId; uid_t userId;
const char* incFilter; const char* incFilter;
Hashtable* pidWhiteList; Hashtable* pidMatchList;
#ifdef HAVE_LIBHWLOC #ifdef HAVE_LIBHWLOC
hwloc_topology_t topology; hwloc_topology_t topology;
@ -66,37 +64,37 @@ typedef struct ProcessList_ {
} ProcessList; } ProcessList;
ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidWhiteList, uid_t userId); ProcessList* ProcessList_new(UsersTable* ut, Hashtable* pidMatchList, uid_t userId);
void ProcessList_delete(ProcessList* pl); void ProcessList_delete(ProcessList* pl);
void ProcessList_goThroughEntries(ProcessList* pl); void ProcessList_goThroughEntries(ProcessList* pl);
extern ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId); ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable* usersTable, Hashtable* pidMatchList, uid_t userId);
extern void ProcessList_done(ProcessList* this); void ProcessList_done(ProcessList* this);
extern void ProcessList_setPanel(ProcessList* this, Panel* panel); void ProcessList_setPanel(ProcessList* this, Panel* panel);
extern void ProcessList_printHeader(ProcessList* this, RichString* header); void ProcessList_printHeader(ProcessList* this, RichString* header);
extern void ProcessList_add(ProcessList* this, Process* p); void ProcessList_add(ProcessList* this, Process* p);
extern void ProcessList_remove(ProcessList* this, Process* p); void ProcessList_remove(ProcessList* this, Process* p);
extern Process* ProcessList_get(ProcessList* this, int idx); Process* ProcessList_get(ProcessList* this, int idx);
extern int ProcessList_size(ProcessList* this); int ProcessList_size(ProcessList* this);
extern void ProcessList_sort(ProcessList* this); void ProcessList_sort(ProcessList* this);
extern ProcessField ProcessList_keyAt(ProcessList* this, int at); ProcessField ProcessList_keyAt(ProcessList* this, int at);
extern void ProcessList_expandTree(ProcessList* this); void ProcessList_expandTree(ProcessList* this);
extern void ProcessList_rebuildPanel(ProcessList* this); void ProcessList_rebuildPanel(ProcessList* this);
extern Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting, Process_New constructor); Process* ProcessList_getProcess(ProcessList* this, pid_t pid, bool* preExisting, Process_New constructor);
extern void ProcessList_scan(ProcessList* this); void ProcessList_scan(ProcessList* this);
#endif #endif

21
README
View File

@ -1,13 +1,13 @@
![htop](https://htop.dev) # [![htop](htop.png)](https://htop.dev)
[![CI](https://github.com/htop-dev/htop/workflows/CI/badge.svg)](https://github.com/htop-dev/htop/actions) [![CI](https://github.com/htop-dev/htop/workflows/CI/badge.svg)](https://github.com/htop-dev/htop/actions)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/21617/badge.svg)](https://scan.coverity.com/projects/21617) [![Coverity Scan Build Status](https://scan.coverity.com/projects/21665/badge.svg)](https://scan.coverity.com/projects/21665)
[![Mailing List](https://img.shields.io/badge/Mailing%20List-htop-blue.svg)](https://groups.io/g/htop) [![Mailing List](https://img.shields.io/badge/Mailing%20List-htop-blue.svg)](https://groups.io/g/htop)
[![IRC #htop](https://img.shields.io/badge/IRC-htop-blue.svg)](https://webchat.freenode.net/#htop) [![IRC #htop](https://img.shields.io/badge/IRC-htop-blue.svg)](https://webchat.freenode.net/#htop)
[![Github Release](https://img.shields.io/github/release/htop-dev/htop.svg)](https://github.com/htop-dev/htop/releases/latest) [![Github Release](https://img.shields.io/github/release/htop-dev/htop.svg)](https://github.com/htop-dev/htop/releases/latest)
[![Download](https://api.bintray.com/packages/htop/source/htop/images/download.svg)](https://bintray.com/htop/source/htop/_latestVersion)
Introduction ## Introduction
------------
`htop` is a cross-platform interactive process viewer. `htop` is a cross-platform interactive process viewer.
It requires `ncurses`. It requires `ncurses`.
@ -15,20 +15,23 @@ It requires `ncurses`.
For more information and details on how to contribute to `htop` For more information and details on how to contribute to `htop`
visit [htop.dev](https://htop.dev). visit [htop.dev](https://htop.dev).
Build instructions ## Build instructions
------------------
This program is distributed as a standard autotools-based package. This program is distributed as a standard autotools-based package.
For detailed instructions see the [INSTALL](/INSTALL) file, which For detailed instructions see the `INSTALL` file, which
is created after `./autogen.sh` is run. is created after `./autogen.sh` is run.
When compiling from a [release tarball](https://github.com/htop-dev/htop/releases/), run: When compiling from a [release tarball](https://github.com/htop-dev/htop/releases/), run:
./configure && make ~~~ shell
./configure && make
~~~
For compiling sources downloaded from the Git repository, run: For compiling sources downloaded from the Git repository, run:
./autogen.sh && ./configure && make ~~~ shell
./autogen.sh && ./configure && make
~~~
By default `make install` will install into `/usr/local`, for changing By default `make install` will install into `/usr/local`, for changing
the path use `./configure --prefix=/some/path`. the path use `./configure --prefix=/some/path`.

View File

@ -7,66 +7,11 @@ in the source distribution for its full text.
#include "RichString.h" #include "RichString.h"
#include "XAlloc.h" #include "XAlloc.h"
#include "Macros.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define RICHSTRING_MAXLEN 350
/*{
#include "config.h"
#include <ctype.h>
#include <assert.h>
#ifdef HAVE_NCURSESW_CURSES_H
#include <ncursesw/curses.h>
#elif HAVE_NCURSES_NCURSES_H
#include <ncurses/ncurses.h>
#elif HAVE_NCURSES_CURSES_H
#include <ncurses/curses.h>
#elif HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_CURSES_H
#include <curses.h>
#endif
#ifdef HAVE_LIBNCURSESW
#include <wctype.h>
#endif
#define RichString_size(this) ((this)->chlen)
#define RichString_sizeVal(this) ((this).chlen)
#define RichString_begin(this) RichString (this); memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr;
#define RichString_beginAllocated(this) memset(&this, 0, sizeof(RichString)); (this).chptr = (this).chstr;
#define RichString_end(this) RichString_prune(&(this));
#ifdef HAVE_LIBNCURSESW
#define RichString_printVal(this, y, x) mvadd_wchstr(y, x, (this).chptr)
#define RichString_printoffnVal(this, y, x, off, n) mvadd_wchnstr(y, x, (this).chptr + off, n)
#define RichString_getCharVal(this, i) ((this).chptr[i].chars[0] & 255)
#define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)] = (CharType) { .chars = { ch, 0 } }; } while(0)
#define CharType cchar_t
#else
#define RichString_printVal(this, y, x) mvaddchstr(y, x, (this).chptr)
#define RichString_printoffnVal(this, y, x, off, n) mvaddchnstr(y, x, (this).chptr + off, n)
#define RichString_getCharVal(this, i) ((this).chptr[i])
#define RichString_setChar(this, at, ch) do{ (this)->chptr[(at)] = ch; } while(0)
#define CharType chtype
#endif
typedef struct RichString_ {
int chlen;
CharType* chptr;
CharType chstr[RICHSTRING_MAXLEN+1];
} RichString;
}*/
#ifndef CLAMP
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
#define charBytes(n) (sizeof(CharType) * (n)) #define charBytes(n) (sizeof(CharType) * (n))
static void RichString_extendLen(RichString* this, int len) { static void RichString_extendLen(RichString* this, int len) {

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_RichString #ifndef HEADER_RichString
#define HEADER_RichString #define HEADER_RichString
/* /*
@ -9,7 +7,6 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
#define RICHSTRING_MAXLEN 350
#include "config.h" #include "config.h"
#include <ctype.h> #include <ctype.h>
@ -52,43 +49,36 @@ in the source distribution for its full text.
#define CharType chtype #define CharType chtype
#endif #endif
#define RICHSTRING_MAXLEN 350
typedef struct RichString_ { typedef struct RichString_ {
int chlen; int chlen;
CharType* chptr; CharType* chptr;
CharType chstr[RICHSTRING_MAXLEN+1]; CharType chstr[RICHSTRING_MAXLEN+1];
} RichString; } RichString;
#ifndef CLAMP
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
#define charBytes(n) (sizeof(CharType) * (n))
#define RichString_setLen(this, len) do{ if(len < RICHSTRING_MAXLEN && this->chlen < RICHSTRING_MAXLEN) { RichString_setChar(this,len,0); this->chlen=len; } else RichString_extendLen(this,len); }while(0)
#ifdef HAVE_LIBNCURSESW #ifdef HAVE_LIBNCURSESW
extern void RichString_setAttrn(RichString* this, int attrs, int start, int finish); void RichString_setAttrn(RichString* this, int attrs, int start, int finish);
extern int RichString_findChar(RichString* this, char c, int start); int RichString_findChar(RichString* this, char c, int start);
#else #else
extern void RichString_setAttrn(RichString* this, int attrs, int start, int finish); void RichString_setAttrn(RichString* this, int attrs, int start, int finish);
extern int RichString_findChar(RichString* this, char c, int start); int RichString_findChar(RichString* this, char c, int start);
#endif #endif
extern void RichString_prune(RichString* this); void RichString_prune(RichString* this);
extern void RichString_setAttr(RichString* this, int attrs); void RichString_setAttr(RichString* this, int attrs);
extern void RichString_append(RichString* this, int attrs, const char* data); void RichString_append(RichString* this, int attrs, const char* data);
extern void RichString_appendn(RichString* this, int attrs, const char* data, int len); void RichString_appendn(RichString* this, int attrs, const char* data, int len);
extern void RichString_write(RichString* this, int attrs, const char* data); void RichString_write(RichString* this, int attrs, const char* data);
#endif #endif

View File

@ -16,33 +16,6 @@ in the source distribution for its full text.
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
/*{
#include "FunctionBar.h"
#include "Vector.h"
#include "Header.h"
#include "Settings.h"
#include "Panel.h"
typedef enum Orientation_ {
VERTICAL,
HORIZONTAL
} Orientation;
typedef struct ScreenManager_ {
int x1;
int y1;
int x2;
int y2;
Orientation orientation;
Vector* panels;
int panelCount;
const Header* header;
const Settings* settings;
bool owner;
bool allowFocusChange;
} ScreenManager;
}*/
ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation orientation, const Header* header, const Settings* settings, bool owner) { ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation orientation, const Header* header, const Settings* settings, bool owner) {
ScreenManager* this; ScreenManager* this;
@ -190,22 +163,6 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
set_escdelay(25); set_escdelay(25);
ch = getch(); ch = getch();
if (this->settings->vimMode) {
switch (ch) {
case 'h': ch = KEY_LEFT; break;
case 'j': ch = KEY_DOWN; break;
case 'k': ch = KEY_UP; break;
case 'l': ch = KEY_RIGHT; break;
case KEY_LEFT: ch = 'h'; break;
case KEY_DOWN: ch = 'j'; break;
case KEY_UP: ch = 'k'; break;
case KEY_RIGHT: ch = 'l'; break;
case 'K': ch = 'k'; break;
case 'J': ch = 'K'; break;
case 'L': ch = 'l'; break;
}
}
HandlerResult result = IGNORED; HandlerResult result = IGNORED;
if (ch == KEY_MOUSE && this->settings->enableMouse) { if (ch == KEY_MOUSE && this->settings->enableMouse) {
ch = ERR; ch = ERR;

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_ScreenManager #ifndef HEADER_ScreenManager
#define HEADER_ScreenManager #define HEADER_ScreenManager
/* /*
@ -9,7 +7,6 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
#include "FunctionBar.h"
#include "Vector.h" #include "Vector.h"
#include "Header.h" #include "Header.h"
#include "Settings.h" #include "Settings.h"
@ -34,19 +31,18 @@ typedef struct ScreenManager_ {
bool allowFocusChange; bool allowFocusChange;
} ScreenManager; } ScreenManager;
ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation orientation, const Header* header, const Settings* settings, bool owner);
extern ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation orientation, const Header* header, const Settings* settings, bool owner); void ScreenManager_delete(ScreenManager* this);
extern void ScreenManager_delete(ScreenManager* this); int ScreenManager_size(ScreenManager* this);
extern int ScreenManager_size(ScreenManager* this); void ScreenManager_add(ScreenManager* this, Panel* item, int size);
extern void ScreenManager_add(ScreenManager* this, Panel* item, int size); Panel* ScreenManager_remove(ScreenManager* this, int idx);
extern Panel* ScreenManager_remove(ScreenManager* this, int idx); void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2);
extern void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2); void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey);
extern void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey);
#endif #endif

View File

@ -17,61 +17,6 @@ in the source distribution for its full text.
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#define DEFAULT_DELAY 15
/*{
#include "Process.h"
#include <stdbool.h>
typedef struct {
int len;
char** names;
int* modes;
} MeterColumnSettings;
typedef struct Settings_ {
char* filename;
MeterColumnSettings columns[2];
ProcessField* fields;
int flags;
int colorScheme;
int delay;
int cpuCount;
int direction;
ProcessField sortKey;
bool countCPUsFromZero;
bool detailedCPUTime;
bool showCPUUsage;
bool showCPUFrequency;
bool treeView;
bool showProgramPath;
bool hideThreads;
bool shadowOtherUsers;
bool showThreadNames;
bool hideKernelThreads;
bool hideUserlandThreads;
bool highlightBaseName;
bool highlightMegabytes;
bool highlightThreads;
bool updateProcessNames;
bool accountGuestInCPUMeter;
bool headerMargin;
bool enableMouse;
bool vimMode;
bool changed;
} Settings;
#ifndef Settings_cpuId
#define Settings_cpuId(settings, cpu) ((settings)->countCPUsFromZero ? (cpu) : (cpu)+1)
#endif
}*/
void Settings_delete(Settings* this) { void Settings_delete(Settings* this) {
free(this->filename); free(this->filename);
free(this->fields); free(this->fields);
@ -118,7 +63,6 @@ static void Settings_defaultMeters(Settings* this) {
this->columns[i].modes = xCalloc(sizes[i], sizeof(int)); this->columns[i].modes = xCalloc(sizes[i], sizeof(int));
this->columns[i].len = sizes[i]; this->columns[i].len = sizes[i];
} }
int r = 0; int r = 0;
if (this->cpuCount > 8) { if (this->cpuCount > 8) {
this->columns[0].names[0] = xStrdup("LeftCPUs2"); this->columns[0].names[0] = xStrdup("LeftCPUs2");
@ -138,7 +82,6 @@ static void Settings_defaultMeters(Settings* this) {
this->columns[0].modes[1] = BAR_METERMODE; this->columns[0].modes[1] = BAR_METERMODE;
this->columns[0].names[2] = xStrdup("Swap"); this->columns[0].names[2] = xStrdup("Swap");
this->columns[0].modes[2] = BAR_METERMODE; this->columns[0].modes[2] = BAR_METERMODE;
this->columns[1].names[r] = xStrdup("Tasks"); this->columns[1].names[r] = xStrdup("Tasks");
this->columns[1].modes[r++] = TEXT_METERMODE; this->columns[1].modes[r++] = TEXT_METERMODE;
this->columns[1].names[r] = xStrdup("LoadAverage"); this->columns[1].names[r] = xStrdup("LoadAverage");
@ -169,13 +112,11 @@ static void readFields(ProcessField* fields, int* flags, const char* line) {
static bool Settings_read(Settings* this, const char* fileName) { static bool Settings_read(Settings* this, const char* fileName) {
FILE* fd; FILE* fd;
CRT_dropPrivileges(); CRT_dropPrivileges();
fd = fopen(fileName, "r"); fd = fopen(fileName, "r");
CRT_restorePrivileges(); CRT_restorePrivileges();
if (!fd) if (!fd)
return false; return false;
bool didReadMeters = false; bool didReadMeters = false;
bool didReadFields = false; bool didReadFields = false;
for (;;) { for (;;) {
@ -254,8 +195,10 @@ static bool Settings_read(Settings* this, const char* fileName) {
} else if (String_eq(option[0], "right_meter_modes")) { } else if (String_eq(option[0], "right_meter_modes")) {
Settings_readMeterModes(this, option[1], 1); Settings_readMeterModes(this, option[1], 1);
didReadMeters = true; didReadMeters = true;
} else if (String_eq(option[0], "vim_mode")) { #ifdef HAVE_LIBHWLOC
this->vimMode = atoi(option[1]); } else if (String_eq(option[0], "topology_affinity")) {
this->topologyAffinity = !!atoi(option[1]);
#endif
} }
String_freeArray(option); String_freeArray(option);
} }
@ -335,13 +278,14 @@ bool Settings_write(Settings* this) {
fprintf(fd, "left_meter_modes="); writeMeterModes(this, fd, 0); fprintf(fd, "left_meter_modes="); writeMeterModes(this, fd, 0);
fprintf(fd, "right_meters="); writeMeters(this, fd, 1); fprintf(fd, "right_meters="); writeMeters(this, fd, 1);
fprintf(fd, "right_meter_modes="); writeMeterModes(this, fd, 1); fprintf(fd, "right_meter_modes="); writeMeterModes(this, fd, 1);
fprintf(fd, "vim_mode=%d\n", (int) this->vimMode); #ifdef HAVE_LIBHWLOC
fprintf(fd, "topology_affinity=%d\n", (int) this->topologyAffinity);
#endif
fclose(fd); fclose(fd);
return true; return true;
} }
Settings* Settings_new(int cpuCount) { Settings* Settings_new(int cpuCount) {
Settings* this = xCalloc(1, sizeof(Settings)); Settings* this = xCalloc(1, sizeof(Settings));
this->sortKey = PERCENT_CPU; this->sortKey = PERCENT_CPU;
@ -362,7 +306,9 @@ Settings* Settings_new(int cpuCount) {
this->cpuCount = cpuCount; this->cpuCount = cpuCount;
this->showProgramPath = true; this->showProgramPath = true;
this->highlightThreads = true; this->highlightThreads = true;
#ifdef HAVE_LIBHWLOC
this->topologyAffinity = false;
#endif
this->fields = xCalloc(Platform_numberOfFields+1, sizeof(ProcessField)); this->fields = xCalloc(Platform_numberOfFields+1, sizeof(ProcessField));
// TODO: turn 'fields' into a Vector, // TODO: turn 'fields' into a Vector,
// (and ProcessFields into proper objects). // (and ProcessFields into proper objects).
@ -393,7 +339,6 @@ Settings* Settings_new(int cpuCount) {
htopDir = String_cat(home, "/.config/htop"); htopDir = String_cat(home, "/.config/htop");
} }
legacyDotfile = String_cat(home, "/.htoprc"); legacyDotfile = String_cat(home, "/.htoprc");
CRT_dropPrivileges(); CRT_dropPrivileges();
(void) mkdir(configDir, 0700); (void) mkdir(configDir, 0700);
(void) mkdir(htopDir, 0700); (void) mkdir(htopDir, 0700);

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Settings #ifndef HEADER_Settings
#define HEADER_Settings #define HEADER_Settings
/* /*
@ -22,7 +20,6 @@ typedef struct {
typedef struct Settings_ { typedef struct Settings_ {
char* filename; char* filename;
MeterColumnSettings columns[2]; MeterColumnSettings columns[2];
ProcessField* fields; ProcessField* fields;
@ -52,22 +49,21 @@ typedef struct Settings_ {
bool accountGuestInCPUMeter; bool accountGuestInCPUMeter;
bool headerMargin; bool headerMargin;
bool enableMouse; bool enableMouse;
bool vimMode; #ifdef HAVE_LIBHWLOC
bool topologyAffinity;
#endif
bool changed; bool changed;
} Settings; } Settings;
#ifndef Settings_cpuId
#define Settings_cpuId(settings, cpu) ((settings)->countCPUsFromZero ? (cpu) : (cpu)+1) #define Settings_cpuId(settings, cpu) ((settings)->countCPUsFromZero ? (cpu) : (cpu)+1)
#endif
void Settings_delete(Settings* this);
extern void Settings_delete(Settings* this); bool Settings_write(Settings* this);
extern bool Settings_write(Settings* this); Settings* Settings_new(int cpuCount);
extern Settings* Settings_new(int cpuCount); void Settings_invertSortOrder(Settings* this);
extern void Settings_invertSortOrder(Settings* this);
#endif #endif

View File

@ -18,14 +18,6 @@ in the source distribution for its full text.
#include <ctype.h> #include <ctype.h>
/*{
typedef struct SignalItem_ {
const char* name;
int number;
} SignalItem;
}*/
Panel* SignalsPanel_new() { Panel* SignalsPanel_new() {
Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem), FunctionBar_newEnterEsc("Send ", "Cancel ")); Panel* this = Panel_new(1, 1, 1, 1, true, Class(ListItem), FunctionBar_newEnterEsc("Send ", "Cancel "));

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_SignalsPanel #ifndef HEADER_SignalsPanel
#define HEADER_SignalsPanel #define HEADER_SignalsPanel
/* /*
@ -9,13 +7,11 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text. in the source distribution for its full text.
*/ */
typedef struct SignalItem_ { typedef struct SignalItem_ {
const char* name; const char* name;
int number; int number;
} SignalItem; } SignalItem;
Panel* SignalsPanel_new();
extern Panel* SignalsPanel_new();
#endif #endif

View File

@ -14,18 +14,6 @@ in the source distribution for its full text.
#include <strings.h> #include <strings.h>
#include <stdlib.h> #include <stdlib.h>
/*{
#include <stdio.h>
#define String_startsWith(s, match) (strncmp((s),(match),strlen(match)) == 0)
#define String_contains_i(s1, s2) (strcasestr(s1, s2) != NULL)
}*/
/*
* String_startsWith gives better performance if strlen(match) can be computed
* at compile time (e.g. when they are immutable string literals). :)
*/
char* String_cat(const char* s1, const char* s2) { char* String_cat(const char* s1, const char* s2) {
int l1 = strlen(s1); int l1 = strlen(s1);
int l2 = strlen(s2); int l2 = strlen(s2);
@ -81,10 +69,7 @@ char** String_split(const char* s, char sep, int* n) {
s += size + 1; s += size + 1;
} }
if (s[0] != '\0') { if (s[0] != '\0') {
int size = strlen(s); out[ctr] = xStrdup(s);
char* token = xMalloc(size + 1);
strncpy(token, s, size + 1);
out[ctr] = token;
ctr++; ctr++;
} }
out = xRealloc(out, sizeof(char*) * (ctr + 1)); out = xRealloc(out, sizeof(char*) * (ctr + 1));

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_StringUtils #ifndef HEADER_StringUtils
#define HEADER_StringUtils #define HEADER_StringUtils
/* /*
@ -19,18 +17,18 @@ in the source distribution for its full text.
* at compile time (e.g. when they are immutable string literals). :) * at compile time (e.g. when they are immutable string literals). :)
*/ */
extern char* String_cat(const char* s1, const char* s2); char* String_cat(const char* s1, const char* s2);
extern char* String_trim(const char* in); char* String_trim(const char* in);
extern int String_eq(const char* s1, const char* s2); int String_eq(const char* s1, const char* s2);
extern char** String_split(const char* s, char sep, int* n); char** String_split(const char* s, char sep, int* n);
extern void String_freeArray(char** s); void String_freeArray(char** s);
extern char* String_getToken(const char* line, const unsigned short int numMatch); char* String_getToken(const char* line, const unsigned short int numMatch);
extern char* String_readLine(FILE* fd); char* String_readLine(FILE* fd);
#endif #endif

View File

@ -16,9 +16,6 @@ in the source distribution for its full text.
#include <sys/param.h> #include <sys/param.h>
#include <assert.h> #include <assert.h>
/*{
#include "Meter.h"
}*/
int SwapMeter_attributes[] = { int SwapMeter_attributes[] = {
SWAP SWAP

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_SwapMeter #ifndef HEADER_SwapMeter
#define HEADER_SwapMeter #define HEADER_SwapMeter
/* /*

View File

@ -4,47 +4,47 @@ Main screen:
For all views, all modes: For all views, all modes:
Mouse click header - nothing happens. Mouse click header - nothing happens.
Mouse click on ProcessList title bar - exit Tree view, update FunctionBar, title bar updates, sort by clicked field. Mouse click on ProcessList title bar - exit Tree view, update FunctionBar, title bar updates, sort by clicked field.
*** FAILING: wrong FB update depending on mode; does not change sort in wip branch *** FAILING: wrong FB update depending on mode; does not change sort in wip branch
click on same entry - invert sort. click on same entry - invert sort.
click on another entry - sort another field. click on another entry - sort another field.
Mouse click on a process - select that process. Mouse click on a process - select that process.
for each entry in FunctionBar: for each entry in FunctionBar:
Mouse click entry - perform action of associated key. Mouse click entry - perform action of associated key.
In Normal mode, Sorted view: In Normal mode, Sorted view:
<+> or <-> - do nothing. <+> or <-> - do nothing.
<F6> - enter SortBy screen. <F6> - enter SortBy screen.
In Normal mode, Tree view: In Normal mode, Tree view:
select process - update F6 in FunctionBar if subtree is collapsed or expanded. select process - update F6 in FunctionBar if subtree is collapsed or expanded.
<F6>, <+> or <-> - expand/collapse subtree. <F6>, <+> or <-> - expand/collapse subtree.
In Normal mode, either Sorted or Tree view: In Normal mode, either Sorted or Tree view:
<F3>, </> - activate Search mode. <F3>, </> - activate Search mode.
<F4>, <\> - activate Filter mode. <F4>, <\> - activate Filter mode.
<F7>, <]> - as root only, decrease process NICE value. <F7>, <]> - as root only, decrease process NICE value.
<F8>, <[> - increase process NICE value. <F8>, <[> - increase process NICE value.
<a> - enter Affinity screen. <a> - enter Affinity screen.
<b> - do nothing. <b> - do nothing.
<c> - select process and all its children. <c> - select process and all its children.
<d>, <e>, <f>, <g> - do nothing. <d>, <e>, <f>, <g> - do nothing.
<F1>, <h>, <?> - enter Help screen. <F1>, <h>, <?> - enter Help screen.
<i> - on Linux, enter IOPriority screen. <i> - on Linux, enter IOPriority screen.
@ -64,67 +64,67 @@ Main screen:
<s> - enter STrace screen. <s> - enter STrace screen.
<F5>, <t> - toggle between Tree and Sorted view, update F5 in FunctionBar, follow process <F5>, <t> - toggle between Tree and Sorted view, update F5 in FunctionBar, follow process
<u> - enter User screen. <u> - enter User screen.
<v>, <w>, <x>, <y>, <z> - do nothing. <v>, <w>, <x>, <y>, <z> - do nothing.
<A>, <B> - do nothing. <A>, <B> - do nothing.
<F2>, <C>, <S> - enter Setup screen. <F2>, <C>, <S> - enter Setup screen.
<D>, <E> - do nothing. <D>, <E> - do nothing.
<F> - follow process. <F> - follow process.
<G> - do nothing. <G> - do nothing.
<H> - toggle show/hide userland threads. <H> - toggle show/hide userland threads.
<I> - invert sort order. <I> - invert sort order.
<J> - do nothing. <J> - do nothing.
<K> - toggle show/hide kernel threads. <K> - toggle show/hide kernel threads.
<L> - do nothing. <L> - do nothing.
<M> - enter Sorted view, update function bar, sort by MEM%. <M> - enter Sorted view, update function bar, sort by MEM%.
<N>, <O> - do nothing. <N>, <O> - do nothing.
<P> - enter Sorted view, update function bar, sort by CPU%. <P> - enter Sorted view, update function bar, sort by CPU%.
<Q>, <R> - do nothing. <Q>, <R> - do nothing.
<T> - enter Sorted view, update function bar, sort by TIME. <T> - enter Sorted view, update function bar, sort by TIME.
<U> - untag all processes. <U> - untag all processes.
<V>, <W>, <X>, <Y>, <Z> - do nothing. <V>, <W>, <X>, <Y>, <Z> - do nothing.
<<>, <>>, <,>, <.> - enter SortBy screen. <<>, <>>, <,>, <.> - enter SortBy screen.
space - tag current process, move down cursor. space - tag current process, move down cursor.
numbers - incremental PID search. numbers - incremental PID search.
In Search mode: In Search mode:
TODO TODO
In Filter mode: In Filter mode:
TODO TODO
Setup screen: Setup screen:
TODO TODO
SortBy screen: SortBy screen:
TODO TODO
User screen: User screen:
TODO TODO
@ -136,7 +136,7 @@ Kill screen:
Affinity screen: Affinity screen:
TODO TODO
Help screen: Help screen:
any key - back to Main screen. any key - back to Main screen.
@ -152,4 +152,3 @@ STrace screen:
LSOF screen: LSOF screen:
TODO TODO

View File

@ -10,9 +10,6 @@ in the source distribution for its full text.
#include "Platform.h" #include "Platform.h"
#include "CRT.h" #include "CRT.h"
/*{
#include "Meter.h"
}*/
int TasksMeter_attributes[] = { int TasksMeter_attributes[] = {
CPU_SYSTEM, PROCESS_THREAD, PROCESS, TASKS_RUNNING CPU_SYSTEM, PROCESS_THREAD, PROCESS, TASKS_RUNNING
@ -23,7 +20,7 @@ static void TasksMeter_updateValues(Meter* this, char* buffer, int len) {
this->values[0] = pl->kernelThreads; this->values[0] = pl->kernelThreads;
this->values[1] = pl->userlandThreads; this->values[1] = pl->userlandThreads;
this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads; this->values[2] = pl->totalTasks - pl->kernelThreads - pl->userlandThreads;
this->values[3] = MIN(pl->runningTasks, pl->cpuCount); this->values[3] = MINIMUM(pl->runningTasks, pl->cpuCount);
if (pl->totalTasks > this->total) { if (pl->totalTasks > this->total) {
this->total = pl->totalTasks; this->total = pl->totalTasks;
} }

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_TasksMeter #ifndef HEADER_TasksMeter
#define HEADER_TasksMeter #define HEADER_TasksMeter
/* /*

View File

@ -8,7 +8,6 @@ in the source distribution for its full text.
#include "TraceScreen.h" #include "TraceScreen.h"
#include "CRT.h" #include "CRT.h"
#include "InfoScreen.h"
#include "ProcessList.h" #include "ProcessList.h"
#include "ListItem.h" #include "ListItem.h"
#include "IncSet.h" #include "IncSet.h"
@ -27,21 +26,6 @@ in the source distribution for its full text.
#include <sys/wait.h> #include <sys/wait.h>
#include <signal.h> #include <signal.h>
/*{
#include "InfoScreen.h"
typedef struct TraceScreen_ {
InfoScreen super;
bool tracing;
int fdpair[2];
int child;
FILE* strace;
int fd_strace;
bool contLine;
bool follow;
} TraceScreen;
}*/
static const char* const TraceScreenFunctions[] = {"Search ", "Filter ", "AutoScroll ", "Stop Tracing ", "Done ", NULL}; static const char* const TraceScreenFunctions[] = {"Search ", "Filter ", "AutoScroll ", "Stop Tracing ", "Done ", NULL};

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_TraceScreen #ifndef HEADER_TraceScreen
#define HEADER_TraceScreen #define HEADER_TraceScreen
/* /*
@ -25,16 +23,16 @@ typedef struct TraceScreen_ {
extern InfoScreenClass TraceScreen_class; extern InfoScreenClass TraceScreen_class;
extern TraceScreen* TraceScreen_new(Process* process); TraceScreen* TraceScreen_new(Process* process);
extern void TraceScreen_delete(Object* cast); void TraceScreen_delete(Object* cast);
extern void TraceScreen_draw(InfoScreen* this); void TraceScreen_draw(InfoScreen* this);
extern bool TraceScreen_forkTracer(TraceScreen* this); bool TraceScreen_forkTracer(TraceScreen* this);
extern void TraceScreen_updateTrace(InfoScreen* super); void TraceScreen_updateTrace(InfoScreen* super);
extern bool TraceScreen_onKey(InfoScreen* super, int ch); bool TraceScreen_onKey(InfoScreen* super, int ch);
#endif #endif

View File

@ -9,9 +9,6 @@ in the source distribution for its full text.
#include "Platform.h" #include "Platform.h"
#include "CRT.h" #include "CRT.h"
/*{
#include "Meter.h"
}*/
int UptimeMeter_attributes[] = { int UptimeMeter_attributes[] = {
UPTIME UPTIME

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_UptimeMeter #ifndef HEADER_UptimeMeter
#define HEADER_UptimeMeter #define HEADER_UptimeMeter
/* /*

View File

@ -18,13 +18,6 @@ in the source distribution for its full text.
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
/*{
#include "Hashtable.h"
typedef struct UsersTable_ {
Hashtable* users;
} UsersTable;
}*/
UsersTable* UsersTable_new() { UsersTable* UsersTable_new() {
UsersTable* this; UsersTable* this;

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_UsersTable #ifndef HEADER_UsersTable
#define HEADER_UsersTable #define HEADER_UsersTable
/* /*
@ -15,12 +13,12 @@ typedef struct UsersTable_ {
Hashtable* users; Hashtable* users;
} UsersTable; } UsersTable;
extern UsersTable* UsersTable_new(); UsersTable* UsersTable_new();
extern void UsersTable_delete(UsersTable* this); void UsersTable_delete(UsersTable* this);
extern char* UsersTable_getRef(UsersTable* this, unsigned int uid); char* UsersTable_getRef(UsersTable* this, unsigned int uid);
extern void UsersTable_foreach(UsersTable* this, Hashtable_PairFunction f, void* userData); void UsersTable_foreach(UsersTable* this, Hashtable_PairFunction f, void* userData);
#endif #endif

View File

@ -12,25 +12,6 @@ in the source distribution for its full text.
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
/*{
#include "Object.h"
#define swap(a_,x_,y_) do{ void* tmp_ = a_[x_]; a_[x_] = a_[y_]; a_[y_] = tmp_; }while(0)
#ifndef DEFAULT_SIZE
#define DEFAULT_SIZE -1
#endif
typedef struct Vector_ {
Object **array;
ObjectClass* type;
int arraySize;
int growthRate;
int items;
bool owner;
} Vector;
}*/
Vector* Vector_new(ObjectClass* type, bool owner, int size) { Vector* Vector_new(ObjectClass* type, bool owner, int size) {
Vector* this; Vector* this;
@ -280,7 +261,7 @@ inline Object* Vector_get(Vector* this, int idx) {
#else #else
#define Vector_get(v_, idx_) ((v_)->array[idx_]) // In this case, Vector_get is defined as a macro in vector.h
#endif #endif
@ -293,7 +274,7 @@ inline int Vector_size(Vector* this) {
#else #else
#define Vector_size(v_) ((v_)->items) // In this case, Vector_size is defined as a macro in vector.h
#endif #endif
@ -335,3 +316,15 @@ inline int Vector_indexOf(Vector* this, void* search_, Object_Compare compare) {
} }
return -1; return -1;
} }
void Vector_splice(Vector* this, Vector* from) {
assert(Vector_isConsistent(this));
assert(Vector_isConsistent(from));
assert(!(this->owner && from->owner));
int olditmes = this->items;
this->items += from->items;
Vector_checkArraySize(this);
for (int j = 0; j < from->items; j++)
this->array[olditmes + j] = from->array[j];
}

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_Vector #ifndef HEADER_Vector
#define HEADER_Vector #define HEADER_Vector
/* /*
@ -26,43 +24,37 @@ typedef struct Vector_ {
bool owner; bool owner;
} Vector; } Vector;
Vector* Vector_new(ObjectClass* type, bool owner, int size);
extern Vector* Vector_new(ObjectClass* type, bool owner, int size); void Vector_delete(Vector* this);
extern void Vector_delete(Vector* this);
#ifdef DEBUG #ifdef DEBUG
extern int Vector_count(Vector* this); int Vector_count(Vector* this);
#endif #endif
extern void Vector_prune(Vector* this); void Vector_prune(Vector* this);
// If I were to use only one sorting algorithm for both cases, it would probably be this one: void Vector_quickSort(Vector* this);
/*
*/ void Vector_insertionSort(Vector* this);
extern void Vector_quickSort(Vector* this); void Vector_insert(Vector* this, int idx, void* data_);
extern void Vector_insertionSort(Vector* this); Object* Vector_take(Vector* this, int idx);
extern void Vector_insert(Vector* this, int idx, void* data_); Object* Vector_remove(Vector* this, int idx);
extern Object* Vector_take(Vector* this, int idx); void Vector_moveUp(Vector* this, int idx);
extern Object* Vector_remove(Vector* this, int idx); void Vector_moveDown(Vector* this, int idx);
extern void Vector_moveUp(Vector* this, int idx); void Vector_set(Vector* this, int idx, void* data_);
extern void Vector_moveDown(Vector* this, int idx);
extern void Vector_set(Vector* this, int idx, void* data_);
#ifdef DEBUG #ifdef DEBUG
extern Object* Vector_get(Vector* this, int idx); Object* Vector_get(Vector* this, int idx);
#else #else
@ -72,7 +64,7 @@ extern Object* Vector_get(Vector* this, int idx);
#ifdef DEBUG #ifdef DEBUG
extern int Vector_size(Vector* this); int Vector_size(Vector* this);
#else #else
@ -80,12 +72,10 @@ extern int Vector_size(Vector* this);
#endif #endif
/* void Vector_add(Vector* this, void* data_);
*/ int Vector_indexOf(Vector* this, void* search_, Object_Compare compare);
extern void Vector_add(Vector* this, void* data_); void Vector_splice(Vector* this, Vector* from);
extern int Vector_indexOf(Vector* this, void* search_, Object_Compare compare);
#endif #endif

View File

@ -8,13 +8,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
/*{
#include <err.h>
#include <assert.h>
#include <stdlib.h>
}*/
static inline void fail() { void fail() {
curs_set(1); curs_set(1);
endwin(); endwin();
err(1, NULL); err(1, NULL);
@ -44,6 +39,10 @@ void* xRealloc(void* ptr, size_t size) {
return data; return data;
} }
#undef xAsprintf
#define xAsprintf(strp, fmt, ...) do { int _r=asprintf(strp, fmt, __VA_ARGS__); if (_r < 0) { fail(); } } while(0)
#define xSnprintf(fmt, len, ...) do { int _l=len; int _n=snprintf(fmt, _l, __VA_ARGS__); if (!(_n > -1 && _n < _l)) { curs_set(1); endwin(); err(1, NULL); } } while(0) #define xSnprintf(fmt, len, ...) do { int _l=len; int _n=snprintf(fmt, _l, __VA_ARGS__); if (!(_n > -1 && _n < _l)) { curs_set(1); endwin(); err(1, NULL); } } while(0)
#undef xStrdup #undef xStrdup

View File

@ -1,5 +1,3 @@
/* Do not edit this file. It was automatically generated. */
#ifndef HEADER_XAlloc #ifndef HEADER_XAlloc
#define HEADER_XAlloc #define HEADER_XAlloc
@ -11,11 +9,17 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
extern void* xMalloc(size_t size); void fail(void);
extern void* xCalloc(size_t nmemb, size_t size); void* xMalloc(size_t size);
extern void* xRealloc(void* ptr, size_t size); void* xCalloc(size_t nmemb, size_t size);
void* xRealloc(void* ptr, size_t size);
#undef xAsprintf
#define xAsprintf(strp, fmt, ...) do { int _r=asprintf(strp, fmt, __VA_ARGS__); if (_r < 0) { fail(); } } while(0)
#define xSnprintf(fmt, len, ...) do { int _l=len; int _n=snprintf(fmt, _l, __VA_ARGS__); if (!(_n > -1 && _n < _l)) { curs_set(1); endwin(); err(1, NULL); } } while(0) #define xSnprintf(fmt, len, ...) do { int _l=len; int _n=snprintf(fmt, _l, __VA_ARGS__); if (!(_n > -1 && _n < _l)) { curs_set(1); endwin(); err(1, NULL); } } while(0)
@ -32,9 +36,9 @@ extern void* xRealloc(void* ptr, size_t size);
#endif #endif
#if (__has_attribute(nonnull) || \ #if (__has_attribute(nonnull) || \
((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))) ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)))
extern char* xStrdup_(const char* str) __attribute__((nonnull)); char* xStrdup_(const char* str) __attribute__((nonnull));
#endif // __has_attribute(nonnull) || GNU C 3.3 or later #endif // __has_attribute(nonnull) || GNU C 3.3 or later
extern char* xStrdup_(const char* str); char* xStrdup_(const char* str);
#endif #endif

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ(2.65) AC_PREREQ(2.65)
AC_INIT([htop],[3.0.0],[htop@groups.io]) AC_INIT([htop],[3.0.2],[htop@groups.io])
AC_CONFIG_SRCDIR([htop.c]) AC_CONFIG_SRCDIR([htop.c])
AC_CONFIG_AUX_DIR([.]) AC_CONFIG_AUX_DIR([.])
@ -111,20 +111,12 @@ AC_SUBST(wextra_flag)
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
PROCDIR=/proc PROCDIR=/proc
AC_ARG_ENABLE(proc, [AS_HELP_STRING([--enable-proc], [use Linux-compatible proc filesystem])], enable_proc="yes", enable_proc="no")
if test "x$enable_proc" = xyes; then
# An enabled proc assumes we're emulating Linux.
my_htop_platform=linux
AC_DEFINE(HAVE_PROC, 1, [Define if using a Linux-compatible proc filesystem.])
fi
AC_ARG_WITH(proc, [AS_HELP_STRING([--with-proc=DIR], [Location of a Linux-compatible proc filesystem (default=/proc).])], AC_ARG_WITH(proc, [AS_HELP_STRING([--with-proc=DIR], [Location of a Linux-compatible proc filesystem (default=/proc).])],
if test -n "$withval"; then
if test -n "$withval"; then AC_DEFINE_UNQUOTED(PROCDIR, "$withval", [Path of proc filesystem])
AC_DEFINE_UNQUOTED(PROCDIR, "$withval", [Path of proc filesystem]) PROCDIR="$withval"
PROCDIR="$withval" fi,
fi, AC_DEFINE(PROCDIR, "/proc", [Path of proc filesystem]))
AC_DEFINE(PROCDIR, "/proc", [Path of proc filesystem]))
if test "x$cross_compiling" = xno; then if test "x$cross_compiling" = xno; then
if test "x$enable_proc" = xyes; then if test "x$enable_proc" = xyes; then
@ -223,7 +215,7 @@ else
HTOP_CHECK_LIB([ncurses], [refresh], [HAVE_LIBNCURSES], HTOP_CHECK_LIB([ncurses], [refresh], [HAVE_LIBNCURSES],
missing_libraries="$missing_libraries libncurses" missing_libraries="$missing_libraries libncurses"
)))) ))))
AC_CHECK_HEADERS([curses.h],[:], AC_CHECK_HEADERS([curses.h],[:],
[AC_CHECK_HEADERS([ncurses/curses.h],[:], [AC_CHECK_HEADERS([ncurses/curses.h],[:],
[AC_CHECK_HEADERS([ncurses/ncurses.h],[:], [AC_CHECK_HEADERS([ncurses/ncurses.h],[:],
@ -295,6 +287,12 @@ then
]) ])
fi fi
AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [Treat warnings as errors (default: warnings are not errors)])], [enable_werror="$enableval"], [enable_werror=no])
AS_IF([test "x$enable_werror" = "xyes"], [AM_CFLAGS="$AM_CFLAGS -Werror"])
AC_SUBST([AM_CFLAGS])
AC_CHECK_PROGS(PYTHON, [python python3 python2])
AC_SUBST(PYTHON)
# Bail out on errors. # Bail out on errors.
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
@ -333,3 +331,20 @@ then
echo "****************************************************************" echo "****************************************************************"
echo "" echo ""
fi fi
AC_MSG_RESULT([
${PACKAGE_NAME} ${VERSION}
platform: $my_htop_platform
proc directory: $PROCDIR
openvz: $enable_openvz
cgroup: $enable_cgroup
vserver: $enable_vserver
ancient vserver: $enable_ancient_vserver
taskstats: $enable_taskstats
unicode: $enable_unicode
linux affinity: $enable_linux_affinity
hwlock: $enable_hwloc
setuid: $enable_setuid
linux delay accounting: $enable_delayacct
])

View File

@ -72,4 +72,3 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
CFRelease(power_sources); CFRelease(power_sources);
} }
} }

Some files were not shown because too many files have changed in this diff Show More