Skip to content

Commit

Permalink
fix: simplify instantiating a new standard renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Aug 20, 2024
1 parent 53d72b4 commit 544a715
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions standard_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ type standardRenderer struct {

// NewStandardRenderer creates a new renderer. Normally you'll want to initialize it
// with os.Stdout as the first argument.
func NewStandardRenderer(out io.Writer) Renderer {
func NewStandardRenderer() Renderer {
r := &standardRenderer{
out: out,
mtx: &sync.Mutex{},
queuedMessageLines: []string{},
}
Expand Down
12 changes: 6 additions & 6 deletions tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) {
p.renderer.Execute(ansi.RequestKittyKeyboard)

case modifyOtherKeys:
p.renderer.execute(ansi.RequestModifyOtherKeys)
p.renderer.Execute(ansi.RequestModifyOtherKeys)

case setModifyOtherKeysMsg:
p.modifyOtherKeys = int(msg)
Expand Down Expand Up @@ -642,17 +642,17 @@ func (p *Program) Run() (Model, error) {
}

// If no renderer is set use the standard one.
output := p.output
if p.renderer == nil {
output := p.output
// TODO(v2): remove the ANSI compressor
if p.startupOptions.has(withANSICompressor) {
output = &compressor.Writer{Forward: output}
}
p.renderer = NewStandardRenderer(output)
} else {
// Ensure the renderer has the correct output.
p.renderer.SetOutput(p.output)
p.renderer = NewStandardRenderer()
}

// Set the renderer output.
p.renderer.SetOutput(output)
if p.ttyOutput != nil {
// Set the initial size of the terminal.
w, h, err := term.GetSize(p.ttyOutput.Fd())
Expand Down

0 comments on commit 544a715

Please sign in to comment.