Solution to the problem that Sublime cannot input Chinese Characters in Ubuntu 14.04

Source: Internet
Author: User

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:

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.