In ubuntu15.10, sublime text3 cannot enter Chinese. Solution: ubuntu15.10sublime
Link to the original article: http://geek.csdn.net/news/detail/444641.first, ensure that your computer has a c+compiler Environment
If not, run the following command to install
sudo apt-get install build-essentialsudo apt-get install libgtk2.0-dev
2. In ~ Directory to create a file named sublime-imfix.c
The content is as follows:
#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);}}
3. Compile the above file into a shared library libsublime-imfix.so
gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
4. Copy the libsublime-imfix.so to the folder where sublime_text is located
sudo mv libsublime-imfix.so /opt/sublime_text/
5. Modify the file/usr/bin/subl content
sudo vi /usr/bin/subl
Set
#!/bin/shexec /opt/sublime_text/sublime_text "$@"
Change
#!/bin/shLD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text "$@"
In this case, you can run subl in the command to enter Chinese Characters in sogou for linux. However, you cannot enter Chinese Characters in other ways.
6. To enable Chinese input when right-clicking a file, you also need to modify the content of the file sublime_text.desktop.
Command
sudo vi /usr/share/applications/sublime_text.desktop
Replace the string in [Desktop Entry]
Exec=/opt/sublime_text/sublime_text %F
Change
Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text %F"
Set the string in [Desktop Action Window]
Exec=/opt/sublime_text/sublime_text -n
Change
Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text -n"
Set the string in [Desktop Action Document]
Exec=/opt/sublime_text/sublime_text --command new_file
Change
Exec=bash -c "LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text --command new_file"
Note: Pay attention to the double quotation marks (") when modifying the parameters. Otherwise, files with space file names cannot be opened.
Here only the/usr/share/applications/sublime-text.desktop is modified, but it works properly.
Sublime-text.desktop under the opt/sublime_text/directory can be modified or not modified.