diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-01-10 15:57:46 +0100 |
---|---|---|
committer | Christian Göttsche <cgzones@googlemail.com> | 2021-01-11 12:02:25 +0100 |
commit | a5db139a0a671e1f7422d6cd387f4bc8d0afb8e7 (patch) | |
tree | b8060e0b189b7cd045d7a135c2e17593bb1fb34c /Process.c | |
parent | 8a67d7f0866bf9451aad301e98059daa5c18e7c3 (diff) |
Linux: use correct column alignment for wide fields
This affects:
- PROC_COMM, PROC_EXE and CWD on Linux
- JAIL on FreeBSD and DragonFlyBSD
- ZONE on Solaris
Diffstat (limited to 'Process.c')
-rw-r--r-- | Process.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -244,6 +244,11 @@ void Process_outputRate(RichString* str, char* buffer, size_t n, double rate, in } } +void Process_printLeftAlignedField(RichString* str, int attr, const char* content, unsigned int width) { + int c = RichString_appendnWide(str, attr, content, MINIMUM(width, strlen(content))); + RichString_appendChr(str, ' ', width + 1 - c); +} + void Process_writeField(const Process* this, RichString* str, ProcessField field) { char buffer[256]; buffer[255] = '\0'; int attr = CRT_colors[DEFAULT_COLOR]; @@ -365,8 +370,7 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field attr = CRT_colors[PROCESS_SHADOW]; if (this->user) { - int c = RichString_appendnWide(str, attr, this->user, MINIMUM(9, strlen(this->user))); - RichString_appendChr(str, ' ', 10 - c); + Process_printLeftAlignedField(str, attr, this->user, 9); return; } |