Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMarion <marion.zepf@gmail.com>2013-09-12 16:48:40 (GMT)
committer Marion <marion.zepf@gmail.com>2013-09-12 16:48:40 (GMT)
commit63a284bbc73bc9131b3ae23433025e0e470d803d (patch)
treec8dff0a7f97841c21ed5ecb1b31f4e61e8a658ae /plugins
parent4c4e63bc7928d239a8881990fdae1a2eca4757e2 (diff)
update labels of value blocks after running 'push', 'pop', or 'clear heap'
Diffstat (limited to 'plugins')
-rw-r--r--plugins/turtle_blocks_extras/turtle_blocks_extras.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
index d986b85..c909803 100644
--- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py
+++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
@@ -476,7 +476,8 @@ program started'))
last-out heap)'))
self.tw.lc.def_prim('push', 1,
Primitive(self.tw.lc.heap.append,
- arg_descs=[ArgSlot(TYPE_OBJECT)]))
+ arg_descs=[ArgSlot(TYPE_OBJECT)],
+ call_afterwards=self.after_push))
define_logo_function('tapush', 'to tapush :foo\nmake "taheap fput \
:foo :taheap\nend\nmake "taheap []\n')
@@ -501,7 +502,8 @@ end\n')
logo_command='taclearheap',
help_string=_('emptys FILO (first-in-last-out \
heap)'))
- self.tw.lc.def_prim('clearheap', 0, Primitive(self.tw.lc.reset_heap))
+ self.tw.lc.def_prim('clearheap', 0,
+ Primitive(self.tw.lc.reset_heap, call_afterwards=self.after_pop))
define_logo_function('taclearheap', 'to taclearheap\nmake "taheap []\n\
end\n')
@@ -516,7 +518,8 @@ end\n')
help_string=_('pops value off FILO (first-in \
last-out heap)'))
self.tw.lc.def_prim('pop', 0,
- Primitive(self.tw.lc.heap.pop, return_type=TYPE_BOX))
+ Primitive(self.tw.lc.heap.pop, return_type=TYPE_BOX,
+ call_afterwards=self.after_pop))
define_logo_function('tapop', 'to tapop\nif emptyp :taheap [stop]\n\
make "tmp first :taheap\nmake "taheap butfirst :taheap\noutput :tmp\nend\n')
@@ -1136,6 +1139,13 @@ Journal objects'))
self.tw.lc.update_label_value('pop', self.tw.lc.heap[-2])
return self.tw.lc.heap.pop(-1)
+ def after_pop(self):
+ if self.tw.lc.update_values:
+ if not self.tw.lc.heap:
+ self.tw.lc.update_label_value('pop')
+ else:
+ self.tw.lc.update_label_value('pop', self.tw.lc.heap[-1])
+
def _prim_print(self, n, flag):
""" Print object n """
if flag and (self.tw.hide or self.tw.step_time == 0):
@@ -1192,6 +1202,10 @@ Journal objects'))
if self.tw.lc.update_values:
self.tw.lc.update_label_value('pop', val)
+ def after_push(self, val):
+ if self.tw.lc.update_values:
+ self.tw.lc.update_label_value('pop', val)
+
def _prim_readpixel(self):
""" Read r, g, b, a from the canvas and push b, g, r to the stack """
r, g, b, a = self.tw.turtles.get_active_turtle().get_pixel()