This experience is currently in the Ubuntu14.04 environment, has Sogou input method for Linux and Sublime Text 3 in the case of successful installation.
Save the following code to the file Sublime_imfix.c (located in the ~ directory)
#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);
}
Compile the code from the previous step into a shared library libsublime-imfix.so, command
CD ~
Gcc-shared-o libsublime-imfix.so sublime_imfix.c ' pkg-config--libs--cflags gtk+-2.0 '-fPIC
Then copy the libsublime-imfix.so to the folder where Sublime_text resides.
sudo mv libsublime-imfix.so/opt/sublime_text/
Modify the contents of a file/usr/bin/subl
sudo gedit/usr/bin/subl
Will
#!/bin/sh
Exec/opt/sublime_text/sublime_text "[Email protected]"
Revision changed to
#!/bin/sh
ld_preload=/opt/sublime_text/libsublime-imfix.so exec/opt/sublime_text/sublime_text "[Email protected]"
At this point, executing subl in the command will be able to use Sogou for Linux Chinese input
In order to use the right mouse button to open the file can use Chinese input, also need to modify the contents of the file Sublime_text.desktop.
Command
sudo gedit/usr/share/applications/sublime_text.desktop
Set the string in [Desktop Entry]
exec=/opt/sublime_text/sublime_text%F
Revision changed to
exec=bash-c "ld_preload=/opt/sublime_text/libsublime-imfix.so exec/opt/sublime_text/sublime_text%F"
string in [Desktop Action Window]
exec=/opt/sublime_text/sublime_text-n
Revision changed to
exec=bash-c "ld_preload=/opt/sublime_text/libsublime-imfix.so exec/opt/sublime_text/sublime_text-n"
string in [Desktop Action Document]
exec=/opt/sublime_text/sublime_text--command new_file
Revision changed to
exec=bash-c "ld_preload=/opt/sublime_text/libsublime-imfix.so exec/opt/sublime_text/sublime_text-- Command New_file "
Attention:
Note the double quotation mark "" when you modify it, or you will not be able to open a file with a space file name.
Only /usr/share/applications/sublime-text.desktophas been modified here, but it can be used normally.
Opt/sublime_text / directory sublime-text.desktop can be modified or not modified.
6
After the above steps, we can enter Chinese in sublime.