/* libhangul
- * Copyright (C) 2004 - 2006 Choe Hwanjin
+ * Copyright (C) 2004 - 2007 Choe Hwanjin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
typedef struct _HangulCombination HangulCombination;
typedef struct _HangulBuffer HangulBuffer;
typedef struct _HangulInputContext HangulInputContext;
-typedef bool (*HangulICFilter) (HangulInputContext*,
- ucschar, const ucschar*, void*);
+
+typedef bool (*HangulOnTransition) (HangulInputContext*,
+ ucschar,
+ const ucschar*,
+ void*);
+typedef void (*HangulOnTranslate) (HangulInputContext*,
+ int,
+ ucschar*,
+ void*);
enum {
HANGUL_OUTPUT_SYLLABLE,
const char* id);
void hangul_ic_set_combination(HangulInputContext *hic,
const HangulCombination *combination);
-void hangul_ic_set_filter(HangulInputContext *hic,
- HangulICFilter func, void *user_data);
+
+void hangul_ic_connect_translate (HangulInputContext* hic,
+ HangulOnTranslate callback,
+ void* user_data);
+void hangul_ic_connect_transition(HangulInputContext* hic,
+ HangulOnTransition callback,
+ void* user_data);
const ucschar* hangul_ic_get_preedit_string(HangulInputContext *hic);
const ucschar* hangul_ic_get_commit_string(HangulInputContext *hic);
const char* hanja_get_value(const Hanja* hanja);
const char* hanja_get_comment(const Hanja* hanja);
+
+/* deprecated */
+typedef bool (*HangulICFilter) (ucschar*, ucschar, ucschar, ucschar, void*);
+void hangul_ic_set_filter(HangulInputContext *hic,
+ HangulICFilter func, void *user_data);
+
#ifdef __cplusplus
}
#endif
const HangulCombination* combination;
HangulBuffer buffer;
- HangulICFilter filter;
- void *filter_data;
int output_mode;
ucschar preedit_string[64];
ucschar commit_string[64];
ucschar flushed_string[64];
+
+ HangulOnTranslate on_translate;
+ void* on_translate_data;
+
+ HangulOnTransition on_transition;
+ void* on_transition_data;
+
+ HangulICFilter filter;
+ void *filter_data;
};
#include "hangulkeyboard.h"
hangul_ic_push(HangulInputContext *hic, ucschar c)
{
ucschar buf[64] = { 0, };
- if (hic->filter != NULL) {
+ if (hic->on_transition != NULL) {
ucschar cho, jung, jong;
if (hangul_is_choseong(c)) {
cho = c;
}
hangul_jaso_to_string(cho, jung, jong, buf, N_ELEMENTS(buf));
- if (!hic->filter(hic, c, buf, hic->filter_data)) {
+ if (!hic->on_transition(hic, c, buf, hic->on_transition_data)) {
hangul_ic_flush_internal(hic);
return false;
}
bool
hangul_ic_process(HangulInputContext *hic, int ascii)
{
- ucschar ch;
+ ucschar c;
if (hic == NULL)
return false;
- ch = hangul_keyboard_get_value(hic->keyboard, ascii);
-
hic->preedit_string[0] = 0;
hic->commit_string[0] = 0;
+ c = hangul_keyboard_get_value(hic->keyboard, ascii);
+ if (hic->on_translate != NULL)
+ hic->on_translate(hic, ascii, &c, hic->on_translate_data);
+
if (hangul_keyboard_get_type(hic->keyboard) == HANGUL_KEYBOARD_TYPE_JAMO)
- return hangul_ic_process_jamo(hic, ch);
+ return hangul_ic_process_jamo(hic, c);
else
- return hangul_ic_process_jaso(hic, ch);
+ return hangul_ic_process_jaso(hic, c);
}
const ucschar*
hic->output_mode = mode;
}
+void
+hangul_ic_connect_translate (HangulInputContext* hic,
+ HangulOnTranslate callback,
+ void* user_data)
+{
+ if (hic != NULL) {
+ hic->on_translate = callback;
+ hic->on_translate_data = user_data;
+ }
+}
+
+void
+hangul_ic_connect_transition(HangulInputContext* hic,
+ HangulOnTransition callback,
+ void* user_data)
+{
+ if (hic != NULL) {
+ hic->on_transition = callback;
+ hic->on_transition_data = user_data;
+ }
+}
+
void hangul_ic_set_filter(HangulInputContext *hic,
HangulICFilter func, void *user_data)
{
- if (hic == NULL)
- return;
-
- hic->filter = func;
- hic->filter_data = user_data;
+ return;
}
void