elvish/pkg/cli/tk/empty.go
Qi Xiao d2936c06a1 Use a more sophisticated algorithm to distribute widget heights.
This is needed since there can now be an arbitrary number of widgets competing
for vertical space.

- Add a new MaxHeight method to the tk.Widget interface to provide hint on how
  to distribute the height.

- Implement the algorithm in distributeHeight in cli/app.go.
2021-09-05 01:17:46 +01:00

24 lines
506 B
Go

package tk
import (
"src.elv.sh/pkg/cli/term"
)
// Empty is an empty widget.
type Empty struct{}
// Render shows nothing, although the resulting Buffer still occupies one line.
func (Empty) Render(width, height int) *term.Buffer {
return term.NewBufferBuilder(width).Buffer()
}
// MaxHeight returns 1, since this widget always occupies one line.
func (Empty) MaxHeight(width, height int) int {
return 1
}
// Handle always returns false.
func (Empty) Handle(event term.Event) bool {
return false
}