Skip to content

Commit

Permalink
add Printf/Println to tea.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxwell Huang-Hobbs committed Feb 28, 2022
1 parent c1af0c9 commit 94b5738
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tea.go
Expand Up @@ -690,3 +690,30 @@ func (p *Program) DisableMouseAllMotion() {
defer p.mtx.Unlock()
fmt.Fprintf(p.output, te.CSI+te.DisableMouseAllMotionSeq)
}

// Printf prints above the Program. This output is unmanaged by the program and
// will persist across renders by the Program.
//
// Unlike fmt.Printf (but similar to log.Printf) the message will be print on
// its own line.
//
// If the altscreen is active no output will be printed.
func (p *Program) Println(args ...interface{}) {
p.msgs <- printLineMessage{
messageBody: fmt.Sprint(args...),
}
}

// Printf prints above the Program. It takes a format template followed by
// values similar to fmt.Printf. This output is unmanaged by the program and
// will persist across renders by the Program.
//
// Unlike fmt.Printf (but similar to log.Printf) the message will be print on
// its own line.
//
// If the altscreen is active no output will be printed.
func (p *Program) Printf(template string, args ...interface{}) {
p.msgs <- printLineMessage{
messageBody: fmt.Sprintf(template, args...),
}
}

0 comments on commit 94b5738

Please sign in to comment.