From 56991d936b498aa5c925d9c5168dea833a111730 Mon Sep 17 00:00:00 2001 From: "g.lenda" Date: Fri, 27 Jun 2025 16:26:41 +0000 Subject: [PATCH 1/3] initial plan9 support --- signals_plan9.go | 12 ++++++++++++ tty_plan9.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 signals_plan9.go create mode 100644 tty_plan9.go diff --git a/signals_plan9.go b/signals_plan9.go new file mode 100644 index 0000000000..5919eb0444 --- /dev/null +++ b/signals_plan9.go @@ -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) + } +} diff --git a/tty_plan9.go b/tty_plan9.go new file mode 100644 index 0000000000..3e05f97ae5 --- /dev/null +++ b/tty_plan9.go @@ -0,0 +1,45 @@ +package tea + +import ( + "fmt" + "os" +) + +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 fmt.Errorf("no yet") +} + +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() { + /* + c := make(chan os.Signal, 1) + signal.Notify(c, syscall.SIGCONT) + _ = syscall.Kill(0, syscall.SIGTSTP) + // blocks until a CONT happens... + <-c + */ +} From 255445613b2e1578c75fd54df9a0b28606cf9c01 Mon Sep 17 00:00:00 2001 From: "g.lenda" Date: Mon, 30 Jun 2025 18:39:36 +0000 Subject: [PATCH 2/3] Finish plan 9 support. Depends on a pending commit to x/term. If that commit is pushed, then this go test works. --- tty_plan9.go | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/tty_plan9.go b/tty_plan9.go index 3e05f97ae5..229df3f2fd 100644 --- a/tty_plan9.go +++ b/tty_plan9.go @@ -2,25 +2,28 @@ 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) - } + // 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 fmt.Errorf("no yet") + if f, ok := p.output.(term.File); ok && term.IsTerminal(f.Fd()) { + p.ttyOutput = f + } + + return nil } func openInputTTY() (*os.File, error) { @@ -35,11 +38,9 @@ const suspendSupported = false // Send SIGTSTP to the entire process group. func suspendProcess() { - /* - c := make(chan os.Signal, 1) - signal.Notify(c, syscall.SIGCONT) - _ = syscall.Kill(0, syscall.SIGTSTP) - // blocks until a CONT happens... - <-c - */ + 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) + } } From 2a61bccec671c52392b53152d685d6a70fc03bff Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Tue, 1 Jul 2025 17:00:10 -0300 Subject: [PATCH 3/3] ci: build for plan9 --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 189c3915df..b634034864 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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