示例#1
0
文件: eve.c 项目: CarterTsai/hime
void hime_reset()
{
#if 1
  if (!current_CS)
    return;
//  dbg("hime_reset\n");

  switch(current_method_type()) {
    case method_type_PHO:
      pho_reset();
      return;
#if USE_TSIN
    case method_type_TSIN:
      tsin_reset();
      return;
#endif
    case method_type_MODULE:
      if (inmd[current_CS->in_method].mod_cb_funcs)
        module_cb()->module_reset();
      return;
    default:
      gtab_reset();
//      dbg("metho %d\n", current_CS->in_method);
  }
#endif
}
示例#2
0
文件: eve.c 项目: CarterTsai/hime
void flush_edit_buffer()
{
//  dbg("flush_edit_buffer\n");
  if (!current_CS)
    return;
//  dbg("hime_reset\n");
  switch(current_method_type()) {
#if USE_TSIN
    case method_type_TSIN:
      flush_tsin_buffer();
      break;
#endif
    case method_type_MODULE:
      if (inmd[current_CS->in_method].mod_cb_funcs)
      module_cb()->module_flush_input();
      break;
    default:
      output_gbuf();
//      dbg("metho %d\n", current_CS->in_method);
  }
#if 0
  dbg("output_bufferN:%d\n", output_bufferN);
  if (output_bufferN) {
    output_buffer_call_back();
  }
#endif
}
示例#3
0
文件: eve.c 项目: CarterTsai/hime
int hime_get_preedit(ClientState *cs, char *str, HIME_PREEDIT_ATTR attr[], int *cursor, int *comp_flag)
{
//  dbg("hime_get_preedit %x\n", current_CS);
  if (!current_CS) {
//empty:
//    dbg("empty\n");
    str[0]=0;
    *cursor=0;
    return 0;
  }

  str[0]=0;
  *comp_flag=0;

//  cs->use_preedit = TRUE;

  switch(current_method_type()) {
    case method_type_PHO:
      return pho_get_preedit(str, attr, cursor, comp_flag);
#if USE_TSIN
    case method_type_TSIN:
      return tsin_get_preedit(str, attr, cursor, comp_flag);
#endif
    case method_type_MODULE:
      if (inmd[current_CS->in_method].mod_cb_funcs)
        return module_cb()->module_get_preedit(str, attr, cursor, comp_flag);
    default:
      return gtab_get_preedit(str, attr, cursor, comp_flag);
//      dbg("metho %d\n", current_CS->in_method);
  }

  return 0;
}
示例#4
0
文件: eve.c 项目: Tetralet/hime
// return TRUE if the key press is processed
gboolean ProcessKeyRelease(KeySym keysym, u_int kev_state)
{
  disp_win_kbm_capslock();

  check_CS();
#if 0
  dbg_time("key release %x %x\n", keysym, kev_state);
#endif

  if (current_CS->im_state == HIME_STATE_DISABLED)
    return FALSE;

#if 1
  if (current_CS->b_hime_protocol && (last_keysym == XK_Shift_L ||
  last_keysym == XK_Shift_R || last_keysym == XK_Control_L || last_keysym == XK_Control_R)) {
    if (((keysym == XK_Control_L || keysym == XK_Control_R)
          && (kev_state & ShiftMask)) ||
        ((keysym == XK_Shift_L || keysym == XK_Shift_R)
          && (kev_state & ControlMask))) {
       cycle_next_in_method();
       return TRUE;
    }
  }
#endif

  switch(current_method_type()) {
    case method_type_TSIN:
      return feedkey_pp_release(keysym, kev_state);
    case method_type_MODULE:
      if (!module_cb())
        return FALSE;
      return module_cb()->module_feedkey_release(keysym, kev_state);
    default:
      return feedkey_gtab_release(keysym, kev_state);
  }

  return FALSE;
}
示例#5
0
文件: eve.c 项目: Tetralet/hime
gboolean win_is_visible()
{
  if (!current_CS)
    return FALSE;
  switch (current_method_type()) {
    case method_type_PHO:
      return gwin_pho && GTK_WIDGET_VISIBLE(gwin_pho);
#if USE_TSIN
    case method_type_TSIN:
      return gwin0 && GTK_WIDGET_VISIBLE(gwin0);
#endif
    case method_type_MODULE:
      if (!module_cb())
        return FALSE;
      return module_cb()->module_win_visible();
    default:
      if (!gwin_gtab)
        return FALSE;
      return gwin_gtab && GTK_WIDGET_VISIBLE(gwin_gtab);
  }

  return FALSE;
}
示例#6
0
文件: eve.c 项目: CarterTsai/hime
void update_active_in_win_geom()
{
//  dbg("update_active_in_win_geom\n");
  switch (current_method_type()) {
    case method_type_PHO:
      get_win_pho_geom();
      break;
#if USE_TSIN
    case method_type_TSIN:
      get_win0_geom();
      break;
#endif
    case method_type_MODULE:
      module_cb()->module_get_win_geom();
      break;
    default:
      get_win_gtab_geom();
      break;
  }
}
示例#7
0
文件: eve.c 项目: Tetralet/hime
void update_active_in_win_geom()
{
  HIME_module_callback_functions *mod_cbs;
//  dbg("update_active_in_win_geom\n");
  switch (current_method_type()) {
    case method_type_PHO:
      get_win_pho_geom();
      break;
#if USE_TSIN
    case method_type_TSIN:
      get_win0_geom();
      break;
#endif
    case method_type_MODULE:
      mod_cbs = module_cb();
      if(mod_cbs && mod_cbs->module_get_win_geom)
        mod_cbs->module_get_win_geom();
      break;
    default:
      get_win_gtab_geom();
      break;
  }
}
示例#8
0
文件: eve.c 项目: CarterTsai/hime
gboolean init_in_method(int in_no)
{
  gboolean init_im = !(cur_inmd && (cur_inmd->flag & FLAG_GTAB_SYM_KBM));

  if (in_no < 0)
    return FALSE;

  check_CS();


  if (current_CS->in_method != in_no) {
    if (!(inmd[in_no].flag & FLAG_GTAB_SYM_KBM)) {
      if (current_method_type() == method_type_TSIN) {
        flush_tsin_buffer();
      } else
        output_gbuf();

      hide_in_win(current_CS);
    }

    if (cur_inmd && (cur_inmd->flag & FLAG_GTAB_SYM_KBM))
      hide_win_kbm();
  }


  reset_current_in_win_xy();

//  dbg("switch init_in_method %x %d\n", current_CS, in_no);
  set_tsin_pho_mode0(current_CS);
  tsin_set_win1_cb();

  switch (inmd[in_no].method_type) {
    case method_type_PHO:
      current_CS->in_method = in_no;
      init_tab_pho();
      break;
    case method_type_TSIN:
      set_wselkey(pho_selkey);
      current_CS->in_method = in_no;
      init_tab_pp(init_im);
      break;
    case method_type_MODULE:
    {
      HIME_module_main_functions gmf;
      init_HIME_module_main_functions(&gmf);
      if (!inmd[in_no].mod_cb_funcs) {
        char ttt[256];
        strcpy(ttt, inmd[in_no].filename);

        dbg("module %s\n", ttt);
        if (!(inmd[in_no].mod_cb_funcs = init_HIME_module_callback_functions(ttt))) {
          dbg("module not found\n");
          return FALSE;
        }
      }

      if (inmd[in_no].mod_cb_funcs->module_init_win(&gmf)) {
        current_CS->in_method = in_no;
        module_cb()->module_show_win();
        set_wselkey(pho_selkey);
      } else {
        return FALSE;
      }

      break;
    }
    default:
      init_gtab(in_no);
      if (!inmd[in_no].DefChars)
        return FALSE;
      current_CS->in_method = in_no;
      if (!(inmd[in_no].flag & FLAG_GTAB_SYM_KBM))
        show_win_gtab();
      else {
        win_kbm_inited = 1;
        show_win_kbm();
      }

      set_gtab_input_method_name(inmd[in_no].cname);
      break;
  }
#if WIN32
  if (current_CS && current_CS->in_method != last_input_method)
    last_input_method = current_CS->in_method;
#endif

#if TRAY_ENABLED
  disp_tray_icon();
#endif

  if (inmd[current_CS->in_method].selkey) {
    set_wselkey(inmd[current_CS->in_method].selkey);
    gtab_set_win1_cb();
//    dbg("aa selkey %s\n", inmd[current_CS->in_method].selkey);
  }

  update_in_win_pos();
  update_win_kbm_inited();

  return TRUE;
}
示例#9
0
文件: eve.c 项目: CarterTsai/hime
void toggle_im_enabled()
{
//    dbg("toggle_im_enabled\n");
    check_CS();

    if (current_CS->in_method < 0)
      p_err("err found");


    if (current_CS->im_state != HIME_STATE_DISABLED) {
      if (current_CS->im_state == HIME_STATE_ENG_FULL) {
        current_CS->im_state = HIME_STATE_CHINESE;
        disp_im_half_full();
        save_CS_current_to_temp();
        return;
      }

      if (current_method_type() == method_type_TSIN) {
#if USE_TSIN
        flush_tsin_buffer();
#endif
      }
      else if (current_method_type () == method_type_MODULE)
      {
          module_cb ()->module_flush_input ();
      }
      else {
        output_gbuf();
        reset_gtab_all();
      }

      hide_in_win(current_CS);
#if 0
      hide_win_status();
#endif
      current_CS->im_state = HIME_STATE_DISABLED;

      update_win_kbm();

#if TRAY_ENABLED
      disp_tray_icon();
#endif
    } else {
      if (!current_method_type())
        init_gtab(current_CS->in_method);


      init_state_chinese(current_CS);
      reset_current_in_win_xy();
#if 1
      show_in_win(current_CS);
      update_in_win_pos();
#else
      update_in_win_pos();
      show_in_win(current_CS);
#endif

      update_win_kbm();

#if TRAY_ENABLED
      disp_tray_icon();
#endif
    }

    save_CS_current_to_temp();
}
示例#10
0
文件: eve.c 项目: CarterTsai/hime
// return TRUE if the key press is processed
gboolean ProcessKeyPress(KeySym keysym, u_int kev_state)
{
#if 0
  dbg("key press %x %x\n", keysym, kev_state);
#endif
  destroy_phrase_save_menu();

  disp_win_kbm_capslock();
  check_CS();

  if (current_CS->client_win)
    focus_win = current_CS->client_win;

  if (
#if WIN32
  !test_mode &&
#endif
  callback_str_buffer && strlen(callback_str_buffer)) {
    send_text(callback_str_buffer);
    callback_str_buffer[0]=0;
    return TRUE;
  }

  if (force_preedit) {
    force_preedit=0;
    return 1;
  }

  if (keysym == XK_space) {
#if 0
    dbg("state %x\n", kev->state);
    dbg("%x\n", Mod4Mask);
#endif
    if (
      ((kev_state & (ControlMask|Mod1Mask|ShiftMask))==ControlMask && hime_im_toggle_keys==Control_Space) ||
      ((kev_state & Mod1Mask) && hime_im_toggle_keys==Alt_Space) ||
      ((kev_state & ShiftMask) && hime_im_toggle_keys==Shift_Space) ||
      ((kev_state & Mod4Mask) && hime_im_toggle_keys==Windows_Space)
    ) {
      if (current_method_type() == method_type_TSIN) {
        tsin_set_eng_ch(1);
      }

      toggle_im_enabled();
#if UNIX
      return TRUE;
#else
      return FALSE;
#endif
    }
  }

  if (keysym == XK_space && (kev_state & ShiftMask)) {
    if (last_keysym != XK_Shift_L && last_keysym != XK_Shift_R)
      return FALSE;

    toggle_half_full_char();

    return TRUE;
  }


  if ((kev_state & (Mod1Mask|ShiftMask)) == (Mod1Mask|ShiftMask)) {
    if (current_CS->im_state != HIME_STATE_DISABLED || hime_eng_phrase_enabled)
      return feed_phrase(keysym, kev_state);
    else
      return 0;
  }

//  dbg("state %x\n", kev_state);
  if ((current_CS->im_state & (HIME_STATE_ENG_FULL)) ) {
    return full_char_proc(keysym);
  }


  if ((kev_state & ControlMask) && (kev_state&(Mod1Mask|Mod5Mask))) {
    if (keysym == 'g' || keysym == 'r') {
      send_output_buffer_bak();
      return TRUE;
    }

    if (!hime_enable_ctrl_alt_switch)
      return FALSE;

    int kidx = hime_switch_keys_lookup(keysym);
    if (kidx < 0)
      return FALSE;

    if (inmd[kidx].method_type == method_type_SYMBOL_TABLE) {
#if 1
      if (current_CS->im_state == HIME_STATE_CHINESE) {
        if (!win_is_visible())
          win_sym_enabled=1;
        else
          win_sym_enabled^=1;
      } else
        win_sym_enabled=0;
#else
      win_sym_enabled^=1;
#endif

      create_win_sym();
      if (win_sym_enabled) {
        force_show = TRUE;
        if (current_CS->im_state == HIME_STATE_CHINESE)
          show_in_win(current_CS);
        force_show = FALSE;
      }
      return TRUE;
    }

    if (!inmd[kidx].cname)
      return FALSE;

    current_CS->im_state = HIME_STATE_CHINESE;
#if WIN32
    if (!test_mode)
#endif
      init_in_method(kidx);

    return TRUE;
  }

  last_keysym = keysym;

  if (current_CS->im_state == HIME_STATE_DISABLED) {
    return FALSE;
  }

  if (!current_CS->b_hime_protocol) {
  if (((keysym == XK_Control_L || keysym == XK_Control_R)
                   && (kev_state & ShiftMask)) ||
      ((keysym == XK_Shift_L || keysym == XK_Shift_R)
                   && (kev_state & ControlMask))) {
     cycle_next_in_method();
     return TRUE;
  }
  }

  if (current_CS->b_raise_window && keysym>=' ' && keysym < 127) {
    if (timeout_handle)
      g_source_remove(timeout_handle);
    timeout_handle = g_timeout_add(200, timeout_raise_window, NULL);
  }

  if (kev_state & ControlMask) {
    if (feed_phrase(keysym, kev_state))
      return TRUE;
  }

  switch(current_method_type()) {
    case method_type_PHO:
      return feedkey_pho(keysym, kev_state);
#if USE_TSIN
    case method_type_TSIN:
      return feedkey_pp(keysym, kev_state);
#endif
    case method_type_MODULE:
      return module_cb()->module_feedkey(keysym, kev_state);
    default:
      return feedkey_gtab(keysym, kev_state);
  }

  return FALSE;
}