Autosyncing with Wine HEAD

svn path=/trunk/; revision=27917
This commit is contained in:
The Wine Synchronizer 2007-07-27 10:05:21 +00:00
parent 3f23ffe17b
commit 9bd259e856
7 changed files with 106 additions and 25 deletions

View file

@ -232,21 +232,28 @@ ME_MoveCaret(ME_TextEditor *editor)
ME_WrapMarkedParagraphs(editor); ME_WrapMarkedParagraphs(editor);
ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height); ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height);
CreateCaret(editor->hWnd, NULL, 0, height); if(editor->bHaveFocus)
SetCaretPos(x, y); {
CreateCaret(editor->hWnd, NULL, 0, height);
SetCaretPos(x, y);
}
} }
void ME_ShowCaret(ME_TextEditor *ed) void ME_ShowCaret(ME_TextEditor *ed)
{ {
ME_MoveCaret(ed); ME_MoveCaret(ed);
ShowCaret(ed->hWnd); if(ed->bHaveFocus)
ShowCaret(ed->hWnd);
} }
void ME_HideCaret(ME_TextEditor *ed) void ME_HideCaret(ME_TextEditor *ed)
{ {
HideCaret(ed->hWnd); if(ed->bHaveFocus)
DestroyCaret(); {
HideCaret(ed->hWnd);
DestroyCaret();
}
} }
void ME_InternalDeleteText(ME_TextEditor *editor, int nOfs, void ME_InternalDeleteText(ME_TextEditor *editor, int nOfs,
@ -366,6 +373,8 @@ void ME_DeleteTextAtCursor(ME_TextEditor *editor, int nCursor,
int nChars) int nChars)
{ {
assert(nCursor>=0 && nCursor<editor->nCursors); assert(nCursor>=0 && nCursor<editor->nCursors);
/* text operations set modified state */
editor->nModifyStep = 1;
ME_InternalDeleteText(editor, ME_GetCursorOfs(editor, nCursor), nChars); ME_InternalDeleteText(editor, ME_GetCursorOfs(editor, nCursor), nChars);
} }

View file

@ -66,7 +66,7 @@
+ EM_GETSELTEXT (ANSI&Unicode) + EM_GETSELTEXT (ANSI&Unicode)
+ EM_GETSCROLLPOS 3.0 (only Y value valid) + EM_GETSCROLLPOS 3.0 (only Y value valid)
! - EM_GETTHUMB ! - EM_GETTHUMB
- EM_GETTEXTEX 2.0 + EM_GETTEXTEX 2.0
+ EM_GETTEXTLENGTHEX (GTL_PRECISE unimplemented) + EM_GETTEXTLENGTHEX (GTL_PRECISE unimplemented)
- EM_GETTEXTMODE 2.0 - EM_GETTEXTMODE 2.0
? + EM_GETTEXTRANGE (ANSI&Unicode) ? + EM_GETTEXTRANGE (ANSI&Unicode)
@ -114,7 +114,7 @@
+ EM_SETSCROLLPOS 3.0 + EM_SETSCROLLPOS 3.0
- EM_SETTABSTOPS 3.0 - EM_SETTABSTOPS 3.0
- EM_SETTARGETDEVICE - 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_SETTEXTMODE 2.0
- EM_SETTYPOGRAPHYOPTIONS 3.0 - EM_SETTYPOGRAPHYOPTIONS 3.0
+ EM_SETUNDOLIMIT 2.0 + EM_SETUNDOLIMIT 2.0
@ -226,9 +226,8 @@
#include "winreg.h" #include "winreg.h"
#define NO_SHLWAPI_STREAM #define NO_SHLWAPI_STREAM
#include "shlwapi.h" #include "shlwapi.h"
#include "imm.h"
#include "textserv.h"
#include "rtf.h" #include "rtf.h"
#include "imm.h"
#define STACK_SIZE_DEFAULT 100 #define STACK_SIZE_DEFAULT 100
#define STACK_SIZE_MAX 1000 #define STACK_SIZE_MAX 1000
@ -1155,6 +1154,7 @@ ME_TextEditor *ME_MakeEditor(HWND hWnd) {
ed->lpOleCallback = NULL; ed->lpOleCallback = NULL;
ed->mode = TM_RICHTEXT | TM_MULTILEVELUNDO | TM_MULTICODEPAGE; ed->mode = TM_RICHTEXT | TM_MULTILEVELUNDO | TM_MULTICODEPAGE;
ed->AutoURLDetect_bEnable = FALSE; ed->AutoURLDetect_bEnable = FALSE;
ed->bHaveFocus = FALSE;
GetClientRect(hWnd, &ed->rcFormat); GetClientRect(hWnd, &ed->rcFormat);
for (i=0; i<HFONT_CACHE_SIZE; i++) for (i=0; i<HFONT_CACHE_SIZE; i++)
{ {
@ -1418,7 +1418,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
{ {
ME_TextEditor *editor = (ME_TextEditor *)GetWindowLongPtrW(hWnd, 0); 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); hWnd, msg, get_msg_name(msg), wParam, lParam, unicode);
if (!editor && msg != WM_NCCREATE && msg != WM_NCDESTROY) { if (!editor && msg != WM_NCCREATE && msg != WM_NCDESTROY) {
@ -1520,7 +1520,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
editor->nUndoLimit = min(wParam, STACK_SIZE_MAX); editor->nUndoLimit = min(wParam, STACK_SIZE_MAX);
/* Setting a max stack size keeps wine from getting killed /* Setting a max stack size keeps wine from getting killed
for hogging memory. Windows allocates all this memory at once, so 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; return editor->nUndoLimit;
} }
case EM_CANUNDO: case EM_CANUNDO:
@ -1635,17 +1635,23 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
} }
case EM_SETTEXTEX: case EM_SETTEXTEX:
{ {
LPWSTR wszText = (LPWSTR)lParam; LPWSTR wszText;
SETTEXTEX *pStruct = (SETTEXTEX *)wParam; SETTEXTEX *pStruct = (SETTEXTEX *)wParam;
size_t len = wszText ? lstrlenW(wszText) : 0; size_t len;
int from, to; int from, to;
ME_Style *style; ME_Style *style;
int oldModify = editor->nModifyStep; 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) { if (!pStruct) return 0;
FIXME("EM_SETTEXTEX only supports unicode right now!\n");
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 */ /* FIXME: this should support RTF strings too, according to MSDN */
if (pStruct->flags & ST_SELECTION) { if (pStruct->flags & ST_SELECTION) {
ME_GetSelection(editor, &from, &to); ME_GetSelection(editor, &from, &to);
@ -2001,7 +2007,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
nStart = 0; nStart = 0;
nCount = ex->cb - 1; nCount = ex->cb - 1;
} }
if (ex->codepage == 1200 || unicode) if (ex->codepage == 1200)
{ {
nCount = min(nCount, ex->cb / sizeof(WCHAR) - 1); nCount = min(nCount, ex->cb / sizeof(WCHAR) - 1);
return ME_GetTextW(editor, (LPWSTR)lParam, nStart, nCount, ex->flags & GT_USECRLF); return ME_GetTextW(editor, (LPWSTR)lParam, nStart, nCount, ex->flags & GT_USECRLF);
@ -2018,6 +2024,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
buflen = ME_GetTextW(editor, buffer, nStart, nCount, ex->flags & GT_USECRLF); 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); 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); richedit_free(buffer);
return rc; return rc;
@ -2183,7 +2190,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
nNextLineOfs = ME_FindItemFwd(item, diParagraphOrEnd)->member.para.nCharOfs nNextLineOfs = ME_FindItemFwd(item, diParagraphOrEnd)->member.para.nCharOfs
- (editor->bEmulateVersion10?2:1); - (editor->bEmulateVersion10?2:1);
nChars = nNextLineOfs - nThisLineOfs; nChars = nNextLineOfs - nThisLineOfs;
TRACE("EM_LINELENGTH(%d)==%d\n",wParam, nChars); TRACE("EM_LINELENGTH(%ld)==%d\n",wParam, nChars);
return nChars; return nChars;
} }
case EM_EXLIMITTEXT: case EM_EXLIMITTEXT:
@ -2330,11 +2337,13 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
} }
break; break;
case WM_SETFOCUS: case WM_SETFOCUS:
editor->bHaveFocus = TRUE;
ME_ShowCaret(editor); ME_ShowCaret(editor);
ME_SendOldNotify(editor, EN_SETFOCUS); ME_SendOldNotify(editor, EN_SETFOCUS);
return 0; return 0;
case WM_KILLFOCUS: case WM_KILLFOCUS:
ME_HideCaret(editor); ME_HideCaret(editor);
editor->bHaveFocus = FALSE;
ME_SendOldNotify(editor, EN_KILLFOCUS); ME_SendOldNotify(editor, EN_KILLFOCUS);
return 0; return 0;
case WM_ERASEBKGND: case WM_ERASEBKGND:
@ -2507,6 +2516,64 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
ME_RewrapRepaint(editor); ME_RewrapRepaint(editor);
return DefWindowProcW(hWnd, msg, wParam, lParam); 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: case EM_GETOLEINTERFACE:
{ {
LPVOID *ppvObj = (LPVOID*) lParam; LPVOID *ppvObj = (LPVOID*) lParam;
@ -2789,14 +2856,14 @@ static BOOL ME_RegisterEditorClass(HINSTANCE hInstance)
LRESULT WINAPI REComboWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { LRESULT WINAPI REComboWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
/* FIXME: Not implemented */ /* 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); hWnd, msg, get_msg_name(msg), wParam, lParam);
return DefWindowProcW(hWnd, msg, wParam, lParam); return DefWindowProcW(hWnd, msg, wParam, lParam);
} }
LRESULT WINAPI REListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { LRESULT WINAPI REListWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
/* FIXME: Not implemented */ /* 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); hWnd, msg, get_msg_name(msg), wParam, lParam);
return DefWindowProcW(hWnd, msg, wParam, lParam); return DefWindowProcW(hWnd, msg, wParam, lParam);
} }

View file

@ -321,6 +321,9 @@ typedef struct tagME_TextEditor
BOOL bHideSelection; BOOL bHideSelection;
BOOL AutoURLDetect_bEnable; BOOL AutoURLDetect_bEnable;
WCHAR cPasswordMask; WCHAR cPasswordMask;
BOOL bHaveFocus;
/*for IME */
int imeStartIndex;
} ME_TextEditor; } ME_TextEditor;
typedef struct tagME_Context typedef struct tagME_Context

View file

@ -2682,7 +2682,7 @@ static void
RTFFlushCPOutputBuffer(RTF_Info *info) RTFFlushCPOutputBuffer(RTF_Info *info)
{ {
int bufferMax = info->dwCPOutputCount * 2 * sizeof(WCHAR); int bufferMax = info->dwCPOutputCount * 2 * sizeof(WCHAR);
WCHAR *buffer = (WCHAR *)RTFAlloc(bufferMax); WCHAR *buffer = RTFAlloc(bufferMax);
int length; int length;
length = MultiByteToWideChar(info->codePage, 0, info->cpOutputBuffer, length = MultiByteToWideChar(info->codePage, 0, info->cpOutputBuffer,

View file

@ -10,6 +10,7 @@
<define name="WINVER">0x501</define> <define name="WINVER">0x501</define>
<library>wine</library> <library>wine</library>
<library>ole32</library> <library>ole32</library>
<library>imm32</library>
<library>user32</library> <library>user32</library>
<library>gdi32</library> <library>gdi32</library>
<library>kernel32</library> <library>kernel32</library>

View file

@ -130,7 +130,7 @@ ME_String *ME_VSplitString(ME_String *orig, int charidx)
s = ME_MakeString(orig->szData+charidx); s = ME_MakeString(orig->szData+charidx);
orig->nLen = charidx; orig->nLen = charidx;
orig->szData[charidx] = L'\0'; orig->szData[charidx] = '\0';
return s; return s;
} }
@ -347,6 +347,8 @@ ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code)
LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz) LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz)
{ {
assert(psz != NULL);
if (unicode) if (unicode)
return (LPWSTR)psz; return (LPWSTR)psz;
else { else {

View file

@ -28,7 +28,6 @@
#include "editor.h" #include "editor.h"
#include "ole2.h" #include "ole2.h"
#include "richole.h" #include "richole.h"
#include "winreg.h"
#include "imm.h" #include "imm.h"
#include "textserv.h" #include "textserv.h"
#include "wine/debug.h" #include "wine/debug.h"