Skip to content
Open

Plan9 #1445

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ jobs:
go-version: ""
go-version-file: ./examples/go.mod
working-directory: ./examples

build-plan9:
uses: charmbracelet/meta/.github/workflows/build-plan9.yml@main
12 changes: 12 additions & 0 deletions signals_plan9.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package tea

import "time"

// listenForResize sends messages (or errors) when the terminal resizes.
// Argument output should be the file descriptor for the terminal; usually
// os.Stdout.
func (p *Program) listenForResize(done chan struct{}) {
for {
time.Sleep(100 * time.Second)
}
}
46 changes: 46 additions & 0 deletions tty_plan9.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package tea

import (
"fmt"
"log"
"os"
"path/filepath"

"github.com/charmbracelet/x/term"
)

func (p *Program) initInput() (err error) {
// Check if input is a terminal
if f, ok := p.input.(term.File); ok && term.IsTerminal(f.Fd()) {
p.ttyInput = f
p.previousTtyInputState, err = term.MakeRaw(p.ttyInput.Fd())
if err != nil {
return fmt.Errorf("error entering raw mode: %w", err)
}
}

if f, ok := p.output.(term.File); ok && term.IsTerminal(f.Fd()) {
p.ttyOutput = f
}

return nil
}

func openInputTTY() (*os.File, error) {
f, err := os.Open("/dev/cons")
if err != nil {
return nil, fmt.Errorf("could not open a new TTY: %w", err)
}
return f, nil
}

const suspendSupported = false

// Send SIGTSTP to the entire process group.
func suspendProcess() {
p := os.Getpid()
ctl := filepath.Join("proc", fmt.Sprintf("%d", p), "ctl")
if err := os.WriteFile(ctl, []byte("stop"), 0); err != nil {
log.Printf("Write sto to %q: %v", ctl, err)
}
}
Loading