File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,9 +5,18 @@ package bubbletea
55
66import (
77 tea "github.com/charmbracelet/bubbletea"
8+ "github.com/charmbracelet/lipgloss"
89 "github.com/charmbracelet/ssh"
10+ "github.com/muesli/termenv"
911)
1012
13+ // MakeRenderer returns a new lipgloss.Renderer for the given ssh.Session.
14+ // It will use the pty if one is available, otherwise it will use the session
15+ // writer.
16+ func MakeRenderer (s ssh.Session ) * lipgloss.Renderer {
17+ return lipgloss .NewRenderer (s , termenv .WithUnsafe (), termenv .WithColorCache (true ))
18+ }
19+
1120func makeIOOpts (s ssh.Session ) []tea.ProgramOption {
1221 return []tea.ProgramOption {
1322 tea .WithInput (s ),
Original file line number Diff line number Diff line change 44package bubbletea
55
66import (
7+ "io"
8+
79 tea "github.com/charmbracelet/bubbletea"
10+ "github.com/charmbracelet/lipgloss"
811 "github.com/charmbracelet/ssh"
12+ "github.com/muesli/termenv"
913)
1014
15+ // MakeRenderer returns a new lipgloss.Renderer for the given ssh.Session.
16+ // It will use the pty if one is available, otherwise it will use the session
17+ // writer.
18+ func MakeRenderer (s ssh.Session ) * lipgloss.Renderer {
19+ var f io.Writer = s
20+ pty , _ , ok := s .Pty ()
21+ if ok {
22+ f = pty .Slave
23+ }
24+ return lipgloss .NewRenderer (f , termenv .WithColorCache (true ))
25+ }
26+
1127func makeIOOpts (s ssh.Session ) []tea.ProgramOption {
1228 pty , _ , ok := s .Pty ()
1329 if ! ok || s .EmulatedPty () {
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ func main() {
6060}
6161
6262func teaHandler (s ssh.Session ) (tea.Model , []tea.ProgramOption ) {
63- renderer := newRenderer (s )
63+ renderer := bm . MakeRenderer (s )
6464 m := model {
6565 sess : s ,
6666 style : renderer .NewStyle ().Foreground (lipgloss .Color ("8" )),
Load diff This file was deleted.
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments