void candidate_deactivate_cb(void *ptr) { uim_agent_context *ua = (uim_agent_context *)ptr; debug_printf(DEBUG_NOTE, "candidate_deactivate_cb\n"); clear_candidate(ua->cand); }
static void update_context_encoding(uim_agent_context *ua) { debug_printf(DEBUG_NOTE, "update_context_encoding\n"); /* discard current context */ clear_candidate(ua->cand); clear_preedit(ua->pe); uim_set_client_encoding(ua->context, ua->encoding); }
/* release context from context list */ int release_uim_agent_context(int context_id) { uim_agent_context_list *ptr; for (ptr = agent_context_list_head; ptr != NULL; ptr = ptr->next) { if (ptr->agent_context->context_id == context_id) { uim_agent_context *ua = ptr->agent_context; /* clear current */ if (current == ua) clear_current_uim_agent_context(); /* release */ uim_release_context(ua->context); /* clear candidate */ clear_candidate(ua->cand); free(ua->cand); /* clear preedit */ clear_preedit(ua->pe); free(ua->pe); /* free others */ free(ua->encoding); free(ua->im); free(ua->prop->list); free(ua->prop); free(ua->comstr); /* rebuild list */ if (ptr->next != NULL) ptr->next->prev = ptr->prev; else agent_context_list_tail = ptr->prev; if (ptr->prev != NULL) ptr->prev->next = ptr->next; else agent_context_list_head = ptr->next; free(ua); free(ptr); return context_id; } } return -1; }
static int cmd_reset(int context_id) { /* reset current context */ uim_agent_context *ua = get_uim_agent_context(context_id); if (ua != NULL) { /* before reset, clear preedit and candidate */ clear_preedit(ua->pe); clear_candidate(ua->cand); uim_reset_context(ua->context); check_prop_list_update(ua); check_default_engine(); return 1; } else { return -1; } }
int new_candidate(uim_context context, candidate_info *cand, int num, int limit) { int i; #if !UIM_EL_USE_NEW_PAGE_HANDLING uim_candidate u_cand; #endif if (cand->valid) clear_candidate(cand); cand->valid = 1; cand->index = -1; cand->disp_limit = limit; cand->num = num; #if UIM_EL_USE_NEW_PAGE_HANDLING cand->page_index = 0; #endif cand->cand_array = uim_malloc(sizeof(candidate) * num); #if !UIM_EL_USE_NEW_PAGE_HANDLING /* get candidates from context */ for (i = 0; i < num; i ++) { u_cand = uim_get_candidate(context, i, limit ? i % limit : i); cand->cand_array[i].str = uim_strdup(uim_candidate_get_cand_str(u_cand)); cand->cand_array[i].label = uim_strdup(uim_candidate_get_heading_label(u_cand)); uim_candidate_free(u_cand); } #else for (i = 0; i < num; i++) { cand->cand_array[i].str = NULL; cand->cand_array[i].label = NULL; } set_page_candidates(context, cand); #endif return 1; }