Make editors readonly during execution
This commit is contained in:
parent
ffc9c03452
commit
251a6836f5
@ -137,6 +137,7 @@ export const Mainframe = <RS extends {}>({ langName, provider }: Props<RS>) => {
|
|||||||
<CodeEditor
|
<CodeEditor
|
||||||
ref={codeEditorRef}
|
ref={codeEditorRef}
|
||||||
languageId="brainfuck"
|
languageId="brainfuck"
|
||||||
|
readOnly={execController.state === "processing"}
|
||||||
defaultValue={providerRef.current.sampleProgram}
|
defaultValue={providerRef.current.sampleProgram}
|
||||||
tokensProvider={providerRef.current.editorTokensProvider}
|
tokensProvider={providerRef.current.editorTokensProvider}
|
||||||
onValidateCode={execController.validateCode}
|
onValidateCode={execController.validateCode}
|
||||||
@ -151,7 +152,12 @@ export const Mainframe = <RS extends {}>({ langName, provider }: Props<RS>) => {
|
|||||||
renderer={providerRef.current.Renderer as any}
|
renderer={providerRef.current.Renderer as any}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
renderInput={() => <InputEditor ref={inputEditorRef} />}
|
renderInput={() => (
|
||||||
|
<InputEditor
|
||||||
|
ref={inputEditorRef}
|
||||||
|
readOnly={execController.state === "processing"}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
renderOutput={() => <OutputViewer ref={outputEditorRef} />}
|
renderOutput={() => <OutputViewer ref={outputEditorRef} />}
|
||||||
renderExecControls={() => (
|
renderExecControls={() => (
|
||||||
<ExecutionControls
|
<ExecutionControls
|
||||||
|
@ -29,6 +29,8 @@ type Props = {
|
|||||||
defaultValue: string;
|
defaultValue: string;
|
||||||
/** Tokens provider for the language */
|
/** Tokens provider for the language */
|
||||||
tokensProvider?: MonacoTokensProvider;
|
tokensProvider?: MonacoTokensProvider;
|
||||||
|
/** Set editor as read-only */
|
||||||
|
readOnly?: boolean;
|
||||||
/** Callback to validate code syntax */
|
/** Callback to validate code syntax */
|
||||||
onValidateCode: (code: string) => Promise<WorkerParseError | undefined>;
|
onValidateCode: (code: string) => Promise<WorkerParseError | undefined>;
|
||||||
/** Callback to update debugging breakpoints */
|
/** Callback to update debugging breakpoints */
|
||||||
@ -107,7 +109,11 @@ const CodeEditorComponent = (props: Props, ref: React.Ref<CodeEditorRef>) => {
|
|||||||
setEditor(editor);
|
setEditor(editor);
|
||||||
setMonaco(monaco);
|
setMonaco(monaco);
|
||||||
}}
|
}}
|
||||||
options={{ minimap: { enabled: false }, glyphMargin: true }}
|
options={{
|
||||||
|
minimap: { enabled: false },
|
||||||
|
glyphMargin: true,
|
||||||
|
readOnly: props.readOnly,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -12,7 +12,10 @@ export interface InputEditorRef {
|
|||||||
/**
|
/**
|
||||||
* A very simple text editor for user input
|
* A very simple text editor for user input
|
||||||
*/
|
*/
|
||||||
const InputEditorComponent = (_: {}, ref: React.Ref<InputEditorRef>) => {
|
const InputEditorComponent = (
|
||||||
|
props: { readOnly?: boolean },
|
||||||
|
ref: React.Ref<InputEditorRef>
|
||||||
|
) => {
|
||||||
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null);
|
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null);
|
||||||
|
|
||||||
React.useImperativeHandle(
|
React.useImperativeHandle(
|
||||||
@ -29,6 +32,7 @@ const InputEditorComponent = (_: {}, ref: React.Ref<InputEditorRef>) => {
|
|||||||
large
|
large
|
||||||
growVertically
|
growVertically
|
||||||
inputRef={textareaRef}
|
inputRef={textareaRef}
|
||||||
|
readOnly={props.readOnly}
|
||||||
placeholder="Enter program input here..."
|
placeholder="Enter program input here..."
|
||||||
style={{ height: "100%", resize: "none", boxShadow: "none" }}
|
style={{ height: "100%", resize: "none", boxShadow: "none" }}
|
||||||
/>
|
/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user