Skip to content
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

support for OSC 4 #16

Open
cgsdev0 opened this issue Mar 3, 2024 · 1 comment
Open

support for OSC 4 #16

cgsdev0 opened this issue Mar 3, 2024 · 1 comment

Comments

@cgsdev0
Copy link

cgsdev0 commented Mar 3, 2024

hi!

i've been messing around with OSC 4 sequences lately to change the terminal's color palette on the fly. i noticed asciinema doesn't support it

it's kinda difficult to find good documentation for these sequences, but the best i've seen so far is https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Operating-System-Commands

i created a short demo:

{"version":2,"width":50,"height":28,"timestamp":1709462310,"env":{"TERM":"tmux-256color","SHELL":"/usr/bin/zsh"}}
[0.107432, "o", "\u001b]2;applesauce\u001b\\"]
[0.140703, "o", "\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[38;5;242msarah\u001b[39m\u001b[38;5;242m@applesauce\u001b[39m \u001b[34m~\u001b[39m\r\n\r\u001b[35m❯\u001b[39m \u001b[K"]
[0.140784, "o", "\u001b[?1h\u001b="]
[0.141187, "o", "\u001b[?2004h"]
[0.92006, "o", "\u001b[32mc\u001b[39m"]
[0.924449, "o", "\b\u001b[32mc\u001b[39m\u001b[90mlear\u001b[39m\b\b\b\b"]
[1.010068, "o", "\b\u001b[1m\u001b[31mc\u001b[1m\u001b[31mu\u001b[0m\u001b[39m\u001b[39m \u001b[39m \u001b[39m \b\b\b"]
[1.013263, "o", "\u001b[90mrl -LN party.hotdogstand.lol\u001b[39m\u001b[28D"]
[1.13193, "o", "\b\b\u001b[1m\u001b[31mc\u001b[1m\u001b[31mu\u001b[1m\u001b[31mr\u001b[0m\u001b[39m"]
[1.243904, "o", "\b\b\b\u001b[0m\u001b[32mc\u001b[0m\u001b[32mu\u001b[0m\u001b[32mr\u001b[32ml\u001b[39m"]
[1.589589, "o", "\u001b[39m \u001b[39m-\u001b[39mL\u001b[39mN\u001b[39m \u001b[39mp\u001b[39ma\u001b[39mr\u001b[39mt\u001b[39my\u001b[39m.\u001b[39mh\u001b[39mo\u001b[39mt\u001b[39md\u001b[39mo\u001b[39mg\u001b[39ms\u001b[39mt\u001b[39ma\u001b[39mn\u001b[39md\u001b[39m.\u001b[39ml\u001b[39mo\u001b[39ml"]
[1.984949, "o", "\u001b[?1l\u001b>"]
[1.990999, "o", "\u001b[?2004l"]
[1.991892, "o", "\r\r\n"]
[2.050787, "o", "\u001b]4;0;#ff0000\u001b\\\u001b]4;1;#ffff00\u001b\\\u001b]4;2;#ffff00\u001b\\\u001b]4;3;#ffff00\u001b\\\u001b]4;4;#ffff00\u001b\\\u001b]4;5;#ffff00\u001b\\\u001b]4;6;#ffff00\u001b\\\u001b]4;7;#ffff00\u001b\\\u001b]4;8;#ffff00\u001b\\\u001b]4;9;#ffff00\u001b\\\u001b]4;10;#ffff00\u001b\\\u001b]4;11;#ffff00\u001b\\\u001b]4;12;#ffff00\u001b\\\u001b]4;13;#ffff00\u001b\\\u001b]4;14;#ffff00\u001b\\\u001b]4;15;#ffff00\u001b\\\u001b]10;#ffff00\u001b\\\u001b]11;#ff0000\u001b\\\u001b]12;#ffff00\u001b\\\u001b]13;#ffff00\u001b\\\u001b]17;#ffff00\u001b\\\u001b]19;#ff0000\u001b\\\u001b]4;232;#ff0000\u001b\\\u001b]4;256;#ffff00\u001b\\\u001b]708;#ff0000\u001b\\"]
[3.051149, "o", "\u001b]4;0;#ffff00\u001b\\\u001b]4;1;#ff0000\u001b\\\u001b]4;2;#ff0000\u001b\\\u001b]4;3;#ff0000\u001b\\\u001b]4;4;#ff0000\u001b\\\u001b]4;5;#ff0000\u001b\\\u001b]4;6;#ff0000\u001b\\\u001b]4;7;#ff0000\u001b\\\u001b]4;8;#ff0000\u001b\\\u001b]4;9;#ff0000\u001b\\\u001b]4;10;#ff0000\u001b\\\u001b]4;11;#ff0000\u001b\\\u001b]4;12;#ff0000\u001b\\\u001b]4;13;#ff0000\u001b\\\u001b]4;14;#ff0000\u001b\\\u001b]4;15;#ff0000\u001b\\\u001b]10;#ff0000\u001b\\\u001b]11;#ffff00\u001b\\\u001b]12;#ff0000\u001b\\\u001b]13;#ff0000\u001b\\\u001b]17;#ff0000\u001b\\\u001b]19;#ffff00\u001b\\\u001b]4;232;#ffff00\u001b\\\u001b]4;256;#ff0000\u001b\\\u001b]708;#ffff00\u001b\\"]
[4.05504, "o", "\u001b]4;0;#ff0000\u001b\\\u001b]4;1;#ffff00\u001b\\\u001b]4;2;#ffff00\u001b\\\u001b]4;3;#ffff00\u001b\\\u001b]4;4;#ffff00\u001b\\\u001b]4;5;#ffff00\u001b\\\u001b]4;6;#ffff00\u001b\\\u001b]4;7;#ffff00\u001b\\\u001b]4;8;#ffff00\u001b\\\u001b]4;9;#ffff00\u001b\\\u001b]4;10;#ffff00\u001b\\\u001b]4;11;#ffff00\u001b\\\u001b]4;12;#ffff00\u001b\\\u001b]4;13;#ffff00\u001b\\\u001b]4;14;#ffff00\u001b\\\u001b]4;15;#ffff00\u001b\\\u001b]10;#ffff00\u001b\\\u001b]11;#ff0000\u001b\\\u001b]12;#ffff00\u001b\\\u001b]13;#ffff00\u001b\\\u001b]17;#ffff00\u001b\\\u001b]19;#ff0000\u001b\\\u001b]4;232;#ff0000\u001b\\\u001b]4;256;#ffff00\u001b\\\u001b]708;#ff0000\u001b\\"]
[5.052719, "o", "\u001b]4;0;#ffff00\u001b\\\u001b]4;1;#ff0000\u001b\\\u001b]4;2;#ff0000\u001b\\\u001b]4;3;#ff0000\u001b\\\u001b]4;4;#ff0000\u001b\\\u001b]4;5;#ff0000\u001b\\\u001b]4;6;#ff0000\u001b\\\u001b]4;7;#ff0000\u001b\\\u001b]4;8;#ff0000\u001b\\\u001b]4;9;#ff0000\u001b\\\u001b]4;10;#ff0000\u001b\\\u001b]4;11;#ff0000\u001b\\\u001b]4;12;#ff0000\u001b\\\u001b]4;13;#ff0000\u001b\\\u001b]4;14;#ff0000\u001b\\\u001b]4;15;#ff0000\u001b\\\u001b]10;#ff0000\u001b\\\u001b]11;#ffff00\u001b\\\u001b]12;#ff0000\u001b\\\u001b]13;#ff0000\u001b\\\u001b]17;#ff0000\u001b\\\u001b]19;#ffff00\u001b\\\u001b]4;232;#ffff00\u001b\\\u001b]4;256;#ff0000\u001b\\\u001b]708;#ffff00\u001b\\"]
[6.053719, "o", "\u001b]4;0;#ff0000\u001b\\\u001b]4;1;#ffff00\u001b\\\u001b]4;2;#ffff00\u001b\\\u001b]4;3;#ffff00\u001b\\\u001b]4;4;#ffff00\u001b\\\u001b]4;5;#ffff00\u001b\\\u001b]4;6;#ffff00\u001b\\\u001b]4;7;#ffff00\u001b\\\u001b]4;8;#ffff00\u001b\\\u001b]4;9;#ffff00\u001b\\\u001b]4;10;#ffff00\u001b\\\u001b]4;11;#ffff00\u001b\\\u001b]4;12;#ffff00\u001b\\\u001b]4;13;#ffff00\u001b\\\u001b]4;14;#ffff00\u001b\\\u001b]4;15;#ffff00\u001b\\\u001b]10;#ffff00\u001b\\\u001b]11;#ff0000\u001b\\\u001b]12;#ffff00\u001b\\\u001b]13;#ffff00\u001b\\\u001b]17;#ffff00\u001b\\\u001b]19;#ff0000\u001b\\\u001b]4;232;#ff0000\u001b\\\u001b]4;256;#ffff00\u001b\\\u001b]708;#ff0000\u001b\\"]
[6.286387, "o", "^C"]
[6.289531, "o", "\r\n"]
[6.322799, "o", "\u001b[0m\u001b[27m\u001b[24m\u001b[J\u001b[38;5;242msarah\u001b[39m\u001b[38;5;242m@applesauce\u001b[39m \u001b[34m~\u001b[39m\r\n\r\u001b[31m❯\u001b[39m \u001b[K"]
[6.322841, "o", "\u001b[?1h\u001b="]
[6.323225, "o", "\u001b[?2004h"]
[6.638575, "o", "\u001b[?2004l\r\r\n"]

the expected behavior is this (i rendered this gif from the demo using gifcast, which uses xterm.js for rendering)

Spoiler because it's quite obnoxious lol

download

since this is likely a very low priority feature (understandably), i did some digging on my own to see if i could make it work. i was able to hack together some code to parse the sequences, but i got stumped when it came to actually updating the colors in the palette. i messed around with updating the pen's colors, but i couldn't find a way to refresh the entire screen.

i mostly just wanted to document my exploration here. if you can nudge me in the right direction, i might be able to put up a pull request in the future. cheers!

@ku1ik
Copy link
Collaborator

ku1ik commented Jun 2, 2024

Hi,

Indeed OSC 4 is not supported at the moment. To make it work, it would take at least to implement the following:

  • recognizing OSC 4 in avt,
  • exposing it to the player from avt::Vt
  • adding support for dynamic themes in the player (the way the player defines colors today, via CSS custom props, should make it relatively straightforward)
  • ensuring that a theme is reset to the initial one when rewinding (seeking back) in the player

This is doable, however non-trivial, and at the moment it doesn't seem like worth the trouble (given other priorities).

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

No branches or pull requests

2 participants