peterbrittain / asciimatics

A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations
Apache License 2.0
3.62k stars 237 forks source link

Are there some way to select/copy/paste a block of text? #309

Closed jarodtang closed 3 years ago

jarodtang commented 3 years ago

Hi there,

I'm new to asciimatics, I would like to ask are some some way (examples) to select a block of text, as copy & paste to another place?

Regards, Jarod

peterbrittain commented 3 years ago

If you want to copy and paste to another application, you need to use the native clipboard.

Asciimatics doesn't support that, but there are other packages on pypi that do - e.g. pyperclip.

jarodtang commented 3 years ago

If you want to copy and paste to another application, you need to use the native clipboard.

Asciimatics doesn't support that, but there are other packages on pypi that do - e.g. pyperclip.

I just want to copy & paste in asciimatics. So what's prefer way to select/copy and paste?

Regards, Jarod

peterbrittain commented 3 years ago

I'm going to need a little more detail of your use case to be sure, but if it is just a matter of copying one bit of the screen to another location, then you should be able to use the get_from and print_at methods in your Screen. The former only extracts a single character, so you'd need to iterate over the area that you want to copy.

jarodtang commented 3 years ago

Thanks, I want to select a continuous block of text, such as "more detail of your use case to be sure" ( such as from a TextBox widget in a Frame), copy, and paste it into a text box. Are there some easy way to do that?

Regards, Jarod

peterbrittain commented 3 years ago

Asciimatics relies on the native clipboard for this sort of operation...

For example, on most terminals mouse click and drag selects a portion of the screen (possibly with an extra mouse click to copy it to the clipboard) and then selecting the new widget and right clicking on the new location will work (as that will input all the text into the widget with the focus).

jarodtang commented 3 years ago

Thanks for your information.

peterbrittain commented 3 years ago

NP. I'm assuming that handles this issue and so am closing.