/** @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; }
/** @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; }
/** @brief Return the next phrase not longer than the previous phrase. */ int ChoiceNextAvail( ChewingData *pgdata ) { if (pgdata->choiceInfo.isSymbol) return 0; if ( --( pgdata->availInfo.currentAvail ) < 0 ) pgdata->availInfo.currentAvail = pgdata->availInfo.nAvail - 1; SetChoiceInfo( pgdata ); return 0; }
int ChoicePrevAvail( ChewingContext *ctx ) { ChewingData *pgdata = ctx->data; if (pgdata->choiceInfo.isSymbol) return 0; if ( ++( pgdata->availInfo.currentAvail ) >= pgdata->availInfo.nAvail ) pgdata->availInfo.currentAvail = 0; SetChoiceInfo( pgdata ); return 0; }
/** @brief Return the next phrase not longer than the previous phrase. */ int ChoiceNextAvail( ChewingData *pgdata ) { if (pgdata->choiceInfo.isSymbol) return 0; if ( --( pgdata->availInfo.currentAvail ) < 0 ) pgdata->availInfo.currentAvail = pgdata->availInfo.nAvail - 1; SetChoiceInfo( &( pgdata->choiceInfo ), &( pgdata->availInfo ), pgdata->phoneSeq, PhoneSeqCursor( pgdata ), pgdata->config.candPerPage ); return 0; }
int ChoiceLastAvail(ChewingData *pgdata) { assert(pgdata); assert(pgdata->bSelect); if (pgdata->choiceInfo.isSymbol != WORD_CHOICE) return 0; ChangeCurrentAvailInfo(pgdata, 0); SetChoiceInfo(pgdata); return 0; }
int ChoiceNextAvail(ChewingData *pgdata) { assert(pgdata); assert(pgdata->bSelect); if (!ChoiceHasNextAvail(pgdata)) { return -1; } ChangeCurrentAvailInfo(pgdata, pgdata->availInfo.currentAvail - 1); SetChoiceInfo(pgdata); return 0; }