[NEW_FEATURE] Process WM_IME_REQUEST message to support Windows IME.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@374 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-12-23 18:06:09 +00:00
parent aaccc02a2b
commit 0c6496f6b3
2 changed files with 80 additions and 1 deletions

View File

@ -253,6 +253,85 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
break; break;
} }
case WM_IME_REQUEST:
{
if (wParam == IMR_RECONVERTSTRING)
{
int textLength;
int selectSize;
char smallTextBuffer[128];
char * selectedStr = smallTextBuffer;
RECONVERTSTRING * reconvert = (RECONVERTSTRING *)lParam;
// does nothing with a rectangular selection
if (execute(SCI_SELECTIONISRECTANGLE, 0, 0))
return 0;
// get the codepage of the text
unsigned int codepage = execute(SCI_GETCODEPAGE);
// get the current text selection
CharacterRange range = getSelection();
if (range.cpMax == range.cpMin)
{
// no selection: select the current word instead
expandWordSelection();
range = getSelection();
}
selectSize = range.cpMax - range.cpMin;
// does nothing if still no luck with the selection
if (selectSize == 0)
return 0;
if (selectSize + 1 > sizeof(smallTextBuffer))
selectedStr = new char[selectSize + 1];
getText(selectedStr, range.cpMin, range.cpMax);
if (reconvert == NULL)
{
// convert the selection to Unicode, and get the number
// of bytes required for the converted text
textLength = sizeof(WCHAR) * ::MultiByteToWideChar(codepage, 0, selectedStr, selectSize, NULL, 0);
}
else
{
// convert the selection to Unicode, and store it at the end of the structure.
// Beware: For a Unicode IME, dwStrLen , dwCompStrLen, and dwTargetStrLen
// are TCHAR values, that is, character counts. The members dwStrOffset,
// dwCompStrOffset, and dwTargetStrOffset specify byte counts.
textLength = ::MultiByteToWideChar( codepage, 0,
selectedStr, selectSize,
(LPWSTR)((LPSTR)reconvert + sizeof(RECONVERTSTRING)),
reconvert->dwSize - sizeof(RECONVERTSTRING));
// fill the structure
reconvert->dwVersion = 0;
reconvert->dwStrLen = textLength;
reconvert->dwStrOffset = sizeof(RECONVERTSTRING);
reconvert->dwCompStrLen = textLength;
reconvert->dwCompStrOffset = 0;
reconvert->dwTargetStrLen = reconvert->dwCompStrLen;
reconvert->dwTargetStrOffset = reconvert->dwCompStrOffset;
textLength *= sizeof(WCHAR);
}
if (selectedStr != smallTextBuffer)
delete [] selectedStr;
// return the total length of the structure
return sizeof(RECONVERTSTRING) + textLength;
}
break;
}
case WM_VSCROLL : case WM_VSCROLL :
{ {
break; break;

View File

@ -323,7 +323,7 @@ void doException(Notepad_plus & notepad_plus_plus) {
printMsg(TEXT("Notepad++ will attempt to save any unsaved data. However, dataloss is very likely."), TEXT("Recovery initiating"), MB_OK | MB_ICONINFORMATION); printMsg(TEXT("Notepad++ will attempt to save any unsaved data. However, dataloss is very likely."), TEXT("Recovery initiating"), MB_OK | MB_ICONINFORMATION);
bool res = notepad_plus_plus.emergency(); bool res = notepad_plus_plus.emergency();
if (res) { if (res) {
printMsg(TEXT("Notepad++ was able to successfully recover some unsaved documents, or nothing to be saved could be found.\r\nYou can find the results at C:\\N++RECOV"), TEXT("Recovery success"), MB_OK | MB_ICONINFORMATION); printMsg(TEXT("Notepad++ was able to successfully recover some unsaved documents, or nothing to be saved could be found.\r\nYou can find the results at N++RECOV directory, located in your system temporary directory."), TEXT("Recovery success"), MB_OK | MB_ICONINFORMATION);
} else { } else {
printMsg(TEXT("Unfortunatly, Notepad++ was not able to save your work. We are sorry for any lost data."), TEXT("Recovery failure"), MB_OK | MB_ICONERROR); printMsg(TEXT("Unfortunatly, Notepad++ was not able to save your work. We are sorry for any lost data."), TEXT("Recovery failure"), MB_OK | MB_ICONERROR);
} }