Skip to content

[staging] Support Termios operations#282

Open
milseman wants to merge 1 commit intoapple:stagingfrom
milseman:termios
Open

[staging] Support Termios operations#282
milseman wants to merge 1 commit intoapple:stagingfrom
milseman:termios

Conversation

@milseman
Copy link
Contributor

Adds a draft implementation of termios support, using the TerminalDescriptor design style akin to SocketDescriptor.

Also adds a couple fun sample commands:

Terminal size

% swift run system-samples terminal-size 
196x56

% ls
cmake           CODE_OF_CONDUCT.md  LICENSE.txt     Package.swift       README.md       Tests
CMakeLists.txt      CONTRIBUTING.md     Package.resolved    Proposals       Sources

% swift run system-samples terminal-size --border --set-rows 5 --set-columns 80
Attempting to set terminal size to 80x5...
✓ Successfully set terminal size

80x5

┌──────────────────────────────────────────────────────────────────────────────┐
│                                     80x5                                     │
│                                                                              │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

% ls
cmake           LICENSE.txt     README.md
CMakeLists.txt      Package.resolved    Sources
CODE_OF_CONDUCT.md  Package.swift       Tests
CONTRIBUTING.md     Proposals


Password reader (disable echo)

% swift run system-samples password-reader
Password: 
Password read successfully (3 characters)
Password was: ***

Raw mode reader

% swift run system-samples raw-mode
Raw Mode Key Reader
==================

In raw mode, characters are available immediately without
waiting for Enter. Press 'q' to quit.

Try pressing keys, arrow keys, or special keys...

Read 3 byte(s): 0x1B 0x5B 0x43  [RIGHT ARROW]

Terminal restored to normal mode.

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