Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a cmd to request window size #988

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions commands.go
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.
aymanbagabas marked this conversation as resolved.
Show resolved Hide resolved
func WindowSize() Cmd {
return func() Msg {
return windowSizeMsg{}
}
}
3 changes: 3 additions & 0 deletions tea.go
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