-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Copy with Control Sequences #15703
Comments
This is an initial attempt at allowing including control sequences in text copied from the terminal, for use in tools that subsequently know how to parse and display that. See microsoft#15703. At a high level, so far this: - Expands the `CopyActionArgs` to have a `withControlSequences` bool - Plumbs that bool down through many layers to where we actuall get data out of the text buffer - Adds basic proof-of-concept functionality in the text buffer to generate the relevant control sequences based on the text attributes and uses that when the bool is set. Right now I'm mainly looking for feedback on whether this is something that might be accepted (is this functionality that's wanted) and whether this approach broadly seems reasonable. If both of those "checks" pass, I'll work on polishing this up with completeness, tests, etc.
This is an initial attempt at allowing including control sequences in text copied from the terminal, for use in tools that subsequently know how to parse and display that. See microsoft#15703. At a high level, so far this: - Expands the `CopyTextArgs` to have a `withControlSequences` bool. - Plumbs that bool down through many layers to where we actuall get data out of the text buffer. - Adds basic proof-of-concept functionality in the text buffer to generate the relevant control sequences based on the text attributes and uses that when the bool is set. Right now I'm mainly looking for feedback on whether this is something that might be accepted (is this functionality that's wanted) and whether this approach broadly seems reasonable. If both of those "checks" pass, I'll work on polishing this up with completeness, tests, etc.
Hey there! I'm interested in helping out with this, and I've gotten a very basic proof-of-concept version working locally: https://github.com/microsoft/terminal/compare/main...FuegoFro:windows_terminal:copy_with_control_sequences?expand=1 But before I keep working on it I wanted to check in on a few things:
I appreciate any and all guidance here! 🙏 (also as a side note, I just wanted to say how much I appreciate the docs and tooling here; I was able to go from "I've never worked with Windows-specific tooling" to "I have this up and running and can see the changes I've made" in a day, which is awesome 🎉) |
Oh man, this is so cool! Thanks so much for working on it! Absolutely -- we usually mark things "Help Wanted" if we think they'll be approachable for a community member. Getting down into the nitty-gritty of the text buffer usually isn't approachable. In the time since you started working on that (maybe? I could be wrong!) @lhecker added a somewhat generic or genericizable function to TextBuffer that does the same thing. It's currently used for session save/restore. I wonder if y'all can converge! I'm so glad you were able to get going1 and I'm looking forward to your eventual PR 🙂 Footnotes
|
Ah amazing, thank you so much for the quick response! That function is exactly what I wanted, so glad I can reuse it and not reimplement that all myself! 😅 Thanks for pointing me at it 😊 Given there wasn't mention of a spec in the above response, I've gone ahead and opened #17059 with an implementation that reuses the serialize function. Aside from a few questions I've left there, I think it should be ready for feedback! |
If I may just offer some outside view on this. VT being an in-band control in the text stream, copying it as Now on to the second solution, using a special ANSI/VT clipboard format. This would be a great solution for terminal-oriented apps that want to explicitly support these control sequences. I don't think this is an alternative to the So to summarize, my ideal solution would be:
This makes the VT always available to apps that expect it, and enables advanced users/devs to copy with VT to apps that are not designed for it. I would also add a On a related note, the |
The same can be said of HTML and RTF though. If we're going to support that for one format, we should support it for all of them. |
@j4james I agree, and browsers have the Developer Tools to enable copy of HTML as Providing exports to HTML, RTF, and Bitmap from Terminal would make a lot of sense to improve the copy/paste scenarios with apps that do not handle VT. |
Description of the new feature/enhancement
Option to copy text from the terminal with ANSI sequences. Useful when you need to copy styled output to another file like a markdown codefence with ansi-support (ex. expressive-code/expressive-code#29)
See similar option in iTerm2: Edit > Copy with Control Sequences
Proposed technical implementation details (optional)
A new "Copy with Control Sequences" command that includes escape sequences in the copied text. Either include original ANSI-sequences if possible or recreate (best-effort) like iTerm2.
The text was updated successfully, but these errors were encountered: