-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: use pty Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: deps Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: deps Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: update example * fix: deps * docs: fix example * feat: pass lipgloss.Renderer down to the tea.App * fix: go mod tidy Signed-off-by: Carlos Alexandro Becker <[email protected]> * improvements Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: pty Co-authored-by: Ayman Bagabas <[email protected]> Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: better diff * chore: typo * fix: godocs * fix: allocate pty on macos Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: improvements based on #219 Signed-off-by: Carlos Alexandro Becker <[email protected]> Co-authored-by: Ayman Bagabas <[email protected]> * chore: godoc * fix: review Co-authored-by: Ayman Bagabas <[email protected]> Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: example Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: tea program handler Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: examples * refactor: improve p!=nil handling Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: ensure session envs are available to renderer (#223) * fix: rename func to makeoptions * fix: not too much breaking * chore: fix gitignore * fix: dep Signed-off-by: Carlos Alexandro Becker <[email protected]> * fix: update charmbracelet/ssh * fix: update dep Signed-off-by: Carlos Alexandro Becker <[email protected]> * chore: go mod tidy Signed-off-by: Carlos Alexandro Becker <[email protected]> * chore: update example --------- Signed-off-by: Carlos Alexandro Becker <[email protected]> Co-authored-by: Ayman Bagabas <[email protected]>
- Loading branch information
1 parent
d2fab68
commit 7f44d6d
Showing
12 changed files
with
319 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ examples/git/.repos | |
.repos | ||
.ssh | ||
coverage.txt | ||
id_ed25519 | ||
id_ed25519.pub | ||
|
||
# MacOS specific | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build !linux && !darwin && !freebsd && !dragonfly && !netbsd && !openbsd && !solaris | ||
// +build !linux,!darwin,!freebsd,!dragonfly,!netbsd,!openbsd,!solaris | ||
|
||
package bubbletea | ||
|
||
import ( | ||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/charmbracelet/lipgloss" | ||
"github.com/charmbracelet/ssh" | ||
"github.com/muesli/termenv" | ||
) | ||
|
||
func makeOpts(s ssh.Session) []tea.ProgramOption { | ||
return []tea.ProgramOption{ | ||
tea.WithInput(s), | ||
tea.WithOutput(s), | ||
} | ||
} | ||
|
||
func newRenderer(s ssh.Session) *lipgloss.Renderer { | ||
pty, _, _ := s.Pty() | ||
env := sshEnviron(append(s.Environ(), "TERM="+pty.Term)) | ||
return lipgloss.NewRenderer(s, termenv.WithEnvironment(env), termenv.WithUnsafe(), termenv.WithColorCache(true)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris | ||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris | ||
|
||
package bubbletea | ||
|
||
import ( | ||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/charmbracelet/lipgloss" | ||
"github.com/charmbracelet/ssh" | ||
"github.com/muesli/termenv" | ||
) | ||
|
||
func makeOpts(s ssh.Session) []tea.ProgramOption { | ||
pty, _, ok := s.Pty() | ||
if !ok || s.EmulatedPty() { | ||
return []tea.ProgramOption{ | ||
tea.WithInput(s), | ||
tea.WithOutput(s), | ||
} | ||
} | ||
|
||
return []tea.ProgramOption{ | ||
tea.WithInput(pty.Slave), | ||
tea.WithOutput(pty.Slave), | ||
} | ||
} | ||
|
||
func newRenderer(s ssh.Session) *lipgloss.Renderer { | ||
pty, _, ok := s.Pty() | ||
env := sshEnviron(append(s.Environ(), "TERM="+pty.Term)) | ||
if !ok || pty.Slave == nil { | ||
return lipgloss.NewRenderer(s, termenv.WithEnvironment(env), termenv.WithUnsafe(), termenv.WithColorCache(true)) | ||
} | ||
return lipgloss.NewRenderer(pty.Slave, termenv.WithEnvironment(env), termenv.WithColorCache(true)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
id_ed25519* | ||
file.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.