Skip to content

Add public API for sending input to the terminal (#126)#128

Merged
dakra merged 1 commit intomainfrom
issue-126-public-send-api
Apr 18, 2026
Merged

Add public API for sending input to the terminal (#126)#128
dakra merged 1 commit intomainfrom
issue-126-public-send-api

Conversation

@dakra
Copy link
Copy Markdown
Owner

@dakra dakra commented Apr 18, 2026

Closes #126.

Summary

Adds two thin public wrappers so external packages (agent integrations, Swerty-style keymaps, etc.) can drive a ghostel buffer without poking at ghostel-- internals:

  • ghostel-send-string STRING — forwards to ghostel--send-key
  • ghostel-send-key KEY-NAME &optional MODS — forwards to ghostel--send-encoded

Both operate on the current buffer and signal user-error when called outside a ghostel-mode buffer (same predicate style as ghostel-debug-typing-latency). The internals stay as-is — nothing is renamed, no behavior changes for existing callers.

The utf8 third arg of ghostel--send-encoded is intentionally not exposed (no caller uses it; the VT derives text from the key name).

Test plan

  • make -j4 all test-evil — 123 elisp + 74 native + 30 evil tests pass
  • Lint clean (byte-compile, checkdoc, package-lint)
  • 5 new ERT tests cover: routing for both wrappers, nil-mods → "" coercion, and user-error when called outside a ghostel buffer
  • Manually drive a live ghostel buffer with (with-current-buffer "*ghostel*" (ghostel-send-string "echo hi\n"))

Promote two thin wrappers — `ghostel-send-string' and `ghostel-send-key'
— so external packages (agent integrations, custom keymaps) can drive a
ghostel buffer without reaching into `ghostel--' internals.  Both signal
a `user-error' when called outside a ghostel-mode buffer.

Rename the internal `ghostel--send-key' to `ghostel--send-string' to
match what it does (writes raw bytes to the PTY) and avoid naming
confusion with the new public `ghostel-send-key' (which takes a key
name and mods and goes through the encoder).  The old internal name is
kept as an obsolete alias so third-party packages that reached into it
keep working.
@dakra dakra force-pushed the issue-126-public-send-api branch from 0f838c4 to 5453c22 Compare April 18, 2026 17:57
@dakra dakra merged commit 5453c22 into main Apr 18, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a public API for sending a string / key to the terminal

1 participant