From ff9409b1737627857eb47f64f536a3f66b6a09a4 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:01:07 +0200 Subject: Imported Upstream version 2.0.0 --- ListItem.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'ListItem.c') diff --git a/ListItem.c b/ListItem.c index 140ebdc..c9e906f 100644 --- a/ListItem.c +++ b/ListItem.c @@ -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 @@ -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); -- cgit v1.2.3