sublime在linux下无法输入中文好像是通病,但是解决方法貌似都一样的
- 保存下面的代码在任意目录,命名为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);}
- 将代码编译为共享库 libsublime-imfix.so,注意是在有sublime_imfix.c文件的目录下
gcc -shared -o libsublime-imfix.so sublime_imfix.c
`pkg-config --libs --cflags gtk+-2.0` -fPIC
- 下一步将libsublime-imfix.so文件放在某个文件夹下,并打开sublime的启动脚本(/usr/bin/subl),加上下面这句
#注意替换路径为你的libsublime-imfix.so文件路径,这句话加在 exec 前
LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so
参考:http://jingyan.baidu.com/article/f3ad7d0ff8731609c3345b3b.html