40 lines
808 B
Go
40 lines
808 B
Go
package core
|
|
|
|
import "strings"
|
|
|
|
const CommandOutputExitMessage = "Press ENTER to continue"
|
|
|
|
type CommandOutput struct {
|
|
Title string
|
|
Lines []string
|
|
ScrollOffset int // Not implemented yet
|
|
// Height is computing via lines and title
|
|
Inline bool // Show inline instead of the window
|
|
IsError bool
|
|
}
|
|
|
|
// CommandOutput.Height: Compute the height (in lines) based on the line count, and title.
|
|
func (c *CommandOutput) Height() int {
|
|
if c.Inline {
|
|
return 1
|
|
}
|
|
|
|
var h int
|
|
h += len(c.Lines)
|
|
if strings.TrimSpace(c.Title) != "" {
|
|
h++
|
|
}
|
|
|
|
// Padding:
|
|
// +1 for 'enter key...' message
|
|
// +1 for top bar (border)
|
|
h += 2
|
|
|
|
return h
|
|
}
|
|
|
|
// CommandOutput.IsActive: Is the command output in a state that should be displayed.
|
|
func (c *CommandOutput) IsActive() bool {
|
|
return len(c.Lines) > 0
|
|
}
|