webterm: more idiomatic array type definitions

This commit is contained in:
fang 2021-06-22 17:11:24 +02:00
parent 288c2121d1
commit 8cc8139243
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
2 changed files with 7 additions and 7 deletions

View File

@ -10,22 +10,22 @@ export type Tint =
export type Deco = null | 'br' | 'un' | 'bl';
export type Stye = {
deco: Array<Deco>,
deco: Deco[],
back: Tint,
fore: Tint
};
export type Stub = {
stye: Stye,
text: Array<string>
text: string[]
}
export type Blit =
| { bel: null } // make a noise
| { clr: null } // clear the screen
| { hop: number | { r: number, c: number } } // set cursor col/pos
| { klr: Array<Stub> } // put styled
| { put: Array<string> } // put text at cursor
| { klr: Stub[] } // put styled
| { put: string[] } // put text at cursor
| { nel: null } // newline
| { sag: { path: string, file: string } } // save to jamfile
| { sav: { path: string, file: string } } // save to file

View File

@ -67,7 +67,7 @@ const termConfig: ITerminalOptions = {
macOptionClickForcesSelection: true,
}
const csi = (cmd: string, ...args: Array<number>) => {
const csi = (cmd: string, ...args: number[]) => {
return '\x1b[' + args.join(';') + cmd;
}
@ -92,7 +92,7 @@ const stye = (s: Stye) => {
// text decorations
//
if (s.deco.length > 0) {
out += s.deco.reduce((decs: Array<number>, deco: Deco) => {
out += s.deco.reduce((decs: number[], deco: Deco) => {
switch (deco) {
case null: decs.push(0); return decs;
case 'br': decs.push(1); return decs;
@ -258,7 +258,7 @@ export default function TermApp(props: TermAppProps) {
const onInput = useCallback((ses: string, e: string) => {
const term = useTermState.getState().sessions[ses].term;
let belts: Array<Belt> = [];
let belts: Belt[] = [];
let strap = '';
while (e.length > 0) {