mirror of https://github.com/xzeldon/htop.git
Merge branch 'RichString_attrn' of cgzones/htop
This commit is contained in:
commit
8a67d7f086
4
Meter.c
4
Meter.c
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
12
Process.c
12
Process.c
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
RichString_appendWide(str, attr, comm);
|
||||
|
||||
if (this->settings->highlightBaseName) {
|
||||
RichString_setAttrn(str, baseattr, start, finish);
|
||||
RichString_setAttrn(str, baseattr, start, len);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
22
RichString.c
22
RichString.c
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue