My own repo with exiting with programs exit code.
This commit is contained in:
parent
b745c44832
commit
027e546e1f
47 changed files with 32301 additions and 1 deletions
59
html/src/components/terminal/index.tsx
Normal file
59
html/src/components/terminal/index.tsx
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import { bind } from 'decko';
|
||||
import { Component, h } from 'preact';
|
||||
import { Xterm, XtermOptions } from './xterm';
|
||||
|
||||
import '@xterm/xterm/css/xterm.css';
|
||||
import { Modal } from '../modal';
|
||||
|
||||
interface Props extends XtermOptions {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface State {
|
||||
modal: boolean;
|
||||
}
|
||||
|
||||
export class Terminal extends Component<Props, State> {
|
||||
private container: HTMLElement;
|
||||
private xterm: Xterm;
|
||||
|
||||
constructor(props: Props) {
|
||||
super();
|
||||
this.xterm = new Xterm(props, this.showModal);
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
await this.xterm.refreshToken();
|
||||
this.xterm.open(this.container);
|
||||
this.xterm.connect();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.xterm.dispose();
|
||||
}
|
||||
|
||||
render({ id }: Props, { modal }: State) {
|
||||
return (
|
||||
<div id={id} ref={c => (this.container = c as HTMLElement)}>
|
||||
<Modal show={modal}>
|
||||
<label class="file-label">
|
||||
<input onChange={this.sendFile} class="file-input" type="file" multiple />
|
||||
<span class="file-cta">Choose files…</span>
|
||||
</label>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@bind
|
||||
showModal() {
|
||||
this.setState({ modal: true });
|
||||
}
|
||||
|
||||
@bind
|
||||
sendFile(event: Event) {
|
||||
this.setState({ modal: false });
|
||||
const files = (event.target as HTMLInputElement).files;
|
||||
if (files) this.xterm.sendFile(files);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue