Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final Project Submission #48

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2082,6 +2082,18 @@ BlockMorph.prototype.userMenu = function () {
"help...",
'showHelp'
);
menu.addItem(
"color...",
function () {
this.pickColor(
menu.title + '\ncolor:',
this.setColor,
this,
this.color
);
},
'choose the World\'s\nbackground color'
);
if (shiftClicked) {
top = this.topBlock();
if (top instanceof ReporterBlockMorph) {
Expand Down Expand Up @@ -3901,7 +3913,21 @@ HatBlockMorph.prototype.init = function () {
HatBlockMorph.prototype.blockSequence = function () {
// override my inherited method so that I am not part of my sequence
var result = HatBlockMorph.uber.blockSequence.call(this);
result.shift();
var head = result.shift();
if (head.blockSpec === "Debug when %greenflag clicked") {
var debugArr = [];
var index;
var origIndex = 0;
for (index = 0; index < result.length*2; index+=2) {
debugArr[index] = result[origIndex];
var curr = new BlockMorph();
curr.setSpec('pause all %pause');
curr.setSelector('doPauseAll');
debugArr[index+1] = curr;
origIndex += 1;
}
result = debugArr;
}
return result;
};

Expand Down
Binary file removed help/list->sentence.png
Binary file not shown.
Binary file removed help/sentence->list.png
Binary file not shown.
Empty file added ideas
Empty file.
1 change: 0 additions & 1 deletion morphic.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@
Each World has an - invisible - "Hand" resembling the mouse cursor
(or the user's finger on touch screens) which handles mouse events,
and may also have a keyboardReceiver to handle key events.

The basic idea of Morphic is to continuously run display cycles and
to incrementally update the screen by only redrawing those World
regions which have been "dirtied" since the last redraw. Before
Expand Down
28 changes: 24 additions & 4 deletions objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,11 @@ SpriteMorph.prototype.initBlocks = function () {
category: 'control',
spec: 'when %greenflag clicked'
},
receiveDebug: {
type: 'hat',
category: 'control',
spec: 'Debug when %greenflag clicked'
},
receiveKey: {
type: 'hat',
category: 'control',
Expand Down Expand Up @@ -1049,6 +1054,11 @@ SpriteMorph.prototype.initBlocks = function () {
spec: '%txtfun of %s',
defaults: [null, "Abelson & Sussman"]
},
reportFactorial: {
type: 'reporter',
category: 'operators',
spec: '%n !'
},

/*
reportScript: {
Expand Down Expand Up @@ -1254,6 +1264,7 @@ SpriteMorph.prototype.blockAlternatives = {

// control:
receiveGo: ['receiveClick'],
receiveDebug: ['receiveClick'],
receiveClick: ['receiveGo'],
doBroadcast: ['doBroadcastAndWait'],
doBroadcastAndWait: ['doBroadcast'],
Expand All @@ -1270,10 +1281,11 @@ SpriteMorph.prototype.blockAlternatives = {
reportMouseY: ['reportMouseX'],

// operators:
reportSum: ['reportDifference', 'reportProduct', 'reportQuotient'],
reportDifference: ['reportSum', 'reportProduct', 'reportQuotient'],
reportProduct: ['reportDifference', 'reportSum', 'reportQuotient'],
reportQuotient: ['reportDifference', 'reportProduct', 'reportSum'],
reportSum: ['reportDifference', 'reportProduct', 'reportQuotient', 'reportFactorial'],
reportDifference: ['reportSum', 'reportProduct', 'reportQuotient', 'reportFactorial'],
reportProduct: ['reportDifference', 'reportSum', 'reportQuotient', 'reportFactorial'],
reportQuotient: ['reportDifference', 'reportProduct', 'reportSum', 'reportFactorial'],
reportFactorial: ['reportDifference', 'reportProduct', 'reportQuotient', 'reportSum'],
reportLessThan: ['reportEquals', 'reportGreaterThan'],
reportEquals: ['reportLessThan', 'reportGreaterThan'],
reportGreaterThan: ['reportEquals', 'reportLessThan'],
Expand Down Expand Up @@ -1827,6 +1839,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
} else if (cat === 'control') {

blocks.push(block('receiveGo'));
blocks.push(block('receiveDebug'));
blocks.push(block('receiveKey'));
blocks.push(block('receiveClick'));
blocks.push(block('receiveMessage'));
Expand Down Expand Up @@ -1942,6 +1955,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
blocks.push(block('reportDifference'));
blocks.push(block('reportProduct'));
blocks.push(block('reportQuotient'));
blocks.push(block('reportFactorial'));
blocks.push('-');
blocks.push(block('reportModulus'));
blocks.push(block('reportRound'));
Expand Down Expand Up @@ -3489,11 +3503,15 @@ SpriteMorph.prototype.allHatBlocksFor = function (message) {
if (typeof message === 'number') {message = message.toString(); }
return this.scripts.children.filter(function (morph) {
var event;
//if (morph.blockSpec.equals("Debug when %greenflag clicked")
if (morph.selector) {
if (morph.selector === 'receiveMessage') {
event = morph.inputs()[0].evaluate();
return event === message || (event instanceof Array);
}
if (morph.selector === 'receiveDebug') {
return message === '__shout__go__';
}
if (morph.selector === 'receiveGo') {
return message === '__shout__go__';
}
Expand Down Expand Up @@ -4992,6 +5010,7 @@ StageMorph.prototype.blockTemplates = function (category) {
} else if (cat === 'control') {

blocks.push(block('receiveGo'));
blocks.push(block('receiveDebug'));
blocks.push(block('receiveKey'));
blocks.push(block('receiveClick'));
blocks.push(block('receiveMessage'));
Expand Down Expand Up @@ -5101,6 +5120,7 @@ StageMorph.prototype.blockTemplates = function (category) {
blocks.push(block('reportDifference'));
blocks.push(block('reportProduct'));
blocks.push(block('reportQuotient'));
blocks.push(block('reportFactorial'));
blocks.push('-');
blocks.push(block('reportModulus'));
blocks.push(block('reportRound'));
Expand Down
14 changes: 14 additions & 0 deletions plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#Debugging Stepper Implementation Plan

##Modifications to the following classes

-thread.js
-Modification to startProcess in order for detection of debugging mode toggle
-gui.js
-Implementation of the pointer arrow as well as stepping interface for user
control of iteration through block
- Add a stop block which simply acts as a block where we should stop the debugging execution.
- Evaluate code for play/pause buttons and determine how they carry out their functionality
- Using this knowledge generate a stepper button and insert into gui which would then create
-
there is a **allHatBlocksFor** method within objects which determines which kind of hat blocks to add to an array
Loading