new "defaults" selector for block attributes

snap8
Jens Mönig 2022-06-28 16:45:56 +02:00
rodzic 4fe18e62ed
commit 563daf55f2
3 zmienionych plików z 26 dodań i 1 usunięć

Wyświetl plik

@ -16,7 +16,7 @@
* new MOUSE POSITION primitive reporter in the SENSING category
* new "position" choice in OF reporter's attribute dropdown, reports a list of XY coordinates
* new "categories" choice in MY reporter's dropdown, reports an ordered list of all category names whose indices match the "category" reported elsewhere
* new "label", "type", "scope", "slots", "menus" and "editables" choices in the OF BLOCK block-attribute reporter's dropdown
* new "label", "type", "scope", "slots", "defaults", "menus" and "editables" choices in the OF BLOCK block-attribute reporter's dropdown
* new "set attribute of block" primitive, experimental
* new "define block" primitive, experimental
* new "this script" primitive, experimental
@ -58,6 +58,7 @@
* German translation update for "menus"
* blocks, threads: new "editables" selector for block attributes (indicates read-only input slots)
* German translation update for "editables"
* blocks, threads: new "defaults" selector for block attributes
### 2022-06-27
* threads: trim block label before identifying existing definition in DEFINE

Wyświetl plik

@ -809,6 +809,7 @@ SyntaxElementMorph.prototype.labelParts = {
'type': ['type'],
'scope': ['scope'],
'slots': ['slots'],
'defaults': ['defaults'],
'menus' : ['menus'],
'editables' : ['editables']
}
@ -823,6 +824,7 @@ SyntaxElementMorph.prototype.labelParts = {
'type': ['type'],
'scope': ['scope'],
'slots': ['slots'],
'defaults': ['defaults'],
'menus' : ['menus'],
'editables' : ['editables']
}

Wyświetl plik

@ -5663,6 +5663,15 @@ Process.prototype.reportBasicBlockAttribute = function (attribute, block) {
each.getSlotSpec() : each.getSpec()
)
).map(spec => this.slotType(spec));
case 'defaults':
slots = new List();
if (expr.isCustomBlock) {
def = (expr.isGlobal ?
expr.definition
: this.blockReceiver().getMethod(expr.semanticSpec));
def.declarations.forEach(value => slots.add(value[1]));
}
return slots;
case 'menus':
slots = new List();
if (expr.isCustomBlock) {
@ -5964,6 +5973,19 @@ Process.prototype.doSetBlockAttribute = function (attribute, block, val) {
}
});
break;
case 'defaults':
this.assertType(val, ['list', 'Boolean', 'number', 'text']);
if (!(val instanceof List)) {
val = new List([val]);
}
def.inputNames().forEach((name, idx) => {
var info = def.declarations.get(name),
options = val.at(idx + 1);
this.assertType(options, ['Boolean', 'number', 'text']);
info[1] = options;
def.declarations.set(name, info);
});
break;
case 'menus':
this.assertType(val, ['list', 'text', 'number']);
if (!(val instanceof List)) {