Sublime_text_2 cannot input Chinese solution under Ubuntu

Source: Internet
Author: User
Tags gtk sublime text

Reference: http://my.oschina.net/wugaoxing/blog/121281

Environment configuration: Ubuntu 14.10

1. Save the following code as SUBLIME_IMFIX.C file

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

2. Install the C + + compiler environment and GTK Libgtk2.0-dev

1 sudo Install build-essential2sudoinstall libgtk2. 0-dev

3. Compiling a shared internal library

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

4. Start Sublime Text 2

1 ld_preload=./libsublime-imfix.so./sublime_text

OK ~ can input Chinese ~

5. Add to Environment variables

Example: My Sublime is installed under ~/sublime_text_2/sublime_text

Add in. bashrc

1 alias sublime='ld_preload=~/sublime_text_2/libsublime-imfix.so ~/sublime_text_2/sublime_ Text'

You can enter sublime directly on the command line to start the sublime that can input Chinese ~

 

Sublime_text_2 cannot input Chinese solution under Ubuntu

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.