首先要安裝C++编译环境,有的话跳过
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); }
将sublime-imfix.c编译成共享库libsublime-imfix.so
gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
将libsublime-imfix.so拷贝到sublime_text所在文件夹
sudo mv libsublime-imfix.so /opt/sublime_text/
将/usr/bin/subl的内容修改为
#!/bin/sh
LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text "$@"
并将/usr/share/applications/sublime_text.desktop文件中的所有
Exec=/opt/sublime_text/sublime_text
字段改为
Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text
至此,就可以在Sublime中输入中文了
-
« 上一篇:
ESXi挂载物理硬盘到虚拟机,手动硬盘直通
-
ESXi安装APC网络关机工具PCNS实现停电安全关机
:下一篇 »