Skip to content

Commit 6ae4bd5

Browse files
committed
Refactor terminal setup and layout in App component
1 parent a3b9431 commit 6ae4bd5

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

page/src/App.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const App = (props: {
2525
const [triple, setTriple] = createSignal("wasm32-wasip1");
2626

2727
return (
28-
<>
28+
<div>
2929
<MonacoEditor
3030
language="rust"
3131
value={default_value}
@@ -34,7 +34,9 @@ const App = (props: {
3434
onChange={handleEditorChange}
3535
/>
3636
{/* <p class="text-4xl text-green-700 text-center">Hello tailwind!</p> */}
37-
<SetupMyTerminal ctx={props.ctx} callback={props.callback} />
37+
<div class="flex" style={{ width: "100vw" }}>
38+
<SetupMyTerminal ctx={props.ctx} callback={props.callback} />
39+
</div>
3840
<div class="flex">
3941
<div class="p-4 text-white">
4042
<RunButton triple={triple()} />
@@ -59,7 +61,7 @@ const App = (props: {
5961
<DownloadButton />
6062
</div>
6163
</div>
62-
</>
64+
</div>
6365
);
6466
};
6567

page/src/xterm.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export const SetupMyTerminal = (props: {
2424
}) => {
2525
let xterm: Terminal | undefined = undefined;
2626

27+
const fit_addon = new FitAddon();
28+
2729
const terminal_queue = [];
2830
const write_terminal = (str: string) => {
2931
if (xterm) {
@@ -53,6 +55,7 @@ export const SetupMyTerminal = (props: {
5355
xterm.write(terminal_queue.join(""));
5456
terminal_queue.length = 0;
5557
get_ref(terminal, props.callback);
58+
fit_addon.fit();
5659
return () => {
5760
console.log("Terminal unmounted.");
5861
};
@@ -107,7 +110,14 @@ export const SetupMyTerminal = (props: {
107110
};
108111

109112
// You can pass either an ITerminalAddon constructor or an instance, depending on whether you need to access it later.
110-
return <XTerm onMount={handleMount} onKey={keydown} addons={[FitAddon]} />;
113+
return (
114+
<XTerm
115+
onMount={handleMount}
116+
onKey={keydown}
117+
addons={[fit_addon]}
118+
class="w-full"
119+
/>
120+
);
111121
};
112122

113123
const get_ref = (term, callback) => {

0 commit comments

Comments
 (0)