Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-8 input doesn't work #65

Open
sternenseemann opened this issue Dec 21, 2024 · 2 comments
Open

UTF-8 input doesn't work #65

sternenseemann opened this issue Dec 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@sternenseemann
Copy link
Contributor

sternenseemann commented Dec 21, 2024

Describe the bug

ad treats all input as ASCII which doesn't match its buffers.

To Reproduce

Open ad, type or paste (via the terminal's clipboard functionality) non ASCII characters.
ad adds garbage to the buffer.

Possible Fixes

I wrote an unpolished and slightly incorrect fix for this (sternenseemann@375b30d) which fills an up to four byte buffer in try_read_char.

However, I think that try_read_char should be replaced since reading input char by char is quite slow (you can already observe that when pasting a large amount of text via the system/terminal clipboard). Instead, the TUI should probably read input in a buffered fashion. If the input handling code was to be rewritten in this fashion, implementing unicode input would be simpler, as a buffer for remaining bytes would already exist.

@sternenseemann sternenseemann added the bug Something isn't working label Dec 21, 2024
@sminez
Copy link
Owner

sminez commented Dec 21, 2024

Ah, yeah the assumption that all characters coming from stdin are a single byte is an oversight from when I first implemented utf8 support. That said, I'm confused as to how you are hitting this through pasting: how are you triggering this? Pasting should directly access the clipboard (currently through xclip though I'm aware that needs improving as per #61) which works fine, and middle clicks should be getting intercepted and handled internally by ad rather than triggering a paste.

Reading input buffered isn't something I'm looking to implement at the current time and I'd need to understand better what the benefits were: as I said, the behaviour of pasting for me doesn't exhibit this behaviour at all.

@sternenseemann
Copy link
Contributor Author

As I write, I'm not using the clipboard feature in this case. With an TUI editor users will do that occasionally. Besides, you can also just enter unicode characters directly via your keyboard.

when pasting a large amount of text via the system/terminal clipboard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants