Back to index

im-sdk  12.3.91
Classes | Defines | Typedefs | Functions
ime_buffer.h File Reference
#include "ime.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _ImeBufferRec

Defines

#define IME_PREEDIT_AREA   1
#define IME_LOOKUP_AREA   2
#define IME_STATUS_AREA   4
#define IME_COMMIT   8

Typedefs

typedef struct _ImeBufferRec ImeBufferRec

Functions

ImeBufferRecalloc_ime_buffer (int max_preedit_bytes, int max_candidate_num, int max_candidate_byte, int max_numberring_byte, int max_commit_byte)
void free_ime_buffer (ImeBufferRec *ime_buffer)
void clear_ime_buffer (ImeBufferRec *ime_buffer)

Class Documentation

struct _ImeBufferRec

Definition at line 30 of file ctim.h.

Collaboration diagram for _ImeBufferRec:
Class Members
ImeCandidatesRec candidates
char * candidates
char candidates_buf
int candidates_start_pos
char * comments
char comments_buf
unsigned char * commit_buf
char commit_buf
int commit_len
int cur_lookup_pos
ImeEncoding encoding
char input_buf
int input_len
int lookup_label_type
char * lookups
char lookups_buf
int max_cand_num
int num_candidates
int page_state
ImePreeditRec preedit
char preedit_buf
int preedit_caretpos
int preedit_len
int return_status
int session_id

Define Documentation

#define IME_COMMIT   8

Definition at line 9 of file ime_buffer.h.

#define IME_LOOKUP_AREA   2

Definition at line 7 of file ime_buffer.h.

#define IME_PREEDIT_AREA   1

Definition at line 6 of file ime_buffer.h.

#define IME_STATUS_AREA   4

Definition at line 8 of file ime_buffer.h.


Typedef Documentation

typedef struct _ImeBufferRec ImeBufferRec

Function Documentation

ImeBufferRec* alloc_ime_buffer ( int  max_preedit_bytes,
int  max_candidate_num,
int  max_candidate_byte,
int  max_numberring_byte,
int  max_commit_byte 
)

Definition at line 27 of file ime_buffer.c.

{
    int i, suc;

    ImeBufferRec *ime_buffer = (ImeBufferRec *)calloc(1, sizeof(ImeBufferRec));
    if (ime_buffer) {

        suc = ((ime_buffer->commit_buf = (unsigned char*)malloc(max_commit_byte)) != NULL);
        suc = suc && ((ime_buffer->preedit.preedit.text = (unsigned char*)calloc(1, max_preedit_bytes)) != NULL);
        suc = suc && ((ime_buffer->candidates.numbers = (unsigned char*)calloc(1, max_numberring_byte*max_candidate_num+1)) != NULL);
        suc = suc && ((ime_buffer->candidates.candidates = (ImeText)calloc(max_candidate_num, sizeof(ImeTextRec))) != NULL);
        if (suc) {
            memset(ime_buffer->candidates.candidates, 0, sizeof(ImeTextRec)*max_candidate_num);
            ime_buffer->max_cand_num = max_candidate_num;
        }
        for (i = 0; suc && i < max_candidate_num; ++i) {
            suc = suc && ((ime_buffer->candidates.candidates[i].text = (unsigned char *)calloc(1, max_candidate_byte)) != NULL);
        }

        if (!suc) {
            free_ime_buffer(ime_buffer);
            ime_buffer = NULL;
        }
    }
    clear_ime_buffer(ime_buffer);
    return ime_buffer;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void clear_ime_buffer ( ImeBufferRec ime_buffer)

Definition at line 60 of file ime_buffer.c.

{
    if (ime_buffer) {
        if (ime_buffer->preedit.preedit.text)
            ime_buffer->preedit.preedit.text[0] = '\0';
        ime_buffer->preedit.caret = 0;
        ime_buffer->candidates.count = 0;
        ime_buffer->return_status = 0;
    }
}

Here is the caller graph for this function:

void free_ime_buffer ( ImeBufferRec ime_buffer)

Definition at line 5 of file ime_buffer.c.

{
    int i;

    if (ime_buffer) {
        if (ime_buffer->candidates.candidates) {
            for (i = 0; i < ime_buffer->max_cand_num; ++i) {
                if (ime_buffer->candidates.candidates[i].text)
                    free(ime_buffer->candidates.candidates[i].text);
            }
            free(ime_buffer->candidates.candidates);
        }
        if (ime_buffer->candidates.numbers)
            free(ime_buffer->candidates.numbers);
        if (ime_buffer->preedit.preedit.text)
            free(ime_buffer->preedit.preedit.text);
        if (ime_buffer->commit_buf)
            free(ime_buffer->commit_buf);
        free(ime_buffer);
    }
}

Here is the caller graph for this function: