mirror of
https://github.com/google/blockly.git
synced 2026-01-30 12:10:12 +01:00
Add a Lua code generator
This is based on the JS generator, with a lot of inspiration from Ellen Spertus's blockly-lua: https://github.com/espertus/blockly-lua All unit tests pass with Lua 5.3.2.
This commit is contained in:
@@ -244,7 +244,7 @@ Code.LANG = Code.getLang();
|
||||
* List of tab names.
|
||||
* @private
|
||||
*/
|
||||
Code.TABS_ = ['blocks', 'javascript', 'php', 'python', 'dart', 'xml'];
|
||||
Code.TABS_ = ['blocks', 'javascript', 'php', 'python', 'dart', 'lua', 'xml'];
|
||||
|
||||
Code.selected = 'blocks';
|
||||
|
||||
@@ -341,6 +341,14 @@ Code.renderContent = function() {
|
||||
code = prettyPrintOne(code, 'dart');
|
||||
content.innerHTML = code;
|
||||
}
|
||||
} else if (content.id == 'content_lua') {
|
||||
code = Blockly.Lua.workspaceToCode(Code.workspace);
|
||||
content.textContent = code;
|
||||
if (typeof prettyPrintOne == 'function') {
|
||||
code = content.innerHTML;
|
||||
code = prettyPrintOne(code, 'lua');
|
||||
content.innerHTML = code;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<script src="../../python_compressed.js"></script>
|
||||
<script src="../../php_compressed.js"></script>
|
||||
<script src="../../dart_compressed.js"></script>
|
||||
<script src="../../lua_compressed.js"></script>
|
||||
<script src="code.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -41,6 +42,8 @@
|
||||
<td class="tabmin"> </td>
|
||||
<td id="tab_dart" class="taboff">Dart</td>
|
||||
<td class="tabmin"> </td>
|
||||
<td id="tab_lua" class="taboff">Lua</td>
|
||||
<td class="tabmin"> </td>
|
||||
<td id="tab_xml" class="taboff">XML</td>
|
||||
<td class="tabmax">
|
||||
<button id="trashButton" class="notext" title="...">
|
||||
@@ -67,6 +70,7 @@
|
||||
<pre id="content_php" class="content"></pre>
|
||||
<pre id="content_python" class="content"></pre>
|
||||
<pre id="content_dart" class="content"></pre>
|
||||
<pre id="content_lua" class="content"></pre>
|
||||
<textarea id="content_xml" class="content" wrap="off"></textarea>
|
||||
|
||||
<xml id="toolbox" style="display: none">
|
||||
|
||||
Reference in New Issue
Block a user