Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
offset = 0;
for (uint8_t i = 0; i < this->curItems; i++) {
int attr = this->curAttributes ? this->curAttributes[i] : Meter_attributes(this)[i];
RichString_setAttrn(&bar, CRT_colors[attr], startPos + offset, startPos + offset + blockSizes[i] - 1);
RichString_setAttrn(&bar, CRT_colors[attr], startPos + offset, blockSizes[i]);
RichString_printoffnVal(bar, y, x + offset, startPos + offset, MINIMUM(blockSizes[i], w - offset));
offset += blockSizes[i];
offset = CLAMP(offset, 0, w);
}
if (offset < w) {
RichString_setAttrn(&bar, CRT_colors[BAR_SHADOW], startPos + offset, startPos + w - 1);
RichString_setAttrn(&bar, CRT_colors[BAR_SHADOW], startPos + offset, w - offset);
RichString_printoffnVal(bar, y, x + offset, startPos + offset, w - offset);
}

Expand Down
12 changes: 6 additions & 6 deletions Process.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ void Process_fillStarttimeBuffer(Process* this) {
}

static inline void Process_writeCommand(const Process* this, int attr, int baseattr, RichString* str) {
int start = RichString_size(str), finish = 0;
int start = RichString_size(str);
int len = 0;
const char* comm = this->comm;

if (this->settings->highlightBaseName || !this->settings->showProgramPath) {
Expand All @@ -192,25 +193,24 @@ static inline void Process_writeCommand(const Process* this, int attr, int basea
if (comm[i] == '/') {
basename = i + 1;
} else if (comm[i] == ':') {
finish = i + 1;
len = i + 1;
break;
}
}
if (!finish) {
if (len == 0) {
if (this->settings->showProgramPath) {
start += basename;
} else {
comm += basename;
}
finish = this->basenameOffset - basename;
len = this->basenameOffset - basename;
}
finish += start - 1;
Comment thread
BenBE marked this conversation as resolved.
}

RichString_appendWide(str, attr, comm);

if (this->settings->highlightBaseName) {
RichString_setAttrn(str, baseattr, start, finish);
RichString_setAttrn(str, baseattr, start, len);
}
}

Expand Down
22 changes: 9 additions & 13 deletions RichString.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ static inline int RichString_writeFromAscii(RichString* this, int attrs, const c
return len;
}

inline void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
cchar_t* ch = this->chptr + start;
finish = CLAMP(finish, 0, this->chlen - 1);
for (int i = start; i <= finish; i++) {
ch->attr = attrs;
ch++;
inline void RichString_setAttrn(RichString* this, int attrs, int start, int charcount) {
int end = CLAMP(start + charcount, 0, this->chlen);
for (int i = start; i < end; i++) {
this->chptr[i].attr = attrs;
}
}

Expand Down Expand Up @@ -110,12 +108,10 @@ static inline int RichString_writeFromAscii(RichString* this, int attrs, const c
return RichString_writeFromWide(this, attrs, data_c, from, len);
}

void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
chtype* ch = this->chptr + start;
finish = CLAMP(finish, 0, this->chlen - 1);
for (int i = start; i <= finish; i++) {
*ch = (*ch & 0xff) | attrs;
ch++;
void RichString_setAttrn(RichString* this, int attrs, int start, int charcount) {
int end = CLAMP(start + charcount, 0, this->chlen);
for (int i = start; i < end; i++) {
this->chptr[i] = (this->chptr[i] & 0xff) | attrs;
}
}

Expand Down Expand Up @@ -148,7 +144,7 @@ void RichString_appendChr(RichString* this, char c, int count) {
}

void RichString_setAttr(RichString* this, int attrs) {
RichString_setAttrn(this, attrs, 0, this->chlen - 1);
RichString_setAttrn(this, attrs, 0, this->chlen);
}

int RichString_appendWide(RichString* this, int attrs, const char* data) {
Expand Down
2 changes: 1 addition & 1 deletion RichString.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef struct RichString_ {
int highlightAttr;
} RichString;

void RichString_setAttrn(RichString* this, int attrs, int start, int finish);
void RichString_setAttrn(RichString* this, int attrs, int start, int charcount);

int RichString_findChar(RichString* this, char c, int start);

Expand Down
18 changes: 9 additions & 9 deletions linux/LinuxProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,30 +528,30 @@ static void LinuxProcess_writeCommand(const Process* this, int attr, int baseAtt
if (!lp->mergedCommand.separateComm && commStart == baseStart && highlightBaseName) {
/* If it was matched with procExe's basename, make it bold if needed */
if (commEnd > baseEnd) {
RichString_setAttrn(str, A_BOLD | baseAttr, baseStart, baseEnd - 1);
RichString_setAttrn(str, A_BOLD | commAttr, baseEnd, commEnd - 1);
RichString_setAttrn(str, A_BOLD | baseAttr, baseStart, baseEnd - baseStart);
RichString_setAttrn(str, A_BOLD | commAttr, baseEnd, commEnd - baseEnd);
} else if (commEnd < baseEnd) {
RichString_setAttrn(str, A_BOLD | commAttr, commStart, commEnd - 1);
RichString_setAttrn(str, A_BOLD | baseAttr, commEnd, baseEnd - 1);
RichString_setAttrn(str, A_BOLD | commAttr, commStart, commEnd - commStart);
RichString_setAttrn(str, A_BOLD | baseAttr, commEnd, baseEnd - commEnd);
} else {
// Actually should be highlighted commAttr, but marked baseAttr to reduce visual noise
RichString_setAttrn(str, A_BOLD | baseAttr, commStart, commEnd - 1);
RichString_setAttrn(str, A_BOLD | baseAttr, commStart, commEnd - commStart);
}

baseStart = baseEnd;
} else {
RichString_setAttrn(str, commAttr, commStart, commEnd - 1);
RichString_setAttrn(str, commAttr, commStart, commEnd - commStart);
}
}

if (baseStart < baseEnd && highlightBaseName) {
RichString_setAttrn(str, baseAttr, baseStart, baseEnd - 1);
RichString_setAttrn(str, baseAttr, baseStart, baseEnd - baseStart);
}

if (mc->sep1)
RichString_setAttrn(str, CRT_colors[FAILED_READ], strStart + mc->sep1, strStart + mc->sep1);
RichString_setAttrn(str, CRT_colors[FAILED_READ], strStart + mc->sep1, 1);
if (mc->sep2)
RichString_setAttrn(str, CRT_colors[FAILED_READ], strStart + mc->sep2, strStart + mc->sep2);
RichString_setAttrn(str, CRT_colors[FAILED_READ], strStart + mc->sep2, 1);
}

static void LinuxProcess_writeCommandField(const Process *this, RichString *str, char *buffer, int n, int attr) {
Expand Down