void hangul_ic_delete(HangulInputContext *hic);
bool hangul_ic_process(HangulInputContext *hic, int ascii);
void hangul_ic_reset(HangulInputContext *hic);
-void hangul_ic_flush(HangulInputContext *hic);
bool hangul_ic_backspace(HangulInputContext *hic);
bool hangul_ic_is_empty(HangulInputContext *hic);
int hangul_ic_dvorak_to_qwerty(int qwerty);
const ucschar* hangul_ic_get_preedit_string(HangulInputContext *hic);
const ucschar* hangul_ic_get_commit_string(HangulInputContext *hic);
+const ucschar* hangul_ic_flush(HangulInputContext *hic);
/* hanja.c */
enum {
ucschar preedit_string[64];
ucschar commit_string[64];
+ ucschar flushed_string[64];
};
#include "hangulkeyboard.h"
hic->preedit_string[0] = 0;
hic->commit_string[0] = 0;
+ hic->flushed_string[0] = 0;
hangul_buffer_clear(&hic->buffer);
}
-/* this function does not clear previously made commit string */
+/* append current preedit to the commit buffer.
+ * this function does not clear previously made commit string. */
static void
hangul_ic_flush_internal(HangulInputContext *hic)
{
hangul_buffer_clear(&hic->buffer);
}
-void
+const ucschar*
hangul_ic_flush(HangulInputContext *hic)
{
if (hic == NULL)
- return;
+ return NULL;
+ // get the remaining string and clear the buffer
+ hic->preedit_string[0] = 0;
hic->commit_string[0] = 0;
- hangul_ic_flush_internal(hic);
+ hic->flushed_string[0] = 0;
+ hangul_buffer_get_string(&hic->buffer, hic->flushed_string,
+ N_ELEMENTS(hic->flushed_string));
+
+ hangul_buffer_clear(&hic->buffer);
+
+ return hic->flushed_string;
}
bool
hangul_buffer_clear(&hic->buffer);
+ hic->preedit_string[0] = 0;
+ hic->commit_string[0] = 0;
+ hic->flushed_string[0] = 0;
+
return hic;
}
printf("%c", ascii);
}
}
+
if (!hangul_ic_is_empty(hic)) {
- hangul_ic_flush(hic);
- commit_string = (wchar_t*)hangul_ic_get_commit_string(hic);
- n = wcstombs(commit, commit_string, sizeof(commit));
+ const wchar_t *flushed = (wchar_t*)hangul_ic_flush(hic);
+ n = wcstombs(commit, flushed, sizeof(commit));
commit[n] = '\0';
if (strlen(commit) > 0) {
printf("%s", commit);