smalruby-editor 0.2.1-x86-mingw32 → 0.2.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of smalruby-editor might be problematic. Click here for more details.

Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/LEGAL +4 -3
  3. data/app/assets/javascripts/blocks/character.js.coffee.erb +7 -3
  4. data/app/assets/javascripts/blocks/events.js.coffee.erb +7 -10
  5. data/app/assets/javascripts/blocks/hardware.js.coffee.erb +119 -31
  6. data/app/assets/javascripts/blocks/motion.js.coffee.erb +16 -20
  7. data/app/assets/javascripts/blocks/operators.js.coffee.erb +1 -1
  8. data/app/assets/javascripts/blocks/pen.js.coffee.erb +2 -1
  9. data/app/assets/javascripts/blocks/ruby.js.coffee.erb +3 -3
  10. data/app/assets/javascripts/blocks/sensing.js.coffee.erb +8 -8
  11. data/app/assets/javascripts/blocks/sound.js.coffee.erb +3 -1
  12. data/app/assets/javascripts/fix_blockly.js.erb +105 -0
  13. data/app/assets/javascripts/generators/ruby.js.coffee.erb +3 -0
  14. data/app/assets/javascripts/msg/en_us.js +67 -17
  15. data/app/assets/javascripts/msg/ja.js +151 -95
  16. data/app/assets/javascripts/{smalruby.js.coffee → smalruby.js.coffee.erb} +35 -16
  17. data/app/assets/javascripts/views/character_selector_view.js.coffee +2 -2
  18. data/app/assets/javascripts/views/{load_modal_view.js.coffee → load_modal_view.js.coffee.erb} +8 -2
  19. data/app/assets/javascripts/views/main_menu_view.js.coffee.erb +33 -48
  20. data/app/assets/javascripts/views/signin_modal_view.js.coffee.erb +43 -0
  21. data/app/assets/stylesheets/application.css +3 -1
  22. data/app/assets/stylesheets/toolbox.css.scss.erb +2 -56
  23. data/app/assets/stylesheets/toolbox_default.css.scss.erb +34 -0
  24. data/app/assets/stylesheets/toolbox_smalrubot_s1.css.scss.erb +31 -0
  25. data/app/assets/stylesheets/toolbox_smalrubot_v3.css.scss.erb +32 -0
  26. data/app/controllers/application_controller.rb +5 -0
  27. data/app/controllers/source_codes_controller.rb +6 -3
  28. data/app/helpers/application_helper.rb +12 -0
  29. data/app/helpers/editor_helper.rb +25 -0
  30. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action.rb +13 -0
  31. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_action_with_sec.rb +14 -0
  32. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_ir_photoreflector_value.rb +29 -0
  33. data/app/models/concerns/ruby_to_block/block/hardware_smalrubot_s1_led_turn_on_or_off.rb +22 -0
  34. data/app/views/editor/_block_tab.html.haml +7 -6
  35. data/app/views/editor/_reset_modal.html.haml +4 -4
  36. data/app/views/editor/_signin_modal.html.haml +8 -9
  37. data/app/views/editor/_toolbox_default.html.haml +504 -0
  38. data/app/views/editor/_toolbox_smalrubot_s1.html.haml +171 -0
  39. data/app/views/editor/_toolbox_smalrubot_v3.html.haml +177 -0
  40. data/app/views/editor/index.html.haml +12 -2
  41. data/app/views/layouts/application.html.erb +1 -0
  42. data/config/environments/production.rb +1 -0
  43. data/config/locales/en.yml +19 -16
  44. data/config/locales/ja.yml +28 -25
  45. data/demos/hardware_led.rb.xml +79 -79
  46. data/lib/smalruby_editor/config.rb +22 -0
  47. data/lib/smalruby_editor/version.rb +1 -1
  48. data/lib/smalruby_editor.rb +58 -0
  49. data/public/assets/application-71c4890fe0ea2e896fc0acff41cdb0ad.js +39 -0
  50. data/public/assets/application-71c4890fe0ea2e896fc0acff41cdb0ad.js.gz +0 -0
  51. data/public/assets/{application-d5358d75a2c4e570c749b333c59b55ab.css → application-c196e243630d74071981a16041bf391d.css} +1 -1
  52. data/public/assets/application-c196e243630d74071981a16041bf391d.css.gz +0 -0
  53. data/public/assets/blockly/msg/js/en_us-d5e1938b2d57c1df954f4411b9165d10.js +1 -0
  54. data/public/assets/blockly/msg/js/en_us-d5e1938b2d57c1df954f4411b9165d10.js.gz +0 -0
  55. data/public/assets/blockly/msg/js/ja-9f676d46458a2802b8f5a797c90ae8a4.js +1 -0
  56. data/public/assets/blockly/msg/js/ja-9f676d46458a2802b8f5a797c90ae8a4.js.gz +0 -0
  57. data/public/assets/manifest-f3d29c6d66b959abe4294a899733e4f0.json +1 -0
  58. data/public/assets/msg/en_us-213fb4a57884078038725a2991776f47.js +1 -0
  59. data/public/assets/msg/en_us-213fb4a57884078038725a2991776f47.js.gz +0 -0
  60. data/public/assets/msg/ja-aeface7456b479021e977a0387204036.js +1 -0
  61. data/public/assets/msg/ja-aeface7456b479021e977a0387204036.js.gz +0 -0
  62. data/public/assets/toolbox_default-e023d3f7a2cc7cc1f54a1224577b3c26.css +1 -0
  63. data/public/assets/toolbox_default-e023d3f7a2cc7cc1f54a1224577b3c26.css.gz +0 -0
  64. data/public/assets/toolbox_smalrubot_s1-18d28dc4b99723b60a3f538b742027df.css +1 -0
  65. data/public/assets/toolbox_smalrubot_s1-18d28dc4b99723b60a3f538b742027df.css.gz +0 -0
  66. data/public/assets/toolbox_smalrubot_v3-9af26ff13d4496890c4a391f65f95bcd.css +1 -0
  67. data/public/assets/toolbox_smalrubot_v3-9af26ff13d4496890c4a391f65f95bcd.css.gz +0 -0
  68. data/public/blockly/media/anon.jpeg +0 -0
  69. data/public/blockly/media/handclosed.cur +0 -0
  70. data/public/blockly/media/handdelete.cur +0 -0
  71. data/public/blockly/media/progress.gif +0 -0
  72. data/public/blockly/media/sprites.png +0 -0
  73. data/smalruby-editor.gemspec +2 -1
  74. data/spec/acceptance/base.feature +3 -3
  75. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action.feature +107 -0
  76. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_action_with_sec.feature +151 -0
  77. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_ir_photoreflector_value.feature +100 -0
  78. data/spec/acceptance/block_mode/blocks/hardware/smalrubot_s1_led_turn_on_or_off.feature +73 -0
  79. data/spec/acceptance/ruby_mode/translate.feature +6 -6
  80. data/spec/acceptance/standalone/save.feature +3 -3
  81. data/spec/acceptance/standalone/signin.feature +1 -2
  82. data/spec/lib/smalruby_editor_spec.rb +21 -11
  83. data/spec/models/concerns/ruby_to_block/block/hardware__smalrubot_s1_spec.rb +279 -0
  84. data/vendor/assets/javascripts/blockly/blockly_compressed.js +995 -668
  85. data/vendor/assets/javascripts/blockly/blocks_compressed.js +138 -114
  86. data/vendor/assets/javascripts/blockly/msg/js/en_us.js +6 -6
  87. data/vendor/assets/javascripts/blockly/msg/js/ja.js +42 -28
  88. metadata +66 -25
  89. data/app/assets/javascripts/fix_blockly.js +0 -128
  90. data/app/assets/javascripts/views/signin_modal_view.js.coffee +0 -33
  91. data/app/views/editor/_toolbox.html.haml +0 -496
  92. data/public/assets/application-b305a6ea9e7c045a8e170bbf6fb09dd1.js +0 -35
  93. data/public/assets/application-b305a6ea9e7c045a8e170bbf6fb09dd1.js.gz +0 -0
  94. data/public/assets/application-d5358d75a2c4e570c749b333c59b55ab.css.gz +0 -0
  95. data/public/assets/blockly/msg/js/en_us-6f7333af29688596ef863fa36a22cb41.js +0 -1
  96. data/public/assets/blockly/msg/js/en_us-6f7333af29688596ef863fa36a22cb41.js.gz +0 -0
  97. data/public/assets/blockly/msg/js/ja-d2cbf808bda8180571bc5f39141a98fe.js +0 -1
  98. data/public/assets/blockly/msg/js/ja-d2cbf808bda8180571bc5f39141a98fe.js.gz +0 -0
  99. data/public/assets/manifest-b1b843b1334b3b973824ab66b1f7a077.json +0 -1
  100. data/public/assets/msg/en_us-c6f8f0084f38560bf933b742ede64a52.js +0 -1
  101. data/public/assets/msg/en_us-c6f8f0084f38560bf933b742ede64a52.js.gz +0 -0
  102. data/public/assets/msg/ja-3703e6ceebd04ae1f08b0e871800539d.js +0 -1
  103. data/public/assets/msg/ja-3703e6ceebd04ae1f08b0e871800539d.js.gz +0 -0
  104. data/public/blockly/media/trashbody.png +0 -0
  105. data/public/blockly/media/trashlid.png +0 -0
  106. data/public/blockly/media/tree.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 322300c91cb3be15ca123aed5778949776efab96
4
- data.tar.gz: 3ec172bc24afd0ba188530f2cdeefb5fb4088443
3
+ metadata.gz: 16e2f41ebe0bcb080122de6d84382e4a82c550b0
4
+ data.tar.gz: c1a2828d36962c91c92e3e3eaec07fd808ea3306
5
5
  SHA512:
6
- metadata.gz: 7d6e97d54e7642f6855686fb4a3cd0db1855b923263b37c7ea240a03db02f7d5b02419dc44db8bd383667e99101cfc04419f056193794e1fea0f4c1ae46cf562
7
- data.tar.gz: c26010d761c5089ea5155e092a73f6a9e3903d91c3e06f7f0abdc0d934432f36f3ce06b94572a33c4015d65163c8431a5c492a9b988af70a77a3dd121dac3a80
6
+ metadata.gz: 5153febde2d8cb996df669b9c58753edb474b79ec59929c49e0483729ca52d9909ab27abe58478e3eed0f8661a7f6d75715baaf50382ed6ec29674c78fdeb57e
7
+ data.tar.gz: 44d20b9087ca9195c4f16d57d142403b8fc14b3e464e8d8622dcc7fa20cd9bf7f895ec272a6cb0a4306f746a027042829ab5bb0d9b348392bff3fe59fcf16ae0
data/LEGAL CHANGED
@@ -40,6 +40,7 @@ vendor/assets/javascripts/jquery.blockUI.js:
40
40
  public/favicon.ico, public/apple-touch-icon.png, public/large.png,
41
41
  public/square.png, public/tiny.png, public/wide.png:
42
42
 
43
- Copyright (C) Hikari Arakawa (Smalruby Project) 2013,
44
- licensed under CC BY-SA 2.1 JP:
45
- http://creativecommons.org/licenses/by-sa/2.1/jp/ .
43
+ Copyright (C) Hikari Arakawa (Ruby Programming Shounendan and
44
+ Smalruby) 2013. このイメージキャラクター、もしくはその派生版は、Ru
45
+ byプログラミング少年団とスモウルビー:Smalrubyに関連する文脈で誰で
46
+ も自由に利用できるが、それらは荒川ひかりによる保証を示すものではない。
@@ -19,10 +19,14 @@ Blockly.Blocks['<%= n %>'] =
19
19
  nameField = new Blockly.FieldLabel('')
20
20
  # HACK: ラベルをXMLとして出力させるためにEDITABLEをtrueにしている
21
21
  nameField.EDITABLE = true
22
- # HACK: 画像とラベルの縦位置を合わせる
23
- nameField.textElement_.setAttribute('y', 10)
24
22
  nameField.setText = _.bind(@nameFieldSetText_, @)
25
23
 
24
+ # HACK: 画像とラベルの縦位置を合わせる
25
+ originalInit = nameField.init
26
+ nameField.init = ->
27
+ originalInit.apply(@, arguments)
28
+ @getSvgRoot().setAttribute('y', size / 4)
29
+
26
30
  @appendDummyInput()
27
31
  .appendField(imageField, 'COSTUME')
28
32
  .appendField(nameField, 'NAME')
@@ -34,7 +38,7 @@ Blockly.Blocks['<%= n %>'] =
34
38
  dispose: (healStack, animate) ->
35
39
  @character.off 'change', @changeHandler
36
40
  @character.unlink?(@)
37
- Blockly.Block.prototype.dispose.apply(@, arguments)
41
+ @constructor.prototype.dispose.apply(@, arguments)
38
42
 
39
43
  nameFieldSetText_: (name) ->
40
44
  charSet = Smalruby.Collections.CharacterSet
@@ -32,12 +32,10 @@ Blockly.Blocks['<%= n %>'] =
32
32
 
33
33
  @setHelpUrl('')
34
34
  @setColour(<%= color %>)
35
- @appendDummyInput()
36
- .appendField(<%= bm('.on_key_push_or_down_prefix') %>)
37
- .appendField(new Blockly.FieldDropdown(keyDropdown), 'KEY')
38
- .appendField(<%= bm('.on_key_push_or_down_middle') %>)
39
- .appendField(new Blockly.FieldDropdown(podDropdown), 'POD')
40
- .appendField(<%= bm('.on_key_push_or_down_suffix') %>)
35
+ @interpolateMsg(<%= bm('.on_key_push_or_down') %>,
36
+ ['KEY', new Blockly.FieldDropdown(keyDropdown)],
37
+ ['POD', new Blockly.FieldDropdown(podDropdown)],
38
+ Blockly.ALIGN_RIGHT)
41
39
  @appendStatementInput('DO')
42
40
  @setPreviousStatement(true)
43
41
  @setNextStatement(true)
@@ -70,10 +68,9 @@ Blockly.Blocks['<%= n %>'] =
70
68
  init: ()->
71
69
  @setHelpUrl('')
72
70
  @setColour(<%= color %>)
73
- @appendDummyInput()
74
- .appendField(<%= bm('.on_hit_prefix') %>)
75
- .appendField(new Smalruby.FieldCharacter(), 'CHAR')
76
- .appendField(<%= bm('.on_hit_suffix') %>)
71
+ @interpolateMsg(<%= bm('.on_hit') %>,
72
+ ['CHAR', new Smalruby.FieldCharacter()],
73
+ Blockly.ALIGN_RIGHT)
77
74
  @appendStatementInput('DO')
78
75
  @setPreviousStatement(true)
79
76
  @setNextStatement(true)
@@ -83,7 +83,7 @@ Blockly.Blocks['<%= n %>'] =
83
83
  @setHelpUrl('')
84
84
  @setColour(<%= colors[:looks] %>)
85
85
  @interpolateMsg(<%= bm(".led_#{method}") %>,
86
- ['PIN', ['Dropdown', dioPinDropdown], Blockly.ALIGN_RIGHT],
86
+ ['PIN', new Blockly.FieldDropdown(dioPinDropdown)],
87
87
  Blockly.ALIGN_RIGHT)
88
88
  @setPreviousStatement(true)
89
89
  @setNextStatement(true)
@@ -105,9 +105,9 @@ Blockly.Blocks['<%= n %>'] =
105
105
  @setHelpUrl('')
106
106
  @setColour(<%= colors[:looks] %>)
107
107
  @interpolateMsg(<%= bm('.rgb_led_set_color') %>,
108
- ['AC', ['Dropdown', acDropdown], Blockly.ALIGN_RIGHT],
109
- ['PIN', ['Dropdown', rgbLedPinDropdown], Blockly.ALIGN_RIGHT],
110
- ['COLOUR', ['Colour', '#ff0000'], Blockly.ALIGN_RIGHT],
108
+ ['AC', new Blockly.FieldDropdown(acDropdown)],
109
+ ['PIN', new Blockly.FieldDropdown(rgbLedPinDropdown)],
110
+ ['COLOUR', new Blockly.FieldColour('#ff0000')],
111
111
  Blockly.ALIGN_RIGHT)
112
112
  @setPreviousStatement(true)
113
113
  @setNextStatement(true)
@@ -130,8 +130,8 @@ Blockly.Blocks['<%= n %>'] =
130
130
  @setHelpUrl('')
131
131
  @setColour(<%= colors[:looks] %>)
132
132
  @interpolateMsg(<%= bm('.rgb_led_turn_off') %>,
133
- ['AC', ['Dropdown', acDropdown], Blockly.ALIGN_RIGHT],
134
- ['PIN', ['Dropdown', rgbLedPinDropdown], Blockly.ALIGN_RIGHT],
133
+ ['AC', new Blockly.FieldDropdown(acDropdown)],
134
+ ['PIN', new Blockly.FieldDropdown(rgbLedPinDropdown)],
135
135
  Blockly.ALIGN_RIGHT)
136
136
  @setPreviousStatement(true)
137
137
  @setNextStatement(true)
@@ -153,7 +153,7 @@ Blockly.Blocks['<%= n %>'] =
153
153
  @setHelpUrl('')
154
154
  @setColour(<%= colors[:looks] %>)
155
155
  @interpolateMsg(<%= bm('.seven_segment_display_show') %>,
156
- ['NUM', ['Dropdown', dropdown], Blockly.ALIGN_RIGHT],
156
+ ['NUM', new Blockly.FieldDropdown(dropdown)],
157
157
  Blockly.ALIGN_RIGHT)
158
158
  @setPreviousStatement(true)
159
159
  @setNextStatement(true)
@@ -222,7 +222,7 @@ Blockly.Blocks['<%= n %>'] =
222
222
  @setHelpUrl('')
223
223
  @setColour(<%= colors[:motion] %>)
224
224
  @interpolateMsg(<%= bm('.servo_set_position') %>,
225
- ['PIN', ['Dropdown', pwmPinDropdown], Blockly.ALIGN_RIGHT],
225
+ ['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
226
226
  ['POS', ['Number'], Blockly.ALIGN_RIGHT],
227
227
  Blockly.ALIGN_RIGHT)
228
228
  @setInputsInline(true)
@@ -254,7 +254,7 @@ Blockly.Blocks['<%= n %>'] =
254
254
  @setHelpUrl('')
255
255
  @setColour(<%= colors[:motion] %>)
256
256
  @interpolateMsg(<%= bm(".#{subcategory}_#{method}") %>,
257
- ['PIN', ['Dropdown', twoWDPinDropdown], Blockly.ALIGN_RIGHT],
257
+ ['PIN', new Blockly.FieldDropdown(twoWDPinDropdown)],
258
258
  Blockly.ALIGN_RIGHT)
259
259
  @setInputsInline(true)
260
260
  @setPreviousStatement(true)
@@ -275,7 +275,7 @@ Blockly.Blocks['<%= n %>'] =
275
275
  @setColour(<%= colors[:motion] %>)
276
276
  @interpolateMsg(<%= bm(".#{subcategory}_run") %>,
277
277
  ['COMMAND', ['String'], Blockly.ALIGN_RIGHT],
278
- ['PIN', ['Dropdown', twoWDPinDropdown], Blockly.ALIGN_RIGHT],
278
+ ['PIN', new Blockly.FieldDropdown(twoWDPinDropdown)],
279
279
  ['SEC', ['Number'], Blockly.ALIGN_RIGHT],
280
280
  Blockly.ALIGN_RIGHT)
281
281
  @setInputsInline(true)
@@ -296,8 +296,9 @@ Blockly.Blocks['<%= n %>'] =
296
296
  init: ()->
297
297
  @setHelpUrl('')
298
298
  @setColour(<%= colors[:motion] %>)
299
- @appendDummyInput()
300
- .appendField(new Blockly.FieldDropdown(actionDropdown), 'COMMAND')
299
+ @interpolateMsg(<%= bm(".#{subcategory}_commands") %>,
300
+ ['COMMAND', new Blockly.FieldDropdown(actionDropdown)],
301
+ Blockly.ALIGN_RIGHT)
301
302
  @setOutput(true, 'String')
302
303
  @setTooltip('')
303
304
 
@@ -312,8 +313,8 @@ Blockly.Blocks['<%= n %>'] =
312
313
  @setHelpUrl('')
313
314
  @setColour(<%= colors[:motion] %>)
314
315
  @interpolateMsg(<%= bm(".#{subcategory}_set_speed") %>,
315
- ['PIN', ['Dropdown', pwmPinDropdown], Blockly.ALIGN_RIGHT],
316
- ['LOR', ['Dropdown', lorDropdown], Blockly.ALIGN_RIGHT],
316
+ ['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
317
+ ['LOR', new Blockly.FieldDropdown(lorDropdown)],
317
318
  ['SPEED', ['Number'], Blockly.ALIGN_RIGHT],
318
319
  Blockly.ALIGN_RIGHT)
319
320
  @setInputsInline(true)
@@ -334,8 +335,8 @@ Blockly.Blocks['<%= n %>'] =
334
335
  @setHelpUrl('')
335
336
  @setColour(<%= colors[:sensing] %>)
336
337
  @interpolateMsg(<%= bm(".#{subcategory}_speed") %>,
337
- ['PIN', ['Dropdown', pwmPinDropdown], Blockly.ALIGN_RIGHT],
338
- ['LOR', ['Dropdown', lorDropdown], Blockly.ALIGN_RIGHT],
338
+ ['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
339
+ ['LOR', new Blockly.FieldDropdown(lorDropdown)],
339
340
  Blockly.ALIGN_RIGHT)
340
341
  @setOutput(true, 'Number')
341
342
  @setTooltip('')
@@ -361,8 +362,8 @@ Blockly.Blocks['<%= n %>'] =
361
362
  @setHelpUrl('')
362
363
  @setColour(<%= colors[:motion] %>)
363
364
  @interpolateMsg(<%= bm(".#{subcategory}") %>,
364
- ['PIN', ['Dropdown', pwmPinDropdown], Blockly.ALIGN_RIGHT],
365
- ['METHOD', ['Dropdown', methodDropdown], Blockly.ALIGN_RIGHT],
365
+ ['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
366
+ ['METHOD', new Blockly.FieldDropdown(methodDropdown)],
366
367
  Blockly.ALIGN_RIGHT)
367
368
  @setInputsInline(true)
368
369
  @setPreviousStatement(true)
@@ -382,7 +383,7 @@ Blockly.Blocks['<%= n %>'] =
382
383
  @setHelpUrl('')
383
384
  @setColour(<%= colors[:motion] %>)
384
385
  @interpolateMsg(<%= bm(".#{subcategory}_set_speed") %>,
385
- ['PIN', ['Dropdown', pwmPinDropdown], Blockly.ALIGN_RIGHT],
386
+ ['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
386
387
  ['SPEED', ['Number'], Blockly.ALIGN_RIGHT],
387
388
  Blockly.ALIGN_RIGHT)
388
389
  @setInputsInline(true)
@@ -402,7 +403,7 @@ Blockly.Blocks['<%= n %>'] =
402
403
  @setHelpUrl('')
403
404
  @setColour(<%= colors[:sensing] %>)
404
405
  @interpolateMsg(<%= bm(".#{subcategory}_speed") %>,
405
- ['PIN', ['Dropdown', pwmPinDropdown], Blockly.ALIGN_RIGHT],
406
+ ['PIN', new Blockly.FieldDropdown(pwmPinDropdown)],
406
407
  Blockly.ALIGN_RIGHT)
407
408
  @setOutput(true, 'Number')
408
409
  @setTooltip('')
@@ -423,8 +424,8 @@ Blockly.Blocks['<%= n %>'] =
423
424
  @setHelpUrl('')
424
425
  @setColour(<%= colors[:sensing] %>)
425
426
  @interpolateMsg(<%= bm(".button_pressed_or_released") %>,
426
- ['PIN', ['Dropdown', dioPinDropdown], Blockly.ALIGN_RIGHT],
427
- ['POR', ['Dropdown', porDropdown], Blockly.ALIGN_RIGHT],
427
+ ['PIN', new Blockly.FieldDropdown(dioPinDropdown)],
428
+ ['POR', new Blockly.FieldDropdown(porDropdown)],
428
429
  Blockly.ALIGN_RIGHT)
429
430
  @setOutput(true, 'Boolean')
430
431
  @setTooltip('')
@@ -443,7 +444,7 @@ Blockly.Blocks['<%= n %>'] =
443
444
  @setHelpUrl('')
444
445
  @setColour(<%= colors[:sensing] %>)
445
446
  @interpolateMsg(<%= bm('.sensor_value') %>,
446
- ['PIN', ['Dropdown', aiPinDropdown], Blockly.ALIGN_RIGHT],
447
+ ['PIN', new Blockly.FieldDropdown(aiPinDropdown)],
447
448
  Blockly.ALIGN_RIGHT)
448
449
  @setOutput(true, 'Number')
449
450
  @setTooltip('')
@@ -471,8 +472,8 @@ Blockly.Blocks['<%= n %>'] =
471
472
  @setHelpUrl('')
472
473
  @setColour(<%= colors[:looks] %>)
473
474
  @interpolateMsg(<%= bm(".#{subcategory}_led_turn_on_or_off") %>,
474
- ['COLOUR', ['Dropdown', colourDropdown], Blockly.ALIGN_RIGHT],
475
- ['OOO', ['Dropdown', oooDropdown], Blockly.ALIGN_RIGHT],
475
+ ['COLOUR', new Blockly.FieldDropdown(colourDropdown)],
476
+ ['OOO', new Blockly.FieldDropdown(oooDropdown)],
476
477
  Blockly.ALIGN_RIGHT)
477
478
  @setInputsInline(true)
478
479
  @setPreviousStatement(true)
@@ -491,7 +492,7 @@ Blockly.Blocks['<%= n %>'] =
491
492
  @setHelpUrl('')
492
493
  @setColour(<%= colors[:sensing] %>)
493
494
  @interpolateMsg(<%= bm(".#{subcategory}_motor_speed") %>,
494
- ['LOR', ['Dropdown', lorDropdown], Blockly.ALIGN_RIGHT],
495
+ ['LOR', new Blockly.FieldDropdown(lorDropdown)],
495
496
  Blockly.ALIGN_RIGHT)
496
497
  @setOutput(true, 'Number')
497
498
  @setTooltip('')
@@ -507,7 +508,7 @@ Blockly.Blocks['<%= n %>'] =
507
508
  @setHelpUrl('')
508
509
  @setColour(<%= colors[:motion] %>)
509
510
  @interpolateMsg(<%= bm(".#{subcategory}_motor_set_speed") %>,
510
- ['LOR', ['Dropdown', lorDropdown], Blockly.ALIGN_RIGHT],
511
+ ['LOR', new Blockly.FieldDropdown(lorDropdown)],
511
512
  ['SPEED', ['Number'], Blockly.ALIGN_RIGHT],
512
513
  Blockly.ALIGN_RIGHT)
513
514
  @setInputsInline(true)
@@ -528,7 +529,7 @@ Blockly.Blocks['<%= n %>'] =
528
529
  @setHelpUrl('')
529
530
  @setColour(<%= colors[:motion] %>)
530
531
  @interpolateMsg(<%= bm(".#{subcategory}_action") %>,
531
- ['ACTION', ['Dropdown', actionDropdown], Blockly.ALIGN_RIGHT],
532
+ ['ACTION', new Blockly.FieldDropdown(actionDropdown)],
532
533
  Blockly.ALIGN_RIGHT)
533
534
  @setInputsInline(true)
534
535
  @setPreviousStatement(true)
@@ -546,7 +547,7 @@ Blockly.Blocks['<%= n %>'] =
546
547
  @setHelpUrl('')
547
548
  @setColour(<%= colors[:motion] %>)
548
549
  @interpolateMsg(<%= bm(".#{subcategory}_action_with_sec") %>,
549
- ['ACTION', ['Dropdown', actionDropdown], Blockly.ALIGN_RIGHT],
550
+ ['ACTION', new Blockly.FieldDropdown(actionDropdown)],
550
551
  ['SEC', ['Number'], Blockly.ALIGN_RIGHT],
551
552
  Blockly.ALIGN_RIGHT)
552
553
  @setInputsInline(true)
@@ -568,8 +569,8 @@ Blockly.Blocks['<%= n %>'] =
568
569
  @setHelpUrl('')
569
570
  @setColour(<%= colors[:sensing] %>)
570
571
  @interpolateMsg(<%= bm(".#{subcategory}_touch_sensor_pressed_or_released") %>,
571
- ['LOR', ['Dropdown', lorDropdown], Blockly.ALIGN_RIGHT],
572
- ['POR', ['Dropdown', porDropdown], Blockly.ALIGN_RIGHT],
572
+ ['LOR', new Blockly.FieldDropdown(lorDropdown)],
573
+ ['POR', new Blockly.FieldDropdown(porDropdown)],
573
574
  Blockly.ALIGN_RIGHT)
574
575
  @setOutput(true, 'Boolean')
575
576
  @setTooltip('')
@@ -591,3 +592,90 @@ Blockly.Blocks['<%= n %>'] =
591
592
 
592
593
  Blockly.Ruby['<%= n %>'] = (block) ->
593
594
  Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.light_sensor.value")
595
+
596
+
597
+ # SmalrubotS1 sub category
598
+ <% subcategory = 'smalrubot_s1' %>
599
+
600
+ # turn on/off Smalrubot s1 blue/white LED
601
+ <% n = "#{category}_#{subcategory}_led_turn_on_or_off" %>
602
+ Blockly.Blocks['<%= n %>'] =
603
+ init: ()->
604
+ colourDropdown = [
605
+ [<%= bm('colour.blue') %>, 'blue'],
606
+ [<%= bm('colour.white') %>, 'white'],
607
+ ]
608
+ oooDropdown = [
609
+ [<%= bm('common.turn_on') %>, 'turn_on'],
610
+ [<%= bm('common.turn_off') %>, 'turn_off'],
611
+ ]
612
+
613
+ @setHelpUrl('')
614
+ @setColour(<%= colors[:looks] %>)
615
+ @interpolateMsg(<%= bm(".#{subcategory}_led_turn_on_or_off") %>,
616
+ ['COLOUR', new Blockly.FieldDropdown(colourDropdown)],
617
+ ['OOO', new Blockly.FieldDropdown(oooDropdown)],
618
+ Blockly.ALIGN_RIGHT)
619
+ @setInputsInline(true)
620
+ @setPreviousStatement(true)
621
+ @setNextStatement(true)
622
+ @setTooltip('')
623
+
624
+ Blockly.Ruby['<%= n %>'] = (block) ->
625
+ colour = @getFieldValue('COLOUR')
626
+ ooo = @getFieldValue('OOO')
627
+ Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{ooo}_#{colour}_led")
628
+
629
+ # forward/backward/turn left/turn right/stop Smalrubot s1
630
+ <% n = "#{category}_#{subcategory}_action" %>
631
+ Blockly.Blocks['<%= n %>'] =
632
+ init: ()->
633
+ @setHelpUrl('')
634
+ @setColour(<%= colors[:motion] %>)
635
+ @interpolateMsg(<%= bm(".#{subcategory}_action") %>,
636
+ ['ACTION', new Blockly.FieldDropdown(actionDropdown)],
637
+ Blockly.ALIGN_RIGHT)
638
+ @setInputsInline(true)
639
+ @setPreviousStatement(true)
640
+ @setNextStatement(true)
641
+ @setTooltip('')
642
+
643
+ Blockly.Ruby['<%= n %>'] = (block) ->
644
+ action = @getFieldValue('ACTION')
645
+ Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{action}")
646
+
647
+ # forward/backward/turn left/turn right/stop Smalrubot s1 for ( ) secs
648
+ <% n = "#{category}_#{subcategory}_action_with_sec" %>
649
+ Blockly.Blocks['<%= n %>'] =
650
+ init: ()->
651
+ @setHelpUrl('')
652
+ @setColour(<%= colors[:motion] %>)
653
+ @interpolateMsg(<%= bm(".#{subcategory}_action_with_sec") %>,
654
+ ['ACTION', new Blockly.FieldDropdown(actionDropdown)],
655
+ ['SEC', ['Number'], Blockly.ALIGN_RIGHT],
656
+ Blockly.ALIGN_RIGHT)
657
+ @setInputsInline(true)
658
+ @setPreviousStatement(true)
659
+ @setNextStatement(true)
660
+ @setTooltip('')
661
+
662
+ Blockly.Ruby['<%= n %>'] = (block) ->
663
+ action = @getFieldValue('ACTION')
664
+ sec = Blockly.Ruby.valueToCode(@, 'SEC', Blockly.Ruby.ORDER_FUNCTION_CALL) || 'nil'
665
+ Blockly.Ruby.characterMethodCall_("<%= subcategory %>.#{action}(sec: #{sec})")
666
+
667
+ # Smalrubot s1 left/right ir photoreflector value
668
+ <% n = "#{category}_#{subcategory}_ir_photoreflector_value" %>
669
+ Blockly.Blocks['<%= n %>'] =
670
+ init: ()->
671
+ @setHelpUrl('')
672
+ @setColour(<%= colors[:sensing] %>)
673
+ @interpolateMsg(<%= bm(".#{subcategory}_ir_photoreflector_value") %>,
674
+ ['LOR', new Blockly.FieldDropdown(lorDropdown)],
675
+ Blockly.ALIGN_RIGHT)
676
+ @setOutput(true, 'Boolean')
677
+ @setTooltip('')
678
+
679
+ Blockly.Ruby['<%= n %>'] = (block) ->
680
+ lor = @getFieldValue('LOR')
681
+ Blockly.Ruby.characterMethodCallInput_("<%= subcategory %>.#{lor}_ir_photoreflector_value")
@@ -91,9 +91,9 @@ Blockly.Blocks['<%= n %>'] =
91
91
  init: ()->
92
92
  @setHelpUrl('')
93
93
  @setColour(<%= color %>)
94
- @appendDummyInput()
95
- .appendField(new Smalruby.FieldCharacter(), 'CHAR')
96
- .appendField(<%= bm('.point_towards_character') %>)
94
+ @interpolateMsg(<%= bm('.point_towards_character') %>,
95
+ ['CHAR', new Smalruby.FieldCharacter()],
96
+ Blockly.ALIGN_RIGHT)
97
97
  @setPreviousStatement(true)
98
98
  @setNextStatement(true)
99
99
  @setTooltip('')
@@ -108,11 +108,10 @@ Blockly.Blocks['<%= n %>'] =
108
108
  init: ()->
109
109
  @setHelpUrl('')
110
110
  @setColour(<%= color %>)
111
- @appendDummyInput().appendField(<%= bm('.set_x_y_x') %>)
112
- @appendValueInput('X').setCheck('Number')
113
- @appendDummyInput().appendField(<%= bm('.set_x_y_y') %>)
114
- @appendValueInput('Y').setCheck('Number')
115
- @appendDummyInput().appendField(<%= bm('.set_x_y_suffix') %>)
111
+ @interpolateMsg(<%= bm('.set_x_y') %>,
112
+ ['X', ['Number'], Blockly.ALIGN_RIGHT],
113
+ ['Y', ['Number'], Blockly.ALIGN_RIGHT],
114
+ Blockly.ALIGN_RIGHT)
116
115
  @setInputsInline(true)
117
116
  @setPreviousStatement(true)
118
117
  @setNextStatement(true)
@@ -144,10 +143,9 @@ Blockly.Blocks['<%= n %>'] =
144
143
  init: ()->
145
144
  @setHelpUrl('')
146
145
  @setColour(<%= color %>)
147
- @appendDummyInput()
148
- .appendField(<%= bm('.go_to_character_prefix') %>)
149
- .appendField(new Smalruby.FieldCharacter(), 'CHAR')
150
- .appendField(<%= bm('.go_to_character_suffix') %>)
146
+ @interpolateMsg(<%= bm('.go_to_character') %>,
147
+ ['CHAR', new Smalruby.FieldCharacter()],
148
+ Blockly.ALIGN_RIGHT)
151
149
  @setPreviousStatement(true)
152
150
  @setNextStatement(true)
153
151
  @setTooltip('')
@@ -248,10 +246,9 @@ Blockly.Blocks['<%= n %>'] =
248
246
 
249
247
  @setHelpUrl('')
250
248
  @setColour(<%= color %>)
251
- @appendDummyInput()
252
- .appendField(<%= bm('.turn_xy_prefix') %>)
253
- .appendField(new Blockly.FieldDropdown(dropdown), 'XY')
254
- .appendField(<%= bm('.turn_xy_suffix') %>)
249
+ @interpolateMsg(<%= bm('.turn_xy') %>,
250
+ ['XY', new Blockly.FieldDropdown(dropdown)],
251
+ Blockly.ALIGN_RIGHT)
255
252
  @setPreviousStatement(true)
256
253
  @setNextStatement(true)
257
254
  @setTooltip('')
@@ -272,10 +269,9 @@ Blockly.Blocks['<%= n %>'] =
272
269
 
273
270
  @setHelpUrl('')
274
271
  @setColour(<%= color %>)
275
- @appendDummyInput()
276
- .appendField(<%= bm('.set_rotation_style_prefix') %>)
277
- .appendField(new Blockly.FieldDropdown(dropdown), 'STYLE')
278
- .appendField(<%= bm('.set_rotation_style_suffix') %>)
272
+ @interpolateMsg(<%= bm('.set_rotation_style') %>,
273
+ ['STYLE', new Blockly.FieldDropdown(dropdown)],
274
+ Blockly.ALIGN_RIGHT)
279
275
  @setPreviousStatement(true)
280
276
  @setNextStatement(true)
281
277
  @setTooltip('')
@@ -241,7 +241,7 @@ Blockly.Blocks['<%= n %>'] =
241
241
  @setColour(<%= color %>)
242
242
  @interpolateMsg(<%= bm('.math_method') %>,
243
243
  ['NUM', ['Number'], Blockly.ALIGN_RIGHT],
244
- ['METHOD', ['Dropdown', dropdown], Blockly.ALIGN_RIGHT],
244
+ ['METHOD', new Blockly.FieldDropdown(dropdown)],
245
245
  Blockly.ALIGN_RIGHT)
246
246
  @setInputsInline(true)
247
247
  @setOutput(true, 'Number')
@@ -3,6 +3,7 @@
3
3
  <%
4
4
  category = 'pen'
5
5
  require 'smalruby_editor'
6
+ require 'smalruby_editor/blockly_message_helper'
6
7
  color = SmalrubyEditor::COLORS[category.to_sym]
7
8
  %>
8
9
 
@@ -34,7 +35,7 @@ Blockly.Blocks['<%= n %>'] =
34
35
  @setHelpUrl('')
35
36
  @setColour(<%= color %>)
36
37
  @interpolateMsg(<%= bm('.set_pen_color') %>,
37
- ['COLOUR', ['Colour', '#ff0000'], Blockly.ALIGN_RIGHT],
38
+ ['COLOUR', new Blockly.FieldColour('#ff0000')],
38
39
  Blockly.ALIGN_RIGHT)
39
40
  @setPreviousStatement(true)
40
41
  @setNextStatement(true)
@@ -63,9 +63,9 @@ Blockly.Blocks['<%= n %>'] =
63
63
  init: ()->
64
64
  @setHelpUrl('')
65
65
  @setColour(<%= color %>)
66
- @interpolateMsg('p %1',
67
- ['ARG', null, Blockly.ALIGN_RIGHT],
68
- Blockly.ALIGN_RIGHT)
66
+ @interpolateMsg(<%= bm('.p') %>,
67
+ ['ARG', null, Blockly.ALIGN_RIGHT],
68
+ Blockly.ALIGN_RIGHT)
69
69
  @setInputsInline(true)
70
70
  @setPreviousStatement(true)
71
71
  @setNextStatement(true)
@@ -215,10 +215,10 @@ Blockly.Blocks['<%= n %>'] =
215
215
 
216
216
  @setHelpUrl('')
217
217
  @setColour(<%= color %>)
218
- @appendDummyInput()
219
- .appendField(new Smalruby.FieldCharacter(), 'CHAR')
220
- .appendField(<%= bm('.character_property_middle') %>)
221
- .appendField(new Blockly.FieldDropdown(dropdown), 'PROPERTY')
218
+ @interpolateMsg(<%= bm('.character_property') %>,
219
+ ['CHAR', new Smalruby.FieldCharacter()],
220
+ ['PROPERTY', new Blockly.FieldDropdown(dropdown)],
221
+ Blockly.ALIGN_RIGHT)
222
222
  @setOutput(true, ['Number', 'String'])
223
223
  @setTooltip('')
224
224
 
@@ -244,9 +244,9 @@ Blockly.Blocks['<%= n %>'] =
244
244
 
245
245
  @setHelpUrl('')
246
246
  @setColour(<%= color %>)
247
- @appendDummyInput()
248
- .appendField(<%= bm('.time_now') %>)
249
- .appendField(new Blockly.FieldDropdown(dropdown), 'METHOD')
247
+ @interpolateMsg(<%= bm('.time_now') %>,
248
+ ['METHOD', new Blockly.FieldDropdown(dropdown)],
249
+ Blockly.ALIGN_RIGHT)
250
250
  @setOutput(true, 'Number')
251
251
  @setTooltip('')
252
252
 
@@ -261,7 +261,7 @@ Blockly.Blocks['<%= n %>'] =
261
261
  @setHelpUrl('')
262
262
  @setColour(<%= color %>)
263
263
  @appendDummyInput()
264
- .appendField('2000年からの日数')
264
+ .appendField(<%= bm('.days_since_2000') %>)
265
265
  @setOutput(true, 'Number')
266
266
  @setTooltip('')
267
267
 
@@ -23,7 +23,9 @@ Blockly.Blocks['<%= n %>'] =
23
23
  ]
24
24
  @setHelpUrl('')
25
25
  @setColour(<%= color %>)
26
- @appendDummyInput().appendField(new Blockly.FieldDropdown(sounds), 'NAME')
26
+ @interpolateMsg(<%= bm('.preset_sounds') %>,
27
+ ['NAME', new Blockly.FieldDropdown(sounds)],
28
+ Blockly.ALIGN_RIGHT)
27
29
  @setOutput(true, 'String')
28
30
  @setTooltip('')
29
31
 
@@ -0,0 +1,105 @@
1
+ /**
2
+ * this program copied from Blockly and modified
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ <%
18
+ require 'smalruby_editor'
19
+ %>
20
+
21
+ // blockly/core/toolbox.js
22
+ // HACK: don't close category when clicked twice
23
+ Blockly.Toolbox.TreeNode.prototype.onMouseDown = function(e) {
24
+ // Expand icon.
25
+ if (this.hasChildren() && this.isUserCollapsible_) {
26
+ this.toggle();
27
+ this.select();
28
+ } else if (this.isSelected()) {
29
+ //this.getTree().setSelectedItem(null);
30
+ } else {
31
+ this.select();
32
+ }
33
+ this.updateRow();
34
+ };
35
+
36
+ Blockly.Blocks.math.HUE = <%= SmalrubyEditor::COLORS[:operators] %>;
37
+ Blockly.Blocks.texts.HUE = <%= SmalrubyEditor::COLORS[:operators] %>;
38
+
39
+ // blockly/core/field_textinput.js
40
+ Blockly.FieldTextInput.prototype.showEditorOrig_ =
41
+ Blockly.FieldTextInput.prototype.showEditor_;
42
+ Blockly.FieldTextInput.prototype.showEditor_ = function(opt_quietInput) {
43
+ Blockly.FieldTextInput.prototype.showEditorOrig_.apply(this, arguments);
44
+ var htmlInput = Blockly.FieldTextInput.htmlInput_;
45
+ htmlInput.onKeyDownWrapper_ =
46
+ Blockly.bindEvent_(htmlInput, 'keydown', this, this.onHtmlInputChange2_);
47
+ };
48
+
49
+ Blockly.FieldTextInput.prototype.onHtmlInputChange_ = function(e) {
50
+ var htmlInput = Blockly.FieldTextInput.htmlInput_;
51
+ if (e.keyCode != 27) {
52
+ // Update source block.
53
+ var text = htmlInput.value;
54
+ if (text !== htmlInput.oldValue_) {
55
+ htmlInput.oldValue_ = text;
56
+ this.setText(text);
57
+ this.validate_();
58
+ } else if (goog.userAgent.WEBKIT) {
59
+ // Cursor key. Render the source block to show the caret moving.
60
+ // Chrome only (version 26, OS X).
61
+ this.sourceBlock_.render();
62
+ }
63
+ }
64
+ };
65
+
66
+ Blockly.FieldTextInput.prototype.onHtmlInputChange2_ = function(e) {
67
+ var htmlInput = Blockly.FieldTextInput.htmlInput_;
68
+ if (e.keyCode == 13) {
69
+ // Enter
70
+ Blockly.WidgetDiv.hide();
71
+ } else if (e.keyCode == 27) {
72
+ // Esc
73
+ this.setText(htmlInput.defaultValue);
74
+ Blockly.WidgetDiv.hide();
75
+ }
76
+ };
77
+
78
+ Blockly.FieldTextInput.prototype.widgetDisposeOrig_ =
79
+ Blockly.FieldTextInput.prototype.widgetDispose_;
80
+ Blockly.FieldTextInput.prototype.widgetDispose_ = function() {
81
+ var thisField = this;
82
+ return function() {
83
+ Blockly.FieldTextInput.prototype.widgetDisposeOrig_.call(thisField);
84
+ var htmlInput = Blockly.FieldTextInput.htmlInput_;
85
+ Blockly.unbindEvent_(htmlInput.onKeyDownWrapper_);
86
+ };
87
+ };
88
+
89
+ // blockly/core/names.js
90
+ Blockly.Names.prototype.safeName_ = function(name) {
91
+ if (!name) {
92
+ name = 'unnamed';
93
+ } else {
94
+ // Unfortunately names in non-latin characters will look like
95
+ // _E9_9F_B3_E4_B9_90 which is pretty meaningless.
96
+ // HACK: Rubyでは日本語の変数名を許可しているためencodeURIを行わない。
97
+ // また、使えない記号を置換する。
98
+ name = name.replace(/[ !"#$%&'()=\-~^\\|`@{\[+;*:}\]<>,.?\/]/g, '_')
99
+ // Most languages don't allow names with leading numbers.
100
+ if ('0123456789'.indexOf(name[0]) != -1) {
101
+ name = '_' + name;
102
+ }
103
+ }
104
+ return name;
105
+ };
@@ -51,6 +51,9 @@ Blockly.Ruby.init = ->
51
51
  @definitions_['receiver_stack'] = ['main']
52
52
  @definitions_['character_stack'] = []
53
53
 
54
+ if Smalruby.isEnabled('auto_init_hardware')
55
+ @definitions_['init_hardware'] = 'init_hardware'
56
+
54
57
  Blockly.Ruby.defineCharacter = (c) ->
55
58
  name = c.get('name')
56
59
  blockName = "character_#{name}"