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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: seamless input of unicode chars #838

Open
eugenesvk opened this issue Mar 17, 2024 · 5 comments 路 Fixed by #840
Open

Feature request: seamless input of unicode chars #838

eugenesvk opened this issue Mar 17, 2024 · 5 comments 路 Fixed by #840
Labels
enhancement New feature or request

Comments

@eugenesvk
Copy link
Contributor

eugenesvk commented Mar 17, 2024

Is your feature request related to a problem? Please describe.

Currently to input unicode chars you have to pre-define an alias (defalias sml (unicode 馃榾)), which is rather unergonomic

This is also limited to a single char

Describe the solution you'd like.

Direct way to use unicode symbols without pre-definition, e.g.,

(deflayer qwert馃榾
q w e r t 馃敚馃榾)

instead of

(defalias  馃檨 (unicode 馃檨))
(deflayer qwert馃檨
q w e r t @馃檨)

馃敚 here is a reserved unicode symbol prefix that tells kanata to treat subsequent sequence as thought it were a unicode action

Also this 馃敚馃榾馃榾馃榾 should insert all 3 unicode chars. And should accept single chars that are composed of multiple code points like 馃げ馃徔

Describe alternatives you've considered.

Am only aware of the alias option

Additional context

No response

@eugenesvk eugenesvk added the enhancement New feature or request label Mar 17, 2024
@jtroo
Copy link
Owner

jtroo commented Mar 17, 2024

I believe it is backwards compatible to make the existing (unicode ...) / (馃敚 ...) action accept arbitrary characters, and seems like it would be good to reuse it for this use case. This means typing extra parens over the given example, but has the advantage of supporting spaces.

Though on the note of spaces, (馃敚 馃榾 馃榾 馃榾 馃榾) would place only a single space between every face since parsed lists don't know how many spaces were between each item. An alternative solution might then be (馃敚 "馃榾 馃榾 馃榾 馃榾").

@eugenesvk
Copy link
Contributor Author

eugenesvk commented Mar 17, 2024

Yes, quotes should be used to preserve spaces, that's like their main function :)!

And while extending the action is good I think the simplest case should still be simpler than (). I'm checking if something similar to if let Some(alias) = ac.strip_prefix('@') { can be added, so you just check for if let Some(unisym) = ac.strip_prefix('馃敚') { and then invoke the unicode action (and if you need spaces, then suffer the pain of () and "" delimiters ;)

(Btw, it seems that this char is considered a rust char, not a real one, so composed emojis error on this (馃敚 馃げ馃徔) , then extending unicode would also fix this)

@eugenesvk
Copy link
Contributor Author

By the way, what about inserting unicode text via clipboard (restoring the old clipboard values after) instead of typing char by char and having various app compatibility issues that require linux-unicode-u-code?

Or is this not "low-level" enough?

@jtroo jtroo reopened this Mar 17, 2024
@jtroo
Copy link
Owner

jtroo commented Mar 17, 2024

By the way, what about inserting unicode text via clipboard (restoring the old clipboard values after) instead of typing char by char and having various app compatibility issues that require linux-unicode-u-code?

Or is this not "low-level" enough?

The existing unicode mechanism for Linux already relies on the DE / application support of C-S-u [hex seq] to work, which I would not consider to be particularly low-level. I would be in favour of adding clipboard as an option for Linux unicode support if that works better - is that what other software does? E.g. espanso?

@eugenesvk
Copy link
Contributor Author

eugenesvk commented Mar 18, 2024

Espanso uses both and exposes it (and a few other settings) as user configurable option

It uses 2 backends: injection and clipboard, and says

  • injection is slow for longer strings
  • clipboard isn't instant so you could get previous pastes before the text copied by espanso is "set", so it adds a configurable delay

not sure what the other tradeoffs are

(https://espanso.org/docs/configuration/options/)

the mechanism used to perform the injection. Espanso can either inject text by simulating keypresses (Inject backend) or by using the clipboard (Clipboard backend). Both of them have pros and cons, so the Auto backend is used by default to automatically choose the most appropriate one based on the situation. If for whatever reason the Auto backend is not appropriate, you can change this option to override it.

but also to configure the threshold

clipboard_threshold | Number of chars after which a match is injected with the clipboard backend instead of the default one. This is done for efficiency reasons, as injecting a long match through separate events becomes slow for long strings. This is only relevant if the backend is set to聽Auto.

It even allows this to be set on a per app basis, which is very cool, but per the docs doesn't work on Wayland

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants