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

Parse ConEmu OSC9 #3125

Open
mitchellh opened this issue Dec 25, 2024 · 2 comments
Open

Parse ConEmu OSC9 #3125

mitchellh opened this issue Dec 25, 2024 · 2 comments
Labels
contributor friendly A well-scoped, approachable issue for someone looking to contributor. vt Control sequence related

Comments

@mitchellh
Copy link
Contributor

See: https://conemu.github.io/en/AnsiEscapeCodes.html#OSC_Operating_system_commands

Some other background: #3124, #3119

ConEmu OSC9 conflicts with iTerm notifications. We've supported iTerm notifications for a long time and I'd like to continue to do so. As a workaround, I think we should say that any ConEmu OSC9 commands can never be desktop notifications. This feels like a good tradeoff to me because why are you making those notifications anyways... and you can work around it by using OSC777.

We should expand our OSC parser to parse all ConEmu OS commands (OSC9).

As part of this, we should do better research on how ConEmu handles specific erroneous inputs because the table does not make it clear and there is no spec.

NOTE: This issue is only tracking parsing. We should not do anything with these commands. I'm not sure if we ever want to support some of these and for the others we should discuss in a GH discussion about what to do.

@mitchellh mitchellh added contributor friendly A well-scoped, approachable issue for someone looking to contributor. vt Control sequence related labels Dec 25, 2024
@Jan200101
Copy link
Collaborator

Jan200101 commented Dec 25, 2024

Here is how ConEmu implements the parsing https://github.com/Maximus5/ConEmu/blob/740b09c363cb16fbb730d72c53eaca1c530a016e/src/ConEmuCD/ConAnsiImpl.cpp#L2264
and here is how it handles the parsed data https://github.com/Maximus5/ConEmu/blob/740b09c363cb16fbb730d72c53eaca1c530a016e/src/ConEmu/RealConsole.cpp#L13656

notably it doesn't validate input beyond what it expects
so 9;4;3blablablabla isn't parsed further than 9;4;3

There is also the case that the "Running" state (9;4;1;pr) also has pr as optional component , despite what the documentation says, and defaults to 0

the Windows Terminal implementation is even more relaxed:
the OSC is segmented and parsed depending on the number of segments available

I think it might be reasonable to support a subset of what ConEmu does:

  • be a lot more strict with the format, if anything that isn't expected is received fall back to desktop notification
  • progress type can only be 1 char
  • pr must be a number
  • pr cannot be negative
  • remove (0) doesn't support pr
  • set (1) requires pr
  • error (2) supports but doesn't require pr
  • indeterminate (3) doesn't support pr
  • pause (4) supports but doesn't require pr

this should follow the spirit of the documentation even if it doesn't follow the implementation of ConEmu or Windows Terminal

@mitchellh
Copy link
Contributor Author

I should note that we don't need a single PR to do all of OSC9 at once to close this issue. In fact, I'd prefer that not the case. I'd rather see small scoped PRs so do less, add tests, make it clean. ❤

And thanks @Jan200101 this is great information!

This was referenced Jan 1, 2025
mitchellh added a commit that referenced this issue Jan 5, 2025
This PR implements support for the [ConEmu OSC9;3 escape
sequence](https://conemu.github.io/en/AnsiEscapeCodes.html#OSC_Operating_system_commands).

| Sequence | Description |
| - | - |
ESC ] 9 ; 3 ; ”txt“ ST | Change ConEmu Tab to txt. Set empty string to
return original Tab text

#3125
mitchellh added a commit that referenced this issue Jan 5, 2025
# Description

This PR implements support for the [ConEmu OSC9;1 escape
sequence](https://conemu.github.io/en/AnsiEscapeCodes.html#OSC_Operating_system_commands).

Based on my understanding of [ConEmu's source
code](https://github.com/Maximus5/ConEmu/blob/740b09c363cb16fbb730d72c53eaca1c530a016e/src/ConEmuCD/ConAnsiImpl.cpp#L705-L724):
- The default timeout is set to `100` milliseconds if no value is
specified.
- The timeout value is clamped to a maximum of `10000` milliseconds.

#3125
This was referenced Jan 11, 2025
mitchellh added a commit that referenced this issue Jan 11, 2025
| Sequence | Description |
| - | - |
ESC ] 9 ; 5 ST | Wait for Enter/Space/Esc. Set environment variable
“ConEmuWaitKey” to “ENTER”/”SPACE”/”ESC” on exit.

Source:
https://conemu.github.io/en/AnsiEscapeCodes.html#OSC_Operating_system_commands

#3125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly A well-scoped, approachable issue for someone looking to contributor. vt Control sequence related
Projects
None yet
Development

No branches or pull requests

2 participants