Skip to content
This repository has been archived by the owner on Jul 17, 2019. It is now read-only.

Commit

Permalink
Merge pull request #21 from Nestor94Gonzalez/new-build
Browse files Browse the repository at this point in the history
Fixed block id encoding issue & changed find path block color to match Erle-Brain category
  • Loading branch information
vmayoral committed Apr 20, 2016
2 parents 7650c6c + 0103e05 commit a0d8914
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
9 changes: 5 additions & 4 deletions blockly_compressed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion blocks/erle-brain.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Blockly.Blocks['find_path'] = {
.appendField("Find path");
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(260);
this.setColour(0);
this.setTooltip('');
this.setHelpUrl('http://erlerobotics.com/docs/Robot_Operating_System/ROS/Blockly/Intro.html');
}
Expand Down
2 changes: 1 addition & 1 deletion blocks_compressed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions core/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ Blockly.Generator.prototype.blockToCode = function(block) {
return [this.scrub_(block, code[0]), code[1]];
} else if (goog.isString(code)) {
if (this.STATEMENT_PREFIX) {
code = this.STATEMENT_PREFIX.replace(/%1/g, '\'' + block.id + '\'') +
code;
// Escaping all $ signs by $$ for replace function
var regexp_ready_block_id = block.id.replace(/\$/g, "$$$$");
code = this.STATEMENT_PREFIX.replace(/%1/g,
'\'' + regexp_ready_block_id + '\'') + code;
}
return this.scrub_(block, code);
} else if (code === null) {
Expand Down Expand Up @@ -257,12 +259,15 @@ Blockly.Generator.prototype.statementToCode = function(block, name) {
* @return {string} Loop contents, with infinite loop trap added.
*/
Blockly.Generator.prototype.addLoopTrap = function(branch, id) {
// Escaping all $ signs by $$ for replace function
var regexp_ready_block_id = id.replace(/\$/g, "$$$$");
if (this.INFINITE_LOOP_TRAP) {
branch = this.INFINITE_LOOP_TRAP.replace(/%1/g, '\'' + id + '\'') + branch;
branch = this.INFINITE_LOOP_TRAP.replace(/%1/g,
'\'' + regexp_ready_block_id + '\'') + branch;
}
if (this.STATEMENT_PREFIX) {
branch += this.prefixLines(this.STATEMENT_PREFIX.replace(/%1/g,
'\'' + id + '\''), this.INDENT);
'\'' + regexp_ready_block_id + '\''), this.INDENT);
}
return branch;
};
Expand Down
6 changes: 4 additions & 2 deletions generators/python/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ Blockly.Python['procedures_defreturn'] = function(block) {
var funcName = Blockly.Python.variableDB_.getName(block.getFieldValue('NAME'),
Blockly.Procedures.NAME_TYPE);
var branch = Blockly.Python.statementToCode(block, 'STACK');
// Escaping all $ signs by $$ for replace function
var regexp_ready_block_id = block.id.replace(/\$/g, "$$$$");
if (Blockly.Python.STATEMENT_PREFIX) {
branch = Blockly.Python.prefixLines(
Blockly.Python.STATEMENT_PREFIX.replace(/%1/g,
'\'' + block.id + '\''), Blockly.Python.INDENT) + branch;
'\'' + regexp_ready_block_id + '\''), Blockly.Python.INDENT) + branch;
}
if (Blockly.Python.INFINITE_LOOP_TRAP) {
branch = Blockly.Python.INFINITE_LOOP_TRAP.replace(/%1/g,
'"' + block.id + '"') + branch;
'"' + regexp_ready_block_id + '"') + branch;
}
var returnValue = Blockly.Python.valueToCode(block, 'RETURN',
Blockly.Python.ORDER_NONE) || '';
Expand Down
4 changes: 2 additions & 2 deletions python_compressed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a0d8914

Please sign in to comment.