Skip to content

Commit

Permalink
enabled setting custom blocks labels to (nested) lists of label parts
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoenig committed Aug 12, 2024
1 parent be87c43 commit 25c73cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Snap! (BYOB) History

## in development:
* **Notable Changes:**
* enabled setting custom blocks labels to (nested) lists of label parts, not just in DEFINE but also in SET

### 2024-08-12
* threads: enabled setting custom blocks labels to (nested) lists of label parts

## 10.0.2:
* **Notable Fixes:**
Expand Down
2 changes: 1 addition & 1 deletion snap.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<script src="src/symbols.js?version=2024-01-24"></script>
<script src="src/widgets.js?version=2024-07-24"></script>
<script src="src/blocks.js?version=2024-06-10"></script>
<script src="src/threads.js?version=2024-08-05"></script>
<script src="src/threads.js?version=2024-08-12"></script>
<script src="src/objects.js?version=2024-08-07"></script>
<script src="src/scenes.js?version=2024-05-28"></script>
<script src="src/gui.js?version=2024-08-09"></script>
Expand Down
10 changes: 9 additions & 1 deletion src/threads.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ StagePickerMorph, CustomBlockDefinition, CommentMorph*/

/*jshint esversion: 11, bitwise: false, evil: true*/

modules.threads = '2024-August-05';
modules.threads = '2024-August-12';

var ThreadManager;
var Process;
Expand Down Expand Up @@ -8404,8 +8404,16 @@ Process.prototype.doSetBlockAttribute = function (attribute, block, val) {
(oldType == 'command' && rep.includes(type));
}

function labelFromList(list) {
return list.map(each => each instanceof List ? each.asWords()
: each).asTXT().replaceAll('\n', ' $nl ');
}

switch (choice) {
case 'label':
if (val instanceof List) {
val = labelFromList(val);
}
def.setBlockLabel(val);
break;
case 'comment':
Expand Down

0 comments on commit 25c73cf

Please sign in to comment.