-
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 <caarlos0@users.noreply.github.com> * fix: deps Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: deps Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * 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 <caarlos0@users.noreply.github.com> * improvements Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: pty Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com> Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: better diff * chore: typo * fix: godocs * fix: allocate pty on macos Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: improvements based on #219 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com> * chore: godoc * fix: review Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com> Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: example Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: tea program handler Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: examples * refactor: improve p!=nil handling Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * 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 <caarlos0@users.noreply.github.com> * fix: update charmbracelet/ssh * fix: update dep Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * chore: go mod tidy Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * chore: update example --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Co-authored-by: Ayman Bagabas <ayman.bagabas@gmail.com>
- 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.