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 the rendered text on the terminal copyable #985

Open
chgxtony opened this issue Mar 15, 2024 · 8 comments
Open

Make the rendered text on the terminal copyable #985

chgxtony opened this issue Mar 15, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@chgxtony
Copy link

chgxtony commented Mar 15, 2024

Problem

The text rendered to the screen by Ratatui cannot be copied now

Solution

https://github.com/altsem/gitu/tree/master/src/screen
this project still references Ratatui, which enables text to be copied。
Can these functions be integrated into Ratatui's widgets

@chgxtony chgxtony added the enhancement New feature or request label Mar 15, 2024
@joshka
Copy link
Member

joshka commented Mar 15, 2024

Can you provide some more details please (OS, terminal, backend, example code or a link to your code). Also, given all of the above, there's lots of different ways to interpret "copying" (programmatic, mouse, cursor selection, automatic highlight vs ctrl/cmd+C etc). Can you be more specific?

@chgxtony
Copy link
Author

Sorry, I posted the wrong link, I have corrected it. it is this link https://github.com/altsem/gitu/tree/master/src/screen
Gitu has implemented text that can be copied

@chgxtony chgxtony reopened this Mar 15, 2024
@joshka
Copy link
Member

joshka commented Mar 17, 2024

I still need more info on what the problem is here

@matusbielik
Copy link

matusbielik commented Apr 17, 2024

I am not the OP, but I'd also like to learn more about what is possible when it comes to copying.
I am using Alacritty on Linux, and outside of Ratatui apps, I can automatically put text into clipboard just by selecting it. Then I can paste it by clicking the middle mouse button into the terminal prompt or using CTRL+V anywhere else in the system. In ratatui apps (e.g. example app 'table'), I can't select any text, so it is not very useful as a lightweight admin interface where texts need to be copy-able easily.

When using Debian's default Gnome Terminal (Version 3.51.90 for GNOME 46), putting selected text into clipboard is not automatic, but the user still can select the text, then put it into clipboard with CTRL+SHIFT+C (or selecting 'Copy' from the context menu after clicking right mouse button). I am also not able to select the text in ratatui apps and neither bring up context menu with right mouse button.

I understand it is not trivial to make it possible for every terminal emulator and OS, but I suppose copying text is very important "feature" that shouldn't be lost with Ratatui.

EDIT:
Interestingly enough, copying work well on both terminals for me when running the example "flex".
What is different between table and flex examples (I am new to ratatui). Thx

@EdJoPaTo
Copy link
Member

At least gnome console and alacritty support Shift + Click when the terminal is in alt mode. Then Ctrl + Shift + C can be used to copy the content into the system clipboard.

@joshka
Copy link
Member

joshka commented Apr 19, 2024

What is different between table and flex examples (I am new to ratatui). Thx

Table has mouse capture turned on (as do a lot of the examples unnecessarily). This prevents the mouse clicks that would generally make it possible to perform copy/paste actions (noting that there's usually workarounds as @EdJoPaTo mentions).

execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;

Fixing this means:

  • Remove the enable/disable mouse capture from all the examples where mouse clicks are not handled

@chgxtony would it be safe to reframe this issue as "Many of the examples don't allow selecting text using the mouse"?

@EdJoPaTo
Copy link
Member

This is not specific to only the examples. Also with scrollable widgets and mouse interaction mouse capture is of interest.

@joshka
Copy link
Member

joshka commented Apr 21, 2024

This is not specific to only the examples. Also with scrollable widgets and mouse interaction mouse capture is of interest.

Got it - perhaps it would be worth adding some info about this sort of problem in the website somewhere. Maybe a FAQ about how mouse capture interacts with selection.

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

No branches or pull requests

4 participants