Skip to content

Resizing truncates on terminal window's original size #661

Answered by Zebbeni
Zebbeni asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, it looks like batching a WindowSizeMsg Cmd with my tick Cmd solves my problem. It'd be great if bubbletea comes up with a way to avoid polling for window resizes on Windows machines in the future but I'm happy with this for now.

previous:

func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
	switch msg.(type) {
	case tickMsg:
		w, h, _ := term.GetSize(int(os.Stdout.Fd()))
		if w != m.w || h != m.h {
			m.updateSize(w, h)
		}
		return m, tick
	}
	return m, nil
}

solution:

func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
	switch msg.(type) {
	case tickMsg:
		w, h, _ := term.GetSize(int(os.Stdout.Fd()))
		if w != m.w || h != m.h {
			m.updateSize(w, h)
		}
		return m, tea.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by bashbunni
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #658 on February 15, 2023 19:28.