mirror of https://github.com/xzeldon/htop.git
Merge branch 'user_wide' of cgzones/htop
This commit is contained in:
commit
1cc3f8074f
13
Process.c
13
Process.c
|
@ -363,15 +363,14 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
|||
case USER: {
|
||||
if (Process_getuid != this->st_uid)
|
||||
attr = CRT_colors[PROCESS_SHADOW];
|
||||
|
||||
if (this->user) {
|
||||
xSnprintf(buffer, n, "%-9s ", this->user);
|
||||
} else {
|
||||
xSnprintf(buffer, n, "%-9d ", this->st_uid);
|
||||
}
|
||||
if (buffer[9] != '\0') {
|
||||
buffer[9] = ' ';
|
||||
buffer[10] = '\0';
|
||||
int c = RichString_appendnWide(str, attr, this->user, MINIMUM(9, strlen(this->user)));
|
||||
RichString_appendChr(str, ' ', 10 - c);
|
||||
return;
|
||||
}
|
||||
|
||||
xSnprintf(buffer, n, "%-9d ", this->st_uid);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
44
RichString.c
44
RichString.c
|
@ -48,25 +48,29 @@ static void RichString_setLen(RichString* this, int len) {
|
|||
|
||||
#ifdef HAVE_LIBNCURSESW
|
||||
|
||||
static inline void RichString_writeFromWide(RichString* this, int attrs, const char* data_c, int from, int len) {
|
||||
static inline int RichString_writeFromWide(RichString* this, int attrs, const char* data_c, int from, int len) {
|
||||
wchar_t data[len + 1];
|
||||
len = mbstowcs(data, data_c, len);
|
||||
if (len < 0)
|
||||
return;
|
||||
if (len <= 0)
|
||||
return 0;
|
||||
|
||||
int newLen = from + len;
|
||||
RichString_setLen(this, newLen);
|
||||
for (int i = from, j = 0; i < newLen; i++, j++) {
|
||||
this->chptr[i] = (CharType) { .attr = attrs & 0xffffff, .chars = { (iswprint(data[j]) ? data[j] : '?') } };
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static inline void RichString_writeFromAscii(RichString* this, int attrs, const char* data, int from, int len) {
|
||||
static inline int RichString_writeFromAscii(RichString* this, int attrs, const char* data, int from, int len) {
|
||||
int newLen = from + len;
|
||||
RichString_setLen(this, newLen);
|
||||
for (int i = from, j = 0; i < newLen; i++, j++) {
|
||||
this->chptr[i] = (CharType) { .attr = attrs & 0xffffff, .chars = { (isprint(data[j]) ? data[j] : '?') } };
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
inline void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
|
||||
|
@ -91,17 +95,19 @@ int RichString_findChar(RichString* this, char c, int start) {
|
|||
|
||||
#else /* HAVE_LIBNCURSESW */
|
||||
|
||||
static inline void RichString_writeFromWide(RichString* this, int attrs, const char* data_c, int from, int len) {
|
||||
static inline int RichString_writeFromWide(RichString* this, int attrs, const char* data_c, int from, int len) {
|
||||
int newLen = from + len;
|
||||
RichString_setLen(this, newLen);
|
||||
for (int i = from, j = 0; i < newLen; i++, j++) {
|
||||
this->chptr[i] = (((unsigned char)data_c[j]) >= 32 ? ((unsigned char)data_c[j]) : '?') | attrs;
|
||||
}
|
||||
this->chptr[newLen] = 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static inline void RichString_writeFromAscii(RichString* this, int attrs, const char* data_c, int from, int len) {
|
||||
RichString_writeFromWide(this, attrs, data_c, from, len);
|
||||
static inline int RichString_writeFromAscii(RichString* this, int attrs, const char* data_c, int from, int len) {
|
||||
return RichString_writeFromWide(this, attrs, data_c, from, len);
|
||||
}
|
||||
|
||||
void RichString_setAttrn(RichString* this, int attrs, int start, int finish) {
|
||||
|
@ -145,26 +151,26 @@ void RichString_setAttr(RichString* this, int attrs) {
|
|||
RichString_setAttrn(this, attrs, 0, this->chlen - 1);
|
||||
}
|
||||
|
||||
void RichString_appendWide(RichString* this, int attrs, const char* data) {
|
||||
RichString_writeFromWide(this, attrs, data, this->chlen, strlen(data));
|
||||
int RichString_appendWide(RichString* this, int attrs, const char* data) {
|
||||
return RichString_writeFromWide(this, attrs, data, this->chlen, strlen(data));
|
||||
}
|
||||
|
||||
void RichString_appendnWide(RichString* this, int attrs, const char* data, int len) {
|
||||
RichString_writeFromWide(this, attrs, data, this->chlen, len);
|
||||
int RichString_appendnWide(RichString* this, int attrs, const char* data, int len) {
|
||||
return RichString_writeFromWide(this, attrs, data, this->chlen, len);
|
||||
}
|
||||
|
||||
void RichString_writeWide(RichString* this, int attrs, const char* data) {
|
||||
RichString_writeFromWide(this, attrs, data, 0, strlen(data));
|
||||
int RichString_writeWide(RichString* this, int attrs, const char* data) {
|
||||
return RichString_writeFromWide(this, attrs, data, 0, strlen(data));
|
||||
}
|
||||
|
||||
void RichString_appendAscii(RichString* this, int attrs, const char* data) {
|
||||
RichString_writeFromAscii(this, attrs, data, this->chlen, strlen(data));
|
||||
int RichString_appendAscii(RichString* this, int attrs, const char* data) {
|
||||
return RichString_writeFromAscii(this, attrs, data, this->chlen, strlen(data));
|
||||
}
|
||||
|
||||
void RichString_appendnAscii(RichString* this, int attrs, const char* data, int len) {
|
||||
RichString_writeFromAscii(this, attrs, data, this->chlen, len);
|
||||
int RichString_appendnAscii(RichString* this, int attrs, const char* data, int len) {
|
||||
return RichString_writeFromAscii(this, attrs, data, this->chlen, len);
|
||||
}
|
||||
|
||||
void RichString_writeAscii(RichString* this, int attrs, const char* data) {
|
||||
RichString_writeFromAscii(this, attrs, data, 0, strlen(data));
|
||||
int RichString_writeAscii(RichString* this, int attrs, const char* data) {
|
||||
return RichString_writeFromAscii(this, attrs, data, 0, strlen(data));
|
||||
}
|
||||
|
|
12
RichString.h
12
RichString.h
|
@ -52,16 +52,16 @@ void RichString_setAttr(RichString* this, int attrs);
|
|||
|
||||
void RichString_appendChr(RichString* this, char c, int count);
|
||||
|
||||
void RichString_appendWide(RichString* this, int attrs, const char* data);
|
||||
int RichString_appendWide(RichString* this, int attrs, const char* data);
|
||||
|
||||
void RichString_appendnWide(RichString* this, int attrs, const char* data, int len);
|
||||
int RichString_appendnWide(RichString* this, int attrs, const char* data, int len);
|
||||
|
||||
void RichString_writeWide(RichString* this, int attrs, const char* data);
|
||||
int RichString_writeWide(RichString* this, int attrs, const char* data);
|
||||
|
||||
void RichString_appendAscii(RichString* this, int attrs, const char* data);
|
||||
int RichString_appendAscii(RichString* this, int attrs, const char* data);
|
||||
|
||||
void RichString_appendnAscii(RichString* this, int attrs, const char* data, int len);
|
||||
int RichString_appendnAscii(RichString* this, int attrs, const char* data, int len);
|
||||
|
||||
void RichString_writeAscii(RichString* this, int attrs, const char* data);
|
||||
int RichString_writeAscii(RichString* this, int attrs, const char* data);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue