コード例 #1
0
ファイル: test.c プロジェクト: choehwanjin/libhangul
END_TEST

START_TEST(test_hangul_ic_auto_reorder)
{
    bool val = get_ic_option(HANGUL_IC_OPTION_AUTO_REORDER);

    set_ic_option(HANGUL_IC_OPTION_AUTO_REORDER, true);
    fail_unless(check_preedit("2", "rk", L"가"));
    fail_unless(check_preedit("2", "kr", L"가"));

    set_ic_option(HANGUL_IC_OPTION_AUTO_REORDER, false);
    fail_unless(check_preedit("2", "rk", L"가"));
    fail_unless(check_commit("2", "kr", L"ㅏ"));
    fail_unless(check_preedit("2", "kr", L"ㄱ"));

    set_ic_option(HANGUL_IC_OPTION_AUTO_REORDER, true);
    fail_unless(check_preedit("3f", "kf", L"가"));
    fail_unless(check_preedit("3f", "fk", L"가"));

    set_ic_option(HANGUL_IC_OPTION_AUTO_REORDER, false);
    fail_unless(check_preedit("3f", "kf", L"가"));
    fail_unless(check_commit("3f", "fk", L"ㅏ"));
    fail_unless(check_preedit("3f", "fk", L"ㄱ"));

    set_ic_option(HANGUL_IC_OPTION_AUTO_REORDER, val);
}
コード例 #2
0
ファイル: test.c プロジェクト: choehwanjin/libhangul
END_TEST

START_TEST(test_hangul_ic_process_3s)
{
    /* ㅎㅐㅅㅅ */
    fail_unless(check_preedit("3s", "mrqq", L"했"));
}
コード例 #3
0
ファイル: test.c プロジェクト: choehwanjin/libhangul
END_TEST

START_TEST(test_hangul_ic_non_choseong_combi)
{
    bool val = get_ic_option(HANGUL_IC_OPTION_NON_CHOSEONG_COMBI);
    set_ic_option(HANGUL_IC_OPTION_NON_CHOSEONG_COMBI, true);
    fail_unless(check_preedit("2", "rt", L"ㄳ"));
    fail_unless(check_commit("2", "rtk", L"ㄱ"));
    fail_unless(check_preedit("2", "rtk", L"사"));

    set_ic_option(HANGUL_IC_OPTION_NON_CHOSEONG_COMBI, false);
    fail_unless(check_commit("2", "rt", L"ㄱ"));
    fail_unless(check_preedit("2", "rt", L"ㅅ"));

    set_ic_option(HANGUL_IC_OPTION_NON_CHOSEONG_COMBI, val);
END_TEST
}
コード例 #4
0
ファイル: test.c プロジェクト: choehwanjin/libhangul
END_TEST

START_TEST(test_hangul_ic_process_3f)
{
    /* L V T  */
    /* ㅎ     */
    fail_unless(check_preedit("3f", "m", L"ㅎ"));
    /*   ㅗ   */
    fail_unless(check_preedit("3f", "v", L"ㅗ"));
    /*     ㅌ */
    fail_unless(check_preedit("3f", "W", L"ㅌ"));

    /* ㄱㅏㅇ */
    fail_unless(check_preedit("3f", "kfa", L"강"));
    /* ㄹㅐ   */
    fail_unless(check_preedit("3f", "yr", L"래"));
    /* ㄴ  ㅁ */
    fail_unless(check_preedit("3f", "hz", L"\x1102\x1160\x11b7"));
    /*   ㅜㅅ */ 
    fail_unless(check_preedit("3f", "tq", L"\x115f\x1165\x11ba"));
}
コード例 #5
0
ファイル: view.c プロジェクト: Aseeker/leafpad
static gboolean cb_key_press_event(GtkWidget *view, GdkEventKey *event)
{
	GtkTextBuffer *buffer;
	GtkTextMark *mark;
	GtkTextIter iter;
	GdkRectangle prev_rect;
	
	if (check_preedit(view))
		return FALSE;
	
	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
	mark = gtk_text_buffer_get_insert(buffer);
	gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
	gtk_text_view_get_iter_location(GTK_TEXT_VIEW(view), &iter, &prev_rect);
	
	keyval = 0;
//g_print("key-press-event: 0x%X\n", event->keyval);
	switch (event->keyval) {
	case GDK_Up:		// Try [Shift]+[Down]. it works bad.
	case GDK_Down:
		if (gtk_text_view_move_mark_onscreen(GTK_TEXT_VIEW(view), mark)) {
			GdkRectangle iter_rect;
			gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
			gtk_text_view_get_iter_location(GTK_TEXT_VIEW(view), &iter, &iter_rect);
			if (iter_rect.y < prev_rect.y) {
				gtk_text_view_get_line_at_y(GTK_TEXT_VIEW(view), &iter,				
					iter_rect.y - iter_rect.height, NULL);
				gtk_text_buffer_move_mark(buffer, mark, &iter);
			}
			if (!(event->state & GDK_SHIFT_MASK)) {
				gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
				gtk_text_buffer_place_cursor(buffer, &iter);
			}
			return TRUE;
		}
		break;
	case GDK_Page_Up:
	case GDK_Page_Down:
		if (gtk_text_view_move_mark_onscreen(GTK_TEXT_VIEW(view), mark)) {
			GdkRectangle visible_rect, iter_rect;
			gint pos = 0;
			gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(view), &visible_rect);
			gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
			gtk_text_view_get_iter_location(GTK_TEXT_VIEW(view), &iter, &iter_rect);
			if (iter_rect.y < prev_rect.y)
				pos = 1;
			if (event->keyval == GDK_Page_Up)
				gtk_text_view_get_line_at_y(GTK_TEXT_VIEW(view), &iter,
					iter_rect.y - visible_rect.height + iter_rect.height, NULL);
			else
				gtk_text_view_get_line_at_y(GTK_TEXT_VIEW(view), &iter,
					iter_rect.y + visible_rect.height - iter_rect.height, NULL);
			gtk_text_buffer_move_mark(buffer, mark, &iter);
			gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(view),
				mark, 0, TRUE, 0, pos);
			if (!(event->state & GDK_SHIFT_MASK)) {
				gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark);
				gtk_text_buffer_place_cursor(GTK_TEXT_VIEW(view)->buffer, &iter);
			}
			return TRUE;
		}
		break;
	case GDK_Return:
		if (indent_get_state()) {
			indent_real(view);
			return TRUE;
		}
		break;
	case GDK_Tab:
		if (event->state & GDK_CONTROL_MASK) {
			indent_toggle_tab_width(view);
			return TRUE;
		}
	case GDK_ISO_Left_Tab:
		if (event->state & GDK_SHIFT_MASK)
			indent_multi_line_unindent(GTK_TEXT_VIEW(view)->buffer);
		else if (!check_selection_bound(GTK_TEXT_VIEW(view)->buffer))
			break;
		else
			indent_multi_line_indent(GTK_TEXT_VIEW(view)->buffer);
		return TRUE;
	}
	keyval = event->keyval;
	if ((event->state & GDK_CONTROL_MASK)
		|| (event->keyval == GDK_Control_L)
		|| (event->keyval == GDK_Control_R)) {
		keyval = keyval + 0x10000;
//g_print("=================================================\n");
	}
	
	return FALSE;
}
コード例 #6
0
ファイル: test.c プロジェクト: choehwanjin/libhangul
END_TEST

START_TEST(test_hangul_ic_combi_on_double_stroke)
{
    bool val = get_ic_option(HANGUL_IC_OPTION_COMBI_ON_DOUBLE_STROKE);

    set_ic_option(HANGUL_IC_OPTION_COMBI_ON_DOUBLE_STROKE, true);
    fail_unless(check_preedit("2", "rrkrr", L"깎"));
    fail_unless(check_preedit("2", "rrkrrk", L"가"));

    /* ㅂㅓㅅㅅ */
    fail_unless(check_preedit("2", "qjtt", L"벘"));
    fail_unless(check_commit("2", "qjttm", L"벗"));
    fail_unless(check_preedit("2", "qjttm", L"스"));

    fail_unless(check_preedit("2", "rktt", L"갔"));
    fail_unless(check_preedit("2", "rktt\b", L"갓"));

    set_ic_option(HANGUL_IC_OPTION_COMBI_ON_DOUBLE_STROKE, false);
    fail_unless(check_commit("2", "rr", L"ㄱ"));
    fail_unless(check_preedit("2", "rr", L"ㄱ"));
    fail_unless(check_preedit("2", "rrk", L"가"));
    fail_unless(check_preedit("2", "rrkr", L"각"));
    fail_unless(check_commit("2", "rrkrr", L"각"));
    fail_unless(check_preedit("2", "rrkrr", L"ㄱ"));
    fail_unless(check_preedit("2", "rrkrrk", L"가"));

    /* ㅂㅓㅅㅅ */
    fail_unless(check_commit("2", "qjtt", L"벗"));
    fail_unless(check_preedit("2", "qjtt", L"ㅅ"));

    set_ic_option(HANGUL_IC_OPTION_COMBI_ON_DOUBLE_STROKE, val);
}
コード例 #7
0
ファイル: test.c プロジェクト: choehwanjin/libhangul
END_TEST

START_TEST(test_hangul_ic_process_2y)
{
    /* ㅎ     */
    fail_unless(check_preedit("2y", "g", L"ㅎ"));
    /*   ㅗ   */
    fail_unless(check_preedit("2y", "h", L"ㅗ"));
    /*     ㅌ */
    fail_unless(check_preedit("2y", "x", L"ㅌ"));
    /* ㅂㅇ   */
    fail_unless(check_preedit("2y", "qd", L"\x3178"));
    /* ᄼ     */
    fail_unless(check_preedit("2y", "Z", L"\x113c\x1160"));
    /* ᅐ     */
    fail_unless(check_preedit("2y", "V", L"\x1150\x1160"));
    /* ᅝ     */
    fail_unless(check_preedit("2y", "sg", L"\x115d\x1160"));

    /* ㄱㅏㅇ */
    fail_unless(check_preedit("2y", "rkd", L"강"));
    /* ㄹㅐ   */
    fail_unless(check_preedit("2y", "fo", L"래"));
    /* ㅎ. ㄴ */
    fail_unless(check_preedit("2y", "gKs", L"\x1112\x119e\x11ab"));
    /* ㅃㅇㅏㅁㅆ */
    fail_unless(check_preedit("2y", "QdhaT", L"\x112c\x1169\x11de"));
    /* ㅃㅇㅏㅁㅅㅅㅛ */
    fail_unless(check_commit("2y", "Qdhatty", L"\x112c\x1169\x11dd"));
    fail_unless(check_preedit("2y", "Qdhatty", L"쇼"));
    /* ㅃㅇㅏㅁㅆㅛ */
    fail_unless(check_commit("2y", "QdhaTy", L"\x112c\x1169\x11b7"));
    fail_unless(check_preedit("2y", "QdhaTy", L"쑈"));
    /* 옛이응 처리 */
    /* ㄱㅏㆁㆁ */
    fail_unless(check_preedit("2y", "rkDD", L"\x1100\x1161\x11ee"));
    /* ㄱㅏㆁㆁㅏ */
    fail_unless(check_commit("2y", "rkDDk", L"\x1100\x1161\x11f0"));
    fail_unless(check_preedit("2y", "rkDDk", L"\x114c\x1161"));


    bool val = get_ic_option(HANGUL_IC_OPTION_COMBI_ON_DOUBLE_STROKE);
    set_ic_option(HANGUL_IC_OPTION_COMBI_ON_DOUBLE_STROKE, true);

    /* ㅂㅂㅇㅏㅁㅅㅅ */
    fail_unless(check_preedit("2y", "qqdhatt", L"\x112c\x1169\x11de"));
    /* ㅂㅂㅇㅏㅁㅅㅅㅛ */
    fail_unless(check_commit("2y", "qqdhatty", L"\x112c\x1169\x11dd"));
    fail_unless(check_preedit("2y", "qqdhatty", L"쇼"));
    /* ㅂㅂㅇㅏㅁㅆㅛ */
    fail_unless(check_commit("2y", "qqdhaTy", L"\x112c\x1169\x11b7"));
    fail_unless(check_preedit("2y", "qqdhaTy", L"쑈"));

    /* ㅇㅇㅏㅇㅇㅏ */
    fail_unless(check_commit("2y", "ddkdd", L"\x1147\x1161\x11bc"));
    fail_unless(check_preedit("2y", "ddkdd", L"ㅇ"));

    /* ㅏㅏㅏㅏ */
    fail_unless(check_preedit("2y", "kkkk", L"\x115f\x11a2"));

    set_ic_option(HANGUL_IC_OPTION_COMBI_ON_DOUBLE_STROKE, val);
}