Fixed bug #6898 unable to move cursor within IME composition string.

git-svn-id: svn://10.0.0.236/trunk@39360 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
tague%netscape.com
1999-07-14 20:08:02 +00:00
parent 1a4c1a16ff
commit 7403cbdb59
2 changed files with 30 additions and 8 deletions

View File

@@ -2758,6 +2758,9 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
mIMECompClauseStringLength = 0;
}
if (lParam & GCS_CURSORPOS) {
mIMECursorPosition = ::ImmGetCompositionString(hIMEContext,GCS_CURSORPOS,NULL,0);
}
//
// This provides us with a composition string
//
@@ -3527,17 +3530,24 @@ nsWindow::MapDBCSAtrributeArrayToUnicodeOffsets(PRUint32* textRangeListLengthRes
// figure out the ranges from the compclause string
//
if (mIMECompClauseStringLength==0) {
*textRangeListLengthResult = 1;
*textRangeListResult = new nsTextRange[1];
*textRangeListLengthResult = 2;
*textRangeListResult = new nsTextRange[2];
(*textRangeListResult)[0].mStartOffset=0;
substringLength = ::MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,mIMECompositionString,
mIMECompositionStringLength,NULL,0);
(*textRangeListResult)[0].mEndOffset = substringLength-1;
(*textRangeListResult)[0].mEndOffset = substringLength;
(*textRangeListResult)[0].mRangeType = mIMEAttributeString[0];
substringLength = ::MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,mIMECompositionString,
mIMECursorPosition,NULL,0);
(*textRangeListResult)[0].mStartOffset=substringLength;
(*textRangeListResult)[0].mEndOffset = substringLength;
(*textRangeListResult)[0].mRangeType = NS_TEXTRANGE_CARETPOSITION;
} else {
*textRangeListLengthResult = 0;
for(i=0;i<(PRUint32)mIMECompClauseStringLength;i++) {
*textRangeListLengthResult = 1;
for(i=0;i<mIMECompClauseStringLength;i++) {
if (mIMECompClauseString[i]!=0x00)
(*textRangeListLengthResult)++;
}
@@ -3547,17 +3557,28 @@ nsWindow::MapDBCSAtrributeArrayToUnicodeOffsets(PRUint32* textRangeListLengthRes
//
*textRangeListResult = new nsTextRange[*textRangeListLengthResult];
//
// figure out the cursor position
//
substringLength = ::MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,mIMECompositionString,mIMECursorPosition,NULL,0);
(*textRangeListResult)[0].mStartOffset=substringLength;
(*textRangeListResult)[0].mEndOffset = substringLength;
(*textRangeListResult)[0].mRangeType = NS_TEXTRANGE_CARETPOSITION;
//
// iterate over the attributes and convert them into unicode
lastUnicodeOffset = 0;
lastMBCSOffset = 0;
rangePointer = 0;
for(i=0;i<(PRUint32)mIMECompClauseStringLength;i++) {
rangePointer = 1;
for(i=0;i<mIMECompClauseStringLength;i++) {
if (mIMECompClauseString[i]!=0) {
(*textRangeListResult)[rangePointer].mStartOffset = lastUnicodeOffset;
substringLength = ::MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,mIMECompositionString+lastMBCSOffset,
mIMECompClauseString[i]-lastMBCSOffset,NULL,0);
(*textRangeListResult)[rangePointer].mEndOffset = lastUnicodeOffset + substringLength -1;
(*textRangeListResult)[rangePointer].mEndOffset = lastUnicodeOffset + substringLength;
(*textRangeListResult)[rangePointer].mRangeType = mIMEAttributeString[mIMECompClauseString[i]-1];
lastUnicodeOffset+= substringLength;
lastMBCSOffset = mIMECompClauseString[i];

View File

@@ -249,6 +249,7 @@ protected:
char* mIMECompClauseString;
PRInt32 mIMECompClauseStringLength;
PRInt32 mIMECompClauseStringSize;
long mIMECursorPosition;
#if 1
BOOL mHaveDBCSLeadByte;