-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46cff54
commit 2934365
Showing
4 changed files
with
1,120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React from "react"; | ||
import { Widgets } from "@farjs/blessed"; | ||
import { UiString } from "./UiString"; | ||
|
||
type BlessedElement = Widgets.BlessedElement; | ||
|
||
export interface TextInputProps { | ||
readonly inputRef: React.MutableRefObject<BlessedElement>; | ||
readonly left: number; | ||
readonly top: number; | ||
readonly width: number; | ||
readonly value: string; | ||
readonly state: TextInputState; | ||
stateUpdater(update: (state: TextInputState) => TextInputState): void; | ||
onChange(value: string): void; | ||
onEnter?(): void; | ||
onKeypress?(keyFull: string): boolean; | ||
} | ||
|
||
export interface TextInputState { | ||
readonly offset: number; | ||
readonly cursorX: number; | ||
readonly selStart: number; | ||
readonly selEnd: number; | ||
} | ||
|
||
export type CursorMove = | ||
| CursorMove.At | ||
| CursorMove.Home | ||
| CursorMove.End | ||
| CursorMove.Left | ||
| CursorMove.Right; | ||
|
||
export namespace CursorMove { | ||
interface At { | ||
readonly move: "At"; | ||
readonly pos: number; | ||
} | ||
|
||
interface Home { | ||
readonly move: "Home"; | ||
} | ||
|
||
interface End { | ||
readonly move: "End"; | ||
} | ||
|
||
interface Left { | ||
readonly move: "Left"; | ||
readonly dx?: number; | ||
} | ||
|
||
interface Right { | ||
readonly move: "Right"; | ||
readonly dx?: number; | ||
} | ||
} | ||
|
||
export type TextEdit = TextEdit.Insert | TextEdit.Delete | TextEdit.Backspace; | ||
|
||
export namespace TextEdit { | ||
interface Insert { | ||
readonly edit: "Insert"; | ||
readonly str: UiString; | ||
} | ||
|
||
interface Delete { | ||
readonly edit: "Delete"; | ||
} | ||
|
||
interface Backspace { | ||
readonly edit: "Backspace"; | ||
} | ||
} |
Oops, something went wrong.