Repository navigation
feat: term.update() folds CapabilityEvents into runtime capabilities #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6d4091b
feat: term.update() folds CapabilityEvents into runtime capabilities …
natemoo-re b1b3a19
refactor(term): make applyUpdate module-private
natemoo-re 7cdd381
test(term): cover no-op InputEvent steps in update()
natemoo-re 3b6a1ef
refactor!: createTerm({ terminfo }) takes a TerminalInfo
natemoo-re 9b7cbac
spec: term.update() takes an array of InputEvents
natemoo-re 460f7e1
refactor!: term.update() takes readonly InputEvent[]
natemoo-re 6d9cc3c
chore: update changeset for array-only term.update()
natemoo-re e25c039
spec(renderer): note where capability state lives (non-normative)
natemoo-re 3272810
docs: align capability comments with the share-no-memory design
natemoo-re 33c2ceb
chore: update changeset
natemoo-re File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,33 @@ | ||
| --- | ||
| '@bomb.sh/tty': minor | ||
| --- | ||
|
|
||
| Adds `detectTerminal()`, `TerminalInfo`, `Capabilities`, `DetectOptions`, `KeyTable`, and `MAX_TERMINFO_ENTRY` to the public API, and a `terminfo` option to `createTerm`. | ||
|
|
||
| `detectTerminal()` reads the compiled terminfo entry for the current terminal (from the ncurses search path, or from bytes passed as `entry`), applies environment evidence (`COLORTERM`), and resolves a frozen `TerminalInfo` carrying static `capabilities`, a `probe` query batch to write to stdout, and opaque `keys` for the input parser. | ||
|
|
||
| Pass the returned `TerminalInfo` as `terminfo` to `createTerm` and `createInput`. `term.capabilities` exposes the renderer's current capability snapshot, seeded from `terminfo.capabilities` (or the 256-color baseline when omitted). | ||
|
|
||
| Changes `term.update()` to accept an array of `InputEvent` values instead of `{ events }` or `{ width, height }`. Resizes are now `ResizeEvent`s tagged `type: "resize"`; capability events from `scan()` are folded into `term.capabilities`; all other input events are no-ops, so the full `events` array from `scan()` can be passed straight through. `update()` now returns a `Uint8Array` of bytes to write immediately (empty when there are none). | ||
|
|
||
| #### Migration | ||
|
|
||
| ```diff | ||
| -term.update({ events }); | ||
| +const out = term.update(events); | ||
| +if (out.length) process.stdout.write(out); | ||
| ``` | ||
|
|
||
| ```diff | ||
| -term.update({ width, height }); | ||
| +term.update([{ type: "resize", width, height }]); | ||
| ``` | ||
|
|
||
| To opt in to terminfo-based capability detection: | ||
|
|
||
| ```diff | ||
| +const terminfo = await detectTerminal({ env: process.env }); | ||
| const term = await createTerm({ width, height, terminfo }); | ||
| const input = await createInput({ terminfo }); | ||
| +process.stdout.write(terminfo.probe); | ||
| ``` | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.