Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Flickering in ghostty (or other termials that render as fast as possible) #13

Open
Syphdias opened this issue Aug 18, 2024 · 0 comments

Comments

@Syphdias
Copy link
Contributor

I am currently in the closed beta for ghostty (opening up planed for the end of this year afaik).

This terminal renders everything it gets as fast as possible which leads to flickering ghostty-org/ghostty#2054. There is a way to prevent this by implementing the Synchronized Output Spec.

There would be three steps to implementing it, I am just not sure where.

  1. Check if the terminal supports the Sync Protocol by sending CSI ? 2026 $ p and receiving CSI ? 2026 ; 2 $ y (or at least not CSI ? 2026 ; 0 $ y)
  2. Before redrawing the UI, send BSU (CSI ? 2026 h)
  3. After redrawing the UI, send ESU (CSI ? 2026 l)

I think this should do the trick for setting BSU/ESU for example:

fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
BSU = b'\x1b[?2026h'

tty.setraw(fd)
os.write(fd, BSU)  # or ESU
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)

Not sure where to use stdin or stdout and where that would be in the code.

Also for detecting if the feature is available you need to get the response from stdin.

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

No branches or pull requests

1 participant