orbitalquark / textadept

Textadept is a fast, minimalist, and remarkably extensible cross-platform text editor for programmers.
https://orbitalquark.github.io/textadept
MIT License
636 stars 38 forks source link

Feature Request: Emacs like TeX Input Method #426

Closed humphreylee closed 1 year ago

humphreylee commented 1 year ago

Would you consider feature request for Emacs like TeX input method for symbol and emoji? For example (e.g. in Juno), special character/ symbol, e.g. beta (β) could be entered into the editor with "\beta", followed by "tab" key. Similarly, an example of emoji "\:smile" turned into 😄. Is this do able in textadept for all supported platforms? Thanks.

rgieseke commented 1 year ago

In your init.lua:

snippets.smile = '🙂'
snippets['beta'] = 'β'

There is probably a way to also have a slash or colon in the shortcode but this would be the starting point (I haven't checked how to escape or if it's possible). I also have thought about making a little module which let's you select an emoji from a list with some fuzzy search.

https://orbitalquark.github.io/textadept/api.html#textadept.snippets

rgieseke commented 1 year ago

Note that emojis might not work on all platforms due to the used font. I use the GTK version on Linux because it had better emoji support.

humphreylee commented 1 year ago

Thanks for the tips. "Beta" and 😃 are just examples. Is it possible to have a universal plan for cover most of users' need, similar of how Emacs does it?

rgieseke commented 1 year ago

Sure, you'd loop over a table of mappings with your short keys and symbols. I don't think this would be part of core Textadept but rather would have to be in an external module.

orbitalquark commented 1 year ago

Robert is correct. You'd add this functionality yourself, either via a module, or in your ~/.textadept/init.lua. Tab-completion is tied to snippets, so you would create a map of snippet triggers to emoji. I would not want to maintain such a map in core Textadept. There's also the matter of fonts and encodings. 'β' can be either one byte in certain extended ASCII encodings, or multiple bytes in UTF-8. Keeping encoding-specific maps would be even more difficult.

humphreylee commented 1 year ago

Thanks for your consideration🙏. Closing the issue.