This commit is contained in:
Daniel Kluge 2021-12-16 01:03:54 +01:00
parent ec595650fd
commit 2403816461
7 changed files with 56 additions and 14 deletions

View File

@ -38,9 +38,12 @@ const REPLInput: NextPage<{historyCallback: CallableFunction}> = ({historyCallba
return false;
};
return <div className={styles.wrapper}>
<input className={styles.in} type={"text"} onChange={replinOnChange} onKeyDown={tabComplete} spellCheck={"false"} />
return <div className={styles.wrapperwrapper}>
<span className={styles.inputstart}>$&nbsp;</span>
<div className={styles.wrapper}>
<input className={styles.in} type={"text"} onChange={replinOnChange} onKeyDown={tabComplete} spellCheck={"false"} autoFocus />
<span className={styles.completionWrapper}><span ref={typed} className={styles.typed}></span><span ref={completion} className={styles.completion}></span></span>
</div>
</div>;
};

View File

@ -36,29 +36,29 @@ export function printSyntax(cmd: Command): string[] {
let flagsDesc = [];
if (cmd.flags && cmd.flags.length > 0) {
flagsOption = " [";
flagsDesc.push("");
flagsDesc.push("Flags:");
cmd.flags.forEach((flag => {
flagsOption += `-${flag.short} `;
flagsDesc.push(`\t-${flag.short}\t--${flag.long}\t${flag.desc}`);
}));
flagsOption = flagsOption.substring(0, flagsOption.length-1) + "]";
flagsDesc.push("");
}
let subcmdOption = "";
let subcmdDesc = [];
if (cmd.subcommands && cmd.subcommands.length > 0) {
subcmdOption = " [";
subcmdDesc.push("");
subcmdDesc.push("Subcommands:");
cmd.subcommands.forEach((subcmd => {
subcmdOption += `${subcmd.name}|`;
subcmdDesc.push(`\t${subcmd.name}\t${subcmd.desc}`);
}));
subcmdOption = subcmdOption.substring(0, subcmdOption.length-1) + "]";
subcmdDesc.push("");
}
return [`Usage: ${cmd.name}${flagsOption}${subcmdOption}`, ""].concat(flagsDesc).concat(subcmdDesc);
return [`Usage: ${cmd.name}${flagsOption}${subcmdOption}`].concat(flagsDesc).concat(subcmdDesc);
}
const about: Command = {

View File

@ -1,9 +1,12 @@
import type { NextPage } from "next";
import REPL from "../components/REPL";
import styles from "../styles/Home.module.css";
const Home: NextPage = () => {
return (
<div className={styles.container}>
<REPL />
</div>
);
};

7
styles/Home.module.css Normal file
View File

@ -0,0 +1,7 @@
.container {
display: flex;
flex-direction: column;
height: 100vh;
margin: 0;
padding: 10px;
}

View File

@ -1,10 +1,12 @@
.container {
height: 70vh;
overflow: auto;
display: flex;
flex-direction: column-reverse;
flex-grow: 2;
font-size: 1.25rem;
font-family: "CascadiaCode", monospace;
}
.line {
border-bottom: 1px solid #000;
padding: 3px 0;
}

View File

@ -1,18 +1,36 @@
.wrapper > input, .wrapper > span {
padding: .125rem 0;
font-size: 1.25rem;
font-family: "CascadiaCode";
padding: .125rem .25rem;
width: calc(100% - 1rem);
font-family: "CascadiaCode", monospace;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
color: var(--repl-color);
}
.wrapper {
position: relative;
border: 2px solid #000;
flex-grow: 2;
display: block;
}
.wrapperwrapper {
display: flex;
width: 100%;
flex-direction: row;
flex-wrap: nowrap;
}
.inputstart {
padding: .125rem 0;
font-size: 1.25rem;
font-family: "CascadiaCode", monospace;
}
.in, .in:focus {
border: 0;
outline-width: 0;
background: transparent;
}
.completionWrapper {
@ -34,5 +52,5 @@
}
.completion {
color: #ccc
color: var(--repl-color-hint);
}

View File

@ -5,4 +5,13 @@
* {
box-sizing: border-box;
--repl-color: #188a18;
--repl-color-hint: #092909;
}
body {
margin: 0;
padding: 0;
color: var(--repl-color);
background: #000;
}