Skip to content

Commit

Permalink
Convert Println and Printf to commands
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Feb 28, 2022
1 parent 0ab8a0a commit 5b4cc24
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions standard_renderer.go
Expand Up @@ -482,30 +482,33 @@ type printLineMessage struct {
messageBody string
}

// Println writes a message above your application on the next flush.
// Printf prints above the Program. This output is unmanaged by the program and
// will persist across renders by the Program.
//
// The message is not added to the area bubbletea controls, so it can be
// used to log messages to the terminal without making them a persistent
// part of application model.
// Unlike fmt.Printf (but similar to log.Printf) the message will be print on
// its own line.
//
// Does not work with altScreenMode
func Println(args ...interface{}) Msg {
return printLineMessage{
messageBody: fmt.Sprint(args...),
// If the altscreen is active no output will be printed.
func Println(args ...interface{}) Cmd {
return func() Msg {
return printLineMessage{
messageBody: fmt.Sprint(args...),
}
}
}

// Println writes a message at the top of the next flush.
//
// The message is not added to the area bubbletea controls, so it can be
// used to log messages to the terminal without making them a persistent
// part of application model.
// 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.
//
// Note that unlike fmt.Printf, the message will be put on its own line.
// Unlike fmt.Printf (but similar to log.Printf) the message will be print on
// its own line.
//
// Does not work with altScreenMode
func Printf(template string, args ...interface{}) Msg {
return printLineMessage{
messageBody: fmt.Sprintf(template, args...),
// If the altscreen is active no output will be printed.
func Printf(format string, args ...interface{}) Cmd {
return func() Msg {
return printLineMessage{
messageBody: fmt.Sprintf(template, args...),
}
}
}

0 comments on commit 5b4cc24

Please sign in to comment.