Skip to content

Commit

Permalink
fix(tea): don't query the terminal for "dumb" terminals
Browse files Browse the repository at this point in the history
"dumb" terminals don't support OSC sequences
  • Loading branch information
aymanbagabas committed Jul 31, 2024
1 parent 8aed4c3 commit 6c0aaa6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bubbletea/tea_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ func makeOpts(s ssh.Session) []tea.ProgramOption {

func newRenderer(s ssh.Session) *lipgloss.Renderer {
pty, _, ok := s.Pty()
if !ok || pty.Term == "" || pty.Term == "dumb" {
return lipgloss.NewRenderer(s, termenv.WithProfile(termenv.Ascii))
}
env := sshEnviron(append(s.Environ(), "TERM="+pty.Term))
var r *lipgloss.Renderer
var bg color.Color
Expand All @@ -52,10 +55,12 @@ func newRenderer(s ssh.Session) *lipgloss.Renderer {
)
bg = queryBackgroundColor(s)
}
c, ok := colorful.MakeColor(bg)
if ok {
_, _, l := c.Hsl()
r.SetHasDarkBackground(l < 0.5)
if bg != nil {
c, ok := colorful.MakeColor(bg)
if ok {
_, _, l := c.Hsl()
r.SetHasDarkBackground(l < 0.5)
}
}
return r
}
Expand Down

0 comments on commit 6c0aaa6

Please sign in to comment.