Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support wordwrap #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import ConnectionStatus from "./ConnectionStatus";
import Footer from "./Footer";
import User from "./User";

type WordWrap = typeof editor.EditorOptions.wordWrap.defaultValue;

function getWsUri(id: string) {
return (
(window.location.origin.startsWith("https") ? "wss://" : "ws://") +
Expand Down Expand Up @@ -62,6 +64,7 @@ function App() {
const [hue, setHue] = useStorage("hue", generateHue);
const [editor, setEditor] = useState<editor.IStandaloneCodeEditor>();
const [darkMode, setDarkMode] = useStorage("darkMode", () => false);
const [wordWrap, setWordWrap] = useState<WordWrap>("on");
const rustpad = useRef<Rustpad>();
const id = useHash();

Expand Down Expand Up @@ -194,6 +197,23 @@ function App() {
<Switch isChecked={darkMode} onChange={handleDarkMode} />
</Flex>

<Heading mt={4} mb={1.5} size="sm">
Word Wrap
</Heading>
<Select
size="sm"
bgColor={darkMode ? "#3c3c3c" : "white"}
borderColor={darkMode ? "#3c3c3c" : "white"}
value={wordWrap}
onChange={(event) => setWordWrap(event.target.value as WordWrap)}
>
{["off", "on", "wordWrapColumn", "bounded"].map((value) => (
<option key={value} value={value} style={{ color: "black" }}>
{value}
</option>
))}
</Select>

<Heading mt={4} mb={1.5} size="sm">
Language
</Heading>
Expand Down Expand Up @@ -312,6 +332,7 @@ function App() {
options={{
automaticLayout: true,
fontSize: 13,
wordWrap: wordWrap,
}}
onMount={(editor) => setEditor(editor)}
/>
Expand Down