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
Provenance
- Commit
4d14af7- Tree
3a74c61- Author
Christian Rocha <christian@rocha.is>- Committer
Christian Rocha <christian@rocha.is>- Parent
9c9a92c
5 files changed+30 added−57 removed
modified:go.mod-1 removed
2 unmodified lines3 go 1.134 5 require (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 lines7 github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=8 github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=9 github.com/muesli/termenv v0.7.2 h1:r1raklL3uKE7rOvWgSenmEm2px+dnc33OTisZ8YR1fw=10 github.com/muesli/termenv v0.7.2/go.mod h1:ct2L5N2lmix82RaY3bMWwVu/jUFc9Ule0KGDCiKYPh8=11-github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03 h1:pd4YKIqCB0U7O2I4gWHgEUA2mCEOENmco0l/bM957bU=12-github.com/pkg/term v0.0.0-20200520122047-c3ffed290a03/go.mod h1:Z9+Ul5bCbBKnbCvdOWbLqTHhJiYV414CURZJba6L8qA=11 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=14-golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de h1:ikNHVSjEfnvz6sxdSPCaPt572qowuyMDMJLLm3Db3ig=15-golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=12 golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee h1:4yd7jl+vXjalO5ztz6Vc1VADv+S/80LGJmyl1ROJ2AI=13 golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=14 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=15 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=5 unmodified linesmodified:tty_unix.go+3 added-29 removed
1 // +build darwin dragonfly freebsd linux netbsd openbsd solaris2 3 package tea4 5-import (6- "github.com/muesli/termenv"7- "github.com/pkg/term"8-)9-10-var (11- tty *term.Term12-)13-14-func initTerminal() error {15- var err error16- tty, err = term.Open("/dev/tty")17- if err != nil {18- return err19- }20-21- err = tty.SetRaw()22- if err != nil {23- return err24- }25-26- termenv.HideCursor()27- return nil28-}29-30-func restoreTerminal() {31- termenv.ShowCursor()32- _ = tty.Restore()33-}5+// enableAnsiColors is only needed for Windows, so for other systems this is6+// a no-op.7+func enableAnsiColors() {}modified:tty_windows.go-23 removed
3 unmodified lines4 5 import (6 "os"7 8- "github.com/muesli/termenv"9- "golang.org/x/crypto/ssh/terminal"8 "golang.org/x/sys/windows"9 )10 13-var (14- origTTYState *terminal.State15-)16-11 // enableAnsiColors enables support for ANSI color sequences in Windows12 // default console. Note that this only works with Windows 10.13 func enableAnsiColors() {14 stdout := windows.Handle(os.Stdout.Fd())1 unmodified line16 17 windows.GetConsoleMode(stdout, &originalMode)18 windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)19 }26-27-func initTerminal() error {28- var err error29- origTTYState, err = terminal.MakeRaw(int(os.Stdin.Fd())) // enter raw mode30- if err != nil {31- return err32- }33-34- enableAnsiColors()35- termenv.HideCursor()36- return nil37-}38-39-func restoreTerminal() {40- _ = terminal.Restore(int(os.Stdin.Fd()), origTTYState) // exit raw mode41- termenv.ShowCursor()42-}added:tty.go+27 added
1+package tea2+3+import (4+ "os"5+6+ "github.com/muesli/termenv"7+ "golang.org/x/crypto/ssh/terminal"8+)9+10+var origTTYState *terminal.State11+12+func initTerminal() error {13+ var err error14+ origTTYState, err = terminal.MakeRaw(int(os.Stdin.Fd())) // enter raw mode15+ if err != nil {16+ return err17+ }18+19+ enableAnsiColors()20+ termenv.HideCursor()21+ return nil22+}23+24+func restoreTerminal() error {25+ termenv.ShowCursor()26+ return terminal.Restore(int(os.Stdin.Fd()), origTTYState) // exit raw mode27+}