Author: winesync Date: Fri Jul 27 14:05:21 2007 New Revision: 27917
URL: http://svn.reactos.org/svn/reactos?rev=27917&view=rev Log: Autosyncing with Wine HEAD
Modified: trunk/reactos/dll/win32/riched20/caret.c trunk/reactos/dll/win32/riched20/editor.c trunk/reactos/dll/win32/riched20/editstr.h trunk/reactos/dll/win32/riched20/reader.c trunk/reactos/dll/win32/riched20/riched20.rbuild trunk/reactos/dll/win32/riched20/string.c trunk/reactos/dll/win32/riched20/txtsrv.c
Modified: trunk/reactos/dll/win32/riched20/caret.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/caret.c?... ============================================================================== --- trunk/reactos/dll/win32/riched20/caret.c (original) +++ trunk/reactos/dll/win32/riched20/caret.c Fri Jul 27 14:05:21 2007 @@ -232,21 +232,28 @@
ME_WrapMarkedParagraphs(editor); ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height); - CreateCaret(editor->hWnd, NULL, 0, height); - SetCaretPos(x, y); + if(editor->bHaveFocus) + { + CreateCaret(editor->hWnd, NULL, 0, height); + SetCaretPos(x, y); + } }
void ME_ShowCaret(ME_TextEditor *ed) { ME_MoveCaret(ed); - ShowCaret(ed->hWnd); + if(ed->bHaveFocus) + ShowCaret(ed->hWnd); }
void ME_HideCaret(ME_TextEditor *ed) { - HideCaret(ed->hWnd); - DestroyCaret(); + if(ed->bHaveFocus) + { + HideCaret(ed->hWnd); + DestroyCaret(); + } }
void ME_InternalDeleteText(ME_TextEditor *editor, int nOfs, @@ -366,6 +373,8 @@ int nChars) { assert(nCursor>=0 && nCursor<editor->nCursors); + /* text operations set modified state */ + editor->nModifyStep = 1; ME_InternalDeleteText(editor, ME_GetCursorOfs(editor, nCursor), nChars); }
Modified: trunk/reactos/dll/win32/riched20/editor.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/editor.c... ============================================================================== --- trunk/reactos/dll/win32/riched20/editor.c (original) +++ trunk/reactos/dll/win32/riched20/editor.c Fri Jul 27 14:05:21 2007 @@ -66,7 +66,7 @@ + EM_GETSELTEXT (ANSI&Unicode) + EM_GETSCROLLPOS 3.0 (only Y value valid) ! - EM_GETTHUMB - - EM_GETTEXTEX 2.0 + + EM_GETTEXTEX 2.0 + EM_GETTEXTLENGTHEX (GTL_PRECISE unimplemented) - EM_GETTEXTMODE 2.0 ? + EM_GETTEXTRANGE (ANSI&Unicode) @@ -114,7 +114,7 @@ + EM_SETSCROLLPOS 3.0 - EM_SETTABSTOPS 3.0 - EM_SETTARGETDEVICE - + EM_SETTEXTEX 3.0 (unicode only, no rich text insertion handling, proper style?) + + EM_SETTEXTEX 3.0 (no rich text insertion handling, proper style?) - EM_SETTEXTMODE 2.0 - EM_SETTYPOGRAPHYOPTIONS 3.0 + EM_SETUNDOLIMIT 2.0 @@ -226,9 +226,8 @@ #include "winreg.h" #define NO_SHLWAPI_STREAM #include "shlwapi.h" +#include "rtf.h" #include "imm.h" -#include "textserv.h" -#include "rtf.h"
#define STACK_SIZE_DEFAULT 100 #define STACK_SIZE_MAX 1000 @@ -1155,6 +1154,7 @@ ed->lpOleCallback = NULL; ed->mode = TM_RICHTEXT | TM_MULTILEVELUNDO | TM_MULTICODEPAGE; ed->AutoURLDetect_bEnable = FALSE; + ed->bHaveFocus = FALSE; GetClientRect(hWnd, &ed->rcFormat); for (i=0; i<HFONT_CACHE_SIZE; i++) { @@ -1418,7 +1418,7 @@ { ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(hWnd, 0);
- TRACE("hwnd %p msg %04x (%s) %x %lx, unicode %d\n", + TRACE("hwnd %p msg %04x (%s) %lx %lx, unicode %d\n", hWnd, msg, get_msg_name(msg), wParam, lParam, unicode);
if (!editor && msg != WM_NCCREATE && msg != WM_NCDESTROY) { @@ -1520,7 +1520,7 @@ editor->nUndoLimit = min(wParam, STACK_SIZE_MAX); /* Setting a max stack size keeps wine from getting killed for hogging memory. Windows allocates all this memory at once, so - no program would realistically set a value above our maxiumum. */ + no program would realistically set a value above our maximum. */ return editor->nUndoLimit; } case EM_CANUNDO: @@ -1635,17 +1635,23 @@ } case EM_SETTEXTEX: { - LPWSTR wszText = (LPWSTR)lParam; + LPWSTR wszText; SETTEXTEX *pStruct = (SETTEXTEX *)wParam; - size_t len = wszText ? lstrlenW(wszText) : 0; + size_t len; int from, to; ME_Style *style; int oldModify = editor->nModifyStep; - TRACE("EM_SETTEXTEX - %s, flags %d, cp %d\n", debugstr_w(wszText), (int)pStruct->flags, pStruct->codepage); - if (pStruct->codepage != 1200) { - FIXME("EM_SETTEXTEX only supports unicode right now!\n"); - return 0; - } + + if (!pStruct) return 0; + + TRACE("EM_SETTEXTEX - %s, flags %d, cp %d\n", + pStruct->codepage == 1200 ? debugstr_w((LPCWSTR)lParam) : debugstr_a((LPCSTR)lParam), + pStruct->flags, pStruct->codepage); + + /* FIXME: make use of pStruct->codepage in the to unicode translation */ + wszText = lParam ? ME_ToUnicode(pStruct->codepage == 1200, (void *)lParam) : NULL; + len = wszText ? lstrlenW(wszText) : 0; + /* FIXME: this should support RTF strings too, according to MSDN */ if (pStruct->flags & ST_SELECTION) { ME_GetSelection(editor, &from, &to); @@ -2001,7 +2007,7 @@ nStart = 0; nCount = ex->cb - 1; } - if (ex->codepage == 1200 || unicode) + if (ex->codepage == 1200) { nCount = min(nCount, ex->cb / sizeof(WCHAR) - 1); return ME_GetTextW(editor, (LPWSTR)lParam, nStart, nCount, ex->flags & GT_USECRLF); @@ -2018,6 +2024,7 @@
buflen = ME_GetTextW(editor, buffer, nStart, nCount, ex->flags & GT_USECRLF); rc = WideCharToMultiByte(ex->codepage, flags, buffer, -1, (LPSTR)lParam, ex->cb, ex->lpDefaultChar, ex->lpUsedDefaultChar); + if (rc) rc--; /* do not count 0 terminator */
richedit_free(buffer); return rc; @@ -2183,7 +2190,7 @@ nNextLineOfs = ME_FindItemFwd(item, diParagraphOrEnd)->member.para.nCharOfs - (editor->bEmulateVersion10?2:1); nChars = nNextLineOfs - nThisLineOfs; - TRACE("EM_LINELENGTH(%d)==%d\n",wParam, nChars); + TRACE("EM_LINELENGTH(%ld)==%d\n",wParam, nChars); return nChars; } case EM_EXLIMITTEXT: @@ -2330,11 +2337,13 @@ } break; case WM_SETFOCUS: + editor->bHaveFocus = TRUE; ME_ShowCaret(editor); ME_SendOldNotify(editor, EN_SETFOCUS); return 0; case WM_KILLFOCUS: ME_HideCaret(editor); + editor->bHaveFocus = FALSE; ME_SendOldNotify(editor, EN_KILLFOCUS); return 0; case WM_ERASEBKGND: @@ -2507,6 +2516,64 @@ ME_RewrapRepaint(editor); return DefWindowProcW(hWnd, msg, wParam, lParam); } + /* IME messages to make richedit controls IME aware */ + case WM_IME_SETCONTEXT: + case WM_IME_CONTROL: + case WM_IME_SELECT: + case WM_IME_COMPOSITIONFULL: + return 0; + case WM_IME_STARTCOMPOSITION: + { + editor->imeStartIndex=ME_GetCursorOfs(editor,0); + ME_DeleteSelection(editor); + ME_CommitUndo(editor); + ME_UpdateRepaint(editor); + return 0; + } + case WM_IME_COMPOSITION: + { + HIMC hIMC; + + ME_Style *style = ME_GetInsertStyle(editor, 0); + hIMC = ImmGetContext(hWnd); + ME_DeleteSelection(editor); + ME_CommitUndo(editor); + ME_SaveTempStyle(editor); + if (lParam & GCS_RESULTSTR) + { + LPWSTR lpCompStr = NULL; + DWORD dwBufLen; + + dwBufLen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0); + lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR)); + ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpCompStr, dwBufLen); + lpCompStr[dwBufLen/sizeof(WCHAR)] = 0; + ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style); + } + else if (lParam & GCS_COMPSTR) + { + LPWSTR lpCompStr = NULL; + DWORD dwBufLen; + + dwBufLen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0); + lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR)); + ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, dwBufLen); + lpCompStr[dwBufLen/sizeof(WCHAR)] = 0; + + ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style); + ME_SetSelection(editor,editor->imeStartIndex, + editor->imeStartIndex + dwBufLen/sizeof(WCHAR)); + } + ME_ReleaseStyle(style); + ME_UpdateRepaint(editor); + return 0; + } + case WM_IME_ENDCOMPOSITION: + { + ME_DeleteSelection(editor); + editor->imeStartIndex=-1; + return 0; + } case EM_GETOLEINTERFACE: { LPVOID *ppvObj = (LPVOID*) lParam; @@ -2789,14 +2856,14 @@
LRESULT WINAPI REComboWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { /* FIXME: Not implemented */ - TRACE("hWnd %p msg %04x (%s) %08x %08lx\n", + TRACE("hWnd %p msg %04x (%s) %08lx %08lx\n", hWnd, msg, get_msg_name(msg), wParam, lParam); return DefWindowProcW(hWnd, msg, wParam, lParam); }
LRESULT WINAPI REListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { /* FIXME: Not implemented */ - TRACE("hWnd %p msg %04x (%s) %08x %08lx\n", + TRACE("hWnd %p msg %04x (%s) %08lx %08lx\n", hWnd, msg, get_msg_name(msg), wParam, lParam); return DefWindowProcW(hWnd, msg, wParam, lParam); }
Modified: trunk/reactos/dll/win32/riched20/editstr.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/editstr.... ============================================================================== --- trunk/reactos/dll/win32/riched20/editstr.h (original) +++ trunk/reactos/dll/win32/riched20/editstr.h Fri Jul 27 14:05:21 2007 @@ -321,6 +321,9 @@ BOOL bHideSelection; BOOL AutoURLDetect_bEnable; WCHAR cPasswordMask; + BOOL bHaveFocus; + /*for IME */ + int imeStartIndex; } ME_TextEditor;
typedef struct tagME_Context
Modified: trunk/reactos/dll/win32/riched20/reader.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/reader.c... ============================================================================== --- trunk/reactos/dll/win32/riched20/reader.c (original) +++ trunk/reactos/dll/win32/riched20/reader.c Fri Jul 27 14:05:21 2007 @@ -2682,7 +2682,7 @@ RTFFlushCPOutputBuffer(RTF_Info *info) { int bufferMax = info->dwCPOutputCount * 2 * sizeof(WCHAR); - WCHAR *buffer = (WCHAR *)RTFAlloc(bufferMax); + WCHAR *buffer = RTFAlloc(bufferMax); int length;
length = MultiByteToWideChar(info->codePage, 0, info->cpOutputBuffer,
Modified: trunk/reactos/dll/win32/riched20/riched20.rbuild URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/riched20... ============================================================================== --- trunk/reactos/dll/win32/riched20/riched20.rbuild (original) +++ trunk/reactos/dll/win32/riched20/riched20.rbuild Fri Jul 27 14:05:21 2007 @@ -10,6 +10,7 @@ <define name="WINVER">0x501</define> <library>wine</library> <library>ole32</library> + <library>imm32</library> <library>user32</library> <library>gdi32</library> <library>kernel32</library>
Modified: trunk/reactos/dll/win32/riched20/string.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/string.c... ============================================================================== --- trunk/reactos/dll/win32/riched20/string.c (original) +++ trunk/reactos/dll/win32/riched20/string.c Fri Jul 27 14:05:21 2007 @@ -130,7 +130,7 @@
s = ME_MakeString(orig->szData+charidx); orig->nLen = charidx; - orig->szData[charidx] = L'\0'; + orig->szData[charidx] = '\0'; return s; }
@@ -347,6 +347,8 @@
LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz) { + assert(psz != NULL); + if (unicode) return (LPWSTR)psz; else {
Modified: trunk/reactos/dll/win32/riched20/txtsrv.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/riched20/txtsrv.c... ============================================================================== --- trunk/reactos/dll/win32/riched20/txtsrv.c (original) +++ trunk/reactos/dll/win32/riched20/txtsrv.c Fri Jul 27 14:05:21 2007 @@ -28,7 +28,6 @@ #include "editor.h" #include "ole2.h" #include "richole.h" -#include "winreg.h" #include "imm.h" #include "textserv.h" #include "wine/debug.h"