mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
When showing/hiding the cursor operate on the program's io.Writer
Previously we were operating on io.Stdout.
This commit is contained in:
committed by
Christian Rocha
parent
f5fde56af0
commit
6d70abd7d5
11
tty.go
11
tty.go
@@ -1,13 +1,14 @@
|
||||
package tea
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/containerd/console"
|
||||
"github.com/muesli/termenv"
|
||||
)
|
||||
|
||||
var tty console.Console
|
||||
|
||||
func initTerminal() error {
|
||||
func initTerminal(w io.Writer) error {
|
||||
tty = console.Current()
|
||||
err := tty.SetRaw()
|
||||
if err != nil {
|
||||
@@ -15,11 +16,11 @@ func initTerminal() error {
|
||||
}
|
||||
|
||||
enableAnsiColors()
|
||||
termenv.HideCursor()
|
||||
hideCursor(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
func restoreTerminal() error {
|
||||
termenv.ShowCursor()
|
||||
func restoreTerminal(w io.Writer) error {
|
||||
showCursor(w)
|
||||
return tty.Reset()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user