Ubuntu 系統 sublime3 中文輸入

轉載自  http://doc.polarwin.cn/tutorial/Ubuntu_sublime3_chinese_input.htmlhtml

-------------本文徹底複製的上面的文章--------------------web

Ubuntu安裝sublime3並解決中文輸入問題

1 安裝

首先添加源:vim

sudo add-apt-repository ppa:webupd8team/sublime-text-3

而後更新:sublime-text

sudo apt-get update

而後安裝:bash

sudo apt-get install sublime-text-installer

2 解決中文輸入問題

首先安裝必需的軟件包:app

sudo apt-get install build-essential libgtk2.0-dev

而後創建一個名爲sublime_imfix.c的c文件,內容以下:sublime-text-3

 #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);
}

而後進行編譯:字體

gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC

而後將libsublime-imfix.so拷貝到sublime_text所在文件夾:ui

sudo mv libsublime-imfix.so /opt/sublime_text/

修改/usr/bin/subl 文件:spa

sudo vim /usr/bin/subl

內容以下:

LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text "$@"

而後進入目錄/usr/share/applications/,修改文件sublime-text.desktop:

sudo vim /usr/share/applications/sublime-text.deskto

將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"

將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"

將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"

一樣的將/opt/sublime_text路徑下的sublime_text.desktop按照相同的方式修改。

3 等寬字體設置

Preferences菜單Settings-User: {

「font_face」: 「Courier New」, 「font_size」: 14.0

}

相關文章
相關標籤/搜索