aboutsummaryrefslogtreecommitdiffstats
path: root/ListItem.c
blob: 840ca9868145a11811f087380da56ceb862e024c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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);
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy