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

Make text selectable #263

Closed
gitnik opened this issue Oct 12, 2016 · 9 comments
Closed

Make text selectable #263

gitnik opened this issue Oct 12, 2016 · 9 comments

Comments

@gitnik
Copy link

gitnik commented Oct 12, 2016

I can't find an option to make text inside my box selectable and thus copyable?

@pt300
Copy link

pt300 commented Oct 13, 2016

Uh. What?

@gitnik
Copy link
Author

gitnik commented Oct 13, 2016

The docs don't mention how I can make it so that text inside a box can be selected via mouse.

Here I have a box into which I pipe the output of a gulp process. But as you can see in the gif I have no way of interacting with the text:
http://giphy.com/gifs/3otOKmBidQetuQ6Aww

@pt300
Copy link

pt300 commented Oct 13, 2016

That's not problem with blessed but with your terminal.
Usually you can have problems with selection when output gets updated. To prevent that you could try pausing stdout with ctrl+s, copy what you want and resume it with ctrl+q. That should at least work on Linux.

@pt300
Copy link

pt300 commented Oct 14, 2016

As I think about it now it might be also caused by blessed capturing mouse clicks.
You could try finding a way to disable that.

@gitnik
Copy link
Author

gitnik commented Oct 17, 2016

Ok thanks I will give that a try

@gitnik
Copy link
Author

gitnik commented Oct 17, 2016

mouse: false did the trick. thank you!

@gitnik gitnik closed this as completed Oct 17, 2016
@LoganDark
Copy link

on mac you have to hold down fn because otherwise Blessed recieves all the mouse clicks

@tbranyen
Copy link

I found that on Linux (urxvt) you can hold down shift to select text.

@wearhere
Copy link

wearhere commented May 26, 2018

I have found that it is not specifically mouse: false that will enable text selection, but rather making
sure that screen.program.enableMouse() is not called. That method can be called if you use scroll/hover/click handling anywhere in your application, not limited to mouse: true, but also program.on('click'), the use of a hover style, or even enabling the debug log since that's scrollable.

Rather than try to disable all of those uses of mouse events, you can call screen.program.disableMouse() when you want to enable text selection, and then call screen.program.enableMouse() again when you want to use hover or click handling.

A really fortunate thing is that calling disableMouse not only re-enables native Terminal text selection, but also native scrolling. Let's say you have a Log component. By default that Log component will not scroll unless you pass mouse: true to it. So if you pass mouse: false (because you're trying to re-enable text selection), you'll break its scrolling. But then if you call screen.program.disableMouse(), you'll re-enable scrolling. (And, the scrolling will be at a much nicer speed than blessed's default scrolling imo.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants