From 19e44261a482273e644876a6508a616f6ceb8041 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 3 Nov 2023 12:26:09 -0400 Subject: [PATCH] Refactor to prepare for implementing input and output streams to the terminal --- src/bun/terminal_io.ts | 0 src/common/editor.ts | 6 ++++++ src/common/mod.ts | 7 +++++++ src/common/strings_test.ts | 2 +- src/common/terminal_io.ts | 0 src/deno/terminal_io.ts | 0 src/scroll.ts | 16 +++------------- 7 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 src/bun/terminal_io.ts create mode 100644 src/common/editor.ts create mode 100644 src/common/terminal_io.ts create mode 100644 src/deno/terminal_io.ts diff --git a/src/bun/terminal_io.ts b/src/bun/terminal_io.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/common/editor.ts b/src/common/editor.ts new file mode 100644 index 0000000..efab205 --- /dev/null +++ b/src/common/editor.ts @@ -0,0 +1,6 @@ +export class Editor { + constructor() { + } + public processKeyPress(): void { + } +} diff --git a/src/common/mod.ts b/src/common/mod.ts index 9d77c93..08a2152 100644 --- a/src/common/mod.ts +++ b/src/common/mod.ts @@ -1,3 +1,10 @@ +import { importForRuntime } from './runtime.ts'; + export * from './runtime.ts'; export * from './strings.ts'; export type { ITestBase } from './test_base.ts'; + +export async function main() { + const { main } = await importForRuntime('./mod.ts'); + await main(); +} diff --git a/src/common/strings_test.ts b/src/common/strings_test.ts index f4d6b1b..9182bdf 100644 --- a/src/common/strings_test.ts +++ b/src/common/strings_test.ts @@ -6,7 +6,7 @@ t.test('chars fn properly splits strings into unicode characters', () => { t.assertEquals(chars('😺😸😹'), ['😺', '😸', '😹']); }); -t.test('is_ascii properly descerns ascii chars', () => { +t.test('is_ascii properly discerns ascii chars', () => { t.assertTrue(is_ascii('asjyverkjhsdf1928374')); t.assertFalse(is_ascii('😺acalskjsdf')); }); diff --git a/src/common/terminal_io.ts b/src/common/terminal_io.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/deno/terminal_io.ts b/src/deno/terminal_io.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/scroll.ts b/src/scroll.ts index 30067f1..e4c78a1 100644 --- a/src/scroll.ts +++ b/src/scroll.ts @@ -1,19 +1,9 @@ /** * The starting point for running scroll */ - -export enum RunTime { - Bun = 'bun', - Deno = 'deno', - Unknown = 'common', -} - -import { importForRuntime } from './common/mod.ts'; +import { main } from './common/mod.ts'; /** - * Determine the runtime strategy, and go! + * Start the event loop */ -(async () => { - const { main } = await importForRuntime('./mod.ts'); - await main(); -})(); +await main();