0

I am creating a plugin for sublime 4 on Ubuntu 22.04. The plugin uses pyclip (https://pypi.org/project/pyclip/) to copy text from the "clipboard" and perform certain formatting functions on the text before inserting it into the current views edit buffer.

Note: For this to work on Ubuntu you need to have xclip or xsel installed. I am using xclip

The standard use case is:

  1. The user copies a block of text from a webpage in a browser
  2. In sublime, the user runs the appropriate command that calls the plugin.
  3. The plugin calls the pyclip function to get the copied text: copied_text = pyclip.paste(text=True)
  4. The plugin performs some formatting on the text
  5. The plugin pastes the results into the current sublime window at the current cursor position.

This works great whenever the source program is a browser, another text editor, a spreadsheet, etc. HOWEVER, if the source of the text copied to the memory buffer in the cut-and-paste operation is sublime, then the function being called in the plugin to get the text, pyclip.paste(text=True), never returns and the only way to proceed is to restart sublime.

If anyone has any ideas what the issue may be it would be greatly appreciated!

I have dried this with pyperclip instead of pyclip, and with xsel instead of xclip. The problem is exactly the same. If the source program for the copy and paste operation is sublime, then sublime freezes. I have also tried this on ubuntu 20.04 and have the same results.

3
  • 1
    have you considered just using Sublime's API to get the clipboard text instead of a Python package? sublimetext.com/docs/… Commented Oct 12, 2023 at 20:02
  • As @KeithHall mentions, I was also going to ask what this library offers that is not already possible with the API. Do you need to try and grab non-text data or something? Commented Oct 13, 2023 at 2:43
  • Thank you for the suggestion. The sublime api function works great. Commented Oct 19, 2023 at 21:38

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.