示例#1
0
文件: choice.c 项目: bryanyuan2/citc
/** @brief Enter choice mode and relating initialisations. */
int ChoiceFirstAvail( ChewingData *pgdata )
{
	/* save old cursor position */
	pgdata->choiceInfo.oldChiSymbolCursor = pgdata->chiSymbolCursor;

	/* see if there is some word in the cursor position */
	if ( pgdata->chiSymbolBufLen == pgdata->chiSymbolCursor ) {
		if ( pgdata->config.bPhraseChoiceRearward )
			pgdata->chiSymbolCursor = pgdata->preferInterval[ pgdata->nPrefer - 1 ].from + CountSymbols( pgdata, pgdata->chiSymbolBufLen );
		else
			pgdata->chiSymbolCursor--;
	}

	pgdata->bSelect = 1;

	SetAvailInfo( 
		&( pgdata->availInfo ), 
		pgdata->phoneSeq, 
		pgdata->nPhoneSeq,
		PhoneSeqCursor( pgdata ),
		pgdata->bSymbolArrBrkpt );

	if ( ! pgdata->availInfo.nAvail )
		return ChoiceEndChoice( pgdata );

	pgdata->availInfo.currentAvail = pgdata->availInfo.nAvail - 1;
	SetChoiceInfo(
		&( pgdata->choiceInfo ), 
		&( pgdata->availInfo ), 
		pgdata->phoneSeq, 
		PhoneSeqCursor( pgdata ), 
		pgdata->config.candPerPage );
	return 0;
}
示例#2
0
文件: choice.c 项目: Brli/libchewing
/** @brief Enter choice mode and relating initialisations. */
int ChoiceInitAvail(ChewingData *pgdata)
{
    int end, begin;

    /* save old cursor position */
    pgdata->choiceInfo.oldChiSymbolCursor = pgdata->chiSymbolCursor;

    /* see if there is some word in the cursor position */
    if (pgdata->chiSymbolBufLen == pgdata->chiSymbolCursor) {
        pgdata->chiSymbolCursor--;
    }

    end = PhoneSeqCursor(pgdata);

    if (pgdata->config.bPhraseChoiceRearward) {
        pgdata->chiSymbolCursor = SeekPhraseHead(pgdata) + CountSymbols(pgdata, pgdata->chiSymbolCursor);
    }
    begin = PhoneSeqCursor(pgdata);

    pgdata->bSelect = 1;

    SetAvailInfo(pgdata, begin, end);

    if (!pgdata->availInfo.nAvail)
        return ChoiceEndChoice(pgdata);

    pgdata->availInfo.currentAvail = pgdata->availInfo.nAvail - 1;
    SetChoiceInfo(pgdata);
    return 0;
}
示例#3
0
CHEWING_API int chewing_handle_Esc( ChewingContext *ctx )
{
	ChewingData *pgdata = ctx->data;
	ChewingOutput *pgo = ctx->output;
	int keystrokeRtn = KEYSTROKE_ABSORB;

	CheckAndResetRange( pgdata );

	if ( ! ChewingIsEntering( pgdata ) ) {
		keystrokeRtn = KEYSTROKE_IGNORE;
	}
	else if ( pgdata->bSelect ) {
		ChoiceEndChoice( pgdata );
	}
	else if ( ZuinIsEntering( &( pgdata->zuinData ) ) ) {
		ZuinRemoveAll( &( pgdata->zuinData ) );
	}
	else if ( pgdata->config.bEscCleanAllBuf ) {
		CleanAllBuf( pgdata );
		pgo->nCommitStr = pgdata->chiSymbolBufLen;
	}

	MakeOutputWithRtn( pgo, pgdata, keystrokeRtn );
	return 0;
}
示例#4
0
/** @brief commit the selected phrase. */
int ChoiceSelect(ChewingData *pgdata, int selectNo)
{
    ChoiceInfo *pci = &(pgdata->choiceInfo);
    AvailInfo *pai = &(pgdata->availInfo);

    ChangeSelectIntervalAndBreakpoint(pgdata,
                                      PhoneSeqCursor(pgdata),
                                      PhoneSeqCursor(pgdata) + pai->avail[pai->currentAvail].len,
                                      pci->totalChoiceStr[selectNo]);
    ChoiceEndChoice(pgdata);
    return 0;
}