diff options
author | Marion <marion.zepf@gmail.com> | 2013-09-13 15:23:11 (GMT) |
---|---|---|
committer | Marion <marion.zepf@gmail.com> | 2013-09-13 15:23:11 (GMT) |
commit | 891d663f1512746e282982568055543d04bc0384 (patch) | |
tree | 4fcb3d0e12abe8953e2f11e22e6462682453cd78 /plugins | |
parent | ad1e45ec20eeef32bebca6c12e90c39dfb8adeac (diff) |
add Primitive for the 'print heap' block (using tw.print_())
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/turtle_blocks_extras/turtle_blocks_extras.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py index d59a5bb..d0fb8eb 100644 --- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py +++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py @@ -481,7 +481,6 @@ last-out heap)')) define_logo_function('tapush', 'to tapush :foo\nmake "taheap fput \ :foo :taheap\nend\nmake "taheap []\n') - primitive_dictionary['printheap'] = self._prim_printheap palette.add_block('printheap', style='basic-style-extended-vertical', label=_('show heap'), @@ -490,7 +489,9 @@ last-out heap)')) help_string=_('shows values in FILO (first-in \ last-out heap)')) self.tw.lc.def_prim('printheap', 0, - lambda self: primitive_dictionary['printheap']()) + Primitive(self.tw.print_, + arg_descs=[ConstantArg(Primitive(self.tw.lc.get_heap)), + ConstantArg(False)])) define_logo_function('taprintheap', 'to taprintheap \nprint :taheap\n\ end\n') @@ -1145,14 +1146,6 @@ Journal objects')) else: self.tw.lc.update_label_value('pop', self.tw.lc.heap[-1]) - def _prim_printheap(self): - """ Display contents of heap """ - heap_as_string = str(self.tw.lc.heap) - if len(heap_as_string) > 80: - self.tw.showlabel('print', str(self.tw.lc.heap)[0:79] + '…') - else: - self.tw.showlabel('print', str(self.tw.lc.heap)) - def _prim_push(self, val): """ Push value onto FILO """ self.tw.lc.heap.append(val) |