From 2b889177c21bcf2d9d60016ebdf7b49e8bd4b898 Mon Sep 17 00:00:00 2001 From: Pootle daemon Date: Mon, 30 Jan 2012 05:31:06 +0000 Subject: Merge branch 'master' of git.sugarlabs.org:turtleart/mainline --- diff --git a/NEWS b/NEWS index 72121ee..33c0884 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,23 @@ +133 + +ENHANCEMENTS: +* New translations +* Added strings used by WeDo plugin +* Added True and False blocks to Numbers palette (only for large screens) +* Added is heap empty block? +* Added support for polynomial objects in math libraries + (used by nutrition plugin) + +132 + +BUG FIX: +* Fixed problem with exporting of Logo code introduced in v131 +* Capture "special blocks" in used block list +* Fixed typo in local variables causing voltage sensing to fail with + XO 1.75 (#3297) +* Changed light-sensor power_state (deprecated) to level in python + sample code (OLPC #11485) + 131 ENHANCEMENTS: diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py index 8b949da..5a158b3 100644 --- a/TurtleArt/tabasics.py +++ b/TurtleArt/tabasics.py @@ -653,7 +653,11 @@ operators')) logo_command='greater?', help_string=_('logical greater-than operator')) self.tw.lc.def_prim( - 'greater?', 2, lambda self, x, y: primitive_dictionary['more'](x, y)) + 'greater?', 2, + lambda self, x, y: primitive_dictionary['more'](x, y)) + + if self.tw.canvas.width > 1024: + self._make_constant(palette, 'true', _('True'), 1) primitive_dictionary['less'] = self._prim_less palette.add_block('less2', @@ -666,6 +670,9 @@ operators')) self.tw.lc.def_prim( 'less?', 2, lambda self, x, y: primitive_dictionary['less'](x, y)) + if self.tw.canvas.width > 1024: + self._make_constant(palette, 'false', _('False'), 0) + primitive_dictionary['equal'] = self._prim_equal palette.add_block('equal2', style='compare-style', @@ -1120,6 +1127,14 @@ variable')) def _prim_careful_divide(self, x, y): """ Raise error on divide by zero """ + if type(x) == list and _num_type(y): + z = [] + for i in range(len(x)): + try: + z.append(x[i] / y) + except ZeroDivisionError: + raise logoerror("#zerodivide") + return z try: return x / y except ZeroDivisionError: @@ -1136,6 +1151,11 @@ variable')) def _prim_equal(self, x, y): """ Numeric and logical equal """ + if type(x) == list and type(y) == list: + for i in range(len(x)): + if x[i] != y[i]: + return False + return True try: return float(x) == float(y) except ValueError: @@ -1176,6 +1196,11 @@ variable')) """ Add numbers, concat strings """ if _num_type(x) and _num_type(y): return(x + y) + elif type(x) == list and type(y) == list: + z = [] + for i in range(len(x)): + z.append(x[i] + y[i]) + return(z) else: if _num_type(x): xx = str(round_int(x)) @@ -1191,6 +1216,11 @@ variable')) """ Numerical subtraction """ if _num_type(x) and _num_type(y): return(x - y) + elif type(x) == list and type(y) == list: + z = [] + for i in range(len(x)): + z.append(x[i] - y[i]) + return(z) try: return self._string_to_num(x) - self._string_to_num(y) except TypeError: @@ -1200,6 +1230,16 @@ variable')) """ Numerical multiplication """ if _num_type(x) and _num_type(y): return(x * y) + elif type(x) == list and _num_type(y): + z = [] + for i in range(len(x)): + z.append(x[i] * y) + return(z) + elif type(y) == list and _num_type(x): + z = [] + for i in range(len(y)): + z.append(y[i] * x) + return(z) try: return self._string_to_num(x) * self._string_to_num(y) except TypeError: @@ -1260,6 +1300,8 @@ variable')) return(x) if type(x) is ord: return(int(x)) + if type(x) is list: + raise logoerror("#syntaxerror") xx = convert(x.replace(self.tw.decimal_point, '.'), float) if type(xx) is float: return xx diff --git a/activity/activity.info b/activity/activity.info index 80565d4..d304057 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,6 +1,6 @@ [Activity] name = Turtle Art -activity_version = 131 +activity_version = 133 license = MIT bundle_id = org.laptop.TurtleArtActivity exec = sugar-activity TurtleArtActivity.TurtleArtActivity diff --git a/icons/save-load.svg b/icons/save-load.svg new file mode 100644 index 0000000..afaec6d --- /dev/null +++ b/icons/save-load.svg @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py index 9369d80..0ab049a 100644 --- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py +++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py @@ -435,6 +435,16 @@ last-out heap)')) define_logo_function('tapop', 'to tapop\rif emptyp :taheap [stop]\r\ make "tmp first :taheap\rmake "taheap butfirst :taheap\routput :tmp\rend\r') + primitive_dictionary['isheapempty'] = self._prim_is_heap_empty + palette.add_block('isheapempty', + style='box-style', + label=_('empty heap?'), + prim_name='isheapempty', + value_block=True, + help_string=_('returns True if heap is empty')) + self.tw.lc.def_prim('isheapempty', 0, + lambda self: primitive_dictionary['isheapempty']()) + primitive_dictionary['print'] = self._prim_print palette.add_block('comment', style='basic-style-1arg', @@ -972,6 +982,13 @@ bullets')) self.tw.lc.stop_logo() raise logoerror("#notanumber") + def _prim_is_heap_empty(self): + """ is FILO empty? """ + if len(self.tw.lc.heap) == 0: + return 1 + else: + return 0 + def _prim_pop(self): """ Pop value off of FILO """ if len(self.tw.lc.heap) == 0: -- cgit v0.9.1