Sublime text 2 for Linux Chinese Input method cannot be used workaround

Source: Internet
Author: User
Tags gtk sublime text

Sublime Text 2 Linux version has not solved the problem of Chinese input.
At present, there are three kinds of Chinese input schemes, namely:
Scenario One: Using a small input method
The new version of the small input method has supported the sublime Text input Chinese
About the installation and introduction of the small Input method:

Http://blog.ubuntusoft.com/small-input.html

http://forum.ubuntu.org.cn/viewtopic.php?t=226677

Option two: Open another input box that can input Chinese, enter Chinese and copy into sublime Text 2
Someone has made a sublime Text 2 plug-in (Inputhelper), you can quickly call an input box, enter the confirmation will be automatically copied to the ST2 inside.
Installation method of Inputhelper:

CD ~/.config/sublime-text-2/packagesgit clone https://github.com/xgenvn/ Inputhelper.git       

Then restart Sublime Text 2. When you need to enter Chinese, use the shortcut key:

+ Z

You can bring up the input box and insert it automatically after input.
This method applies to all input methods.

Scenario Three: By patching the way, let sublime Text 2 support Fcitx Input method
First we need to install ST2 via PPA (unofficial download of the Free install package):

sudo add-apt-repository PPA: Webupd8team/sublime-text-2sudo apt-get updatesudo apt -get Install sublime-text         

Then patching:
Copy down the code below and save it as sublime-imfix.c (stored in/home/username, your home directory)

/*sublime-imfix.cuse ld_preload to interpose some function to fix sublime Input methodLinux. by Cjacker Huang <jianzhong.huang at i-soft.com.cn> gcc-shared-o libsublime-imfix.so sublime_imfix.c ' Pkg-config --libs--cflags gtk+-2.0 '-fpicld_preload=./libsublime-imfix.so sublime_text*/#include <gtk/gtk.h>#include <gdk/gdkx.h>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;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 areaContext would lost, so here we set it again. 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); }

Open the terminal and install the required environment when compiling:

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

Then compile the sublime_imfix.c (first in the terminal to enter the SUBLIME_IMFIX.C directory):

-O libsublime-imfix. So sublime_imfix. C ' pkg--cflags GTK +--fpic     

After compiling you will get libsublime-imfix.so, I suggest you just leave libsublime-imfix.so in your home directory.
Then modify the startup configuration of the ST2:

/usr/share/applications/sublime-text-2. Desktop      

Found it

Exec=/usr/bin/sublime-text-%F     

Revision changed to

Exec%F

Found it

Exec=/usr/bin/sublime-text---new-window      

Revision changed to

Exec--new-window 

Notice where/home/username/libsublime-imfix.so is modified to the path where you compiled the generated libsublime-imfix.so.
Note that the new version of the ST2 Start command is changed to SUBL (the previous tutorial is the old version of Sublime-text-2), so when modified, the sublime-text-2 changed to Subl
Then save, restart ST2.

Sublime text 2 for Linux Chinese Input method cannot be used workaround

Related Article

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.