Esempio n. 1
0
gboolean
module_feedkey (int nKeyVal, int nKeyState)
{
    if (!g_pChewingCtx)
        return FALSE;

    if (!g_himeModMainFuncs.mf_tsin_pho_mode ())
        return FALSE;

    hime_label_clear (MAX_SEG_NUM);

    chewing_set_ShapeMode (g_pChewingCtx, g_himeModMainFuncs.mf_current_shape_mode());

    if (nKeyState & (Mod1Mask|Mod4Mask|Mod5Mask|ControlMask))
        return FALSE;

    if (!hime_key_filter (&nKeyVal))
        return FALSE;

    if (!hime_buffer_commit ())
        return FALSE;

    if (!hime_buffer_label_show ())
        return FALSE;

    if (!hime_zuin_label_show ())
        return FALSE;

    module_show_win ();

    return TRUE;
}
Esempio n. 2
0
int
module_flush_input (void)
{
    char *pszTmp;

    if (chewing_buffer_Check (g_pChewingCtx))
    {
        pszTmp = chewing_buffer_String (g_pChewingCtx);
        g_himeModMainFuncs.mf_send_text (pszTmp);
        free (pszTmp);
    }

    chewing_Reset (g_pChewingCtx);

    // FIXME: dirty workaround to reset the libchewing internal data
    //        it may impact the bEscCleanAllBuf setting
    chewing_handle_Esc (g_pChewingCtx);

    hime_label_clear (MAX_SEG_NUM);

    if (*g_himeModMainFuncs.mf_hime_pop_up_win && is_empty())
        module_hide_win();

    return 0;
}
Esempio n. 3
0
gboolean
module_feedkey (int nKeyVal, int nKeyState)
{
    if (!g_pChewingCtx)
        return FALSE;

    if (!g_himeModMainFuncs.mf_tsin_pho_mode ())
        return FALSE;

    hime_label_clear (MAX_SEG_NUM);

    if (!hime_key_filter (&nKeyVal))
        return FALSE;

    if (!hime_zuin_label_show ())
        return FALSE;

    if (!hime_buffer_label_show ())
        return FALSE;

    if (!hime_buffer_commit ())
        return FALSE;

    module_show_win ();

    return TRUE;
}
Esempio n. 4
0
gboolean
module_feedkey (int nKeyVal, int nKeyState)
{
    char *pszTmp         = NULL;
    char *pszChewingCand = NULL;
    int nZuinLen         = 0;
    char szWord[4];
    int nPhoIdx, nBufIdx;
    int nIdx;

    if (!g_pChewingCtx)
        return FALSE;

    memset (szWord, 0x00, 4);

    if (!g_himeModMainFuncs.mf_tsin_pho_mode ())
        return FALSE;

    switch (nKeyVal)
    {
        case XK_space:
            chewing_handle_Space (g_pChewingCtx);
            break;

        case XK_Escape:
            chewing_handle_Esc (g_pChewingCtx);
            break;

        case XK_Return:
        case XK_KP_Enter:
            chewing_handle_Enter (g_pChewingCtx);
            break;

        case XK_Delete:
        case XK_KP_Delete:
            chewing_handle_Del (g_pChewingCtx);
            break;

        case XK_BackSpace:
            chewing_handle_Backspace (g_pChewingCtx);
            break;

        case XK_Up:
        case XK_KP_Up:
            chewing_handle_Up (g_pChewingCtx);
            break;

        case XK_Down:
        case XK_KP_Down:
            chewing_handle_Down (g_pChewingCtx);
            break;

        case XK_Left:
        case XK_KP_Left:
            chewing_handle_Left (g_pChewingCtx);
            break;

        case XK_Right:
        case XK_KP_Right:
            chewing_handle_Right (g_pChewingCtx);
            break;

#if 0
        case XK_Shift_L:
            chewing_handle_ShiftLeft (g_pChewingCtx);
            break;

        case XK_Shift_R:
            chewing_handle_ShiftRight (g_pChewingCtx);
            break;
#endif

        case XK_Tab:
            chewing_handle_Tab (g_pChewingCtx);
            break;

        default:
            if (nKeyVal > 32 && nKeyVal < 127)
                chewing_handle_Default (g_pChewingCtx, nKeyVal);
            break;
    }

    hime_label_clear (MAX_SEG_NUM);
    g_nCurrentCursorPos = chewing_cursor_Current (g_pChewingCtx);

    if (g_nCurrentCursorPos < 0 || g_nCurrentCursorPos > MAX_SEG_NUM)
        return FALSE;

    // zuin symbols
    pszTmp = chewing_zuin_String (g_pChewingCtx, &nZuinLen);
    if (pszTmp)
    {
        for (nBufIdx = 0; nBufIdx < nZuinLen; nBufIdx++)
        {
            memcpy (szWord, pszTmp + nBufIdx * 3, 3);
            for (nPhoIdx = 0; nPhoIdx < 3; nPhoIdx++)
                if (strstr (g_himeModMainFuncs.mf_pho_chars[nPhoIdx], szWord) != NULL)
                    hime_label_show (szWord, nPhoIdx + chewing_buffer_Len (g_pChewingCtx) + 1);
        }
        free (pszTmp);
    }

    // check if the composing is valid or not
    if (chewing_buffer_Check (g_pChewingCtx))
    {
        g_himeModMainFuncs.mf_hide_selections_win ();
        pszTmp = chewing_buffer_String (g_pChewingCtx);

        // init cand_no
        chewing_cand_Enumerate (g_pChewingCtx);

        g_himeModMainFuncs.mf_clear_sele ();

        if (chewing_cand_TotalChoice (g_pChewingCtx))
        {
            nIdx = 0;
            while (chewing_cand_hasNext (g_pChewingCtx))
            {
                pszChewingCand = chewing_cand_String (g_pChewingCtx);

                if (nIdx > chewing_get_candPerPage (g_pChewingCtx) - 1)
                    break;
                hime_label_cand_show (pszChewingCand, nIdx++);
                free (pszChewingCand);
            }
        }

        for (nIdx = 0; nIdx < chewing_buffer_Len (g_pChewingCtx); nIdx++)
        {
            memcpy (szWord, pszTmp + (nIdx * 3), 3);
            hime_label_show (szWord, nIdx);
        }

        free (pszTmp);
    }

    if (chewing_commit_Check (g_pChewingCtx))
    {
        pszTmp = chewing_commit_String (g_pChewingCtx);
        g_himeModMainFuncs.mf_send_text (pszTmp);

        // FIXME: workaround for repeated commit
        //        it impacts the bEscCleanAllBuf setting!
        chewing_handle_Esc (g_pChewingCtx);
        free (pszTmp);
    }

    module_show_win ();

    return TRUE;
}