-
Notifications
You must be signed in to change notification settings - Fork 59
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
[BUG] Screen updates cause lots of scrollback buffer to be created #63
Comments
I've observed this as well. Python 3.9.9, Mac Monterey 12.3.1, iTerm 2 Build 3.4.15. |
I've also seen this happen, but not sure why. Theoretically, setting an alternate buffer should mean that no scrollback is preserved after exit, but iTerm doesn't seem to respect this for some reason. |
Same problems here Windows Terminal 1.12.10334.0
System details: ConEmu v.220418
WSL 2
System details: Edit: Windows 10 CMDThis one throws pure ANSI codes out. I didn't check on Linux machine yet. Seems that this module is not Windows-friendly 😃 |
@SomwareHR yup, at the moment the library's windows support is more "this works? cool" than "this has to work". I elaborated on this in some previous issues, but the basic problem is that I don't have a Windows machine I can develop on, so testing is pretty difficult. It will work on both MacOS and Linux, though! I'm not sure what the Windows Terminal team wants to achieve, but they seem to have implemented a lot of the xterm standard into the program, where historically Windows kinda just did its own thing. If they implement xterm-compatible mouse support before I (or another contributor) implements it for Windows then that should work as well. |
I found something that clears the buffer and doesn't create scrollback. It is a bit more manual, but it works. The codes should be the same for Linux and Windows so this could be a universal fix for scrollback. @bczsalba Let me know if this is something you want to integrate into the library def clear_buffer(buffer: TextIO, height: int):
"""Go to top left of buffer and delete all lines.
It will delete the first line and up to terminal height.
Args:
buffer (TextIO): The buffer to manipulate
height (int): The height of the buffer
"""
buffer.write("\x1b[0;0f") # Moves to top left
buffer.write(f"\x1b[{height}M") # Delete lines This will delete all lines from the buffer and put the cursor at the start of the buffer.
|
The current screen clear method is quite simple (just writes I think this can be done in P.S. in the line: buffer.write("\x1b[0;0f") # Moves to top left You are probably better off using As mentioned in #81 I'm working on a compositor that updates the screen char-by-char, which (I think) would fix this issue anyways. We should still include something for this, as the whole idea behind PTG is that the |
I can look at a couple spaces and make some ideas. |
On a sidenote: ED (erase in display, |
This issue is related to #81, so the note I left there is relevant here as well. There is a way to do this better (specifically diff-based screen updates), but in order to implement that we have to change pretty much every bit of PTG's underlying concepts, which is one step short of a full rewrite. This full rewrite has already been done under a new project, so if this bothers you I recommend checking out Celadon and its application framework celx :) |
Describe the bug
Screen updates, such as animations, produce lots of output in the scrollback buffer.
To Reproduce
Perform almost any action in pytermgui application and notice how the scrollbar gets really large, and you can in fact scroll back to see the history of what the screen looked like. This was done with iTerm2.
Expected behavior
Most ncurses based applications do not seem to spam the scrollback buffer this much.
System information
This is on macos Monterey with iTerm2. Running python inside of docker.
The text was updated successfully, but these errors were encountered: