variadic input slot refactorings in blocks.js

pull/95/head
jmoenig 2020-04-29 15:58:48 +02:00
rodzic 783de02b8b
commit 3d79e3c71a
1 zmienionych plików z 15 dodań i 20 usunięć

Wyświetl plik

@ -10545,9 +10545,7 @@ TextSlotMorph.prototype.getSpec = function () {
TextSlotMorph.prototype.contents = function () { TextSlotMorph.prototype.contents = function () {
return detect( return detect(
this.children, this.children,
function (child) { child => child instanceof TextMorph
return (child instanceof TextMorph);
}
); );
}; };
@ -11001,7 +10999,7 @@ MultiArgMorph.prototype.fixHolesLayout = function () {
}; };
MultiArgMorph.prototype.refresh = function () { MultiArgMorph.prototype.refresh = function () {
this.inputs().forEach(function (input) { this.inputs().forEach(input => {
input.fixLayout(); input.fixLayout();
input.rerender(); input.rerender();
}); });
@ -11127,8 +11125,7 @@ MultiArgMorph.prototype.mouseClickLeft = function (pos) {
MultiArgMorph.prototype.userMenu = function () { MultiArgMorph.prototype.userMenu = function () {
var menu = new MenuMorph(this), var menu = new MenuMorph(this),
block = this.parentThatIsA(BlockMorph), block = this.parentThatIsA(BlockMorph),
key = '', key = '';
myself = this;
if (!StageMorph.prototype.enableCodeMapping) { if (!StageMorph.prototype.enableCodeMapping) {
return this.parent.userMenu(); return this.parent.userMenu();
} }
@ -11141,15 +11138,15 @@ MultiArgMorph.prototype.userMenu = function () {
} }
menu.addItem( menu.addItem(
'code list mapping...', 'code list mapping...',
function () {myself.mapCodeList(key); } () => this.mapCodeList(key)
); );
menu.addItem( menu.addItem(
'code item mapping...', 'code item mapping...',
function () {myself.mapCodeItem(key); } () => this.mapCodeItem(key)
); );
menu.addItem( menu.addItem(
'code delimiter mapping...', 'code delimiter mapping...',
function () {myself.mapCodeDelimiter(key); } () => this.mapCodeDelimiter(key)
); );
return menu; return menu;
}; };
@ -11178,9 +11175,7 @@ MultiArgMorph.prototype.mapToCode = function (key, label) {
// private - open a dialog box letting the user map code via the GUI // private - open a dialog box letting the user map code via the GUI
new DialogBoxMorph( new DialogBoxMorph(
this, this,
function (code) { code => StageMorph.prototype.codeMappings[key] = code,
StageMorph.prototype.codeMappings[key] = code;
},
this this
).promptCode( ).promptCode(
'Code mapping - ' + label, 'Code mapping - ' + label,
@ -11211,10 +11206,10 @@ MultiArgMorph.prototype.mappedCode = function (definitions) {
itemCode = StageMorph.prototype.codeMappings[key + 'item'] || '<#1>'; itemCode = StageMorph.prototype.codeMappings[key + 'item'] || '<#1>';
delim = StageMorph.prototype.codeMappings[key + 'delim'] || ' '; delim = StageMorph.prototype.codeMappings[key + 'delim'] || ' ';
this.inputs().forEach(function (input) { this.inputs().forEach(input =>
parts.push(itemCode.replace(/<#1>/g, input.mappedCode(definitions))); parts.push(itemCode.replace(/<#1>/g, input.mappedCode(definitions)))
}); );
parts.forEach(function (part) { parts.forEach(part => {
if (count) { if (count) {
items += delim; items += delim;
} }
@ -11232,9 +11227,9 @@ MultiArgMorph.prototype.evaluate = function () {
// 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(slot =>
result.push(slot.evaluate()); result.push(slot.evaluate())
}); );
return result; return result;
}; };
@ -11328,7 +11323,7 @@ ArgLabelMorph.prototype.fixLayout = function () {
}; };
ArgLabelMorph.prototype.refresh = function () { ArgLabelMorph.prototype.refresh = function () {
this.inputs().forEach(function (input) { this.inputs().forEach(input => {
input.fixLayout(); input.fixLayout();
input.rerender(); input.rerender();
}); });