nimterm/input
This page is generated from the module’s exported API and ## documentation comments.
Shared terminal input decoder.
Reads bytes from term (posix raw stdin) and turns them into keys / mouse events.
ByteReader
Section titled “ByteReader”ByteReader = proc (timeoutMs: int): int {.closure.}InputDecoder
Section titled “InputDecoder”InputDecoder = objectMouseKind
Section titled “MouseKind”MouseKind = enum mouseNone, mousePress, ## left button down mouseRelease, ## left button up mouseDrag ## motion while left button heldFocusKind
Section titled “FocusKind”FocusKind = enum focusNone, focusIn, focusOutInputEvent
Section titled “InputEvent”InputEvent = object key*: Key ch*: char ## ASCII keyChar; prefer `text` for insert text*: string ## UTF-8 rune or a whole paste scrollDelta*: int ## +N scroll up (older), -N scroll down (newer) resized*: bool mouse*: MouseKind button*: UiMouseButton shift*: bool alt*: bool ctrl*: bool mouseX*: int ## 0-based column mouseY*: int ## 0-based row focus*: FocusKindProcedures
Section titled “Procedures”normalizePasteText
Section titled “normalizePasteText”CR LF / CR → LF so a paste never submits.
proc normalizePasteText(s: string): string {.raises: [], tags: [], forbids: [].}Returns: string.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
s |
string |
isModifiedPaste
Section titled “isModifiedPaste”Ctrl/Cmd+V as xterm modifyOtherKeys (27;5;118~) or CSI-u (118;5u).
proc isModifiedPaste(seq: string): bool {.raises: [], tags: [], forbids: [].}Returns: bool.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
seq |
string |
decodeInput
Section titled “decodeInput”proc decodeInput(b: int; readNext: ByteReader): InputEvent {. raises: [Exception], tags: [RootEffect], forbids: [].}Returns: InputEvent.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
b |
int |
|
readNext |
ByteReader |
proc feed(decoder: var InputDecoder; bytes: string) {.raises: [], tags: [], forbids: [].}Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
decoder |
var InputDecoder |
|
bytes |
string |
pending
Section titled “pending”proc pending(decoder: InputDecoder): bool {.raises: [], tags: [], forbids: [].}Returns: bool.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
decoder |
InputDecoder |
escapeWaitMs
Section titled “escapeWaitMs”proc escapeWaitMs(decoder: InputDecoder; nowMs: int64; timeoutMs = 15): int {. raises: [], tags: [], forbids: [].}Returns: int.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
decoder |
InputDecoder |
|
nowMs |
int64 |
|
timeoutMs |
inferred |
15 |
nextEvent
Section titled “nextEvent”proc nextEvent(decoder: var InputDecoder; nowMs: int64; escapeTimeoutMs = 15): InputEvent {. raises: [Exception], tags: [RootEffect], forbids: [].}Returns: InputEvent.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
decoder |
var InputDecoder |
|
nowMs |
int64 |
|
escapeTimeoutMs |
inferred |
15 |
toUiEvent
Section titled “toUiEvent”proc toUiEvent(input: InputEvent; width = 0; height = 0): UiEvent {.raises: [], tags: [], forbids: [].}Returns: UiEvent.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
input |
InputEvent |
|
width |
inferred |
0 |
height |
inferred |
0 |