idoavrah / terraform-tui

Terraform textual UI
https://pypi.org/project/tftui/
Apache License 2.0
973 stars 30 forks source link

Error pyperclip #60

Closed BenjaminMinguy closed 4 months ago

BenjaminMinguy commented 4 months ago

Hello,

i have an error when i try to copy texte :

╭──────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────╮
│ /home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/site-packages/tftui/__main__.py:467 in action_copy                      │
│                                                                                                                                   │
│   464 │                                                                                                                           │
│   465 │   def action_copy(self) -> None:                                                                                          │
│   466 │   │   if self.switcher.current == "resource":                                                                             │
│ ❱ 467 │   │   │   pyperclip.copy(self.app.tree.current_node.data.contents)                                                        │
│   468 │   │   │   self.notify("Copied resource definition to clipboard")                                                          │
│   469 │   │   elif self.switcher.current == "tree":                                                                               │
│   470 │   │   │   pyperclip.copy(self.app.tree.current_node.label.plain)                                                          │
│                                                                                                                                   │
│ ╭────────────────────────────────── locals ──────────────────────────────────╮                                                    │
│ │ self = TerraformTUI(title='Terraform TUI v0.12.5', classes={'-dark-mode'}) │                                                    │
│ ╰────────────────────────────────────────────────────────────────────────────╯                                                    │
│                                                                                                                                   │
│ /home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/site-packages/pyperclip/__init__.py:659 in lazy_load_stub_copy          │
│                                                                                                                                   │
│   656 │   '''                                                                                                                     │
│   657 │   global copy, paste                                                                                                      │
│   658 │   copy, paste = determine_clipboard()                                                                                     │
│ ❱ 659 │   return copy(text)                                                                                                       │
│   660                                                                                                                             │
│   661                                                                                                                             │
│   662 def lazy_load_stub_paste():                                                                                                 │
│                                                                                                                                   │
│ ╭──────────────────────────────────────────── locals ────────────────────────────────────────────╮                                │
│ │ text = 'resource "aws_volume_attachment" "XXX" {\n    device_name = "XXX'+122 │                                │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────────╯                                │
│                                                                                                                                   │
│ /home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/site-packages/pyperclip/__init__.py:336 in __call__                     │
│                                                                                                                                   │
│   333 │   class ClipboardUnavailable(object):                                                                                     │
│   334 │   │                                                                                                                       │
│   335 │   │   def __call__(self, *args, **kwargs):                                                                                │
│ ❱ 336 │   │   │   raise PyperclipException(EXCEPT_MSG)                                                                            │
│   337 │   │                                                                                                                       │
│   338 │   │   if PY2:                                                                                                             │
│   339 │   │   │   def __nonzero__(self):                                                                                          │
│                                                                                                                                   │
│ ╭────────────────────────────────────────────── locals ───────────────────────────────────────────────╮                           │
│ │   args = ('resource "aws_volume_attachment" "XXX" {\n    device_name = XXX'+122,) │                           │
│ │ kwargs = {}                                                                                         │                           │
│ │   self = <pyperclip.init_no_clipboard.<locals>.ClipboardUnavailable object at 0x7f26f5f40cd0>       │                           │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯                           │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
PyperclipException:
    Pyperclip could not find a copy/paste mechanism for your system.
    For more information, please visit https://pyperclip.readthedocs.io/en/latest/index.html#not-implemented-error

For questions and suggestions, please visit https://github.com/idoavrah/terraform-tui/discussions
For issues and bugs, please visit https://github.com/idoavrah/terraform-tui/issues

Can you help me ?

idoavrah commented 4 months ago

From the pyperclip docs, regarding Linux support:

On Linux, this module makes use of the xclip or xsel commands, which should come with the os. Otherwise run “sudo apt-get install xclip” or “sudo apt-get install xsel” (Note: xsel does not always seem to work.)

I suggest you try installing either xclip or xsel. Please let me know if it worked.

I'll fix the application crash in a future release. Thanks!

BenjaminMinguy commented 4 months ago

I already installed xclip (and xsel too) but it is not working. I would like to copy some informations ( for terraform input for exemple) and copy or right click in windows does not working.

But it is a good tools, thanks very much.

Thanks for your feedback

idoavrah commented 4 months ago

Can you elaborate on your setup? Is it a Linux box? Some kind of a remote shell?

BenjaminMinguy commented 4 months ago

Yes, i am on linux ubuntu 20.04, shell bash, it is a virtual machine.

idoavrah commented 4 months ago

Sadly, it turns out it's not feasible. See https://stackoverflow.com/questions/51662213/cant-get-pyperclip-to-use-copy-and-paste-modules-on-python3

I managed to duplicate the issue, running TFTUI on my raspberrypi. Same issue :/

BenjaminMinguy commented 4 months ago

hum, ok, then i should upgrade my workstation... :'(

However, would it be possible to allow selection with the cursor to copy and paste a selection in a future version?

idoavrah commented 4 months ago

You can select parts of the text while holding a modifier key (depends on the terminal type and o/s):

Selecting multiple lines can introduce some extra characters. I'll consider adding a "full screen" toggle the help with this issue. Hope this helps.

BenjaminMinguy commented 4 months ago

Yeah it's Work, thanks very much

idoavrah commented 4 months ago

Fixed in v0.12.6