diff options
author | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:22 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:22 +0200 |
commit | 9379132a8234eeedf62d37ef57713e52c12db6ab (patch) | |
tree | 3c1e0d924af0d44be9b14cab8ea1c05a946cdfe3 /CheckItem.c | |
parent | 9675cf654d86464344e56705db7a71ea17f76c6f (diff) | |
download | debian_htop-9379132a8234eeedf62d37ef57713e52c12db6ab.tar.gz debian_htop-9379132a8234eeedf62d37ef57713e52c12db6ab.tar.bz2 debian_htop-9379132a8234eeedf62d37ef57713e52c12db6ab.zip |
Imported Upstream version 0.7upstream/0.7
Diffstat (limited to 'CheckItem.c')
-rw-r--r-- | CheckItem.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/CheckItem.c b/CheckItem.c index 8326123..45c0b22 100644 --- a/CheckItem.c +++ b/CheckItem.c @@ -16,7 +16,8 @@ in the source distribution for its full text. typedef struct CheckItem_ { Object super; char* text; - bool* value; + bool value; + bool* ref; } CheckItem; }*/ @@ -27,13 +28,14 @@ char* CHECKITEM_CLASS = "CheckItem"; #define CHECKITEM_CLASS NULL #endif -CheckItem* CheckItem_new(char* text, bool* value) { +CheckItem* CheckItem_new(char* text, bool* ref, bool value) { CheckItem* this = malloc(sizeof(CheckItem)); Object_setClass(this, CHECKITEM_CLASS); ((Object*)this)->display = CheckItem_display; ((Object*)this)->delete = CheckItem_delete; this->text = text; this->value = value; + this->ref = ref; return this; } @@ -45,11 +47,25 @@ void CheckItem_delete(Object* cast) { free(this); } +void CheckItem_set(CheckItem* this, bool value) { + if (this->ref) + *(this->ref) = value; + else + this->value = value; +} + +bool CheckItem_get(CheckItem* this) { + if (this->ref) + return *(this->ref); + else + return this->value; +} + void CheckItem_display(Object* cast, RichString* out) { CheckItem* this = (CheckItem*)cast; assert (this != NULL); RichString_write(out, CRT_colors[CHECK_BOX], "["); - if (*(this->value)) + if (CheckItem_get(this)) RichString_append(out, CRT_colors[CHECK_MARK], "x"); else RichString_append(out, CRT_colors[CHECK_MARK], " "); |