diff options
| author | jmoenig <jens@moenig.org> | 2013-07-31 15:15:27 +0200 |
|---|---|---|
| committer | jmoenig <jens@moenig.org> | 2013-07-31 15:15:27 +0200 |
| commit | 6fa1fcd87637cae8f0ad76951b7b389db6bfa969 (patch) | |
| tree | bbe58828c6572490023a74b8710211854f537f2c | |
| parent | e062dfe54862012a6d2fbe4044462c8bc2696711 (diff) | |
| download | snap-byow-6fa1fcd87637cae8f0ad76951b7b389db6bfa969.tar.gz snap-byow-6fa1fcd87637cae8f0ad76951b7b389db6bfa969.zip | |
experimental text SPLIT primitive in the operators category
(currently only accessible in dev mode)
| -rw-r--r-- | blocks.js | 12 | ||||
| -rwxr-xr-x | history.txt | 4 | ||||
| -rw-r--r-- | objects.js | 10 | ||||
| -rw-r--r-- | threads.js | 14 |
4 files changed, 37 insertions, 3 deletions
@@ -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 @@ -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')); } ////////////////////////////////// @@ -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) { |
