3.2 解决sublime text3无法输入中文的问题

  • 安装C/C++的编译环境和gtk、libgtk2.0-dev
sudo apt-get install build-essential sudo apt-get install libgtk2.0-dev
  • 保存以下代码到文件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); }
  • 编译成共享库
gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
  • 拷贝到/opt/sublime_text目录下

注意:/opt/sublime_text/不同版本可能有所不同,请调整为自己安装版本的路径

sudo cp libsublime-imfix.so /opt/sublime_text/libsublime-imfix.so
  • 修改/usr/bin/subl文件,在第一行加入:
export LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so
  • 修改sublime-text.desktop

sudo vim /usr/share/applications/sublime_text.desktop

[Desktop Entry] Version=1.0 Type=Application Name=Sublime Text GenericName=Text Editor Comment=Sophisticated text editor for code, markup and prose Exec=/usr/bin/subl %F #这里修改执行路径为/usr/bin/subl,subl文件刚才已经修改过,大家应该记得 Terminal=false MimeType=text/plain; Icon=sublime-text Categories=TextEditor;Development; StartupNotify=true Actions=Window;Document; [Desktop Action Window] Name=New Window Exec=/usr/bin/subl -n #这里修改执行路径为/usr/bin/subl,subl文件刚才已经修改过,大家应该记得 OnlyShowIn=Unity; [Desktop Action Document] Name=New File Exec=/usr/bin/subl new_file #这里修改执行路径为/usr/bin/subl,subl文件刚才已经修改过,大家应该记得 OnlyShowIn=Unity;

修改以上三处代码,保存。Sublime Text 3即可完全正常使用搜狗输入法输入中文

解决sublime text3无法输入中文的问题
标签: