Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.
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
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
This is the source code for the Snap! Virtual programming language.
# Snap--Disable-Tool

EDIT 12/04/2015: Try it out - grab a motion block, right click, select 'disable' and see what happens.

Description of project idea:
This project will add an "inline comment" functionality to the SNAP! programming language source code through the addition of a 'Disable' button. If the user clicks "disable" the block will turn grey or black and will be skipped when they run the code. Michael and I thought this was a crucial and important feature that would help students using Snap!, especially since this is possible in professional coding languages.

Implementation of project idea:
We will be looking for the files where the code is executed, and add in options for disabling and undoing the disable. This will most likely be the most difficult part. We will also need to look for the file that changes the look of the block so that when the disable button is hit, the block turns grey. Lastly, we need to make sure that users are still able to run their code even after commenting a certain part out.

If somehow we do happen to finish this project with relative ease, Michael and I talked about some other enhancements that we could also do.

Group members:
Michael Ferrin
Angela Kwon
17 changes: 16 additions & 1 deletion blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2270,6 +2270,15 @@ BlockMorph.prototype.userMenu = function () {
}
}

//--------------------Disable–------------------
menu.addItem(
"disable",
function () {
myself.alternateBlockColor();
}
);
//----------------------------------------------

menu.addItem(
"duplicate",
function () {
Expand Down Expand Up @@ -3197,7 +3206,13 @@ BlockMorph.prototype.mouseClickLeft = function () {
if (receiver) {
stage = receiver.parentThatIsA(StageMorph);
if (stage) {
stage.threads.toggleProcess(top);
var clr = SpriteMorph.prototype.blockColor[this.category];

if (this.color.eq(clr)) {
stage.threads.toggleProcess(top, 0);
} else {
stage.threads.toggleProcess(top, 1);
}
}
}
};
Expand Down
15 changes: 10 additions & 5 deletions objects.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ var WatcherMorph;
var StagePrompterMorph;
var Note;
var SpriteHighlightMorph;
//--------------------------Disable--------------
var disable = false;

// SpriteMorph /////////////////////////////////////////////////////////

Expand Down Expand Up @@ -177,7 +179,9 @@ SpriteMorph.prototype.blockColor = {
operators : new Color(98, 194, 19),
variables : new Color(243, 118, 29),
lists : new Color(217, 77, 17),
other: new Color(150, 150, 150)
other: new Color(150, 150, 150),
//--------------Disable-------------------
disable : new Color(0, 0, 0)
};

SpriteMorph.prototype.paletteColor = new Color(55, 55, 55);
Expand All @@ -201,7 +205,6 @@ SpriteMorph.prototype.bubbleMaxTextWidth = 130;

SpriteMorph.prototype.initBlocks = function () {
SpriteMorph.prototype.blocks = {

// Motion
forward: {
only: SpriteMorph,
Expand All @@ -213,6 +216,7 @@ SpriteMorph.prototype.initBlocks = function () {
turn: {
only: SpriteMorph,
type: 'command',
//------------Disable------------------
category: 'motion',
spec: 'turn %clockwise %n degrees',
defaults: [15]
Expand Down Expand Up @@ -3445,15 +3449,15 @@ SpriteMorph.prototype.setPosition = function (aPoint, justMe) {

SpriteMorph.prototype.forward = function (steps) {
var dest,
dist = steps * this.parent.scale || 0;
dist = steps * this.parent.scale || 0;

if (dist >= 0) {
dest = this.position().distanceAngle(dist, this.heading);
} else {
dest = this.position().distanceAngle(
Math.abs(dist),
(this.heading - 180)
);
);
}
this.setPosition(dest);
this.positionTalkBubble();
Expand Down Expand Up @@ -3494,6 +3498,7 @@ SpriteMorph.prototype.faceToXY = function (x, y) {
};

SpriteMorph.prototype.turn = function (degrees) {
//---------------------Disable----------------------
this.setHeading(this.heading + (+degrees || 0));
};

Expand Down Expand Up @@ -3694,7 +3699,7 @@ SpriteMorph.prototype.allHatBlocksForInteraction = function (interaction) {
// SpriteMorph events

SpriteMorph.prototype.mouseClickLeft = function () {
return this.receiveUserInteraction('clicked');
//return this.receiveUserInteraction('clicked');
};

SpriteMorph.prototype.mouseEnter = function () {
Expand Down
17 changes: 16 additions & 1 deletion threads.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ var Process;
var Context;
var VariableFrame;

var mCol = 'rgba(74,108,212,1)'
var loCol = 'rgba(143,86,227,1)'
var sCol = 'rgba(207,74,217,1)'
var pCol = 'rgba(0,161,120,1)'
var cCol = 'rgba(230,168,34,1)'
var sCol = 'rgba(4,148,220,1)'
var opCol = 'rgba(98,194,19,1)'
var vCol = 'rgba(243,118,29,1)'
var liCol = 'rgba(217,77,17,1)'
var otCol = 'rgba(150,150,150,1)'


function snapEquals(a, b) {
if (a instanceof List || (b instanceof List)) {
if (a instanceof List && (b instanceof List)) {
Expand Down Expand Up @@ -486,6 +498,9 @@ Process.prototype.evaluateContext = function () {

Process.prototype.evaluateBlock = function (block, argCount) {
// check for special forms
var clr = SpriteMorph.prototype.blockColor[block.category];
var bc = block.color

if (contains(['reportOr', 'reportAnd', 'doReport'], block.selector)) {
return this[block.selector](block);
}
Expand All @@ -494,7 +509,7 @@ Process.prototype.evaluateBlock = function (block, argCount) {
var rcvr = this.context.receiver || this.topBlock.receiver(),
inputs = this.context.inputs;

if (argCount > inputs.length) {
if (argCount > inputs.length && bc == clr) {
this.evaluateNextInput(block);
} else {
if (this[block.selector]) {
Expand Down