- sublime的安装
- sudo add-apt-repository ppa:webupd8team/sublime-text-3
- sudo apt-get update
- sudo apt-get install sublime-text
-
翻译支持中文输入法的动态库
-
touch sublime_imfix.c
-
写入代码
include
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); }
-
- 安装相关的环境gtk libgtk2.0-dev
- sudo apt-get install build-essential
- sudo apt-get install build-essential
- 编译动态库
- gcc -shared -o libsublime-imfix.so sublime_imfix.c
pkg-config --libs --cflags gtk+-2.0
-fPIC
- gcc -shared -o libsublime-imfix.so sublime_imfix.c
- 测试运行
- 要把/opt/sublime_text为环境变量中才能运行下一条命令中的sublime_text
- LD_PRELOAD=./libsublime-imfix.so sublime_text
- 拷贝文件到/opt/sublime_text目录下
- sudo cp libsublime-imfix.so /opt/sublime_text/libsublime-imfix.so
- 打开终端修改/usr/bin/sublime
- sudo vim /usr/bin/sublime
- export LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so
-
修改sublime-text.desktop
-
sudo vim /usr/share/applications/sublime_text.desktop
[Desktop Entry] Version=1.0 Type=Application Name=Sublime Text GenericName=Text Editor Comment=Sophisticated text editor for code, markup and prose Exec=/usr/bin/subl %F #这里修改执行路径为/usr/bin/subl,subl文件刚才已经修改过,大家应该记得 Terminal=false MimeType=text/plain;
Icon=sublime-text Categories=TextEditor;Development; StartupNotify=true Actions=Window;Document;[Desktop Action Window] Name=New Window Exec=/usr/bin/subl -n #这里修改执行路径为/usr/bin/subl,subl文件刚才已经修改过,大家应该记得 OnlyShowIn=Unity; [Desktop Action Document] Name=New File Exec=/usr/bin/subl new_file #这里修改执行路径为/usr/bin/subl,subl文件刚才已经修改过,大家应该记得 OnlyShowIn=Unity;
-
- 命令
- sublime 则/opt/sublime_text/的 sublime_text可执行文件
- subl 则执行的是/usr/bin/subl可执行文件
- 可参考:http://my.oschina.net/daleyjh/blog/151457
-
ubuntu下安装sublime并解决无法输入中文的问题
最新推荐文章于 2021-08-25 20:47:22 发布