Sync edit.c with wine head.

svn path=/trunk/; revision=50955
This commit is contained in:
Timo Kreuzer
2011-03-02 13:13:10 +00:00
parent 97d2212a19
commit e12dbcd77d
2 changed files with 31 additions and 44 deletions
+30 -44
View File
@@ -426,8 +426,8 @@ static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta
/* The buffer has been expanded, create a new line and
insert it into the link list */
LINEDEF *new_line = HeapAlloc(GetProcessHeap(), 0, sizeof(LINEDEF));
if (new_line == NULL)
break;
if (new_line == NULL) // reactos r33509
break; // reactos r33509
new_line->next = previous_line->next;
previous_line->next = new_line;
current_line = new_line;
@@ -1109,8 +1109,7 @@ static void EDIT_LockBuffer(EDITSTATE *es)
if(textA)
{
HLOCAL hloc32W_new;
UINT countW_new = MultiByteToWideChar(CP_ACP, 0, textA, countA, NULL, 0);
TRACE("%d bytes translated to %d WCHARs\n", countA, countW_new);
UINT countW_new = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
if(countW_new > es->buffer_size + 1)
{
UINT alloc_size = ROUND_TO_GROW(countW_new * sizeof(WCHAR));
@@ -1125,14 +1124,11 @@ static void EDIT_LockBuffer(EDITSTATE *es)
else
WARN("FAILED! Will synchronize partially\n");
}
es->text = LocalLock(es->hloc32W);
MultiByteToWideChar(CP_ACP, 0, textA, -1, es->text, es->buffer_size + 1);
LocalUnlock(es->hloc32A);
}
/*TRACE("Locking 32-bit UNICODE buffer\n");*/
es->text = LocalLock(es->hloc32W);
if(textA)
{
MultiByteToWideChar(CP_ACP, 0, textA, countA, es->text, es->buffer_size + 1);
LocalUnlock(es->hloc32A);
}
else es->text = LocalLock(es->hloc32W);
}
if(es->flags & EF_APP_HAS_HANDLE) text_buffer_changed(es);
es->lock_count++;
@@ -1165,7 +1161,6 @@ static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
if (force || (es->lock_count == 1)) {
if (es->hloc32W) {
CHAR *textA = NULL; // ReactOS hacked!
UINT countA = 0;
UINT countW = get_text_length(es) + 1;
@@ -1190,13 +1185,9 @@ static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
else
WARN("FAILED! Will synchronize partially\n");
}
textA = LocalLock(es->hloc32A);
}
if(textA)
{
WideCharToMultiByte(CP_ACP, 0, es->text, countW, textA, countA, NULL, NULL);
LocalUnlock(es->hloc32A);
WideCharToMultiByte(CP_ACP, 0, es->text, countW,
LocalLock(es->hloc32A), countA, NULL, NULL);
LocalUnlock(es->hloc32A);
}
LocalUnlock(es->hloc32W);
@@ -2799,11 +2790,11 @@ static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, const INT *tabs)
es->tabs = NULL;
else {
es->tabs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
if (es->tabs == NULL)
if (es->tabs == NULL) // reactos r33503
{
es->tabs_count = 0;
return FALSE;
}
} // reactos r33503
memcpy(es->tabs, tabs, count * sizeof(INT));
}
return TRUE;
@@ -2847,8 +2838,8 @@ static BOOL EDIT_EM_Undo(EDITSTATE *es)
ulength = strlenW(es->undo_text);
utext = HeapAlloc(GetProcessHeap(), 0, (ulength + 1) * sizeof(WCHAR));
if (utext == NULL)
return FALSE;
if (utext == NULL) // reactos r33503
return FALSE; // reactos r33503
strcpyW(utext, es->undo_text);
@@ -2877,7 +2868,7 @@ static BOOL EDIT_EM_Undo(EDITSTATE *es)
* controls without ES_WANTRETURN would attempt to detect whether it is inside
* a dialog box or not.
*/
static BOOL EDIT_IsInsideDialog(EDITSTATE *es)
static inline BOOL EDIT_IsInsideDialog(EDITSTATE *es)
{
return (es->flags & EF_DIALOGMODE);
}
@@ -3109,11 +3100,7 @@ static void EDIT_WM_Command(EDITSTATE *es, INT code, INT id, HWND control)
*/
static void EDIT_WM_ContextMenu(EDITSTATE *es, INT x, INT y)
{
#ifdef __REACTOS__
HMENU menu = LoadMenuA(User32Instance, "EDITMENU");
#else
HMENU menu = LoadMenuA(user32_module, "EDITMENU");
#endif
HMENU popup = GetSubMenu(menu, 0);
UINT start = es->selection_start;
UINT end = es->selection_end;
@@ -3144,6 +3131,10 @@ static void EDIT_WM_ContextMenu(EDITSTATE *es, INT x, INT y)
y = rc.top + (rc.bottom - rc.top) / 2;
}
if (!(es->flags & EF_FOCUSED))
SetFocus(es->hwndSelf);
#ifdef __REACTOS__
selectedItem = TrackPopupMenu(popup, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, x, y, 0, es->hwndSelf, NULL);
// Added see Revision 43925 comments.
switch (selectedItem) {
@@ -3170,7 +3161,7 @@ static void EDIT_WM_ContextMenu(EDITSTATE *es, INT x, INT y)
ERR("unknown menu item, please report\n");
break;
}
#endif
DestroyMenu(menu);
}
@@ -3682,7 +3673,7 @@ static void EDIT_WM_SetFont(EDITSTATE *es, HFONT font, BOOL redraw)
EDIT_UpdateText(es, NULL, TRUE);
if (es->flags & EF_FOCUSED) {
DestroyCaret();
CreateCaret(es->hwndSelf, 0, 2, es->line_height);
CreateCaret(es->hwndSelf, 0, 1, es->line_height);
EDIT_SetCaretPos(es, es->selection_end,
es->flags & EF_AFTER_WRAP);
ShowCaret(es->hwndSelf);
@@ -4428,10 +4419,10 @@ static LRESULT EDIT_WM_Create(EDITSTATE *es, LPCWSTR name)
/*********************************************************************
*
* WM_DESTROY
* WM_NCDESTROY
*
*/
static LRESULT EDIT_WM_Destroy(EDITSTATE *es)
static LRESULT EDIT_WM_NCDestroy(EDITSTATE *es)
{
LINEDEF *pc, *pp;
@@ -4472,8 +4463,7 @@ static inline LRESULT DefWindowProcT(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
* The messages are in the order of the actual integer values
* (which can be found in include/windows.h)
*/
LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam, BOOL unicode )
LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode )
{
EDITSTATE *es = (EDITSTATE *)GetWindowLongPtrW( hwnd, 0 );
LRESULT result = 0;
@@ -4495,7 +4485,7 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
if (!es && msg != WM_NCCREATE)
return DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
if (es && (msg != WM_DESTROY)) EDIT_LockBuffer(es);
if (es && (msg != WM_NCDESTROY)) EDIT_LockBuffer(es);
switch (msg) {
case EM_GETSEL:
@@ -4570,13 +4560,9 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
break;
/* these messages missing from specs */
case WM_USER+15:
case 0x00bf:
case WM_USER+16:
case 0x00c0:
case WM_USER+19:
case 0x00c3:
case WM_USER+26:
case 0x00ca:
FIXME("undocumented message 0x%x, please report\n", msg);
result = DefWindowProcW(hwnd, msg, wParam, lParam);
@@ -4733,8 +4719,8 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
result = EDIT_WM_NCCreate(hwnd, (LPCREATESTRUCTW)lParam, unicode);
break;
case WM_DESTROY:
result = EDIT_WM_Destroy(es);
case WM_NCDESTROY:
result = EDIT_WM_NCDestroy(es);
es = NULL;
#ifdef __REACTOS__
NtUserSetWindowFNID(hwnd, FNID_DESTROY);
@@ -5058,10 +5044,10 @@ const struct builtin_class_descr EDIT_builtin_class =
CS_DBLCLKS | CS_PARENTDC, /* style */
EditWndProcA, /* procA */
EditWndProcW, /* procW */
#ifdef _WIN64
sizeof(EDITSTATE *), /* extra */
#else
#ifndef _WIN64
sizeof(EDITSTATE *) + sizeof(WORD), /* extra */
#else
sizeof(EDITSTATE *), /* extra */
#endif
IDC_IBEAM, /* cursor */
0 /* brush */
@@ -106,6 +106,7 @@
/* Internal Thread Data */
extern HINSTANCE User32Instance;
#define user32_module User32Instance
extern HINSTANCE hImmInstance;
/* Critical Section*/