diff --git a/client/src/components/chat.tsx b/client/src/components/chat.tsx index ec4c715..bcca2c3 100644 --- a/client/src/components/chat.tsx +++ b/client/src/components/chat.tsx @@ -11,11 +11,11 @@ import { useAppDispatch, useAppSelector } from '../hooks' import { Button, Markdown } from './utils' import { ChatContext, GameIdContext, PageContext, PreferencesContext, ProofContext } from '../state/context' import { GameHint, InteractiveGoalsWithHints } from './infoview/rpc_api' -import { lastStepHasErrors } from './infoview/goals' -import { AllMessages } from '../../../node_modules/@leanprover/infoview/dist/infoview/messages' -import { LeanDiagnostic, RpcErrorCode, getInteractiveDiagnostics, InteractiveDiagnostic, TaggedText_stripTags } from '@leanprover/infoview-api' +// import { lastStepHasErrors } from './infoview/goals' +// import { AllMessages } from '../../../node_modules/@leanprover/infoview/dist/infoview/messages' +// import { LeanDiagnostic, RpcErrorCode, getInteractiveDiagnostics, InteractiveDiagnostic, TaggedText_stripTags } from '@leanprover/infoview-api' import { Location, DocumentUri, Diagnostic, DiagnosticSeverity, PublishDiagnosticsParams } from 'vscode-languageserver-protocol' -import { InteractiveMessage } from '../../../node_modules/lean4-infoview/src/infoview/traceExplorer' +// import { InteractiveMessage } from '../../../node_modules/lean4-infoview/src/infoview/traceExplorer' import '../css/chat.css' import { faHome } from '@fortawesome/free-solid-svg-icons' @@ -39,9 +39,10 @@ export function MoreHelpButton({selected=null} : {selected?: number}) { const { proof } = React.useContext(ProofContext) const { showHelp, setShowHelp } = React.useContext(ChatContext) - let k = proof?.steps.length ? - ((selected === null) ? (proof?.steps.length - (lastStepHasErrors(proof) ? 2 : 1)) : selected) - : 0 + let k = 0 + // let k = proof?.steps.length ? + // ((selected === null) ? (proof?.steps.length - (lastStepHasErrors(proof) ? 2 : 1)) : selected) + // : 0 const activateHiddenHints = (ev) => { // If the last step (`k`) has errors, we want the hidden hints from the @@ -204,10 +205,10 @@ export function filterHints(hints: GameHint[], prevHints: GameHint[]): GameHint[ } // TODO -function helper(step, proof, kind, typewriterMode, selectedStep) { - return (step == proof?.steps?.length - (lastStepHasErrors(proof) ? 2 : 1) ? ' recent' : '') + - (!(kind == HintKind.Conclusion) && step >= (typewriterMode ? proof?.steps?.length : selectedStep+1) ? ' deleted-hint' : '') -} +// function helper(step, proof, kind, typewriterMode, selectedStep) { +// return (step == proof?.steps?.length - (lastStepHasErrors(proof) ? 2 : 1) ? ' recent' : '') + +// (!(kind == HintKind.Conclusion) && step >= (typewriterMode ? proof?.steps?.length : selectedStep+1) ? ' deleted-hint' : '') +// } /** A hint as it is displayed in the chat. */ export function Hint({hint, kind, step=null} : GameHintWithStep) { @@ -232,7 +233,7 @@ export function Hint({hint, kind, step=null} : GameHintWithStep) { // until the next command is submitted; in editor, moving the cursor through the proof will // render all hints return
- I'm an editor -
-} diff --git a/client/src/components/editor/Editor.tsx b/client/src/components/editor/Editor.tsx new file mode 100644 index 0000000..1933c71 --- /dev/null +++ b/client/src/components/editor/Editor.tsx @@ -0,0 +1,93 @@ +import * as React from 'react'; +import Split from 'react-split' +import { useContext, useEffect, useRef, useState } from 'react' +import { useTranslation } from "react-i18next" +import { GameIdContext } from '../../state/context'; +import { useLoadLevelQuery } from '../../state/api'; +import { Markdown } from '../utils'; +import * as monaco from 'monaco-editor' +import { LeanMonaco, LeanMonacoEditor, LeanMonacoOptions } from 'lean4monaco' + +import '../../css/editor.css' +import { useSelector } from 'react-redux'; +import { selectTypewriterMode } from '../../state/progress'; + +export function Editor() { + let { t } = useTranslation() + const {gameId, worldId, levelId } = useContext(GameIdContext) + + const typewriterMode = useSelector(selectTypewriterMode(gameId)) + + const editorRef = useRef{levelInfo.data?.descrFormat}
{t("Click somewhere in the Lean file to enable the infoview.")}
} -{t("Click somewhere in the Lean file to enable the infoview.")}
} +//{levelInfo.data?.descrFormat}
{t("Waiting for Lean server to start…")}
- } else if (serverStoppedResult) { - ret ={serverStoppedResult.message}
{serverStoppedResult.reason}
{levelInfo.data?.descrFormat}
{t("Waiting for Lean server to start…")}
+// } else if (serverStoppedResult) { +// ret ={serverStoppedResult.message}
{serverStoppedResult.reason}
{title}
} -//-//-//-//
{serverStoppedResult.message}
-{serverStoppedResult.reason}
-{title}
} +// //+// //+// //+// //
{serverStoppedResult.message}
+//{serverStoppedResult.reason}
+//{t("Crashed! Go to editor mode and fix your proof! Last server response:")}
- {interimDiags.map(diag => { - const severityClass = diag.severity ? { - [DiagnosticSeverity.Error]: 'error', - [DiagnosticSeverity.Warning]: 'warning', - [DiagnosticSeverity.Information]: 'information', - [DiagnosticSeverity.Hint]: 'hint', - }[diag.severity] : ''; - - return{t("Line")} {diag.range.start.line}, {t("Character")} {diag.range.start.character}
-
- {diag.message}
-
- Level completed! 🎉
: -
- no goals left
- This probably means you solved the level with warnings or Lean encountered a parsing error.
-
{t("Crashed! Go to editor mode and fix your proof! Last server response:")}
+// {interimDiags.map(diag => { +// const severityClass = diag.severity ? { +// [DiagnosticSeverity.Error]: 'error', +// [DiagnosticSeverity.Warning]: 'warning', +// [DiagnosticSeverity.Information]: 'information', +// [DiagnosticSeverity.Hint]: 'hint', +// }[diag.severity] : ''; + +// return{t("Line")} {diag.range.start.line}, {t("Character")} {diag.range.start.character}
+//
+// {diag.message}
+//
+// Level completed! 🎉
: +//
+// no goals left
+// This probably means you solved the level with warnings or Lean encountered a parsing error.
+//
{title}
} ----
{title}
} ----
{title}
} +//+//+//+//
{title}
} +//+//+//+//