diff options
author | Daniel Lange <DLange@git.local> | 2016-04-11 13:01:07 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:01:07 +0200 |
commit | ff9409b1737627857eb47f64f536a3f66b6a09a4 (patch) | |
tree | 61b631ba551e68a4f656b8b76ff7bd0d9955fc64 /ListItem.c | |
parent | f75ab6d2c11e8a8e18191b087564aedebbeb96c5 (diff) | |
download | debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.gz debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.tar.bz2 debian_htop-ff9409b1737627857eb47f64f536a3f66b6a09a4.zip |
Imported Upstream version 2.0.0upstream/2.0.0
Diffstat (limited to 'ListItem.c')
-rw-r--r-- | ListItem.c | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -8,7 +8,7 @@ in the source distribution for its full text. #include "ListItem.h" #include "CRT.h" -#include "String.h" +#include "StringUtils.h" #include "RichString.h" #include <string.h> @@ -22,6 +22,7 @@ typedef struct ListItem_ { Object super; char* value; int key; + bool moving; } ListItem; }*/ @@ -33,14 +34,23 @@ static void ListItem_delete(Object* cast) { } static void ListItem_display(Object* cast, RichString* out) { - ListItem* this = (ListItem*)cast; + ListItem* const this = (ListItem*)cast; assert (this != NULL); /* int len = strlen(this->value)+1; char buffer[len+1]; snprintf(buffer, len, "%s", this->value); */ - RichString_write(out, CRT_colors[DEFAULT_COLOR], this->value/*buffer*/); + if (this->moving) { + RichString_write(out, CRT_colors[DEFAULT_COLOR], +#ifdef HAVE_LIBNCURSESW + CRT_utf8 ? "↕ " : +#endif + "+ "); + } else { + RichString_prune(out); + } + RichString_append(out, CRT_colors[DEFAULT_COLOR], this->value/*buffer*/); } ObjectClass ListItem_class = { @@ -51,8 +61,9 @@ ObjectClass ListItem_class = { ListItem* ListItem_new(const char* value, int key) { ListItem* this = AllocThis(ListItem); - this->value = strdup(value); + this->value = xStrdup(value); this->key = key; + this->moving = false; return this; } @@ -60,7 +71,7 @@ void ListItem_append(ListItem* this, const char* text) { int oldLen = strlen(this->value); int textLen = strlen(text); int newLen = strlen(this->value) + textLen; - this->value = realloc(this->value, newLen + 1); + this->value = xRealloc(this->value, newLen + 1); memcpy(this->value + oldLen, text, textLen); this->value[newLen] = '\0'; } @@ -69,7 +80,7 @@ const char* ListItem_getRef(ListItem* this) { return this->value; } -int ListItem_compare(const void* cast1, const void* cast2) { +long ListItem_compare(const void* cast1, const void* cast2) { ListItem* obj1 = (ListItem*) cast1; ListItem* obj2 = (ListItem*) cast2; return strcmp(obj1->value, obj2->value); |