Ubuntu下sublime汉语不可能输入的管理方案,第22中

2019-05-09 21:15 来源:未知

注:

笔者动用的是Ubuntu 一三.10,使用的是fcitx输入法,Google拼音。

Linux版本为Ubuntu 一三.0四beta 二,顺便安装了fcitx 搜狗输入法,不过发掘在sublime text 第22中学不大概输入中文,在此以前在Ubuntu 1贰.04.第22中学fcitx不荒谬输入的,只是有局部没不平时。

只测试了了fcitx,未有测试ibus
因为不是菜鸟教程,所以安装sublime,fcitx,gcc等等的就背着了
若看不懂请留言
上面为兑现进程:

前日安装了Sublime Text 二后,开采切换不出fcitx输入法。遂在英特网找了多数方法,最终这种办法很得力,所以分享给大家:

针对发掘标题,化解难题的基准,咱就找化解方法呗,经过谷歌和论坛发帖,找到了化解方法。

copy下列代码,保存为sublime_fix.c

图片 1

图片 2

复制代码 代码如下:

保存上面那份代码保存为 ~/sublime-imfix.c

Ubuntu 1贰.10 安装破解Sublime Text 2 http://www.linuxidc.com/Linux/2013-07/86898.htm

#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);
    }
}

/*
sublime-imfix.c
Use LD_PRELOAD to interpose some function to fix sublime input method support for linux.
By Cjacker Huang <jianzhong.huang at i-soft.com.cn>
 
gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk -2.0` -fPIC
LD_PRELOAD=./libsublime-imfix.so sublime_text
*/ 
#include <gtk/gtk.h> 
#include <gdk/gdkx.h> 
typedef GdkSegment GdkRegionBox; 
 
struct _GdkRegion 

  long size; 
  long numRects; 
  GdkRegionBox *rects; 
  GdkRegionBox extents; 
}; 
 
GtkIMContext *local_context; 
 
void 
gdk_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); 

Ubuntu 13.04安装Sublime Text 2 http://www.linuxidc.com/Linux/2013-05/84228.htm

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);
}

设置C/C 的编写翻译碰到和gtk libgtk二.0-dev

编码神器——Sublime Text 包处理工具及扩大大全 http://www.linuxidc.com/Linux/2013-10/91701.htm

选拔下列命令编写翻译它

sudo apt-get install build-essential 
sudo apt-get install libgtk2.0-dev 

何以开荒 Sublime Text 二 的插件 http://www.linuxidc.com/Linux/2013-09/90046.htm

复制代码 代码如下:

用极端进入 sublime-imfix.c 所在目录,运维上边发号施令

Windows Mac Linux下安装以及破解Sublime Text 2编辑器 http://www.linuxidc.com/Linux/2013-08/89452.htm

gcc -shared -o libsublime-imfix.so sublime_fix.c `pkg-config --libs --cflags gtk -2.0/` -fPIC

gcc -shared -o libsublime-imfix.so sublime-imfix.c  `pkg-config --libs --cflags gtk -2.0` -fPIC 

文本编辑器Sublime Text 使用体验 http://www.linuxidc.com/Linux/2013-08/89326.htm

增进运维权限给libsublime-imfix.so

用文件编辑器修改 /usr/share/applications/sublime.desktop 文件(那是你安装sublime text 二时和好建的),找到发轫为"Exec="的行(有两行),把subl修改为

编写翻译共享内库

复制代码 代码如下:

bash -c 'LD_PRELOAD=~/libsublime-imfix.so subl'

  1. 保存下述代码为 sublime-imfix.c 文件

chmod x libsublime-imfix.so

OK,在运维器这里点击sublime text 贰就足以普通话输入了!(注意:在极限输入subl展开时,是不能切换中文输入法的哦)

/*
sublime-imfix.c
Use LD_PRELOAD to interpose some function to fix sublime input method support for linux.
By Cjacker Huang <jianzhong.huang at i-soft.com.cn>

将编写翻译后的文件libsublime-imfix.so复制到sublime的文件夹上面
在sublime安装目录下新建文件为sublime_sh.sh,copy内容如下:

Ubuntu 1贰.十 安装破解Sublime Text 二

gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk -2.0` -fPIC
LD_PRELOAD=./libsublime-imfix.so sublime_text
*/
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
typedef GdkSegment GdkRegionBox;

复制代码 代码如下:

Ubuntu 13.04安装Sublime Text 2

struct _GdkRegion
{
  long size;
  long numRects;
  GdkRegionBox *rects;
  GdkRegionBox extents;
};

#!/bin/bash
SUBLIME_HOME="~/software"  #你的sublime安装目录
LD_LIB="$SUBLIME_HOME/libsublime-imfix.so"
sh  -c "LD_PRELOAD=$LD_LIB  $SUBLIME_HOME/sublime $@"

编码神器——Sublime Text 包管理工科具及扩充大全

GtkIMContext *local_context;

你早已能够由此teminal运营sublime了,运维./sublime_sh.sh即可
若要通过运营器运维sublime,请将你sublime.desktop里面包车型地铁exec路径修改为sublime_sh.sh所在门路

怎样支付 Sublime Text 二 的插件

void
gdk_region_get_clipbox (const GdkRegion *region,
            GdkRectangle    *rectangle)
{
  g_return_if_fail (region != NULL);
  g_return_if_fail (rectangle != NULL);

你或然感兴趣的篇章:

  • Ubuntu配置sublime text 三的c编写翻译碰到的具体步骤
  • ubuntu下利用sublime text时怎样完善输入中文
  • ubuntu sublime普通话输入难题化解办法

Windows Mac Linux下安装以及破解Sublime Text 2编辑器

  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);
  }
}

文本编辑器Sublime Text 使用体验

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

壹三.10,使用的是fcitx输入法,谷歌拼音。 明日安装了Sublime Text 二后,开采切换不出fcitx输入法。遂在网络找了多数情势,最终...

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);
}

  1. 安装C/C 的编写翻译情况和gtk libgtk2.0-dev

sudo apt-get install build-essential

sudo apt-get install libgtk2.0-dev

  1. 编写翻译共享内库

gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk -2.0` -fPIC

  1. 启动 Sublime Text 2

好了,未来试行下述命令运行 Sublime Text 2,就足以行使fcitx输入汉语了!

LD_PRELOAD=./libsublime-imfix.so sublime_text

不过如此的话,大家每一次都要在极端里面使用命令运维sublime text 2,这样很不方便人民群众,接下去我们还要经过修改sublime-text-贰.desktop到达点击Logo运维。

开辟终端进入applications修改sublime-text-二.desktop

cd /usr/share/applications

sudo vim sublime-text-2.desktop

打开sublime-text-2.desktop后,将

Exec=/usr/bin/sublime-text-2 %F

修改为

Exec=bash -c 'LD_PRELOAD=/usr/lib/libsublime-imfix.so /usr/bin/sublime-text-2' %F

还有将

Exec=/usr/bin/sublime-text-2 --new-window

修改为

Exec=bash -c 'LD_PRELOAD=/usr/lib/libsublime-imfix.so /usr/bin/sublime-text-2' --new-window

好了,接下去你在dash中式点心击展开sublime text2呢,初叶你的代码之旅吧。

越来越多Ubuntu相关音信见Ubuntu 专项论题页面 http://www.linuxidc.com/topicnews.aspx?tid=2

正文永世更新链接地址:http://www.linuxidc.com/Linux/2014-06/103855.htm

图片 3

TAG标签: 韦德娱乐1946
版权声明:本文由韦德娱乐1946_韦德娱乐1946网页版|韦德国际1946官网发布于韦德国际1946官网,转载请注明出处:Ubuntu下sublime汉语不可能输入的管理方案,第22中