这篇“Ubuntu下sublime中文无法输入如何解决”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“Ubuntu下sublime中文无法输入如何解决”文章吧。
#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);}
使用下列命令编译它
gcc -shared -o libsublime-imfix.so sublime_fix.c `pkg-config --libs --cflags gtk+-2.0/` -fpic
chmod +x libsublime-imfix.so
将编译后的文件libsublime-imfix.so复制到sublime的文件夹下面
在sublime安装目录下新建文件为sublime_sh.sh,copy内容如下:
#!/bin/bash sublime_home="~/software" #你的sublime安装目录 ld_lib="$sublime_home/libsublime-imfix.so" sh -c "ld_preload=$ld_lib $sublime_home/sublime $@"
你已经可以通过teminal启动sublime了,运行./sublime_sh.sh即可
若要通过启动器启动sublime,请将你sublime.desktop里面的exec路径修改为sublime_sh.sh所在路径
以上就是关于“Ubuntu下sublime中文无法输入如何解决”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注编程之家行业资讯频道。