Skip to content

Commit

Permalink
fix: update copy-paste guide (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
tconbeer authored Feb 12, 2024
1 parent 4f7563d commit 48eab9d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/docs/bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ menuOrder: 200
- <Key>ctrl+v</Key>, <Key>ctrl+u</Key>, <Key>shift+insert</Key>, <Key>Right Click</Key> Paste selected text.
- <Key>ctrl+z</Key> Undo.
- <Key>ctrl+y</Key> Redo.
- <Key>ctrl+/</Key>, <Key>ctrl+\_</Key> Toggle comments on selected line(s).
<!-- prettier-ignore -->
- <Key>ctrl+/</Key>, <Key>ctrl+_</Key> Toggle comments on selected line(s).
- <Key>tab</Key> Insert spaces at cursor to move the cursor to the next tab stop, or indent the selected line(s) to the next tab stop.
- <Key>shift+tab</Key> Dedent the selected line(s) to the next tab stop.
- <Key>shift+delete</Key> Delete the current line.
Expand Down
10 changes: 4 additions & 6 deletions src/docs/troubleshooting/copying-and-pasting.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ menuOrder: 920
import Key from "$lib/components/key.svelte"
</script>

**Note: Currently copying and pasting is only supported by the query editor, not the other widgets.**

Harlequin's query editor supports cut, copy, and paste. However, this is more complex than it seems. If these features are not working for you, there could be a number of root causes. This section walks through how copy-paste works in Harlequin, and offers some solutions for common problems.
Harlequin's Query Editor, Data Catalog, and Results Viewer support cut and copy, and its Query Editor supports paste. However, this is more complex than it seems. If these features are not working for you, there could be a number of root causes. This section walks through how copy-paste works in Harlequin, and offers some solutions for common problems.

### Internal Copy and Paste

Harlequin's query editor implements its own internal clipboard, so copying and pasting within the query editor should always work. To test the internal clipboard, select text in the query editor and press <Key>ctrl+c</Key> to copy it. Paste it with <Key>ctrl+u</Key> (`u`, not `v` for this step!). If that doesn't work, Harlequin isn't receiving those key presses from your terminal. Please [open an issue](https://github.com/tconbeer/harlequin/issues).
Harlequin's Query Editor implements its own internal clipboard, so copying and pasting within the Query Editor should always work. To test the internal clipboard, select text in the Query Editor and press <Key>ctrl+c</Key> to copy it. Paste it with <Key>ctrl+u</Key> (`u`, not `v` for this step!). If that doesn't work, Harlequin isn't receiving those key presses from your terminal. Please [open an issue](https://github.com/tconbeer/harlequin/issues).

### Copying outside Harlequin, Pasting inside Harlequin

Expand All @@ -22,11 +20,11 @@ There are two mechanisms for Harlequin to receive clipboard data when you initia
1. Harlequin receives a key press that it interprets as a paste command. This happens when you press <Key>ctrl+u</Key>, and depending on your terminal, may or may not happen when you press <Key>ctrl+v</Key>. When Harlequin interprets a key press as a paste command, it attempts to access the system clipboard and paste its contents. If it cannot access the system clipboard, Harlequin will paste the contents of its internal clipboard. To determine if Harlequin can access the system clipboard:

- Copy some text outside of Harlequin.
- Focus on the Harlequin query editor, then press <Key>ctrl+u</Key> (`u`, not `v` for this step!).
- Focus on the Harlequin Query Editor, then press <Key>ctrl+u</Key> (`u`, not `v` for this step!).
- If Harlequin does not paste anything, or if it pastes something different from what you just copied, Harlequin cannot access the system clipboard. You can work around this by pasting using your terminal's built-in paste functionality, or by fixing its access to the system clipboard (keep reading).
- Starting in Harlequin v1.1, you should see a notification pop-up if Harlequin cannot access your system clipboard.

2. Harlequin receives a native `Paste` message from the terminal. To trigger a `Paste` message, you want to use the same keys that you would to paste into your shell. This might be <Key>ctrl+v</Key>, <Key>shift+insert</Key>, or a right click of your mouse. When Harlequin receives a `Paste` message, it will insert the contents of that message into the query editor. Since this doesn't rely on the clipboard, this should work on nearly any terminal, whether Harlequin and the terminal share a host or not. Many terminals allow you to configure the key or mouse bindings for `Paste`.
2. Harlequin receives a native `Paste` message from the terminal. To trigger a `Paste` message, you want to use the same keys that you would to paste into your shell. This might be <Key>ctrl+v</Key>, <Key>shift+insert</Key>, or a right click of your mouse. When Harlequin receives a `Paste` message, it will insert the contents of that message into the Query Editor. Since this doesn't rely on the clipboard, this should work on nearly any terminal, whether Harlequin and the terminal share a host or not. Many terminals allow you to configure the key or mouse bindings for `Paste`.

If Harlequin cannot access the system clipboard, there may be a couple of causes:

Expand Down
3 changes: 2 additions & 1 deletion src/docs/troubleshooting/key-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ Harlequin can only react to key presses that are sent to it from the Terminal it
If you don't want to [upgrade your terminal](terminal-recommendations), you can use the following aliases, which should be supported everywhere (if not, [open an issue](https://github.com/tconbeer/harlequin/issues)):

- Run query: use <Key>ctrl+j</Key>, not <Key>ctrl+enter</Key>.
- Comment line: use <Key>ctrl+\_</Key> (underscore), not <Key>ctrl+/</Key>.
<!-- prettier-ignore -->
- Comment line: use <Key>ctrl+_</Key> (underscore), not <Key>ctrl+/</Key>.
- On a Mac: For all bindings, use <Key>^ Control</Key>, not <Key>⌘ Command</Key>.

[See here](copying-and-pasting) for copy and paste.
Expand Down

0 comments on commit 48eab9d

Please sign in to comment.