aboutsummaryrefslogtreecommitdiffstats
path: root/property.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2006-08-13 11:38:20 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2006-08-13 11:38:20 +0000
commit9e6804e49cac8d859b899ae49509ffdf347eda7f (patch)
treef8a2d2be1201910d04463c9bb4e95cd6ea46ea81 /property.c
parent523bb7ba13a5d88588a270cf8ce2f0c0ac882708 (diff)
downloadlcd4linux-9e6804e49cac8d859b899ae49509ffdf347eda7f.tar.gz
[lcd4linux @ 2006-08-13 11:38:20 by reinelt]
text widget uses dynamic properties git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@691 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'property.c')
-rw-r--r--property.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/property.c b/property.c
index b2302ba..d465275 100644
--- a/property.c
+++ b/property.c
@@ -1,4 +1,4 @@
-/* $Id: property.c,v 1.1 2006/08/13 09:53:10 reinelt Exp $
+/* $Id: property.c,v 1.2 2006/08/13 11:38:20 reinelt Exp $
*
* dynamic properties
*
@@ -23,6 +23,9 @@
*
*
* $Log: property.c,v $
+ * Revision 1.2 2006/08/13 11:38:20 reinelt
+ * text widget uses dynamic properties
+ *
* Revision 1.1 2006/08/13 09:53:10 reinelt
* dynamic properties added (used by 'style' of text widget)
*
@@ -38,6 +41,8 @@
* void property_free (PROPERTY *prop)
* frees all property allocations
*
+ * int property_eval(PROPERTY * prop)
+ * evaluates a property; returns 1 if value has changed
*
* double P2N(PROPERTY * prop)
* returns a (already evaluated) property as number
@@ -84,12 +89,38 @@ void property_load(const char *section, const char *name, const char *defval, PR
}
-void property_eval(PROPERTY * prop)
+int property_eval(PROPERTY * prop)
{
- if (prop->compiled != NULL) {
- DelResult(&prop->result);
- Eval(prop->compiled, &prop->result);
+ RESULT old;
+ int update = 1;
+
+ /* this is a bit ugly: we need to remember the old value */
+
+ old.type = prop->result.type;
+ old.size = prop->result.size;
+ old.number = prop->result.number;
+ old.string = prop->result.string != NULL ? strdup(prop->result.string) : NULL;
+
+ DelResult(&prop->result);
+ Eval(prop->compiled, &prop->result);
+
+ if (prop->result.type & R_NUMBER && old.type & R_NUMBER && prop->result.number == old.number) {
+ update = 0;
}
+
+ if (prop->result.type & R_STRING && old.type & R_STRING && prop->result.size == old.size) {
+ if (prop->result.string == NULL && old.string == NULL) {
+ update = 0;
+ }
+ else if (prop->result.string != NULL && old.string != NULL && strcmp(prop->result.string, old.string) == 0) {
+ update = 0;
+ }
+ }
+
+ if (old.string)
+ free (old.string);
+
+ return update;
}