Solve the problem that sublime cannot input Chinese Characters in Ubuntu, using tusublime

Source: Internet
Author: User

Solve the problem that sublime cannot input Chinese Characters in Ubuntu, using tusublime

Solve the problem that sublime cannot enter Chinese Characters in Ubuntu.

After installing sublime in Ubuntu, you cannot enter Chinese characters, but can enter it normally in other software. This is a sublime bug, the solution is to automatically add a dynamic correction library before running sublime through shell. The solution is as follows:

Enter a directory such ~ :

cd

Create a C source code

subl sublime-imfix.c

Paste the following code:

#include <gtk/gtkimcontext.h>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); g_object_set_data(G_OBJECT(context),"window",window); if(!GDK_IS_WINDOW (window))   return; 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);}

 

Install the dependency package before compilation. Run the following command:

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

 

Then compile the C file:

gcc -shared -o libsublime-imfix.so sublime-imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC

 

Next, tell the program link to this before each sublime program is run. so library file can be input in sublime Chinese, its command is LD_PRELOAD =/opt/sublime_text/libsublime-imfix.so exec/opt/sublime_text "$ @", /opt/sublime_text/is the default directory for sublime installation. Command Line subl or Dash Sublime Text, or open with> sublime text in the file browser, they can start the sublime program, but they do not have to look for their startup portal, and then change it one by one. They all rely on the execution of/opt/sublime_text. With this feature, the/opt/sublime_text binary files are saved separately, then, write a shell script named/opt/sublime_text, which tells the program link before executing the/opt/sublime_text binary code before creating the shell script. so to modify the library file. The process is as follows:

Cd/opt/sublime_text/sudo mv sublime_text sublime_text0sudo vim sublime_text # If you are not familiar with vim, sudo gedit sublime_text

 

Write the following statement in a row and save it:

LD_PRELOAD =/opt/sublime_text/libsublime-imfix.so exec/opt/sublime_text/sublime_text0 "$ @"

sudo chmod +x sublime_text

Now, you can enter Chinese Characters in sublime.

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.