github.com/kolbycrouch/elvish@v0.14.1-0.20210614162631-215b9ac1c423/pkg/cli/tk/label.go (about) 1 package tk 2 3 import ( 4 "src.elv.sh/pkg/cli/term" 5 "src.elv.sh/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 }