-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add Terminal preferences and allow ctrl+c and ctrl+v on terminal if it has a selection #3469
Conversation
I think it's a useful heuristic for the ctrl-c, since you are still able to send a ctrl-c to your program. But it blocks ctrl-v all the time, how would a user send a ctrl-v to the program? |
✅ ECA
FYI: |
@AndrienkoAleksandr Thanks for all the input. I've updated this PR with latest commit fd0a08d which uses @kittaakos This now also detects user's system if it is an OSX, and only allows |
@uniibu, please make sure you have squashed your commits before handing it over for the review. Thank you! |
This has not been addressed. With this patch, it's not possible to send ctrl-v to the program anymore... |
@simark @uniibu Maybe we should create a command to activate/deactivate custom keyDownHandler? |
@simark The patch still allows @AndrienkoAleksandr I initially planned to add a preference for terminal where a user can enable/disable the keybindings such as ctrl+c or ctrl+v.. So that could be an option. @kittaakos commits squashed. |
I mean, if you have bound something to ctrl-v in your program which runs in the terminal, you can't use that anymore since it will paste text instead. |
As per @simark's concern, I've added terminal to the preferences with This further opens up the terminal for further front-end user configurations, such as |
2982ce7
to
84cdd7e
Compare
'terminal.enableCopy': { | ||
type: 'boolean', | ||
description: 'Enable ctrl-c (cmd-c on macOS) to copy selected text', | ||
default: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I wouldn't be against setting these to true by default, since it's probably more common for people to use copy/paste than to use ctrl-v.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to set up true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this gets merged, i'd be happy to have the default to true as well. +1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update it before merge?
Since theia let most key bindings be handled by xterm, the usual copy&paste key shortcuts no longer works. Theia did this intentionally to have key bindings such as ctrl+c to propagate into xterm, which then is used to send a kill signal SIGINT. This PR, allows the user to copy texts on the terminal via ctrl+c or cmd+c(mac), but only if there is a selected/highlighted text on the terminal. This also allows the user to use ctrl+v or cmd+v to paste from clipboard Signed-off-by: Uni Sayo <[email protected]> add missing semicolon and remove trailing whitespace Signed-off-by: Uni Sayo <[email protected]> use KeyCode from core to detect keybindings, ignore ctrl+c/v if osx As suggested, this commit simplifies detection of the keybindings by using KeyCode class from theia/core. It also detects if the user system is OSX. For non-osx systems, ctrl+c with selection and ctrl+v will work. And for osx systems, cmd+c with selection and cmd+v will work, while ctrl+c and ctrl+v will propagate to xterm normally. Signed-off-by: Uni Sayo <[email protected]> Add Terminal Preferences with enableCopy and enablePaste Adding terminal preferences gives the user an option to enable ctrl/cmd+c and ctrl/cmd+v keyboard commands. This also opens up the terminal for other user configurations. Signed-off-by: Uni Sayo <[email protected]> remove preferencechange listener Signed-off-by: Uni Sayo <[email protected]> reword descriptions Signed-off-by: Uni Sayo <[email protected]> remove clearSelection on copy Signed-off-by: Uni Sayo <[email protected]> Change copyright to reflect my company Signed-off-by: Uni Sayo <[email protected]> set default value to true Signed-off-by: Uni Sayo <[email protected]>
|
Background:
Since theia let most key bindings be handled by xtermjs, the usual
copy&paste key shortcuts no longer works.
Theia did this intentionally to have key bindings such as ctrl+c to
propagate into xterm, which then is used to send a kill signal SIGINT.
About:
This PR adds
Terminal
to preferences withenableCopy
andenablePaste
as initial options.enableCopy
[Boolean] - Enablesctrl-c
orcmd-c
(for OSX) to copy selected texts from the terminal.If there is no text selected, the command will propagate normally to xterm.
enablePaste
[Boolean] - Enabledctrl-v
orcmd-v
(for OSX) to paste from clipboard,This PR uses xterm's
attachCustomKeyEventHandler
to listen for key strokes and the selection is returned by xterm'shasSelection
function.Signed-off-by: Uni Sayo [email protected]