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

部分代码不存在,我应该如何找到他们 #104

Closed
GentlemanWally opened this issue Jul 21, 2020 · 4 comments
Closed

部分代码不存在,我应该如何找到他们 #104

GentlemanWally opened this issue Jul 21, 2020 · 4 comments

Comments

@GentlemanWally
Copy link

你好,
我发现有些代码在源码中并不存在,它们也并不是c++自带的函数,如果我想学习阅读源码,我应该如何去解决这个问题,找到这些代码呢?
比如说下面这些:
我并没有找到 ibus.h 和 ibnotify/notify.h 文件
image
我没有找到 kClearNone, kClearAuto, kClearManual, kClearMaxLength 是在哪个文件进行定义的
image

@lotem
Copy link
Member

lotem commented Jul 21, 2020

图一所示为引用其他Linux软件包提供的头文件。
https://github.com/rime/ibus-rime#installation 列出了本项目所依赖的软件包,包含libibuslibnotify

图二为 librime 的代码。您所列举的哪些枚举值是在图中的最后一行代码处定义的。

这种场合在问题中插入代码即可,不必截图。

@GentlemanWally
Copy link
Author

谢谢,但是我有个问题,就是rime_main.c中的ibus_main(),在什么地方进行定义的,它是其他软件中的函数吗?它在输入法中是负责执行输入的模块还是没有实际的意义啊?
`static void rime_with_ibus() {
ibus_init();
IBusBus *bus = ibus_bus_new();
g_object_ref_sink(bus);

if (!ibus_bus_is_connected(bus)) {
g_warning("not connected to ibus");
exit(0);
}

g_signal_connect(bus, "disconnected", G_CALLBACK(ibus_disconnect_cb), NULL);

IBusFactory *factory = ibus_factory_new(ibus_bus_get_connection(bus));
g_object_ref_sink(factory);

ibus_factory_add_engine(factory, "rime", IBUS_TYPE_RIME_ENGINE);
if (!ibus_bus_request_name(bus, "im.rime.Rime", 0)) {
g_error("error requesting bus name");
exit(1);
}

if (!notify_init("ibus-rime")) {
g_error("notify_init failed");
exit(1);
}

RIME_STRUCT(RimeTraits, ibus_rime_traits);
fill_traits(&ibus_rime_traits);
rime_api->setup(&ibus_rime_traits);

gboolean full_check = FALSE;
ibus_rime_start(full_check);
ibus_rime_load_settings();

ibus_main();

ibus_rime_stop();
unload_plugins();
notify_uninit();

g_object_unref(factory);
g_object_unref(bus);
}`

@GentlemanWally
Copy link
Author

我想要修改一下拼音串切分,音字转换这部分的代码,如果可以的话,您能告诉我一下哪些地方是我应该去重点学习了解的啊?

@shenlebantongying
Copy link

ibus_main() 的
搜索 https://github.com/ibus/ibus/search?q=ibus_main
声明和注释 https://github.com/ibus/ibus/blob/6b47e41d66497dd35752a89ea80e4bac55b64e45/src/ibusshare.c#L297
定义 https://github.com/ibus/ibus/blob/6b47e41d66497dd35752a89ea80e4bac55b64e45/src/ibusshare.h#L356
你点开肯定又要问什么是 g_main_loop_run(),那是 GTK 的东西。

大概的关系是 ibus 作为通用的输入法前端是用 GTK 那一系列的东西写的,而 rime 的核心东西都在 librime 里面。

而这个仓库 ibus-rime 是桥接上面两者的,所以的大部分文件都会 include 一些 Librime, libibus 还有 gtk 里面的文件。奇妙的是 gtk 有一个 gobject 让 c 语言也能用上面向对象,所以 ibus 的仓库和这里会有一堆用 gobject 的代码会比较麻烦。

你想改的东西大概在 https://github.com/rime/librime 里面。你不妨先不管具体内容,先试一下完整编译整个程序,然后安装到你的电脑上。

@lotem lotem closed this as completed Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants