Skip to content

PTY-based terminal - #7

Open
Yan123-tech wants to merge 1 commit into
mainfrom
feature/terminal-pty
Open

Yan123-tech wants to merge 1 commit into
mainfrom
feature/terminal-pty

Conversation

@Yan123-tech

Copy link
Copy Markdown
Owner

Summary

Refs #5. Placeholder branch for the PTY rewrite of TerminalSession. No code yet — the commit is a plan so the work has a home.

Motivation

TerminalSession spawns $SHELL -i over Pipe()s. That gives no job control, no terminal echo, and no TTY-aware behaviour: top exits immediately, vim renders wrong, and Ctrl-C writes 0x03 into a pipe the shell does not interpret as a signal.

Proposed approach

  • Replace the three pipes with a real PTY (posix_openpt → grantpt → unlockpt → ptsname).
  • Parse CR, BS, LF and ANSI SGR, behind a protocol so the parser is unit-testable without spawning a shell.
  • TIOCSWINSZ on panel resize.
  • Forward SIGINT to the foreground process group.
  • Keep the pipe implementation as fallback until verified against an interactive program.

Testing

  • swift build passes
  • swift test passes
  • vim and top render
  • Ctrl-C interrupts
  • ls --color shows colour
  • Resize reflows

Status

Not started. Follow-up commits land here.

Refs #5. Replace the pipe-based shell with a real pseudo-terminal so
interactive programs render and Ctrl-C reaches the foreground process
group.

Plan, per the issue:
- open a PTY via posix_openpt/grantpt/unlockpt and replace the three
  pipes in TerminalSession
- parse at least CR, BS, LF and ANSI SGR so ls --color and git diff
  render, behind a protocol so the parser stays unit-testable
- send TIOCSWINSZ on panel resize
- forward SIGINT to the foreground process group instead of writing
  0x03 to a pipe the shell does not read as a signal

Keeping the existing pipe implementation as the fallback until the PTY
path is verified against an interactive program.
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.

1 participant