当前位置: 首页>>代码示例>>C++>>正文


C++ HIME_module_main_functions::mf_utf8_str_N方法代码示例

本文整理汇总了C++中HIME_module_main_functions::mf_utf8_str_N方法的典型用法代码示例。如果您正苦于以下问题:C++ HIME_module_main_functions::mf_utf8_str_N方法的具体用法?C++ HIME_module_main_functions::mf_utf8_str_N怎么用?C++ HIME_module_main_functions::mf_utf8_str_N使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HIME_module_main_functions的用法示例。


在下文中一共展示了HIME_module_main_functions::mf_utf8_str_N方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: strcat

// FIXME: refine and chk
int
module_get_preedit (char *pszStr, HIME_PREEDIT_ATTR himePreeditAttr[],
                    int *pnCursor, int *pCompFlag)
{
    char *pszTmpStr = NULL;
    char *pszZuinStr = NULL;
    int nIdx;
    int nLength;
    int nTotalLen = 0;
    int nAttr = 0;
    int nZuinLen = 0;

    pszStr[0] = 0;
    *pnCursor = 0;
    himePreeditAttr[0].flag = HIME_PREEDIT_ATTR_FLAG_UNDERLINE;
    himePreeditAttr[0].ofs0 = 0;

    if (chewing_buffer_Len (g_pChewingCtx))
        nAttr = 1;

    for (nIdx = 0; nIdx < chewing_buffer_Len (g_pChewingCtx); nIdx++)
    {
        pszTmpStr = (char *)gtk_label_get_text (GTK_LABEL (g_pSeg[nIdx].label));
        nLength = g_himeModMainFuncs.mf_utf8_str_N (pszTmpStr);
        nTotalLen += nLength;

        if (nIdx < chewing_cursor_Current (g_pChewingCtx))
            *pnCursor += nLength;

#if 0
        if (nIdx == chewing_cursor_Current (g_pChewingCtx))
        {
            himePreeditAttr[1].ofs0 = *pnCursor;
            himePreeditAttr[1].ofs1 = *pnCursor + nLength;
            himePreeditAttr[1].flag = HIME_PREEDIT_ATTR_FLAG_REVERSE;
            nAttr++;
        }
#endif

        strcat (pszStr, pszTmpStr);
    }

    if (g_himeModMainFuncs.mf_hime_display_on_the_spot_key()) {
        pszZuinStr = chewing_zuin_String (g_pChewingCtx, &nZuinLen);
	    strcat (pszStr, pszZuinStr);
        free (pszZuinStr);
        nTotalLen += nZuinLen;
    }

    himePreeditAttr[0].ofs1 = nTotalLen;

    pCompFlag = 0;

    return nAttr;
}
开发者ID:Explorer09,项目名称:hime,代码行数:56,代码来源:chewing.c

示例2: module_get_preedit

int module_get_preedit(char *str, HIME_PREEDIT_ATTR attr[], int *pcursor, int *comp_flag)
{
  int i;

//  dbg("anthy_get_preedit %d\n", cursor);
  str[0]=0;
  *pcursor=0;

  attr[0].flag=HIME_PREEDIT_ATTR_FLAG_UNDERLINE;
  attr[0].ofs0=0;
  int attrN=0;
  int ch_N=0;

  if (state==STATE_CONVERT) {
    if (segN)
      attrN=1;

    for(i=0; i < segN; i++) {
      char *s = (char *)gtk_label_get_text(GTK_LABEL(seg[i].label));
      int N = gmf.mf_utf8_str_N(s);
      ch_N+=N;
      if (i < cursor)
        *pcursor+=N;
      if (gmf.mf_hime_edit_display_ap_only() && i==cursor) {
        attr[1].ofs0=*pcursor;
        attr[1].ofs1=*pcursor+N;
        attr[1].flag=HIME_PREEDIT_ATTR_FLAG_REVERSE;
        attrN++;
      }
      strcat(str, s);
    }

    attr[0].ofs1 = ch_N;
  } else {
    if (jpN)
      attrN=1;

    keys[keysN]=0;

    for(i=0;i < jpN; i++) {
      char *s=idx_hira_kata(jp[i], FALSE);

      int N = gmf.mf_utf8_str_N(s);
//      dbg("%d]%s N:%d\n", i, s, N);
      if (gmf.mf_hime_edit_display_ap_only() && i==cursor) {
        strcat(str, keys);
        ch_N+=keysN;
        *pcursor = ch_N;
        attr[1].ofs0=ch_N;
        attr[1].ofs1=ch_N+N;
        attr[1].flag=HIME_PREEDIT_ATTR_FLAG_REVERSE;
        attrN++;
      }
      strcat(str, s);
      ch_N+=N;
    }

    if (cursor==jpN) {
      *pcursor = ch_N;
      strcat(str, keys);
      ch_N+=keysN;
    }

    attr[0].ofs1 = ch_N;
//    dbg("cursor %d  ch_N:%d  '%s'\n", *pcursor, ch_N, str);
  }

  *comp_flag = keysN>0;
  if (win_anthy && GTK_WIDGET_VISIBLE(win_anthy))
    *comp_flag|=2;
  if (segN || jpN)
    *comp_flag|=4;

  return attrN;
}
开发者ID:CarterTsai,项目名称:hime,代码行数:75,代码来源:anthy.cpp


注:本文中的HIME_module_main_functions::mf_utf8_str_N方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。