rprichard / winpty

A Windows software package providing an interface similar to a Unix pty-master for communicating with Windows console programs.
MIT License
1.29k stars 167 forks source link

winpty clears screen in Git Bash #202

Open jakubsimacek opened 1 year ago

jakubsimacek commented 1 year ago

Hi, is there a way how to prevent clearing the screen after termination of winpty? (or somehow save and then restore it?) For example: (top left corner of the screen) $ echo xyz xyz $ winpty nvim

...after exiting nvim I get: (top left corner of the screen) $

and when I scroll up using the scroll bar, there is nothing. The echo xyz and the output has been erased. Only the content that was already scrolled out before executing winpty.

Thanks a lot, Jakub

andry81 commented 1 year ago

I am not familiar with the winpty, but it looks like it works with the visible screen and so saves only a visible screen, not the entire console buffer. So may be and even actually it does not clear the screen.

jakubsimacek commented 1 year ago

It erases the visible screen (overwrites the visible part of the buffer). The nonvisible part is untouched. (all what has been already scolled away remains). So if you had an ouptut of a command on the screen and started something via winpty, it's lost. Only workaround that crosses my mind is to create a wrapper script which prints x new lines to sroll the content of the screen away so it survives. I hope there is a better solution though.

andry81 commented 1 year ago

I've tested versus python executable and it does not clear the screen on exit. May be the nvim does it on it's own. What is why only a visible portion has cleared. A workaround here would be copy a screen somethere before nvim exit and then copy it back.