以前就載ubuntu14.0.04上安裝了sublime,在學習python的時候,基本不怎麼使用中文,因此就沒有解決它沒法進行中文輸入的問題,今天心血來潮,想解決一下這個問題,也是爲之後少點麻煩,下面我列出我解決的過程與步驟:html
#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); }
cd ~ gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
若是若是「NO package 'gek+-2.0' found」,解決辦法就是下面這個命令,安裝這個包:python
sudo apt-get install libgtk2.0-dev
sudo mv libsublime-imfix.so /opt/sublime_text/
sudo gedit /usr/bin/subl 將 #!/bin/sh exec /opt/sublime_text/sublime_text "$@" 修改成 #!/bin/sh LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text "$@"
sudo gedit /usr/share/applications/sublime_text.desktop 將[Desktop Entry]中的字符串 Exec=/opt/sublime_text/sublime_text %F 修改成 Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text %F" 將[Desktop Action Window]中的字符串 Exec=/opt/sublime_text/sublime_text -n 修改成 Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text -n" 將[Desktop Action Document]中的字符串 Exec=/opt/sublime_text/sublime_text --command new_file 修改成 Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text --command new_file"
參考資料:ubuntu
【1】http://jingyan.baidu.com/article/f3ad7d0ff8731609c3345b3b.htmlbash
【2】http://louisrb.blog.163.com/blog/static/75680129200992641228460/app