Skip to content

Commit

Permalink
Fix newlines not properly outputting for stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
mattxwang committed Apr 26, 2023
1 parent cbe9f51 commit c27f064
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
18 changes: 7 additions & 11 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { InterpreterVersion, LoadProgram, RunResponse } from "./types";

function App() {
const [program, setProgram] = useState(DEFAULT_PROGRAM);
const [stdin, setStdin] = useState('');
const [stdin, setStdin] = useState("");
const [interpreterVersion, setInterpreterVersion] =
useState<InterpreterVersion>({ quarter: "f22", version: "1" });
const [output, setOutput] = useState("");
Expand All @@ -26,7 +26,8 @@ function App() {
const lastResponse =
responses.length === 0 ? { iteration: 0 } : responses[responses.length - 1];

const { TEXT_CODE, TEXT_OUTPUT, TEXT_PROGRAMS, TEXT_RUN, TEXT_STDIN } = getFlavourText(baristaMode)
const { TEXT_CODE, TEXT_OUTPUT, TEXT_PROGRAMS, TEXT_RUN, TEXT_STDIN } =
getFlavourText(baristaMode);

const setQuarter = (quarter: string) =>
setInterpreterVersion({ ...interpreterVersion, quarter });
Expand Down Expand Up @@ -84,7 +85,7 @@ function App() {
addResponse(
program,
stdin,
data.res,
data.res.join("\n"), // res is an array of string outputs
interpreterVersion,
lastResponse.iteration + 1
);
Expand Down Expand Up @@ -179,20 +180,15 @@ function App() {
(code) => code /* this is an identity -- no highlighting */
}
padding={10}
style={{minHeight: "1rem"}}
style={{ minHeight: "1rem" }}
/>

<h2 className="text-xl font-semibold mt-3 mb-1">
your {TEXT_OUTPUT}
</h2>
<Editor
className="editor border"
<textarea
className="editor border p-2"
value={output}
onValueChange={() => ""}
highlight={
(code) => code /* this is an identity -- no highlighting */
}
padding={10}
readOnly={true}
/>
</div>
Expand Down
7 changes: 5 additions & 2 deletions src/PreviousBrew.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ export default function PreviousBrew({
</span>
<button
className="underline"
onClick={() => loadProgram(program, stdin, output, interpreterVersion)}
onClick={() =>
loadProgram(program, stdin, output, interpreterVersion)
}
>
load
</button>
</span>
<span className="text-xs">
code: <code>{program}</code>
<br />
in: <code>{stdin.trim() === '' ? '-' : stdin}</code> | out: <code>{output}</code>
in: <code>{stdin.trim() === "" ? "-" : stdin}</code> | out:{" "}
<code>{output}</code>
</span>
</li>
);
Expand Down
6 changes: 3 additions & 3 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export const getFlavourText = (baristaMode: boolean) => {
TEXT_OUTPUT: baristaMode ? "brew" : "output",
TEXT_PROGRAMS: baristaMode ? "blends" : "programs",
TEXT_RUN: baristaMode ? "roast" : "run",
TEXT_STDIN: baristaMode ? "add-ins" : "stdin"
}
}
TEXT_STDIN: baristaMode ? "add-ins" : "stdin",
};
};

0 comments on commit c27f064

Please sign in to comment.