github.com/elves/elvish@v0.15.0/pkg/cli/label.go (about) 1 package cli 2 3 import ( 4 "github.com/elves/elvish/pkg/cli/term" 5 "github.com/elves/elvish/pkg/ui" 6 ) 7 8 // Label is a Renderer that writes out a text. 9 type Label struct { 10 Content ui.Text 11 } 12 13 // Render shows the content. If the given box is too small, the text is cropped. 14 func (l Label) Render(width, height int) *term.Buffer { 15 // TODO: Optimize by stopping as soon as $height rows are written. 16 bb := term.NewBufferBuilder(width) 17 bb.WriteStyled(l.Content) 18 b := bb.Buffer() 19 b.TrimToLines(0, height) 20 return b 21 } 22 23 // Handle always returns false. 24 func (l Label) Handle(event term.Event) bool { 25 return false 26 }