fcitx / fcitx5-lua

25 stars 7 forks source link

Demo input method #12

Open Ferada opened 3 years ago

Ferada commented 3 years ago

I'm interested in using this, but it was a little bit difficult to find any information on how to. Would it be possible to add a simple demo input method that shows how to use this API, including how to make sure it gets loaded from the user configuration?

Also, there's also a Lua module for fcitx 4, but that doesn't seem have the same API available yet, so it's not possible to add a full input method via Lua in 4, is that correct?

wengxt commented 3 years ago

Right now it's not possible to implement input method with this because of missing API (mainly because there's no such requirements).

But if you have such requirement I can add one.

Can you provide more information about what do you want to implement?

Ferada commented 3 years ago

I was considering Lua just to speed things up for development, I'm looking into presage integration for one.

Other specific ideas were basically turning Quick Phrase into a "postfix" IME, so typing the abbreviation first, then selecting the possible expansion, similar to how Vim's abbreviations work.

wengxt commented 3 years ago

As for presage, you'd better for extending https://github.com/fcitx/fcitx5/tree/master/src/modules/spell instead, so it can benefit everything that using it in general. In fcitx 4 we used to have presage support in its spell module but I have a feeling that it is not actively maintained any more so I didn't port it to fcitx 5.

As for the second one, if it's generally useful, you'd better look into to see if it's a better place to implement it. https://github.com/fcitx/fcitx5/tree/master/src/im/keyboard.

Adding a new engine that have duplicate functionality is not really a thing we'd like to see.

quickphrase itself is extendable with fcitx5-lua. Here's an example for it: https://fcitx.github.io/fcitx5-lua/modules/fcitx.html

https://github.com/fcitx/fcitx5-chinese-addons/blob/master/im/pinyin/pinyin.lua

Ferada commented 3 years ago

That's very helpful information, thank you.

Adding a new engine that have duplicate functionality is not really a thing we'd like to see.

I can imagine. Let me ask this then: Can you see any way where the quickphrase functionality could be triggered later, that is, after already writing the corresponding phrase? To me that's mostly a question of ergonomics, e.g. the way the pinyin input works is just a much better approach and I'd like to have the same for quickphrase. The way I understood it so far this would require keeping part of the current text in the IME and only releasing it to the application if it's clear that no replacement was selected?

wengxt commented 3 years ago

I realize you probably aren't aware that fcitx's keyboard engine also provides a predication mode? Just press Ctrl + Alt + H to enable it.

Right now it has both spell checking and emoji in the completion result.

Here's a screen shot for it from fcitx's wiki keyboard engine from fcitx 4

Is that the thing you want to implement?

The underlined text is just a place holder that input method asked application to display (usually refered as "Preedit").

When I'm talking about duplication, I just try to say certain feature should be done without implementation a whole new engine to do so. Sometimes it might be better to implement it as a special mode within certain engine.

Ferada commented 3 years ago

Makes sense, I'll see if I can make some modifications for myself to that part instead then. Thanks for the information, much appreciated.

wengxt commented 3 years ago

Feel free to join telegram https://fcitx-im.org/telegram/captcha.html / irc fcitx@freenode for discussion

wengxt commented 3 years ago

Still, adding support for lua based input method is also a desired feature. Keep this open for tracking that.