Skip to content

想要给这个程序增加输入法功能有没有可能? #518

Answered by wengxt
wastee asked this question in Q&A
Discussion options

You must be logged in to vote

GDK 是 GTK 底层的只和图形绘制有关系的 API,GTK 是用 GDK 实现的,输入法的实现都在 gtk 的 wdiget 里

我大概读了一下 swell 的代码,看起来是用 gdk 的来模拟 win32 的部分,假定你能替换里面的 libSwell 成为你的版本
那么你需要做的就是
1、给 libswell 开启 Gtk 支持,主要指 SWELL_SUPPORT_GTK=1
2、创建一个 GtkIMContext 对象 https://developer-old.gnome.org/gtk3/stable/GtkIMContext.html
3、和 GtkIMContext 对象交互(例如把按键交给它处理 https://developer-old.gnome.org/gtk3/stable/GtkIMContext.html#gtk-im-context-filter-keypress 处理程序的焦点),并且把对应事件(例如 https://developer-old.gnome.org/gtk3/stable/GtkIMContext.html#GtkIMContext-commit )翻译成对应的 Windows 的输入法事件 https://docs.microsoft.com/en-us/windows/win32/intl/wm-ime-char

和 sublime 的情况完全不象,sublime 的控件和窗口都是 Gtk 的,只是在具体和输入法相关的 API 上有一些小问题,缺少一些调用

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wastee
Comment options

Answer selected by wastee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants