cd/opt/sublime_text/
sudo vim sub-fcitx.c
New file sub-fcitx.c, recommended in the sublime text in the same directory, the following code to copy into, reference: http://jianghang.name/index.php/archives/11/
#include <gtk/gtk.h>#include<gdk/gdkx.h>typedef gdksegment Gdkregionbox;struct_gdkregion{Longsize; Longnumrects; Gdkregionbox*rects; Gdkregionbox extents;}; Gtkimcontext*Local_context;voidGdk_region_get_clipbox (ConstGdkregion *Region , Gdkrectangle*rectangle) {G_return_if_fail ( region!=NULL); G_return_if_fail (Rectangle!=NULL); Rectangle->x = region->extents.x1; Rectangle->y = region->extents.y1; Rectangle->width = region->extents.x2-region->extents.x1; Rectangle->height = region->extents.y2-region->extents.y1; Gdkrectangle rect; Rect.x= rectangle->x; Rect.y= rectangle->y; Rect.width=0; Rect.height= rectangle->height; //The caret width is 2; //maybe sometimes we'll make a mistake, but for most of the time, it should is the caret. if(Rectangle->width = =2&&Gtk_is_im_context (Local_context)) {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.StaticGdkfilterreturn Event_filter (gdkxevent *xevent, Gdkevent *Event, Gpointer Im_context) {XEvent*xev = (XEvent *) xevent; if(Xev->type = = Keyrelease &&Gtk_is_im_context (Im_context)) {Gdkwindow*win = G_object_get_data (G_object (Im_context),"window"); if(Gdk_is_window (Win)) {Gtk_im_context_set_client_window (Im_context, Win); } } returngdk_filter_continue;}voidGtk_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); } if(!Gdk_is_window (WINDOW)) { return; } g_object_set_data (G_object (context),"window", window); intwidth =gdk_window_get_width (window); intHeight =gdk_window_get_height (window); if(Width! =0&& Height! =0) {gtk_im_context_focus_in (context); Local_context=context; } gdk_window_add_filter (window, event_filter, context);}
2. Install the compilation environment
sudo apt-get install build-essentialsudo apt-get install LIBGTK2. 0-dev
3. Switch to SUB-FCITX.C, directory, compile to generate so file
cd/opt/sublime_text/-shared-o libsublime-imfix.so sub-fcitx.c ' pkg-config--libs--cflags gtk+-2.0 '-fpic
Normally, there will be one more libsublime-imfix.so file in the directory.
Switch to the sublime text directory, LD_PRELOAD=./libsublime-imfix.so ./sublime_text
after the command to start sublime text, you will find that you can enter Chinese, but this is too much trouble, by adding their own startup script can simplify the process
4. Modify the command to start sublime directly in the terminal via SUBL.
sudo vim/usr/bin/subl
Add in the first line, there are many online icons, do not repeat.
Export ld_preload=/opt/sublime_text/libsublime-imfix.so
Solve the problem of using command line SUBL to open sublime text3 unable to input Chinese under Ubuntu