diff --git a/tui/bubble.go b/tui/bubble.go index 209428cf89e3c522d9f2987f1d4b2fd5026a3516..891d86096172285bf84d85f69c9c82e5f2264f3f 100644 --- a/tui/bubble.go +++ b/tui/bubble.go @@ -41,10 +41,9 @@ type MenuEntry struct { } type SessionConfig struct { - Width int - Height int - WindowChanges <-chan ssh.Window - InitialRepo string + Width int + Height int + InitialRepo string } type Bubble struct { @@ -67,22 +66,21 @@ type Bubble struct { func NewBubble(cfg *Config, sCfg *SessionConfig) *Bubble { b := &Bubble{ - config: cfg, - styles: style.DefaultStyles(), - width: sCfg.Width, - height: sCfg.Height, - windowChanges: sCfg.WindowChanges, - repoSource: cfg.RepoSource, - repoMenu: make([]MenuEntry, 0), - boxes: make([]tea.Model, 2), - initialRepo: sCfg.InitialRepo, + config: cfg, + styles: style.DefaultStyles(), + width: sCfg.Width, + height: sCfg.Height, + repoSource: cfg.RepoSource, + repoMenu: make([]MenuEntry, 0), + boxes: make([]tea.Model, 2), + initialRepo: sCfg.InitialRepo, } b.state = startState return b } func (b *Bubble) Init() tea.Cmd { - return tea.Batch(b.windowChangesCmd, b.setupCmd) + return b.setupCmd } func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) { @@ -108,19 +106,18 @@ func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) { b.error = msg.Error() b.state = errorState return b, nil - case windowMsg: - cmds = append(cmds, b.windowChangesCmd) case tea.WindowSizeMsg: b.width = msg.Width b.height = msg.Height if b.state == loadedState { - ab, cmd := b.boxes[b.activeBox].Update(msg) - b.boxes[b.activeBox] = ab - if cmd != nil { - cmds = append(cmds, cmd) + for i, bx := range b.boxes { + m, cmd := bx.Update(msg) + b.boxes[i] = m + if cmd != nil { + cmds = append(cmds, cmd) + } } } - // XXX: maybe propagate size changes to child bubbles (particularly height) case selection.SelectedMsg: b.activeBox = 1 rb := b.repoMenu[msg.Index].bubble diff --git a/tui/commands.go b/tui/commands.go index 623cbedbf4c3ef166be5b29df7a35a27ecd2a36a..e57b133797340bcd0b4d15bc045d7fb9ab7b2bd9 100644 --- a/tui/commands.go +++ b/tui/commands.go @@ -17,13 +17,6 @@ func (e errMsg) Error() string { return e.err.Error() } -func (b *Bubble) windowChangesCmd() tea.Msg { - w := <-b.windowChanges - b.width = w.Width - b.height = w.Height - return windowMsg{} -} - func (b *Bubble) setupCmd() tea.Msg { lipgloss.SetColorProfile(termenv.ANSI256) b.repos = b.repoSource.AllRepos() diff --git a/tui/session.go b/tui/session.go index dff5618b5308ba6469a406f39afd34a5d3498890..da41a8471e6d866f617794cbc59f1a48e1dcd73c 100644 --- a/tui/session.go +++ b/tui/session.go @@ -55,14 +55,13 @@ func SessionHandler(reposPath string, repoPoll time.Duration) func(ssh.Session) default: return nil, nil } - pty, changes, active := s.Pty() + pty, _, active := s.Pty() if !active { fmt.Println("not active") return nil, nil } cfg.Width = pty.Window.Width cfg.Height = pty.Window.Height - cfg.WindowChanges = changes return NewBubble(appCfg, cfg), []tea.ProgramOption{tea.WithAltScreen()} } }