diff options
| author | theimpostor <sahirhoda@gmail.com> | 2024-11-11 14:01:48 -0600 |
|---|---|---|
| committer | theimpostor <sahirhoda@gmail.com> | 2024-11-11 14:01:48 -0600 |
| commit | 6acbe36b9592bb9eded805db7f667343a56d4ad2 (patch) | |
| tree | a64992df08c406302593c169a49b137f783d8ef1 /tty_windows.go | |
| parent | 8f0d87986109ba3d02690aad2773e6512413dd1a (diff) | |
fix windows support
Diffstat (limited to 'tty_windows.go')
| -rw-r--r-- | tty_windows.go | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tty_windows.go b/tty_windows.go new file mode 100644 index 0000000..78131e8 --- /dev/null +++ b/tty_windows.go @@ -0,0 +1,64 @@ +//go:build windows +// +build windows + +package main + +import ( + "fmt" + "github.com/gdamore/tcell/v2" + "os" +) + +// stdIoTty is an implementation of the Tty API based upon stdin/stdout. +type stdIoTty struct { + in *os.File + out *os.File +} + +func (tty *stdIoTty) Read(b []byte) (int, error) { + return tty.in.Read(b) +} + +func (tty *stdIoTty) Write(b []byte) (int, error) { + return tty.out.Write(b) +} + +func (tty *stdIoTty) Close() error { + return nil +} + +func (tty *stdIoTty) Start() error { + tty.in = os.Stdin + tty.out = os.Stdout + return nil +} + +func (tty *stdIoTty) Drain() error { + return nil +} + +func (tty *stdIoTty) Stop() error { + return nil +} + +func (tty *stdIoTty) WindowSize() (tcell.WindowSize, error) { + return tcell.WindowSize{}, fmt.Errorf("not implemented") +} + +func (tty *stdIoTty) NotifyResize(cb func()) { +} + +// NewStdioTty opens a tty using standard input/output. +func NewStdIoTty() (tcell.Tty, error) { + tty := &stdIoTty{ + in: os.Stdin, + out: os.Stdout, + } + return tty, nil +} + +func opentty() (tty tcell.Tty, err error) { + debugLog.Println("Using stdio tty") + tty, err = NewStdIoTty() + return +} |
