Skip to content
Myr

Remove pkg/term dependency

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by Christian Rocha · parent 9c9a92c · Browse files · 5 files+30 added−57 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+30 added−57 removed

  • other:+30 added−57 removed

5 files+30 added−57 removed

modified:go.mod-1 removed
2 unmodified lines
3go 1.1345require (6 github.com/muesli/termenv v0.7.27 github.com/pkg/term v0.0.0-20200520122047-c3ffed290a037 golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee8 golang.org/x/sys v0.0.0-20201009025420-dfb3f7c4e6349)
modified:go.sum-4 removed
6 unmodified lines
7github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=8github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=9github.com/muesli/termenv v0.7.2 h1:r1raklL3uKE7rOvWgSenmEm2px+dnc33OTisZ8YR1fw=10github.com/muesli/termenv v0.7.2/go.mod h1:ct2L5N2lmix82RaY3bMWwVu/jUFc9Ule0KGDCiKYPh8=11github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03 h1:pd4YKIqCB0U7O2I4gWHgEUA2mCEOENmco0l/bM957bU=12github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03/go.mod h1:Z9+Ul5bCbBKnbCvdOWbLqTHhJiYV414CURZJba6L8qA=11golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=14golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de h1:ikNHVSjEfnvz6sxdSPCaPt572qowuyMDMJLLm3Db3ig=15golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=12golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee h1:4yd7jl+vXjalO5ztz6Vc1VADv+S/80LGJmyl1ROJ2AI=13golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=14golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=15golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
5 unmodified lines
modified:tty_unix.go+3 added-29 removed
1// +build darwin dragonfly freebsd linux netbsd openbsd solaris23package tea45import (6 "github.com/muesli/termenv"7 "github.com/pkg/term"8)910var (11 tty *term.Term12)1314func initTerminal() error {15 var err error16 tty, err = term.Open("/dev/tty")17 if err != nil {18 return err19 }2021 err = tty.SetRaw()22 if err != nil {23 return err24 }2526 termenv.HideCursor()27 return nil28}2930func restoreTerminal() {31 termenv.ShowCursor()32 _ = tty.Restore()33}5// enableAnsiColors is only needed for Windows, so for other systems this is6// a no-op.7func enableAnsiColors() {}
modified:tty_windows.go-23 removed
3 unmodified lines
45import (6 "os"78 "github.com/muesli/termenv"9 "golang.org/x/crypto/ssh/terminal"8 "golang.org/x/sys/windows"9)1013var (14 origTTYState *terminal.State15)1611// enableAnsiColors enables support for ANSI color sequences in Windows12// default console. Note that this only works with Windows 10.13func enableAnsiColors() {14 stdout := windows.Handle(os.Stdout.Fd())
1 unmodified line
1617 windows.GetConsoleMode(stdout, &originalMode)18 windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)19}2627func initTerminal() error {28 var err error29 origTTYState, err = terminal.MakeRaw(int(os.Stdin.Fd())) // enter raw mode30 if err != nil {31 return err32 }3334 enableAnsiColors()35 termenv.HideCursor()36 return nil37}3839func restoreTerminal() {40 _ = terminal.Restore(int(os.Stdin.Fd()), origTTYState) // exit raw mode41 termenv.ShowCursor()42}
added:tty.go+27 added
1package tea23import (4 "os"56 "github.com/muesli/termenv"7 "golang.org/x/crypto/ssh/terminal"8)910var origTTYState *terminal.State1112func initTerminal() error {13 var err error14 origTTYState, err = terminal.MakeRaw(int(os.Stdin.Fd())) // enter raw mode15 if err != nil {16 return err17 }1819 enableAnsiColors()20 termenv.HideCursor()21 return nil22}2324func restoreTerminal() error {25 termenv.ShowCursor()26 return terminal.Restore(int(os.Stdin.Fd()), origTTYState) // exit raw mode27}