Init initializes the view.
(ctx context.Context)
| 36 | |
| 37 | // Init initializes the view. |
| 38 | func (p *Picker) Init(ctx context.Context) error { |
| 39 | app, err := extractApp(ctx) |
| 40 | if err != nil { |
| 41 | return err |
| 42 | } |
| 43 | |
| 44 | pickerView := app.Styles.Views().Picker |
| 45 | p.actions.Add(tcell.KeyEscape, ui.NewKeyAction("Back", app.PrevCmd, true)) |
| 46 | |
| 47 | p.SetBorder(true) |
| 48 | p.SetMainTextColor(pickerView.MainColor.Color()) |
| 49 | p.ShowSecondaryText(false) |
| 50 | p.SetShortcutColor(pickerView.ShortcutColor.Color()) |
| 51 | p.SetSelectedBackgroundColor(pickerView.FocusColor.Color()) |
| 52 | p.SetTitle(fmt.Sprintf(" [%s::b]Containers Picker ", app.Styles.Frame().Title.FgColor.String())) |
| 53 | |
| 54 | p.SetInputCapture(func(evt *tcell.EventKey) *tcell.EventKey { |
| 55 | if a, ok := p.actions.Get(evt.Key()); ok { |
| 56 | a.Action(evt) |
| 57 | evt = nil |
| 58 | } |
| 59 | return evt |
| 60 | }) |
| 61 | |
| 62 | return nil |
| 63 | } |
| 64 | |
| 65 | // InCmdMode checks if prompt is active. |
| 66 | func (*Picker) InCmdMode() bool { |
nothing calls this directly
no test coverage detected