From 203b861e2888fbbe51be9e9d49391d0736cef03b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hiunn-hu=C3=A9?= Date: Fri, 4 Apr 2014 22:50:15 +0800 Subject: [PATCH] Toggle space mode with shift-space This should fix #141 --- src/chewingio.c | 3 +++ test/test-bopomofo.c | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/chewingio.c b/src/chewingio.c index 9458f6dea..8825fe874 100644 --- a/src/chewingio.c +++ b/src/chewingio.c @@ -1727,6 +1727,9 @@ CHEWING_API int chewing_handle_ShiftSpace(ChewingContext *ctx) if (!pgdata->bSelect) { CheckAndResetRange(pgdata); } + + chewing_set_ShapeMode(ctx, 1 - chewing_get_ShapeMode(ctx)); + CallPhrasing(pgdata, 0); MakeOutputWithRtn(pgo, pgdata, keystrokeRtn); return 0; diff --git a/test/test-bopomofo.c b/test/test-bopomofo.c index aa999cbb5..fffe6fff7 100644 --- a/test/test-bopomofo.c +++ b/test/test-bopomofo.c @@ -1015,7 +1015,27 @@ void test_PageDown() void test_ShiftSpace() { - /* FIXME: Implement this. */ + ChewingContext *ctx; + int mode; + + ctx = chewing_new(); + start_testcase(ctx, fd); + + mode = chewing_get_ShapeMode(ctx); + ok(mode == HALFSHAPE_MODE, "mode shall be HALFSHAPE_MODE"); + + type_keystroke_by_string(ctx, ""); + mode = chewing_get_ShapeMode(ctx); + ok(mode == FULLSHAPE_MODE, "mode shall be FULLSHAPE_MODE"); + + type_keystroke_by_string(ctx, " "); + ok_commit_buffer(ctx, "\xE3\x80\x80"); /* Fullshape Space (U+3000) */ + + chewing_set_ChiEngMode(ctx, SYMBOL_MODE); + type_keystroke_by_string(ctx, "a"); + ok_commit_buffer(ctx, "\xEF\xBD\x81"); /* Fullshape a */ + + chewing_delete(ctx); } void test_Numlock_numeric_input()