本文整理汇总了C++中chewing_new函数的典型用法代码示例。如果您正苦于以下问题:C++ chewing_new函数的具体用法?C++ chewing_new怎么用?C++ chewing_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chewing_new函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_libchewing_googlecode_issue_473
void test_libchewing_googlecode_issue_473()
{
/* FIXME: Add const cause gcc warning */
static char *INPUT[] = {
"t<N->_ M1<N+>H[Ls3<L><N1>PL+Z]4<C1>&(^H*H<TT>Sc<N->P]!|<CB>-<C6>S<H><N1><C0>U<B>d}P!f<EN><N.><C7>V!U!w|4-=S<C1>b<N2>Q",
"wv<C0><C5><N9>$FIF<D><N4>B *<C2>E4*<C2>q)Kf)<SS><TT>4=<N5>%<R>mN4<EN>H<N9><N.>8s{XTD<N6>jZV(y3G`9<C6>JTy<B>J<C1>SNc<E>hC<SL><N/><R><C6>@an<C3><N7>wzF<C3>P*<N*><B>l<C3><N6>W<N*> $<SR><N.><N1><E><E><N0><N6>Y",
};
size_t i;
ChewingContext *ctx;
ctx = chewing_new();
start_testcase(ctx, fd);
chewing_set_maxChiSymbolLen(ctx, 16);
chewing_set_autoShiftCur(ctx, 1);
chewing_set_candPerPage(ctx, 9);
chewing_set_addPhraseDirection(ctx, 1);
chewing_set_spaceAsSelection(ctx, 1);
for (i = 0; i < ARRAY_SIZE(INPUT); ++i) {
chewing_Reset(ctx);
type_keystroke_by_string(ctx, INPUT[i]);
}
chewing_delete(ctx);
}
示例2: test_Backspace_in_select
void test_Backspace_in_select()
{
ChewingContext *ctx;
int ret;
ctx = chewing_new();
start_testcase(ctx, fd);
type_keystroke_by_string(ctx, "`<B>");
ok_candidate(ctx, NULL, 0);
type_keystroke_by_string(ctx, "hk4");
ret = chewing_cand_TotalChoice(ctx);
ok(ret == 0, "chewing_cand_TotalChoice() returns `%d' shall be `%d'", ret, 0);
type_keystroke_by_string(ctx, "<D>");
ret = chewing_cand_TotalChoice(ctx);
ok(ret > 0, "chewing_cand_TotalChoice() returns `%d' shall be greater than `%d'", ret, 0);
type_keystroke_by_string(ctx, "<B>");
ret = chewing_cand_TotalChoice(ctx);
ok(ret == 0, "chewing_cand_TotalChoice() returns `%d' shall be `%d'", ret, 0);
chewing_delete(ctx);
}
示例3: test_Capslock
void test_Capslock()
{
ChewingContext *ctx;
int mode;
ctx = chewing_new();
start_testcase(ctx, fd);
mode = chewing_get_ChiEngMode(ctx);
ok(mode == CHINESE_MODE, "mode shall be CHINESE_MODE");
type_keystroke_by_string(ctx, "ji"); /* ㄨㄛ */
ok_bopomofo_buffer(ctx, "\xe3\x84\xa8\xe3\x84\x9b" /* ㄨㄛ */ );
ok_preedit_buffer(ctx, "");
ok_commit_buffer(ctx, "");
type_keystroke_by_string(ctx, "<CB>");
mode = chewing_get_ChiEngMode(ctx);
ok(mode == SYMBOL_MODE, "mode shall change to SYMBOL_MODE");
ok_bopomofo_buffer(ctx, "");
ok_preedit_buffer(ctx, "");
ok_commit_buffer(ctx, "");
chewing_delete(ctx);
}
示例4: test_jk_selection
void test_jk_selection()
{
#if 0
FIXME: libchewing is broken in this case
ChewingContext *ctx;
int ret;
int i;
const int EXPECT_CAND_LEN[] = { 1, 2, 1, 1, 2, 1, 1 };
ctx = chewing_new();
start_testcase(ctx, fd);
type_keystroke_by_string(ctx, "`31hk4g4`31hk4g4`31" /* ,測試,測試, */ );
ret = chewing_cand_open(ctx);
ok(ret == 0, "chewing_cand_open() returns `%d' shall be `%d'", ret, 0);
for (i = ARRAY_SIZE(EXPECT_CAND_LEN) - 1; i >= 0; --i) {
ret = chewing_cand_TotalChoice(ctx);
ok(ret > 0, "chewing_cand_TotalChoice() returns `%d' shall be greater than `%d'", ret, 0);
ok_candidate_len(ctx, EXPECT_CAND_LEN[i]);
type_keystroke_by_string(ctx, "j");
}
for (i = 0; i < ARRAY_SIZE(EXPECT_CAND_LEN); ++i) {
ret = chewing_cand_TotalChoice(ctx);
ok(ret > 0, "chewing_cand_TotalChoice() returns `%d' shall be greater than `%d'", ret, 0);
ok_candidate_len(ctx, EXPECT_CAND_LEN[i]);
type_keystroke_by_string(ctx, "i");
}
chewing_delete(ctx);
#endif
}
示例5: test_select_candidate_4_bytes_utf8
void test_select_candidate_4_bytes_utf8()
{
ChewingContext *ctx;
clean_userphrase();
ctx = chewing_new();
start_testcase(ctx, fd);
chewing_set_maxChiSymbolLen(ctx, 16);
chewing_set_phraseChoiceRearward(ctx, 1);
chewing_set_autoShiftCur(ctx, 1);
type_keystroke_by_string(ctx, "2k62k6"); /* ㄉㄜˊ ㄉㄜˊ */
ok_preedit_buffer(ctx, "\xE5\xBE\x97\xE5\xBE\x97" /* 得得 */ );
type_keystroke_by_string(ctx, "<H>");
type_keystroke_by_string(ctx, "<D>8");
ok_preedit_buffer(ctx, "\xF0\xA2\x94\xA8\xE5\xBE\x97" /* 𢔨得 */ );
type_keystroke_by_string(ctx, "<D>8");
ok_preedit_buffer(ctx, "\xF0\xA2\x94\xA8\xF0\xA2\x94\xA8" /* 𢔨𢔨 */ );
chewing_delete(ctx);
}
示例6: test_Space_selection_word
void test_Space_selection_word()
{
ChewingContext *ctx;
char *buf;
int len;
clean_userphrase();
ctx = chewing_new();
start_testcase(ctx, fd);
chewing_set_spaceAsSelection(ctx, 1);
type_keystroke_by_string(ctx, "hk4g4<H>" /* 測試 */ );
type_keystroke_by_string(ctx, " "); /* open candidate window */
chewing_cand_Enumerate(ctx);
buf = chewing_cand_String(ctx);
len = ueStrLen(buf);
ok(len == 2, "candidate `%s' length `%d' shall be `%d'", buf, len, 2);
chewing_free(buf);
type_keystroke_by_string(ctx, " "); /* next candidate list */
chewing_cand_Enumerate(ctx);
buf = chewing_cand_String(ctx);
len = ueStrLen(buf);
ok(len == 1, "candidate `%s' length `%d' shall be `%d'", buf, len, 1);
chewing_free(buf);
type_keystroke_by_string(ctx, " "); /* next page */
ok(chewing_cand_CurrentPage(ctx) == 1, "current page shall be 1");
chewing_delete(ctx);
}
示例7: test_bopomofo_buffer
void test_bopomofo_buffer()
{
ChewingContext *ctx;
ctx = chewing_new();
start_testcase(ctx, fd);
type_keystroke_by_string(ctx, "1ul");
ok_bopomofo_buffer(ctx, "\xE3\x84\x85\xE3\x84\xA7\xE3\x84\xA0" /* ㄅㄧㄠ */ );
type_keystroke_by_string(ctx, " ");
ok_bopomofo_buffer(ctx, "");
type_keystroke_by_string(ctx, "ul");
ok_bopomofo_buffer(ctx, "\xE3\x84\xA7\xE3\x84\xA0" /* ㄧㄠ */ );
type_keystroke_by_string(ctx, " ");
ok_bopomofo_buffer(ctx, "");
type_keystroke_by_string(ctx, "3");
ok_bopomofo_buffer(ctx, "\xCB\x87" /* ˇ */ );
type_keystroke_by_string(ctx, " ");
ok_bopomofo_buffer(ctx, "");
chewing_delete(ctx);
}
示例8: test_set_spaceAsSelection
void test_set_spaceAsSelection()
{
ChewingContext *ctx;
int value;
int mode;
chewing_Init( 0, 0 );
ctx = chewing_new();
for ( value = 0; value < 2; ++value ) {
chewing_set_spaceAsSelection( ctx, value );
mode = chewing_get_spaceAsSelection( ctx );
ok( mode == value,
"spaceAsSelection `%d' shall be `%d'", mode, value );
chewing_set_spaceAsSelection( ctx, -1 );
mode = chewing_get_spaceAsSelection( ctx );
ok( mode == value,
"spaceAsSelection `%d' shall be `%d'", mode, value );
chewing_set_spaceAsSelection( ctx, 2 );
mode = chewing_get_spaceAsSelection( ctx );
ok( mode == value,
"spaceAsSelection `%d' shall be `%d'", mode, value );
}
chewing_delete( ctx );
chewing_Terminate();
}
示例9: test_set_escCleanAllBuf
void test_set_escCleanAllBuf()
{
ChewingContext *ctx;
int value;
int mode;
chewing_Init( 0, 0 );
ctx = chewing_new();
for ( value = 0; value < 2; ++value ) {
chewing_set_escCleanAllBuf( ctx, value );
mode = chewing_get_escCleanAllBuf( ctx );
ok( mode == value,
"escCleanAllBuf shall be `%d'", value );
chewing_set_escCleanAllBuf( ctx, -1 );
mode = chewing_get_escCleanAllBuf( ctx );
ok( mode == value,
"escCleanAllBuf shall be `%d'", value );
chewing_set_escCleanAllBuf( ctx, 2 );
mode = chewing_get_escCleanAllBuf( ctx );
ok( mode == value,
"escCleanAllBuf shall be `%d'", value );
}
chewing_delete( ctx );
chewing_Terminate();
}
示例10: QLabel
MainWindow::MainWindow()
{
this->_lblChewing = new QLabel();
this->_lblCommit = new QLabel();
this->_lblBuffer = new QLabel();
this->_lblAux = new QLabel();
this->_lblLine = new QLabel();
chewing_Init("/usr/share/chewing", ".");
this->_ct = chewing_new();
chewing_set_candPerPage(this->_ct, 9);
chewing_set_maxChiSymbolLen(this->_ct, 20);
chewing_set_escCleanAllBuf(this->_ct, 1);
QWidget* container = new QWidget;
QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget(new QLabel("Chewing symbol in buffer"));
layout->addWidget(this->_lblChewing);
layout->addWidget(new QLabel("Preedit buffer"));
layout->addWidget(this->_lblBuffer);
layout->addWidget(new QLabel("Commit output"));
layout->addWidget(this->_lblCommit);
layout->addWidget(new QLabel("Aux buffer"));
layout->addWidget(this->_lblAux);
layout->addWidget(new QLabel("Final output"));
layout->addWidget(this->_lblLine);
container->setLayout(layout);
this->setCentralWidget(container);
}
示例11: test_set_selKey
void test_set_selKey()
{
ChewingContext *ctx;
int *select_key;
chewing_Init( 0, 0 );
ctx = chewing_new();
chewing_set_maxChiSymbolLen( ctx, 16 );
// XXX: chewing_set_selKey shall accept const char *.
chewing_set_selKey( ctx,
ALTERNATE_SELECT_KEY, ARRAY_SIZE( ALTERNATE_SELECT_KEY ));
select_key = chewing_get_selKey( ctx );
ok( select_key, "chewing_get_selKey shall not return NULL" );
ok( !memcmp( select_key, ALTERNATE_SELECT_KEY,
sizeof( ALTERNATE_SELECT_KEY )),
"select key shall be ALTERNATE_SELECT_KEY");
type_keystroke_by_string( ctx, DATA.token );
ok_preedit_buffer( ctx, DATA.expected );
chewing_free( select_key );
chewing_delete( ctx );
chewing_Terminate();
}
示例12: test_set_candPerPage
void test_set_candPerPage()
{
const int VALUE[] = {
MIN_CAND_PER_PAGE,
MAX_CAND_PER_PAGE,
};
const int INVALID_VALUE[] = {
MIN_CAND_PER_PAGE - 1,
MAX_CAND_PER_PAGE + 1,
};
ChewingContext *ctx;
size_t i;
size_t j;
ctx = chewing_new();
start_testcase( ctx, fd );
for ( i = 0; i < ARRAY_SIZE( VALUE ); ++i ) {
chewing_set_candPerPage( ctx, VALUE[i] );
ok( chewing_get_candPerPage( ctx ) == VALUE[i],
"candPerPage shall be `%d'", VALUE[i] );
for ( j = 0; j < ARRAY_SIZE( INVALID_VALUE ); ++j ) {
// mode shall not change when set mode has invalid value.
chewing_set_candPerPage( ctx, INVALID_VALUE[j] );
ok( chewing_get_candPerPage( ctx ) == VALUE[i],
"candPerPage shall be `%d'", VALUE[i] );
}
}
chewing_delete( ctx );
}
示例13: test_set_ShapeMode
void test_set_ShapeMode()
{
const int VALUE[] = {
HALFSHAPE_MODE,
FULLSHAPE_MODE,
};
const int INVALID_VALUE[] = {
-1,
2,
};
ChewingContext *ctx;
size_t i;
size_t j;
ctx = chewing_new();
start_testcase( ctx, fd );
for ( i = 0; i < ARRAY_SIZE( VALUE ); ++i ) {
chewing_set_ShapeMode( ctx, VALUE[i] );
ok( chewing_get_ShapeMode( ctx ) == VALUE[i],
"ShapeMode shall be `%d'", VALUE[i] );
for ( j = 0; j < ARRAY_SIZE( INVALID_VALUE ); ++j ) {
// mode shall not change when set mode has invalid value.
chewing_set_ShapeMode( ctx, INVALID_VALUE[j] );
ok( chewing_get_ShapeMode( ctx ) == VALUE[i],
"ShapeMode shall be `%d'", VALUE[i] );
}
}
chewing_delete( ctx );
}
示例14: test_set_addPhraseDirection
void test_set_addPhraseDirection()
{
ChewingContext *ctx;
int value;
int mode;
ctx = chewing_new();
start_testcase( ctx, fd );
for ( value = 0; value < 2; ++value ) {
chewing_set_addPhraseDirection( ctx, value );
mode = chewing_get_addPhraseDirection( ctx );
ok( mode == value,
"addPhraseDirection `%d' shall be `%d'", mode, value );
chewing_set_addPhraseDirection( ctx, -1 );
mode = chewing_get_addPhraseDirection( ctx );
ok( mode == value,
"addPhraseDirection `%d' shall be `%d'", mode, value );
chewing_set_addPhraseDirection( ctx, 2 );
mode = chewing_get_addPhraseDirection( ctx );
ok( mode == value,
"addPhraseDirection `%d' shall be `%d'", mode, value );
}
chewing_delete( ctx );
}
示例15: test_Numlock_numeric_input
void test_Numlock_numeric_input()
{
const TestData NUMLOCK_INPUT[] = {
{"<N0>", "0"},
{"<N1>", "1"},
{"<N2>", "2"},
{"<N3>", "3"},
{"<N4>", "4"},
{"<N5>", "5"},
{"<N6>", "6"},
{"<N7>", "7"},
{"<N8>", "8"},
{"<N9>", "9"},
{"<N+>", "+"},
{"<N->", "-"},
{"<N*>", "*"},
{"<N/>", "/"},
{"<N.>", "."},
};
size_t i;
ChewingContext *ctx;
ctx = chewing_new();
start_testcase(ctx, fd);
chewing_set_maxChiSymbolLen(ctx, 16);
for (i = 0; i < ARRAY_SIZE(NUMLOCK_INPUT); ++i) {
type_keystroke_by_string(ctx, NUMLOCK_INPUT[i].token);
ok_commit_buffer(ctx, NUMLOCK_INPUT[i].expected);
}
chewing_delete(ctx);
}