diff options
author | Daniel Lange <DLange@git.local> | 2022-02-04 11:23:04 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2022-02-04 11:23:04 +0100 |
commit | 93c96b12c9cb349b762d38d69568d65cd3e4fbfd (patch) | |
tree | 9cb12bb8f6c16c23cbb19df65c2334449693187d /ProcessList.c | |
parent | ebf0c067a1fdd4b4779b9557552c2278755dcab4 (diff) | |
parent | a6822e98434cf7da6fab033898094976d881ee0f (diff) | |
download | debian_htop-93c96b12c9cb349b762d38d69568d65cd3e4fbfd.tar.gz debian_htop-93c96b12c9cb349b762d38d69568d65cd3e4fbfd.tar.bz2 debian_htop-93c96b12c9cb349b762d38d69568d65cd3e4fbfd.zip |
Update upstream source from tag 'upstream/3.1.2'
Update to upstream version '3.1.2'
with Debian dir 5ce130e9471b77941bbd217b5ea8b7b3419a91c6
Diffstat (limited to 'ProcessList.c')
-rw-r--r-- | ProcessList.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/ProcessList.c b/ProcessList.c index 1ce6b76..c4c759d 100644 --- a/ProcessList.c +++ b/ProcessList.c @@ -105,13 +105,19 @@ static const char* alignedProcessFieldTitle(const ProcessList* this, ProcessFiel if (!title) return "- "; - if (!Process_fields[field].pidColumn) - return title; + if (Process_fields[field].pidColumn) { + static char titleBuffer[PROCESS_MAX_PID_DIGITS + sizeof(" ")]; + xSnprintf(titleBuffer, sizeof(titleBuffer), "%*s ", Process_pidDigits, title); + return titleBuffer; + } - static char titleBuffer[PROCESS_MAX_PID_DIGITS + /* space */ 1 + /* null-terminator */ + 1]; - xSnprintf(titleBuffer, sizeof(titleBuffer), "%*s ", Process_pidDigits, title); + if (field == ST_UID) { + static char titleBuffer[PROCESS_MAX_UID_DIGITS + sizeof(" ")]; + xSnprintf(titleBuffer, sizeof(titleBuffer), "%*s ", Process_uidDigits, title); + return titleBuffer; + } - return titleBuffer; + return title; } void ProcessList_printHeader(const ProcessList* this, RichString* header) { @@ -626,10 +632,15 @@ void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) { ProcessList_goThroughEntries(this, false); + uid_t maxUid = 0; for (int i = Vector_size(this->processes) - 1; i >= 0; i--) { Process* p = (Process*) Vector_get(this->processes, i); Process_makeCommandStr(p); + // keep track of the highest UID for column scaling + if (p->st_uid > maxUid) + maxUid = p->st_uid; + if (p->tombStampMs > 0) { // remove tombed process if (this->monotonicMs >= p->tombStampMs) { @@ -647,6 +658,9 @@ void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) { } } + // Set UID column width based on max UID. + Process_setUidColumnWidth(maxUid); + if (this->settings->treeView) { // Clear out the hashtable to avoid any left-over processes from previous build // |