pull/29/head
Bernat Romagosa 2016-12-29 12:23:01 +01:00
commit 0d65bc9b79
14 zmienionych plików z 183 dodań i 165 usunięć

117
blocks.js
Wyświetl plik

@ -149,7 +149,7 @@ isSnapObject, copy, PushButtonMorph, SpriteIconMorph, Process, AlignmentMorph*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.blocks = '2016-December-19'; modules.blocks = '2016-December-27';
var SyntaxElementMorph; var SyntaxElementMorph;
var BlockMorph; var BlockMorph;
@ -246,52 +246,52 @@ SyntaxElementMorph.uber = Morph.prototype;
outline: outline:
corner - radius of command block rounding corner - radius of command block rounding
rounding - radius of reporter block rounding rounding - radius of reporter block rounding
edge - width of 3D-ish shading box edge - width of 3D-ish shading box
hatHeight - additional top space for hat blocks hatHeight - additional top space for hat blocks
hatWidth - minimum width for hat blocks hatWidth - minimum width for hat blocks
rfBorder - pixel width of reification border (grey outline) rfBorder - pixel width of reification border (grey outline)
minWidth - minimum width for any syntax element's contents minWidth - minimum width for any syntax element's contents
jigsaw shape: jigsaw shape:
inset - distance from indentation to left edge inset - distance from indentation to left edge
dent - width of indentation bottom dent - width of indentation bottom
paddings: paddings:
bottomPadding - adds to the width of the bottom most c-slot bottomPadding - adds to the width of the bottom most c-slot
cSlotPadding - adds to the width of the open "C" in c-slots cSlotPadding - adds to the width of the open "C" in c-slots
typeInPadding - adds pixels between text and edge in input slots typeInPadding - adds pixels between text and edge in input slots
labelPadding - adds left/right pixels to block labels labelPadding - adds left/right pixels to block labels
label: label:
labelFontName - <string> specific font family name labelFontName - <string> specific font family name
labelFontStyle - <string> generic font family name, cascaded labelFontStyle - <string> generic font family name, cascaded
fontSize - duh fontSize - duh
embossing - <Point> offset for embossing effect embossing - <Point> offset for embossing effect
labelWidth - column width, used for word wrapping labelWidth - column width, used for word wrapping
labelWordWrap - <bool> if true labels can break after each word labelWordWrap - <bool> if true labels can break after each word
dynamicInputLabels - <bool> if true inputs can have dynamic labels dynamicInputLabels - <bool> if true inputs can have dynamic labels
snapping: snapping:
feedbackColor - <Color> for displaying drop feedbacks feedbackColor - <Color> for displaying drop feedbacks
feedbackMinHeight - height of white line for command block snaps feedbackMinHeight - height of white line for command block snaps
minSnapDistance - threshold when commands start snapping minSnapDistance - threshold when commands start snapping
reporterDropFeedbackPadding - increases reporter drop feedback reporterDropFeedbackPadding - increases reporter drop feedback
color gradients: color gradients:
contrast - <percent int> 3D-ish shading gradient contrast contrast - <percent int> 3D-ish shading gradient contrast
labelContrast - <percent int> 3D-ish label shading contrast labelContrast - <percent int> 3D-ish label shading contrast
activeHighlight - <Color> for stack highlighting when active activeHighlight - <Color> for stack highlighting when active
errorHighlight - <Color> for error highlighting errorHighlight - <Color> for error highlighting
activeBlur - <pixels int> shadow for blurred activeHighlight activeBlur - <pixels int> shadow for blurred activeHighlight
activeBorder - <pixels int> unblurred activeHighlight activeBorder - <pixels int> unblurred activeHighlight
rfColor - <Color> for reified outlines and slot backgrounds rfColor - <Color> for reified outlines and slot backgrounds
*/ */
SyntaxElementMorph.prototype.setScale = function (num) { SyntaxElementMorph.prototype.setScale = function (num) {
@ -1120,7 +1120,8 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
part = new InputSlotMorph( part = new InputSlotMorph(
null, null,
false, false,
{ color: ['color'], {
color: ['color'],
fisheye: ['fisheye'], fisheye: ['fisheye'],
whirl: ['whirl'], whirl: ['whirl'],
pixelate: ['pixelate'], pixelate: ['pixelate'],
@ -2020,14 +2021,14 @@ SyntaxElementMorph.prototype.endLayout = function () {
SyntaxElementMorph my most important attributes and public SyntaxElementMorph my most important attributes and public
accessors are: accessors are:
selector - (string) name of method to be triggered selector - (string) name of method to be triggered
receiver() - answer the object (sprite) to which I apply receiver() - answer the object (sprite) to which I apply
inputs() - answer an array with my arg slots and nested reporters inputs() - answer an array with my arg slots and nested reporters
defaults - an optional Array containing default input values defaults - an optional Array containing default input values
topBlock() - answer the top block of the stack I'm attached to topBlock() - answer the top block of the stack I'm attached to
blockSpec - a formalized description of my label parts blockSpec - a formalized description of my label parts
setSpec() - force me to change my label structure setSpec() - force me to change my label structure
evaluate() - answer the result of my evaluation evaluate() - answer the result of my evaluation
isUnevaluated() - answer whether I am part of a special form isUnevaluated() - answer whether I am part of a special form
Zebra coloring provides a mechanism to alternate brightness of nested, Zebra coloring provides a mechanism to alternate brightness of nested,
@ -2101,28 +2102,28 @@ SyntaxElementMorph.prototype.endLayout = function () {
arity: multiple arity: multiple
%mult%x - where %x stands for any of the above single inputs %mult%x - where %x stands for any of the above single inputs
%inputs - for an additional text label 'with inputs' %inputs - for an additional text label 'with inputs'
%words - for an expandable list of default 2 (used in JOIN) %words - for an expandable list of default 2 (used in JOIN)
%exp - for a static expandable list of minimum 0 (used in LIST) %exp - for a static expandable list of minimum 0 (used in LIST)
%scriptVars - for an expandable list of variable reporter templates %scriptVars - for an expandable list of variable reporter templates
%parms - for an expandable list of formal parameters %parms - for an expandable list of formal parameters
%ringparms - the same for use inside Rings %ringparms - the same for use inside Rings
special form: upvar special form: upvar
%upvar - same as %t (inline variable reporter template) %upvar - same as %t (inline variable reporter template)
special form: input name special form: input name
%inputName - variable blob (used in input type dialog) %inputName - variable blob (used in input type dialog)
examples: examples:
'if %b %c else %c' - creates Scratch's If/Else block 'if %b %c else %c' - creates Scratch's If/Else block
'set pen color to %clr' - creates Scratch's Pen color block 'set pen color to %clr' - creates Scratch's Pen color block
'list %mult%s' - creates BYOB's list reporter block 'list %mult%s' - creates BYOB's list reporter block
'call %n %inputs' - creates BYOB's Call block 'call %n %inputs' - creates BYOB's Call block
'the script %parms %c' - creates BYOB's THE SCRIPT block 'the script %parms %c' - creates BYOB's THE SCRIPT block
*/ */
@ -2349,7 +2350,7 @@ BlockMorph.prototype.userMenu = function () {
menu.addItem( menu.addItem(
"script pic with result...", "script pic with result...",
function () { function () {
top.ExportResultPic(); top.exportResultPic();
}, },
'open a new window\n' + 'open a new window\n' +
'with a picture of both\nthis script and its result', 'with a picture of both\nthis script and its result',
@ -4909,7 +4910,7 @@ ReporterBlockMorph.prototype.mouseClickLeft = function (pos) {
// ReporterBlock exporting picture with result bubble // ReporterBlock exporting picture with result bubble
ReporterBlockMorph.prototype.ExportResultPic = function () { ReporterBlockMorph.prototype.exportResultPic = function () {
var top = this.topBlock(), var top = this.topBlock(),
receiver = top.receiver(), receiver = top.receiver(),
stage; stage;
@ -4923,7 +4924,6 @@ ReporterBlockMorph.prototype.ExportResultPic = function () {
} }
}; };
// ReporterBlockMorph deleting // ReporterBlockMorph deleting
ReporterBlockMorph.prototype.userDestroy = function () { ReporterBlockMorph.prototype.userDestroy = function () {
@ -8620,19 +8620,18 @@ TemplateSlotMorph.prototype.unflash = function () {
I am a diamond-shaped argument slot. I am a diamond-shaped argument slot.
My block spec is My block spec is
%b - Boolean %b - Boolean
%boolUE - Boolean unevaluated %boolUE - Boolean unevaluated
I can be directly edited. When the user clicks on me I toggle I can be directly edited. When the user clicks on me I toggle
between <true>, <false> and <null> values. between <true>, <false> and <null> values.
evaluate returns my value. evaluate() returns my value.
my most important public attributes and accessors are: my most important public attributes and accessors are:
value - user editable contents (Boolean or null) value - user editable contents (Boolean or null)
setContents(Boolean/null) - display the argument (Boolean or null) setContents(Boolean/null) - display the argument (Boolean or null)
*/ */
// BooleanSlotMorph inherits from ArgMorph: // BooleanSlotMorph inherits from ArgMorph:
@ -10848,7 +10847,7 @@ function BlockHighlightMorph() {
evaluation is handles by the interpreter evaluation is handles by the interpreter
*/ */
// MultiArgMorph inherits from ArgMorph: // MultiArgMorph inherits from ArgMorph:
MultiArgMorph.prototype = new ArgMorph(); MultiArgMorph.prototype = new ArgMorph();
MultiArgMorph.prototype.constructor = MultiArgMorph; MultiArgMorph.prototype.constructor = MultiArgMorph;
@ -11256,10 +11255,9 @@ MultiArgMorph.prototype.mappedCode = function (definitions) {
// MultiArgMorph arity evaluating: // MultiArgMorph arity evaluating:
MultiArgMorph.prototype.evaluate = function () { MultiArgMorph.prototype.evaluate = function () {
/* // this is usually overridden by the interpreter. This method is only
this is usually overridden by the interpreter. This method is only // called (and needed) for the variables menu.
called (and needed) for the variables menu.
*/
var result = []; var result = [];
this.inputs().forEach(function (slot) { this.inputs().forEach(function (slot) {
result.push(slot.evaluate()); result.push(slot.evaluate());
@ -11285,7 +11283,7 @@ MultiArgMorph.prototype.isEmptySlot = function () {
input's value along. input's value along.
*/ */
// ArgLabelMorph inherits from ArgMorph: // ArgLabelMorph inherits from ArgMorph:
ArgLabelMorph.prototype = new ArgMorph(); ArgLabelMorph.prototype = new ArgMorph();
ArgLabelMorph.prototype.constructor = ArgLabelMorph; ArgLabelMorph.prototype.constructor = ArgLabelMorph;
@ -11395,10 +11393,9 @@ ArgLabelMorph.prototype.reactToGrabOf = function () {
// ArgLabelMorph evaluating: // ArgLabelMorph evaluating:
ArgLabelMorph.prototype.evaluate = function () { ArgLabelMorph.prototype.evaluate = function () {
/* // this is usually overridden by the interpreter. This method is only
this is usually overridden by the interpreter. This method is only // called (and needed) for the variables menu.
called (and needed) for the variables menu.
*/
return this.argMorph().evaluate(); return this.argMorph().evaluate();
}; };
@ -11410,7 +11407,7 @@ ArgLabelMorph.prototype.isEmptySlot = function () {
/* /*
I am an unevaluated, non-editable, rf-colored, rounded or diamond I am an unevaluated, non-editable, rf-colored, rounded or diamond
input slot. My current (only) use is in the THE BLOCK block. input slot. My current (only) use is in the THE BLOCK block.
My command spec is %f My command spec is %f
*/ */

Wyświetl plik

@ -2,7 +2,7 @@
byob.js byob.js
"build your own blocks" for SNAP! "build your own blocks" for Snap!
based on morphic.js, widgets.js blocks.js, threads.js and objects.js based on morphic.js, widgets.js blocks.js, threads.js and objects.js
inspired by Scratch inspired by Scratch
@ -108,7 +108,7 @@ WatcherMorph, Variable*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.byob = '2016-September-27'; modules.byob = '2016-December-27';
// Declarations // Declarations

21
gui.js
Wyświetl plik

@ -72,7 +72,7 @@ isRetinaSupported, SliderMorph, Animation*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.gui = '2016-December-19'; modules.gui = '2016-December-27';
// Declarations // Declarations
@ -1358,6 +1358,7 @@ IDE_Morph.prototype.createSpriteEditor = function () {
this.spriteEditor.contents.acceptsDrops = true; this.spriteEditor.contents.acceptsDrops = true;
scripts.scrollFrame = this.spriteEditor; scripts.scrollFrame = this.spriteEditor;
scripts.updateUndropControls();
this.add(this.spriteEditor); this.add(this.spriteEditor);
this.spriteEditor.scrollX(this.spriteEditor.padding); this.spriteEditor.scrollX(this.spriteEditor.padding);
this.spriteEditor.scrollY(this.spriteEditor.padding); this.spriteEditor.scrollY(this.spriteEditor.padding);
@ -2410,6 +2411,20 @@ IDE_Morph.prototype.settingsMenu = function () {
); );
} }
menu.addLine(); menu.addLine();
/*
addPreference(
'JavaScript',
function () {
Process.prototype.enableJS = !Process.prototype.enableJS;
myself.currentSprite.blocksCache.operators = null;
myself.currentSprite.paletteCache.operators = null;
myself.refreshPalette();
},
Process.prototype.enableJS,
'uncheck to disable support for\nnative JavaScript functions',
'check to support\nnative JavaScript functions'
);
*/
if (isRetinaSupported()) { if (isRetinaSupported()) {
addPreference( addPreference(
'Retina display support', 'Retina display support',
@ -2485,7 +2500,7 @@ IDE_Morph.prototype.settingsMenu = function () {
'Execute on slider change', 'Execute on slider change',
'toggleSliderExecute', 'toggleSliderExecute',
ArgMorph.prototype.executeOnSliderEdit, ArgMorph.prototype.executeOnSliderEdit,
'uncheck to supress\nrunning scripts\nwhen moving the slider', 'uncheck to suppress\nrunning scripts\nwhen moving the slider',
'check to run\nthe edited script\nwhen moving the slider' 'check to run\nthe edited script\nwhen moving the slider'
); );
} }
@ -4475,6 +4490,8 @@ IDE_Morph.prototype.toggleAppMode = function (appMode) {
} }
}); });
} }
// update undrop controls
this.currentSprite.scripts.updateUndropControls();
} }
this.setExtent(this.world().extent()); // resume trackChanges this.setExtent(this.world().extent()); // resume trackChanges
}; };

Wyświetl plik

@ -3206,6 +3206,24 @@ http://snap.berkeley.edu/run#cloud:Username=jens&ProjectName=rotation
------ ------
* Objects: added Boolean operators to “reporterize” * Objects: added Boolean operators to “reporterize”
161222
------
* Objects: simplified reporterize>>blockFromAST
* Threads: prevented color slots from flashing. Good catch, thanks, Joan!
161223
------
* Objects: tweaked reporterize infixParser
161225
------
* GUI: update undrop controls when switching sprites and display modes
161227
------
* GUI, Threads, Objects, Store: Disable JS-Functions, to protect users from malicious scripts, commented out for now
== v4.10 === (in development) == v4.10 === (in development)
Features: Features:

Wyświetl plik

@ -846,7 +846,7 @@ SnapTranslator.dict.ca = {
'uncheck for round ends of lines': 'uncheck for round ends of lines':
'desmarqueu per fer que\nels extrems de les línies\ndel llapis siguin arrodonides', 'desmarqueu per fer que\nels extrems de les línies\ndel llapis siguin arrodonides',
'Inheritance support': 'Inheritance support':
'Suport per a herència', 'Suport a l\'herència d\'objectes',
// inputs // inputs
'with inputs': 'with inputs':
@ -1122,9 +1122,9 @@ SnapTranslator.dict.ca = {
'Command\n(C-shape)': 'Command\n(C-shape)':
'Comanda\n(en forma de C)', 'Comanda\n(en forma de C)',
'Any\n(unevaluated)': 'Any\n(unevaluated)':
'Qualsevol\n(sense evaluar)', 'Qualsevol\n(sense avaluar)',
'Boolean\n(unevaluated)': 'Boolean\n(unevaluated)':
'Booleà\n(sense evaluar)', 'Booleà\n(sense avaluar)',
'Single input.': 'Single input.':
'Entrada única.', 'Entrada única.',
'Default Value:': 'Default Value:':
@ -1904,8 +1904,6 @@ SnapTranslator.dict.ca = {
'desmarqueu per deshabilitar\nel suport a l\'edició per teclat', 'desmarqueu per deshabilitar\nel suport a l\'edició per teclat',
'check to enable\nkeyboard editing support': 'check to enable\nkeyboard editing support':
'marqueu per habilitar\nel suport a l\'edició per teclat', 'marqueu per habilitar\nel suport a l\'edició per teclat',
'Inheritance support':
'Suport a l\'herència d\'objectes',
'uncheck to disable\nsprite inheritance features': 'uncheck to disable\nsprite inheritance features':
'desmarqueu per deshabilitar les\nfuncionalitats relatives a l\'herència d\'objectes', 'desmarqueu per deshabilitar les\nfuncionalitats relatives a l\'herència d\'objectes',
'check for sprite\ninheritance features': 'check for sprite\ninheritance features':
@ -1924,8 +1922,6 @@ SnapTranslator.dict.ca = {
'captura de pantalla', 'captura de pantalla',
'stage image': 'stage image':
'imatge de l\'escenari', 'imatge de l\'escenari',
'frames':
'frames',
'processes': 'processes':
'processos', 'processos',
'map %repRing over %l': 'map %repRing over %l':

Wyświetl plik

@ -1909,8 +1909,6 @@ SnapTranslator.dict.pt = {
'Desassinalar para desactivar\na edição usando o teclado.', 'Desassinalar para desactivar\na edição usando o teclado.',
'check to enable\nkeyboard editing support': 'check to enable\nkeyboard editing support':
'Assinalar para activar\na edição usando o teclado.', 'Assinalar para activar\na edição usando o teclado.',
'Inheritance support':
'Suporte para herança',
'uncheck to disable\nsprite inheritance features': 'uncheck to disable\nsprite inheritance features':
'Desassinalar para desactivar\nfuncionalidades de herança de actores.', 'Desassinalar para desactivar\nfuncionalidades de herança de actores.',
'check for sprite\ninheritance features': 'check for sprite\ninheritance features':

Wyświetl plik

@ -1,6 +1,6 @@
/* /*
lang-zh.js lang-zh_CN.js
Simplified Chinese translation for SNAP! Simplified Chinese translation for SNAP!
@ -166,7 +166,7 @@
/*global SnapTranslator*/ /*global SnapTranslator*/
SnapTranslator.dict.zh = { SnapTranslator.dict.zh_CN = {
/* /*
Special characters: (see <http://0xcc.net/jsescape/>) Special characters: (see <http://0xcc.net/jsescape/>)

Wyświetl plik

@ -1,6 +1,6 @@
/* /*
lang-tw.js lang-zh_TW.js
Traditional Chinese translation for SNAP! Traditional Chinese translation for SNAP!
SNAP 繁體中文翻譯版 SNAP 繁體中文翻譯版
@ -167,7 +167,7 @@
/*global SnapTranslator*/ /*global SnapTranslator*/
SnapTranslator.dict.tw = { SnapTranslator.dict.zh_TW = {
/* /*
Special characters: (see <http://0xcc.net/jsescape/>) Special characters: (see <http://0xcc.net/jsescape/>)

Wyświetl plik

@ -0,0 +1 @@
<blocks app="Snap! 4.0, http://snap.berkeley.edu" version="1"><block-definition s="safely try %&apos;action&apos; then if %&apos;error&apos; %&apos;handler&apos;" type="command" category="control"><header></header><code></code><inputs><input type="%cs"></input><input type="%upvar"></input><input type="%cs"></input></inputs><script><custom-block s="let %upvar be %s"><l>reset</l><block s="evaluate"><block s="reportJSFunction"><list><l>proc</l></list><l>var oldHandleError = proc.handleError,&#xD; oldCatchingErrors = proc.isCatchingErrors;&#xD;&#xD;return function(){&#xD; proc.handleError = oldHandleError;&#xD; proc.isCatchingErrors = oldCatchingErrors;&#xD;}</l></block><list></list></block></custom-block><block s="doCallCC"><block s="reifyScript"><script><block s="doRun"><block s="reportJSFunction"><list><l>reset</l><l>action</l><l>handler</l><l>proc</l></list><l>proc.isCatchingErrors = true;&#xD;proc.handleError = function(error, element){&#xD; reset();&#xD; proc.context = handler;&#xD; proc.context.variables.setVar("error", error);&#xD;}&#xD;&#xD;try{&#xD; proc.evaluate(action, new List(), true);&#xD;}&#xD;catch(e){&#xD; proc.handleError(e, null);&#xD;} </l></block><list><block var="reset"/><block var="action"/><block s="reifyScript"><script><block s="doRun"><block s="reifyScript"><script><block s="doRun"><block var="handler"/><list></list></block><block s="doRun"><block var="return"/><list></list></block></script><list></list></block><list></list></block></script><list></list></block></list></block></script><list><l>return</l></list></block></block><block s="doRun"><block var="reset"/><list></list></block></script></block-definition><block-definition s="error %&apos;msg&apos;" type="command" category="control"><header></header><code></code><inputs><input type="%txt"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>msg</l></list><l>throw new Error(msg);</l></block><list><block var="msg"/></list></block></script></block-definition><block-definition s="let %&apos;var&apos; be %&apos;val&apos;" type="command" category="other"><header></header><code></code><inputs><input type="%upvar"></input><input type="%s"></input></inputs><script><block s="doSetVar"><l>var</l><block var="val"/></block></script></block-definition></blocks>

Wyświetl plik

@ -42,7 +42,7 @@
/*global modules, contains*/ /*global modules, contains*/
modules.locale = '2016-December-09'; modules.locale = '2016-December-27';
// Global stuff // Global stuff
@ -229,7 +229,7 @@ SnapTranslator.dict.cs = {
'2015-11-16' '2015-11-16'
}; };
SnapTranslator.dict.zh = { SnapTranslator.dict.zh_CN = {
'language_name': 'language_name':
'简体中文', '简体中文',
'language_translator': 'language_translator':
@ -317,7 +317,7 @@ SnapTranslator.dict.pl = {
'2016-11-14' '2016-11-14'
}; };
SnapTranslator.dict.tw = { SnapTranslator.dict.zh_TW = {
'language_name': 'language_name':
'繁體中文', '繁體中文',
'language_translator': 'language_translator':

Wyświetl plik

@ -1136,7 +1136,7 @@
/*global window, HTMLCanvasElement, FileReader, Audio, FileList*/ /*global window, HTMLCanvasElement, FileReader, Audio, FileList*/
var morphicVersion = '2016-December-12'; var morphicVersion = '2016-December-27';
var modules = {}; // keep track of additional loaded modules var modules = {}; // keep track of additional loaded modules
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
@ -3849,9 +3849,7 @@ Morph.prototype.perish = function (msecs, onComplete) {
// Morph utilities: // Morph utilities:
Morph.prototype.nop = function () { Morph.prototype.nop = nop;
nop();
};
Morph.prototype.resize = function () { Morph.prototype.resize = function () {
this.world().activeHandle = new HandleMorph(this); this.world().activeHandle = new HandleMorph(this);
@ -4122,7 +4120,7 @@ Morph.prototype.developersMenu = function () {
menu.addItem( menu.addItem(
"pick up", "pick up",
'pickUp', 'pickUp',
'disattach and put \ninto the hand' 'detach and put \ninto the hand'
); );
menu.addItem( menu.addItem(
"attach...", "attach...",
@ -6310,9 +6308,7 @@ SliderButtonMorph.prototype.init = function (orientation) {
SliderButtonMorph.uber.init.call(this, orientation); SliderButtonMorph.uber.init.call(this, orientation);
}; };
SliderButtonMorph.prototype.autoOrientation = function () { SliderButtonMorph.prototype.autoOrientation = nop;
nop();
};
SliderButtonMorph.prototype.drawNew = function () { SliderButtonMorph.prototype.drawNew = function () {
var colorBak = this.color.copy(); var colorBak = this.color.copy();
@ -6548,9 +6544,7 @@ SliderMorph.prototype.init = function (
// this.drawNew(); // this.drawNew();
}; };
SliderMorph.prototype.autoOrientation = function () { SliderMorph.prototype.autoOrientation = nop;
nop();
};
SliderMorph.prototype.rangeSize = function () { SliderMorph.prototype.rangeSize = function () {
return this.stop - this.start; return this.stop - this.start;
@ -9833,9 +9827,7 @@ ScrollFrameMorph.prototype.scrollY = function (steps) {
} }
}; };
ScrollFrameMorph.prototype.step = function () { ScrollFrameMorph.prototype.step = nop;
nop();
};
ScrollFrameMorph.prototype.mouseDownLeft = function (pos) { ScrollFrameMorph.prototype.mouseDownLeft = function (pos) {
if (!this.isScrollingByDragging) { if (!this.isScrollingByDragging) {
@ -10026,7 +10018,6 @@ ScrollFrameMorph.prototype.developersMenu = function () {
return menu; return menu;
}; };
ScrollFrameMorph.prototype.toggleTextLineWrapping = function () { ScrollFrameMorph.prototype.toggleTextLineWrapping = function () {
this.isTextLineWrapping = !this.isTextLineWrapping; this.isTextLineWrapping = !this.isTextLineWrapping;
}; };
@ -11447,21 +11438,13 @@ WorldMorph.prototype.initEventListeners = function () {
}; };
}; };
WorldMorph.prototype.mouseDownLeft = function () { WorldMorph.prototype.mouseDownLeft = nop;
nop();
};
WorldMorph.prototype.mouseClickLeft = function () { WorldMorph.prototype.mouseClickLeft = nop;
nop();
};
WorldMorph.prototype.mouseDownRight = function () { WorldMorph.prototype.mouseDownRight = nop;
nop();
};
WorldMorph.prototype.mouseClickRight = function () { WorldMorph.prototype.mouseClickRight = nop;
nop();
};
WorldMorph.prototype.wantsDropOf = function () { WorldMorph.prototype.wantsDropOf = function () {
// allow handle drops if any drops are allowed // allow handle drops if any drops are allowed
@ -11538,7 +11521,7 @@ WorldMorph.prototype.contextMenu = function () {
menu.addItem( menu.addItem(
"fill page...", "fill page...",
'fillPage', 'fillPage',
'let the World automatically\nadjust to browser resizings' 'let the World automatically\nadjust to browser resizing'
); );
if (useBlurredShadows) { if (useBlurredShadows) {
menu.addItem( menu.addItem(

Wyświetl plik

@ -82,7 +82,7 @@ SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize, BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph*/ TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph*/
modules.objects = '2016-December-21'; modules.objects = '2016-December-27';
var SpriteMorph; var SpriteMorph;
var StageMorph; var StageMorph;
@ -2027,8 +2027,11 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push('-'); blocks.push('-');
blocks.push(block('reportIsA')); blocks.push(block('reportIsA'));
blocks.push(block('reportIsIdentical')); blocks.push(block('reportIsIdentical'));
blocks.push('-');
blocks.push(block('reportJSFunction')); if (true) { // (Process.prototype.enableJS) {
blocks.push('-');
blocks.push(block('reportJSFunction'));
}
// for debugging: /////////////// // for debugging: ///////////////
@ -2641,8 +2644,8 @@ SpriteMorph.prototype.reporterize = function (expressionString) {
var ast; var ast;
function parseInfix(expression, operator, already) { function parseInfix(expression, operator, already) {
// very basic binary infix parser for arithmetic expressions // very basic diadic infix parser for arithmetic expressions
// with strict left-to-right operator precedence (like in Smalltalk) // with strict left-to-right operator precedence (as in Smalltalk)
// which can be overriden by - nested - parentheses. // which can be overriden by - nested - parentheses.
// assumes well-formed expressions, no graceful error handling yet. // assumes well-formed expressions, no graceful error handling yet.
@ -2702,13 +2705,17 @@ SpriteMorph.prototype.reporterize = function (expressionString) {
case '&': case '&':
case '|': case '|':
if (!operator && !inputs[0].length) { if (!operator && !inputs[0].length) {
inputs[0] += ch; inputs[0] = ch;
} else if (operator) { } else if (operator) {
return parseInfix( if (!inputs[1].length) {
expression.slice(idx), inputs[1] = ch;
ch, } else {
[operator, already, format(inputs[1])] return parseInfix(
); expression.slice(idx),
ch,
[operator, already, format(inputs[1])]
);
}
} else { } else {
operator = ch; operator = ch;
already = format(inputs[0]); already = format(inputs[0]);
@ -2725,7 +2732,8 @@ SpriteMorph.prototype.reporterize = function (expressionString) {
} }
function blockFromAST(ast) { function blockFromAST(ast) {
var block, selectors, monads, alias, key, sel, i, inps; var block, selectors, monads, alias, key, sel, i, inps,
off = 1;
selectors = { selectors = {
'+': 'reportSum', '+': 'reportSum',
'-': 'reportDifference', '-': 'reportDifference',
@ -2747,60 +2755,40 @@ SpriteMorph.prototype.reporterize = function (expressionString) {
'!' : 'not' '!' : 'not'
}; };
key = alias[ast[0]] || ast[0]; key = alias[ast[0]] || ast[0];
if (contains(monads, key)) { if (contains(monads, key)) { // monadic
sel = selectors[key]; sel = selectors[key];
if (sel) { if (sel) { // single input
block = SpriteMorph.prototype.blockForSelector(sel); block = SpriteMorph.prototype.blockForSelector(sel);
inps = block.inputs(); inps = block.inputs();
i = 0; } else { // two inputs, first is function name
} else {
block = SpriteMorph.prototype.blockForSelector('reportMonadic'); block = SpriteMorph.prototype.blockForSelector('reportMonadic');
inps = block.inputs(); inps = block.inputs();
inps[0].setContents([key]); inps[0].setContents([key]);
i = 1; off = 0;
} }
if (ast[1] instanceof Array) { } else { // diadic
block.silentReplaceInput(inps[i], blockFromAST(ast[1])); block = SpriteMorph.prototype.blockForSelector(selectors[key]);
} else if (isString(ast[1])) { inps = block.inputs();
if (contains(['true', 'false'], ast[1])) { }
for (i = 1; i < ast.length; i += 1) {
if (ast[i] instanceof Array) {
block.silentReplaceInput(inps[i - off], blockFromAST(ast[i]));
} else if (isString(ast[i])) {
if (contains(['true', 'false'], ast[i])) {
block.silentReplaceInput( block.silentReplaceInput(
inps[i], inps[i - off],
SpriteMorph.prototype.blockForSelector( SpriteMorph.prototype.blockForSelector(
ast[1] === 'true' ? 'reportTrue' : 'reportFalse' ast[i] === 'true' ? 'reportTrue' : 'reportFalse'
) )
); );
} else if (ast[1] !== '_') { } else if (ast[i] !== '_') {
block.silentReplaceInput( block.silentReplaceInput(
inps[i], inps[i - off],
SpriteMorph.prototype.variableBlock(ast[1]) SpriteMorph.prototype.variableBlock(ast[i])
); );
} }
} else { // number } else { // number
inps[i].setContents(ast[1]); inps[i - off].setContents(ast[i]);
}
} else { // diadic
block = SpriteMorph.prototype.blockForSelector(selectors[ast[0]]);
inps = block.inputs();
for (i = 1; i < 3; i += 1) {
if (ast[i] instanceof Array) {
block.silentReplaceInput(inps[i - 1], blockFromAST(ast[i]));
} else if (isString(ast[i])) {
if (contains(['true', 'false'], ast[i])) {
block.silentReplaceInput(
inps[i - 1],
SpriteMorph.prototype.blockForSelector(
ast[i] === 'true' ? 'reportTrue' : 'reportFalse'
)
);
} else if (ast[i] !== '_') {
block.silentReplaceInput(
inps[i - 1],
SpriteMorph.prototype.variableBlock(ast[i])
);
}
} else { // number
inps[i - 1].setContents(ast[i]);
}
} }
} }
block.isDraggable = true; block.isDraggable = true;
@ -6248,8 +6236,11 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push('-'); blocks.push('-');
blocks.push(block('reportIsA')); blocks.push(block('reportIsA'));
blocks.push(block('reportIsIdentical')); blocks.push(block('reportIsIdentical'));
blocks.push('-');
blocks.push(block('reportJSFunction')); if (true) { // (Process.prototype.enableJS) {
blocks.push('-');
blocks.push(block('reportJSFunction'));
}
// for debugging: /////////////// // for debugging: ///////////////

Wyświetl plik

@ -61,7 +61,7 @@ normalizeCanvas*/
// Global stuff //////////////////////////////////////////////////////// // Global stuff ////////////////////////////////////////////////////////
modules.store = '2016-November-24'; modules.store = '2016-December-27';
// XML_Serializer /////////////////////////////////////////////////////// // XML_Serializer ///////////////////////////////////////////////////////
@ -1017,6 +1017,16 @@ SnapSerializer.prototype.loadBlock = function (model, isReporter) {
model.attributes['var'] model.attributes['var']
); );
} }
/*
if (model.attributes.s === 'reportJSFunction' &&
!Process.prototype.enableJS) {
if (window.confirm('enable JavaScript?')) {
Process.prototype.enableJS = true;
} else {
throw new Error('JavaScript is not enabled');
}
}
*/
block = SpriteMorph.prototype.blockForSelector(model.attributes.s); block = SpriteMorph.prototype.blockForSelector(model.attributes.s);
} else if (model.tag === 'custom-block') { } else if (model.tag === 'custom-block') {
isGlobal = model.attributes.scope ? false : true; isGlobal = model.attributes.scope ? false : true;

Wyświetl plik

@ -59,9 +59,9 @@ degrees, detect, nop, radians, ReporterSlotMorph, CSlotMorph, RingMorph,
IDE_Morph, ArgLabelMorph, localize, XML_Element, hex_sha512, TableDialogMorph, IDE_Morph, ArgLabelMorph, localize, XML_Element, hex_sha512, TableDialogMorph,
StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy, StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy,
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
TableFrameMorph, isSnapObject*/ TableFrameMorph, ColorSlotMorph, isSnapObject*/
modules.threads = '2016-October-27'; modules.threads = '2016-December-27';
var ThreadManager; var ThreadManager;
var Process; var Process;
@ -473,6 +473,7 @@ Process.prototype.isCatchingErrors = true;
Process.prototype.enableLiveCoding = false; // experimental Process.prototype.enableLiveCoding = false; // experimental
Process.prototype.enableSingleStepping = false; // experimental Process.prototype.enableSingleStepping = false; // experimental
Process.prototype.flashTime = 0; // experimental Process.prototype.flashTime = 0; // experimental
// Process.prototype.enableJS = false;
function Process(topBlock, onComplete, rightAway) { function Process(topBlock, onComplete, rightAway) {
this.topBlock = topBlock || null; this.topBlock = topBlock || null;
@ -1000,6 +1001,11 @@ Process.prototype.evaluate = function (
) { ) {
if (!context) {return null; } if (!context) {return null; }
if (context instanceof Function) { if (context instanceof Function) {
/*
if (!this.enableJS) {
throw new Error('JavaScript is not enabled');
}
*/
return context.apply( return context.apply(
this.blockReceiver(), this.blockReceiver(),
args.asArray().concat([this]) args.asArray().concat([this])
@ -3357,7 +3363,8 @@ Process.prototype.flashContext = function () {
expr instanceof SyntaxElementMorph && expr instanceof SyntaxElementMorph &&
!(expr instanceof CommandSlotMorph) && !(expr instanceof CommandSlotMorph) &&
!this.context.isFlashing && !this.context.isFlashing &&
expr.world()) { expr.world() &&
!(expr instanceof ColorSlotMorph)) {
this.unflash(); this.unflash();
expr.flash(); expr.flash();
this.context.isFlashing = true; this.context.isFlashing = true;