aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/ScriptingRepl.tsx
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-07-28 17:59:00 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-07-28 17:59:00 -0400
commitbe1e6e967a60f49eec1cb1d404912b0736812323 (patch)
treed0ea9b9eae9834b44c28fc91794e84bf8a168fc2 /src/client/views/ScriptingRepl.tsx
parent5fd48d3d10e86cea834f0238ec5d648febb62c81 (diff)
Added ability to capture documents in button scripts
Diffstat (limited to 'src/client/views/ScriptingRepl.tsx')
-rw-r--r--src/client/views/ScriptingRepl.tsx31
1 files changed, 3 insertions, 28 deletions
diff --git a/src/client/views/ScriptingRepl.tsx b/src/client/views/ScriptingRepl.tsx
index 0cff145b6..e05195ca0 100644
--- a/src/client/views/ScriptingRepl.tsx
+++ b/src/client/views/ScriptingRepl.tsx
@@ -4,41 +4,16 @@ import { observable, action } from 'mobx';
import './ScriptingRepl.scss';
import { Scripting, CompileScript, ts, Transformer } from '../util/Scripting';
import { DocumentManager } from '../util/DocumentManager';
-import { DocumentView } from './nodes/DocumentView';
import { OverlayView } from './OverlayView';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { library } from '@fortawesome/fontawesome-svg-core';
import { faCaretDown, faCaretRight } from '@fortawesome/free-solid-svg-icons';
+import { DocumentIconContainer } from './nodes/DocumentIcon';
library.add(faCaretDown);
library.add(faCaretRight);
@observer
-export class DocumentIcon extends React.Component<{ view: DocumentView, index: number }> {
- render() {
- const view = this.props.view;
- const transform = view.props.ScreenToLocalTransform().scale(view.props.ContentScaling()).inverse();
- const { x, y, width, height } = transform.transformBounds(0, 0, view.props.PanelWidth(), view.props.PanelHeight());
-
- return (
- <div className="documentIcon-outerDiv" style={{
- position: "absolute",
- transform: `translate(${x + width / 2}px, ${y}px)`,
- }}>
- <p>${this.props.index}</p>
- </div>
- );
- }
-}
-
-@observer
-export class DocumentIconContainer extends React.Component {
- render() {
- return DocumentManager.Instance.DocumentViews.map((dv, i) => <DocumentIcon key={i} index={i} view={dv} />);
- }
-}
-
-@observer
export class ScriptingObjectDisplay extends React.Component<{ scrollToBottom: () => void, value: { [key: string]: any }, name?: string }> {
@observable collapsed = true;
@@ -129,7 +104,7 @@ export class ScriptingRepl extends React.Component {
if (ts.isParameter(node.parent)) {
// delete knownVars[node.text];
} else if (isntPropAccess && isntPropAssign && !(node.text in knownVars) && !(node.text in globalThis)) {
- const match = node.text.match(/\$([0-9]+)/);
+ const match = node.text.match(/\d([0-9]+)/);
if (match) {
const m = parseInt(match[1]);
usedDocuments.push(m);
@@ -153,7 +128,7 @@ export class ScriptingRepl extends React.Component {
switch (e.key) {
case "Enter": {
const docGlobals: { [name: string]: any } = {};
- DocumentManager.Instance.DocumentViews.forEach((dv, i) => docGlobals[`$${i}`] = dv.props.Document);
+ DocumentManager.Instance.DocumentViews.forEach((dv, i) => docGlobals[`d${i}`] = dv.props.Document);
const globals = Scripting.makeMutableGlobalsCopy(docGlobals);
const script = CompileScript(this.commandString, { typecheck: false, addReturn: true, editable: true, params: { args: "any" }, transformer: this.getTransformer(), globals });
if (!script.compiled) {