rpms/libchewing/F-11 libchewing-0.3.2.phraseChoiceRearward.2.patch, NONE, 1.1 import.log, 1.17, 1.18 libchewing.spec, 1.39, 1.40 libchewing-0.3.2.phraseChoiceRearward.patch, 1.4, NONE

Ding-Yi Chen dchen at fedoraproject.org
Tue Feb 2 05:33:09 UTC 2010


Author: dchen

Update of /cvs/pkgs/rpms/libchewing/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv4020/F-11

Modified Files:
	import.log libchewing.spec 
Added Files:
	libchewing-0.3.2.phraseChoiceRearward.2.patch 
Removed Files:
	libchewing-0.3.2.phraseChoiceRearward.patch 
Log Message:
Revise phrase choice from rear logic

libchewing-0.3.2.phraseChoiceRearward.2.patch:
 chewingio.c |   56 ++++++++++++++++++-----------------
 choice.c    |   95 ++++++++++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 100 insertions(+), 51 deletions(-)

--- NEW FILE libchewing-0.3.2.phraseChoiceRearward.2.patch ---
diff -up ./src/chewingio.c.phraseChoiceRearward ./src/chewingio.c
--- ./src/chewingio.c.phraseChoiceRearward	2008-12-02 00:29:20.000000000 +1000
+++ ./src/chewingio.c	2010-02-02 15:17:13.000000000 +1000
@@ -20,6 +20,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <stdlib.h>
+#include <stdio.h>
 
 #include "chewing-utf8-util.h"
 #include "global.h"
@@ -100,6 +101,31 @@ int addTerminateService( void (*callback
 	return 1;
 }
 
+static void chooseCandidate(  ChewingContext *ctx, int toSelect, int key_buf_cursor )
+{
+	ChewingData *pgdata = ctx->data;
+	if ( toSelect ) {
+		if( ! pgdata->bSelect ) {
+			ChoiceFirstAvail( pgdata );
+		} else {
+			if ( pgdata->config.bPhraseChoiceRearward ){
+				int avail_willbe=(pgdata->availInfo.currentAvail > 0)?
+					pgdata->availInfo.currentAvail-1: pgdata->availInfo.nAvail - 1;
+				pgdata->chiSymbolCursor=pgdata->choiceInfo.oldChiSymbolCursor 
+					- pgdata->availInfo.avail[avail_willbe].len;
+				if (chewing_buffer_Len(ctx) > pgdata->choiceInfo.oldChiSymbolCursor){
+					pgdata->chiSymbolCursor++;
+				}
+			}
+			ChoiceNextAvail( pgdata );
+		}
+	} else if ( pgdata->symbolKeyBuf[ key_buf_cursor ] ) {
+		/* Open Symbol Choice List */
+		if( ! pgdata->choiceInfo.isSymbol )
+			OpenSymbolChoice( pgdata );
+	}
+}
+
 CHEWING_API ChewingContext *chewing_new()
 {
 	ChewingContext *ctx;
@@ -556,17 +582,7 @@ CHEWING_API int chewing_handle_Space( Ch
 				if ( ChewingIsChiAt( key_buf_cursor, pgdata ) )
 					toSelect = 1;
 
-				if ( toSelect ) {
-					if ( ! pgdata->bSelect )
-						ChoiceFirstAvail( pgdata );
-					else
-						ChoiceNextAvail( pgdata );
-				}
-				else if ( pgdata->symbolKeyBuf[ key_buf_cursor ] ) {
-					/* Open Symbol Choice List */
-					if( ! pgdata->choiceInfo.isSymbol )
-						OpenSymbolChoice( pgdata );
-				}
+				chooseCandidate( ctx, toSelect, key_buf_cursor );
 				break;
 		}
 	}
@@ -753,22 +769,10 @@ CHEWING_API int chewing_handle_Down( Che
 
 	/* see if to select */
 	if ( ChewingIsChiAt( key_buf_cursor, pgdata ) )
-			toSelect = 1;
-
-	if ( toSelect ) {
-		if( ! pgdata->bSelect ) {
-			ChoiceFirstAvail( pgdata );
-		}
-		else {
-			ChoiceNextAvail( pgdata );
-		}
-	} 
-	else if ( pgdata->symbolKeyBuf[ key_buf_cursor ] ) {
-		/* Open Symbol Choice List */
-		if ( ! pgdata->choiceInfo.isSymbol )
-			OpenSymbolChoice( pgdata );
-	}
+		toSelect = 1;
 
+	chooseCandidate( ctx, toSelect, key_buf_cursor );
+	
 	MakeOutputWithRtn( pgo, pgdata, keystrokeRtn );
 	return 0;
 }
diff -up ./src/choice.c.phraseChoiceRearward ./src/choice.c
--- ./src/choice.c.phraseChoiceRearward	2008-12-02 00:29:20.000000000 +1000
+++ ./src/choice.c	2010-02-02 15:18:02.000000000 +1000
@@ -71,22 +71,44 @@ 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[] )
+static void SetAvailInfo(
+		AvailInfo *pai, const uint16 phoneSeq[],
+		int nPhoneSeq, int begin, const int bSymbolArrBrkpt[],
+		ChewingData *pgdata,int end)
 {
-	int end, pho_id;
+	int pho_id;
 	int diff;
 	uint16 userPhoneSeq[ MAX_PHONE_SEQ_LEN ];
 
 	pai->nAvail = 0;
 
-	for ( end = begin; end < nPhoneSeq; end++ ) {
-		diff = end - begin;
-		if ( diff > 0 && bSymbolArrBrkpt[ end ] ) 
-			break;
+	int i,head,head_tmp;
+	if ( pgdata->config.bPhraseChoiceRearward ){
+	        for (i=end;i>=begin;i--){
+			head=i;
+			if(bSymbolArrBrkpt[i])
+				break;
+		}
+		head_tmp=end;
+	}else{
+		head_tmp=head=begin;
+	}
+
+	int tail,tail_tmp;
+	if ( pgdata->config.bPhraseChoiceRearward ){
+		tail_tmp=tail=end;
+	}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;
@@ -95,8 +117,8 @@ static void SetAvailInfo( 
 		}
 		else {
 			memcpy(
-				userPhoneSeq, 
-				&phoneSeq[ begin ], 
+				userPhoneSeq,
+				&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++;
+		}
 	}
 }
 
@@ -208,6 +236,21 @@ static void SetChoiceInfo(
 	pci->pageNo = 0;
 }
 
+/*
+ * Seek the start of the phrase (eng chars are skipped)
+ */
+static int SeekPhraseHead( ChewingData *pgdata ){
+	int i;
+	int phoneSeq=PhoneSeqCursor( pgdata );
+	for(i=pgdata->nPrefer-1; i>=0; i--){
+		if (pgdata->preferInterval[ i ].from > phoneSeq 
+			|| pgdata->preferInterval[ i ].to < phoneSeq )
+			continue;
+		return pgdata->preferInterval[ i ].from;
+	}
+	return 0;
+}
+
 /** @brief Enter choice mode and relating initialisations. */
 int ChoiceFirstAvail( ChewingData *pgdata )
 {
@@ -216,30 +259,32 @@ int ChoiceFirstAvail( ChewingData *pgdat
 
 	/* 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->chiSymbolCursor--;
 	}
+	int end=PhoneSeqCursor( pgdata );
+	if ( pgdata->config.bPhraseChoiceRearward ){
+		pgdata->chiSymbolCursor = SeekPhraseHead(pgdata)+ CountSymbols( pgdata, pgdata->chiSymbolCursor );
+       }
+	int begin=PhoneSeqCursor( pgdata );
 
 	pgdata->bSelect = 1;
-
-	SetAvailInfo( 
-		&( pgdata->availInfo ), 
-		pgdata->phoneSeq, 
+	SetAvailInfo(
+		&( pgdata->availInfo ),
+		pgdata->phoneSeq,
 		pgdata->nPhoneSeq,
-		PhoneSeqCursor( pgdata ),
-		pgdata->bSymbolArrBrkpt );
+		begin,
+		pgdata->bSymbolArrBrkpt,
+		pgdata,end);
 
 	if ( ! pgdata->availInfo.nAvail )
 		return ChoiceEndChoice( pgdata );
 
 	pgdata->availInfo.currentAvail = pgdata->availInfo.nAvail - 1;
 	SetChoiceInfo(
-		&( pgdata->choiceInfo ), 
-		&( pgdata->availInfo ), 
-		pgdata->phoneSeq, 
-		PhoneSeqCursor( pgdata ), 
+		&( pgdata->choiceInfo ),
+		&( pgdata->availInfo ),
+		pgdata->phoneSeq,
+		PhoneSeqCursor( pgdata ),
 		pgdata->config.candPerPage );
 	return 0;
 }


Index: import.log
===================================================================
RCS file: /cvs/pkgs/rpms/libchewing/F-11/import.log,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -p -r1.17 -r1.18
--- import.log	5 Jan 2010 08:06:24 -0000	1.17
+++ import.log	2 Feb 2010 05:33:09 -0000	1.18
@@ -15,3 +15,4 @@ libchewing-0_3_2-14_fc11:F-11:libchewing
 libchewing-0_3_2-15_fc11:F-11:libchewing-0.3.2-15.fc11.src.rpm:1249275892
 libchewing-0_3_2-16_fc11:F-11:libchewing-0.3.2-16.fc11.src.rpm:1254274911
 libchewing-0_3_2-17_fc12:F-11:libchewing-0.3.2-17.fc12.src.rpm:1262678689
+libchewing-0_3_2-21_fc12:F-11:libchewing-0.3.2-21.fc12.src.rpm:1265088766


Index: libchewing.spec
===================================================================
RCS file: /cvs/pkgs/rpms/libchewing/F-11/libchewing.spec,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -p -r1.39 -r1.40
--- libchewing.spec	5 Jan 2010 08:06:24 -0000	1.39
+++ libchewing.spec	2 Feb 2010 05:33:09 -0000	1.40
@@ -2,7 +2,7 @@
 %define name_zh_TW %{im_name_zh_TW}函式庫
 Name:           libchewing
 Version:        0.3.2
-Release:        17%{?dist}
+Release:        21%{?dist}
 Summary:        Intelligent phonetic input method library for Traditional Chinese
 Summary(zh_TW): %{name_zh_TW}
 
@@ -20,7 +20,7 @@ Source:         http://chewing.csie.net/
 #Patch7: libchewing-0.3.0-9.bz200694.patch
 #Patch8: libchewing-0.3.0-11.bz195416.patch
 Patch9: libchewing-0.3.2.bz477690.patch
-Patch10: libchewing-0.3.2.phraseChoiceRearward.patch
+Patch10: libchewing-0.3.2.phraseChoiceRearward.2.patch
 Patch11: libchewing-0.3.2.chewing_zuin.patch
 
 %{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
@@ -130,6 +130,19 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Tue Feb 02 2010 Ding-Yi Chen <dchen at redhat dot com> - 0.3.2-21
+- Revised phrase choice from rear logic.
+  Thus update phraseChoiceRearward.patch as phraseChoiceRearward.2.patch
+- Resolves: #555192
+
+* Fri Jan 21 2010 Ding-Yi Chen <dchen at redhat dot com> - 0.3.2-20
+- Resolves: #555192
+- Fix for package wrangler.
+
+* Tue Jan 19 2010 Ding-Yi Chen <dchen at redhat dot com> - 0.3.2-18
+- Resolves: #555192
+- Fix for package wrangler.
+
 * Tue Jan 05 2010 Ding-Yi Chen <dchen at redhat dot com> - 0.3.2-17
 - Add zh_TW summary and description
 - Split out python binding into a subpackage.


--- libchewing-0.3.2.phraseChoiceRearward.patch DELETED ---



More information about the scm-commits mailing list