diff options
| author | Dax Raad <[email protected]> | 2025-05-18 22:30:41 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-05-26 12:40:17 -0400 |
| commit | 99af6146d5def31c59993636d60eb75a483a283b (patch) | |
| tree | eb57ed227c15cf9be54bc9f231c83895d812f881 /pkg/tui/layout/layout.go | |
| parent | 020e0ca039287b73fa33041fbd1bb214e6ccb396 (diff) | |
| download | opencode-99af6146d5def31c59993636d60eb75a483a283b.tar.gz opencode-99af6146d5def31c59993636d60eb75a483a283b.zip | |
openapi
Diffstat (limited to 'pkg/tui/layout/layout.go')
| -rw-r--r-- | pkg/tui/layout/layout.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pkg/tui/layout/layout.go b/pkg/tui/layout/layout.go new file mode 100644 index 000000000..495a3fbc5 --- /dev/null +++ b/pkg/tui/layout/layout.go @@ -0,0 +1,35 @@ +package layout + +import ( + "reflect" + + "github.com/charmbracelet/bubbles/key" + tea "github.com/charmbracelet/bubbletea" +) + +type Focusable interface { + Focus() tea.Cmd + Blur() tea.Cmd + IsFocused() bool +} + +type Sizeable interface { + SetSize(width, height int) tea.Cmd + GetSize() (int, int) +} + +type Bindings interface { + BindingKeys() []key.Binding +} + +func KeyMapToSlice(t any) (bindings []key.Binding) { + typ := reflect.TypeOf(t) + if typ.Kind() != reflect.Struct { + return nil + } + for i := range typ.NumField() { + v := reflect.ValueOf(t).Field(i) + bindings = append(bindings, v.Interface().(key.Binding)) + } + return +} |
