From d3c9975943df58e293359b87905d19ff1fd52061 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 11 Apr 2016 13:00:15 +0200 Subject: Imported Upstream version 0.5 --- ListItem.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 ListItem.c (limited to 'ListItem.c') diff --git a/ListItem.c b/ListItem.c new file mode 100644 index 0000000..840ca98 --- /dev/null +++ b/ListItem.c @@ -0,0 +1,48 @@ +/* +htop +(C) 2004 Hisham H. Muhammad +Released under the GNU GPL, see the COPYING file +in the source distribution for its full text. +*/ + +#include "ListItem.h" +#include "Object.h" +#include "CRT.h" + +#include "debug.h" + +/*{ + +typedef struct ListItem_ { + Object super; + char* text; +} ListItem; + +extern char* LISTITEM_CLASS; +}*/ + +/* private property */ +char* LISTITEM_CLASS = "ListItem"; + +ListItem* ListItem_new(char* text) { + ListItem* this = malloc(sizeof(ListItem)); + ((Object*)this)->class = LISTITEM_CLASS; + ((Object*)this)->display = ListItem_display; + ((Object*)this)->delete = ListItem_delete; + this->text = text; + return this; +} + +void ListItem_delete(Object* cast) { + ListItem* this = (ListItem*)cast; + assert (this != NULL); + + free(this->text); + free(this); +} + +void ListItem_display(Object* cast, RichString* out) { + ListItem* this = (ListItem*)cast; + assert (this != NULL); + RichString_write(out, CRT_colors[DEFAULT_COLOR], this->text); +} -- cgit v1.2.3