diff options
| author | Adi Yeroslav <[email protected]> | 2025-07-16 15:43:48 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-16 07:43:48 -0500 |
| commit | 57d1a60efcd0bc7cc5709fac75a46270e344e43d (patch) | |
| tree | bbf56e3cd86a15eeff653fad9e98dd5f7a2cb835 /packages/tui/internal/app | |
| parent | add81b97396730ed3e838e8ca8e3a20a64013113 (diff) | |
| download | opencode-57d1a60efcd0bc7cc5709fac75a46270e344e43d.tar.gz opencode-57d1a60efcd0bc7cc5709fac75a46270e344e43d.zip | |
feat(tui): shift+tab to cycle modes backward (#1049)
Diffstat (limited to 'packages/tui/internal/app')
| -rw-r--r-- | packages/tui/internal/app/app.go | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/packages/tui/internal/app/app.go b/packages/tui/internal/app/app.go index 52be32694..818203b98 100644 --- a/packages/tui/internal/app/app.go +++ b/packages/tui/internal/app/app.go @@ -205,10 +205,17 @@ func (a *App) SetClipboard(text string) tea.Cmd { return tea.Sequence(cmds...) } -func (a *App) SwitchMode() (*App, tea.Cmd) { - a.ModeIndex++ - if a.ModeIndex >= len(a.Modes) { - a.ModeIndex = 0 +func (a *App) cycleMode(forward bool) (*App, tea.Cmd) { + if forward { + a.ModeIndex++ + if a.ModeIndex >= len(a.Modes) { + a.ModeIndex = 0 + } + } else { + a.ModeIndex-- + if a.ModeIndex < 0 { + a.ModeIndex = len(a.Modes) - 1 + } } a.Mode = &a.Modes[a.ModeIndex] @@ -244,6 +251,14 @@ func (a *App) SwitchMode() (*App, tea.Cmd) { } } +func (a *App) SwitchMode() (*App, tea.Cmd) { + return a.cycleMode(true) +} + +func (a *App) SwitchModeReverse() (*App, tea.Cmd) { + return a.cycleMode(false) +} + func (a *App) InitializeProvider() tea.Cmd { providersResponse, err := a.Client.Config.Providers(context.Background()) if err != nil { |
