kopia lustrzana https://github.com/backface/turtlestitch
separated global and local variables in the palette, marked local ones with location pin
rodzic
4aa1fac41e
commit
7e74a345e5
27
blocks.js
27
blocks.js
|
@ -1603,8 +1603,8 @@ SyntaxElementMorph.prototype.fixLayout = function (silently) {
|
||||||
lines = [],
|
lines = [],
|
||||||
space = this.isPrototype ?
|
space = this.isPrototype ?
|
||||||
1 : Math.floor(fontHeight(this.fontSize) / 3),
|
1 : Math.floor(fontHeight(this.fontSize) / 3),
|
||||||
ico = this.isCustomBlock && !this.isGlobal ?
|
ico = this instanceof BlockMorph && this.hasLocationPin() ?
|
||||||
this.methodIconExtent().x + space : 0,
|
this.methodIconExtent().x + space : 0,
|
||||||
bottomCorrection,
|
bottomCorrection,
|
||||||
initialExtent = this.extent();
|
initialExtent = this.extent();
|
||||||
|
|
||||||
|
@ -1838,8 +1838,8 @@ SyntaxElementMorph.prototype.fixHighlight = function () {
|
||||||
SyntaxElementMorph.prototype.methodIconExtent = function () {
|
SyntaxElementMorph.prototype.methodIconExtent = function () {
|
||||||
// answer the span of the icon for the "local method" indicator
|
// answer the span of the icon for the "local method" indicator
|
||||||
var ico = this.fontSize * 1.2;
|
var ico = this.fontSize * 1.2;
|
||||||
return this.isCustomBlock && !this.isGlobal ?
|
return this.hasLocationPin() ? new Point(ico * 0.66, ico)
|
||||||
new Point(ico * 0.66, ico) : new Point(0, 0);
|
: new Point(0, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
// SyntaxElementMorph evaluating:
|
// SyntaxElementMorph evaluating:
|
||||||
|
@ -3558,6 +3558,10 @@ BlockMorph.prototype.eraseHoles = function (context) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BlockMorph.prototype.hasLocationPin = function () {
|
||||||
|
return (this.isCustomBlock && !this.isGlobal) || this.isLocalVarTemplate;
|
||||||
|
};
|
||||||
|
|
||||||
// BlockMorph highlighting
|
// BlockMorph highlighting
|
||||||
|
|
||||||
BlockMorph.prototype.addHighlight = function (oldHighlight) {
|
BlockMorph.prototype.addHighlight = function (oldHighlight) {
|
||||||
|
@ -3849,6 +3853,11 @@ BlockMorph.prototype.fullCopy = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
BlockMorph.prototype.reactToTemplateCopy = function () {
|
BlockMorph.prototype.reactToTemplateCopy = function () {
|
||||||
|
if (this.isLocalVarTemplate) {
|
||||||
|
this.isLocalVarTemplate = null;
|
||||||
|
this.drawNew();
|
||||||
|
this.fixLayout();
|
||||||
|
}
|
||||||
this.forceNormalColoring();
|
this.forceNormalColoring();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4627,8 +4636,8 @@ CommandBlockMorph.prototype.drawNew = function () {
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw method icon if applicable
|
// draw location pin icon if applicable
|
||||||
if (this.isCustomBlock && !this.isGlobal) {
|
if (this.hasLocationPin()) {
|
||||||
this.drawMethodIcon(context);
|
this.drawMethodIcon(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5182,6 +5191,7 @@ ReporterBlockMorph.prototype.init = function (isPredicate, silently) {
|
||||||
this.isPredicate = isPredicate || false;
|
this.isPredicate = isPredicate || false;
|
||||||
this.setExtent(new Point(200, 80), silently);
|
this.setExtent(new Point(200, 80), silently);
|
||||||
this.cachedSlotSpec = null; // don't serialize
|
this.cachedSlotSpec = null; // don't serialize
|
||||||
|
this.isLocalVarTemplate = null; // don't serialize
|
||||||
};
|
};
|
||||||
|
|
||||||
// ReporterBlockMorph drag & drop:
|
// ReporterBlockMorph drag & drop:
|
||||||
|
@ -5403,10 +5413,11 @@ ReporterBlockMorph.prototype.drawNew = function () {
|
||||||
this.drawRounded(context);
|
this.drawRounded(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw method icon if applicable
|
// draw location pin icon if applicable
|
||||||
if (this.isCustomBlock && !this.isGlobal) {
|
if (this.hasLocationPin()) {
|
||||||
this.drawMethodIcon(context);
|
this.drawMethodIcon(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// erase CommandSlots
|
// erase CommandSlots
|
||||||
this.eraseHoles(context);
|
this.eraseHoles(context);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3854,12 +3854,13 @@ Fixes:
|
||||||
* Blocks: made the OF-block auto-unringify when dropped on ring-slots
|
* Blocks: made the OF-block auto-unringify when dropped on ring-slots
|
||||||
* Blocks: disabled firing the Custom-Block-Dialog when accidentall clicking on a custom block definition script
|
* Blocks: disabled firing the Custom-Block-Dialog when accidentall clicking on a custom block definition script
|
||||||
|
|
||||||
180121
|
180122
|
||||||
------
|
------
|
||||||
* Morphic: fixed occasional stuck cursors, thanks, Bernat!
|
* Morphic: fixed occasional stuck cursors, thanks, Bernat!
|
||||||
* Paint: fixed a flood-fill alpha issue, thanks, Bernat!I
|
* Paint: fixed a flood-fill alpha issue, thanks, Bernat!I
|
||||||
* Blocks, GUI: minor fixes, contributed by the community
|
* Blocks, GUI: minor fixes, contributed by the community
|
||||||
* various Translation updates, contributed by the community
|
* various Translation updates, contributed by the community
|
||||||
|
* Blocks, Objects, Threads: separated global and local variables in the palette, marked local ones with location pin
|
||||||
|
|
||||||
|
|
||||||
v4.1.1 New Features:
|
v4.1.1 New Features:
|
||||||
|
@ -3869,8 +3870,9 @@ v4.1.1 New Features:
|
||||||
* added "width" and "height" selectors to Pixels library
|
* added "width" and "height" selectors to Pixels library
|
||||||
|
|
||||||
Notable Changes:
|
Notable Changes:
|
||||||
|
* global and local variables are now separat in the palette, each sorted alphabetically, local vars marked with location pin (only in palette)
|
||||||
* keyboard events are now always thread safe (the same as in Scratch nowadays)
|
* keyboard events are now always thread safe (the same as in Scratch nowadays)
|
||||||
* the OF-block auto-unringified when being dropped on ring-slots, such as in CALL
|
* the OF-block auto-unringifies when being dropped on ring-slots, such as in CALL
|
||||||
* accidentally clicking on a custom block definition no longer fires up the Block Dialog
|
* accidentally clicking on a custom block definition no longer fires up the Block Dialog
|
||||||
|
|
||||||
Notable Fixes:
|
Notable Fixes:
|
||||||
|
|
75
objects.js
75
objects.js
|
@ -1751,11 +1751,12 @@ SpriteMorph.prototype.blockForSelector = function (selector, setDefaults) {
|
||||||
return block;
|
return block;
|
||||||
};
|
};
|
||||||
|
|
||||||
SpriteMorph.prototype.variableBlock = function (varName) {
|
SpriteMorph.prototype.variableBlock = function (varName, isLocalTemplate) {
|
||||||
var block = new ReporterBlockMorph(false);
|
var block = new ReporterBlockMorph(false);
|
||||||
block.selector = 'reportGetVar';
|
block.selector = 'reportGetVar';
|
||||||
block.color = this.blockColor.variables;
|
block.color = this.blockColor.variables;
|
||||||
block.category = 'variables';
|
block.category = 'variables';
|
||||||
|
block.isLocalVarTemplate = isLocalTemplate;
|
||||||
block.setSpec(varName);
|
block.setSpec(varName);
|
||||||
block.isDraggable = true;
|
block.isDraggable = true;
|
||||||
return block;
|
return block;
|
||||||
|
@ -1778,8 +1779,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
||||||
return newBlock;
|
return newBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
function variableBlock(varName) {
|
function variableBlock(varName, isLocal) {
|
||||||
var newBlock = SpriteMorph.prototype.variableBlock(varName);
|
var newBlock = SpriteMorph.prototype.variableBlock(varName, isLocal);
|
||||||
newBlock.isDraggable = false;
|
newBlock.isDraggable = false;
|
||||||
newBlock.isTemplate = true;
|
newBlock.isTemplate = true;
|
||||||
if (contains(inheritedVars, varName)) {
|
if (contains(inheritedVars, varName)) {
|
||||||
|
@ -2195,7 +2196,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
||||||
|
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
|
|
||||||
varNames = this.variables.allNames();
|
varNames = this.reachableGlobalVariableNames(true);
|
||||||
if (varNames.length > 0) {
|
if (varNames.length > 0) {
|
||||||
varNames.forEach(function (name) {
|
varNames.forEach(function (name) {
|
||||||
blocks.push(variableWatcherToggle(name));
|
blocks.push(variableWatcherToggle(name));
|
||||||
|
@ -2204,6 +2205,15 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
varNames = this.allLocalVariableNames(true);
|
||||||
|
if (varNames.length > 0) {
|
||||||
|
varNames.forEach(function (name) {
|
||||||
|
blocks.push(variableWatcherToggle(name));
|
||||||
|
blocks.push(variableBlock(name, true));
|
||||||
|
});
|
||||||
|
blocks.push('-');
|
||||||
|
}
|
||||||
|
|
||||||
blocks.push(block('doSetVar'));
|
blocks.push(block('doSetVar'));
|
||||||
blocks.push(block('doChangeVar'));
|
blocks.push(block('doChangeVar'));
|
||||||
blocks.push(block('doShowVar'));
|
blocks.push(block('doShowVar'));
|
||||||
|
@ -5735,6 +5745,41 @@ SpriteMorph.prototype.hasSpriteVariable = function (varName) {
|
||||||
return contains(this.variables.names(), varName);
|
return contains(this.variables.names(), varName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SpriteMorph.prototype.allLocalVariableNames = function (sorted) {
|
||||||
|
var exceptGlobals = this.globalVariables(),
|
||||||
|
globalNames = exceptGlobals.names(),
|
||||||
|
data;
|
||||||
|
|
||||||
|
function alphabetically(x, y) {
|
||||||
|
return x.toLowerCase() < y.toLowerCase() ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = this.variables.allNames(exceptGlobals).filter(function (each) {
|
||||||
|
return !contains(globalNames, each);
|
||||||
|
});
|
||||||
|
if (sorted) {
|
||||||
|
data.sort(alphabetically);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
SpriteMorph.prototype.reachableGlobalVariableNames = function (sorted) {
|
||||||
|
var locals = this.allLocalVariableNames(),
|
||||||
|
data;
|
||||||
|
|
||||||
|
function alphabetically(x, y) {
|
||||||
|
return x.toLowerCase() < y.toLowerCase() ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = this.globalVariables().names().filter(function (each) {
|
||||||
|
return !contains(locals, each);
|
||||||
|
});
|
||||||
|
if (sorted) {
|
||||||
|
data.sort(alphabetically);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
// SpriteMorph inheritance - custom blocks
|
// SpriteMorph inheritance - custom blocks
|
||||||
|
|
||||||
SpriteMorph.prototype.getMethod = function (spec) {
|
SpriteMorph.prototype.getMethod = function (spec) {
|
||||||
|
@ -6927,13 +6972,14 @@ StageMorph.prototype.blockTemplates = function (category) {
|
||||||
return newBlock;
|
return newBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
function variableBlock(varName) {
|
function variableBlock(varName, isLocal) {
|
||||||
var newBlock = SpriteMorph.prototype.variableBlock(varName);
|
var newBlock = SpriteMorph.prototype.variableBlock(varName, isLocal);
|
||||||
newBlock.isDraggable = false;
|
newBlock.isDraggable = false;
|
||||||
newBlock.isTemplate = true;
|
newBlock.isTemplate = true;
|
||||||
return newBlock;
|
return newBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function watcherToggle(selector) {
|
function watcherToggle(selector) {
|
||||||
if (myself.hiddenPrimitives[selector]) {
|
if (myself.hiddenPrimitives[selector]) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -7267,7 +7313,7 @@ StageMorph.prototype.blockTemplates = function (category) {
|
||||||
|
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
|
|
||||||
varNames = this.variables.allNames();
|
varNames = this.reachableGlobalVariableNames(true);
|
||||||
if (varNames.length > 0) {
|
if (varNames.length > 0) {
|
||||||
varNames.forEach(function (name) {
|
varNames.forEach(function (name) {
|
||||||
blocks.push(variableWatcherToggle(name));
|
blocks.push(variableWatcherToggle(name));
|
||||||
|
@ -7276,6 +7322,15 @@ StageMorph.prototype.blockTemplates = function (category) {
|
||||||
blocks.push('-');
|
blocks.push('-');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
varNames = this.allLocalVariableNames(true);
|
||||||
|
if (varNames.length > 0) {
|
||||||
|
varNames.forEach(function (name) {
|
||||||
|
blocks.push(variableWatcherToggle(name));
|
||||||
|
blocks.push(variableBlock(name, true));
|
||||||
|
});
|
||||||
|
blocks.push('-');
|
||||||
|
}
|
||||||
|
|
||||||
blocks.push(block('doSetVar'));
|
blocks.push(block('doSetVar'));
|
||||||
blocks.push(block('doChangeVar'));
|
blocks.push(block('doChangeVar'));
|
||||||
blocks.push(block('doShowVar'));
|
blocks.push(block('doShowVar'));
|
||||||
|
@ -7698,6 +7753,12 @@ StageMorph.prototype.inheritedVariableNames = function () {
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
StageMorph.prototype.allLocalVariableNames
|
||||||
|
= SpriteMorph.prototype.allLocalVariableNames;
|
||||||
|
|
||||||
|
StageMorph.prototype.reachableGlobalVariableNames
|
||||||
|
= SpriteMorph.prototype.reachableGlobalVariableNames;
|
||||||
|
|
||||||
// StageMorph inheritance - custom blocks
|
// StageMorph inheritance - custom blocks
|
||||||
|
|
||||||
StageMorph.prototype.getMethod
|
StageMorph.prototype.getMethod
|
||||||
|
|
12
threads.js
12
threads.js
|
@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy,
|
||||||
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
|
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
|
||||||
TableFrameMorph, ColorSlotMorph, isSnapObject*/
|
TableFrameMorph, ColorSlotMorph, isSnapObject*/
|
||||||
|
|
||||||
modules.threads = '2018-January-21';
|
modules.threads = '2018-January-22';
|
||||||
|
|
||||||
var ThreadManager;
|
var ThreadManager;
|
||||||
var Process;
|
var Process;
|
||||||
|
@ -4100,7 +4100,8 @@ VariableFrame.prototype.names = function () {
|
||||||
return names;
|
return names;
|
||||||
};
|
};
|
||||||
|
|
||||||
VariableFrame.prototype.allNamesDict = function () {
|
VariableFrame.prototype.allNamesDict = function (upTo) {
|
||||||
|
// "upTo" is an optional parent frame at which to stop, e.g. globals
|
||||||
var dict = {}, current = this;
|
var dict = {}, current = this;
|
||||||
|
|
||||||
function addKeysToDict(srcDict, trgtDict) {
|
function addKeysToDict(srcDict, trgtDict) {
|
||||||
|
@ -4112,19 +4113,20 @@ VariableFrame.prototype.allNamesDict = function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (current) {
|
while (current && (current !== upTo)) {
|
||||||
addKeysToDict(current.vars, dict);
|
addKeysToDict(current.vars, dict);
|
||||||
current = current.parentFrame;
|
current = current.parentFrame;
|
||||||
}
|
}
|
||||||
return dict;
|
return dict;
|
||||||
};
|
};
|
||||||
|
|
||||||
VariableFrame.prototype.allNames = function () {
|
VariableFrame.prototype.allNames = function (upTo) {
|
||||||
/*
|
/*
|
||||||
only show the names of the lexical scope, hybrid scoping is
|
only show the names of the lexical scope, hybrid scoping is
|
||||||
reserved to the daring ;-)
|
reserved to the daring ;-)
|
||||||
|
"upTo" is an optional parent frame at which to stop, e.g. globals
|
||||||
*/
|
*/
|
||||||
var answer = [], each, dict = this.allNamesDict();
|
var answer = [], each, dict = this.allNamesDict(upTo);
|
||||||
|
|
||||||
for (each in dict) {
|
for (each in dict) {
|
||||||
if (Object.prototype.hasOwnProperty.call(dict, each)) {
|
if (Object.prototype.hasOwnProperty.call(dict, each)) {
|
||||||
|
|
Ładowanie…
Reference in New Issue