Allow copying with ANSI escape code control sequences
Summary of the Pull Request
This extends the copy command to be able to include control sequences, for use in tools that subsequently know how to parse and display that.
References and Relevant Issues
https://github.com/microsoft/terminal/issues/15703
Detailed Description of the Pull Request / Additional comments
At a high level, this:
- Expands the
CopyTextArgsto have awithControlSequencesbool. - Plumbs that bool down through many layers to where we actuall get data out of the text buffer.
- Modifies the existing
TextBuffer::Serializeto be more generic and renames it toTextBuffer::ChunkedSerialize. - Uses the new
ChunkedSerializeto generate the data for the copy request.
Validation Steps Performed
To test this I've manually:
- Generated some styled terminal contents, copied it with the control sequences, pasted it into a file,
cated the file and seen that it looks the same. - Set
"firstWindowPreference": "persistedWindowLayout"and validated that the contents of windows are saved and restored with styling intact.
I also checked that Invoke-OpenConsoleTests passed.
PR Checklist
- [x] Closes #15703
- [ ] Tests added/passed
- [x] Documentation updated
- If checked, please file a pull request on our docs repo and link it here: https://github.com/MicrosoftDocs/terminal/pull/756
- [x] Schema updated (if necessary)
@check-spelling-bot Report
:red_circle: Please review
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
Unrecognized words (1)
Callbcak
Previously acknowledged words that are now absent
AAAa Jsons vtapi 🫥To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands
... in a clone of the [email protected]:FuegoFro/windows_terminal.git repository
on the copy_with_control_sequences branch (:information_source: how do I use this?):
curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/microsoft/terminal/actions/runs/8676439456/attempts/1'
Available :books: dictionaries could cover words (expected and unrecognized) not in the :blue_book: dictionary
This includes both expected items (2228) from .github/actions/spelling/expect/04cdb9b77d6827c0202f51acd4205b017015bfff.txt .github/actions/spelling/expect/alphabet.txt .github/actions/spelling/expect/expect.txt .github/actions/spelling/expect/web.txt and unrecognized words (1)
| Dictionary | Entries | Covers | Uniquely |
|---|---|---|---|
| cspell:swift/src/swift.txt | 53 | 1 | 1 |
| cspell:gaming-terms/dict/gaming-terms.txt | 59 | 1 | 1 |
| cspell:monkeyc/src/monkeyc_keywords.txt | 123 | 1 | 1 |
| cspell:cryptocurrencies/cryptocurrencies.txt | 125 | 1 | 1 |
| cspell:scala/dict/scala.txt | 153 | 1 | 1 |
Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:
with:
extra_dictionaries:
cspell:swift/src/swift.txt
cspell:gaming-terms/dict/gaming-terms.txt
cspell:monkeyc/src/monkeyc_keywords.txt
cspell:cryptocurrencies/cryptocurrencies.txt
cspell:scala/dict/scala.txt
To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:
check_extra_dictionaries: ''
Errors (1)
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
| :x: Errors | Count |
|---|---|
| :x: ignored-expect-variant | 3 |
See :x: Event descriptions for more information.
:pencil2: Contributor please read this
By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
- ... misspelled, then please correct them instead of using the command.
- ... names, please add them to
.github/actions/spelling/allow/names.txt. - ... APIs, you can add them to a file in
.github/actions/spelling/allow/. - ... just things you're using, please add them to an appropriate file in
.github/actions/spelling/expect/. - ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in
.github/actions/spelling/patterns/.
See the README.md in each directory for more information.
:microscope: You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. :wink:
If the flagged items are :exploding_head: false positives
If items relate to a ...
-
binary file (or some other file you wouldn't want to check at all).
Please add a file path to the
excludes.txtfile matching the containing file.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^refers to the file's path from the root of the repository, so^README\.md$would exclude README.md (on whichever branch you're using). -
well-formed pattern.
If you can write a pattern that would match it, try adding it to the
patterns.txtfile.Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
@microsoft-github-policy-service agree
I'll try to review your PR sometime later this week and hopefully help you with designing the new TextBuffer functions. I'm currently trying to finish up a massive, rather complex PR myself unfortunately, which is why I can't help at the moment. 😣
I've reviewed the code now and I think it's ready to merge. Ideally we would replace all those boolean parameters with something "more compact", an enum, struct, or something else, but I think that's outside the scope of the PR.
However, I'd personally like to wait merging this PR until we've released 1.21 to Preview (in a month or so?) and only merge it into version 1.22. That way we'll have enough time to test this and noodle about any followup improvements we may want to do.
Thank you for taking the time to review it! That's great to hear and makes sense regarding waiting for the release to merge 👍
I'm happy to make some refactors regarding the "more compact" thing you were talking about, but I'd need a little more about what you've got in mind. More compact in terms of syntax or bytes taken (or something else)? Would this effectively be combining singleLine, withControlSequences, formats, and maybe dismissSelection into a single struct that we pass through?
The merge between this and main has gotten a little gnarly - I'm gonna take it out of the bugbash queue for today. Pretty sure it's not an impossible merge, but longer than I have time ATM