Ubuntu 14.04下Sublime text2解压版无法启用fcitx中文输入法的问题
来源:互联网 发布:郑州好玩软件科技公司 编辑:程序博客网 时间:2024/06/06 13:01
环境:
ubuntu 14.04 x64
fcitx五笔拼音输入法
sublime text 2
sublime text的中文输入法问题网上很多解决办法,用来用去都无法实现,后来发现原来是因为本地用的是解压版,没有创建快捷方式,导致启动时引导不上输入法,记录如下:
1、保存以下代码为“sublime-imfix.c”
/*sublime-imfix.cUse LD_PRELOAD to interpose some function to fix sublime input method support for linux.By Cjacker Huang gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPICLD_PRELOAD=./libsublime-imfix.so subl*/#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; //The caret width is 2; //Maybe sometimes we will make a mistake, but for most of the time, it should be the caret. if(rectangle->width == 2 && GTK_IS_IM_CONTEXT(local_context)) { gtk_im_context_set_cursor_location(local_context, rectangle); }} //this is needed, for example, if you input something in file dialog and return back the edit area//context will lost, so here we set it again. 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);}
2、安装 C/C++ 的编译环境和 gtk libgtk2.0-dev
sudo apt-get install build-essentialsudo apt-get install libgtk2.0-dev
3、编译共享内库,生成“libsublime-imfix.so”,把生成的so文件放到sublime根目录
gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
4、修改 /usr/bin/subl 为
#!/bin/shexport LD_PRELOAD=/opt/sublime_text/libsublime-imfix.soexec /opt/sublime_text/sublime_text "$@"
[Desktop Entry]Version=1.0Type=ApplicationName=Sublime_TextGenericName=Text EditorComment=Sophisticated text editor for code, markup and proseExec=bash -c 'LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text %F'Terminal=falseMimeType=text/plain;Icon=/opt/sublime_text/Icon/256x256/sublime_text.pngCategories=TextEditor;Development;Utility;StartupNotify=trueActions=Window;Document;X-Desktop-File-Install-Version=0.22[Desktop Action Window]Name=New WindowExec=bash -c 'LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text -n'OnlyShowIn=Unity;[Desktop Action Document]Name=New FileExec=bash -c 'LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text --command new_file'OnlyShowIn=Unity;
6、重启
附下载地址:http://download.csdn.net/detail/bellovin/8760605
0 0
- Ubuntu 14.04下Sublime text2解压版无法启用fcitx中文输入法的问题
- 解决ubuntu下用sublime-text2不能输入中文的问题 fcitx
- 解决Ubuntu下Sublime text 2的中文输入问题(使用fcitx输入法)
- ubuntu sublime-text2 输入法问题
- Ubuntu下安装fcitx和sublime中文输入法
- ubuntu下中文输入法的安装--fcitx
- Ubuntu系统下Sublime Text 2中fcitx中文输入法的解决方法
- Ubuntu 14.04下Qt 5.3.1 使用fcitx 输入法输入中文的问题
- 64位ubuntu16.04下pycharm无法切换fcitx输入法和无法输入中文的问题
- 解决Linux下 sublime text2输入法问题的方案
- Ubuntu 14.04 中文fcitx输入法
- 解决linux中sublime text2无法输入中文的问题
- Ubuntu下安装Fcitx中文输入法
- ubuntu下安装安装中文输入法fcitx
- Ubuntu下安装fcitx中文输入法
- ubuntu下安装fcitx 中文输入法
- ubuntu14 下 sublime text2 不能输入中文的问题
- Mac下Sublime text2中文乱码问题的解决
- Git 学习笔记
- 文件增量备份工具
- 操作系统--线程介绍
- spring-boot 配置多数据源多orm框架混用
- 手写一个栈溢出程序(深入版)
- Ubuntu 14.04下Sublime text2解压版无法启用fcitx中文输入法的问题
- JQuery笔记-学习绚丽效果教你做之JQuery实战
- 用 C 语言编写 Windows 服务程序的五个步骤 .
- Android退出应用程序
- zookeeper 原理
- 从最大似然到EM算法浅解
- Codeforces Round #301 (Div. 2) D 概率DP
- 自定义View—实现滚动TextView(跑马灯)效果
- 面试题11:数值的整数次方