Page 1 of 1

Restore buffer on exit /b [Closed]

Posted: 16 Nov 2021 13:41
by atfon
Edit: Please disregard.I had previously turned off the cursor with a terminal escape sequence. The powershell command works fine.

I have a script which changes the console screen height and width periodically with the mode con command. I'd like to reset it back to the defaults on exit /b. I can use this:

Code: Select all

mode con: cols=120 lines=30
If I do this, I lose the default buffer. Is there any way to restore the buffer?

I can use powershell:

Code: Select all

powershell -command "&{$w=(get-host).ui.rawui;$w.buffersize=@{width=120;height=9001};$w.windowsize=@{width=120;height=30};}"
However, I find that my cursor stops blinking.

[Win 10 Pro]

Re: Restore buffer on exit /b [Closed]

Posted: 16 Nov 2021 14:26
by aGerman
The PowerShell command works flawlessly for me, Win11 Home.
// EDIT Didn't see your update :lol:

I tried to use an alternate screen buffer, resize it, and later turn back to the original buffer.
https://docs.microsoft.com/en-us/window ... een-buffer
However, updating the size of the alternate buffer doesn't seem to be supported.

Steffen

Re: Restore buffer on exit /b [Closed]

Posted: 16 Nov 2021 14:47
by atfon
aGerman wrote:
16 Nov 2021 14:26
I tried to use an alternate screen buffer, resize it, and later turn back to the original buffer.
https://docs.microsoft.com/en-us/window ... een-buffer
However, updating the size of the alternate buffer doesn't seem to be supported.

Steffen
Thank you for testing the Terminal Escape Sequences with the buffer. I was just getting to that myself! :)