コード例 #1
0
ファイル: choice.c プロジェクト: shaform/ibus-freearray
int ChoiceEndChoice( ChewingData *pgdata )
{
	pgdata->bSelect = 0;
	pgdata->choiceInfo.nTotalChoice = 0;
	pgdata->choiceInfo.nPage = 0;
#ifdef FAFT_CHEWING
	/* This is really strange */
	if ( pgdata->choiceInfo.isSymbol != 1 && pgdata->choiceInfo.isSymbol != 2 ) {
#else
	if ( pgdata->choiceInfo.isSymbol != 1 || pgdata->choiceInfo.isSymbol != 2 ) {
#endif
		/* return to the old chiSymbolCursor position */
		pgdata->chiSymbolCursor = pgdata->choiceInfo.oldChiSymbolCursor;
	}
	pgdata->choiceInfo.isSymbol = 0;
	return 0;
}

#ifndef FAFT_CHEWING
static void ChangeUserData( ChewingData *pgdata, int selectNo )
{
	uint16 userPhoneSeq[ MAX_PHONE_SEQ_LEN ];
	int len;

	len = ueStrLen( pgdata->choiceInfo.totalChoiceStr[ selectNo ] ); 
	memcpy(
		userPhoneSeq, 
		&( pgdata->phoneSeq[ PhoneSeqCursor( pgdata ) ] ), 
		len * sizeof( uint16 ) );
	userPhoneSeq[ len ] = 0;
	UserUpdatePhrase( userPhoneSeq, pgdata->choiceInfo.totalChoiceStr[ selectNo ] );
}
コード例 #2
0
ファイル: choice.c プロジェクト: Brli/libchewing
static void ChangeUserData(ChewingData *pgdata, int selectNo)
{
    uint16_t userPhoneSeq[MAX_PHONE_SEQ_LEN];
    int len;

    len = ueStrLen(pgdata->choiceInfo.totalChoiceStr[selectNo]);
    memcpy(userPhoneSeq, &(pgdata->phoneSeq[PhoneSeqCursor(pgdata)]), len * sizeof(uint16_t));
    userPhoneSeq[len] = 0;
    UserUpdatePhrase(pgdata, userPhoneSeq, pgdata->choiceInfo.totalChoiceStr[selectNo]);
}
コード例 #3
0
ファイル: chewingio.c プロジェクト: shaform/ibus-freearray
CHEWING_API int chewing_handle_CtrlNum( ChewingContext *ctx, int key )
{
	ChewingData *pgdata = ctx->data;
	ChewingOutput *pgo = ctx->output;
	int keystrokeRtn = KEYSTROKE_ABSORB;
	int newPhraseLen;
	int i;
	uint16 addPhoneSeq[ MAX_PHONE_SEQ_LEN ];
	char addWordSeq[ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ];
	int phraseState;
	int cursor;

	CheckAndResetRange( pgdata );

	if ( pgdata->bSelect )
		return 0;

	CallPhrasing( pgdata );
	newPhraseLen = key - '0';

	if ( key == '0' || key == '1' ) {
		pgdata->bSelect = 1;
		pgdata->choiceInfo.oldChiSymbolCursor = pgdata->chiSymbolCursor;

		HaninSymbolInput(
				&( pgdata->choiceInfo ),
				&( pgdata->availInfo ),
				pgdata->phoneSeq,
				pgdata->config.candPerPage );
		CallPhrasing( pgdata );
		MakeOutputWithRtn( pgo, pgdata, keystrokeRtn );
		return 0;
	}

	cursor = PhoneSeqCursor( pgdata );
	if ( ! pgdata->config.bAddPhraseForward ) {
		if ( 
			newPhraseLen >= 1 && 
			cursor + newPhraseLen - 1 <= pgdata->nPhoneSeq ) {
			if ( NoSymbolBetween( 
				pgdata, 
				cursor, 
				cursor + newPhraseLen - 1 ) ) {
				/* Manually add phrase to the user phrase database. */
				memcpy( addPhoneSeq,
				        &pgdata->phoneSeq[ cursor ],
				        sizeof( uint16 ) * newPhraseLen );
				addPhoneSeq[ newPhraseLen ] = 0;
				ueStrNCpy( addWordSeq,
				           ueStrSeek( (char *) &pgdata->phrOut.chiBuf,
				                      cursor ),
				           newPhraseLen, 1);


				phraseState = UserUpdatePhrase( addPhoneSeq, addWordSeq );
				SetUpdatePhraseMsg( 
					pgdata, 
					addWordSeq, 
					newPhraseLen, 
					phraseState );

				/* Clear the breakpoint between the New Phrase */
				for ( i = 1; i < newPhraseLen; i++ )
					pgdata->bUserArrBrkpt[ cursor + i ] = 0;
			}
		}
	}
	else {
		if ( 
			newPhraseLen >= 1 && 
			cursor - newPhraseLen >= 0 ) {
			if ( NoSymbolBetween( pgdata, 
			                      cursor, 
			                      cursor - newPhraseLen ) ) {
				/* Manually add phrase to the user phrase database. */
				memcpy( addPhoneSeq,
				        &pgdata->phoneSeq[ cursor - newPhraseLen ],
				        sizeof( uint16 ) * newPhraseLen );
				addPhoneSeq[ newPhraseLen ] = 0;
				ueStrNCpy( addWordSeq,
				           ueStrSeek( (char *) &pgdata->phrOut.chiBuf,
				           cursor - newPhraseLen ),
				           newPhraseLen, 1);

				phraseState = UserUpdatePhrase( addPhoneSeq, addWordSeq );
				SetUpdatePhraseMsg( 
					pgdata, 
					addWordSeq, 
					newPhraseLen, 
					phraseState );

				/* Clear the breakpoint between the New Phrase */
				for ( i = 1; i < newPhraseLen; i++ )
					pgdata->bUserArrBrkpt[ cursor - newPhraseLen + i ] = 0;
			}
		}
	}
	CallPhrasing( pgdata );
	MakeOutputWithRtn( pgo, pgdata, keystrokeRtn );
	MakeOutputAddMsgAndCleanInterval( pgo, pgdata );
	return 0;
}