很多朋友有跟我一樣的問題
那么問題應(yīng)該如何解決呢犹菱?
其實(shí)很簡單,我們一步一步來說:
1. 保存下面代碼到文件sublime_imfix.c
#include <gtk/gtkimcontext.h>
void gtk_im_context_set_client_window (GtkIMContext *context,
GdkWindow *window)
{
GtkIMContextClass *klass;
g_return_if_fail (GTK_IS_IM_CONTEXT (context));
klass = GTK_IM_CONTEXT_GET_CLASS (context);
if (klass->set_client_window)
klass->set_client_window (context, window);
g_object_set_data(G_OBJECT(context),"window",window);
if(!GDK_IS_WINDOW (window))
return;
int width = gdk_window_get_width(window);
int height = gdk_window_get_height(window);
if(width != 0 && height !=0)
gtk_im_context_focus_in(context);
}
2. 安裝sublime_imfix.c編譯環(huán)境和gtk libgtk2.0-dev
sudo apt-get install build-essential
sudo apt-get install libgtk2.0-dev
3. 在終端中將sublime_imfix.c編譯成共享庫
gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config--libs--cflagsgtk+-2.0` -fPIC
4.修改/usr/bin/subl里的文件為:
#!/bin/sh
export LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so
exec /opt/sublime_text/sublime_text "$@"
5.此時在終端中已經(jīng)能使用subl命令運(yùn)行并能輸入中文莽囤,但是隨便找到一個文檔祝辣,右鍵使用sublime-text打開,發(fā)現(xiàn)依然還是無法輸入中文智政,所以我們繼續(xù)下一步操作质涛。
6.修改 /usr/share/applications/sublime_text.desktop 為:
[Desktop Entry]
[...]
Exec=env LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so /opt/sublime_text/sublime_text %F
[...]
[Desktop Action Window]
[...]
Exec=env LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so /opt/sublime_text/sublime_text -n
[...]
[Desktop Action Document]
[...]
Exec=env LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so /opt/sublime_text/sublime_text --command new_file
[...]
PS:上述中的[…]為對代碼的省略稠歉,只需修改文件中exec語句,目的是在sublime-text運(yùn)行之前汇陆,加載修復(fù)驅(qū)動怒炸,之后再進(jìn)入程序;
到此完成了修復(fù)工作毡代,搜狗輸入法已經(jīng)可以在sublime-text3中使用了
聲明:樓主我使用的版本為:sublime-text 3.0 build 3143