aboutsummaryrefslogblamecommitdiffstats
path: root/termui/help_bar.go
blob: f5222ea4f8a6a5a6c27e5ed285698e67f0b0e780 (plain) (tree)
1
2
3
4
5
6
7
8
9





                 

                                                  
                                                






                       
                                           
                                   
                                  
                                                                                                                




                                       
                                                                                             
         
 

                               
package termui

import (
	"fmt"
	"strings"

	text "github.com/MichaelMure/go-term-text"

	"github.com/git-bug/git-bug/util/colors"
)

type helpBar []struct {
	keys string
	text string
}

func (hb helpBar) Render(maxX int) string {
	var builder strings.Builder
	for _, entry := range hb {
		builder.WriteString(colors.White(colors.BlueBg(fmt.Sprintf("[%s] %s", entry.keys, entry.text))))
		builder.WriteByte(' ')
	}

	l := text.Len(builder.String())
	if l < maxX {
		builder.WriteString(colors.White(colors.BlueBg(strings.Repeat(" ", maxX-l))))
	}

	return builder.String()
}