import React, { ReactElement } from "react"; import Button from "@mui/material/Button"; import Typography from "@mui/material/Typography"; import Select from "@mui/material/Select"; import Switch from "@mui/material/Switch"; import MenuItem from "@mui/material/MenuItem"; import TextField from "@mui/material/TextField"; import EditIcon from "@mui/icons-material/Edit"; import { useBoolean } from "../../ui/React/hooks"; import { Modal } from "../../ui/React/Modal"; import { ThemeEditorModal } from "./ThemeEditorModal"; import { CursorBlinking, CursorStyle, Options } from "./Options"; const CURSOR_STYLES: CursorStyle[] = ["line", "block", "underline", "line-thin", "block-outline", "underline-thin"]; const CURSOR_BLINKING_MODES: CursorBlinking[] = ["blink", "smooth", "phase", "expand", "solid"]; export type OptionsModalProps = { open: boolean; options: Options; onClose: () => void; onOptionChange: (option: keyof Options, value: Options[keyof Options]) => void; onThemeChange: () => void; }; export function OptionsModal(props: OptionsModalProps): ReactElement { const [themeEditorOpen, { on: openThemeEditor, off: closeThemeEditor }] = useBoolean(false); const onFontSizeChange = (event: React.ChangeEvent) => { const fontSize = parseInt(event.target.value); if (!Number.isFinite(fontSize) || fontSize < 1) return; props.onOptionChange("fontSize", fontSize); }; const onTabSizeChange = (event: React.ChangeEvent) => { const tabSize = parseInt(event.target.value); if (!Number.isFinite(tabSize) || tabSize < 1) return; props.onOptionChange("tabSize", tabSize); }; return (
Theme:
Indent using spaces: props.onOptionChange("insertSpaces", e.target.checked)} checked={props.options.insertSpaces} />
Tab size:
Auto-detect indentation: props.onOptionChange("detectIndentation", e.target.checked)} checked={props.options.detectIndentation} />
Word wrap:
Enable vim mode: props.onOptionChange("vim", e.target.checked)} checked={props.options.vim} />
Font family: props.onOptionChange("fontFamily", e.target.value)} />
Font size:
Enable font ligatures: props.onOptionChange("fontLigatures", e.target.checked)} checked={props.options.fontLigatures} />
Cursor style:
Cursor blinking:
); }