diff options
author | Choe Hwanjin <choe.hwanjin@gmail.com> | 2007-01-14 21:14:07 +0900 |
---|---|---|
committer | Choe Hwanjin <choe.hwanjin@gmail.com> | 2007-01-14 21:14:07 +0900 |
commit | 91c19b4007909b3738d2f477df7d7bbb897b49b7 (patch) | |
tree | 6e78233d2713a15915bc43a9f870acdbd6ca4193 | |
parent | 440c780a6890182bd6172307edb60ad1ff2aaa3e (diff) | |
download | libhangul-91c19b4007909b3738d2f477df7d7bbb897b49b7.tar.gz |
HangulInputContext의 상태를 알 수 있는 함수 추가:
* hangul_buffer_has_choseong(), hangul_buffer_has_jungseong(),
hangul_buffer_has_jongseong() 추가
git-svn-id: http://kldp.net/svn/hangul/libhangul/trunk@114 8f00fcd2-89fc-0310-932e-b01be5b65e01
-rw-r--r-- | hangul/hangul.h | 5 | ||||
-rw-r--r-- | hangul/hangulctype.c | 41 | ||||
-rw-r--r-- | hangul/hangulinputcontext.c | 36 |
3 files changed, 82 insertions, 0 deletions
diff --git a/hangul/hangul.h b/hangul/hangul.h index 6529443..a981709 100644 --- a/hangul/hangul.h +++ b/hangul/hangul.h @@ -93,7 +93,12 @@ void hangul_ic_delete(HangulInputContext *hic); bool hangul_ic_process(HangulInputContext *hic, int ascii); void hangul_ic_reset(HangulInputContext *hic); bool hangul_ic_backspace(HangulInputContext *hic); + bool hangul_ic_is_empty(HangulInputContext *hic); +bool hangul_ic_has_choseong(HangulInputContext *hic); +bool hangul_ic_has_jungseong(HangulInputContext *hic); +bool hangul_ic_has_jongseong(HangulInputContext *hic); + int hangul_ic_dvorak_to_qwerty(int qwerty); void hangul_ic_set_output_mode(HangulInputContext *hic, int mode); diff --git a/hangul/hangulctype.c b/hangul/hangulctype.c index 0035f90..104c83a 100644 --- a/hangul/hangulctype.c +++ b/hangul/hangulctype.c @@ -25,6 +25,8 @@ #include <config.h> #endif +#include <stdlib.h> + #include "hangul.h" /** @@ -373,4 +375,43 @@ hangul_jaso_to_syllable(ucschar choseong, ucschar jungseong, ucschar jongseong) return c; } +void +hangul_syllable_to_jaso(ucschar syllable, + ucschar* choseong, + ucschar* jungseong, + ucschar* jongseong) +{ + static const ucschar hangul_base = 0xac00; + static const ucschar choseong_base = 0x1100; + static const ucschar jungseong_base = 0x1161; + static const ucschar jongseong_base = 0x11a7; + static const int njungseong = 21; + static const int njongseong = 28; + + if (!hangul_is_syllable(syllable)) { + if (jongseong != NULL) + *jongseong = 0; + if (jungseong != NULL) + *jungseong = 0; + if (choseong != NULL) + *choseong = 0; + return; + } + + syllable -= hangul_base; + + if (jongseong != NULL) { + *jongseong = jongseong_base + syllable % njongseong; + } + syllable /= njongseong; + + if (jungseong != NULL) { + *jungseong = jungseong_base + syllable % njungseong; + } + syllable /= njungseong; + + if (choseong != NULL) { + *choseong = choseong_base + syllable; + } +} diff --git a/hangul/hangulinputcontext.c b/hangul/hangulinputcontext.c index e304c63..adf4599 100644 --- a/hangul/hangulinputcontext.c +++ b/hangul/hangulinputcontext.c @@ -274,6 +274,24 @@ hangul_buffer_is_empty(HangulBuffer *buffer) buffer->jongseong == 0; } +static bool +hangul_buffer_has_choseong(HangulBuffer *buffer) +{ + return buffer->choseong != 0; +} + +static bool +hangul_buffer_has_jungseong(HangulBuffer *buffer) +{ + return buffer->jungseong != 0; +} + +static bool +hangul_buffer_has_jongseong(HangulBuffer *buffer) +{ + return buffer->jongseong != 0; +} + static void hangul_buffer_push(HangulBuffer *buffer, ucschar ch) { @@ -969,6 +987,24 @@ hangul_ic_is_empty(HangulInputContext *hic) return hangul_buffer_is_empty(&hic->buffer); } +bool +hangul_ic_has_choseong(HangulInputContext *hic) +{ + return hangul_buffer_has_choseong(&hic->buffer); +} + +bool +hangul_ic_has_jungseong(HangulInputContext *hic) +{ + return hangul_buffer_has_jungseong(&hic->buffer); +} + +bool +hangul_ic_has_jongseong(HangulInputContext *hic) +{ + return hangul_buffer_has_jongseong(&hic->buffer); +} + void hangul_ic_set_output_mode(HangulInputContext *hic, int mode) { |