kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.2k stars 972 forks source link

Reading the clipboard (OSC52) followed by a DA1 #7743

Closed aymanbagabas closed 1 month ago

aymanbagabas commented 1 month ago

Describe the bug I'm trying to write a program to read the terminal response to a clipboard read using OSC52 \x1b]52;c;?\x07. In order to detect if the terminal supports the sequence, I'm writing DA1 \x1b[c after the query sequence to see which one the terminal replies to first. Since reading the clipboard prompts the user, the terminal should hold writing any responses until the user provides a response to the prompt. But that seems not to be the case, Kitty writes the DA1 response, waits for a clipboard prompt response, and then writes the OSC52 read response.

To Reproduce Steps to reproduce the behavior:

  1. cat | printf '\x1b]52;c;?\x07\x1b[c'
  2. See response

Environment details

Version 0.35.2 (0.35.2)
kovidgoyal commented 1 month ago

Yes, that is by design. kitty is not going to block the event loop for what is a fundamentally asynchronous operation. If you want to query for the state of clipboard support use the XTGETTCAP escape code, as described here: https://sw.kovidgoyal.net/kitty/kittens/query_terminal/ this is synchronous and reports the state of the clipboard_control setting and the terminal name among many other things.