MCPcopy Create free account
hub / github.com/Effect-TS/effect / renderAutoCompleteChoicePrefix

Function renderAutoCompleteChoicePrefix

packages/effect/src/cli/Prompt.ts:3392–3421  ·  view source on GitHub ↗
(
  state: AutoCompleteState,
  options: AutoCompleteOptionsReq<A>,
  toDisplay: { readonly startIndex: number; readonly endIndex: number },
  currentIndex: number,
  figures: Theme,
  renderOptions?: RenderOptions | undefined
)

Source from the content-addressed store, hash-verified

3390}
3391
3392const renderAutoCompleteChoicePrefix = <A>(
3393 state: AutoCompleteState,
3394 options: AutoCompleteOptionsReq<A>,
3395 toDisplay: { readonly startIndex: number; readonly endIndex: number },
3396 currentIndex: number,
3397 figures: Theme,
3398 renderOptions?: RenderOptions | undefined
3399) => {
3400 const prefix = renderPagingPrefix(
3401 figures,
3402 currentIndex === toDisplay.startIndex && toDisplay.startIndex > 0,
3403 currentIndex === toDisplay.endIndex - 1 && toDisplay.endIndex < state.filtered.length
3404 )
3405 const choiceIndex = state.filtered[currentIndex]
3406 if (renderOptions?.plain === true) {
3407 return state.index === choiceIndex
3408 ? figures.pointer + prefix
3409 : prefix + " ".repeat(figures.pointer.length)
3410 }
3411 const choice = options.choices[choiceIndex]
3412 if (choice.disabled) {
3413 const annotation = Ansi.combine(Ansi.bold, figures.mutedColor)
3414 return state.index === choiceIndex
3415 ? annotateSymbol(figures, figures.pointer, annotation) + prefix
3416 : prefix + " ".repeat(figures.pointer.length)
3417 }
3418 return state.index === choiceIndex
3419 ? annotateSymbol(figures, figures.pointer, figures.primaryColor) + prefix
3420 : prefix + " ".repeat(figures.pointer.length)
3421}
3422
3423const renderChoiceTitle = <A>(
3424 choice: SelectChoice<A>,

Callers 1

Calls 3

renderPagingPrefixFunction · 0.85
annotateSymbolFunction · 0.85
combineMethod · 0.65

Tested by

no test coverage detected