From 7a31a05415933b54818e1e789985c199b0ff9c15 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Mon, 15 Feb 2010 15:39:16 +0000 Subject: while and until macros --- diff --git a/taconstants.py b/taconstants.py index 766059c..0811fd0 100644 --- a/taconstants.py +++ b/taconstants.py @@ -118,8 +118,8 @@ PALETTES = [['clean', 'forward', 'back', 'show', 'left', 'right', ['plus2', 'minus2', 'product2', 'division2', 'identity2', 'remainder2', 'sqrt', 'random', 'number', 'greater2', 'less2', 'equal2', 'not', 'and2', 'or2'], - ['wait', 'forever', 'while', 'repeat', 'if', 'ifelse', 'hspace', - 'vspace', 'stopstack'], + ['wait', 'forever', 'repeat', 'if', 'ifelse', 'while', 'until', + 'hspace', 'vspace', 'stopstack'], ['hat1', 'stack1', 'hat', 'hat2', 'stack2', 'stack', 'storeinbox1', 'storeinbox2', 'string', 'box1', 'box2', 'box', 'storein', 'start'], @@ -162,7 +162,7 @@ BASIC_STYLE_HEAD_1ARG = ['hat'] BASIC_STYLE_TAIL = ['stopstack', 'empty'] BASIC_STYLE = ['clean', 'penup', 'pendown', 'stack1', 'stack2', 'vspace', 'hideblocks', 'showblocks', 'clearheap', 'printheap', 'kbinput', - 'fullscreen', 'sandwichcollapsed'] + 'fullscreen', 'sandwichcollapsed', 'while', 'until'] BASIC_STYLE_EXTENDED = ['picturelist', 'picture1x1', 'picture2x2', 'picture2x1', 'picture1x2', 'picture1x1a'] BASIC_STYLE_1ARG = ['forward', 'back', 'left', 'right', 'seth', 'show', @@ -188,7 +188,7 @@ NOT_STYLE = ['not'] FLOW_STYLE = ['forever'] FLOW_STYLE_TAIL = ['hspace'] FLOW_STYLE_1ARG = ['repeat'] -FLOW_STYLE_BOOLEAN = ['if', 'while', 'until'] +FLOW_STYLE_BOOLEAN = ['if'] FLOW_STYLE_ELSE = ['ifelse'] COLLAPSIBLE_TOP = ['sandwichtop'] COLLAPSIBLE_BOTTOM = ['sandwichbottom'] @@ -200,181 +200,6 @@ PORTFOLIO_STYLE_1x1 = ['template1x1', 'template1x1a'] PORTFOLIO_STYLE_2x1 = ['template2x1'] PORTFOLIO_STYLE_1x2 = ['template1x2'] - -# -# Macros (groups of blocks) -# -MACROS = { - 'until': - [[0, 'forever', 0, 0, [None, 1, None]], - [1, 'if', 0, 0, [0, None, 2, 3]], - [2, 'stopstack', 0, 0, [1, None]], - [3, 'vspace', 0, 0, [1, None]]], - 'while': - [[0, 'forever', 0, 0, [None, 2, 1]], - [1, 'vspace', 0, 0, [0, None]], - [2, 'if', 0, 0, [0, None, None, 3]], - [3, 'vspace', 0, 0, [2, 4]], - [4, 'stopstack', 0, 0, [3, None]]], - 'kbinput': - [[0, 'forever', 0, 0, [None, 1, None]], - [1, 'kbinput', 0, 0, [0, 2]], - [2, 'vspace', 0, 0, [1, 3]], - [3, 'if', 0, 0, [2, 4, 7, 8]], - [4, 'greater2', 0, 0, [3, 5, 6, None]], - [5, 'keyboard', 0, 0, [4, None]], - [6, ['number', '0'], 0, 0, [4, None]], - [7, 'stopstack', 0, 0, [3, None]], - [8, 'vspace', 0, 0, [3, 9]], - [9, 'wait', 0, 0, [8, 10, None]], - [10, ['number', '1'], 0, 0, [9, None]]], - 'picturelist': - [[0, 'sandwichtop', 0, 0, [None, 1, 2]], - [1, ['string', _('bulleted list')], 0, 0, [0, None]], - [2, 'setxy', 0, 0, [0, 3, 4, 5]], - [3, 'titlex', 0, 0, [2, None]], - [4, 'titley', 0, 0, [2, None]], - [5, 'show', 0, 0, [2, 6, 7]], - [6, ['string',_('Title')], 0, 0, [5, None]], - [7, 'setxy', 0, 0, [5, 8, 9, 10]], - [8, 'leftx', 0, 0, [7, None]], - [9, 'topy', 0, 0, [7, None]], - [10, 'list', 0, 0, [7, 11, 12, 13]], - [11, ['string','∙ '], 0, 0, [10, None]], - [12, ['string','∙ '], 0, 0, [10, None]], - [13, 'sandwichbottom', 0, 0, [10, None]]], - 'picture1x1a': - [[0, 'sandwichtop', 0, 0, [None, 1, 2]], - [1, ['string', _('picture')], 0, 0, [0, None]], - [2, 'setxy', 0, 0, [0, 3, 4, 5]], - [3, 'titlex', 0, 0, [2, None]], - [4, 'titley', 0, 0, [2, None]], - [5, 'show', 0, 0, [2, 6, 7]], - [6, ['string',_('Title')], 0, 0, [5, None]], - [7, 'setscale', 0, 0, [5, 8, 9]], - [8, ['number', '90'], 0, 0, [7, None]], - [9, 'setxy', 0, 0, [7, 10, 11, 12]], - [10, 'leftx', 0, 0, [9, None]], - [11, 'topy', 0, 0, [9, None]], - [12, 'showaligned', 0, 0, [9, 13, 14]], - [13, 'journal', 0, 0, [12, None]], - [14, 'sandwichbottom', 0, 0, [12, None]]], - 'picture2x2': - [[0, 'sandwichtop', 0, 0, [None, 1, 2]], - [1, ['string', _('2×2 pictures')], 0, 0, [0, None]], - [2, 'setxy', 0, 0, [0, 3, 4, 5]], - [3, 'titlex', 0, 0, [2, None]], - [4, 'titley', 0, 0, [2, None]], - [5, 'show', 0, 0, [2, 6, 7]], - [6, ['string',_('Title')], 0, 0, [5, None]], - [7, 'setscale', 0, 0, [5, 8, 9]], - [8, ['number', '45'], 0, 0, [7, None]], - [9, 'setxy', 0, 0, [7, 10, 11, 12]], - [10, 'leftx', 0, 0, [9, None]], - [11, 'topy', 0, 0, [9, None]], - [12, 'showaligned', 0, 0, [9, 13, 14]], - [13, 'journal', 0, 0, [12, None]], - [14, 'setxy', 0, 0, [12, 15, 16, 17]], - [15, 'rightx', 0, 0, [14, None]], - [16, 'topy', 0, 0, [14, None]], - [17, 'showaligned', 0, 0, [14, 18, 19]], - [18, 'journal', 0, 0, [17, None]], - [19, 'setxy', 0, 0, [17, 20, 21, 22]], - [20, 'leftx', 0, 0, [19, None]], - [21, 'bottomy', 0, 0, [19, None]], - [22, 'showaligned', 0, 0, [19, 23, 24]], - [23, 'journal', 0, 0, [22, None]], - [24, 'setxy', 0, 0, [22, 25, 26, 27]], - [25, 'rightx', 0, 0, [24, None]], - [26, 'bottomy', 0, 0, [24, None]], - [27, 'showaligned', 0, 0, [24, 28, 29]], - [28, 'journal', 0, 0, [27, None]], - [29, 'sandwichbottom', 0, 0, [27, None]]], - 'picture2x1': - [[0, 'sandwichtop', 0, 0, [None, 1, 2]], - [1, ['string', _('2×1 pictures')], 0, 0, [0, None]], - [2, 'setxy', 0, 0, [0, 3, 4, 5]], - [3, 'titlex', 0, 0, [2, None]], - [4, 'titley', 0, 0, [2, None]], - [5, 'show', 0, 0, [2, 6, 7]], - [6, ['string',_('Title')], 0, 0, [5, None]], - [7, 'setscale', 0, 0, [5, 8, 9]], - [8, ['number', '45'], 0, 0, [7, None]], - [9, 'setxy', 0, 0, [7, 10, 11, 12]], - [10, 'leftx', 0, 0, [9, None]], - [11, 'topy', 0, 0, [9, None]], - [12, 'showaligned', 0, 0, [9, 13, 14]], - [13, 'journal', 0, 0, [12, None]], - [14, 'setxy', 0, 0, [12, 15, 16, 17]], - [15, 'rightx', 0, 0, [14, None]], - [16, 'topy', 0, 0, [14, None]], - [17, 'showaligned', 0, 0, [14, 18, 19]], - [18, 'journal', 0, 0, [17, None]], - [19, 'setxy', 0, 0, [17, 20, 21, 22]], - [20, 'leftx', 0, 0, [19, None]], - [21, 'bottomy', 0, 0, [19, None]], - [22, 'showaligned', 0, 0, [19, 23, 24]], - [23, 'description', 0, 0, [22, None]], - [24, 'setxy', 0, 0, [22, 25, 26, 27]], - [25, 'rightx', 0, 0, [24, None]], - [26, 'bottomy', 0, 0, [24, None]], - [27, 'showaligned', 0, 0, [24, 28, 29]], - [28, 'description', 0, 0, [27, None]], - [29, 'sandwichbottom', 0, 0, [27, None]]], - 'picture1x2': - [[0, 'sandwichtop', 0, 0, [None, 1, 2]], - [1, ['string', _('1×2 pictures')], 0, 0, [0, None]], - [2, 'setxy', 0, 0, [0, 3, 4, 5]], - [3, 'titlex', 0, 0, [2, None]], - [4, 'titley', 0, 0, [2, None]], - [5, 'show', 0, 0, [2, 6, 7]], - [6, ['string',_('Title')], 0, 0, [5, None]], - [7, 'setscale', 0, 0, [5, 8, 9]], - [8, ['number', '45'], 0, 0, [7, None]], - [9, 'setxy', 0, 0, [7, 10, 11, 12]], - [10, 'leftx', 0, 0, [9, None]], - [11, 'topy', 0, 0, [9, None]], - [12, 'showaligned', 0, 0, [9, 13, 14]], - [13, 'journal', 0, 0, [12, None]], - [14, 'setxy', 0, 0, [12, 15, 16, 17]], - [15, 'rightx', 0, 0, [14, None]], - [16, 'topy', 0, 0, [14, None]], - [17, 'showaligned', 0, 0, [14, 18, 19]], - [18, 'description', 0, 0, [17, None]], - [19, 'setxy', 0, 0, [17, 20, 21, 22]], - [20, 'leftx', 0, 0, [19, None]], - [21, 'bottomy', 0, 0, [19, None]], - [22, 'showaligned', 0, 0, [19, 23, 24]], - [23, 'journal', 0, 0, [22, None]], - [24, 'setxy', 0, 0, [22, 25, 26, 27]], - [25, 'rightx', 0, 0, [24, None]], - [26, 'bottomy', 0, 0, [24, None]], - [27, 'showaligned', 0, 0, [24, 28, 29]], - [28, 'description', 0, 0, [27, None]], - [29, 'sandwichbottom', 0, 0, [27, None]]], - 'picture1x1': - [[0, 'sandwichtop', 0, 0, [None, 1, 2]], - [1, ['string', _('1×1 picture')], 0, 0, [0, None]], - [2, 'setxy', 0, 0, [0, 3, 4, 5]], - [3, 'titlex', 0, 0, [2, None]], - [4, 'titley', 0, 0, [2, None]], - [5, 'show', 0, 0, [2, 6, 7]], - [6, ['string',_('Title')], 0, 0, [5, None]], - [7, 'setscale', 0, 0, [5, 8, 9]], - [8, ['number', '45'], 0, 0, [7, None]], - [9, 'setxy', 0, 0, [7, 10, 11, 12]], - [10, 'leftx', 0, 0, [9, None]], - [11, 'topy', 0, 0, [9, None]], - [12, 'showaligned', 0, 0, [9, 13, 14]], - [13, 'journal', 0, 0, [12, None]], - [14, 'setxy', 0, 0, [12, 15, 16, 17]], - [15, 'rightx', 0, 0, [14, None]], - [16, 'topy', 0, 0, [14, None]], - [17, 'showaligned', 0, 0, [14, 18, 19]], - [18, 'description', 0, 0, [17, None]], - [19, 'sandwichbottom', 0, 0, [17, None]]] - } - # # Blocks that are expandable # @@ -519,10 +344,10 @@ BLOCK_NAMES = { 'toppos':[_('top')], 'topy':[_('picture top')], 'turtle':[_('turtle')], - 'until':[' ', _('until')], + 'until':[_('until')], 'vspace':[' '], 'wait':[_('wait')], - 'while':[' ', _('while')], + 'while':[_('while')], 'width':[_('width')], 'xcor':[_('xcor')], 'ycor':[_('ycor')], @@ -633,9 +458,7 @@ PRIMITIVES = { 'titley':'titley', 'toppos':'tpos', 'topy':'topy', - 'until':'until', 'vspace':'nop', - 'while':'while', 'wait':'wait', 'width':'hres', 'write':'write', @@ -929,3 +752,180 @@ NOISE_KEYS = ['Shift_L', 'Shift_R', 'Control_L', 'Caps_Lock', 'Pause', WHITE_SPACE = ['space','Tab'] CURSOR = '█' + + +# +# Macros (groups of blocks) +# +MACROS = { + 'until': + [[0, 'forever', 0, 0, [None, 2, 1]], + [1, 'vspace', 0, 0, [0, None]], + [2, 'ifelse', 0, 0, [0, None, 3, None, None]], + [3, 'vspace', 0, 0, [2, 4]], + [4, 'stopstack', 0, 0, [3, None]]], + 'while': + [[0, 'forever', 0, 0, [None, 2, 1]], + [1, 'vspace', 0, 0, [0, None]], + [2, 'ifelse', 0, 0, [0, None, 3, 4, None]], + [3, 'vspace', 0, 0, [2, None]], + [4, 'stopstack', 0, 0, [2, None]]], + 'kbinput': + [[0, 'forever', 0, 0, [None, 1, None]], + [1, 'kbinput', 0, 0, [0, 2]], + [2, 'vspace', 0, 0, [1, 3]], + [3, 'if', 0, 0, [2, 4, 7, 8]], + [4, 'greater2', 0, 0, [3, 5, 6, None]], + [5, 'keyboard', 0, 0, [4, None]], + [6, ['number', '0'], 0, 0, [4, None]], + [7, 'stopstack', 0, 0, [3, None]], + [8, 'vspace', 0, 0, [3, 9]], + [9, 'wait', 0, 0, [8, 10, None]], + [10, ['number', '1'], 0, 0, [9, None]]], + 'picturelist': + [[0, 'sandwichtop', 0, 0, [None, 1, 2]], + [1, ['string', _('bulleted list')], 0, 0, [0, None]], + [2, 'setxy', 0, 0, [0, 3, 4, 5]], + [3, 'titlex', 0, 0, [2, None]], + [4, 'titley', 0, 0, [2, None]], + [5, 'show', 0, 0, [2, 6, 7]], + [6, ['string',_('Title')], 0, 0, [5, None]], + [7, 'setxy', 0, 0, [5, 8, 9, 10]], + [8, 'leftx', 0, 0, [7, None]], + [9, 'topy', 0, 0, [7, None]], + [10, 'list', 0, 0, [7, 11, 12, 13]], + [11, ['string','∙ '], 0, 0, [10, None]], + [12, ['string','∙ '], 0, 0, [10, None]], + [13, 'sandwichbottom', 0, 0, [10, None]]], + 'picture1x1a': + [[0, 'sandwichtop', 0, 0, [None, 1, 2]], + [1, ['string', _('picture')], 0, 0, [0, None]], + [2, 'setxy', 0, 0, [0, 3, 4, 5]], + [3, 'titlex', 0, 0, [2, None]], + [4, 'titley', 0, 0, [2, None]], + [5, 'show', 0, 0, [2, 6, 7]], + [6, ['string',_('Title')], 0, 0, [5, None]], + [7, 'setscale', 0, 0, [5, 8, 9]], + [8, ['number', '90'], 0, 0, [7, None]], + [9, 'setxy', 0, 0, [7, 10, 11, 12]], + [10, 'leftx', 0, 0, [9, None]], + [11, 'topy', 0, 0, [9, None]], + [12, 'showaligned', 0, 0, [9, 13, 14]], + [13, 'journal', 0, 0, [12, None]], + [14, 'sandwichbottom', 0, 0, [12, None]]], + 'picture2x2': + [[0, 'sandwichtop', 0, 0, [None, 1, 2]], + [1, ['string', _('2×2 pictures')], 0, 0, [0, None]], + [2, 'setxy', 0, 0, [0, 3, 4, 5]], + [3, 'titlex', 0, 0, [2, None]], + [4, 'titley', 0, 0, [2, None]], + [5, 'show', 0, 0, [2, 6, 7]], + [6, ['string',_('Title')], 0, 0, [5, None]], + [7, 'setscale', 0, 0, [5, 8, 9]], + [8, ['number', '45'], 0, 0, [7, None]], + [9, 'setxy', 0, 0, [7, 10, 11, 12]], + [10, 'leftx', 0, 0, [9, None]], + [11, 'topy', 0, 0, [9, None]], + [12, 'showaligned', 0, 0, [9, 13, 14]], + [13, 'journal', 0, 0, [12, None]], + [14, 'setxy', 0, 0, [12, 15, 16, 17]], + [15, 'rightx', 0, 0, [14, None]], + [16, 'topy', 0, 0, [14, None]], + [17, 'showaligned', 0, 0, [14, 18, 19]], + [18, 'journal', 0, 0, [17, None]], + [19, 'setxy', 0, 0, [17, 20, 21, 22]], + [20, 'leftx', 0, 0, [19, None]], + [21, 'bottomy', 0, 0, [19, None]], + [22, 'showaligned', 0, 0, [19, 23, 24]], + [23, 'journal', 0, 0, [22, None]], + [24, 'setxy', 0, 0, [22, 25, 26, 27]], + [25, 'rightx', 0, 0, [24, None]], + [26, 'bottomy', 0, 0, [24, None]], + [27, 'showaligned', 0, 0, [24, 28, 29]], + [28, 'journal', 0, 0, [27, None]], + [29, 'sandwichbottom', 0, 0, [27, None]]], + 'picture2x1': + [[0, 'sandwichtop', 0, 0, [None, 1, 2]], + [1, ['string', _('2×1 pictures')], 0, 0, [0, None]], + [2, 'setxy', 0, 0, [0, 3, 4, 5]], + [3, 'titlex', 0, 0, [2, None]], + [4, 'titley', 0, 0, [2, None]], + [5, 'show', 0, 0, [2, 6, 7]], + [6, ['string',_('Title')], 0, 0, [5, None]], + [7, 'setscale', 0, 0, [5, 8, 9]], + [8, ['number', '45'], 0, 0, [7, None]], + [9, 'setxy', 0, 0, [7, 10, 11, 12]], + [10, 'leftx', 0, 0, [9, None]], + [11, 'topy', 0, 0, [9, None]], + [12, 'showaligned', 0, 0, [9, 13, 14]], + [13, 'journal', 0, 0, [12, None]], + [14, 'setxy', 0, 0, [12, 15, 16, 17]], + [15, 'rightx', 0, 0, [14, None]], + [16, 'topy', 0, 0, [14, None]], + [17, 'showaligned', 0, 0, [14, 18, 19]], + [18, 'journal', 0, 0, [17, None]], + [19, 'setxy', 0, 0, [17, 20, 21, 22]], + [20, 'leftx', 0, 0, [19, None]], + [21, 'bottomy', 0, 0, [19, None]], + [22, 'showaligned', 0, 0, [19, 23, 24]], + [23, 'description', 0, 0, [22, None]], + [24, 'setxy', 0, 0, [22, 25, 26, 27]], + [25, 'rightx', 0, 0, [24, None]], + [26, 'bottomy', 0, 0, [24, None]], + [27, 'showaligned', 0, 0, [24, 28, 29]], + [28, 'description', 0, 0, [27, None]], + [29, 'sandwichbottom', 0, 0, [27, None]]], + 'picture1x2': + [[0, 'sandwichtop', 0, 0, [None, 1, 2]], + [1, ['string', _('1×2 pictures')], 0, 0, [0, None]], + [2, 'setxy', 0, 0, [0, 3, 4, 5]], + [3, 'titlex', 0, 0, [2, None]], + [4, 'titley', 0, 0, [2, None]], + [5, 'show', 0, 0, [2, 6, 7]], + [6, ['string',_('Title')], 0, 0, [5, None]], + [7, 'setscale', 0, 0, [5, 8, 9]], + [8, ['number', '45'], 0, 0, [7, None]], + [9, 'setxy', 0, 0, [7, 10, 11, 12]], + [10, 'leftx', 0, 0, [9, None]], + [11, 'topy', 0, 0, [9, None]], + [12, 'showaligned', 0, 0, [9, 13, 14]], + [13, 'journal', 0, 0, [12, None]], + [14, 'setxy', 0, 0, [12, 15, 16, 17]], + [15, 'rightx', 0, 0, [14, None]], + [16, 'topy', 0, 0, [14, None]], + [17, 'showaligned', 0, 0, [14, 18, 19]], + [18, 'description', 0, 0, [17, None]], + [19, 'setxy', 0, 0, [17, 20, 21, 22]], + [20, 'leftx', 0, 0, [19, None]], + [21, 'bottomy', 0, 0, [19, None]], + [22, 'showaligned', 0, 0, [19, 23, 24]], + [23, 'journal', 0, 0, [22, None]], + [24, 'setxy', 0, 0, [22, 25, 26, 27]], + [25, 'rightx', 0, 0, [24, None]], + [26, 'bottomy', 0, 0, [24, None]], + [27, 'showaligned', 0, 0, [24, 28, 29]], + [28, 'description', 0, 0, [27, None]], + [29, 'sandwichbottom', 0, 0, [27, None]]], + 'picture1x1': + [[0, 'sandwichtop', 0, 0, [None, 1, 2]], + [1, ['string', _('1×1 picture')], 0, 0, [0, None]], + [2, 'setxy', 0, 0, [0, 3, 4, 5]], + [3, 'titlex', 0, 0, [2, None]], + [4, 'titley', 0, 0, [2, None]], + [5, 'show', 0, 0, [2, 6, 7]], + [6, ['string',_('Title')], 0, 0, [5, None]], + [7, 'setscale', 0, 0, [5, 8, 9]], + [8, ['number', '45'], 0, 0, [7, None]], + [9, 'setxy', 0, 0, [7, 10, 11, 12]], + [10, 'leftx', 0, 0, [9, None]], + [11, 'topy', 0, 0, [9, None]], + [12, 'showaligned', 0, 0, [9, 13, 14]], + [13, 'journal', 0, 0, [12, None]], + [14, 'setxy', 0, 0, [12, 15, 16, 17]], + [15, 'rightx', 0, 0, [14, None]], + [16, 'topy', 0, 0, [14, None]], + [17, 'showaligned', 0, 0, [14, 18, 19]], + [18, 'description', 0, 0, [17, None]], + [19, 'sandwichbottom', 0, 0, [17, None]]] + } + -- cgit v0.9.1