From 5b88ca833baddc54b2b5f79245d20acadbbfa07f Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sat, 31 Dec 2011 21:35:13 +0000 Subject: internalized macro expansion of while and until blocks --- (limited to 'plugins/turtle_blocks_extras/turtle_blocks_extras.py') diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py index d512f54..9369d80 100644 --- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py +++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py @@ -93,30 +93,23 @@ class Turtle_blocks_extras(Plugin): colors=["#FFC000", "#A08000"], help_string=_('Palette of flow operators')) - ''' - primitive_dictionary['while'] = self._prim_while + # internally expanded macro palette.add_block('while', style='flow-style-boolean', label=[_('while'), ' ', ' '], prim_name='while', - default=[None, None, 'vspace'], + default=[None, None, None], special_name=_('while'), help_string=_('do-while-True operator that uses \ boolean operators from Numbers palette')) - self.tw.lc.def_prim('while', 2, primitive_dictionary['while'], True) - ''' - # macro - palette.add_block('while', - style='flow-style-boolean', - label=_('while'), - help_string=_('do-while-True operator that uses \ -boolean operators from Numbers palette')) - - # macro - palette.add_block('until', + # internally expanded macro + palette.add_block('until', style='flow-style-boolean', - label=_('until'), + label=[_('until'), ' ', ' '], + prim_name='until', + default=[None, None, None], + special_name=_('until'), help_string=_('do-until-True operator that uses \ boolean operators from Numbers palette')) @@ -1278,21 +1271,6 @@ bullets')) self.tw.lc.update_label_value('time', elapsed_time) return elapsed_time - ''' - def _prim_while(self, boolean, blklist): """ Repeat while true: - won't work as coded as boolean is only calculated once. """ - - while(True): - if not boolean: - break - self.tw.lc.icall(self.tw.lc.evline, blklist[:]) - yield True - if self.tw.lc.procstop: - break - self.tw.lc.ireturn() - yield True - ''' - # Deprecated blocks def _prim_t1x1(self, title, media): -- cgit v0.9.1