Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Sytax highliting #12

Merged
merged 2 commits into from
Apr 15, 2024
Merged
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
64 changes: 32 additions & 32 deletions Frontend/Blocks/block_definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Blockly.Blocks['string_block'] = {
this.appendDummyInput()
.appendField(new Blockly.FieldTextInput("Hello World!"), "input");
this.setOutput(true, null);
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -18,7 +18,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck(null);
this.setOutput(true, null);
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -33,7 +33,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck(null);
this.setOutput(true, null);
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -46,7 +46,7 @@ Blockly.Blocks['string_block'] = {
.appendField("print");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(260);
this.setColour('#4C97FF');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -63,7 +63,7 @@ Blockly.Blocks['string_block'] = {
.appendField("then");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(65);
this.setColour('#FFBF00');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -74,7 +74,7 @@ Blockly.Blocks['string_block'] = {
this.appendDummyInput()
.appendField(new Blockly.FieldNumber(0), "input");
this.setOutput(true, "Number");
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -89,7 +89,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck(null);
this.setOutput(true, "Boolean");
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -108,7 +108,7 @@ Blockly.Blocks['string_block'] = {
.appendField("else");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(65);
this.setColour('#FFAB19');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -123,7 +123,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck("Number");
this.setOutput(true, null);
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -138,7 +138,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck(null);
this.setOutput(true, null);
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -153,7 +153,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck(null);
this.setOutput(true, "Boolean");
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -172,7 +172,7 @@ Blockly.Blocks['string_block'] = {
.appendField("else");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(65);
this.setColour('#FFBF00');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -187,7 +187,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck("Number");
this.setOutput(true, null);
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -202,7 +202,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck(null);
this.setOutput(true, null);
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -218,7 +218,7 @@ Blockly.Blocks['string_block'] = {
.appendField("do");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(65);
this.setColour('#FFBF00');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -233,7 +233,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck(null);
this.setOutput(true, "Boolean");
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -248,7 +248,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck(null);
this.setOutput(true, "Boolean");
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -263,7 +263,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck(null);
this.setOutput(true, "Boolean");
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -278,7 +278,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck(null);
this.setOutput(true, "Boolean");
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -290,7 +290,7 @@ Blockly.Blocks['string_block'] = {
.appendField("input")
.appendField(new Blockly.FieldTextInput("prompt"), "input");
this.setOutput(true, "String");
this.setColour(260);
this.setColour('#4C97FF');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -301,7 +301,7 @@ Blockly.Blocks['string_block'] = {
this.appendDummyInput()
.appendField("True");
this.setOutput(true, "Boolean");
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -312,7 +312,7 @@ Blockly.Blocks['string_block'] = {
this.appendDummyInput()
.appendField("False");
this.setOutput(true, "Boolean");
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -327,7 +327,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck("Number");
this.setOutput(true, null);
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -342,7 +342,7 @@ Blockly.Blocks['string_block'] = {
this.appendValueInput("right")
.setCheck("Number");
this.setOutput(true, null);
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -362,7 +362,7 @@ Blockly.Blocks['string_block'] = {
.setCheck(null)
.appendField("step");
this.setOutput(true, null);
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -379,7 +379,7 @@ Blockly.Blocks['string_block'] = {
.setCheck(null);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(65);
this.setColour('#FFBF00');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -391,7 +391,7 @@ Blockly.Blocks['string_block'] = {
.appendField("list")
.appendField(new Blockly.FieldTextInput("1,2,3"), "input");
this.setOutput(true, null);
this.setColour(160);
this.setColour('#CF63CF');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -409,7 +409,7 @@ Blockly.Blocks['string_block'] = {
.setCheck(null);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(160);
this.setColour('#CF63CF');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -423,7 +423,7 @@ Blockly.Blocks['string_block'] = {
.appendField(new Blockly.FieldNumber(0, 0, Infinity, 1), "index")
.appendField("of");
this.setOutput(true, null);
this.setColour(160);
this.setColour('#CF63CF');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -441,7 +441,7 @@ Blockly.Blocks['string_block'] = {
.appendField(new Blockly.FieldTextInput("1,2,3"), "value");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(160);
this.setColour('#CF63CF');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -459,7 +459,7 @@ Blockly.Blocks['string_block'] = {
.setCheck(null);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(160);
this.setColour('#CF63CF');
this.setTooltip("");
this.setHelpUrl("");
}
Expand All @@ -471,7 +471,7 @@ Blockly.Blocks['string_block'] = {
.appendField("str")
.appendField(new Blockly.FieldNumber(0, 0, Infinity, 1), "number")
this.setOutput(true, null);
this.setColour(120);
this.setColour('#59C059');
this.setTooltip("");
this.setHelpUrl("");
}
Expand Down
80 changes: 46 additions & 34 deletions Frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,34 @@
</head>

<xml xmlns="https://developers.google.com/blockly/xml" id="toolbox" style="display: none">
<category name="Input/Output" colour="#4C97FF" css-icon="customIcon fa fa-file">
<block type="print_block" deletable="true" movable="true" editable="true"></block>
<block type="input_block" deletable="true" movable="true" editable="true">
<field name="input">prompt</field>
</block>
</category>
<category name="List Operations" colour="#CF63CF" css-icon="customIcon fa fa-list">
<block type="list_block" deletable="true" movable="true" editable="true">
<field name="input">1,2,3</field>
</block>
<block type="list_append_block" deletable="true" movable="true" editable="true"></block>
<block type="list_remove_block"></block>
<block type="list_index_get_block" deletable="true" movable="true" editable="true">
<field name="index">0</field>
</block>
<block type="list_index_set_block" deletable="true" movable="true" editable="true">
<field name="index">0</field>
<field name="value">x</field>
</block>
</category>
<category name="Control" colour="#FFBF00" css-icon="customIcon fa fa-sitemap">
<block type="if_block" deletable="true" movable="true" editable="true"></block>
<block type="if_else_block" deletable="true" movable="true" editable="true"></block>
<block type="while_block" deletable="true" movable="true" editable="true"></block>
<block type="for_block" deletable="true" movable="true" editable="true">
<field name="variable">index</field>
</block>
</category>
<category name="Operators" colour="#59C059" css-icon="customIcon fa fa-cog">
<block type="string_block" deletable="true" movable="true" editable="true">
<field name="input">Hello World!</field>
Expand All @@ -46,37 +74,12 @@
<block type="int_str_conv_block" deletable="true" movable="true" editable="true"></block>

</category>
<category name="List Operations" colour="#5ba58c" css-icon="customIcon fa fa-list">
<block type="list_block" deletable="true" movable="true" editable="true">
<field name="input">1,2,3</field>
</block>
<block type="list_append_block" deletable="true" movable="true" editable="true"></block>
<block type="list_remove_block"></block>
<block type="list_index_get_block" deletable="true" movable="true" editable="true">
<field name="index">0</field>
</block>
<block type="list_index_set_block" deletable="true" movable="true" editable="true">
<field name="index">0</field>
<field name="value">x</field>
</block>
</category>
<category name="Input/Output" colour="#745ba5" css-icon="customIcon fa fa-file">
<block type="print_block" deletable="true" movable="true" editable="true"></block>
<block type="input_block" deletable="true" movable="true" editable="true">
<field name="input">prompt</field>
</block>
</category>
<category name="Control" colour="#9fa55b" css-icon="customIcon fa fa-sitemap">
<block type="if_block" deletable="true" movable="true" editable="true"></block>
<block type="if_else_block" deletable="true" movable="true" editable="true"></block>
<block type="while_block" deletable="true" movable="true" editable="true"></block>
<block type="for_block" deletable="true" movable="true" editable="true">
<field name="variable">index</field>
</block>
</category>


<sep></sep>
<category name="Functions" colour="#995ba5" custom="PROCEDURE" css-icon="customIcon fa fa-cubes"></category>
<category name="Variables" colour="#a55b80" custom="VARIABLE" css-icon="customIcon fa fa-bath"></category>
<category name="Variables" colour="#FF8C1A" custom="VARIABLE" css-icon="customIcon fa fa-bath"></category>

<category name="Functions" colour="#FF6680" custom="PROCEDURE" css-icon="customIcon fa fa-cubes"></category>
</xml>
<xml xmlns="https://developers.google.com/blockly/xml" id="workspaceBlocks" style="display: none"></xml>

Expand All @@ -100,8 +103,9 @@
<div class="button-row">
<p class="code-title">Python Code</p>
<div class="button-group">
<a class="button" id="run-button"><i id="run-icon" class="fa fa-flag"></i> <span id="run-text">Run</span></a>
<a class="button" id="copy-button"><i class="fa fa-copy"></i><span id = "copy-text">Copy</span></a>
<a class="button" id="run-button"><i id="run-icon" class="fa fa-flag"></i> <span
id="run-text">Run</span></a>
<a class="button" id="copy-button"><i class="fa fa-copy"></i><span id="copy-text">Copy</span></a>
</div>
</div>
<div class="code-snippet">
Expand All @@ -114,8 +118,16 @@
</div>
</div>
<div class="output">
<p class="output-title">Output</p>
<textarea id="terminal-output" class="terminal-output" rows="10" readonly></textarea>
<div class="button-row">
<p class="output-title">Output</p>
<div class="button-group">
<a class="button" id="clear-button"><i id="run-clear" class="fa fa-trash"></i> <span
id="run-text">Clear</span></a>
</div>
</div>
<div class="terminal-output-div">
<textarea id="terminal-output" class="terminal-output" rows="10" readonly></textarea>
</div>
</div>
</div>
</body>
Expand Down
Loading