You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libchewing/libchewing-0.3.2.phraseChoi...

112 lines
3.1 KiB

diff -up ./src/chewingio.c.phraseChoiceRearward ./src/chewingio.c
--- ./src/chewingio.c.phraseChoiceRearward 2008-12-02 00:29:20.000000000 +1000
+++ ./src/chewingio.c 2009-05-18 18:02:15.000000000 +1000
@@ -740,6 +740,7 @@ CHEWING_API int chewing_handle_Down( Che
int toSelect = 0;
int keystrokeRtn = KEYSTROKE_ABSORB;
int key_buf_cursor;
+ static int cursor_last=-1;
CheckAndResetRange( pgdata );
@@ -757,9 +758,15 @@ CHEWING_API int chewing_handle_Down( Che
if ( toSelect ) {
if( ! pgdata->bSelect ) {
+ cursor_last=pgdata->chiSymbolCursor;
ChoiceFirstAvail( pgdata );
}
else {
+ if ( pgdata->config.bPhraseChoiceRearward ){
+ int avail_willbe=(pgdata->availInfo.currentAvail>0)?
+ pgdata->availInfo.currentAvail-1: pgdata->availInfo.nAvail - 1;
+ pgdata->chiSymbolCursor=cursor_last -pgdata->availInfo.avail[avail_willbe].len;
+ }
ChoiceNextAvail( pgdata );
}
}
diff -up ./src/choice.c.phraseChoiceRearward ./src/choice.c
--- ./src/choice.c.phraseChoiceRearward 2008-12-02 00:29:20.000000000 +1000
+++ ./src/choice.c 2009-05-18 17:56:32.000000000 +1000
@@ -73,20 +73,42 @@ static void ChangeSelectIntervalAndBreak
/** @brief Loading all possible phrases after the cursor from long to short into AvailInfo structure.*/
static void SetAvailInfo(
AvailInfo *pai, const uint16 phoneSeq[],
- int nPhoneSeq, int begin, const int bSymbolArrBrkpt[] )
+ int nPhoneSeq, int begin, const int bSymbolArrBrkpt[],
+ ChewingData *pgdata)
{
int end, pho_id;
int diff;
uint16 userPhoneSeq[ MAX_PHONE_SEQ_LEN ];
pai->nAvail = 0;
+
+ int i,head,head_tmp;
+ if ( pgdata->config.bPhraseChoiceRearward ){
+ for (i=nPhoneSeq-1;i>=begin;i--){
+ head=i;
+ if(bSymbolArrBrkpt[i])
+ break;
+ }
+ head_tmp=nPhoneSeq-1;
+ }else{
+ head_tmp=head=begin;
+ }
- for ( end = begin; end < nPhoneSeq; end++ ) {
- diff = end - begin;
- if ( diff > 0 && bSymbolArrBrkpt[ end ] )
- break;
+ int tail,tail_tmp;
+ if ( pgdata->config.bPhraseChoiceRearward ){
+ tail_tmp=tail=nPhoneSeq-1;
+ }else{
+ for (i=begin;i<nPhoneSeq;i++){
+ if(bSymbolArrBrkpt[i])
+ break;
+ tail=i;
+ }
+ tail_tmp=begin;
+ }
- pho_id = TreeFindPhrase( begin, end, phoneSeq );
+ while(head<=head_tmp && tail_tmp>=tail){
+ diff = tail_tmp - head_tmp;
+ pho_id = TreeFindPhrase( head_tmp, tail_tmp, phoneSeq );
if ( pho_id != -1 ) {
/* save it! */
pai->avail[ pai->nAvail ].len = diff + 1;
@@ -96,7 +118,7 @@ static void SetAvailInfo(
else {
memcpy(
userPhoneSeq,
- &phoneSeq[ begin ],
+ &phoneSeq[ head_tmp ],
sizeof( uint16 ) * ( diff + 1 ) ) ;
userPhoneSeq[ diff + 1 ] = 0;
if ( UserGetPhraseFirst( userPhoneSeq ) ) {
@@ -109,6 +131,12 @@ static void SetAvailInfo(
pai->avail[ pai->nAvail ].id = -1;
}
}
+
+ if ( pgdata->config.bPhraseChoiceRearward ){
+ head_tmp--;
+ }else{
+ tail_tmp++;
+ }
}
}
@@ -229,7 +257,8 @@ int ChoiceFirstAvail( ChewingData *pgdat
pgdata->phoneSeq,
pgdata->nPhoneSeq,
PhoneSeqCursor( pgdata ),
- pgdata->bSymbolArrBrkpt );
+ pgdata->bSymbolArrBrkpt,
+ pgdata);
if ( ! pgdata->availInfo.nAvail )
return ChoiceEndChoice( pgdata );