MCPcopy
hub / github.com/derailed/k9s / Init

Method Init

internal/view/picker.go:38–63  ·  view source on GitHub ↗

Init initializes the view.

(ctx context.Context)

Source from the content-addressed store, hash-verified

36
37// Init initializes the view.
38func (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.
66func (*Picker) InCmdMode() bool {

Callers

nothing calls this directly

Calls 8

NewKeyActionFunction · 0.92
extractAppFunction · 0.85
ColorMethod · 0.80
FrameMethod · 0.80
AddMethod · 0.65
GetMethod · 0.65
ViewsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected