nadrad / h-m-m

Hackers Mind Map
GNU General Public License v3.0
1.89k stars 53 forks source link

Pasting support for the editor #10

Closed arisolt closed 2 years ago

arisolt commented 2 years ago

Not sure if this is isolated to my machine. I am unable to Paste from the clipboard when editing a node. Is this normal?

I'm on Mojave 10.14.6 for what it's worth.

nadrad commented 2 years ago

Can you send me the output of the following command?

php -r 'echo PHP_OS_FAMILY;'

arisolt commented 2 years ago

That would be Darwin

nadrad commented 2 years ago

When it's 'Darwin', it tries to use pbcopy and pbpaste to work with the clipboard.

Can you check copying and pasting separately and let me know which one has a problem? i.e., copy something from another application and check to see if you can paste it in h-m-m, and then copy something from h-m-m and see if you can paste it in another application.

Also, maybe you can check if running pbpaste in the terminal echos the content you have in your clipboard.

arisolt commented 2 years ago

pbpaste work correctly in the terminal. copying from h-m-m into another application also works correctly. copying text from another application, then using command P in h-m-m correctly pastes the content as a new node. only when activating edit mode for a node using command e, it won't insert the clipboard text when pasting it (either using cmd+v, or right-click -> paste)

nadrad commented 2 years ago

Oh, I see... I never included that in the editing feature :) I'll add it in the future.

nadrad commented 2 years ago

I've renamed the title to be clearer to me later on.

arisolt commented 2 years ago

that would be a very useful feature imo :)

nadrad commented 2 years ago

Done (ctrl+v)

arisolt commented 2 years ago

something funky is going on. copy-pasting the below text (or any other text) results in this behaviour.

Many users simply launch a new shell or open a new terminal window, but there is no need to do that, there’s a way to directly refresh the profile in use thanks to the source command.

image

nadrad commented 2 years ago

Can you make sure you're using the latest version? The last few commits solved a few issued related to multi-byte characters in the editor.

If you still had the problem, please save the file and upload it here because when you paste the text as you've done before, github may clean up some of the control characters (that may be why I don't see a problem when I paste it in my machine).

arisolt commented 2 years ago

just cloned the repo again. for what it's worth, i get the issue also when i copy from the github post. test.txt

nadrad commented 2 years ago

There are a few "delete" characters inside your file, and that's causing the problem. The fact that you have problems when copying text from the comment above when I don't is that either my system is automatically removing the control characters or your system is adding them for some reason.

Regardless, I've added something to remove all control characters from the text read from the file, clipboard, and direct entry. I think it should be fine for you now... let me know.

jonas-w commented 2 years ago

The normal way of pasting in my terminal (alacritty on archlinux), or in most of the other terminals, is to press Ctrl+Shift+V and when i paste the normal way it also makes some funny stuff.

But your keybinding with Ctrl+V works perfectly.

nadrad commented 2 years ago

It's funny... when the user presses ctrl+shift+v, the application doesn't receive the ctrl+shift+v sequence, but receives the actual content! Because I didn't expect to receive such a long input, it was split in multiple loops, and because each loop expected one character, the cursor wasn't moving enough and the next round... you get it.

Anyway, it's covered now, and ctrl+shift+v should work fine in the editor.

jonas-w commented 2 years ago

Seems to work fine, thanks! (At least on linux, idk about Mac)

arisolt commented 2 years ago

confirmed pasting now works on mac too. good stuff :)

nadrad commented 2 years ago

Finally! Dealing with those control characters was a little tricky. We forget about those things when working with high-level programs.