Skip to content

Commit af3c157

Browse files
committed
Blockly: nouveau bloc Type.
1 parent cd10887 commit af3c157

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

microalg_export_blockly.l

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@
6969
"</block>"))
7070
(de Demander ()
7171
"<block type=\"demander\"></block>")
72+
(de Type (content)
73+
(pack "<block type=\"type\">"
74+
"<value name=\"VALUE\">"
75+
content
76+
"</value>"
77+
"</block>"))
7278
(de Nombre (content)
7379
(pack "<block type=\"nombre\">"
7480
"<value name=\"VALUE\">"

web/blockly_microalg.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,29 @@ Blockly.MicroAlg['texte'] = function(block) {
460460
};
461461

462462
// Bloc Type
463+
Blockly.Blocks['type'] = {
464+
init: function() {
465+
this.setHelpUrl(malg_url + '#cmd-Type');
466+
this.setColour(20);
467+
this.appendValueInput('VALUE')
468+
.appendField('Type');
469+
this.setOutput(true, 'String');
470+
this.setTooltip('Convertir une valeur en texte.');
471+
}
472+
};
473+
463474
// Gen Type
475+
Blockly.MicroAlg['type'] = function(block) {
476+
var arg = Blockly.MicroAlg.statementToCode(block, 'VALUE') || '';
477+
if (arg === '') return '(Type)';
478+
var num_lines = arg.split('\n').length;
479+
if (num_lines == 1) {
480+
// Prevent indentation if we only have one line.
481+
return '(Type ' + arg.substring(Blockly.MicroAlg.INDENT.length) + ')';
482+
} else {
483+
return '(Type\n' + arg + '\n)';
484+
}
485+
};
464486

465487
// Bloc <
466488
// Gen <

web/ide_injections.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ function inject_microalg_blockly_in(elt_id, editor_id, msg) {
255255
' <block type="concatener"></block>' +
256256
' <block type="demander"></block>' +
257257
' <block type="operations"></block>' +
258+
' <block type="type"></block>' +
258259
' <block type="texte?"></block>' +
259260
' <block type="texte"></block>' +
260261
' <block type="nombre?"></block>' +

0 commit comments

Comments
 (0)