Solution to SublimeText Chinese Input problems in Ubuntu

Source: Internet
Author: User
I selected the Pyhton encoding tool and thought that the SublimeText tool is simple and easy to use. The Vim configuration is too complicated. I gave up after a day, and there was a problem with the SublimeText Chinese input, therefore, write a C file and send the text to SublimeText ~~ (It seems like this. I am also a cainiao. I am not very familiar with the role of this C file. If I am wrong, I can explain this article to me --), the following describes the installation method. The problem with Chinese input is

I selected the Pyhton encoding tool and thought that the Sublime Text tool is simple and easy to use. The Vim configuration is too complicated and I gave up after a day, sublimeText has a problem in Chinese Input. Therefore, you need to write a C program to send the Text to Sublime Text ~~ (It seems like this. I am also a cainiao. I am not very familiar with the role of this C file. If I am wrong, I can explain this article to me --), the following describes the installation method.
 

The question of Chinese input is reference in this article: http://www.linuxidc.com/Linux/2014-06/103855.htm

Ubuntu 12.10 install and crack Sublime Text 2Http://www.linuxidc.com/Linux/2013-07/86898.htm

Ubuntu 13.04 install Sublime Text 2 http://www.linuxidc.com/Linux/2013-05/84228.htm

Code artifact-Sublime Text package management tools and extensions Daquan http://www.linuxidc.com/Linux/2013-10/91701.htm

How to Develop Sublime Text 2 plug-in http://www.linuxidc.com/Linux/2013-09/90046.htm

Install and crack Sublime Text 2 editor http://www.linuxidc.com/Linux/2013-08/89452.htm in Windows Mac Linux

Text Editor Sublime Text experience http://www.linuxidc.com/Linux/2013-08/89326.htm

I directly compressed files on the Sublime Text official website. After decompression, the SublimeText2 program in the folder can be directly run, but Chinese characters cannot be entered at this time.
 
First, we need to compile the C file, so we need to download the corresponding C toolkit and enter the following command in shell:
 
1sudoapt-get installbuild-essential2sudoapt-get installlibgtk2.0-dev
 
Then save the following code as a sublime-imfix.c File
 
# Include # Include
Typedef GdkSegment GdkRegionBox;
Struct _ GdkRegion
{
Long size;
Long numRects;
GdkRegionBox * rects;
GdkRegionBox extents;
};
GtkIMContext * local_context;
Voidgdk_region_get_clipbox (const GdkRegion * 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;
If (rectangle-> width = 2 & GTK_IS_IM_CONTEXT (local_context )){
Gtk_im_context_set_cursor_location (local_context, rectangle );
}
}

Static GdkFilterReturn 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 );
}
Return GDK_FILTER_CONTINUE;
}
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 );
If (! GDK_IS_WINDOW (window ))
Return;
G_object_set_data (G_OBJECT (context), "window", window );
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 );
Local_context = context;
}
Gdk_window_add_filter (window, event_filter, context );
}
 
 
Then run the cd command to enter the place where you store the C file and run the following command to compile the file (this command should be run at one time)
 

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

 
If there is no major problem after running, you will find. so file, use the mv command to move the file to the SublimeText directory, and then use shell to enter the SublimeText directory. Then run the following script to open SublimeText and enter Chinese. (Put my SublimeText under the APP folder in the Home directory. here you need to change it to your own path)
 

SUBLIME_HOME = "$ HOME/APP/SublimeText2"
LD_LIB = "$ SUBLIME_HOME/libsublime-imfix.so"
Sh-c "LD_PRELOAD = $ LD_LIB $ SUBLIME_HOME/sublime_text $ @"


Of course, you can also change the Exce path of the SublimeText desktop file to the path of the script file, and then start the software through the starter.

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2014-06/103858.htm

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.