mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 12:14:36 +03:00
New setting: "Show program path"
Add a setting to hide all but the last component from the programme path, leaving only the "basename". Makes htop more usable on smaller screens, or systems with longer than average paths. Off by default. "Highlight program basename" will still be respected, to further visually separate process names from their arguments.
This commit is contained in:
40
Process.c
40
Process.c
@ -275,25 +275,33 @@ void Process_printTime(RichString* str, unsigned long long totalHundredths) {
|
||||
}
|
||||
|
||||
static inline void Process_writeCommand(Process* this, int attr, int baseattr, RichString* str) {
|
||||
int start = RichString_size(str);
|
||||
RichString_append(str, attr, this->comm);
|
||||
if (this->settings->highlightBaseName) {
|
||||
int finish = RichString_size(str) - 1;
|
||||
if (this->basenameOffset != -1)
|
||||
finish = (start + this->basenameOffset) - 1;
|
||||
int colon = RichString_findChar(str, ':', start);
|
||||
if (colon != -1 && colon < finish) {
|
||||
finish = colon;
|
||||
} else {
|
||||
for (int i = finish - start; i >= 0; i--) {
|
||||
if (this->comm[i] == '/') {
|
||||
start += i+1;
|
||||
break;
|
||||
}
|
||||
int start = RichString_size(str), finish = 0;
|
||||
char* comm = this->comm;
|
||||
|
||||
if (this->settings->highlightBaseName || !this->settings->showProgramPath) {
|
||||
int i, basename = 0;
|
||||
for (i = 0; i < this->basenameOffset; i++) {
|
||||
if (comm[i] == '/') {
|
||||
basename = i + 1;
|
||||
} else if (comm[i] == ':') {
|
||||
finish = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
RichString_setAttrn(str, baseattr, start, finish);
|
||||
if (!finish) {
|
||||
if (this->settings->showProgramPath)
|
||||
start += basename;
|
||||
else
|
||||
comm += basename;
|
||||
finish = this->basenameOffset - basename;
|
||||
}
|
||||
finish += start - 1;
|
||||
}
|
||||
|
||||
RichString_append(str, attr, comm);
|
||||
|
||||
if (this->settings->highlightBaseName)
|
||||
RichString_setAttrn(str, baseattr, start, finish);
|
||||
}
|
||||
|
||||
void Process_outputRate(RichString* str, char* buffer, int n, double rate, int coloring) {
|
||||
|
Reference in New Issue
Block a user