mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Remove pkg/term dependency
This commit is contained in:
@@ -5,15 +5,9 @@ package tea
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/muesli/termenv"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
var (
|
||||
origTTYState *terminal.State
|
||||
)
|
||||
|
||||
// enableAnsiColors enables support for ANSI color sequences in Windows
|
||||
// default console. Note that this only works with Windows 10.
|
||||
func enableAnsiColors() {
|
||||
@@ -23,20 +17,3 @@ func enableAnsiColors() {
|
||||
windows.GetConsoleMode(stdout, &originalMode)
|
||||
windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
||||
}
|
||||
|
||||
func initTerminal() error {
|
||||
var err error
|
||||
origTTYState, err = terminal.MakeRaw(int(os.Stdin.Fd())) // enter raw mode
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
enableAnsiColors()
|
||||
termenv.HideCursor()
|
||||
return nil
|
||||
}
|
||||
|
||||
func restoreTerminal() {
|
||||
_ = terminal.Restore(int(os.Stdin.Fd()), origTTYState) // exit raw mode
|
||||
termenv.ShowCursor()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user