Skip to content

feat: sync internal clipboard with system#9

Open
druxorey wants to merge 1 commit into
maaslalani:mainfrom
druxorey:main
Open

feat: sync internal clipboard with system#9
druxorey wants to merge 1 commit into
maaslalani:mainfrom
druxorey:main

Conversation

@druxorey

@druxorey druxorey commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

This pull request resolves #7, integrating the system clipboard, allowing yanked (copied) and deleted cell content to be available outside the application. The main changes include importing the github.com/atotto/clipboard package, serializing clipboard data to a tab-separated string, and writing it to the system clipboard during yank and delete operations.

System Clipboard Integration:

  • Added github.com/atotto/clipboard as a dependency in go.mod to enable cross-platform clipboard access.
  • Imported the clipboard package as sysclip in internal/sheets/clipboard.go.
  • Implemented the String() method for the clipboard type to serialize clipboard contents as tab-separated values, with rows separated by newlines.
  • Updated storeYankClipboard and storeDeleteClipboard methods to write the serialized clipboard data to the system clipboard after yanking or deleting cells.

- Implement String method for clipboard to format cells
- Add github.com/atotto/clipboard dependency
- Automatically write yanked or deleted cells to system clipboard
@maaslalani

Copy link
Copy Markdown
Owner

Hey! Thank you so much for the contribution. I wouldn't feel comfortable erasing the contents of the clipboard automatically. We should add a separate keybinding to copy to the system clipboard ("y+) for example.

@druxorey

druxorey commented Apr 4, 2026

Copy link
Copy Markdown
Contributor Author

Honestly, it seemed the most natural way to me; that's how I have it configured in my nvim config. But if you think this is better, that's perfect for me. I'll fix it in in a while and upload a new commit.

@druxorey

druxorey commented Apr 4, 2026

Copy link
Copy Markdown
Contributor Author

@maaslalani I was implementing the y+ feature but I ran into a problem that I'm not sure how you'd prefer to solve. In normal mode, when I press the y key, It waits for another key to be pressed before deciding what to do, so adding this functionality is trivial. The problem arises with visual mode, because just like in Vim, pressing the y key doesn't wait for anything and simply yanks it. Therefore, the three solutions I'm considering are the following:

  1. I implement the same waiting that occurs in normal mode.

  2. Some other shortcut is used, as it is not a feature that does not have a default shortcut in vim.

  3. The functionality is left as I had originally intended. Honestly, I don't think there's a problem; after all, if you look at all the sheets applications, they all copy directly to the system clipboard.

I would like to know your opinion on this before proceeding with the implementation.

@druxorey
druxorey deleted the branch maaslalani:main April 7, 2026 21:48
@druxorey druxorey closed this Apr 7, 2026
@druxorey
druxorey deleted the main branch April 7, 2026 21:48
@druxorey
druxorey restored the main branch April 7, 2026 21:49
@druxorey druxorey reopened this Apr 7, 2026
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

Successfully merging this pull request may close these issues.

Copy to system clipboard ?

2 participants