Solution to the problem that Sublime cannot input Chinese Characters in Ubuntu 14.04
After sublime is installed in Ubuntu 14.04, it cannot be entered in Chinese, but can be entered 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.
For more information about Sublime Text, read:
The eight most commonly used Sublime Text 3 plug-ins
Ubuntu installation code editor Sublime Text 3 (Build 3083)
Animation display 16 Sublime Text Shortcut Key Usage
Ubuntu 12.10 install and crack Sublime Text 2
Install Sublime Text 2 on Ubuntu 13.04
Code artifact-Sublime Text package management tools and extensions
How to Develop the Sublime Text 2 plug-in
Install and crack the Sublime Text 2 editor in Windows Mac Linux
Text Editor Sublime Text User Experience
Sublime Text details: click here
Sublime Text: click here
This article permanently updates the link address: