保存下面的代码到文件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);

}
Ubuntu下Sublime Text 3解决无法输入中文的方法

将上一步的代码编译成共享库libsublime-imfix.so,命令

cd ~

gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC
Ubuntu下Sublime Text 3解决无法输入中文的方法

然后将libsublime-imfix.so拷贝到sublime_text所在文件夹

sudo mv libsublime-imfix.so /opt/sublime_text/
Ubuntu下Sublime Text 3解决无法输入中文的方法

修改文件/usr/bin/subl的内容

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 "$@"

此时,在命令中执行 subl 将可以使用搜狗for linux的中文输入
Ubuntu下Sublime Text 3解决无法输入中文的方法

为了使用鼠标右键打开文件时能够使用中文输入,还需要修改文件sublime_text.desktop的内容。

命令

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"

注意:

修改时请注意双引号"",否则会导致不能打开带有空格文件名的文件。

此处仅修改了/usr/share/applications/sublime-text.desktop,但可以正常使用了。

opt/sublime_text/目录下的sublime-text.desktop可以修改,也可不修改。
Ubuntu下Sublime Text 3解决无法输入中文的方法

ubunutu_install_sublime_china的更多相关文章

随机推荐

  1. hibernate 连接数据库时报错

         错误信息 : com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allo ...

  2. App Extension编程指南(iOS8/OS X v10.10)中文版

    http://www.cocoachina.com/ios/20141023/10027.html 当iOS 8.0和OS X v10.10发布后,一个全新的概念出现在我们眼前,那就是应用扩展.顾名思 ...

  3. 【JDBC】百万数据插入

    使用JDBC连接数据库时,如果插入的数据量大,一条一条地插入数据会变得非常缓慢.此时,我们需要用到预处理. 查阅Java开发文档,我们可以看到: 接口 PreparedStatement 表示预编译的 ...

  4. SQLite内存数据库

    [转]SQLite内存数据库 http://www.cnblogs.com/liuyong/archive/2010/09/14/1826152.html SQLite 介绍 一. SQLite 是实 ...

  5. spark结合 Openfire服务器,发送聊天消息

    1.下载OpenFire服务器,进行安装,参考http://www.cnblogs.com/hoojo/archive/2012/05/17/2506769.html 2.程序运行客户端:下载客户端代 ...

  6. 行内onclick使用遇坑--------作用域与传入字符串

    问题一:行内onclick触发的函数放在$(funtion(){})内报错,错误代码如下: <input type="button" value="确定" ...

  7. nrpe 在ubuntu上安装遇到的问题

    Nagios Linux客户端需要安装NRPE进行数据收集,如果在Ubuntu系统下安装过程中遇到下面的错误提示:checking for SSL libraries... configure: er ...

  8. 图像切割之(五)活动轮廓模型之Snake模型简单介绍

    图像切割之(五)活动轮廓模型之Snake模型简单介绍 zouxy09@qq.com http://blog.csdn.net/zouxy09 在"图像切割之(一)概述"中咱们简单了 ...

  9. Codeforces Round #331 (Div. 2)C. Wilbur and Points 贪心

    C. Wilbur and Points Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/ ...

  10. Codeforces Round #327 (Div. 2) B. Rebranding 水题

    B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...