sublime中文解决

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文件。

      命令行输入(在sublime_imfix.c文件目录下编译)gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
如果报错如果出现如下的错误:fatal error: gtk/gtkimcontext.h: 没有那个文件或目录
需要在命令行输入apt-get install libgtk2.0-dev然后再继续编译,之后会在该目录生成一个文件libsublime-imfix.so

 

3.将libsublime-imfix.so文件复制到sublime_text所在文件夹

命令:mv libsublime-imfix.so /opt/sublime_text

 

4.接着,修改文件/usr/bin/subl的内容:


vim /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 “$@”

 

5.修改sublime_text.desktop文件

vim /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”

 

6.将文件克隆到本地git clone https://github.com/lyfeyaj/sublime-text-imfix.git

 

7.运行脚本 :cd sublime-text-imfix && ./sublime-imfix

posted @ 2018-03-29 10:29  夏诗  阅读(497)  评论(0编辑  收藏  举报