Virtual Terminal/Pseudo-console buffer size events for Windows Terminal

Viewed 32

What is the preferred way to respond to changes in the buffer size for Windows Terminal? With an old-school command prompt, I would get a reference to the window handle for the console and hook the events from there. Is there an equivalent for PseudoConsoles?

1 Answers

In C++, you'd use ReadConsoleInput as in Reading Input Buffer Events to listen for WINDOW_BUFFER_SIZE_EVENT messages.

Alas, I'm not familiar enough with C# to know the idiomatic way of doing this. Surprisingly, I'm not seeing a simplified version of that in the Console API. You might need to pinvoke to do this.

Related