Skip to content

Commit

Permalink
Add functions and drag, remove prints
Browse files Browse the repository at this point in the history
  • Loading branch information
ltuthill committed Sep 1, 2021
1 parent 89a787a commit 73b504e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
14 changes: 6 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ class App extends React.Component<any, State> {
}

parse = (expr: string) => {
expr = expr.replace(/([^\w_])?sin\(/g, (_, prefix) => prefix ?? "" + " Math.sin(");
expr = expr.replace(/([^\w_])?cos\(/g, (_, prefix) => prefix ?? "" + " Math.cos(");
expr = expr.replace(/([^\w_])?tan\(/g, (_, prefix) => prefix ?? "" + " Math.tan(");
expr = expr.replace(/(Math\.)?sin\(/g, "Math.sin(");
expr = expr.replace(/(Math\.)?cos\(/g, "Math.cos(");
expr = expr.replace(/(Math\.)?tan\(/g, "Math.tan(");
expr = expr.replace(/(Math\.)?sqrt\(/g, "Math.sqrt(");
return expr;
}

Expand All @@ -104,7 +105,6 @@ class App extends React.Component<any, State> {
if (overrides != undefined) {
let override = overrides[label];
if (override != null && override != undefined) {
console.log(`${label} override: ${override}`);
value = override.toString();
}
}
Expand All @@ -118,13 +118,13 @@ class App extends React.Component<any, State> {
else
return '0';
} catch (e) {
console.log(e);
//console.log(e);
return 0;
}
}

freeLabels = (blocks: any, expr: string) => {
return Array.from(expr.matchAll(/\$(?<label>[\w_]+)/g)).filter(match => blocks.filter((row: any) => row.filter((block: any) => block.label == match.groups?.label).length > 0).length == 0).map(match => match[0].substr(1));
return Array.from(new Set<any>(Array.from(expr.matchAll(/\$(?<label>[\w_]+)/g)).filter(match => blocks.filter((row: any) => row.filter((block: any) => block.label == match.groups?.label).length > 0).length == 0).map(match => match[0].substr(1))));
}

renderBlocks = (text: string, overrides?: any) => {
Expand Down Expand Up @@ -173,7 +173,6 @@ class App extends React.Component<any, State> {

makeRow = (row: any, i: number) => {
let j: number = 0;
console.log(row);
return <div className='block-row' key={i}>{row.map((block: any) => this.makeBlock(block, j++))}</div>;
}

Expand All @@ -191,7 +190,6 @@ class App extends React.Component<any, State> {
}

render = () => {
console.log(this.state);
let i = 0;
return (
<main className="app">
Expand Down
2 changes: 1 addition & 1 deletion src/electron/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function createWindow() {
label: process.platform === 'darwin' ? 'Quit' : 'Close',
accelerator: process.platform === 'darwin' ? 'Cmd+Q' : 'Ctrl+Q',
role: 'quit'
}
},
]
},
{
Expand Down
5 changes: 5 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
body, html {
-webkit-user-select: none;
-webkit-app-region: drag;
padding: 0;
margin: 0;
height: 100%;
Expand All @@ -7,6 +9,7 @@ body, html {

div.block-row {
display: flex;
-webkit-app-region: none;
}

div.block-row:not(:first-of-type) {
Expand Down Expand Up @@ -52,6 +55,8 @@ textarea.program-input {
box-shadow: 0 0 5px 5px rgba(0, 0, 0, 0.1) inset;
justify-self: stretch;
align-self: stretch;
-webkit-user-select: text;
-webkit-app-region: none;
resize: none;
flex-grow: 1;
border: 0;
Expand Down

0 comments on commit 73b504e

Please sign in to comment.