Home Download Buy Blog Forum Support

Input method support

Re: Input method support

Postby thunderdrum on Mon Oct 22, 2012 6:57 am

Still not solved.

build 2217 with fcitx......
it seems that it can not call the fcitx by the shortcut with Ctrl-Space. but change the fcitx's shortcut from C-S to another. Problem remains....
thunderdrum
 
Posts: 1
Joined: Thu Oct 18, 2012 6:00 am

Re: Input method support

Postby chenjau on Wed Oct 24, 2012 3:36 am

input methods(seems all 3rd party or system intergrated ) can't follow cursor position in microsoft windows 7 and xp.
Jon, please consider fix this problem, every cjk user depend on input methods
chenjau
 
Posts: 3
Joined: Tue Oct 23, 2012 2:06 pm

Re: Input method support

Postby tonytonyjan on Thu Nov 15, 2012 11:02 am

Still not works in CJK with ibus :(
I hope this can be solved as soon as possible.

By the way, there is a package named "InputHelper" which can temporarily solve this issue. (Though it's not quite convenient)
tonytonyjan
 
Posts: 2
Joined: Thu Nov 15, 2012 10:54 am

Re: Input method support

Postby everyx on Fri Nov 23, 2012 6:01 am

I'm a sublime text2 user from China, it works fine in my windows, but in my fedora i can't input any Chinese words :o , it's important for CJK user, please fix it.
everyx
 
Posts: 1
Joined: Fri Nov 23, 2012 5:58 am

Re: Input method support

Postby carl_tw on Sun Nov 25, 2012 6:17 am

VIM is awesome! I'm not going to buy a Sublime until this bug has been fixed.
carl_tw
 
Posts: 1
Joined: Sun Nov 25, 2012 5:56 am

Re: Input method support

Postby cjacker on Thu Dec 27, 2012 10:23 am

This is a dirty fix but at least works. cursor position update also supported.

Use LD_PRELOAD to reimplement gtk_im_context_set_client_window and set im focus in.
use "gdk_region_get_clipbox" to catch the caret position. (It's really difficult to find which function can catch the position....)

Here I made a assumption that the caret width is always 2, since it is 2.

the height is the "font glyph height".

1, save below code to sublime_imfix.c

Code: Select all
/*
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);
}



2, compile a shared library.

Code: Select all
gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC


3, LD_PRELOAD it
Code: Select all
LD_PRELOAD=./libsublime-imfix.so sublime_text
Last edited by cjacker on Tue Jan 01, 2013 7:09 am, edited 6 times in total.
cjacker
 
Posts: 3
Joined: Thu Dec 27, 2012 10:16 am

Re: Input method support

Postby cjacker on Thu Dec 27, 2012 10:34 am

.
Last edited by cjacker on Sun Dec 30, 2012 6:13 pm, edited 2 times in total.
cjacker
 
Posts: 3
Joined: Thu Dec 27, 2012 10:16 am

Re: Input method support

Postby Khiyuan on Thu Dec 27, 2012 11:49 am

cjacker wrote:This is a dirty fix but at least works. cursor location update still not works, since I really can not find a proper way to get the current caret loation relative to
GdkWidow, it seems sublime use a customized GtkWidget? I am not sure.
......


I've tested this in Archlinux with sublime version 2.0.1-2, It works quite well.

Thanks for your excellent job!!
Khiyuan
 
Posts: 1
Joined: Thu Dec 27, 2012 11:42 am

Re: Input method support

Postby cjacker on Sun Dec 30, 2012 6:32 pm

Khiyuan wrote:
cjacker wrote:This is a dirty fix but at least works. cursor location update still not works, since I really can not find a proper way to get the current caret loation relative to
GdkWidow, it seems sublime use a customized GtkWidget? I am not sure.
......


I've tested this in Archlinux with sublime version 2.0.1-2, It works quite well.

Thanks for your excellent job!!


original post had been updated to support cursor location update, please try it.
cjacker
 
Posts: 3
Joined: Thu Dec 27, 2012 10:16 am

Re: Input method support

Postby edubkendo on Wed Jan 09, 2013 3:12 am

Followed all of cjacker's steps but they didn't seem to work for me. No errors or anything, I just still don't get anything from the IME. Even if I turn it on manurally, when I type the characters are still English, not the Japanese characters from the IME.
edubkendo
 
Posts: 30
Joined: Fri May 18, 2012 2:43 pm
Location: Nashville

PreviousNext

Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 23 guests