Back to index

im-sdk  12.3.91
Defines | Functions
newpinyin_filter.c File Reference
#include <stdio.h>
#include "newpinyin_im.h"
#include "PYIM.h"

Go to the source code of this file.


#define IME_Status   ime_buffer->return_status
#define Input_Buf   ime_buffer->input_buf
#define Input_Len   ime_buffer->input_len
#define Preedit_Buf   ime_buffer->preedit_buf
#define Preedit_Len   ime_buffer->preedit_len
#define Preedit_CaretPos   ime_buffer->preedit_caretpos
#define Commit_Buf   ime_buffer->commit_buf
#define Commit_Len   ime_buffer->commit_len
#define Status_Buf   ime_buffer->status_buf
#define Status_Len   ime_buffer->status_len
#define Lookups_Num   ime_buffer->num_candidates
#define Lookup_Pos   ime_buffer->cur_lookup_pos
#define Candidates   ime_buffer->candidates
#define Comments   ime_buffer->comments
#define Lookups   ime_buffer->lookups


int convert_to_imebuffer (ImToXSun *pIeh, ImeBufferRec *ime_buffer)
int newpy_open (JINT nSesID)
int newpy_close (JINT nSesID)
int newpy_filter (int keycode, int keychar, int keystatus, ImeBufferRec *ime_buffer)

Define Documentation

#define Candidates   ime_buffer->candidates

Definition at line 19 of file newpinyin_filter.c.

#define Comments   ime_buffer->comments

Definition at line 20 of file newpinyin_filter.c.

#define Commit_Buf   ime_buffer->commit_buf

Definition at line 13 of file newpinyin_filter.c.

#define Commit_Len   ime_buffer->commit_len

Definition at line 14 of file newpinyin_filter.c.

#define IME_Status   ime_buffer->return_status

Definition at line 7 of file newpinyin_filter.c.

#define Input_Buf   ime_buffer->input_buf

Definition at line 8 of file newpinyin_filter.c.

#define Input_Len   ime_buffer->input_len

Definition at line 9 of file newpinyin_filter.c.


Definition at line 5 of file newpinyin_filter.c.

#define Lookup_Pos   ime_buffer->cur_lookup_pos

Definition at line 18 of file newpinyin_filter.c.

#define Lookups   ime_buffer->lookups

Definition at line 21 of file newpinyin_filter.c.

#define Lookups_Num   ime_buffer->num_candidates

Definition at line 17 of file newpinyin_filter.c.

#define Preedit_Buf   ime_buffer->preedit_buf

Definition at line 10 of file newpinyin_filter.c.

#define Preedit_CaretPos   ime_buffer->preedit_caretpos

Definition at line 12 of file newpinyin_filter.c.

#define Preedit_Len   ime_buffer->preedit_len

Definition at line 11 of file newpinyin_filter.c.

#define Status_Buf   ime_buffer->status_buf

Definition at line 15 of file newpinyin_filter.c.

#define Status_Len   ime_buffer->status_len

Definition at line 16 of file newpinyin_filter.c.

Function Documentation

int convert_to_imebuffer ( ImToXSun pIeh,
ImeBufferRec ime_buffer 

Definition at line 60 of file newpinyin_filter.c.

       JINT   i, j, nHz;
       JINT   nNumDollar;   /* Number of Numsign and Dollar before Caret */
       static ImToXSunChar  iehc;
       IME_Status = 0;

       DEBUG_printf("nType:%d\n", pIeh->nType);
       if (pIeh->nType == IMXSUN_TYPE_BOUNCEKEY)

       ime_buffer->lookup_label_type = NUMERIC_LABEL;
       Lookups_Num = pIeh->nChoiceNum;
       IME_Status |= IME_LOOKUP_AREA;

       /* One Hanzi is  2 Bytes */
       nHz = 0;
       for (i = 0; (pIeh->pwPreedit[i] >= 0x8140); i++)
       iehc.nType        = pIeh->nType;
       iehc.nErrorCode   = pIeh->nErrorCode;
       iehc.nChoiceNum   = pIeh->nChoiceNum;
       iehc.nLabelType   = LABELTYPE_1234567;
       nNumDollar = 0;
       j = 0;
       for (i = 0; pIeh->pwPreedit[i] != 0x0000; i++)
              if ((pIeh->pwPreedit[i] != (JWORD)'#') && (pIeh->pwPreedit[i] != (JWORD)'$'))
                     pIeh->pwPreedit[j++] = pIeh->pwPreedit[i];
              else  /* '#' and '$' before pIeh->nCaretPos should be counted!! */
                     if (i < pIeh->nCaretPos)
                            nNumDollar ++;
       for (; j < 128; j++)
              pIeh->pwPreedit[j++] = 0x0000;
       iehc.nCaretPos    = pIeh->nCaretPos + nHz - nNumDollar;
       Jword2Uchar(pIeh->pwPreedit, iehc.szPreedit, 128);
       Jword2Uchar(pIeh->pwCommit,  iehc.szCommit,  256);
       Jword2Uchar(pIeh->pwStatus,  iehc.szStatus,   16);

       Preedit_CaretPos = pIeh->nCaretPos + nHz - nNumDollar;

       DEBUG_printf("pIeh->nCaretPos:%d, nHz:%d, nNumDollar:%d\n", pIeh->nCaretPos, nHz, nNumDollar);
       DEBUG_printf("Preedit_CaretPos:%d\n", Preedit_CaretPos);
       Preedit_CaretPos = pIeh->nCaretPos;

       strncpy((char *)Preedit_Buf, (char *)(iehc.szPreedit), MAX_PREEDIT_CHAR_NUM);
       strncpy((char *)Commit_Buf,  (char *)(iehc.szCommit),  MAX_COMMIT_CHAR_NUM);
       Preedit_Len = strlen((char *)Preedit_Buf);
       IME_Status |= IME_PREEDIT_AREA;

       Commit_Len  = strlen((char *)Commit_Buf);
       IME_Status |= IME_COMMIT;

       DEBUG_printf("Lookups_Num:%d\n", Lookups_Num);
       DEBUG_printf("Preedit:%s\n", Preedit_Buf);
       DEBUG_printf("Commit:%s\n",  Commit_Buf);
       DEBUG_printf("Preedit:%s\n", iehc.szPreedit);
       DEBUG_printf("Commit:%s\n", iehc.szCommit);
       DEBUG_printf("Status:%s\n", iehc.szStatus);

       DEBUG_printf("Newpy return: commit_len: %d\n", strlen((char *)iehc.szCommit));
       DEBUG_printf("Commit:%s\n", (char *)iehc.szCommit);
       DEBUG_printf("Commit:%s\n",  Commit_Buf);
       for(i = 0; i < 8; i++) {
              Jword2Uchar(pIeh->pwLookupChoice[i], iehc.szLookupChoice[i],  24);
              strncpy((char *)Lookups[i], (char *)(iehc.szLookupChoice[i]), 24);
              DEBUG_printf("Lookups[%d]:%s\n", i, Lookups[i]);


Here is the call graph for this function:

Here is the caller graph for this function:

int newpy_close ( JINT  nSesID)

Definition at line 36 of file newpinyin_filter.c.


Here is the call graph for this function:

Here is the caller graph for this function:

int newpy_filter ( int  keycode,
int  keychar,
int  keystatus,
ImeBufferRec ime_buffer 

Definition at line 42 of file newpinyin_filter.c.

       ImToXSun *pIeh;
       JINT ret;

       JINT nSesID = ime_buffer->session_id;
       pIeh = (ImToXSun *)NewPY_trans (nSesID, (JINT)keycode, (JINT)keychar, (JINT)keystatus);

       if (pIeh == NULL)
       ret = convert_to_imebuffer(pIeh, ime_buffer);
       return (ret);

Here is the call graph for this function:

Here is the caller graph for this function:

int newpy_open ( JINT  nSesID)

Definition at line 25 of file newpinyin_filter.c.

       ImToXSun *pIeh;

       pIeh = (ImToXSun *)NewPY_open(nSesID);
       if (pIeh == NULL)
              return (-1);


Here is the call graph for this function:

Here is the caller graph for this function: