kopia lustrzana https://github.com/backface/turtlestitch
PAUSE primitive command block
rodzic
20c1d4d14f
commit
1591466317
10
blocks.js
10
blocks.js
|
@ -1196,6 +1196,16 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
|||
new Point() : this.embossing;
|
||||
part.drawNew();
|
||||
break;
|
||||
case '%pause':
|
||||
part = new SymbolMorph('pause');
|
||||
part.size = this.fontSize;
|
||||
part.color = new Color(160, 80, 0);
|
||||
part.isProtectedLabel = true; // doesn't participate in zebraing
|
||||
part.shadowColor = this.color.darker(this.labelContrast);
|
||||
part.shadowOffset = MorphicPreferences.isFlat ?
|
||||
new Point() : this.embossing;
|
||||
part.drawNew();
|
||||
break;
|
||||
default:
|
||||
// nop();
|
||||
}
|
||||
|
|
|
@ -1827,4 +1827,4 @@ ______
|
|||
130730
|
||||
------
|
||||
* 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
|
||||
|
|
19
objects.js
19
objects.js
|
@ -123,7 +123,7 @@ PrototypeHatBlockMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.objects = '2013-July-15';
|
||||
modules.objects = '2013-July-30';
|
||||
|
||||
var SpriteMorph;
|
||||
var StageMorph;
|
||||
|
@ -662,6 +662,14 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
spec: 'delete this clone'
|
||||
},
|
||||
|
||||
// Debugging - pausing
|
||||
|
||||
doPauseAll: {
|
||||
type: 'command',
|
||||
category: 'control',
|
||||
spec: 'pause all %pause'
|
||||
},
|
||||
|
||||
// Sensing
|
||||
|
||||
reportTouchingObject: {
|
||||
|
@ -1613,6 +1621,8 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push(block('receiveOnClone'));
|
||||
blocks.push(block('createClone'));
|
||||
blocks.push(block('removeClone'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('doPauseAll'));
|
||||
|
||||
} else if (cat === 'sensing') {
|
||||
|
||||
|
@ -3701,7 +3711,10 @@ StageMorph.prototype.fireStopAllEvent = function () {
|
|||
});
|
||||
this.removeAllClones();
|
||||
if (ide) {
|
||||
ide.controlBar.pauseButton.refresh();
|
||||
ide.nextSteps([
|
||||
nop,
|
||||
function () {ide.controlBar.pauseButton.refresh(); }
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -3878,6 +3891,8 @@ StageMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push(block('reportCallCC'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('createClone'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('doPauseAll'));
|
||||
|
||||
} else if (cat === 'sensing') {
|
||||
|
||||
|
|
20
threads.js
20
threads.js
|
@ -83,7 +83,7 @@ ArgLabelMorph, localize, XML_Element, hex_sha512*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.threads = '2013-July-15';
|
||||
modules.threads = '2013-July-30';
|
||||
|
||||
var ThreadManager;
|
||||
var Process;
|
||||
|
@ -339,7 +339,7 @@ Process.prototype.runStep = function () {
|
|||
a step is an an uninterruptable 'atom', it can consist
|
||||
of several contexts, even of several blocks
|
||||
*/
|
||||
if (this.isPaused) {
|
||||
if (this.isPaused) { // allow pausing in between atomic steps:
|
||||
return this.pauseStep();
|
||||
}
|
||||
this.readyToYield = false;
|
||||
|
@ -348,6 +348,10 @@ Process.prototype.runStep = function () {
|
|||
&& (this.isAtomic ?
|
||||
(Date.now() - this.lastYield < this.timeout) : true)
|
||||
) {
|
||||
// also allow pausing inside atomic steps - for PAUSE block primitive:
|
||||
if (this.isPaused) {
|
||||
return this.pauseStep();
|
||||
}
|
||||
this.evaluateContext();
|
||||
}
|
||||
this.lastYield = Date.now();
|
||||
|
@ -1433,6 +1437,18 @@ Process.prototype.doSetFastTracking = function (bool) {
|
|||
}
|
||||
};
|
||||
|
||||
Process.prototype.doPauseAll = function () {
|
||||
var stage, ide;
|
||||
if (this.homeContext.receiver) {
|
||||
stage = this.homeContext.receiver.parentThatIsA(StageMorph);
|
||||
if (stage) {
|
||||
stage.threads.pauseAll(stage);
|
||||
}
|
||||
ide = stage.parentThatIsA(IDE_Morph);
|
||||
if (ide) {ide.controlBar.pauseButton.refresh(); }
|
||||
}
|
||||
};
|
||||
|
||||
// Process loop primitives
|
||||
|
||||
Process.prototype.doForever = function (body) {
|
||||
|
|
Ładowanie…
Reference in New Issue