From b2936e020019d2bed910095df5adc4fc953deea2 Mon Sep 17 00:00:00 2001 From: Jon Eugster Date: Sun, 8 Oct 2023 01:54:46 +0200 Subject: [PATCH] show typewriter input as disabled if non-primary goal is selected --- client/src/components/infoview/infoview.css | 16 ++++++++++++++++ client/src/components/infoview/main.tsx | 18 ++++++++++++------ client/src/components/infoview/typewriter.tsx | 4 ++-- client/src/components/level.tsx | 2 +- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/client/src/components/infoview/infoview.css b/client/src/components/infoview/infoview.css index 274c022..ddd23c9 100644 --- a/client/src/components/infoview/infoview.css +++ b/client/src/components/infoview/infoview.css @@ -51,6 +51,22 @@ /* margin: 0.2em 0 0; */ } +.typewriter.disabled{ + background: #bbb; +} + +.typewriter.disabled .btn-inverted, +.typewriter.disabled .mtk1 { + color: #777; +} + +.typewriter.disabled .typewriter-input-wrapper, +.typewriter.disabled .monaco-editor, +.typewriter.disabled .monaco-editor-background, +.typewriter.disabled .btn-inverted { + background-color: #eee; +} + .typewriter form { display: flex; } diff --git a/client/src/components/infoview/main.tsx b/client/src/components/infoview/main.tsx index 853f79c..be8017e 100644 --- a/client/src/components/infoview/main.tsx +++ b/client/src/components/infoview/main.tsx @@ -261,16 +261,15 @@ function Command({ command, deleteProof }: { command: string, deleteProof: any } // }, fastIsEqual) /** The tabs of goals that lean ahs after the command of this step has been processed */ -function GoalsTabs({ proofStep, last, onClick}: { proofStep: ProofStep, last : boolean, onClick? : any }) { - const [selectedGoal, setSelectedGoal] = React.useState(0) +function GoalsTabs({ proofStep, last, onClick, onGoalChange=(n)=>{}}: { proofStep: ProofStep, last : boolean, onClick? : any, onGoalChange?: (n?: number) => void }) { - if (!proofStep.goals.length) { return <> } + const [selectedGoal, setSelectedGoal] = React.useState(0) return
{proofStep.goals.map((goal, i) => ( // TODO: Should not use index as key. -
{ setSelectedGoal(i); ev.stopPropagation() }}> +
{ onGoalChange(i); setSelectedGoal(i); ev.stopPropagation() }}> {i ? `Goal ${i + 1}` : "Active Goal"}
))} @@ -297,6 +296,8 @@ export function TypewriterInterface(props: { world: string, level: number, data: const proofPanelRef = React.useRef(null) + const [disableInput, setDisableInput] = React.useState(false) + /** Delete all proof lines starting from a given line. * Note that the first line (i.e. deleting everything) is `1`! */ @@ -342,6 +343,11 @@ export function TypewriterInterface(props: { world: string, level: number, data: } else { proofPanelRef.current?.scrollTo(0,0) } + // also reenable the commandline when the proof changes + + // BUG: If selecting 2nd goal on a intermediate proofstep and then delete proof to there, + // the commandline is not displaying disabled even though it should. + setDisableInput(false) }, [proof]) // Scroll to element if selection changes @@ -460,7 +466,7 @@ export function TypewriterInterface(props: { world: string, level: number, data: } } - + setDisableInput(n > 0) : (n) => {}}/> {/* Show a message that there are no goals left */} {!step.goals.length && (
@@ -493,7 +499,7 @@ export function TypewriterInterface(props: { world: string, level: number, data: }
-
} diff --git a/client/src/components/infoview/typewriter.tsx b/client/src/components/infoview/typewriter.tsx index 145f2df..49836ef 100644 --- a/client/src/components/infoview/typewriter.tsx +++ b/client/src/components/infoview/typewriter.tsx @@ -64,7 +64,7 @@ config.autoClosingPairs = config.autoClosingPairs.map( monaco.languages.setLanguageConfiguration('lean4cmd', config); /** The input field */ -export function Typewriter({hidden}: {hidden?: boolean}) { +export function Typewriter({hidden, disabled}: {hidden?: boolean, disabled?: boolean}) { /** Reference to the hidden multi-line editor */ const editor = React.useContext(MonacoEditorContext) @@ -308,7 +308,7 @@ export function Typewriter({hidden}: {hidden?: boolean}) { runCommand() } - return
+ return
diff --git a/client/src/components/level.tsx b/client/src/components/level.tsx index 04450ff..8f97f67 100644 --- a/client/src/components/level.tsx +++ b/client/src/components/level.tsx @@ -142,7 +142,7 @@ function ChatPanel({lastLevel}) {
{introText?.filter(t => t.trim()).map(((t, i) => + hint={{text: t, hidden: false}} step={0} selected={selectedStep} toggleSelection={toggleSelection(0)} /> ))} {proof.map((step, i) => { // It the last step has errors, it will have the same hints