smalruby-editor 0.1.20-x86-mingw32 → 0.1.21-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/app/assets/javascripts/blocks/character.js.coffee.erb +3 -10
- data/app/assets/javascripts/blocks/control.js.coffee.erb +2 -1
- data/app/assets/javascripts/blocks/data.js.coffee.erb +2 -1
- data/app/assets/javascripts/blocks/etc.js.coffee.erb +2 -1
- data/app/assets/javascripts/blocks/events.js.coffee.erb +5 -4
- data/app/assets/javascripts/blocks/field_character.js.coffee.erb +9 -0
- data/app/assets/javascripts/blocks/hardware.js.coffee.erb +171 -54
- data/app/assets/javascripts/blocks/looks.js.coffee.erb +2 -1
- data/app/assets/javascripts/blocks/motion.js.coffee.erb +4 -16
- data/app/assets/javascripts/blocks/operators.js.coffee.erb +2 -1
- data/app/assets/javascripts/blocks/pen.js.coffee.erb +2 -1
- data/app/assets/javascripts/blocks/ruby.js.coffee.erb +2 -1
- data/app/assets/javascripts/blocks/sensing.js.coffee.erb +25 -3
- data/app/assets/javascripts/blocks/sound.js.coffee.erb +2 -1
- data/app/assets/javascripts/generators/ruby.js.coffee.erb +27 -5
- data/app/assets/javascripts/models/source_code.js.coffee +20 -7
- data/app/assets/javascripts/views/main_menu_view.js.coffee +5 -7
- data/app/assets/stylesheets/editor.css.scss +5 -1
- data/app/assets/stylesheets/toolbox.css.scss.erb +29 -24
- data/app/controllers/source_codes_controller.rb +7 -36
- data/app/helpers/editor_helper.rb +9 -0
- data/app/models/concerns/ruby_to_block/block/hardware_button_down_or_up.rb +25 -0
- data/app/models/concerns/ruby_to_block/block/hardware_button_not_use_pullup.rb +18 -0
- data/app/models/concerns/ruby_to_block/block/hardware_motor_driver.rb +22 -0
- data/app/models/concerns/ruby_to_block/block/hardware_motor_driver_set_speed.rb +20 -0
- data/app/models/concerns/ruby_to_block/block/hardware_motor_driver_speed.rb +24 -0
- data/app/models/concerns/ruby_to_block/block/hardware_on_button_down_or_up.rb +19 -0
- data/app/models/concerns/ruby_to_block/block/hardware_operation.rb +15 -0
- data/app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car_set_speed.rb +22 -0
- data/app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car_speed.rb +26 -0
- data/app/models/concerns/ruby_to_block/block/ruby_p.rb +19 -0
- data/app/models/concerns/ruby_to_block/block/{motion_reach_wall.rb → sensing_reach_wall.rb} +1 -1
- data/app/models/concerns/ruby_to_block/block/text.rb +3 -2
- data/app/models/source_code.rb +20 -0
- data/app/views/editor/_toolbox.html.haml +84 -63
- data/app/views/editor/index.html.haml +1 -1
- data/demos/adjust_2wd_car.rb.xml +179 -0
- data/demos/car_chase.rb.xml +129 -126
- data/demos/hardware_led.rb.xml +7 -4
- data/demos/pong.rb.xml +17 -14
- data/demos/star.rb.xml +115 -112
- data/lib/smalruby_editor/version.rb +3 -3
- data/lib/smalruby_editor.rb +16 -0
- data/public/assets/{application-c8991557a0789ac1bc9220f409e7f1c1.js → application-734570836cdba680c1568220a51af40f.js} +216 -86
- data/public/assets/{application-c8991557a0789ac1bc9220f409e7f1c1.js.gz → application-734570836cdba680c1568220a51af40f.js.gz} +0 -0
- data/public/assets/{application-d4fe6c0f970efe8eab9267fd08718d96.css → application-898cb749439fba4ce44cffeac1216201.css} +37 -9
- data/public/assets/{application-d4fe6c0f970efe8eab9267fd08718d96.css.gz → application-898cb749439fba4ce44cffeac1216201.css.gz} +0 -0
- data/public/assets/manifest-332a5a1668194028b55103e0ea45c054.json +1 -1
- data/smalruby-editor.gemspec +2 -1
- data/spec/acceptance/block_mode/blocks/events/on_hit.feature +2 -0
- data/spec/acceptance/block_mode/blocks/hardware/button_down_or_up.feature +79 -0
- data/spec/acceptance/block_mode/blocks/hardware/button_not_use_pullup.feature +61 -0
- data/spec/acceptance/block_mode/blocks/hardware/motor_driver.feature +73 -0
- data/spec/acceptance/block_mode/blocks/hardware/motor_driver_speed.feature +93 -0
- data/spec/acceptance/block_mode/blocks/hardware/on_button_down_or_up.feature +87 -0
- data/spec/acceptance/block_mode/blocks/hardware/two_wheel_drive_car_speed.feature +111 -0
- data/spec/acceptance/block_mode/blocks/motion/reach_wall.feature +1 -1
- data/spec/acceptance/block_mode/blocks/operators/text.feature +38 -0
- data/spec/acceptance/block_mode/blocks/sensing/hit.feature +98 -52
- data/spec/acceptance/block_mode/blocks/sensing/reach_wall.feature +98 -0
- data/spec/acceptance/block_mode/demo.feature +3 -1
- data/spec/acceptance/standalone/save.feature +51 -0
- data/spec/helpers/editor_helper_spec.rb +20 -0
- data/spec/javascripts/models/source_code_spec.coffee +40 -0
- data/spec/models/concerns/ruby_to_block/block/hardware_spec.rb +269 -0
- data/spec/models/concerns/ruby_to_block/block/motion_spec.rb +1 -1
- data/spec/models/concerns/ruby_to_block/block/{motion_reach_wall_spec.rb → sensing_reach_wall_spec.rb} +2 -2
- data/spec/models/concerns/ruby_to_block/block/text_spec.rb +39 -0
- data/spec/models/concerns/ruby_to_block_spec.rb +2 -2
- data/spec/models/source_code_spec.rb +53 -0
- data/spec/steps/base_steps.rb +5 -0
- metadata +56 -12
- data/demos/rgb_led_anode.rb.xml +0 -83
@@ -1,3 +1,3 @@
|
|
1
|
-
module SmalrubyEditor
|
2
|
-
VERSION = '0.1.
|
3
|
-
end
|
1
|
+
module SmalrubyEditor
|
2
|
+
VERSION = '0.1.21'
|
3
|
+
end
|
data/lib/smalruby_editor.rb
CHANGED
@@ -2,6 +2,22 @@
|
|
2
2
|
require 'smalruby_editor/version'
|
3
3
|
|
4
4
|
module SmalrubyEditor
|
5
|
+
# ジャンルのカラー
|
6
|
+
COLORS = {
|
7
|
+
character: 198,
|
8
|
+
control: 43,
|
9
|
+
data: 330,
|
10
|
+
etc: 340,
|
11
|
+
events: 33,
|
12
|
+
looks: 270,
|
13
|
+
motion: 208,
|
14
|
+
operators: 100,
|
15
|
+
pen: 160,
|
16
|
+
ruby: 340,
|
17
|
+
sensing: 190,
|
18
|
+
sound: 300,
|
19
|
+
}
|
20
|
+
|
5
21
|
def create_home_directory(home_dir = nil)
|
6
22
|
if home_dir.blank?
|
7
23
|
path = ENV['SMALRUBY_EDITOR_HOME'] || '~/.smalruby-editor'
|
@@ -12886,16 +12886,33 @@ Blockly.Blocks['text'].init = function() {
|
|
12886
12886
|
}
|
12887
12887
|
this.set('filename', filename);
|
12888
12888
|
}
|
12889
|
-
if (this.get('
|
12890
|
-
|
12889
|
+
if (!this.get('data')) {
|
12890
|
+
if (this.get('filename').match(/\.xml$/)) {
|
12891
|
+
data = Smalruby.dumpXml();
|
12892
|
+
} else {
|
12893
|
+
if (window.blockMode) {
|
12894
|
+
data = Blockly.Ruby.workspaceToCode();
|
12895
|
+
} else {
|
12896
|
+
data = window.textEditor.getSession().getDocument().getValue();
|
12897
|
+
}
|
12898
|
+
}
|
12899
|
+
return this.set('data', data);
|
12900
|
+
}
|
12901
|
+
},
|
12902
|
+
getRbxmlFilename: function() {
|
12903
|
+
var filename;
|
12904
|
+
filename = this.get('filename');
|
12905
|
+
if (filename.match(/\.rb\.xml$/)) {
|
12906
|
+
return filename;
|
12891
12907
|
} else {
|
12892
|
-
if (
|
12893
|
-
|
12908
|
+
if (filename.match(/\.rb$/)) {
|
12909
|
+
return filename + '.xml';
|
12910
|
+
} else if (filename.match(/\.xml$/)) {
|
12911
|
+
return filename.replace(/\.xml$/, '.rb.xml');
|
12894
12912
|
} else {
|
12895
|
-
|
12913
|
+
return filename + '.rb.xml';
|
12896
12914
|
}
|
12897
12915
|
}
|
12898
|
-
return this.set('data', data);
|
12899
12916
|
},
|
12900
12917
|
run: function() {
|
12901
12918
|
return this.post_('run');
|
@@ -13585,16 +13602,12 @@ Blockly.Blocks['text'].init = function() {
|
|
13585
13602
|
return window.textEditor.focus();
|
13586
13603
|
},
|
13587
13604
|
onRun: function(e) {
|
13588
|
-
var errorMsg,
|
13605
|
+
var errorMsg, sourceCode, xmlSourceCode,
|
13589
13606
|
_this = this;
|
13590
13607
|
e.preventDefault();
|
13591
13608
|
sourceCode = this.getSourceCode();
|
13592
|
-
filename = sourceCode.get('filename');
|
13593
|
-
if (!filename.match(/\.xml$/)) {
|
13594
|
-
filename += '.xml';
|
13595
|
-
}
|
13596
13609
|
xmlSourceCode = new Smalruby.SourceCode({
|
13597
|
-
filename:
|
13610
|
+
filename: sourceCode.getRbxmlFilename()
|
13598
13611
|
});
|
13599
13612
|
clearMessages();
|
13600
13613
|
this.blockUI({
|
@@ -13704,15 +13717,11 @@ Blockly.Blocks['text'].init = function() {
|
|
13704
13717
|
$('#filename').focus();
|
13705
13718
|
return;
|
13706
13719
|
}
|
13720
|
+
sourceCode = this.getSourceCode();
|
13707
13721
|
if (window.blockMode) {
|
13708
|
-
if (!filename.match(/\.xml$/)) {
|
13709
|
-
filename += '.xml';
|
13710
|
-
}
|
13711
13722
|
sourceCode = new Smalruby.SourceCode({
|
13712
|
-
filename:
|
13723
|
+
filename: sourceCode.getRbxmlFilename()
|
13713
13724
|
});
|
13714
|
-
} else {
|
13715
|
-
sourceCode = this.getSourceCode();
|
13716
13725
|
}
|
13717
13726
|
clearMessages();
|
13718
13727
|
this.blockUI({
|
@@ -14018,6 +14027,25 @@ case end next return until\
|
|
14018
14027
|
}
|
14019
14028
|
};
|
14020
14029
|
|
14030
|
+
Blockly.Ruby.defineCharacter = function(c) {
|
14031
|
+
var blockName, name, rotationStyle;
|
14032
|
+
name = c.get('name');
|
14033
|
+
blockName = "character_" + name;
|
14034
|
+
if (!Blockly.Ruby.definitions_[blockName]) {
|
14035
|
+
switch (c.get('rotationStyle')) {
|
14036
|
+
case 'left_right':
|
14037
|
+
rotationStyle = ', rotation_style: :left_right';
|
14038
|
+
break;
|
14039
|
+
case 'none':
|
14040
|
+
rotationStyle = ', rotation_style: :none';
|
14041
|
+
break;
|
14042
|
+
default:
|
14043
|
+
rotationStyle = '';
|
14044
|
+
}
|
14045
|
+
return Blockly.Ruby.definitions_[blockName] = "" + name + " = Character.new(costume: " + (Blockly.Ruby.quote_(c.costume())) + ", x: " + (c.get('x')) + ", y: " + (c.get('y')) + ", angle: " + (c.get('angle')) + rotationStyle + ")";
|
14046
|
+
}
|
14047
|
+
};
|
14048
|
+
|
14021
14049
|
Blockly.Ruby.characterStack = function() {
|
14022
14050
|
return this.definitions_['character_stack'];
|
14023
14051
|
};
|
@@ -14166,8 +14194,24 @@ case end next return until\
|
|
14166
14194
|
return line + '\n';
|
14167
14195
|
};
|
14168
14196
|
|
14197
|
+
Blockly.Ruby.escapeChars_ = {
|
14198
|
+
'"': '\\"'
|
14199
|
+
};
|
14200
|
+
|
14169
14201
|
Blockly.Ruby.quote_ = function(string) {
|
14170
|
-
|
14202
|
+
var i, s, sb, _fn, _i, _ref;
|
14203
|
+
s = String(string);
|
14204
|
+
sb = ['"'];
|
14205
|
+
_fn = function(i) {
|
14206
|
+
var ch;
|
14207
|
+
ch = s.charAt(i);
|
14208
|
+
return sb[i + 1] = Blockly.Ruby.escapeChars_[ch] || ch;
|
14209
|
+
};
|
14210
|
+
for (i = _i = 0, _ref = s.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
|
14211
|
+
_fn(i);
|
14212
|
+
}
|
14213
|
+
sb.push('"');
|
14214
|
+
return sb.join('');
|
14171
14215
|
};
|
14172
14216
|
|
14173
14217
|
Blockly.Ruby.scrub_ = function(block, code) {
|
@@ -14353,6 +14397,21 @@ case end next return until\
|
|
14353
14397
|
}
|
14354
14398
|
};
|
14355
14399
|
|
14400
|
+
Blockly.Block.prototype.getCharacterFieldValue = function(name) {
|
14401
|
+
var c, char;
|
14402
|
+
if (name == null) {
|
14403
|
+
name = 'CHAR';
|
14404
|
+
}
|
14405
|
+
char = this.getFieldValue(name);
|
14406
|
+
if (Blockly.Ruby.c()) {
|
14407
|
+
c = Smalruby.Collections.CharacterSet.findWhere({
|
14408
|
+
name: char
|
14409
|
+
});
|
14410
|
+
Blockly.Ruby.defineCharacter(c);
|
14411
|
+
}
|
14412
|
+
return char;
|
14413
|
+
};
|
14414
|
+
|
14356
14415
|
}).call(this);
|
14357
14416
|
(function() {
|
14358
14417
|
Blockly.Ruby['math_number'] = function(block) {
|
@@ -14442,19 +14501,9 @@ case end next return until\
|
|
14442
14501
|
};
|
14443
14502
|
|
14444
14503
|
Blockly.Ruby['character_new'] = function(block) {
|
14445
|
-
var c, code,
|
14504
|
+
var c, code, targetBlock;
|
14446
14505
|
c = block.character;
|
14447
|
-
|
14448
|
-
case 'left_right':
|
14449
|
-
rotationStyle = ', rotation_style: :left_right';
|
14450
|
-
break;
|
14451
|
-
case 'none':
|
14452
|
-
rotationStyle = ', rotation_style: :none';
|
14453
|
-
break;
|
14454
|
-
default:
|
14455
|
-
rotationStyle = '';
|
14456
|
-
}
|
14457
|
-
Blockly.Ruby.definitions_["character_" + (c.get('name'))] = "" + (c.get('name')) + " = Character.new(costume: " + (Blockly.Ruby.quote_(c.costume())) + ", x: " + (c.get('x')) + ", y: " + (c.get('y')) + ", angle: " + (c.get('angle')) + rotationStyle + ")";
|
14506
|
+
Blockly.Ruby.defineCharacter(c);
|
14458
14507
|
Blockly.Ruby.cs_().push(c);
|
14459
14508
|
try {
|
14460
14509
|
targetBlock = block.getInputTargetBlock('DO');
|
@@ -14771,13 +14820,13 @@ case end next return until\
|
|
14771
14820
|
|
14772
14821
|
Blockly.Ruby['events_on_hit'] = function(block) {
|
14773
14822
|
var char;
|
14774
|
-
char = this.
|
14823
|
+
char = this.getCharacterFieldValue();
|
14775
14824
|
return Blockly.Ruby.characterEvent_(block, 'DO', 'hit', char);
|
14776
14825
|
};
|
14777
14826
|
|
14778
14827
|
}).call(this);
|
14779
14828
|
(function() {
|
14780
|
-
var acDropdown, aiPinDropdown, dioPinDropdown, n, pwmPinDropdown, rgbLedPinDropdown, twoWDPinDropdown;
|
14829
|
+
var acDropdown, aiPinDropdown, dioPinDropdown, lorPinDropdown, n, pwmPinDropdown, rgbLedPinDropdown, twoWDPinDropdown;
|
14781
14830
|
|
14782
14831
|
window.SmalrubyEditor.Hardware = {
|
14783
14832
|
Type: 'Arduino',
|
@@ -14832,6 +14881,8 @@ case end next return until\
|
|
14832
14881
|
|
14833
14882
|
acDropdown = [['アノード', 'anode'], ['カソード', 'cathode']];
|
14834
14883
|
|
14884
|
+
lorPinDropdown = [['左', 'left'], ['右', 'right']];
|
14885
|
+
|
14835
14886
|
twoWDPinDropdown = (function() {
|
14836
14887
|
var _i, _results;
|
14837
14888
|
_results = [];
|
@@ -15218,43 +15269,127 @@ case end next return until\
|
|
15218
15269
|
return [code, Blockly.Ruby.ORDER_ATOMIC];
|
15219
15270
|
};
|
15220
15271
|
|
15221
|
-
Blockly.Blocks['
|
15272
|
+
Blockly.Blocks['hardware_two_wheel_drive_car_set_speed'] = {
|
15273
|
+
init: function() {
|
15274
|
+
this.setHelpUrl('');
|
15275
|
+
this.setColour(208);
|
15276
|
+
this.appendDummyInput().appendField('2WD車').appendField(new Blockly.FieldDropdown(pwmPinDropdown), 'PIN').appendField('の').appendField(new Blockly.FieldDropdown(lorPinDropdown), 'LOR').appendField('の速度を');
|
15277
|
+
this.interpolateMsg('%1%にする', ['SPEED', ['Number'], Blockly.ALIGN_RIGHT], Blockly.ALIGN_RIGHT);
|
15278
|
+
this.setInputsInline(true);
|
15279
|
+
this.setPreviousStatement(true);
|
15280
|
+
this.setNextStatement(true);
|
15281
|
+
return this.setTooltip('');
|
15282
|
+
}
|
15283
|
+
};
|
15284
|
+
|
15285
|
+
Blockly.Ruby['hardware_two_wheel_drive_car_set_speed'] = function(block) {
|
15286
|
+
var lor, pin, speed;
|
15287
|
+
pin = this.getFieldValue('PIN');
|
15288
|
+
lor = this.getFieldValue('LOR');
|
15289
|
+
speed = Blockly.Ruby.valueToCode(this, 'SPEED', Blockly.Ruby.ORDER_NONE) || '100';
|
15290
|
+
return Blockly.Ruby.characterMethodCall_("two_wheel_drive_car(" + (Blockly.Ruby.quote_(pin)) + ")." + lor + "_speed = " + speed);
|
15291
|
+
};
|
15292
|
+
|
15293
|
+
Blockly.Blocks['hardware_two_wheel_drive_car_speed'] = {
|
15222
15294
|
init: function() {
|
15223
15295
|
this.setHelpUrl('');
|
15224
15296
|
this.setColour(190);
|
15225
|
-
this.appendDummyInput().appendField('
|
15226
|
-
this.setOutput(true, '
|
15297
|
+
this.appendDummyInput().appendField('2WD車').appendField(new Blockly.FieldDropdown(pwmPinDropdown), 'PIN').appendField('の').appendField(new Blockly.FieldDropdown(lorPinDropdown), 'LOR').appendField('の速度(%)');
|
15298
|
+
this.setOutput(true, 'Number');
|
15227
15299
|
return this.setTooltip('');
|
15228
15300
|
}
|
15229
15301
|
};
|
15230
15302
|
|
15231
|
-
Blockly.Ruby['
|
15303
|
+
Blockly.Ruby['hardware_two_wheel_drive_car_speed'] = function(block) {
|
15304
|
+
var lor, pin;
|
15305
|
+
pin = this.getFieldValue('PIN');
|
15306
|
+
lor = this.getFieldValue('LOR');
|
15307
|
+
return Blockly.Ruby.characterMethodCallInput_("two_wheel_drive_car(" + (Blockly.Ruby.quote_(pin)) + ")." + lor + "_speed");
|
15308
|
+
};
|
15309
|
+
|
15310
|
+
Blockly.Blocks['hardware_motor_driver'] = {
|
15311
|
+
init: function() {
|
15312
|
+
var methodDropdown;
|
15313
|
+
methodDropdown = [['正転させる', 'forward'], ['逆転させる', 'backward'], ['止める', 'stop']];
|
15314
|
+
this.setHelpUrl('');
|
15315
|
+
this.setColour(208);
|
15316
|
+
this.appendDummyInput().appendField('(モータードライバ').appendField(new Blockly.FieldDropdown(pwmPinDropdown), 'PIN').appendField('で)モーターを').appendField(new Blockly.FieldDropdown(methodDropdown), 'METHOD');
|
15317
|
+
this.setInputsInline(true);
|
15318
|
+
this.setPreviousStatement(true);
|
15319
|
+
this.setNextStatement(true);
|
15320
|
+
return this.setTooltip('');
|
15321
|
+
}
|
15322
|
+
};
|
15323
|
+
|
15324
|
+
Blockly.Ruby['hardware_motor_driver'] = function(block) {
|
15325
|
+
var method, pin;
|
15326
|
+
pin = this.getFieldValue('PIN');
|
15327
|
+
method = this.getFieldValue('METHOD');
|
15328
|
+
return Blockly.Ruby.characterMethodCall_("motor_driver(" + (Blockly.Ruby.quote_(pin)) + ")." + method);
|
15329
|
+
};
|
15330
|
+
|
15331
|
+
Blockly.Blocks['hardware_motor_driver_set_speed'] = {
|
15332
|
+
init: function() {
|
15333
|
+
this.setHelpUrl('');
|
15334
|
+
this.setColour(208);
|
15335
|
+
this.appendDummyInput().appendField('(モータードライバ').appendField(new Blockly.FieldDropdown(pwmPinDropdown), 'PIN').appendField('の)モーターの速度を');
|
15336
|
+
this.interpolateMsg('%1%にする', ['SPEED', ['Number'], Blockly.ALIGN_RIGHT], Blockly.ALIGN_RIGHT);
|
15337
|
+
this.setInputsInline(true);
|
15338
|
+
this.setPreviousStatement(true);
|
15339
|
+
this.setNextStatement(true);
|
15340
|
+
return this.setTooltip('');
|
15341
|
+
}
|
15342
|
+
};
|
15343
|
+
|
15344
|
+
Blockly.Ruby['hardware_motor_driver_set_speed'] = function(block) {
|
15345
|
+
var pin, speed;
|
15346
|
+
pin = this.getFieldValue('PIN');
|
15347
|
+
speed = Blockly.Ruby.valueToCode(this, 'SPEED', Blockly.Ruby.ORDER_NONE) || '100';
|
15348
|
+
return Blockly.Ruby.characterMethodCall_("motor_driver(" + (Blockly.Ruby.quote_(pin)) + ").speed = " + speed);
|
15349
|
+
};
|
15350
|
+
|
15351
|
+
Blockly.Blocks['hardware_motor_driver_speed'] = {
|
15352
|
+
init: function() {
|
15353
|
+
this.setHelpUrl('');
|
15354
|
+
this.setColour(190);
|
15355
|
+
this.appendDummyInput().appendField('(モータードライバ').appendField(new Blockly.FieldDropdown(pwmPinDropdown), 'PIN').appendField('の)モーターの速度(%)');
|
15356
|
+
this.setOutput(true, 'Number');
|
15357
|
+
return this.setTooltip('');
|
15358
|
+
}
|
15359
|
+
};
|
15360
|
+
|
15361
|
+
Blockly.Ruby['hardware_motor_driver_speed'] = function(block) {
|
15232
15362
|
var pin;
|
15233
15363
|
pin = this.getFieldValue('PIN');
|
15234
|
-
return
|
15364
|
+
return Blockly.Ruby.characterMethodCallInput_("motor_driver(" + (Blockly.Ruby.quote_(pin)) + ").speed");
|
15235
15365
|
};
|
15236
15366
|
|
15237
|
-
Blockly.Blocks['
|
15367
|
+
Blockly.Blocks['hardware_button_down_or_up'] = {
|
15238
15368
|
init: function() {
|
15369
|
+
var douDropdown;
|
15370
|
+
douDropdown = window.SmalrubyEditor.Sensing.DownOrUpDropdown;
|
15239
15371
|
this.setHelpUrl('');
|
15240
15372
|
this.setColour(190);
|
15241
|
-
this.appendDummyInput().appendField('ボタン').appendField(new Blockly.FieldDropdown(dioPinDropdown), 'PIN').appendField('
|
15373
|
+
this.appendDummyInput().appendField('ボタン').appendField(new Blockly.FieldDropdown(dioPinDropdown), 'PIN').appendField('が').appendField(new Blockly.FieldDropdown(douDropdown), 'DOU');
|
15242
15374
|
this.setOutput(true, 'Boolean');
|
15243
15375
|
return this.setTooltip('');
|
15244
15376
|
}
|
15245
15377
|
};
|
15246
15378
|
|
15247
|
-
Blockly.Ruby['
|
15248
|
-
var pin;
|
15379
|
+
Blockly.Ruby['hardware_button_down_or_up'] = function(block) {
|
15380
|
+
var dou, pin;
|
15249
15381
|
pin = this.getFieldValue('PIN');
|
15250
|
-
|
15382
|
+
dou = this.getFieldValue('DOU');
|
15383
|
+
return Blockly.Ruby.characterMethodCallInput_("button(" + (Blockly.Ruby.quote_(pin)) + ")." + dou + "?");
|
15251
15384
|
};
|
15252
15385
|
|
15253
|
-
Blockly.Blocks['
|
15386
|
+
Blockly.Blocks['hardware_on_button_down_or_up'] = {
|
15254
15387
|
init: function() {
|
15388
|
+
var douDropdown;
|
15389
|
+
douDropdown = window.SmalrubyEditor.Sensing.DownOrUpDropdown;
|
15255
15390
|
this.setHelpUrl('');
|
15256
15391
|
this.setColour(33);
|
15257
|
-
this.appendDummyInput().appendField('ボタン').appendField(new Blockly.FieldDropdown(dioPinDropdown), 'PIN').appendField('
|
15392
|
+
this.appendDummyInput().appendField('ボタン').appendField(new Blockly.FieldDropdown(dioPinDropdown), 'PIN').appendField('が').appendField(new Blockly.FieldDropdown(douDropdown), 'DOU').appendField('とき');
|
15258
15393
|
this.appendStatementInput('DO');
|
15259
15394
|
this.setPreviousStatement(true);
|
15260
15395
|
this.setNextStatement(true);
|
@@ -15262,38 +15397,28 @@ case end next return until\
|
|
15262
15397
|
}
|
15263
15398
|
};
|
15264
15399
|
|
15265
|
-
Blockly.Ruby['
|
15266
|
-
var
|
15267
|
-
|
15268
|
-
|
15269
|
-
|
15270
|
-
return "\n" + var0 + ".on(:button_down, " + pin + ") do\n" + branch + "end\n";
|
15271
|
-
} else {
|
15272
|
-
return '';
|
15273
|
-
}
|
15400
|
+
Blockly.Ruby['hardware_on_button_down_or_up'] = function(block) {
|
15401
|
+
var dou, pin;
|
15402
|
+
pin = this.getFieldValue('PIN');
|
15403
|
+
dou = this.getFieldValue('DOU');
|
15404
|
+
return Blockly.Ruby.characterEvent_(block, 'DO', "button_" + dou, Blockly.Ruby.quote_(pin));
|
15274
15405
|
};
|
15275
15406
|
|
15276
|
-
Blockly.Blocks['
|
15407
|
+
Blockly.Blocks['hardware_button_not_use_pullup'] = {
|
15277
15408
|
init: function() {
|
15278
15409
|
this.setHelpUrl('');
|
15279
|
-
this.setColour(
|
15280
|
-
this.appendDummyInput().appendField('ボタン').appendField(new Blockly.FieldDropdown(dioPinDropdown), 'PIN').appendField('
|
15281
|
-
this.appendStatementInput('DO');
|
15410
|
+
this.setColour(340);
|
15411
|
+
this.appendDummyInput().appendField('ボタン').appendField(new Blockly.FieldDropdown(dioPinDropdown), 'PIN').appendField('のプルアップ抵抗を使わない');
|
15282
15412
|
this.setPreviousStatement(true);
|
15283
15413
|
this.setNextStatement(true);
|
15284
15414
|
return this.setTooltip('');
|
15285
15415
|
}
|
15286
15416
|
};
|
15287
15417
|
|
15288
|
-
Blockly.Ruby['
|
15289
|
-
var
|
15290
|
-
|
15291
|
-
|
15292
|
-
branch = Blockly.Ruby.statementToCode(block, 'DO') || '\n';
|
15293
|
-
return "\n" + var0 + ".on(:button_up, " + pin + ") do\n" + branch + "end\n";
|
15294
|
-
} else {
|
15295
|
-
return '';
|
15296
|
-
}
|
15418
|
+
Blockly.Ruby['hardware_button_not_use_pullup'] = function(block) {
|
15419
|
+
var pin;
|
15420
|
+
pin = this.getFieldValue('PIN');
|
15421
|
+
return Blockly.Ruby.characterMethodCall_("button(" + (Blockly.Ruby.quote_(pin)) + ").not_use_pullup");
|
15297
15422
|
};
|
15298
15423
|
|
15299
15424
|
Blockly.Blocks['hardware_sensor_value'] = {
|
@@ -15623,7 +15748,7 @@ case end next return until\
|
|
15623
15748
|
|
15624
15749
|
Blockly.Ruby['motion_point_towards_character'] = function(block) {
|
15625
15750
|
var char;
|
15626
|
-
char = this.
|
15751
|
+
char = this.getCharacterFieldValue();
|
15627
15752
|
return Blockly.Ruby.characterMethodCall_('point_towards', char);
|
15628
15753
|
};
|
15629
15754
|
|
@@ -15678,7 +15803,7 @@ case end next return until\
|
|
15678
15803
|
|
15679
15804
|
Blockly.Ruby['motion_go_to_character'] = function(block) {
|
15680
15805
|
var char;
|
15681
|
-
char = this.
|
15806
|
+
char = this.getCharacterFieldValue();
|
15682
15807
|
return Blockly.Ruby.characterMethodCall_("go_to(" + char + ")");
|
15683
15808
|
};
|
15684
15809
|
|
@@ -15789,20 +15914,6 @@ case end next return until\
|
|
15789
15914
|
return Blockly.Ruby.characterMethodCall_('turn_if_reach_wall');
|
15790
15915
|
};
|
15791
15916
|
|
15792
|
-
Blockly.Blocks['motion_reach_wall'] = {
|
15793
|
-
init: function() {
|
15794
|
-
this.setHelpUrl('');
|
15795
|
-
this.setColour(208);
|
15796
|
-
this.appendDummyInput().appendField('端に着いた');
|
15797
|
-
this.setOutput(true, 'Boolean');
|
15798
|
-
return this.setTooltip('');
|
15799
|
-
}
|
15800
|
-
};
|
15801
|
-
|
15802
|
-
Blockly.Ruby['motion_reach_wall'] = function(block) {
|
15803
|
-
return Blockly.Ruby.characterMethodCallInput_('reach_wall?');
|
15804
|
-
};
|
15805
|
-
|
15806
15917
|
Blockly.Blocks['motion_turn'] = {
|
15807
15918
|
init: function() {
|
15808
15919
|
this.setHelpUrl('');
|
@@ -16397,9 +16508,28 @@ case end next return until\
|
|
16397
16508
|
window.SmalrubyEditor.Sensing = {
|
16398
16509
|
KeyDropdown: [['↑', 'K_UP'], ['↓', 'K_DOWN'], ['←', 'K_LEFT'], ['→', 'K_RIGHT'], ['スペース', 'K_SPACE'], ['a', 'K_A'], ['b', 'K_B'], ['c', 'K_C'], ['d', 'K_D'], ['e', 'K_E'], ['f', 'K_F'], ['g', 'K_G'], ['h', 'K_H'], ['i', 'K_I'], ['j', 'K_J'], ['k', 'K_K'], ['l', 'K_L'], ['m', 'K_M'], ['n', 'K_N'], ['o', 'K_O'], ['p', 'K_P'], ['q', 'K_Q'], ['r', 'K_R'], ['s', 'K_S'], ['t', 'K_T'], ['u', 'K_U'], ['v', 'K_V'], ['w', 'K_W'], ['x', 'K_X'], ['y', 'K_Y'], ['z', 'K_Z'], ['0', 'K_0'], ['1', 'K_1'], ['2', 'K_2'], ['3', 'K_3'], ['4', 'K_4'], ['5', 'K_5'], ['6', 'K_6'], ['7', 'K_7'], ['8', 'K_8'], ['9', 'K_9']],
|
16399
16510
|
PushOrDownDropdown: [['押された', 'push'], ['押され続けている', 'down']],
|
16400
|
-
MouseButtonDropdown: [['左ボタン', 'M_LBUTTON'], ['中ボタン', 'M_MBUTTON'], ['右ボタン', 'M_RBUTTON']]
|
16511
|
+
MouseButtonDropdown: [['左ボタン', 'M_LBUTTON'], ['中ボタン', 'M_MBUTTON'], ['右ボタン', 'M_RBUTTON']],
|
16512
|
+
DownOrUpDropdown: [['押された', 'down'], ['離された', 'up']]
|
16401
16513
|
};
|
16402
16514
|
|
16515
|
+
Blockly.Blocks['sensing_reach_wall'] = {
|
16516
|
+
init: function() {
|
16517
|
+
this.setHelpUrl('');
|
16518
|
+
this.setColour(190);
|
16519
|
+
this.appendDummyInput().appendField('端に触れた');
|
16520
|
+
this.setOutput(true, 'Boolean');
|
16521
|
+
return this.setTooltip('');
|
16522
|
+
}
|
16523
|
+
};
|
16524
|
+
|
16525
|
+
Blockly.Ruby['sensing_reach_wall'] = function(block) {
|
16526
|
+
return Blockly.Ruby.characterMethodCallInput_('reach_wall?');
|
16527
|
+
};
|
16528
|
+
|
16529
|
+
Blockly.Blocks['motion_reach_wall'] = Blockly.Blocks['sensing_reach_wall'];
|
16530
|
+
|
16531
|
+
Blockly.Ruby['motion_reach_wall'] = Blockly.Ruby['sensing_reach_wall'];
|
16532
|
+
|
16403
16533
|
Blockly.Blocks['sensing_input_key_push_or_down'] = {
|
16404
16534
|
init: function() {
|
16405
16535
|
var keyDropdown, podDropdown;
|
@@ -16480,7 +16610,7 @@ case end next return until\
|
|
16480
16610
|
|
16481
16611
|
Blockly.Ruby['sensing_hit'] = function(block) {
|
16482
16612
|
var char;
|
16483
|
-
char = this.
|
16613
|
+
char = this.getCharacterFieldValue();
|
16484
16614
|
return Blockly.Ruby.characterMethodCallInput_('hit?', char);
|
16485
16615
|
};
|
16486
16616
|
|
@@ -16559,7 +16689,7 @@ case end next return until\
|
|
16559
16689
|
|
16560
16690
|
Blockly.Ruby['sensing_character_property'] = function(block) {
|
16561
16691
|
var c, char, property;
|
16562
|
-
char = this.
|
16692
|
+
char = this.getCharacterFieldValue();
|
16563
16693
|
property = this.getFieldValue('PROPERTY');
|
16564
16694
|
c = Smalruby.Collections.CharacterSet.findWhere({
|
16565
16695
|
name: char
|
Binary file
|
@@ -4791,7 +4791,11 @@ body {
|
|
4791
4791
|
#messages {
|
4792
4792
|
position: absolute;
|
4793
4793
|
right: 20px;
|
4794
|
-
z-index:
|
4794
|
+
z-index: 999;
|
4795
|
+
max-height: 80%;
|
4796
|
+
overflow: auto;
|
4797
|
+
bottom: 20px;
|
4798
|
+
width: 25%; }
|
4795
4799
|
|
4796
4800
|
.left-pane {
|
4797
4801
|
position: relative;
|
@@ -5211,24 +5215,24 @@ body {
|
|
5211
5215
|
padding-top: 1px;
|
5212
5216
|
padding-bottom: 1px;
|
5213
5217
|
color: white;
|
5214
|
-
background-color: #
|
5218
|
+
background-color: #00abcc !important; }
|
5215
5219
|
#\:g .blocklyTreeRow span.blocklyTreeIcon, #\:g .blocklyTreeRow span.blocklyTreeLabel {
|
5216
5220
|
font-size: 14px; }
|
5217
5221
|
#\:g .blocklyTreeRow.blocklyTreeSelected {
|
5218
5222
|
font-weight: bold;
|
5219
|
-
background-color: #
|
5223
|
+
background-color: #00d5ff !important; }
|
5220
5224
|
|
5221
5225
|
#\:h .blocklyTreeRow {
|
5222
5226
|
margin-bottom: 1px;
|
5223
5227
|
padding-top: 1px;
|
5224
5228
|
padding-bottom: 1px;
|
5225
5229
|
color: white;
|
5226
|
-
background-color: #
|
5230
|
+
background-color: #00abcc !important; }
|
5227
5231
|
#\:h .blocklyTreeRow span.blocklyTreeIcon, #\:h .blocklyTreeRow span.blocklyTreeLabel {
|
5228
5232
|
font-size: 14px; }
|
5229
5233
|
#\:h .blocklyTreeRow.blocklyTreeSelected {
|
5230
5234
|
font-weight: bold;
|
5231
|
-
background-color: #
|
5235
|
+
background-color: #00d5ff !important; }
|
5232
5236
|
|
5233
5237
|
#\:i .blocklyTreeRow {
|
5234
5238
|
margin-bottom: 1px;
|
@@ -5259,24 +5263,24 @@ body {
|
|
5259
5263
|
padding-top: 1px;
|
5260
5264
|
padding-bottom: 1px;
|
5261
5265
|
color: white;
|
5262
|
-
background-color: #
|
5266
|
+
background-color: #44cc00 !important; }
|
5263
5267
|
#\:k .blocklyTreeRow span.blocklyTreeIcon, #\:k .blocklyTreeRow span.blocklyTreeLabel {
|
5264
5268
|
font-size: 14px; }
|
5265
5269
|
#\:k .blocklyTreeRow.blocklyTreeSelected {
|
5266
5270
|
font-weight: bold;
|
5267
|
-
background-color: #
|
5271
|
+
background-color: #55ff00 !important; }
|
5268
5272
|
|
5269
5273
|
#\:l .blocklyTreeRow {
|
5270
5274
|
margin-bottom: 1px;
|
5271
5275
|
padding-top: 1px;
|
5272
5276
|
padding-bottom: 1px;
|
5273
5277
|
color: white;
|
5274
|
-
background-color: #
|
5278
|
+
background-color: #44cc00 !important; }
|
5275
5279
|
#\:l .blocklyTreeRow span.blocklyTreeIcon, #\:l .blocklyTreeRow span.blocklyTreeLabel {
|
5276
5280
|
font-size: 14px; }
|
5277
5281
|
#\:l .blocklyTreeRow.blocklyTreeSelected {
|
5278
5282
|
font-weight: bold;
|
5279
|
-
background-color: #
|
5283
|
+
background-color: #55ff00 !important; }
|
5280
5284
|
|
5281
5285
|
#\:m .blocklyTreeRow {
|
5282
5286
|
margin-bottom: 1px;
|
@@ -5290,5 +5294,29 @@ body {
|
|
5290
5294
|
font-weight: bold;
|
5291
5295
|
background-color: #ff0055 !important; }
|
5292
5296
|
|
5297
|
+
#\:n .blocklyTreeRow {
|
5298
|
+
margin-bottom: 1px;
|
5299
|
+
padding-top: 1px;
|
5300
|
+
padding-bottom: 1px;
|
5301
|
+
color: white;
|
5302
|
+
background-color: #cc0044 !important; }
|
5303
|
+
#\:n .blocklyTreeRow span.blocklyTreeIcon, #\:n .blocklyTreeRow span.blocklyTreeLabel {
|
5304
|
+
font-size: 14px; }
|
5305
|
+
#\:n .blocklyTreeRow.blocklyTreeSelected {
|
5306
|
+
font-weight: bold;
|
5307
|
+
background-color: #ff0055 !important; }
|
5308
|
+
|
5309
|
+
#\:o .blocklyTreeRow {
|
5310
|
+
margin-bottom: 1px;
|
5311
|
+
padding-top: 1px;
|
5312
|
+
padding-bottom: 1px;
|
5313
|
+
color: white;
|
5314
|
+
background-color: #cc0044 !important; }
|
5315
|
+
#\:o .blocklyTreeRow span.blocklyTreeIcon, #\:o .blocklyTreeRow span.blocklyTreeLabel {
|
5316
|
+
font-size: 14px; }
|
5317
|
+
#\:o .blocklyTreeRow.blocklyTreeSelected {
|
5318
|
+
font-weight: bold;
|
5319
|
+
background-color: #ff0055 !important; }
|
5320
|
+
|
5293
5321
|
div.blocklyTreeRoot {
|
5294
5322
|
padding: 0; }
|