romgrk / termrk

Terminal for atom, using pty.js & term.js
MIT License
33 stars 7 forks source link

Question - Selections? #13

Closed ghost closed 9 years ago

ghost commented 9 years ago

Hello

At the risk of sounding a bit silly, is it possible to perform selections in the terminal? Looking at the term.js page it seems to support a selection mode via screenKeys, which seems (?) to be enabled in termrk, but I have no idea how to trigger it. The term.js documentation mentions a tmux-like selection mode using the option key, but a quick attempt at several combinations using the Control key don't seem to work. (This is probably a PEBKAC issue from my side.)

Thanks in advance

romgrk commented 9 years ago

Yes. The activation sequence is ctrl-a [. Once there, you can move cursor the same way vim's normal-mode does. Press v to plant selection tail and start visual mode. Move again with normal-mode keys. Press y to _y_ank (vim's term for copy) selection. Important note: to get out of the ctrl-a [ mode, the key is escape. However, it is currently mapped to termrk:hide. Unmap it before using ctrl-a [ mode. I'll check if I can add an escape escape key.

romgrk commented 9 years ago

Other note: using keybinding resolver, check that none of these keys is catched before being used by termrk.

ghost commented 9 years ago

Thanks, I got it to work (even though I'm not really familiar with Vim :P), though I've got to admit it's not very fast when quickly wanting to grab something from the terminal. I suppose as developer of the extension, you're pretty much stuck with whatever term.js offers and something like mouse selection by simply dragging the mouse is not simple to implement? :P

romgrk commented 9 years ago

Well I have been looking for something like that. I must say that term.js is very poorly documented, but I have been trying to understand the code. I just added scrolling support, by capturing myself the MouseWheel events and programmatically scrolling the terminal, so I guess adding something like selection wouldn't be that hard to do.

I'll keep this thread open, and if I have any update on that I'll post it here.

ghost commented 9 years ago

Just wanted to mention that the term2 package [1] also seems to use term.js and does have selections, I however can't immediately find anything related to it in the source code, perhaps it's somehow catered to by Atom itself because the terminal is openend in a tab (i.e. it's somehow treated as an editable buffer by Atom?).

[1] https://github.com/webBoxio/atom-term2

romgrk commented 9 years ago

As reference: https://github.com/atom/atom/issues/4800

Feature added by 0aa61ae9871b06c9bbde5898670ad587560d0e28

Selection style is determined by @background-color-selected, which should be a default UI variable.

ctrl-c or whatever key you have for copying should work. Let me know if it's not the case.

ghost commented 9 years ago

Awesome, thanks! This makes quick selections from e.g. Git output a whole lot faster.