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

Added CopyOnSelect as a Global Setting #2152

Merged
13 commits merged into from
Aug 20, 2019
Merged

Added CopyOnSelect as a Global Setting #2152

13 commits merged into from
Aug 20, 2019

Conversation

carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Jul 30, 2019

Summary of the Pull Request

Introduces the "copyOnSelect" setting to "globals" as a boolean type. When set to true, a selection is immediately copied to your clipboard upon creation. When set to false, the selection persists and awaits further action.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Standard "added a new global setting" changes
TermControl's PointerReleased event is updated to support a mouse button release event. Just hooked up the copy function right there.

Validation Steps Performed

  • copyOnSelect = true
    • make selection
    • right click to paste (selection persists)
    • Works! ✔
  • copyOnSelect = true
    • make selection
    • right click to paste
    • left click on a cell
    • right click to paste
    • same data should be pasted twice
    • Works! ✔
  • copyOnSelect = true
    • click on a cell (no selection)
    • drag to another cell (selection visible)
    • drag back to first cell (selection should persist, but should only cover one cell)
    • Works! ✔
  • copyOnSelect = false
    • make selection
    • selection persists
    • right click to copy (selection disappears)
    • right click to paste
    • Works! ✔

@carlos-zamora carlos-zamora self-assigned this Jul 30, 2019
zadjii-msft
zadjii-msft previously approved these changes Jul 30, 2019
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@mcpiroman
Copy link
Contributor

mcpiroman commented Jul 30, 2019

Should the selection disappear? That's not how it works on other terminals.

Also, if it doesn't, I'd like to have some visual confirming the current selection is in clipboard (if it is), such as selection outline color. But that's another pr/issue, right?

miniksa
miniksa previously approved these changes Jul 30, 2019
Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. we need to not allow a click to select a single character
  2. look at how other terminals fix that

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jul 30, 2019
@zadjii-msft zadjii-msft dismissed their stale review July 30, 2019 21:34

I agree with dustin on the whole "we need to not allow a click to select a single character" thing

@carlos-zamora
Copy link
Member Author

carlos-zamora commented Jul 31, 2019

Should the selection disappear? That's not how it works on other terminals.

Yeah. I originally had it disappear to provide feedback that you copied it. I'm going to change it to:

  • selection persists after copy
  • right-click immediately pastes (doesn't do a redundant copy)
  • click/tap (no drag) should...
    • not create a new selection
    • @DHowett-MSFT should it erase old selection? erase old selection

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jul 31, 2019
@carlos-zamora
Copy link
Member Author

Question: should setting be renamed to copyMode = {Windows, Unix}? 👍 or 👎 and put your thoughts below!

@zadjii-msft
Copy link
Member

I think I personally prefer copyOnSelect. It's much more literally what I want - I wouldn't necessarily know that unix means "copy on select". Is there other possible values of copyMode you're thinking of other than Windows vs Unix?

@carlos-zamora
Copy link
Member Author

carlos-zamora commented Jul 31, 2019

I think I personally prefer copyOnSelect. It's much more literally what I want - I wouldn't necessarily know that unix means "copy on select". Is there other possible values of copyMode you're thinking of other than Windows vs Unix?

IIRC, MacOS's Terminal has a drop-down on right-click. But that's also weird because there'd be different functionality through that drop down menu like "search with Google", I think. I don't remember what the other drop-down options are.

Edit: here's a snapshot of right-clicking "Dropbox" on MacOS's Terminal
Screen Shot 2019-07-31 at 8 00 20 PM

@0xabu
Copy link

0xabu commented Aug 1, 2019

Question: should setting be renamed to copyMode = {Windows, Unix}?

A copyMode of "unix" is pretty ambiguous, IMO it could just as easily refer to line ending conversion as it could to the select/click behaviour. Also, AFAIK (grumpy old man tone) copy-on-select derives more from X and its ancestors than it does Unix.

CopyOnSelect value accessible through Terminal's IsCopyOnSelectActive
@carlos-zamora
Copy link
Member Author

Alright, decided on the following model for the settings:

The only tricky part I see here is copyOnSelect's 3rd function potentially interfering with pointer bindings. For now, I say we keep it as is. When pointer bindings comes along, we can make it so that smartCopyPaste specifically clears the selection. Thus kinda breaking this up into 2 things (not a big fan but I feel that that's the best way to approach this issue).

@DHowett-MSFT DHowett-MSFT dismissed stale reviews from miniksa and themself August 5, 2019 20:54

Significant changes.

// - Checks if selection on a single cell is allowed for rendering purposes
// Return Value:
// - bool representing if selection is only a single cell. Used for copyOnSelect
const bool Terminal::IsSingleCellCopyAllowed() const noexcept
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this and the above be folded into IsSelectionActive?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one can be deleted once the TermControl caller goes away

@carlos-zamora carlos-zamora added the Area-Interaction Interacting with the vintage console window (as opposed to driving via API or hooks) label Aug 13, 2019
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm of two minds:

  1. I want to ship this feature
  2. I want tests

I'm not approving, but only based on the fact there aren't any tests in a very testable part of the code. The other two can get together and override me though if they want.

src/cascadia/TerminalCore/Terminal.hpp Show resolved Hide resolved
# Conflicts:
#	src/cascadia/TerminalCore/Terminal.hpp
#	src/cascadia/UnitTests_TerminalCore/ScreenSizeLimitsTest.cpp
@nguerrera

This comment has been minimized.

@carlos-zamora
Copy link
Member Author

@zadjii-msft CopyOnSelect tests got added. Note that an "active selection" is considered copy-able. Handling a single cell selection is really weird but I thing the refactor and the test should make it clear what kind of behavior is now expected when using this new mode.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the tests C:

@carlos-zamora
Copy link
Member Author

@msftbot make sure @DHowett-MSFT signs off

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Aug 19, 2019
@ghost
Copy link

ghost commented Aug 19, 2019

Hello @carlos-zamora!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it's approved by @DHowett-MSFT

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits, but I'd like to see them answered before the bot merges the PR ;)

src/cascadia/TerminalCore/Terminal.hpp Outdated Show resolved Hide resolved
src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
// - Checks if selection on a single cell is allowed for rendering purposes
// Return Value:
// - bool representing if selection is only a single cell. Used for copyOnSelect
const bool Terminal::IsSingleCellCopyAllowed() const noexcept
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one can be deleted once the TermControl caller goes away

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 19, 2019
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 19, 2019
@ghost ghost merged commit ff87190 into master Aug 20, 2019
@ghost ghost deleted the dev/cazamor/copy-on-select branch August 20, 2019 16:42
@timriker
Copy link

I'm running the version in the store. (0.3.2171.0) With this version, click-drag, double-click and triple-click all select and copy to clipboard. Right click removes selection, but does NOT paste. A second right click DOES paste. This is odd.

On other terminal apps on windows and Linux, middle button is paste and right button is menu. Is there an option to get that functionality?

What does middle button do currently?

I don't see a "CopyOnSelect" option in settings.

@DHowett-MSFT
Copy link
Contributor

image

Our release process can't possibly be that fast.

@DHowett-MSFT
Copy link
Contributor

As of 0.3.2171.0: selection just selects, right-click copies and deselects, and then right-click pastes.
As of [next version]: copyOnSelect is added, but the preexisting behavior stays the same if it is set to false.

@timriker
Copy link

timriker commented Aug 20, 2019

I didn't expect it to be in the store release yet, just being clear that I'm not yet testing the current change. :)

I would like to see more Linux-y feel with left button select modes, middle button paste mode, and right button menu. It's been requested before on other posts. I was just wondering if there's a plan for adding that. Thanks for the updates!

@DHowett-MSFT
Copy link
Contributor

Thanks! We haven't yet looked at middle-paste, but we've talked about "mouse bindings" (as a post-1.0 feature)!

@ghost
Copy link

ghost commented Aug 27, 2019

🎉Windows Terminal Preview v0.4.2382.0 has been released which incorporates this pull request.:tada:

Handy links:

@alecive
Copy link

alecive commented Sep 25, 2019

Question: I'm using 0.4.2382.0 but I am still having big issues when using WSL with windows terminal. Should I see the copyOnSelect toggle somewhere in the settings? Why don't I see it there?

I am just trying to fix the annoying bug of copying something in my clipboard [from e.g. the notepad or the browser] and then pasting it in my WSL instance within windows terminal. It this PR fixing this issue?

@DHowett-MSFT
Copy link
Contributor

fix the annoying bug of copying something

@alecive what you have described is not a bug (???) so we can't tell if this pull request, which adds an option that makes it so text you select gets copied to the clipboard automatically, fixes it.

(fwiw: add copyOnSelect to your profiles.json as a boolean, either in the globals section or not (if you don't have one))

@lagunary
Copy link

lagunary commented Feb 5, 2020

Awesome!!!!

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Interaction Interacting with the vintage console window (as opposed to driving via API or hooks) AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: add copy on select (per Unix terminals)
10 participants