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

Handling terminal resizes on Windows #538

Closed
aschey opened this issue Oct 14, 2022 · 3 comments · Fixed by #878
Closed

Handling terminal resizes on Windows #538

aschey opened this issue Oct 14, 2022 · 3 comments · Fixed by #878

Comments

@aschey
Copy link
Contributor

aschey commented Oct 14, 2022

Since the PR to handle input records on Windows wasn't merged, would there be any interest in using a simple polling-based approach to handle resizes on Windows? Basically something like this:

w, h, err := term.GetSize(int(f.Fd()))
for {
    time.Sleep(500 * time.Millisecond)
    newW, newH, err := term.GetSize(int(f.Fd()))
    if newW != w || newH != h {
        w = newW
        h = newH
        msgs <- WindowSizeMsg{w, h}
    }
}

Obviously not ideal, but I think it would be nice to support resizing in some capacity. Can make it disabled by default and marked as an unstable feature if necessary.

@aschey aschey changed the title Resizing on Windows Handling terminal resizes on Windows Oct 14, 2022
@muesli
Copy link
Contributor

muesli commented Oct 14, 2022

Personally I dislike such polling based solutions, as they always feel like a bit of a hack. Obviously the current situation isn't ideal and we need to some thing about it, but I'm sure there are proper ways to get notified of a resized console on Windows. Which PR are you referring to?

@aschey
Copy link
Contributor Author

aschey commented Oct 14, 2022

Agree that it's definitely a hack, but I don't know if there's another reliable way to do it besides handling input records. This: #140 is the PR that implemented input records and would've enabled handling resizes. If there is still interest in handling input records, that would be the ideal way to solve this. But as mentioned in the comments, that would require a substantial change to the architecture around how the cancel reader now works.

aymanbagabas added a commit that referenced this issue Dec 3, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 3, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 4, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 4, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 4, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 4, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 4, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 4, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 4, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 4, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 4, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 4, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Dec 15, 2023
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Feb 27, 2024
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Feb 27, 2024
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
aymanbagabas added a commit that referenced this issue Feb 27, 2024
This adds support to the Windows Console Input Buffer API which access
the console API directly without the need for virtual terminal input
(i.e. the current mode that emulates unix inputs).
Since this uses the console input api, we can finally read window size
events.

This is mearly based on the awesome work of @erikgeiser in #140.

Fixes: #538
Fixes: #121
@meowgorithm
Copy link
Member

Just a note that this is now available in Windows courtesy #878. It's currently on master and will be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants