Ubuntu under Sublime Text 3 to resolve a method that cannot input Chinese

Source: Internet
Author: User
Tags gtk sublime text

Environment:

    • Ubuntu14.04

    • Sogou IME for Linux

    • Sublime Text 3

Hint: Compile please do it under non-root

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.


  1. 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);

    }

  2. 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

  3. Then copy the libsublime-imfix.so to the folder where Sublime_text resides.

    sudo mv libsublime-imfix.so/opt/sublime_text/

  4. 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

  5. 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. 6

    After the above steps, we can enter Chinese in sublime.


Ubuntu under Sublime Text 3 to resolve a method that cannot input Chinese

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.