Sublime can't input Chinese under Ubuntu? (Resolved)

Source: Internet
Author: User
Tags gtk sublime text

Install Sublime in Ubuntu but can't input Chinese?

This is not good.

What do we do?

Follow me!

1 Get sublime-imfix.c file

There are GitHub accounts that can be obtained from https://github.com/YoungZHU/sublime-imfix.git.

or copy the following code directly:

1 /*2 sublime-imfix.c3 Use the ld_preload to interpose some function to fix sublime Input method , support for Linux.4 by Cjacker Huang <jianzhong.huang at i-soft.com.cn>5 6 gcc-shared-o libsublime-imfix.so sublime_imfix.c ' pkg-config--libs--cflags gtk+-2.0 '-fPIC7 ld_preload=./libsublime-imfix.so Sublime_text8 */9#include <gtk/gtk.h>Ten#include <gdk/gdkx.h> One typedef gdksegment Gdkregionbox; A  - struct_gdkregion - { the   Longsize; -   Longnumrects; -Gdkregionbox *rects; - gdkregionbox extents; + }; -  +Gtkimcontext *Local_context; A  at void -Gdk_region_get_clipbox (ConstGdkregion *Region , -Gdkrectangle *rectangle) - { -G_return_if_fail (Region! =NULL); -G_return_if_fail (Rectangle! =NULL); in  -Rectangle->x = region->extents.x1; toRectangle->y = region->extents.y1; +Rectangle->width = region->extents.x2-region->extents.x1; -Rectangle->height = region->extents.y2-region->extents.y1; the Gdkrectangle rect; *Rect.x = rectangle->x; $Rect.y = rectangle->y;Panax NotoginsengRect.width =0; -Rect.height = rectangle->height; the   //The caret width is 2; +   //maybe sometimes we'll make a mistake, but for most of the time, it should is the caret. A   if(Rectangle->width = =2&&Gtk_is_im_context (Local_context)) { the gtk_im_context_set_cursor_location (local_context, rectangle); +   } - } $  $ //This was needed, for example, if you input something in file dialog and return to the edit area - //context would lost, so here we set it again. -  the StaticGdkfilterreturn Event_filter (gdkxevent *xevent, Gdkevent *Event, Gpointer Im_context) - {WuyiXEvent *xev = (XEvent *) xevent; the     if(Xev->type = = Keyrelease &&Gtk_is_im_context (Im_context)) { -Gdkwindow * win = G_object_get_data (G_object (Im_context),"window"); Wu        if(Gdk_is_window (Win)) - Gtk_im_context_set_client_window (Im_context, win); About     } $     returngdk_filter_continue; - } -  - voidGtk_im_context_set_client_window (Gtkimcontext *context, AGdkwindow *window) + { theGtkimcontextclass *Klass; - G_return_if_fail (Gtk_is_im_context (CONTEXT)); $Klass =Gtk_im_context_get_class (CONTEXT); the   if(klass->Set_client_window) theKlass->Set_client_window (context, window); the  the   if(!Gdk_is_window (WINDOW)) -     return; inG_object_set_data (G_object (context),"window", window); the   intwidth =gdk_window_get_width (window); the   intHeight =gdk_window_get_height (window); About   if(Width! =0&& Height! =0) { the gtk_im_context_focus_in (context); theLocal_context =context; the   } + gdk_window_add_filter (window, event_filter, context); -}

Note: assume that the sublime-imfix.c file is placed in the home (~) directory.

It does not matter which directory to put in, as long as the file is compiled later to find the directory on the line.

2 Installing dependent libraries

Under Terminal, enter the following command:

sudo Install build-essential libgtk2. 0-dev

3 compiling

Under Terminal, enter the following command to compile:

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

After compiling, the current directory has a library file named: libsublime-imfix.so .

Note: This command needs to be executed in the directory where sublime-imfix.c is located.

This example executes in the home (~) directory, as described in the first step.

4 Move the compiled library file to the sublime installation directory

Under Terminal, enter the following command:

mv libsublime-imfix.so $SUBLIME _home/

Note:

1) The command needs to be executed in the directory where the libsublime-imfix.so is located, in this case home (~)

1) $SUBLIME _home indicates the installation directory of the SUBLIME

2) either directly to the sublime installation directory or to the Lib directory ($SUBLIME _home/lib) that is placed in its installation directory. Note the directory as soon as you reference the file later

5 Start Sublime

Under Terminal, enter the following command to start sublime:

Ld_preload=./libsublime-imfix.so./sublime_text

Note: This command needs to be executed under the sublime installation directory.
Otherwise, you need to replace the two files in the command with an absolute path

Also, there is a GitHub account that can be viewed from https://github.com/YoungZHU/sublime-imfix.git.

If you need to create a shortcut, or lock it to the launcher (Ubuntu), as in the 5th step described above, you need to specify the library file.

To the author of Ubuntu as an example, lock it to the left of the launcher, there will be a sublime_text.desktop file, directory: ~/.local/share/applications/

The contents of the file are as follows:

1 [Desktop Entry]2encoding=utf-83version=1.04Type=Application5Name=sublime Text26icon=/home/young/software/sublime/icon/256x256/Sublime_text.png7Path=/home/young/software/Sublime8Exec=bash-c"Ld_preload=/home/young/software/sublime/lib/libsublime-imfix.so/home/young/software/sublime/sublime_text "9startupnotify=falseTenstartupwmclass=Sublime_text Oneonlyshowin=Unity; AX-unitygenerated=true

The main changes are on line 8th.

This way, you can also enter Chinese without starting sublime from the command line.

Sublime can't input Chinese under Ubuntu? (Resolved)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.