Sublime Chinese _linux processing scheme under Ubuntu

Source: Internet
Author: User
Tags gtk

Note:

Only tested FCITX, no tests IBUs
Because it is not a novice tutorial, so the installation of SUBLIME,FCITX,GCC and so on will not say
If you don't understand, leave a message.
The following is the implementation process:

Copy the following code, save as Sublime_fix.c

Copy Code code as follows:

#include <gtk/gtk.h>
#include <gdk/gdkx.h>
typedef gdksegment Gdkregionbox;
struct _gdkregion
{
Long size;
Long numrects;
Gdkregionbox *rects;
Gdkregionbox extents;
};
Gtkimcontext *local_context;
Voidgdk_region_get_clipbox (const gdkregion *region, Gdkrectangle *rectangle)
{
G_return_if_fail (Region!= NULL);
G_return_if_fail (Rectangle!= NULL);
Rectangle->x = region->extents.x1;
Rectangle->y = region->extents.y1;
Rectangle->width = region->extents.x2-region->extents.x1;
Rectangle->height = region->extents.y2-region->extents.y1;
Gdkrectangle rect;
Rect.x = rectangle->x;
Rect.y = rectangle->y;
rect.width = 0;
Rect.height = rectangle->height;
if (rectangle->width = = 2 && gtk_is_im_context (Local_context)) {
Gtk_im_context_set_cursor_location (local_context, rectangle);
}
}

Static Gdkfilterreturn Event_filter (Gdkxevent *xevent, gdkevent *event, Gpointer im_context)
{
Xevent *xev = (xevent *) xevent;
if (Xev->type = = Keyrelease && gtk_is_im_context (im_context)) {
Gdkwindow * win = G_object_get_data (G_object (im_context), "window");
if (Gdk_is_window (Win))
Gtk_im_context_set_client_window (Im_context, Win);
}
return gdk_filter_continue;
}
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);
if (! Gdk_is_window (WINDOW))
Return
G_object_set_data (G_object (context), "window", window);
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);
Local_context = context;
}
Gdk_window_add_filter (window, event_filter, context);
}

Compile it with the following command

Copy Code code as follows:

Gcc-shared-o libsublime-imfix.so sublime_fix.c ' pkg-config--libs--cflags ' gtk+-2.0/

Add Run permissions to libsublime-imfix.so

Copy Code code as follows:

chmod +x libsublime-imfix.so

Copy the compiled file libsublime-imfix.so to the sublime folder
The new file under the sublime installation directory is sublime_sh.sh,copy as follows:

Copy Code code as follows:

#!/bin/bash
Sublime_home= "~/software" #你的sublime安装目录
ld_lib= "$SUBLIME _home/libsublime-imfix.so"
Sh-c "ld_preload= $LD _lib $SUBLIME _home/sublime $@"

You can already start sublime by Teminal, run./sublime_sh.sh
to start sublime through the initiator, modify the exec path in your sublime.desktop to Sublime_ The path where the sh.sh resides

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.