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

Ability to select/copy all the text in the session #1469

Closed
Tracked by #4993
mrmlnc opened this issue Jun 23, 2019 · 22 comments · Fixed by #13045
Closed
Tracked by #4993

Ability to select/copy all the text in the session #1469

mrmlnc opened this issue Jun 23, 2019 · 22 comments · Fixed by #13045
Assignees
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) good first issue This is a fix that might be easier for someone to do as a first contribution Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.

Comments

@mrmlnc
Copy link

mrmlnc commented Jun 23, 2019

Summary of the new feature/enhancement

Sometimes there are situations when you need to select/copy all the text in the session.

ConEmu has such functionality (MenuEditCopy All).

Proposed technical implementation details (optional)

  • Keybinding for action Select All Text.

May intersect with #715.

@mrmlnc mrmlnc added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jun 23, 2019
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jun 23, 2019
@carlos-zamora carlos-zamora added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. and removed Needs-Tag-Fix Doesn't match tag requirements labels Jun 25, 2019
@DHowett-MSFT DHowett-MSFT removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Jun 27, 2019
@DHowett-MSFT DHowett-MSFT added this to the Terminal Backlog milestone Jun 27, 2019
@DHowett-MSFT DHowett-MSFT added the Help Wanted We encourage anyone to jump in on these. label Jun 27, 2019
@carlos-zamora carlos-zamora self-assigned this May 12, 2020
@carlos-zamora
Copy link
Member

I should add this to the #4993 scenario.

@swinder0161
Copy link

@carlos-zamora what is the plan for this feature? Looks like an important feature.
Select by mouse/trackpad works. Adding by keyboard short cut would be easy to use.

@theswordsmahin
Copy link

For what its worth and to whomever finds this useful, if you zoom out really far with ctrl + scroll wheel highlighting the complete buffer is much less painful even for relatively long histories. Not ideal of course, workable.

@ghost ghost mentioned this issue Dec 11, 2020
6 tasks
@ghost ghost added In-PR This issue has a related PR and removed In-PR This issue has a related PR labels Dec 11, 2020
@zadjii-msft zadjii-msft removed the Help Wanted We encourage anyone to jump in on these. label Feb 9, 2021
@sba923
Copy link

sba923 commented Mar 7, 2021

Make sure one can choose between plain text and formatted text e.g. with colors. MobaXterm supports saving as RTF, preserving formatting.

@DHowett
Copy link
Member

DHowett commented Mar 7, 2021

We already support RTF and HTML copy, @sba923 :)

@sba923
Copy link

sba923 commented Mar 7, 2021

Typing my comment, on my phone, I kinda remembered reading about this somewhere... 😝 I promise I will check out the docs first thing in the morning 😜

@sba923
Copy link

sba923 commented May 5, 2021

We already support RTF and HTML copy, @sba923 :)

I know, but you can't choose dynamically.

You have to define this in the settings. So it's either "always formatted" or "always plain text."

Being able to choose between formatted copy or unformatted copy e.g. by using two different key bindings would be nice.

Or maybe the choice should be at paste time, not at copy time. (I know, one day Win+V will allow pasting the plain-text version of whatever's on the clipboard. But this is not yet for corporate systems running non-Insider Windows 10 builds 😉).

@DHowett
Copy link
Member

DHowett commented May 5, 2021

Or maybe the choice should be at paste time, not at copy time.

That's completely up to the app reading the clipboard. Can't do anything about that.

Being able to choose between formatted copy or unformatted copy e.g. by using two different key bindings would be nice.

You mean like...

{ "command": { "action": "copy", "copyFormatting": "rtf" }, "keys": "ctrl+shift+r" },
{ "command": { "action": "copy", "copyFormatting": "html" }, "keys": "ctrl+shift+h" },
{ "command": { "action": "copy", "copyFormatting": ["html", "rtf"] }, "keys": "ctrl+win+alt+shift+h" },

? From the docs for the copy action.

@sba923
Copy link

sba923 commented May 5, 2021

Or maybe the choice should be at paste time, not at copy time.

That's completely up to the app reading the clipboard. Can't do anything about that.

I know. It's too bad too many apps don't provide a way to choose between plain-text paste and formatted paste.

I paste tons of stuff into Teams, from various sources like VScode and Windows Terminal, and I often don't get what I'd expect.

My current workaround is to first rewrite the clipboard as plain-text-only with some one-liner, such as this running in a WSL2 tab in Windows Terminal 😉

pwsh.exe -noprofile -c Get-ClipboardText | fold -w80 | clip.exe

(this also tackles a Teams issue with the lack of line-wrapping but that's another issue altogether)

Being able to choose between formatted copy or unformatted copy e.g. by using two different key bindings would be nice.

You mean like...

{ "command": { "action": "copy", "copyFormatting": "rtf" }, "keys": "ctrl+shift+r" },
{ "command": { "action": "copy", "copyFormatting": "html" }, "keys": "ctrl+shift+h" },
{ "command": { "action": "copy", "copyFormatting": ["html", "rtf"] }, "keys": "ctrl+win+alt+shift+h" },

? From the docs for the copy action.

Exactly. [blushing mode on] My bad for not RTFM. [blushing mode off]. I'll try defining a "copy as plain text" keybinding and see whether my muscle memory can be trained to using that.

1 similar comment
@sba923
Copy link

sba923 commented May 5, 2021

Or maybe the choice should be at paste time, not at copy time.

That's completely up to the app reading the clipboard. Can't do anything about that.

I know. It's too bad too many apps don't provide a way to choose between plain-text paste and formatted paste.

I paste tons of stuff into Teams, from various sources like VScode and Windows Terminal, and I often don't get what I'd expect.

My current workaround is to first rewrite the clipboard as plain-text-only with some one-liner, such as this running in a WSL2 tab in Windows Terminal 😉

pwsh.exe -noprofile -c Get-ClipboardText | fold -w80 | clip.exe

(this also tackles a Teams issue with the lack of line-wrapping but that's another issue altogether)

Being able to choose between formatted copy or unformatted copy e.g. by using two different key bindings would be nice.

You mean like...

{ "command": { "action": "copy", "copyFormatting": "rtf" }, "keys": "ctrl+shift+r" },
{ "command": { "action": "copy", "copyFormatting": "html" }, "keys": "ctrl+shift+h" },
{ "command": { "action": "copy", "copyFormatting": ["html", "rtf"] }, "keys": "ctrl+win+alt+shift+h" },

? From the docs for the copy action.

Exactly. [blushing mode on] My bad for not RTFM. [blushing mode off]. I'll try defining a "copy as plain text" keybinding and see whether my muscle memory can be trained to using that.

@gyorokpeter
Copy link

Leaving the text format aside, what is the status of being able to copy all text to the clipboard? Since we just got the ability to change the language to English, I can now actually read the menu options and in the "Command Palette" window there is nothing that is related to selecting text. Ctrl+A just inserts ^A instead of selecting the text.
This is a major blocker because I might have a program that spits out dozens of screens worth of output and I want to search for the first error in the output (since usually a single error triggers a cascade of error messages, checking the last one is useless).

@mloskot
Copy link

mloskot commented Jul 16, 2021

@gyorokpeter

I might have a program that spits out dozens of screens worth of output and I want to search for the first error in the output

https://docs.microsoft.com/en-us/windows/terminal/search

I second request to support text selection and copying though.

@ohadschn
Copy link

ohadschn commented Jul 16, 2021

@gyorokpeter

I might have a program that spits out dozens of screens worth of output and I want to search for the first error in the output

https://docs.microsoft.com/en-us/windows/terminal/search

Unless you want wildcard search, regular expression search, find all, count, match whole word, find and replace, mark line and a million other things you'll never have inside a terminal...

One common scenario is using a command that dumps a huge JSON on the screen and you want to copy it over for further processing and formatting (yes, you can use stdout redirect but maybe you forgot, maybe you want to see the output first before saving it, etc).

@PolarGoose
Copy link

PolarGoose commented Nov 18, 2021

I have found a workaround to select all text:

  1. Scroll to the beginning of the console window, for example by pressing Ctrl+Shift+Home
  2. Start selecting text by holding left mouse button
  3. While holding left mouse button press Ctrl+Shift+End, it will move the cursor to the bottom of the window and all console's text will be selected
  4. Release left mouse button
  5. Press Ctrl+C to copy the text

@Araxeus
Copy link

Araxeus commented Feb 26, 2022

Is it really so hard to make a keybind for atleast "Select all current input" ? 😢

@zadjii-msft
Copy link
Member

zadjii-msft commented Feb 26, 2022

Oh, no this should be super easy. This should be marked "Easy Starter", that's my bad. Alas, we haven't had time to get around to it, but it shouldn't be too hard to:

  • add a new ShortcutAction to ALL_SHORTCUT_ACTIONS in AllShortcutActions.h
  • Implement the handler in AppActionHandlers to call into the active panes's TermControls
  • Have the TermControl tell the COntrolCore to tell the Terminal to select all the text from 0,0 to the end of the mutable viewport

If anyone is interested, feel free to take a stab! I'll relabel this appropriately ☺️

### Key Bindings
There will only be 1 new command that needs to be added:
| Action | Keybinding Args | Description |
|--|--|--|
| `selectAll` | | Select the entire text buffer.
By default, the following key binding will be set:
```JS
{ "command": "selectAll", "keys": "ctrl+shift+a" },
```

@zadjii-msft zadjii-msft added good first issue This is a fix that might be easier for someone to do as a first contribution Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Feb 26, 2022
@Araxeus
Copy link

Araxeus commented Feb 26, 2022

FYI ctrl+a works if the tab is powershell but not if its cmd

@MartinDevillers
Copy link

I probably have a silly workflow, but I just wanted to echo that for me "Select All" (Ctrl+A) and "Copy" (Ctrl+C) console output would be a pretty sweet feature to have.

@zadjii-msft zadjii-msft modified the milestones: 22H1, Terminal v1.15 Apr 12, 2022
@Menelion
Copy link

Menelion commented May 5, 2022

Dear devs, could you please implement this? As a blind developer I'm not able to use the mouse at all and, as it seems, there is no way of selecting text in Windows Terminal using the keyboard only. Otherwise, a great app, thank you.

@ghost ghost added the In-PR This issue has a related PR label May 5, 2022
@ghost ghost closed this as completed in #13045 May 6, 2022
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels May 6, 2022
ghost pushed a commit that referenced this issue May 6, 2022
Adds the `selectAll` action which can be used to select all text in the buffer (regardless of whether a selection is present).

## References
#3663 - Mark Mode
#4993 - [Scenario] Keyboard selection

## PR Checklist
* [x] Closes #1469
* [x] Tests added/passed

## Detailed Description of the Pull Request / Additional comments
I've made it such that selecting the "entire buffer" really just selects up to the mutable viewport. This seems like a nice QOL improvement since there's generally nothing past that.

When the user selects all, the viewport does not move. This is consistent with CMD behavior and is intended to allow the user to not lose context when selecting everything.

A minor change had to be made to the DxRenderer because this uncovered an underflow issue. Basically, the selection rects were handed to the DxEngine relative to the viewport (which means that some had a negative y-value). At some point, those rects were stored into `size_t`s, resulting in an underflow issue. This caused the renderer to behave strangely when rendering the selection. Generally, these kinds of issues weren't really noticed because selection would always modify a portion of the viewport.

Funny enough, in a way, this satisfies the "mark mode" scenario because the user now has a way to initiate a selection using only the keyboard. Though this isn't ideal, just a fun thing to point out (that's why I'm not closing the mark mode issue).

## Validation Steps Performed
- Verified using DxEngine and AtlasEngine
- select all --> keyboard selection --> start moving the top-left endpoint (and scroll to there)
- select all --> do not scroll automatically
@ghost
Copy link

ghost commented May 24, 2022

🎉This issue was addressed in #13045, which has now been successfully released as Windows Terminal Preview v1.14.143.:tada:

Handy links:

@Araxeus
Copy link

Araxeus commented May 24, 2022

Sorry but this is super unhelpful, it selects all the text in the prompt including the beginning

Microsoft Windows [Version 10.0.19044.1706]
(c) Microsoft Corporation. All rights reserved.

How about the ability to just select the current writable buffer??

@DHowett
Copy link
Member

DHowett commented May 24, 2022

This feature request was for the ability to select all the text in the buffer. If you're looking for something else, please file a new feature request.

In addition: that part of the buffer is writable:

image

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) good first issue This is a fix that might be easier for someone to do as a first contribution Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.