Skip to content

Commit

Permalink
feat: add a cmd to request window size
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Apr 22, 2024
1 parent 1c6e74d commit bce9727
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,12 @@ func SetWindowTitle(title string) Cmd {
return setWindowTitleMsg(title)
}
}

type windowSizeMsg struct{}

// WindowSize is a command that queries the terminal for its current size.
func WindowSize() Cmd {
return func() Msg {
return windowSizeMsg{}
}
}
3 changes: 3 additions & 0 deletions tea.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ func (p *Program) eventLoop(model Model, cmds chan Cmd) (Model, error) {

case setWindowTitleMsg:
p.SetWindowTitle(string(msg))

case windowSizeMsg:
p.checkResize()
}

// Process internal messages for the renderer.
Expand Down

0 comments on commit bce9727

Please sign in to comment.