From 6fa1fcd87637cae8f0ad76951b7b389db6bfa969 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 31 Jul 2013 15:15:27 +0200 Subject: experimental text SPLIT primitive in the operators category (currently only accessible in dev mode) --- blocks.js | 12 +++++++++++- history.txt | 4 ++++ objects.js | 10 +++++++++- threads.js | 14 +++++++++++++- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/blocks.js b/blocks.js index a955a7f..d58474e 100644 --- a/blocks.js +++ b/blocks.js @@ -155,7 +155,7 @@ DialogBoxMorph, BlockInputFragmentMorph, PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.blocks = '2013-July-30'; +modules.blocks = '2013-July-31'; var SyntaxElementMorph; var BlockMorph; @@ -793,6 +793,16 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { true // read-only ); break; + case '%delim': + part = new InputSlotMorph( + null, // text + false, // numeric? + { + '--line--' : ['--line--'] + }, + false // read-only + ); + break; case '%ida': part = new InputSlotMorph( null, diff --git a/history.txt b/history.txt index a791c96..f60dd59 100755 --- a/history.txt +++ b/history.txt @@ -1829,3 +1829,7 @@ ______ * Blocks: Made it harder to drop reporters on the variadic input per se (as opposed to into one of its slots) in (default) "prefer empty slot drops" setting * Blocks, Threads, Objects: PAUSE primitive command block * GUI: fixed #104 (storing a cloud project under another name causes media loss) + +130731 +------ +* Blocks, Threads, Objects: experimental text SPLIT primitive in the operators category diff --git a/objects.js b/objects.js index 3c566e9..c843de9 100644 --- a/objects.js +++ b/objects.js @@ -123,7 +123,7 @@ PrototypeHatBlockMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.objects = '2013-July-30'; +modules.objects = '2013-July-31'; var SpriteMorph; var StageMorph; @@ -932,6 +932,12 @@ SpriteMorph.prototype.initBlocks = function () { spec: '%txtfun of %s', defaults: [null, "Abelson & Sussman"] }, + reportTextSplit: { // only in dev mode - experimental + type: 'reporter', + category: 'operators', + spec: 'split %s by %delim', + defaults: ["foo bar baz", " "] + }, /* reportScript: { @@ -1721,6 +1727,7 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportTypeOf')); blocks.push(block('reportTextFunction')); + blocks.push(block('reportTextSplit')); } ///////////////////////////////// @@ -3987,6 +3994,7 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportTypeOf')); blocks.push(block('reportTextFunction')); + blocks.push(block('reportTextSplit')); } ////////////////////////////////// diff --git a/threads.js b/threads.js index 0674d94..6b73164 100644 --- a/threads.js +++ b/threads.js @@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/ // Global stuff //////////////////////////////////////////////////////// -modules.threads = '2013-July-30'; +modules.threads = '2013-July-31'; var ThreadManager; var Process; @@ -2000,6 +2000,18 @@ Process.prototype.reportUnicodeAsLetter = function (num) { return String.fromCharCode(code); }; +Process.prototype.reportTextSplit = function (string, delimiter) { + var str = (string || '').toString(), + del; + + if (this.inputOption(delimiter) === '--line--') { + del = '\n'; + } else { + del = (delimiter || '').toString(); + } + return new List(str.split(del)); +}; + // Process debugging Process.prototype.alert = function (data) { -- cgit v1.3.1