Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@
"./controls": "./src/controls.ts",
"./event-emitter": "./src/event_emitter.ts",
"./input": "./src/input.ts",
"./input/keyboard": "./src/input_reader/decoders/keyboard.ts",
"./input/mouse": "./src/input_reader/decoders/mouse.ts",
"./input-reader": "./src/input_reader/mod.ts",
"./input-reader/decoders/keyboard": "./src/input_reader/decoders/keyboard.ts",
"./input-reader/decoders/mouse": "./src/input_reader/decoders/mouse.ts",
"./input-reader/types": "./src/input_reader/types.ts",
"./input/keyboard": "./src/input/keyboard.ts",
"./input/mouse": "./src/input/mouse.ts",
"./input/types": "./src/input/types.ts",
"./layout": "./src/layout/mod.ts",
"./layout/errors": "./src/layout/errors.ts",
"./layout/grid": "./src/layout/grid_layout.ts",
Expand Down
11 changes: 11 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/input.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright 2023 Im-Beast. MIT license.
import type { Tui } from "./tui.ts";
import { emitInputEvents } from "./input_reader/mod.ts";
import { emitInputEvents } from "./input/mod.ts";

export * from "./input/mod.ts";

/** Emit input events to Tui */
export async function handleInput(tui: Tui): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2023 Im-Beast. MIT license.
3// Copyright 2023 Im-Beast. MIT license.
/** Decode code sequence to {KeyPress} object. */
import type { Alphabet, Key, KeyPressEvent } from "../types.ts";
import type { Alphabet, Key, KeyPressEvent } from "./types.ts";

const lowerCaseAlphabet = "abcdefghijklmnopqrstuvwxyz";

Expand Down
6 changes: 3 additions & 3 deletions src/input_reader/mod.ts → src/input/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type {
MouseScrollEvent,
} from "./types.ts";
import type { Stdin } from "../types.ts";
import { decodeMouseSGR, decodeMouseVT_UTF8 } from "./decoders/mouse.ts";
import { decodeKey } from "./decoders/keyboard.ts";
import { decodeMouseSGR, decodeMouseVT_UTF8 } from "./mouse.ts";
import { decodeKey } from "./keyboard.ts";
import type { EmitterEvent, EventEmitter } from "../event_emitter.ts";

export type InputEventRecord = {
Expand All @@ -25,7 +25,7 @@ export async function emitInputEvents(
stdin: Stdin,
emitter: EventEmitter<InputEventRecord>,
minReadInterval = 1000 / 60,
) {
): Promise<void> {
try {
stdin.setRaw(true, { cbreak: Deno.build.os !== "windows" });
} catch {
Expand Down
6 changes: 3 additions & 3 deletions src/input_reader/decoders/mouse.ts → src/input/mouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import type {
MouseEvent,
MousePressEvent,
MouseScrollEvent,
} from "../types.ts";
} from "./types.ts";

let mouseEvent: MouseEvent = {
key: "mouse",
x: 0,
y: 0,
movementX: 0,
movementY: 0,
buffer: undefined as unknown as Uint8Array,
buffer: undefined!,
shift: false,
ctrl: false,
meta: false,
Expand All @@ -32,7 +32,7 @@ export function decodeMouseSGR(
): MousePressEvent | MouseScrollEvent | undefined {
const action = code.at(-1);
if (!code.startsWith("\x1b[<") || (action !== "m" && action !== "M")) {
return undefined;
return undefined;SSS
}

const release = action === "m";
Expand Down
1 change: 0 additions & 1 deletion src/input_reader/types.ts → src/input/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Copyright 2023 Im-Beast. MIT license.
import type { Range } from "../types.ts";

/** Interface defining key press issued to stdin */
Expand Down
Loading