MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / PickFromList

Method PickFromList

ui/fullscreen_backend.go:257–296  ·  view source on GitHub ↗
(title string, values [][2]string)

Source from the content-addressed store, hash-verified

255}
256
257func (b *FullscreenRendererBackend) PickFromList(title string, values [][2]string) *string {
258 if len(values) == 0 {
259 return nil
260 }
261 b.InputEnabled = true
262 b.InputMode = "selection"
263 b.InputPlaceholder = "上下选择,回车确认,Esc 取消。也可输入编号。"
264 b.InputText = ""
265 b.InputCursor = 0
266 b.CompletionItems = nil
267 b.CompletionSelected = 0
268 b.SelectionTitle = title
269 b.SelectionValues = values
270 b.SelectionSelected = 0
271 b.PendingSelection = true
272 b.refreshControls()
273 defer func() {
274 b.PendingSelection = false
275 b.SelectionTitle = ""
276 b.SelectionValues = nil
277 b.SelectionSelected = 0
278 b.InputMode = "normal"
279 b.refreshControls()
280 }()
281 text, ok := b.readFullscreenText()
282 if !ok {
283 return nil
284 }
285 text = strings.TrimSpace(text)
286 if text == "" {
287 return nil
288 }
289 for idx, value := range values {
290 if text == fmt.Sprint(idx+1) {
291 selected := value[0]
292 return &selected
293 }
294 }
295 return nil
296}
297
298func (b *FullscreenRendererBackend) RenderEvent(event agent.StreamEvent) {
299 switch event.Type {

Calls 2

refreshControlsMethod · 0.95
readFullscreenTextMethod · 0.95