Skip to content

Commit

Permalink
fix: cursor visible after leave story
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Nov 10, 2023
1 parent 500be34 commit 1b794c5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/mux/stream/cli/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/cfoust/cy/pkg/mux"

"github.com/muesli/termenv"
"github.com/xo/terminfo"
"golang.org/x/term"
)

Expand All @@ -23,16 +24,22 @@ func Attach(
) error {
output := termenv.NewOutput(out)

info, err := terminfo.LoadFromEnv()
if err != nil {
panic(err)
}

output.AltScreen()
output.EnableMouseAllMotion()
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
oldState, err := term.MakeRaw(int(in.Fd()))
if err != nil {
return err
}
defer func() {
output.ExitAltScreen()
output.DisableMouseAllMotion()
term.Restore(int(os.Stdin.Fd()), oldState)
info.Fprintf(out, terminfo.CursorVisible)
term.Restore(int(in.Fd()), oldState)
}()

go func() { _, _ = io.Copy(stream, in) }()
Expand Down

0 comments on commit 1b794c5

Please sign in to comment.