Skip to content

Commit

Permalink
fix: use raw output
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Dec 12, 2024
1 parent c69a82c commit ee1a613
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func WithContext[T any](ctx context.Context) ProgramOption[T] {
// won't need to use this.
func WithOutput[T any](output io.Writer) ProgramOption[T] {
return func(p *Program[T]) {
p.Output = newSafeWriter(output)
p.Output = output
}
}

Expand Down
6 changes: 3 additions & 3 deletions tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func NewProgram[T any](model Model[T], opts ...ProgramOption[T]) *Program[T] {

// if no output was set, set it to stdout
if p.Output == nil {
p.Output = newSafeWriter(os.Stdout)
p.Output = os.Stdout
}

// if no environment was set, set it to os.Environ()
Expand All @@ -331,7 +331,7 @@ func NewProgram[T any](model Model[T], opts ...ProgramOption[T]) *Program[T] {
if _, err := LogToFile(tracePath, "bubbletea"); err == nil {
// Enable different types of tracing.
if output, _ := strconv.ParseBool(os.Getenv("TEA_TRACE_OUTPUT")); output {
p.Output.(*safeWriter).trace = true
// p.Output.(*safeWriter).trace = true
}
if input, _ := strconv.ParseBool(os.Getenv("TEA_TRACE_INPUT")); input {
p.traceInput = true
Expand Down Expand Up @@ -745,7 +745,7 @@ func (p *Program[T]) Start() error {

// Get the color profile and send it to the program.
if !p.startupOptions.has(withColorProfile) {
p.profile = colorprofile.Detect(p.Output.(*safeWriter).Writer(), p.environ)
p.profile = colorprofile.Detect(p.Output, p.environ)
}

go p.Send(ColorProfileMsg{p.profile})
Expand Down
2 changes: 1 addition & 1 deletion tty_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (p *Program[T]) initInput() (err error) {
}
}

if f, ok := p.Output.(*safeWriter).Writer().(term.File); ok && term.IsTerminal(f.Fd()) {
if f, ok := p.Output.(term.File); ok && term.IsTerminal(f.Fd()) {
p.ttyOutput = f
}

Expand Down

0 comments on commit ee1a613

Please sign in to comment.