summaryrefslogtreecommitdiff
path: root/byob.js
diff options
context:
space:
mode:
Diffstat (limited to 'byob.js')
-rw-r--r--byob.js48
1 files changed, 34 insertions, 14 deletions
diff --git a/byob.js b/byob.js
index b5905ce..4c39872 100644
--- a/byob.js
+++ b/byob.js
@@ -9,7 +9,7 @@
written by Jens Mönig
jens@moenig.org
- Copyright (C) 2014 by Jens Mönig
+ Copyright (C) 2015 by Jens Mönig
This file is part of Snap!.
@@ -106,7 +106,7 @@ SymbolMorph, isNil*/
// Global stuff ////////////////////////////////////////////////////////
-modules.byob = '2014-November-20';
+modules.byob = '2015-June-25';
// Declarations
@@ -209,12 +209,14 @@ CustomBlockDefinition.prototype.copyAndBindTo = function (sprite) {
c.receiver = sprite; // only for (kludgy) serialization
c.declarations = copy(this.declarations); // might have to go deeper
- c.body = Process.prototype.reify.call(
- null,
- this.body.expression,
- new List(this.inputNames())
- );
- c.body.outerContext = null;
+ if (c.body) {
+ c.body = Process.prototype.reify.call(
+ null,
+ this.body.expression,
+ new List(this.inputNames())
+ );
+ c.body.outerContext = null;
+ }
return c;
};
@@ -427,6 +429,7 @@ CustomCommandBlockMorph.prototype.refresh = function () {
// find unnahmed upvars and label them
// to their internal definition (default)
+ this.cachedInputs = null;
this.inputs().forEach(function (inp, idx) {
if (inp instanceof TemplateSlotMorph && inp.contents() === '\u2191') {
inp.setContents(def.inputNames()[idx]);
@@ -441,6 +444,7 @@ CustomCommandBlockMorph.prototype.restoreInputs = function (oldInputs) {
myself = this;
if (this.isPrototype) {return; }
+ this.cachedInputs = null;
this.inputs().forEach(function (inp) {
old = oldInputs[i];
if (old instanceof ReporterBlockMorph &&
@@ -458,6 +462,7 @@ CustomCommandBlockMorph.prototype.restoreInputs = function (oldInputs) {
}
i += 1;
});
+ this.cachedInputs = null;
};
CustomCommandBlockMorph.prototype.refreshDefaults = function () {
@@ -470,6 +475,7 @@ CustomCommandBlockMorph.prototype.refreshDefaults = function () {
}
idx += 1;
});
+ this.cachedInputs = null;
};
CustomCommandBlockMorph.prototype.refreshPrototype = function () {
@@ -922,6 +928,9 @@ CustomReporterBlockMorph.prototype.refresh = function () {
if (!this.isPrototype) {
this.isPredicate = (this.definition.type === 'predicate');
}
+ if (this.parent instanceof SyntaxElementMorph) {
+ this.parent.cachedInputs = null;
+ }
this.drawNew();
};
@@ -1649,7 +1658,7 @@ BlockEditorMorph.prototype.init = function (definition, target) {
scripts = new ScriptsMorph(target);
scripts.isDraggable = false;
scripts.color = IDE_Morph.prototype.groupColor;
- scripts.texture = IDE_Morph.prototype.scriptsPaneTexture;
+ scripts.cachedTexture = IDE_Morph.prototype.scriptsPaneTexture;
scripts.cleanUpMargin = 10;
proto = new PrototypeHatBlockMorph(this.definition);
@@ -1863,6 +1872,9 @@ BlockEditorMorph.prototype.context = function (prototypeHat) {
if (topBlock === null) {
return null;
}
+ topBlock.allChildren().forEach(function (c) {
+ if (c instanceof BlockMorph) {c.cachedInputs = null; }
+ });
stackFrame = Process.prototype.reify.call(
null,
topBlock,
@@ -2037,7 +2049,13 @@ BlockLabelFragment.prototype.defTemplateSpecFragment = function () {
)) {
suff = ' \u03BB';
} else if (this.defaultValue) {
- suff = ' = ' + this.defaultValue.toString();
+ if (this.type === '%n') {
+ suff = ' # = ' + this.defaultValue.toString();
+ } else { // 'any' or 'text'
+ suff = ' = ' + this.defaultValue.toString();
+ }
+ } else if (this.type === '%n') {
+ suff = ' #';
}
return this.labelString + suff;
};
@@ -2972,7 +2990,7 @@ InputSlotDialogMorph.prototype.editSlotOptions = function () {
new DialogBoxMorph(
myself,
function (options) {
- myself.fragment.options = options;
+ myself.fragment.options = options.trim();
},
myself
).promptCode(
@@ -3279,15 +3297,17 @@ BlockExportDialogMorph.prototype.selectNone = function () {
// BlockExportDialogMorph ops
BlockExportDialogMorph.prototype.exportBlocks = function () {
- var str = this.serializer.serialize(this.blocks);
+ var str = encodeURIComponent(
+ this.serializer.serialize(this.blocks)
+ );
if (this.blocks.length > 0) {
- window.open(encodeURI('data:text/xml,<blocks app="'
+ window.open('data:text/xml,<blocks app="'
+ this.serializer.app
+ '" version="'
+ this.serializer.version
+ '">'
+ str
- + '</blocks>'));
+ + '</blocks>');
} else {
new DialogBoxMorph().inform(
'Export blocks',