mirror of https://github.com/xzeldon/htop.git
RichString: implement safe rewind
The current rewind logic causes issues when rewinding over the short string optimization boundary.
This commit is contained in:
parent
08ac22ddb9
commit
b9adc30b86
|
@ -113,7 +113,7 @@ void ProcessList_printHeader(const ProcessList* this, RichString* header) {
|
||||||
|
|
||||||
RichString_appendWide(header, color, alignedProcessFieldTitle(fields[i]));
|
RichString_appendWide(header, color, alignedProcessFieldTitle(fields[i]));
|
||||||
if (key == fields[i] && RichString_getCharVal(*header, RichString_size(header) - 1) == ' ') {
|
if (key == fields[i] && RichString_getCharVal(*header, RichString_size(header) - 1) == ' ') {
|
||||||
header->chlen--; // rewind to override space
|
RichString_rewind(header, 1); // rewind to override space
|
||||||
RichString_appendnWide(header,
|
RichString_appendnWide(header,
|
||||||
CRT_colors[PANEL_SELECTION_FOCUS],
|
CRT_colors[PANEL_SELECTION_FOCUS],
|
||||||
CRT_treeStr[Settings_getActiveDirection(this->settings) == 1 ? TREE_STR_DESC : TREE_STR_ASC],
|
CRT_treeStr[Settings_getActiveDirection(this->settings) == 1 ? TREE_STR_DESC : TREE_STR_ASC],
|
||||||
|
|
|
@ -46,6 +46,10 @@ static void RichString_setLen(RichString* this, int len) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RichString_rewind(RichString* this, int count) {
|
||||||
|
RichString_setLen(this, this->chlen - count);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBNCURSESW
|
#ifdef HAVE_LIBNCURSESW
|
||||||
|
|
||||||
static inline int 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) {
|
||||||
|
|
|
@ -42,6 +42,8 @@ typedef struct RichString_ {
|
||||||
int highlightAttr;
|
int highlightAttr;
|
||||||
} RichString;
|
} RichString;
|
||||||
|
|
||||||
|
void RichString_rewind(RichString* this, int count);
|
||||||
|
|
||||||
void RichString_setAttrn(RichString* this, int attrs, int start, int charcount);
|
void RichString_setAttrn(RichString* this, int attrs, int start, int charcount);
|
||||||
|
|
||||||
int RichString_findChar(const RichString* this, char c, int start);
|
int RichString_findChar(const RichString* this, char c, int start);
|
||||||
|
|
Loading…
Reference in New Issue