(bindingInfos []bindingInfo)
| 106 | } |
| 107 | |
| 108 | func (self *OptionsMapMgr) formatBindingInfos(bindingInfos []bindingInfo) string { |
| 109 | width := self.c.Views().Options.InnerWidth() - 2 // -2 for some padding |
| 110 | var builder strings.Builder |
| 111 | ellipsis := "…" |
| 112 | separator := " | " |
| 113 | |
| 114 | length := 0 |
| 115 | |
| 116 | for i, info := range bindingInfos { |
| 117 | plainText := fmt.Sprintf("%s: %s", info.description, info.key) |
| 118 | |
| 119 | // Check if adding the next formatted string exceeds the available width |
| 120 | textLen := utils.StringWidth(plainText) |
| 121 | if i > 0 && length+len(separator)+textLen > width { |
| 122 | builder.WriteString(theme.OptionsFgColor.Sprint(separator + ellipsis)) |
| 123 | break |
| 124 | } |
| 125 | |
| 126 | formatted := info.style.Sprintf(plainText) |
| 127 | |
| 128 | if i > 0 { |
| 129 | builder.WriteString(theme.OptionsFgColor.Sprint(separator)) |
| 130 | length += len(separator) |
| 131 | } |
| 132 | builder.WriteString(formatted) |
| 133 | length += textLen |
| 134 | } |
| 135 | |
| 136 | return builder.String() |
| 137 | } |
| 138 | |
| 139 | func (self *OptionsMapMgr) renderOptions(options string) { |
| 140 | self.c.SetViewContent(self.c.Views().Options, options) |
no test coverage detected