MCPcopy Index your code
hub / github.com/coder/coder / View

Method View

cli/cliui/select.go:233–272  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

231}
232
233func (m selectModel) View() string {
234 var s strings.Builder
235
236 msg := pretty.Sprintf(pretty.Bold(), "? %s", m.message)
237
238 if m.selected != "" {
239 selected := pretty.Sprint(DefaultStyles.Keyword, m.selected)
240 _, _ = s.WriteString(fmt.Sprintf("%s %s\n", msg, selected))
241
242 return s.String()
243 }
244
245 if m.hideSearch {
246 _, _ = s.WriteString(fmt.Sprintf("%s [Use arrows to move]\n", msg))
247 } else {
248 _, _ = s.WriteString(fmt.Sprintf(
249 "%s %s[Use arrows to move, type to filter]\n",
250 msg,
251 m.search.View(),
252 ))
253 }
254
255 options, start := m.viewableOptions()
256
257 for i, option := range options {
258 // Is this the currently selected option?
259 style := pretty.Wrap(" ", "")
260 if m.cursor == start+i {
261 style = pretty.Style{
262 pretty.Wrap("> ", ""),
263 DefaultStyles.Keyword,
264 }
265 }
266
267 _, _ = s.WriteString(pretty.Sprint(style, option))
268 _, _ = s.WriteString("\n")
269 }
270
271 return s.String()
272}
273
274func (m selectModel) viewableOptions() ([]string, int) {
275 options := m.filteredOptions()

Callers 2

ViewMethod · 0.45
protoNodeToTailcfgMethod · 0.45

Calls 3

viewableOptionsMethod · 0.95
WriteStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected