Skip to content

Commit

Permalink
SUKU tek2 endless functions implemented, sriptToSegment now resprects…
Browse files Browse the repository at this point in the history
… nested commas
  • Loading branch information
SukuWc committed Apr 17, 2024
1 parent 3900e55 commit a48bf81
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 66 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"firebase": "^9.18.0",
"fs-extra": "^10.0.0",
"googleapis": "^100.0.0",
"grid-protocol": "^1.2.31",
"grid-protocol": "^1.2.34",
"is-online": "^10.0.0",
"lua-format": "1.4.1",
"luaparse": "^0.3.0",
Expand Down
40 changes: 39 additions & 1 deletion src/renderer/config-blocks/_script_parsers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
function splitExpression(expression) {
var parts = [];
var currentPart = "";
var parenthesisCount = 0;
var bracketCount = 0;

for (var i = 0; i < expression.length; i++) {
var char = expression.charAt(i);

if (
(char === "," && parenthesisCount === 0 && bracketCount === 0) ||
i === expression.length - 1
) {
if (i === expression.length - 1 && char !== ",") {
currentPart += char;
}
parts.push(currentPart.trim());
currentPart = "";
} else {
currentPart += char;
if (char === "(") {
parenthesisCount++;
} else if (char === ")") {
parenthesisCount--;
} else if (char === "[") {
bracketCount++;
} else if (char === "]") {
bracketCount--;
}
}
}

return parts;
}

export class Script {
static toSegments({ script, short }) {
const expressions = [
Expand Down Expand Up @@ -28,7 +63,10 @@ export class Script {
// remove parenthesis
config = config.replace(/^\((.*)\)$/, "$1");
// split by comma to make array
config = config.split(",");

// old implementation: config = config.split(",");
config = splitExpression(config);

break;
}
case "for loop": {
Expand Down
22 changes: 19 additions & 3 deletions src/renderer/lib/CustomMonaco.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,19 @@ function initialize_autocomplete() {
range: range,
};

if (key.startsWith("GRID_LUA_FNC_E") && key.endsWith("_human")) {
if (key.startsWith("GRID_LUA_FNC_EP") && key.endsWith("_human")) {
if (elementtype === "endless" || elementtype === undefined) {
proposalItem.label = "self:" + grid_protocol[key];
proposalItem.insertText = "self:" + grid_protocol[key] + "()";
} else if (elementtype === "system") {
proposalItem.label = "element[0]:" + grid_protocol[key];
proposalItem.insertText =
"element[0]:" + grid_protocol[key] + "()";
}
} else if (
key.startsWith("GRID_LUA_FNC_E") &&
key.endsWith("_human")
) {
if (elementtype === "encoder" || elementtype === undefined) {
proposalItem.label = "self:" + grid_protocol[key];
proposalItem.insertText = "self:" + grid_protocol[key] + "()";
Expand All @@ -337,7 +349,7 @@ function initialize_autocomplete() {
}

if (key.startsWith("GRID_LUA_FNC_P") && key.endsWith("_human")) {
if (elementtype === "potentiometer" || elementtype === undefined) {
if (elementtype === "potmeter" || elementtype === undefined) {
proposalItem.label = "self:" + grid_protocol[key];
proposalItem.insertText = "self:" + grid_protocol[key] + "()";
} else if (elementtype === "system") {
Expand Down Expand Up @@ -396,7 +408,11 @@ function initialize_highlight() {
"Global function named " + grid_protocol[key];
}

if (key.startsWith("GRID_LUA_FNC_E") && key.endsWith("_human")) {
if (key.startsWith("GRID_LUA_FNC_EP") && key.endsWith("_human")) {
language.functions.push(grid_protocol[key]);
hoverTips[grid_protocol[key]] =
"Endless function named " + grid_protocol[key];
} else if (key.startsWith("GRID_LUA_FNC_E") && key.endsWith("_human")) {
language.functions.push(grid_protocol[key]);
hoverTips[grid_protocol[key]] =
"Encoder function named " + grid_protocol[key];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<svg
data-control-number={elementNumber}
data-module-id={id}
data-control-element-type="button"
width={size * buttonSize + "px"}
height={size * buttonSize + "px"}
viewBox="0 0 30 30 "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
style="filter:url(#dropshadow)"
data-control-number={elementNumber}
data-module-id={id}
data-control-element-type="encoder"
width={size * encoderSize + "px"}
height={size * encoderSize + "px"}
viewBox="0 0 30 30"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
on:grabend={handleGrabEnd}
data-control-number={elementNumber}
data-module-id={id}
data-control-element-type="potentiometer"
width={size * knobSize + "px"}
height={size * knobSize + "px"}
viewBox="0 0 30 30"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
on:grabmove={handleGrabMove}
on:grabend={handleGrabEnd}
data-control-number={elementNumber}
data-control-element-type="fader"
data-module-id={id}
id="fader-cap"
width={size * faderWidth + "px"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
on:grabend={handleGrabEnd}
data-control-number={elementNumber}
data-module-id={id}
data-control-element-type="potentiometer"
width={size * knobSize + "px"}
height={size * knobSize + "px"}
viewBox="0 0 30 30"
Expand Down
11 changes: 0 additions & 11 deletions src/renderer/main/panels/DebugMonitor/DebugMonitor.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,6 @@ function createLuaError() {

switch (type) {
case "luanotok":
/*
"GRID_EVENT_INIT": "00",
"GRID_EVENT_AC": "01",
"GRID_EVENT_EC": "02",
"GRID_EVENT_BC": "03",
"GRID_EVENT_MAP": "04",
"GRID_EVENT_MIDIRX": "05",
"GRID_EVENT_TIMER": "06",
*/

if (d.length >= 15) {
d.shift();
}
Expand Down
Loading

0 comments on commit a48bf81

Please sign in to comment.