ReactOS 0.4.15-dev-8109-gd7be748
editor.c File Reference
#include "editor.h"
#include "commdlg.h"
#include "winreg.h"
#include "shlwapi.h"
#include "rtf.h"
#include "imm.h"
#include "res.h"
Include dependency graph for editor.c:

Go to the source code of this file.

Classes

struct  tagME_RTFStringStreamStruct
 
struct  tagME_GlobalDestStruct
 
struct  paste_format
 

Macros

#define NONAMELESSUNION
 
#define NO_SHLWAPI_STREAM
 
#define STACK_SIZE_DEFAULT   100
 
#define STACK_SIZE_MAX   1000
 
#define TEXT_LIMIT_DEFAULT   32767
 
#define UNSUPPORTED_MSG(e)
 
#define MAX_PREFIX_LEN   9
 

Typedefs

typedef struct tagME_RTFStringStreamStruct ME_RTFStringStreamStruct
 
typedef struct tagME_GlobalDestStruct ME_GlobalDestStruct
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (richedit)
 
static BOOL ME_RegisterEditorClass (HINSTANCE)
 
static BOOL ME_UpdateLinkAttribute (ME_TextEditor *editor, ME_Cursor *start, int nChars)
 
static BOOL is_version_nt (void)
 
static ME_TextBufferME_MakeText (void)
 
static LRESULT ME_StreamInText (ME_TextEditor *editor, DWORD dwFormat, ME_InStream *stream, ME_Style *style)
 
static void ME_ApplyBorderProperties (RTF_Info *info, ME_BorderRect *borderRect, RTFBorder *borderDef)
 
void ME_RTFCharAttrHook (RTF_Info *info)
 
void ME_RTFParAttrHook (RTF_Info *info)
 
void ME_RTFTblAttrHook (RTF_Info *info)
 
void ME_RTFSpecialCharHook (RTF_Info *info)
 
static HRESULT insert_static_object (ME_TextEditor *editor, HENHMETAFILE hemf, HBITMAP hbmp, const SIZEL *sz)
 
static void ME_RTFReadShpPictGroup (RTF_Info *info)
 
static DWORD read_hex_data (RTF_Info *info, BYTE **out)
 
static void ME_RTFReadPictGroup (RTF_Info *info)
 
static void ME_RTFReadObjectGroup (RTF_Info *info)
 
static void ME_RTFReadParnumGroup (RTF_Info *info)
 
static void ME_RTFReadHook (RTF_Info *info)
 
void ME_StreamInFill (ME_InStream *stream)
 
static LRESULT ME_StreamIn (ME_TextEditor *editor, DWORD format, EDITSTREAM *stream, BOOL stripLastCR)
 
static DWORD CALLBACK ME_ReadFromRTFString (DWORD_PTR dwCookie, LPBYTE lpBuff, LONG cb, LONG *pcb)
 
static void ME_StreamInRTFString (ME_TextEditor *editor, BOOL selection, char *string)
 
static int ME_FindText (ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCHAR *text, CHARRANGE *chrgText)
 
static int ME_GetTextEx (ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText)
 
static int ME_GetTextRange (ME_TextEditor *editor, WCHAR *strText, const ME_Cursor *start, int nLen, BOOL unicode)
 
int set_selection (ME_TextEditor *editor, int to, int from)
 
static DWORD CALLBACK ME_ReadFromHGLOBALUnicode (DWORD_PTR dwCookie, LPBYTE lpBuff, LONG cb, LONG *pcb)
 
static DWORD CALLBACK ME_ReadFromHGLOBALRTF (DWORD_PTR dwCookie, LPBYTE lpBuff, LONG cb, LONG *pcb)
 
static HRESULT paste_rtf (ME_TextEditor *editor, FORMATETC *fmt, STGMEDIUM *med)
 
static HRESULT paste_text (ME_TextEditor *editor, FORMATETC *fmt, STGMEDIUM *med)
 
static HRESULT paste_emf (ME_TextEditor *editor, FORMATETC *fmt, STGMEDIUM *med)
 
static void init_paste_formats (void)
 
static BOOL paste_special (ME_TextEditor *editor, UINT cf, REPASTESPECIAL *ps, BOOL check_only)
 
static BOOL ME_Copy (ME_TextEditor *editor, const ME_Cursor *start, int nChars)
 
static BOOL copy_or_cut (ME_TextEditor *editor, BOOL cut)
 
static BOOL ME_FilterEvent (ME_TextEditor *editor, UINT msg, WPARAM *wParam, LPARAM *lParam)
 
static void ME_UpdateSelectionLinkAttribute (ME_TextEditor *editor)
 
static BOOL handle_enter (ME_TextEditor *editor)
 
static BOOL ME_KeyDown (ME_TextEditor *editor, WORD nKey)
 
static LRESULT ME_Char (ME_TextEditor *editor, WPARAM charCode, LPARAM flags, BOOL unicode)
 
static int ME_CalculateClickCount (ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
 
static BOOL is_link (ME_Run *run)
 
static BOOL ME_SetCursor (ME_TextEditor *editor)
 
static void ME_SetDefaultFormatRect (ME_TextEditor *editor)
 
static LONG ME_GetSelectionType (ME_TextEditor *editor)
 
static BOOL ME_ShowContextMenu (ME_TextEditor *editor, int x, int y)
 
ME_TextEditorME_MakeEditor (ITextHost *texthost, BOOL bEmulateVersion10)
 
void ME_DestroyEditor (ME_TextEditor *editor)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 
static int get_default_line_height (ME_TextEditor *editor)
 
static int calc_wheel_change (int *remain, int amount_per_click)
 
static const charget_msg_name (UINT msg)
 
static void ME_LinkNotify (ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
 
void ME_ReplaceSel (ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len)
 
static void ME_SetText (ME_TextEditor *editor, void *text, BOOL unicode)
 
static LRESULT ME_WmCreate (ME_TextEditor *editor, LPARAM lParam, BOOL unicode)
 
static LRESULT handle_EM_SETCHARFORMAT (ME_TextEditor *editor, WPARAM flags, const CHARFORMAT2W *fmt_in)
 
LRESULT ME_HandleMessage (ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode, HRESULT *phresult)
 
static BOOL create_windowed_editor (HWND hwnd, CREATESTRUCTW *create, BOOL emulate_10)
 
static LRESULT RichEditWndProc_common (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
 
static LRESULT WINAPI RichEditWndProcW (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT WINAPI RichEditWndProcA (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI RichEditANSIWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI RichEdit10ANSIWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
void ME_SendOldNotify (ME_TextEditor *editor, int nCode)
 
int ME_GetTextW (ME_TextEditor *editor, WCHAR *buffer, int buflen, const ME_Cursor *start, int srcChars, BOOL bCRLF, BOOL bEOP)
 
static LRESULT WINAPI REComboWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static LRESULT WINAPI REListWndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI REExtendedRegisterClass (void)
 
static int __cdecl wchar_comp (const void *key, const void *elem)
 
static BOOL isurlneutral (WCHAR c)
 
static BOOL ME_FindNextURLCandidate (ME_TextEditor *editor, const ME_Cursor *start, int nChars, ME_Cursor *candidate_min, ME_Cursor *candidate_max)
 
static BOOL ME_IsCandidateAnURL (ME_TextEditor *editor, const ME_Cursor *start, int nChars)
 

Variables

static const WCHAR REListBox20W [] = {'R','E','L','i','s','t','B','o','x','2','0','W', 0}
 
static const WCHAR REComboBox20W [] = {'R','E','C','o','m','b','o','B','o','x','2','0','W', 0}
 
static HCURSOR hLeft
 
BOOL me_debug = FALSE
 
HANDLE me_heap = NULL
 
static BOOL ME_ListBoxRegistered = FALSE
 
static BOOL ME_ComboBoxRegistered = FALSE
 
static const WCHAR rtfW [] = {'R','i','c','h',' ','T','e','x','t',' ','F','o','r','m','a','t',0}
 
static struct paste_format paste_formats []
 
static const char *const edit_messages []
 
static const char *const richedit_messages []
 

Macro Definition Documentation

◆ MAX_PREFIX_LEN

#define MAX_PREFIX_LEN   9

◆ NO_SHLWAPI_STREAM

#define NO_SHLWAPI_STREAM

Definition at line 232 of file editor.c.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 227 of file editor.c.

◆ STACK_SIZE_DEFAULT

#define STACK_SIZE_DEFAULT   100

Definition at line 246 of file editor.c.

◆ STACK_SIZE_MAX

#define STACK_SIZE_MAX   1000

Definition at line 247 of file editor.c.

◆ TEXT_LIMIT_DEFAULT

#define TEXT_LIMIT_DEFAULT   32767

Definition at line 249 of file editor.c.

◆ UNSUPPORTED_MSG

#define UNSUPPORTED_MSG (   e)
Value:
case e: \
FIXME(#e ": stub\n"); \
*phresult = S_FALSE; \
return 0;
#define e
Definition: ke_i.h:82
#define S_FALSE
Definition: winerror.h:2357

Definition at line 3593 of file editor.c.

Typedef Documentation

◆ ME_GlobalDestStruct

◆ ME_RTFStringStreamStruct

Function Documentation

◆ calc_wheel_change()

static int calc_wheel_change ( int remain,
int  amount_per_click 
)
inlinestatic

Definition at line 3280 of file editor.c.

3281{
3282 int change = amount_per_click * (float)*remain / WHEEL_DELTA;
3283 *remain -= WHEEL_DELTA * change / amount_per_click;
3284 return change;
3285}
static float(__cdecl *square_half_float)(float x
#define WHEEL_DELTA
Definition: treelist.c:99

Referenced by ME_HandleMessage().

◆ copy_or_cut()

static BOOL copy_or_cut ( ME_TextEditor editor,
BOOL  cut 
)
static

Definition at line 2364 of file editor.c.

2365{
2366 BOOL result;
2367 int offs, num_chars;
2368 int start_cursor = ME_GetSelectionOfs(editor, &offs, &num_chars);
2369 ME_Cursor *sel_start = &editor->pCursors[start_cursor];
2370
2371 if (cut && (editor->styleFlags & ES_READONLY))
2372 {
2374 return FALSE;
2375 }
2376
2377 num_chars -= offs;
2378 result = ME_Copy(editor, sel_start, num_chars);
2379 if (result && cut)
2380 {
2381 ME_InternalDeleteText(editor, sel_start, num_chars, FALSE);
2382 ME_CommitUndo(editor);
2383 ME_UpdateRepaint(editor, TRUE);
2384 }
2385 return result;
2386}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, int nChars, BOOL bForce)
Definition: caret.c:360
int ME_GetSelectionOfs(ME_TextEditor *editor, int *from, int *to)
Definition: caret.c:42
static BOOL ME_Copy(ME_TextEditor *editor, const ME_Cursor *start, int nChars)
Definition: editor.c:2340
void ME_CommitUndo(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: undo.c:227
void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now) DECLSPEC_HIDDEN
Definition: paint.c:116
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint64EXT * result
Definition: glext.h:11304
#define ES_READONLY
Definition: pedump.c:675
DWORD styleFlags
Definition: editstr.h:388
ME_Cursor * pCursors
Definition: editstr.h:387
BOOL WINAPI MessageBeep(_In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:787

Referenced by ME_HandleMessage(), and ME_KeyDown().

◆ create_windowed_editor()

static BOOL create_windowed_editor ( HWND  hwnd,
CREATESTRUCTW create,
BOOL  emulate_10 
)
static

Definition at line 4994 of file editor.c.

4995{
4996 ITextHost *host = ME_CreateTextHost( hwnd, create, emulate_10 );
4997 ME_TextEditor *editor;
4998
4999 if (!host) return FALSE;
5000
5001 editor = ME_MakeEditor( host, emulate_10 );
5002 if (!editor)
5003 {
5004 ITextHost_Release( host );
5005 return FALSE;
5006 }
5007
5010 editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
5011 editor->hwndParent = create->hwndParent;
5012
5013 SetWindowLongPtrW( hwnd, 0, (LONG_PTR)editor );
5014
5015 return TRUE;
5016}
ME_TextEditor * ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
Definition: editor.c:3056
ITextHost * ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10) DECLSPEC_HIDDEN
Definition: txthost.c:44
static const struct access_res create[16]
Definition: package.c:7644
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define ES_WANTRETURN
Definition: pedump.c:676
DWORD exStyleFlags
Definition: editstr.h:389
char * host
Definition: whois.c:55
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define SetWindowLongPtrW
Definition: winuser.h:5346
#define GWL_STYLE
Definition: winuser.h:852
#define GWL_EXSTYLE
Definition: winuser.h:851

Referenced by RichEdit10ANSIWndProc(), and RichEditWndProc_common().

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 3238 of file editor.c.

3239{
3240 TRACE("\n");
3241 switch (fdwReason)
3242 {
3243 case DLL_PROCESS_ATTACH:
3244 DisableThreadLibraryCalls(hinstDLL);
3245 me_heap = HeapCreate (0, 0x10000, 0);
3246 if (!ME_RegisterEditorClass(hinstDLL)) return FALSE;
3248 LookupInit();
3249 break;
3250
3251 case DLL_PROCESS_DETACH:
3252 if (lpvReserved) break;
3256 UnregisterClassA("RichEdit50A", 0);
3261 LookupCleanup();
3264 break;
3265 }
3266 return TRUE;
3267}
void release_typelib(void)
Definition: apps.c:159
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HANDLE me_heap
Definition: editor.c:261
static const WCHAR REListBox20W[]
Definition: editor.c:256
static BOOL ME_ListBoxRegistered
Definition: editor.c:263
static BOOL ME_ComboBoxRegistered
Definition: editor.c:264
static HCURSOR hLeft
Definition: editor.c:258
static const WCHAR REComboBox20W[]
Definition: editor.c:257
static BOOL ME_RegisterEditorClass(HINSTANCE)
Definition: editor.c:5253
void LookupCleanup(void)
Definition: reader.c:2210
void LookupInit(void)
Definition: reader.c:2191
HANDLE WINAPI HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize)
Definition: heapmem.c:45
BOOL WINAPI HeapDestroy(HANDLE hHeap)
Definition: heapmem.c:85
static IN DWORD IN LPVOID lpvReserved
#define OCR_REVERSE
Definition: res.h:23
static const WCHAR RICHEDIT_CLASS20W[]
Definition: richedit.h:50
#define RICHEDIT_CLASS20A
Definition: richedit.h:43
static const WCHAR MSFTEDIT_CLASS[]
Definition: richedit.h:40
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI UnregisterClassA(_In_ LPCSTR, HINSTANCE)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2136
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

◆ get_default_line_height()

static int get_default_line_height ( ME_TextEditor editor)
inlinestatic

Definition at line 3269 of file editor.c.

3270{
3271 int height = 0;
3272
3273 if (editor->pBuffer && editor->pBuffer->pDefaultStyle)
3275 if (height <= 0) height = 24;
3276
3277 return height;
3278}
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
TEXTMETRICW tm
Definition: editstr.h:76
ME_Style * pDefaultStyle
Definition: editstr.h:270
ME_TextBuffer * pBuffer
Definition: editstr.h:386
LONG tmHeight
Definition: wingdi.h:2383

Referenced by ME_HandleMessage().

◆ get_msg_name()

static const char * get_msg_name ( UINT  msg)
static

Definition at line 3414 of file editor.c.

3415{
3416 if (msg >= EM_GETSEL && msg <= EM_CHARFROMPOS)
3417 return edit_messages[msg - EM_GETSEL];
3418 if (msg >= EM_CANPASTE && msg <= EM_GETIMEMODEBIAS)
3420 return "";
3421}
#define msg(x)
Definition: auth_time.c:54
static const char *const richedit_messages[]
Definition: editor.c:3332
static const char *const edit_messages[]
Definition: editor.c:3287
#define EM_GETIMEMODEBIAS
Definition: richedit.h:152
#define EM_CANPASTE
Definition: richedit.h:83
#define EM_CHARFROMPOS
Definition: richedit.h:78
#define EM_GETSEL
Definition: winuser.h:1997

Referenced by REComboWndProc(), REListWndProc(), and RichEditWndProc_common().

◆ handle_EM_SETCHARFORMAT()

static LRESULT handle_EM_SETCHARFORMAT ( ME_TextEditor editor,
WPARAM  flags,
const CHARFORMAT2W fmt_in 
)
static

Definition at line 3543 of file editor.c.

3544{
3546 BOOL changed = TRUE;
3548
3549 if (!cfany_to_cf2w( &fmt, fmt_in )) return 0;
3550
3551 if (flags & SCF_ALL)
3552 {
3553 if (editor->mode & TM_PLAINTEXT)
3554 {
3555 ME_SetDefaultCharFormat( editor, &fmt );
3556 }
3557 else
3558 {
3559 ME_SetCursorToStart( editor, &start );
3560 ME_SetCharFormat( editor, &start, NULL, &fmt );
3561 editor->nModifyStep = 1;
3562 }
3563 }
3564 else if (flags & SCF_SELECTION)
3565 {
3566 if (editor->mode & TM_PLAINTEXT) return 0;
3567 if (flags & SCF_WORD)
3568 {
3569 end = editor->pCursors[0];
3570 ME_MoveCursorWords( editor, &end, +1 );
3571 start = end;
3572 ME_MoveCursorWords( editor, &start, -1 );
3573 ME_SetCharFormat( editor, &start, &end, &fmt );
3574 }
3575 changed = ME_IsSelection( editor );
3576 ME_SetSelectionCharFormat( editor, &fmt );
3577 if (changed) editor->nModifyStep = 1;
3578 }
3579 else /* SCF_DEFAULT */
3580 {
3581 ME_SetDefaultCharFormat( editor, &fmt );
3582 }
3583
3584 ME_CommitUndo( editor );
3585 if (changed)
3586 {
3587 ME_WrapMarkedParagraphs( editor );
3588 ME_UpdateScrollBar( editor );
3589 }
3590 return 1;
3591}
#define NULL
Definition: types.h:112
void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: caret.c:27
BOOL ME_IsSelection(ME_TextEditor *editor)
Definition: caret.c:1578
BOOL ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
Definition: caret.c:799
BOOL cfany_to_cf2w(CHARFORMAT2W *to, const CHARFORMAT2W *from) DECLSPEC_HIDDEN
Definition: style.c:36
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: wrap.c:1093
void ME_UpdateScrollBar(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: paint.c:1148
void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod) DECLSPEC_HIDDEN
Definition: style.c:540
void ME_SetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
Definition: run.c:696
void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
Definition: run.c:725
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLbitfield flags
Definition: glext.h:7161
#define SCF_WORD
Definition: richedit.h:236
#define SCF_SELECTION
Definition: richedit.h:235
#define TM_PLAINTEXT
Definition: richedit.h:1028
#define SCF_ALL
Definition: richedit.h:237
Definition: dsound.c:943

Referenced by ME_HandleMessage().

◆ handle_enter()

static BOOL handle_enter ( ME_TextEditor editor)
static

Definition at line 2438 of file editor.c.

2439{
2440 BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
2441 BOOL shift_is_down = GetKeyState(VK_SHIFT) & 0x8000;
2442
2443 if (editor->bDialogMode)
2444 {
2445 if (ctrl_is_down)
2446 return TRUE;
2447
2448 if (!(editor->styleFlags & ES_WANTRETURN))
2449 {
2450 if (editor->hwndParent)
2451 {
2452 DWORD dw;
2453 dw = SendMessageW(editor->hwndParent, DM_GETDEFID, 0, 0);
2454 if (HIWORD(dw) == DC_HASDEFID)
2455 {
2456 HWND hwDefCtrl = GetDlgItem(editor->hwndParent, LOWORD(dw));
2457 if (hwDefCtrl)
2458 {
2459 SendMessageW(editor->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, TRUE);
2460 PostMessageW(hwDefCtrl, WM_KEYDOWN, VK_RETURN, 0);
2461 }
2462 }
2463 }
2464 return TRUE;
2465 }
2466 }
2467
2468 if (editor->styleFlags & ES_MULTILINE)
2469 {
2470 static const WCHAR endl = '\r';
2471 static const WCHAR endlv10[] = {'\r','\n'};
2472 ME_Cursor cursor = editor->pCursors[0];
2473 ME_DisplayItem *para = cursor.pPara;
2474 int from, to;
2475 ME_Style *style, *eop_style;
2476
2477 if (editor->styleFlags & ES_READONLY)
2478 {
2480 return TRUE;
2481 }
2482
2483 ME_GetSelectionOfs(editor, &from, &to);
2484 if (editor->nTextLimit > ME_GetTextLength(editor) - (to-from))
2485 {
2486 if (!editor->bEmulateVersion10) /* v4.1 */
2487 {
2488 if (para->member.para.nFlags & MEPF_ROWEND)
2489 {
2490 /* Add a new table row after this row. */
2491 para = ME_AppendTableRow(editor, para);
2492 para = para->member.para.next_para;
2493 editor->pCursors[0].pPara = para;
2494 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
2495 editor->pCursors[0].nOffset = 0;
2496 editor->pCursors[1] = editor->pCursors[0];
2497 ME_CommitUndo(editor);
2499 ME_UpdateRepaint(editor, FALSE);
2500 return TRUE;
2501 }
2502 else if (para == editor->pCursors[1].pPara &&
2503 cursor.nOffset + cursor.pRun->member.run.nCharOfs == 0 &&
2504 para->member.para.prev_para->member.para.nFlags & MEPF_ROWSTART &&
2505 !para->member.para.prev_para->member.para.nCharOfs)
2506 {
2507 /* Insert a newline before the table. */
2508 para = para->member.para.prev_para;
2509 para->member.para.nFlags &= ~MEPF_ROWSTART;
2510 editor->pCursors[0].pPara = para;
2511 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
2512 editor->pCursors[1] = editor->pCursors[0];
2513 ME_InsertTextFromCursor(editor, 0, &endl, 1,
2514 editor->pCursors[0].pRun->member.run.style);
2515 para = editor->pBuffer->pFirst->member.para.next_para;
2516 ME_SetDefaultParaFormat(editor, &para->member.para.fmt);
2517 para->member.para.nFlags = 0;
2518 mark_para_rewrap(editor, para);
2519 editor->pCursors[0].pPara = para;
2520 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
2521 editor->pCursors[1] = editor->pCursors[0];
2522 para->member.para.next_para->member.para.nFlags |= MEPF_ROWSTART;
2525 ME_UpdateRepaint(editor, FALSE);
2526 return TRUE;
2527 }
2528 }
2529 else /* v1.0 - 3.0 */
2530 {
2531 ME_DisplayItem *para = cursor.pPara;
2532 if (ME_IsInTable(para))
2533 {
2534 if (cursor.pRun->member.run.nFlags & MERF_ENDPARA)
2535 {
2536 if (from == to)
2537 {
2539 para = ME_AppendTableRow(editor, para);
2540 editor->pCursors[0].pPara = para;
2541 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
2542 editor->pCursors[0].nOffset = 0;
2543 editor->pCursors[1] = editor->pCursors[0];
2545 ME_UpdateRepaint(editor, FALSE);
2546 return TRUE;
2547 }
2548 }
2549 else
2550 {
2552 if (cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 &&
2554 {
2555 /* Insert newline before table */
2556 cursor.pRun = ME_FindItemBack(para, diRun);
2557 if (cursor.pRun)
2558 {
2559 editor->pCursors[0].pRun = cursor.pRun;
2560 editor->pCursors[0].pPara = para->member.para.prev_para;
2561 }
2562 editor->pCursors[0].nOffset = 0;
2563 editor->pCursors[1] = editor->pCursors[0];
2564 ME_InsertTextFromCursor(editor, 0, &endl, 1,
2565 editor->pCursors[0].pRun->member.run.style);
2566 }
2567 else
2568 {
2569 editor->pCursors[1] = editor->pCursors[0];
2570 para = ME_AppendTableRow(editor, para);
2571 editor->pCursors[0].pPara = para;
2572 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
2573 editor->pCursors[0].nOffset = 0;
2574 editor->pCursors[1] = editor->pCursors[0];
2575 }
2577 ME_UpdateRepaint(editor, FALSE);
2578 return TRUE;
2579 }
2580 }
2581 }
2582
2583 style = ME_GetInsertStyle(editor, 0);
2584
2585 /* Normally the new eop style is the insert style, however in a list it is copied from the existing
2586 eop style (this prevents the list label style changing when the new eop is inserted).
2587 No extra ref is taken here on eop_style. */
2588 if (para->member.para.fmt.wNumbering)
2589 eop_style = para->member.para.eop_run->style;
2590 else
2591 eop_style = style;
2593 if (shift_is_down)
2594 ME_InsertEndRowFromCursor(editor, 0);
2595 else
2596 if (!editor->bEmulateVersion10)
2597 ME_InsertTextFromCursor(editor, 0, &endl, 1, eop_style);
2598 else
2599 ME_InsertTextFromCursor(editor, 0, endlv10, 2, eop_style);
2601 SetCursor(NULL);
2602
2604 ME_UpdateRepaint(editor, FALSE);
2605 ME_SaveTempStyle(editor, style); /* set the temp insert style for the new para */
2607 }
2608 return TRUE;
2609 }
2610 return FALSE;
2611}
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
Arabic default style
Definition: afstyles.h:94
void ME_InsertEndRowFromCursor(ME_TextEditor *editor, int nCursor)
Definition: caret.c:580
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style)
Definition: caret.c:595
int ME_GetTextLength(ME_TextEditor *editor)
Definition: caret.c:83
static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor)
Definition: editor.c:2410
void ME_ReleaseStyle(ME_Style *item) DECLSPEC_HIDDEN
Definition: style.c:462
ME_Style * ME_GetInsertStyle(ME_TextEditor *editor, int nCursor) DECLSPEC_HIDDEN
Definition: style.c:476
void mark_para_rewrap(ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN
Definition: para.c:26
void ME_ContinueCoalescingTransaction(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: undo.c:265
void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style) DECLSPEC_HIDDEN
Definition: style.c:514
void ME_CheckTablesForCorruption(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: table.c:192
ME_DisplayItem * ME_FindItemBack(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN
Definition: list.c:111
ME_DisplayItem * ME_AppendTableRow(ME_TextEditor *editor, ME_DisplayItem *table_row) DECLSPEC_HIDDEN
Definition: table.c:407
void ME_SetDefaultParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
Definition: para.c:992
BOOL ME_IsInTable(ME_DisplayItem *pItem) DECLSPEC_HIDDEN
Definition: table.c:273
ME_DisplayItem * ME_FindItemFwd(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN
Definition: list.c:134
void ME_CommitCoalescingUndo(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: undo.c:301
#define MERF_ENDPARA
Definition: editstr.h:122
#define MEPF_ROWSTART
Definition: editstr.h:144
#define MEPF_ROWEND
Definition: editstr.h:145
@ diRun
Definition: editstr.h:87
unsigned long DWORD
Definition: ntddk_ex.h:95
const char cursor[]
Definition: icontest.c:13
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define LOWORD(l)
Definition: pedump.c:82
#define ES_MULTILINE
Definition: pedump.c:667
CardRegion * from
Definition: spigame.cpp:19
WORD wNumbering
Definition: richedit.h:668
ME_DisplayItem * pPara
Definition: editstr.h:275
int nOffset
Definition: editstr.h:277
ME_DisplayItem * pRun
Definition: editstr.h:276
union tagME_DisplayItem::@540 member
ME_Paragraph para
Definition: editstr.h:262
struct tagME_DisplayItem * next_para
Definition: editstr.h:217
struct tagME_DisplayItem * prev_para
Definition: editstr.h:217
PARAFORMAT2 fmt
Definition: editstr.h:204
ME_Run * eop_run
Definition: editstr.h:216
ME_Style * style
Definition: editstr.h:160
ME_DisplayItem * pFirst
Definition: editstr.h:268
BOOL bDialogMode
Definition: editstr.h:428
BOOL bEmulateVersion10
Definition: editstr.h:385
#define HIWORD(l)
Definition: typedefs.h:247
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define VK_CONTROL
Definition: winuser.h:2203
#define DC_HASDEFID
Definition: winuser.h:2609
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_NEXTDLGCTL
Definition: winuser.h:1643
#define VK_RETURN
Definition: winuser.h:2201
#define VK_SHIFT
Definition: winuser.h:2202
#define WM_KEYDOWN
Definition: winuser.h:1715
#define DM_GETDEFID
Definition: winuser.h:2098
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
SHORT WINAPI GetKeyState(_In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ME_Char(), and ME_KeyDown().

◆ init_paste_formats()

static void init_paste_formats ( void  )
static

Definition at line 2276 of file editor.c.

2277{
2278 struct paste_format *format;
2279 static int done;
2280
2281 if (!done)
2282 {
2283 for (format = paste_formats; format->fmt.cfFormat; format++)
2284 {
2285 if (format->name)
2286 format->fmt.cfFormat = RegisterClipboardFormatW( format->name );
2287 }
2288 done = 1;
2289 }
2290}
static struct paste_format paste_formats[]
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)

Referenced by paste_special().

◆ insert_static_object()

static HRESULT insert_static_object ( ME_TextEditor editor,
HENHMETAFILE  hemf,
HBITMAP  hbmp,
const SIZEL sz 
)
static

Definition at line 1127 of file editor.c.

1129{
1130 LPOLEOBJECT lpObject = NULL;
1131 LPSTORAGE lpStorage = NULL;
1132 LPOLECLIENTSITE lpClientSite = NULL;
1133 LPDATAOBJECT lpDataObject = NULL;
1134 LPOLECACHE lpOleCache = NULL;
1135 LPRICHEDITOLE lpReOle = NULL;
1136 STGMEDIUM stgm;
1137 FORMATETC fm;
1138 CLSID clsid;
1139 HRESULT hr = E_FAIL;
1140 DWORD conn;
1141
1142 if (hemf)
1143 {
1144 stgm.tymed = TYMED_ENHMF;
1145 stgm.u.hEnhMetaFile = hemf;
1146 fm.cfFormat = CF_ENHMETAFILE;
1147 }
1148 else if (hbmp)
1149 {
1150 stgm.tymed = TYMED_GDI;
1151 stgm.u.hBitmap = hbmp;
1152 fm.cfFormat = CF_BITMAP;
1153 }
1154 stgm.pUnkForRelease = NULL;
1155
1156 fm.ptd = NULL;
1157 fm.dwAspect = DVASPECT_CONTENT;
1158 fm.lindex = -1;
1159 fm.tymed = stgm.tymed;
1160
1161 if (!editor->reOle)
1162 {
1163 if (!CreateIRichEditOle(NULL, editor, (LPVOID *)&editor->reOle))
1164 return hr;
1165 }
1166
1167 if (OleCreateDefaultHandler(&CLSID_NULL, NULL, &IID_IOleObject, (void**)&lpObject) == S_OK &&
1168 IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (void**)&lpReOle) == S_OK &&
1169 IRichEditOle_GetClientSite(lpReOle, &lpClientSite) == S_OK &&
1170 IOleObject_SetClientSite(lpObject, lpClientSite) == S_OK &&
1171 IOleObject_GetUserClassID(lpObject, &clsid) == S_OK &&
1172 IOleObject_QueryInterface(lpObject, &IID_IOleCache, (void**)&lpOleCache) == S_OK &&
1173 IOleCache_Cache(lpOleCache, &fm, 0, &conn) == S_OK &&
1174 IOleObject_QueryInterface(lpObject, &IID_IDataObject, (void**)&lpDataObject) == S_OK &&
1175 IDataObject_SetData(lpDataObject, &fm, &stgm, TRUE) == S_OK)
1176 {
1177 REOBJECT reobject;
1178
1179 reobject.cbStruct = sizeof(reobject);
1180 reobject.cp = REO_CP_SELECTION;
1181 reobject.clsid = clsid;
1182 reobject.poleobj = lpObject;
1183 reobject.pstg = lpStorage;
1184 reobject.polesite = lpClientSite;
1185 /* convert from twips to .01 mm */
1186 reobject.sizel.cx = MulDiv(sz->cx, 254, 144);
1187 reobject.sizel.cy = MulDiv(sz->cy, 254, 144);
1188 reobject.dvaspect = DVASPECT_CONTENT;
1189 reobject.dwFlags = 0; /* FIXME */
1190 reobject.dwUser = 0;
1191
1192 ME_InsertOLEFromCursor(editor, &reobject, 0);
1193 hr = S_OK;
1194 }
1195
1196 if (lpObject) IOleObject_Release(lpObject);
1197 if (lpClientSite) IOleClientSite_Release(lpClientSite);
1198 if (lpStorage) IStorage_Release(lpStorage);
1199 if (lpDataObject) IDataObject_Release(lpDataObject);
1200 if (lpOleCache) IOleCache_Release(lpOleCache);
1201 if (lpReOle) IRichEditOle_Release(lpReOle);
1202
1203 return hr;
1204}
#define CF_BITMAP
Definition: constants.h:397
#define CF_ENHMETAFILE
Definition: constants.h:409
HBITMAP hbmp
#define E_FAIL
Definition: ddrawi.h:102
HRESULT WINAPI OleCreateDefaultHandler(REFCLSID clsid, LPUNKNOWN pUnkOuter, REFIID riid, LPVOID *ppvObj)
void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT *reo, int nCursor)
Definition: caret.c:546
LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *ppvObj) DECLSPEC_HIDDEN
Definition: richole.c:5688
#define S_OK
Definition: intsafe.h:52
REFCLSID clsid
Definition: msctf.c:82
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
interface IStorage * LPSTORAGE
Definition: objfwd.h:30
interface IDataObject * LPDATAOBJECT
Definition: objfwd.h:21
const GUID IID_IOleCache
const GUID IID_IDataObject
const GUID IID_IOleObject
#define CLSID_NULL
Definition: guiddef.h:99
HRESULT hr
Definition: shlfolder.c:183
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
DWORD dwUser
Definition: richole.idl:67
CLSID clsid
Definition: richole.idl:60
DWORD dwFlags
Definition: richole.idl:66
LPSTORAGE pstg
Definition: richole.idl:62
LPOLEOBJECT poleobj
Definition: richole.idl:61
DWORD dvaspect
Definition: richole.idl:65
LPOLECLIENTSITE polesite
Definition: richole.idl:63
DWORD cbStruct
Definition: richole.idl:58
LONG cp
Definition: richole.idl:59
SIZEL sizel
Definition: richole.idl:64
IUnknown * reOle
Definition: editstr.h:384

Referenced by ME_RTFReadPictGroup(), and paste_emf().

◆ is_link()

static BOOL is_link ( ME_Run run)
static

Definition at line 2892 of file editor.c.

2893{
2894 return (run->style->fmt.dwMask & CFM_LINK) && (run->style->fmt.dwEffects & CFE_LINK);
2895}
#define CFE_LINK
Definition: richedit.h:411
#define CFM_LINK
Definition: richedit.h:337
DWORD dwMask
Definition: richedit.h:306
DWORD dwEffects
Definition: richedit.h:307
CHARFORMAT2W fmt
Definition: editstr.h:73

Referenced by ME_LinkNotify(), and ME_SetCursor().

◆ is_version_nt()

static BOOL is_version_nt ( void  )
inlinestatic

Definition at line 266 of file editor.c.

267{
268 return !(GetVersion() & 0x80000000);
269}
DWORD WINAPI GetVersion()
Definition: redirtest.c:5

Referenced by ME_RegisterEditorClass().

◆ isurlneutral()

static BOOL isurlneutral ( WCHAR  c)
static

Definition at line 5368 of file editor.c.

5369{
5370 /* NB this list is sorted */
5371 static const WCHAR neutral_chars[] = {'!','\"','\'','(',')',',','-','.',':',';','<','>','?','[',']','{','}'};
5372
5373 /* Some shortcuts */
5374 if (isalnum( c )) return FALSE;
5375 if (c > neutral_chars[ARRAY_SIZE( neutral_chars ) - 1]) return FALSE;
5376
5377 return !!bsearch( &c, neutral_chars, ARRAY_SIZE( neutral_chars ), sizeof(c), wchar_comp );
5378}
#define ARRAY_SIZE(A)
Definition: main.h:33
static int __cdecl wchar_comp(const void *key, const void *elem)
Definition: editor.c:5361
const GLubyte * c
Definition: glext.h:8905
_Check_return_ _CRTIMP int __cdecl isalnum(_In_ int _C)
#define bsearch

Referenced by ME_FindNextURLCandidate().

◆ ME_ApplyBorderProperties()

static void ME_ApplyBorderProperties ( RTF_Info info,
ME_BorderRect borderRect,
RTFBorder borderDef 
)
static

Definition at line 399 of file editor.c.

402{
403 int i, colorNum;
404 ME_Border *pBorders[] = {&borderRect->top,
405 &borderRect->left,
406 &borderRect->bottom,
407 &borderRect->right};
408 for (i = 0; i < 4; i++)
409 {
410 RTFColor *colorDef = info->colorList;
411 pBorders[i]->width = borderDef[i].width;
412 colorNum = borderDef[i].color;
413 while (colorDef && colorDef->rtfCNum != colorNum)
414 colorDef = colorDef->rtfNextColor;
415 if (colorDef)
416 pBorders[i]->colorRef = RGB(
417 colorDef->rtfCRed >= 0 ? colorDef->rtfCRed : 0,
418 colorDef->rtfCGreen >= 0 ? colorDef->rtfCGreen : 0,
419 colorDef->rtfCBlue >= 0 ? colorDef->rtfCBlue : 0);
420 else
421 pBorders[i]->colorRef = RGB(0, 0, 0);
422 }
423}
#define RGB(r, g, b)
Definition: precomp.h:71
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int color
Definition: rtf.h:1015
int width
Definition: rtf.h:1014
Definition: rtf.h:979
int rtfCNum
Definition: rtf.h:980
int rtfCBlue
Definition: rtf.h:983
RTFColor * rtfNextColor
Definition: rtf.h:984
int rtfCRed
Definition: rtf.h:981
int rtfCGreen
Definition: rtf.h:982
ME_Border bottom
Definition: editstr.h:190
ME_Border right
Definition: editstr.h:191
ME_Border left
Definition: editstr.h:189
ME_Border top
Definition: editstr.h:188
COLORREF colorRef
Definition: editstr.h:183

Referenced by ME_RTFSpecialCharHook().

◆ ME_CalculateClickCount()

static int ME_CalculateClickCount ( ME_TextEditor editor,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 2842 of file editor.c.

2844{
2845 static int clickNum = 0;
2846 if (msg < WM_MOUSEFIRST || msg > WM_MOUSELAST)
2847 return 0;
2848
2849 if ((msg == WM_LBUTTONDBLCLK) ||
2850 (msg == WM_RBUTTONDBLCLK) ||
2851 (msg == WM_MBUTTONDBLCLK) ||
2852 (msg == WM_XBUTTONDBLCLK))
2853 {
2855 }
2856
2857 if ((msg == WM_LBUTTONDOWN) ||
2858 (msg == WM_RBUTTONDOWN) ||
2859 (msg == WM_MBUTTONDOWN) ||
2860 (msg == WM_XBUTTONDOWN))
2861 {
2862 static MSG prevClickMsg;
2863 MSG clickMsg;
2864 /* Compare the editor instead of the hwnd so that the this
2865 * can still be done for windowless richedit controls. */
2866 clickMsg.hwnd = (HWND)editor;
2867 clickMsg.message = msg;
2868 clickMsg.wParam = wParam;
2869 clickMsg.lParam = lParam;
2870 clickMsg.time = GetMessageTime();
2871 clickMsg.pt.x = (short)LOWORD(lParam);
2872 clickMsg.pt.y = (short)HIWORD(lParam);
2873 if ((clickNum != 0) &&
2874 (clickMsg.message == prevClickMsg.message) &&
2875 (clickMsg.hwnd == prevClickMsg.hwnd) &&
2876 (clickMsg.wParam == prevClickMsg.wParam) &&
2877 (clickMsg.time - prevClickMsg.time < GetDoubleClickTime()) &&
2878 (abs(clickMsg.pt.x - prevClickMsg.pt.x) < GetSystemMetrics(SM_CXDOUBLECLK)/2) &&
2879 (abs(clickMsg.pt.y - prevClickMsg.pt.y) < GetSystemMetrics(SM_CYDOUBLECLK)/2))
2880 {
2881 clickNum++;
2882 } else {
2883 clickNum = 1;
2884 }
2885 prevClickMsg = clickMsg;
2886 } else {
2887 return 0;
2888 }
2889 return clickNum;
2890}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
HANDLE HWND
Definition: compat.h:19
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define abs(i)
Definition: fconv.c:206
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define SM_CXDOUBLECLK
Definition: winuser.h:999
#define WM_MOUSELAST
Definition: winuser.h:1801
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1778
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1781
#define SM_CYDOUBLECLK
Definition: winuser.h:1000
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
UINT WINAPI GetDoubleClickTime(void)
Definition: ntwrapper.h:314
#define WM_RBUTTONDOWN
Definition: winuser.h:1779
#define WM_MBUTTONDBLCLK
Definition: winuser.h:1784
LONG WINAPI GetMessageTime(void)
Definition: message.c:1361
int WINAPI GetSystemMetrics(_In_ int)
#define WM_MBUTTONDOWN
Definition: winuser.h:1782

Referenced by ME_HandleMessage().

◆ ME_Char()

static LRESULT ME_Char ( ME_TextEditor editor,
WPARAM  charCode,
LPARAM  flags,
BOOL  unicode 
)
static

Definition at line 2745 of file editor.c.

2747{
2748 WCHAR wstr;
2749
2750 if (editor->bMouseCaptured)
2751 return 0;
2752
2753 if (editor->styleFlags & ES_READONLY)
2754 {
2756 return 0; /* FIXME really 0 ? */
2757 }
2758
2759 if (unicode)
2760 wstr = (WCHAR)charCode;
2761 else
2762 {
2763 CHAR charA = charCode;
2764 MultiByteToWideChar(CP_ACP, 0, &charA, 1, &wstr, 1);
2765 }
2766
2767 if (editor->bEmulateVersion10 && wstr == '\r')
2768 handle_enter(editor);
2769
2770 if ((unsigned)wstr >= ' ' || wstr == '\t')
2771 {
2772 ME_Cursor cursor = editor->pCursors[0];
2773 ME_DisplayItem *para = cursor.pPara;
2774 int from, to;
2775 BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
2776 ME_GetSelectionOfs(editor, &from, &to);
2777 if (wstr == '\t' &&
2778 /* v4.1 allows tabs to be inserted with ctrl key down */
2779 !(ctrl_is_down && !editor->bEmulateVersion10))
2780 {
2781 ME_DisplayItem *para;
2782 BOOL bSelectedRow = FALSE;
2783
2784 para = cursor.pPara;
2785 if (ME_IsSelection(editor) &&
2786 cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 &&
2787 to == ME_GetCursorOfs(&editor->pCursors[0]) &&
2788 para->member.para.prev_para->type == diParagraph)
2789 {
2790 para = para->member.para.prev_para;
2791 bSelectedRow = TRUE;
2792 }
2793 if (ME_IsInTable(para))
2794 {
2795 ME_TabPressedInTable(editor, bSelectedRow);
2796 ME_CommitUndo(editor);
2797 return 0;
2798 }
2799 } else if (!editor->bEmulateVersion10) { /* v4.1 */
2800 if (para->member.para.nFlags & MEPF_ROWEND) {
2801 if (from == to) {
2802 para = para->member.para.next_para;
2803 if (para->member.para.nFlags & MEPF_ROWSTART)
2804 para = para->member.para.next_para;
2805 editor->pCursors[0].pPara = para;
2806 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
2807 editor->pCursors[0].nOffset = 0;
2808 editor->pCursors[1] = editor->pCursors[0];
2809 }
2810 }
2811 } else { /* v1.0 - 3.0 */
2812 if (ME_IsInTable(cursor.pRun) &&
2813 cursor.pRun->member.run.nFlags & MERF_ENDPARA &&
2814 from == to)
2815 {
2816 /* Text should not be inserted at the end of the table. */
2817 MessageBeep(-1);
2818 return 0;
2819 }
2820 }
2821 /* FIXME maybe it would make sense to call EM_REPLACESEL instead ? */
2822 /* WM_CHAR is restricted to nTextLimit */
2823 if(editor->nTextLimit > ME_GetTextLength(editor) - (to-from))
2824 {
2825 ME_Style *style = ME_GetInsertStyle(editor, 0);
2827 ME_InsertTextFromCursor(editor, 0, &wstr, 1, style);
2831 }
2832
2834 ME_UpdateRepaint(editor, FALSE);
2835 }
2836 return 0;
2837}
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
int ME_GetCursorOfs(const ME_Cursor *cursor)
Definition: caret.c:957
static BOOL handle_enter(ME_TextEditor *editor)
Definition: editor.c:2438
void ME_TabPressedInTable(ME_TextEditor *editor, BOOL bSelectedRow) DECLSPEC_HIDDEN
Definition: table.c:562
#define ITextHost_TxSetCursor(This, a, b)
Definition: editor.h:303
@ diParagraph
Definition: editstr.h:85
ITextHost * texthost
Definition: editstr.h:383
BOOL bMouseCaptured
Definition: editstr.h:445
char CHAR
Definition: xmlstorage.h:175

Referenced by ME_HandleMessage().

◆ ME_Copy()

static BOOL ME_Copy ( ME_TextEditor editor,
const ME_Cursor start,
int  nChars 
)
static

Definition at line 2340 of file editor.c.

2341{
2342 LPDATAOBJECT dataObj = NULL;
2343 HRESULT hr = S_OK;
2344
2345 if (editor->cPasswordMask)
2346 return FALSE; /* Copying or Cutting masked text isn't allowed */
2347
2348 if(editor->lpOleCallback)
2349 {
2351 range.cpMin = ME_GetCursorOfs(start);
2352 range.cpMax = range.cpMin + nChars;
2353 hr = IRichEditOleCallback_GetClipboardData(editor->lpOleCallback, &range, RECO_COPY, &dataObj);
2354 }
2355 if(FAILED(hr) || !dataObj)
2356 hr = ME_GetDataObject(editor, start, nChars, &dataObj);
2357 if(SUCCEEDED(hr)) {
2358 hr = OleSetClipboard(dataObj);
2359 IDataObject_Release(dataObj);
2360 }
2361 return SUCCEEDED(hr);
2362}
HRESULT WINAPI OleSetClipboard(IDataObject *data)
Definition: clipboard.c:2199
HRESULT ME_GetDataObject(ME_TextEditor *editor, const ME_Cursor *start, int nChars, IDataObject **dataobj)
Definition: clipboard.c:405
GLenum GLint * range
Definition: glext.h:7539
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
WCHAR cPasswordMask
Definition: editstr.h:426
LPRICHEDITOLECALLBACK lpOleCallback
Definition: editstr.h:418

Referenced by copy_or_cut().

◆ ME_DestroyEditor()

void ME_DestroyEditor ( ME_TextEditor editor)

Definition at line 3194 of file editor.c.

3195{
3196 ME_DisplayItem *p = editor->pBuffer->pFirst, *pNext = NULL;
3197 ME_Style *s, *cursor2;
3198 int i;
3199
3200 ME_ClearTempStyle(editor);
3201 ME_EmptyUndoStack(editor);
3202 editor->pBuffer->pFirst = NULL;
3203 while(p) {
3204 pNext = p->next;
3205 if (p->type == diParagraph)
3206 destroy_para(editor, p);
3207 else
3209 p = pNext;
3210 }
3211
3212 LIST_FOR_EACH_ENTRY_SAFE( s, cursor2, &editor->style_list, ME_Style, entry )
3213 ME_DestroyStyle( s );
3214
3216 for (i=0; i<HFONT_CACHE_SIZE; i++)
3217 {
3218 if (editor->pFontCache[i].hFont)
3219 DeleteObject(editor->pFontCache[i].hFont);
3220 }
3221 if (editor->rgbBackColor != -1)
3222 DeleteObject(editor->hbrBackground);
3223 if(editor->lpOleCallback)
3224 IRichEditOleCallback_Release(editor->lpOleCallback);
3225 ITextHost_Release(editor->texthost);
3226 if (editor->reOle)
3227 {
3228 IUnknown_Release(editor->reOle);
3229 editor->reOle = NULL;
3230 }
3232
3233 heap_free(editor->pBuffer);
3234 heap_free(editor->pCursors);
3235 heap_free(editor);
3236}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:230
void destroy_para(ME_TextEditor *editor, ME_DisplayItem *item) DECLSPEC_HIDDEN
Definition: para.c:48
void ME_DestroyStyle(ME_Style *item) DECLSPEC_HIDDEN
Definition: style.c:442
void ME_DestroyDisplayItem(ME_DisplayItem *item) DECLSPEC_HIDDEN
Definition: list.c:160
void ME_EmptyUndoStack(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: undo.c:53
void ME_ClearTempStyle(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: style.c:523
#define HFONT_CACHE_SIZE
Definition: editstr.h:69
pKey DeleteObject()
GLdouble s
Definition: gl.h:2039
GLfloat GLfloat p
Definition: glext.h:8902
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
struct define * next
Definition: compiler.c:65
ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE]
Definition: editstr.h:410
COLORREF rgbBackColor
Definition: editstr.h:397
HBRUSH hbrBackground
Definition: editstr.h:398
struct list style_list
Definition: editstr.h:447

Referenced by ITextServicesImpl_Release(), and ME_HandleMessage().

◆ ME_FilterEvent()

static BOOL ME_FilterEvent ( ME_TextEditor editor,
UINT  msg,
WPARAM wParam,
LPARAM lParam 
)
static

Definition at line 2390 of file editor.c.

2391{
2392 MSGFILTER msgf;
2393
2394 if (!editor->hWnd || !editor->hwndParent) return FALSE;
2395 msgf.nmhdr.hwndFrom = editor->hWnd;
2396 msgf.nmhdr.idFrom = GetWindowLongW(editor->hWnd, GWLP_ID);
2397 msgf.nmhdr.code = EN_MSGFILTER;
2398 msgf.msg = msg;
2399 msgf.wParam = *wParam;
2400 msgf.lParam = *lParam;
2401 if (SendMessageW(editor->hwndParent, WM_NOTIFY, msgf.nmhdr.idFrom, (LPARAM)&msgf))
2402 return FALSE;
2403 *wParam = msgf.wParam;
2404 *lParam = msgf.lParam;
2405 msgf.wParam = *wParam;
2406
2407 return TRUE;
2408}
#define EN_MSGFILTER
Definition: richedit.h:191
#define WM_NOTIFY
Definition: richedit.h:61
LPARAM lParam
Definition: richedit.h:643
NMHDR nmhdr
Definition: richedit.h:640
UINT msg
Definition: richedit.h:641
WPARAM wParam
Definition: richedit.h:642
UINT_PTR idFrom
Definition: winuser.h:3158
UINT code
Definition: winuser.h:3159
HWND hwndFrom
Definition: winuser.h:3157
LONG_PTR LPARAM
Definition: windef.h:208
#define GWLP_ID
Definition: winuser.h:860

Referenced by ME_HandleMessage().

◆ ME_FindNextURLCandidate()

static BOOL ME_FindNextURLCandidate ( ME_TextEditor editor,
const ME_Cursor start,
int  nChars,
ME_Cursor candidate_min,
ME_Cursor candidate_max 
)
static

This proc takes a selection, and scans it forward in order to select the span of a possible URL candidate. A possible URL candidate must start with isalnum or one of the following special characters: *|/+%#@ and must consist entirely of the characters allowed to start the URL, plus : (colon) which may occur at most once, and not at either end.

Definition at line 5387 of file editor.c.

5392{
5393 ME_Cursor cursor = *start, neutral_end, space_end;
5394 BOOL candidateStarted = FALSE, quoted = FALSE;
5395 WCHAR c;
5396
5397 while (nChars > 0)
5398 {
5399 WCHAR *str = get_text( &cursor.pRun->member.run, 0 );
5400 int run_len = cursor.pRun->member.run.len;
5401
5402 nChars -= run_len - cursor.nOffset;
5403
5404 /* Find start of candidate */
5405 if (!candidateStarted)
5406 {
5407 while (cursor.nOffset < run_len)
5408 {
5409 c = str[cursor.nOffset];
5410 if (!iswspace( c ) && !isurlneutral( c ))
5411 {
5412 *candidate_min = cursor;
5413 candidateStarted = TRUE;
5414 neutral_end.pPara = NULL;
5415 space_end.pPara = NULL;
5416 cursor.nOffset++;
5417 break;
5418 }
5419 quoted = (c == '<');
5420 cursor.nOffset++;
5421 }
5422 }
5423
5424 /* Find end of candidate */
5425 if (candidateStarted)
5426 {
5427 while (cursor.nOffset < run_len)
5428 {
5429 c = str[cursor.nOffset];
5430 if (iswspace( c ))
5431 {
5432 if (quoted && c != '\r')
5433 {
5434 if (!space_end.pPara)
5435 {
5436 if (neutral_end.pPara)
5437 space_end = neutral_end;
5438 else
5439 space_end = cursor;
5440 }
5441 }
5442 else
5443 goto done;
5444 }
5445 else if (isurlneutral( c ))
5446 {
5447 if (quoted && c == '>')
5448 {
5449 neutral_end.pPara = NULL;
5450 space_end.pPara = NULL;
5451 goto done;
5452 }
5453 if (!neutral_end.pPara)
5454 neutral_end = cursor;
5455 }
5456 else
5457 neutral_end.pPara = NULL;
5458
5459 cursor.nOffset++;
5460 }
5461 }
5462
5463 cursor.nOffset = 0;
5464 if (!ME_NextRun(&cursor.pPara, &cursor.pRun, TRUE))
5465 goto done;
5466 }
5467
5468done:
5469 if (candidateStarted)
5470 {
5471 if (space_end.pPara)
5472 *candidate_max = space_end;
5473 else if (neutral_end.pPara)
5474 *candidate_max = neutral_end;
5475 else
5476 *candidate_max = cursor;
5477 return TRUE;
5478 }
5479 *candidate_max = *candidate_min = cursor;
5480 return FALSE;
5481}
static BOOL isurlneutral(WCHAR c)
Definition: editor.c:5368
BOOL ME_NextRun(ME_DisplayItem **para, ME_DisplayItem **run, BOOL all_para) DECLSPEC_HIDDEN
Definition: list.c:71
static WCHAR * get_text(const ME_Run *run, int offset)
Definition: editor.h:41
#define iswspace(_c)
Definition: ctype.h:669
#define c
Definition: ke_i.h:80
const WCHAR * str

Referenced by ME_UpdateLinkAttribute().

◆ ME_FindText()

static int ME_FindText ( ME_TextEditor editor,
DWORD  flags,
const CHARRANGE chrg,
const WCHAR text,
CHARRANGE chrgText 
)
static

Definition at line 1856 of file editor.c.

1857{
1858 const int nLen = lstrlenW(text);
1859 const int nTextLen = ME_GetTextLength(editor);
1860 int nMin, nMax;
1862 WCHAR wLastChar = ' ';
1863
1864 TRACE("flags==0x%08x, chrg->cpMin==%d, chrg->cpMax==%d text==%s\n",
1865 flags, chrg->cpMin, chrg->cpMax, debugstr_w(text));
1866
1868 FIXME("Flags 0x%08x not implemented\n",
1870
1871 nMin = chrg->cpMin;
1872 if (chrg->cpMax == -1)
1873 nMax = nTextLen;
1874 else
1875 nMax = chrg->cpMax > nTextLen ? nTextLen : chrg->cpMax;
1876
1877 /* In 1.0 emulation, if cpMax reaches end of text, add the FR_DOWN flag */
1878 if (editor->bEmulateVersion10 && nMax == nTextLen)
1879 {
1880 flags |= FR_DOWN;
1881 }
1882
1883 /* In 1.0 emulation, cpMin must always be no greater than cpMax */
1884 if (editor->bEmulateVersion10 && nMax < nMin)
1885 {
1886 if (chrgText)
1887 {
1888 chrgText->cpMin = -1;
1889 chrgText->cpMax = -1;
1890 }
1891 return -1;
1892 }
1893
1894 /* when searching up, if cpMin < cpMax, then instead of searching
1895 * on [cpMin,cpMax], we search on [0,cpMin], otherwise, search on
1896 * [cpMax, cpMin]. The exception is when cpMax is -1, in which
1897 * case, it is always bigger than cpMin.
1898 */
1899 if (!editor->bEmulateVersion10 && !(flags & FR_DOWN))
1900 {
1901 int nSwap = nMax;
1902
1903 nMax = nMin > nTextLen ? nTextLen : nMin;
1904 if (nMin < nSwap || chrg->cpMax == -1)
1905 nMin = 0;
1906 else
1907 nMin = nSwap;
1908 }
1909
1910 if (!nLen || nMin < 0 || nMax < 0 || nMax < nMin)
1911 {
1912 if (chrgText)
1913 chrgText->cpMin = chrgText->cpMax = -1;
1914 return -1;
1915 }
1916
1917 if (flags & FR_DOWN) /* Forward search */
1918 {
1919 /* If possible, find the character before where the search starts */
1920 if ((flags & FR_WHOLEWORD) && nMin)
1921 {
1922 ME_CursorFromCharOfs(editor, nMin - 1, &cursor);
1923 wLastChar = *get_text( &cursor.pRun->member.run, cursor.nOffset );
1924 ME_MoveCursorChars(editor, &cursor, 1, FALSE);
1925 } else {
1926 ME_CursorFromCharOfs(editor, nMin, &cursor);
1927 }
1928
1929 while (cursor.pRun && ME_GetCursorOfs(&cursor) + nLen <= nMax)
1930 {
1931 ME_DisplayItem *pCurItem = cursor.pRun;
1932 int nCurStart = cursor.nOffset;
1933 int nMatched = 0;
1934
1935 while (pCurItem && ME_CharCompare( *get_text( &pCurItem->member.run, nCurStart + nMatched ), text[nMatched], (flags & FR_MATCHCASE)))
1936 {
1937 if ((flags & FR_WHOLEWORD) && iswalnum(wLastChar))
1938 break;
1939
1940 nMatched++;
1941 if (nMatched == nLen)
1942 {
1943 ME_DisplayItem *pNextItem = pCurItem;
1944 int nNextStart = nCurStart;
1945 WCHAR wNextChar;
1946
1947 /* Check to see if next character is a whitespace */
1948 if (flags & FR_WHOLEWORD)
1949 {
1950 if (nCurStart + nMatched == pCurItem->member.run.len)
1951 {
1952 pNextItem = ME_FindItemFwd(pCurItem, diRun);
1953 nNextStart = -nMatched;
1954 }
1955
1956 if (pNextItem)
1957 wNextChar = *get_text( &pNextItem->member.run, nNextStart + nMatched );
1958 else
1959 wNextChar = ' ';
1960
1961 if (iswalnum(wNextChar))
1962 break;
1963 }
1964
1965 cursor.nOffset += cursor.pPara->member.para.nCharOfs + cursor.pRun->member.run.nCharOfs;
1966 if (chrgText)
1967 {
1968 chrgText->cpMin = cursor.nOffset;
1969 chrgText->cpMax = cursor.nOffset + nLen;
1970 }
1971 TRACE("found at %d-%d\n", cursor.nOffset, cursor.nOffset + nLen);
1972 return cursor.nOffset;
1973 }
1974 if (nCurStart + nMatched == pCurItem->member.run.len)
1975 {
1976 pCurItem = ME_FindItemFwd(pCurItem, diRun);
1977 nCurStart = -nMatched;
1978 }
1979 }
1980 if (pCurItem)
1981 wLastChar = *get_text( &pCurItem->member.run, nCurStart + nMatched );
1982 else
1983 wLastChar = ' ';
1984
1985 cursor.nOffset++;
1986 if (cursor.nOffset == cursor.pRun->member.run.len)
1987 {
1988 ME_NextRun(&cursor.pPara, &cursor.pRun, TRUE);
1989 cursor.nOffset = 0;
1990 }
1991 }
1992 }
1993 else /* Backward search */
1994 {
1995 /* If possible, find the character after where the search ends */
1996 if ((flags & FR_WHOLEWORD) && nMax < nTextLen - 1)
1997 {
1998 ME_CursorFromCharOfs(editor, nMax + 1, &cursor);
1999 wLastChar = *get_text( &cursor.pRun->member.run, cursor.nOffset );
2000 ME_MoveCursorChars(editor, &cursor, -1, FALSE);
2001 } else {
2002 ME_CursorFromCharOfs(editor, nMax, &cursor);
2003 }
2004
2005 while (cursor.pRun && ME_GetCursorOfs(&cursor) - nLen >= nMin)
2006 {
2007 ME_DisplayItem *pCurItem = cursor.pRun;
2008 ME_DisplayItem *pCurPara = cursor.pPara;
2009 int nCurEnd = cursor.nOffset;
2010 int nMatched = 0;
2011
2012 if (nCurEnd == 0)
2013 {
2014 ME_PrevRun(&pCurPara, &pCurItem, TRUE);
2015 nCurEnd = pCurItem->member.run.len;
2016 }
2017
2018 while (pCurItem && ME_CharCompare( *get_text( &pCurItem->member.run, nCurEnd - nMatched - 1 ),
2019 text[nLen - nMatched - 1], (flags & FR_MATCHCASE) ))
2020 {
2021 if ((flags & FR_WHOLEWORD) && iswalnum(wLastChar))
2022 break;
2023
2024 nMatched++;
2025 if (nMatched == nLen)
2026 {
2027 ME_DisplayItem *pPrevItem = pCurItem;
2028 int nPrevEnd = nCurEnd;
2029 WCHAR wPrevChar;
2030 int nStart;
2031
2032 /* Check to see if previous character is a whitespace */
2033 if (flags & FR_WHOLEWORD)
2034 {
2035 if (nPrevEnd - nMatched == 0)
2036 {
2037 pPrevItem = ME_FindItemBack(pCurItem, diRun);
2038 if (pPrevItem)
2039 nPrevEnd = pPrevItem->member.run.len + nMatched;
2040 }
2041
2042 if (pPrevItem)
2043 wPrevChar = *get_text( &pPrevItem->member.run, nPrevEnd - nMatched - 1 );
2044 else
2045 wPrevChar = ' ';
2046
2047 if (iswalnum(wPrevChar))
2048 break;
2049 }
2050
2051 nStart = pCurPara->member.para.nCharOfs
2052 + pCurItem->member.run.nCharOfs + nCurEnd - nMatched;
2053 if (chrgText)
2054 {
2055 chrgText->cpMin = nStart;
2056 chrgText->cpMax = nStart + nLen;
2057 }
2058 TRACE("found at %d-%d\n", nStart, nStart + nLen);
2059 return nStart;
2060 }
2061 if (nCurEnd - nMatched == 0)
2062 {
2063 ME_PrevRun(&pCurPara, &pCurItem, TRUE);
2064 /* Don't care about pCurItem becoming NULL here; it's already taken
2065 * care of in the exterior loop condition */
2066 nCurEnd = pCurItem->member.run.len + nMatched;
2067 }
2068 }
2069 if (pCurItem)
2070 wLastChar = *get_text( &pCurItem->member.run, nCurEnd - nMatched - 1 );
2071 else
2072 wLastChar = ' ';
2073
2074 cursor.nOffset--;
2075 if (cursor.nOffset < 0)
2076 {
2077 ME_PrevRun(&cursor.pPara, &cursor.pRun, TRUE);
2078 cursor.nOffset = cursor.pRun->member.run.len;
2079 }
2080 }
2081 }
2082 TRACE("not found\n");
2083 if (chrgText)
2084 chrgText->cpMin = chrgText->cpMax = -1;
2085 return -1;
2086}
#define FIXME(fmt,...)
Definition: debug.h:114
#define FR_WHOLEWORD
Definition: commdlg.h:145
#define FR_MATCHCASE
Definition: commdlg.h:136
#define FR_DOWN
Definition: commdlg.h:127
#define lstrlenW
Definition: compat.h:750
const WCHAR * text
Definition: package.c:1799
int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BOOL final_eop)
Definition: caret.c:720
static int ME_CharCompare(WCHAR a, WCHAR b, int caseSensitive)
Definition: editor.h:106
void ME_CursorFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_Cursor *pCursor) DECLSPEC_HIDDEN
Definition: run.c:171
BOOL ME_PrevRun(ME_DisplayItem **para, ME_DisplayItem **run, BOOL all_para) DECLSPEC_HIDDEN
Definition: list.c:93
#define iswalnum(_c)
Definition: ctype.h:671
#define debugstr_w
Definition: kernel32.h:32
LONG cpMax
Definition: richedit.h:501
LONG cpMin
Definition: richedit.h:500
int nCharOfs
Definition: editstr.h:162
int len
Definition: editstr.h:163

Referenced by ME_HandleMessage().

◆ ME_GetSelectionType()

static LONG ME_GetSelectionType ( ME_TextEditor editor)
static

Definition at line 2997 of file editor.c.

2998{
2999 LONG sel_type = SEL_EMPTY;
3000 LONG start, end;
3001
3002 ME_GetSelectionOfs(editor, &start, &end);
3003 if (start == end)
3004 sel_type = SEL_EMPTY;
3005 else
3006 {
3007 LONG object_count = 0, character_count = 0;
3008 int i;
3009
3010 for (i = 0; i < end - start; i++)
3011 {
3013
3014 ME_CursorFromCharOfs(editor, start + i, &cursor);
3015 if (cursor.pRun->member.run.reobj)
3016 object_count++;
3017 else
3018 character_count++;
3019 if (character_count >= 2 && object_count >= 2)
3021 }
3022 if (character_count)
3023 {
3024 sel_type |= SEL_TEXT;
3025 if (character_count >= 2)
3026 sel_type |= SEL_MULTICHAR;
3027 }
3028 if (object_count)
3029 {
3030 sel_type |= SEL_OBJECT;
3031 if (object_count >= 2)
3032 sel_type |= SEL_MULTIOBJECT;
3033 }
3034 }
3035 return sel_type;
3036}
long object_count
Definition: nc_alloc.cpp:37
long LONG
Definition: pedump.c:60
#define SEL_EMPTY
Definition: richedit.h:822
#define SEL_OBJECT
Definition: richedit.h:824
#define SEL_MULTICHAR
Definition: richedit.h:825
#define SEL_TEXT
Definition: richedit.h:823
#define SEL_MULTIOBJECT
Definition: richedit.h:826

Referenced by ME_HandleMessage(), and ME_ShowContextMenu().

◆ ME_GetTextEx()

static int ME_GetTextEx ( ME_TextEditor editor,
GETTEXTEX ex,
LPARAM  pText 
)
static

Definition at line 2088 of file editor.c.

2089{
2090 int nChars;
2092
2093 if (!ex->cb || !pText) return 0;
2094
2095 if (ex->flags & ~(GT_SELECTION | GT_USECRLF))
2096 FIXME("GETTEXTEX flags 0x%08x not supported\n", ex->flags & ~(GT_SELECTION | GT_USECRLF));
2097
2098 if (ex->flags & GT_SELECTION)
2099 {
2100 int from, to;
2101 int nStartCur = ME_GetSelectionOfs(editor, &from, &to);
2102 start = editor->pCursors[nStartCur];
2103 nChars = to - from;
2104 }
2105 else
2106 {
2107 ME_SetCursorToStart(editor, &start);
2108 nChars = INT_MAX;
2109 }
2110 if (ex->codepage == CP_UNICODE)
2111 {
2112 return ME_GetTextW(editor, (LPWSTR)pText, ex->cb / sizeof(WCHAR) - 1,
2113 &start, nChars, ex->flags & GT_USECRLF, FALSE);
2114 }
2115 else
2116 {
2117 /* potentially each char may be a CR, why calculate the exact value with O(N) when
2118 we can just take a bigger buffer? :)
2119 The above assumption still holds with CR/LF counters, since CR->CRLF expansion
2120 occurs only in richedit 2.0 mode, in which line breaks have only one CR
2121 */
2122 int crlfmul = (ex->flags & GT_USECRLF) ? 2 : 1;
2123 DWORD buflen;
2124 LPWSTR buffer;
2125 LRESULT rc;
2126
2127 buflen = min(crlfmul * nChars, ex->cb - 1);
2128 buffer = heap_alloc((buflen + 1) * sizeof(WCHAR));
2129
2130 nChars = ME_GetTextW(editor, buffer, buflen, &start, nChars, ex->flags & GT_USECRLF, FALSE);
2131 rc = WideCharToMultiByte(ex->codepage, 0, buffer, nChars + 1,
2132 (LPSTR)pText, ex->cb, ex->lpDefaultChar, ex->lpUsedDefChar);
2133 if (rc) rc--; /* do not count 0 terminator */
2134
2136 return rc;
2137 }
2138}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_UNICODE
Definition: stg_prop.c:74
int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int buflen, const ME_Cursor *start, int srcChars, BOOL bCRLF, BOOL bEOP)
Definition: editor.c:5192
GLuint buffer
Definition: glext.h:5915
#define INT_MAX
Definition: limits.h:40
#define min(a, b)
Definition: monoChain.cc:55
#define GT_SELECTION
Definition: richedit.h:1038
#define GT_USECRLF
Definition: richedit.h:1037
Definition: comerr.c:44
LPCSTR pText
Definition: txtscale.cpp:79
LONG_PTR LRESULT
Definition: windef.h:209
char * LPSTR
Definition: xmlstorage.h:182
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by ME_HandleMessage().

◆ ME_GetTextRange()

static int ME_GetTextRange ( ME_TextEditor editor,
WCHAR strText,
const ME_Cursor start,
int  nLen,
BOOL  unicode 
)
static

Definition at line 2140 of file editor.c.

2142{
2143 if (!strText) return 0;
2144 if (unicode) {
2145 return ME_GetTextW(editor, strText, INT_MAX, start, nLen, FALSE, FALSE);
2146 } else {
2147 int nChars;
2148 WCHAR *p = heap_alloc((nLen+1) * sizeof(*p));
2149 if (!p) return 0;
2150 nChars = ME_GetTextW(editor, p, nLen, start, nLen, FALSE, FALSE);
2151 WideCharToMultiByte(CP_ACP, 0, p, nChars+1, (char *)strText,
2152 nLen+1, NULL, NULL);
2153 heap_free(p);
2154 return nChars;
2155 }
2156}

Referenced by ME_HandleMessage().

◆ ME_GetTextW()

int ME_GetTextW ( ME_TextEditor editor,
WCHAR buffer,
int  buflen,
const ME_Cursor start,
int  srcChars,
BOOL  bCRLF,
BOOL  bEOP 
)

Definition at line 5192 of file editor.c.

5195{
5196 ME_DisplayItem *pRun, *pNextRun;
5197 const WCHAR *pStart = buffer;
5198 const WCHAR cr_lf[] = {'\r', '\n', 0};
5199 const WCHAR *str;
5200 int nLen;
5201
5202 /* bCRLF flag is only honored in 2.0 and up. 1.0 must always return text verbatim */
5203 if (editor->bEmulateVersion10) bCRLF = FALSE;
5204
5205 pRun = start->pRun;
5206 assert(pRun);
5207 pNextRun = ME_FindItemFwd(pRun, diRun);
5208
5209 nLen = pRun->member.run.len - start->nOffset;
5210 str = get_text( &pRun->member.run, start->nOffset );
5211
5212 while (srcChars && buflen && pNextRun)
5213 {
5214 int nFlags = pRun->member.run.nFlags;
5215
5216 if (bCRLF && nFlags & MERF_ENDPARA && ~nFlags & MERF_ENDCELL)
5217 {
5218 if (buflen == 1) break;
5219 /* FIXME: native fails to reduce srcChars here for WM_GETTEXT or
5220 * EM_GETTEXTEX, however, this is done for copying text which
5221 * also uses this function. */
5222 srcChars -= min(nLen, srcChars);
5223 nLen = 2;
5224 str = cr_lf;
5225 } else {
5226 nLen = min(nLen, srcChars);
5227 srcChars -= nLen;
5228 }
5229
5230 nLen = min(nLen, buflen);
5231 buflen -= nLen;
5232
5233 CopyMemory(buffer, str, sizeof(WCHAR) * nLen);
5234
5235 buffer += nLen;
5236
5237 pRun = pNextRun;
5238 pNextRun = ME_FindItemFwd(pRun, diRun);
5239
5240 nLen = pRun->member.run.len;
5241 str = get_text( &pRun->member.run, 0 );
5242 }
5243 /* append '\r' to the last paragraph. */
5244 if (pRun->next->type == diTextEnd && bEOP)
5245 {
5246 *buffer = '\r';
5247 buffer ++;
5248 }
5249 *buffer = 0;
5250 return buffer - pStart;
5251}
static const WCHAR cr_lf[]
Definition: table.c:59
#define assert(x)
Definition: debug.h:53
#define MERF_ENDCELL
Definition: editstr.h:109
@ diTextEnd
Definition: editstr.h:89
struct tagME_DisplayItem * next
Definition: editstr.h:257
int nFlags
Definition: editstr.h:165
#define CopyMemory
Definition: winbase.h:1710

Referenced by fnTextSrv_TxGetText(), get_unicode_text(), ITextRange_fnGetText(), ITextSelection_fnGetText(), ME_GetTextEx(), ME_GetTextRange(), ME_IsCandidateAnURL(), ME_StreamIn(), and range_GetChar().

◆ ME_HandleMessage()

LRESULT ME_HandleMessage ( ME_TextEditor editor,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  unicode,
HRESULT phresult 
)

Definition at line 3604 of file editor.c.

3606{
3607 *phresult = S_OK;
3608
3609 switch(msg) {
3610
3633
3634/* Messages specific to Richedit controls */
3635
3636 case EM_STREAMIN:
3637 return ME_StreamIn(editor, wParam, (EDITSTREAM*)lParam, TRUE);
3638 case EM_STREAMOUT:
3639 return ME_StreamOut(editor, wParam, (EDITSTREAM *)lParam);
3640 case WM_GETDLGCODE:
3641 {
3643
3644 if (lParam)
3645 editor->bDialogMode = TRUE;
3646 if (editor->styleFlags & ES_MULTILINE)
3648 if (!(editor->styleFlags & ES_SAVESEL))
3650 return code;
3651 }
3652 case EM_EMPTYUNDOBUFFER:
3653 ME_EmptyUndoStack(editor);
3654 return 0;
3655 case EM_GETSEL:
3656 {
3657 /* Note: wParam/lParam can be NULL */
3658 UINT from, to;
3659 PUINT pfrom = wParam ? (PUINT)wParam : &from;
3660 PUINT pto = lParam ? (PUINT)lParam : &to;
3661 ME_GetSelectionOfs(editor, (int *)pfrom, (int *)pto);
3662 if ((*pfrom|*pto) & 0xFFFF0000)
3663 return -1;
3664 return MAKELONG(*pfrom,*pto);
3665 }
3666 case EM_EXGETSEL:
3667 {
3668 CHARRANGE *pRange = (CHARRANGE *)lParam;
3669 ME_GetSelectionOfs(editor, &pRange->cpMin, &pRange->cpMax);
3670 TRACE("EM_EXGETSEL = (%d,%d)\n", pRange->cpMin, pRange->cpMax);
3671 return 0;
3672 }
3673 case EM_SETUNDOLIMIT:
3674 {
3675 if ((int)wParam < 0)
3677 else
3678 editor->nUndoLimit = min(wParam, STACK_SIZE_MAX);
3679 /* Setting a max stack size keeps wine from getting killed
3680 for hogging memory. Windows allocates all this memory at once, so
3681 no program would realistically set a value above our maximum. */
3682 return editor->nUndoLimit;
3683 }
3684 case EM_CANUNDO:
3685 return !list_empty( &editor->undo_stack );
3686 case EM_CANREDO:
3687 return !list_empty( &editor->redo_stack );
3688 case WM_UNDO: /* FIXME: actually not the same */
3689 case EM_UNDO:
3690 return ME_Undo(editor);
3691 case EM_REDO:
3692 return ME_Redo(editor);
3693 case EM_GETOPTIONS:
3694 {
3695 /* these flags are equivalent to the ES_* counterparts */
3698 DWORD settings = editor->styleFlags & mask;
3699
3700 return settings;
3701 }
3702 case EM_SETFONTSIZE:
3703 {
3705 LONG tmp_size, size;
3706 BOOL is_increase = ((LONG)wParam > 0);
3707
3708 if (editor->mode & TM_PLAINTEXT)
3709 return FALSE;
3710
3711 cf.cbSize = sizeof(cf);
3712 cf.dwMask = CFM_SIZE;
3713 ME_GetSelectionCharFormat(editor, &cf);
3714 tmp_size = (cf.yHeight / 20) + wParam;
3715
3716 if (tmp_size <= 1)
3717 size = 1;
3718 else if (tmp_size > 12 && tmp_size < 28 && tmp_size % 2)
3719 size = tmp_size + (is_increase ? 1 : -1);
3720 else if (tmp_size > 28 && tmp_size < 36)
3721 size = is_increase ? 36 : 28;
3722 else if (tmp_size > 36 && tmp_size < 48)
3723 size = is_increase ? 48 : 36;
3724 else if (tmp_size > 48 && tmp_size < 72)
3725 size = is_increase ? 72 : 48;
3726 else if (tmp_size > 72 && tmp_size < 80)
3727 size = is_increase ? 80 : 72;
3728 else if (tmp_size > 80 && tmp_size < 1638)
3729 size = 10 * (is_increase ? (tmp_size / 10 + 1) : (tmp_size / 10));
3730 else if (tmp_size >= 1638)
3731 size = 1638;
3732 else
3733 size = tmp_size;
3734
3735 cf.yHeight = size * 20; /* convert twips to points */
3736 ME_SetSelectionCharFormat(editor, &cf);
3737 ME_CommitUndo(editor);
3739 ME_UpdateScrollBar(editor);
3740
3741 return TRUE;
3742 }
3743 case EM_SETOPTIONS:
3744 {
3745 /* these flags are equivalent to ES_* counterparts, except for
3746 * ECO_AUTOWORDSELECTION that doesn't have an ES_* counterpart,
3747 * but is still stored in editor->styleFlags. */
3751 DWORD settings = mask & editor->styleFlags;
3752 DWORD oldSettings = settings;
3753 DWORD changedSettings;
3754
3755 switch(wParam)
3756 {
3757 case ECOOP_SET:
3758 settings = lParam;
3759 break;
3760 case ECOOP_OR:
3761 settings |= lParam;
3762 break;
3763 case ECOOP_AND:
3764 settings &= lParam;
3765 break;
3766 case ECOOP_XOR:
3767 settings ^= lParam;
3768 }
3769 changedSettings = oldSettings ^ settings;
3770
3771 if (changedSettings) {
3772 editor->styleFlags = (editor->styleFlags & ~mask) | (settings & mask);
3773
3774 if (changedSettings & ECO_SELECTIONBAR)
3775 {
3777 if (settings & ECO_SELECTIONBAR) {
3778 assert(!editor->selofs);
3779 editor->selofs = SELECTIONBAR_WIDTH;
3780 editor->rcFormat.left += editor->selofs;
3781 } else {
3782 editor->rcFormat.left -= editor->selofs;
3783 editor->selofs = 0;
3784 }
3785 ME_RewrapRepaint(editor);
3786 }
3787
3788 if ((changedSettings & settings & ES_NOHIDESEL) && !editor->bHaveFocus)
3789 ME_InvalidateSelection( editor );
3790
3791 if (changedSettings & settings & ECO_VERTICAL)
3792 FIXME("ECO_VERTICAL not implemented yet!\n");
3793 if (changedSettings & settings & ECO_AUTOHSCROLL)
3794 FIXME("ECO_AUTOHSCROLL not implemented yet!\n");
3795 if (changedSettings & settings & ECO_AUTOVSCROLL)
3796 FIXME("ECO_AUTOVSCROLL not implemented yet!\n");
3797 if (changedSettings & settings & ECO_WANTRETURN)
3798 FIXME("ECO_WANTRETURN not implemented yet!\n");
3799 if (changedSettings & settings & ECO_AUTOWORDSELECTION)
3800 FIXME("ECO_AUTOWORDSELECTION not implemented yet!\n");
3801 }
3802
3803 return settings;
3804 }
3805 case EM_SETSEL:
3806 {
3807 return set_selection( editor, wParam, lParam );
3808 }
3809 case EM_SETSCROLLPOS:
3810 {
3811 POINT *point = (POINT *)lParam;
3812 ME_ScrollAbs(editor, point->x, point->y);
3813 return 0;
3814 }
3815 case EM_AUTOURLDETECT:
3816 {
3817 if (wParam==1 || wParam ==0)
3818 {
3820 return 0;
3821 }
3822 return E_INVALIDARG;
3823 }
3825 {
3826 return editor->AutoURLDetect_bEnable;
3827 }
3828 case EM_EXSETSEL:
3829 {
3831
3832 return set_selection( editor, range.cpMin, range.cpMax );
3833 }
3834 case EM_SHOWSCROLLBAR:
3835 {
3836 DWORD flags;
3837
3838 switch (wParam)
3839 {
3840 case SB_HORZ:
3841 flags = WS_HSCROLL;
3842 break;
3843 case SB_VERT:
3844 flags = WS_VSCROLL;
3845 break;
3846 case SB_BOTH:
3848 break;
3849 default:
3850 return 0;
3851 }
3852
3853 if (lParam) {
3854 editor->styleFlags |= flags;
3855 if (flags & WS_HSCROLL)
3857 editor->nTotalWidth > editor->sizeWindow.cx);
3858 if (flags & WS_VSCROLL)
3860 editor->nTotalLength > editor->sizeWindow.cy);
3861 } else {
3862 editor->styleFlags &= ~flags;
3864 }
3865 return 0;
3866 }
3867 case EM_SETTEXTEX:
3868 {
3869 LPWSTR wszText;
3870 SETTEXTEX *pStruct = (SETTEXTEX *)wParam;
3871 int from, to, len;
3872 ME_Style *style;
3873 BOOL bRtf, bUnicode, bSelection, bUTF8;
3874 int oldModify = editor->nModifyStep;
3875 static const char utf8_bom[] = {0xef, 0xbb, 0xbf};
3876
3877 if (!pStruct) return 0;
3878
3879 /* If we detect ascii rtf at the start of the string,
3880 * we know it isn't unicode. */
3881 bRtf = (lParam && (!strncmp((char *)lParam, "{\\rtf", 5) ||
3882 !strncmp((char *)lParam, "{\\urtf", 6)));
3883 bUnicode = !bRtf && pStruct->codepage == CP_UNICODE;
3884 bUTF8 = (lParam && (!strncmp((char *)lParam, utf8_bom, 3)));
3885
3886 TRACE("EM_SETTEXTEX - %s, flags %d, cp %d\n",
3888 pStruct->flags, pStruct->codepage);
3889
3890 bSelection = (pStruct->flags & ST_SELECTION) != 0;
3891 if (bSelection) {
3892 int nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
3894 ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to - from, FALSE);
3895 } else {
3897 ME_SetCursorToStart(editor, &start);
3899 style = editor->pBuffer->pDefaultStyle;
3900 }
3901
3902 if (bRtf) {
3903 ME_StreamInRTFString(editor, bSelection, (char *)lParam);
3904 if (bSelection) {
3905 /* FIXME: The length returned doesn't include the rtf control
3906 * characters, only the actual text. */
3907 len = lParam ? strlen((char *)lParam) : 0;
3908 }
3909 } else {
3910 if (bUTF8 && !bUnicode) {
3911 wszText = ME_ToUnicode(CP_UTF8, (void *)(lParam+3), &len);
3912 ME_InsertTextFromCursor(editor, 0, wszText, len, style);
3913 ME_EndToUnicode(CP_UTF8, wszText);
3914 } else {
3915 wszText = ME_ToUnicode(pStruct->codepage, (void *)lParam, &len);
3916 ME_InsertTextFromCursor(editor, 0, wszText, len, style);
3917 ME_EndToUnicode(pStruct->codepage, wszText);
3918 }
3919 }
3920
3921 if (bSelection) {
3924 } else {
3926 len = 1;
3927 ME_SetCursorToStart(editor, &cursor);
3929 }
3930 ME_CommitUndo(editor);
3931 if (!(pStruct->flags & ST_KEEPUNDO))
3932 {
3933 editor->nModifyStep = oldModify;
3934 ME_EmptyUndoStack(editor);
3935 }
3936 ME_UpdateRepaint(editor, FALSE);
3937 return len;
3938 }
3939 case EM_SELECTIONTYPE:
3940 return ME_GetSelectionType(editor);
3941 case EM_SETBKGNDCOLOR:
3942 {
3943 LRESULT lColor;
3944 if (editor->rgbBackColor != -1) {
3945 DeleteObject(editor->hbrBackground);
3946 lColor = editor->rgbBackColor;
3947 }
3948 else lColor = ITextHost_TxGetSysColor(editor->texthost, COLOR_WINDOW);
3949
3950 if (wParam)
3951 {
3952 editor->rgbBackColor = -1;
3954 }
3955 else
3956 {
3957 editor->rgbBackColor = lParam;
3958 editor->hbrBackground = CreateSolidBrush(editor->rgbBackColor);
3959 }
3961 return lColor;
3962 }
3963 case EM_GETMODIFY:
3964 return editor->nModifyStep == 0 ? 0 : -1;
3965 case EM_SETMODIFY:
3966 {
3967 if (wParam)
3968 editor->nModifyStep = 1;
3969 else
3970 editor->nModifyStep = 0;
3971
3972 return 0;
3973 }
3974 case EM_SETREADONLY:
3975 {
3976 if (wParam)
3977 editor->styleFlags |= ES_READONLY;
3978 else
3979 editor->styleFlags &= ~ES_READONLY;
3980 return 1;
3981 }
3982 case EM_SETEVENTMASK:
3983 {
3984 DWORD nOldMask = editor->nEventMask;
3985
3986 editor->nEventMask = lParam;
3987 return nOldMask;
3988 }
3989 case EM_GETEVENTMASK:
3990 return editor->nEventMask;
3991 case EM_SETCHARFORMAT:
3992 return handle_EM_SETCHARFORMAT( editor, wParam, (CHARFORMAT2W *)lParam );
3993 case EM_GETCHARFORMAT:
3994 {
3996 if (dst->cbSize != sizeof(CHARFORMATA) &&
3997 dst->cbSize != sizeof(CHARFORMATW) &&
3998 dst->cbSize != sizeof(CHARFORMAT2A) &&
3999 dst->cbSize != sizeof(CHARFORMAT2W))
4000 return 0;
4001 tmp.cbSize = sizeof(tmp);
4002 if (!wParam)
4003 ME_GetDefaultCharFormat(editor, &tmp);
4004 else
4005 ME_GetSelectionCharFormat(editor, &tmp);
4006 cf2w_to_cfany(dst, &tmp);
4007 return tmp.dwMask;
4008 }
4009 case EM_SETPARAFORMAT:
4010 {
4013 ME_UpdateScrollBar(editor);
4014 ME_CommitUndo(editor);
4015 return result;
4016 }
4017 case EM_GETPARAFORMAT:
4019 return ((PARAFORMAT2 *)lParam)->dwMask;
4021 {
4022 ME_DisplayItem *p = editor->pBuffer->pFirst;
4023 int y = editor->vert_si.nPos;
4024 int ypara = 0;
4025 int count = 0;
4026 int ystart, yend;
4027 while(p) {
4029 if (p->type == diTextEnd)
4030 break;
4031 if (p->type == diParagraph) {
4032 ypara = p->member.para.pt.y;
4033 continue;
4034 }
4035 ystart = ypara + p->member.row.pt.y;
4036 yend = ystart + p->member.row.nHeight;
4037 if (y < yend) {
4038 break;
4039 }
4040 count++;
4041 }
4042 return count;
4043 }
4044 case EM_HIDESELECTION:
4045 {
4046 editor->bHideSelection = (wParam != 0);
4047 ME_InvalidateSelection(editor);
4048 return 0;
4049 }
4050 case EM_LINESCROLL:
4051 {
4052 if (!(editor->styleFlags & ES_MULTILINE))
4053 return FALSE;
4054 ME_ScrollDown( editor, lParam * get_default_line_height( editor ) );
4055 return TRUE;
4056 }
4057 case WM_CLEAR:
4058 {
4059 int from, to;
4060 int nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
4061 ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to-from, FALSE);
4062 ME_CommitUndo(editor);
4063 ME_UpdateRepaint(editor, TRUE);
4064 return 0;
4065 }
4066 case EM_REPLACESEL:
4067 {
4068 int len = 0;
4069 LONG codepage = unicode ? CP_UNICODE : CP_ACP;
4070 LPWSTR wszText = ME_ToUnicode(codepage, (void *)lParam, &len);
4071
4072 TRACE("EM_REPLACESEL - %s\n", debugstr_w(wszText));
4073
4074 ME_ReplaceSel(editor, !!wParam, wszText, len);
4075 ME_EndToUnicode(codepage, wszText);
4076 return len;
4077 }
4078 case EM_SCROLLCARET:
4079 ME_EnsureVisible(editor, &editor->pCursors[0]);
4080 return 0;
4081 case WM_SETFONT:
4082 {
4083 LOGFONTW lf;
4085 HDC hDC;
4086 BOOL bRepaint = LOWORD(lParam);
4087
4088 if (!wParam)
4090
4091 if (!GetObjectW((HGDIOBJ)wParam, sizeof(LOGFONTW), &lf))
4092 return 0;
4093
4094 hDC = ITextHost_TxGetDC(editor->texthost);
4097 if (editor->mode & TM_RICHTEXT) {
4099 ME_SetCursorToStart(editor, &start);
4100 ME_SetCharFormat(editor, &start, NULL, &fmt);
4101 }
4102 ME_SetDefaultCharFormat(editor, &fmt);
4103
4104 ME_CommitUndo(editor);
4105 ME_MarkAllForWrapping(editor);
4107 ME_UpdateScrollBar(editor);
4108 if (bRepaint)
4109 ME_Repaint(editor);
4110#ifdef __REACTOS__
4112 {
4113 HIMC hIMC = ImmGetContext(editor->hWnd);
4114 ImmSetCompositionFontW(hIMC, &lf);
4115 ImmReleaseContext(editor->hWnd, hIMC);
4116 }
4117#endif
4118 return 0;
4119 }
4120 case WM_SETTEXT:
4121 {
4123 ME_SetCursorToStart(editor, &cursor);
4125 if (lParam)
4126 {
4127 TRACE("WM_SETTEXT lParam==%lx\n",lParam);
4128 if (!strncmp((char *)lParam, "{\\rtf", 5) ||
4129 !strncmp((char *)lParam, "{\\urtf", 6))
4130 {
4131 /* Undocumented: WM_SETTEXT supports RTF text */
4132 ME_StreamInRTFString(editor, 0, (char *)lParam);
4133 }
4134 else
4135 ME_SetText(editor, (void*)lParam, unicode);
4136 }
4137 else
4138 TRACE("WM_SETTEXT - NULL\n");
4139 ME_SetCursorToStart(editor, &cursor);
4141 set_selection_cursors(editor, 0, 0);
4142 editor->nModifyStep = 0;
4143 ME_CommitUndo(editor);
4144 ME_EmptyUndoStack(editor);
4145 ME_UpdateRepaint(editor, FALSE);
4146 return 1;
4147 }
4148 case EM_CANPASTE:
4149 return paste_special( editor, 0, NULL, TRUE );
4150 case WM_PASTE:
4151 case WM_MBUTTONDOWN:
4152 wParam = 0;
4153 lParam = 0;
4154 /* fall through */
4155 case EM_PASTESPECIAL:
4157 return 0;
4158 case WM_CUT:
4159 case WM_COPY:
4160 copy_or_cut(editor, msg == WM_CUT);
4161 return 0;
4162 case WM_GETTEXTLENGTH:
4163 {
4164 GETTEXTLENGTHEX how;
4165
4166 /* CR/LF conversion required in 2.0 mode, verbatim in 1.0 mode */
4167 how.flags = GTL_CLOSE | (editor->bEmulateVersion10 ? 0 : GTL_USECRLF) | GTL_NUMCHARS;
4168 how.codepage = unicode ? CP_UNICODE : CP_ACP;
4169 return ME_GetTextLengthEx(editor, &how);
4170 }
4171 case EM_GETTEXTLENGTHEX:
4172 return ME_GetTextLengthEx(editor, (GETTEXTLENGTHEX *)wParam);
4173 case WM_GETTEXT:
4174 {
4175 GETTEXTEX ex;
4176 ex.cb = wParam * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
4177 ex.flags = GT_USECRLF;
4178 ex.codepage = unicode ? CP_UNICODE : CP_ACP;
4179 ex.lpDefaultChar = NULL;
4180 ex.lpUsedDefChar = NULL;
4181 return ME_GetTextEx(editor, &ex, lParam);
4182 }
4183 case EM_GETTEXTEX:
4184 return ME_GetTextEx(editor, (GETTEXTEX*)wParam, lParam);
4185 case EM_GETSELTEXT:
4186 {
4187 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(editor, &nFrom, &nTo);
4188 ME_Cursor *from = &editor->pCursors[nStartCur];
4189 return ME_GetTextRange(editor, (WCHAR *)lParam, from,
4190 nTo - nFrom, unicode);
4191 }
4192 case EM_GETSCROLLPOS:
4193 {
4194 POINT *point = (POINT *)lParam;
4195 point->x = editor->horz_si.nPos;
4196 point->y = editor->vert_si.nPos;
4197 /* 16-bit scaled value is returned as stored in scrollinfo */
4198 if (editor->horz_si.nMax > 0xffff)
4199 point->x = MulDiv(point->x, 0xffff, editor->horz_si.nMax);
4200 if (editor->vert_si.nMax > 0xffff)
4201 point->y = MulDiv(point->y, 0xffff, editor->vert_si.nMax);
4202 return 1;
4203 }
4204 case EM_GETTEXTRANGE:
4205 {
4206 TEXTRANGEW *rng = (TEXTRANGEW *)lParam;
4208 int nStart = rng->chrg.cpMin;
4209 int nEnd = rng->chrg.cpMax;
4210 int textlength = ME_GetTextLength(editor);
4211
4212 TRACE("EM_GETTEXTRANGE min=%d max=%d unicode=%d textlength=%d\n",
4213 rng->chrg.cpMin, rng->chrg.cpMax, unicode, textlength);
4214 if (nStart < 0) return 0;
4215 if ((nStart == 0 && nEnd == -1) || nEnd > textlength)
4216 nEnd = textlength;
4217 if (nStart >= nEnd) return 0;
4218
4219 ME_CursorFromCharOfs(editor, nStart, &start);
4220 return ME_GetTextRange(editor, rng->lpstrText, &start, nEnd - nStart, unicode);
4221 }
4222 case EM_GETLINE:
4223 {
4224 ME_DisplayItem *run;
4225 const unsigned int nMaxChars = *(WORD *) lParam;
4226 unsigned int nCharsLeft = nMaxChars;
4227 char *dest = (char *) lParam;
4228 BOOL wroteNull = FALSE;
4229
4230 TRACE("EM_GETLINE: row=%d, nMaxChars=%d (%s)\n", (int) wParam, nMaxChars,
4231 unicode ? "Unicode" : "Ansi");
4232
4233 run = ME_FindRowWithNumber(editor, wParam);
4234 if (run == NULL)
4235 return 0;
4236
4237 while (nCharsLeft && (run = ME_FindItemFwd(run, diRunOrStartRow))
4238 && run->type == diRun)
4239 {
4240 WCHAR *str = get_text( &run->member.run, 0 );
4241 unsigned int nCopy;
4242
4243 nCopy = min(nCharsLeft, run->member.run.len);
4244
4245 if (unicode)
4246 memcpy(dest, str, nCopy * sizeof(WCHAR));
4247 else
4248 nCopy = WideCharToMultiByte(CP_ACP, 0, str, nCopy, dest,
4249 nCharsLeft, NULL, NULL);
4250 dest += nCopy * (unicode ? sizeof(WCHAR) : 1);
4251 nCharsLeft -= nCopy;
4252 }
4253
4254 /* append line termination, space allowing */
4255 if (nCharsLeft > 0)
4256 {
4257 if (unicode)
4258 *((WCHAR *)dest) = '\0';
4259 else
4260 *dest = '\0';
4261 nCharsLeft--;
4262 wroteNull = TRUE;
4263 }
4264
4265 TRACE("EM_GETLINE: got %u characters\n", nMaxChars - nCharsLeft);
4266 return nMaxChars - nCharsLeft - (wroteNull ? 1 : 0);
4267 }
4268 case EM_GETLINECOUNT:
4269 {
4270 ME_DisplayItem *item = editor->pBuffer->pLast;
4271 int nRows = editor->total_rows;
4272 ME_DisplayItem *prev_para = NULL, *last_para = NULL;
4273
4274 last_para = ME_FindItemBack(item, diRun);
4275 prev_para = ME_FindItemBack(last_para, diRun);
4276 assert(last_para);
4277 assert(last_para->member.run.nFlags & MERF_ENDPARA);
4278 if (editor->bEmulateVersion10 && prev_para &&
4279 last_para->member.run.nCharOfs == 0 &&
4280 prev_para->member.run.len == 1 &&
4281 *get_text( &prev_para->member.run, 0 ) == '\r')
4282 {
4283 /* In 1.0 emulation, the last solitary \r at the very end of the text
4284 (if one exists) is NOT a line break.
4285 FIXME: this is an ugly hack. This should have a more regular model. */
4286 nRows--;
4287 }
4288
4289 TRACE("EM_GETLINECOUNT: nRows==%d\n", nRows);
4290 return max(1, nRows);
4291 }
4292 case EM_LINEFROMCHAR:
4293 {
4294 if (wParam == -1)
4295 return ME_RowNumberFromCharOfs(editor, ME_GetCursorOfs(&editor->pCursors[1]));
4296 else
4297 return ME_RowNumberFromCharOfs(editor, wParam);
4298 }
4299 case EM_EXLINEFROMCHAR:
4300 {
4301 if (lParam == -1)
4302 return ME_RowNumberFromCharOfs(editor, ME_GetCursorOfs(&editor->pCursors[1]));
4303 else
4304 return ME_RowNumberFromCharOfs(editor, lParam);
4305 }
4306 case EM_LINEINDEX:
4307 {
4308 ME_DisplayItem *item, *para;
4309 int nCharOfs;
4310
4311 if (wParam == -1)
4313 else
4314 item = ME_FindRowWithNumber(editor, wParam);
4315 if (!item)
4316 return -1;
4317 para = ME_GetParagraph(item);
4319 nCharOfs = para->member.para.nCharOfs + item->member.run.nCharOfs;
4320 TRACE("EM_LINEINDEX: nCharOfs==%d\n", nCharOfs);
4321 return nCharOfs;
4322 }
4323 case EM_LINELENGTH:
4324 {
4325 ME_DisplayItem *item, *item_end;
4326 int nChars = 0, nThisLineOfs = 0, nNextLineOfs = 0;
4327 ME_DisplayItem *para, *run;
4328
4329 if (wParam > ME_GetTextLength(editor))
4330 return 0;
4331 if (wParam == -1)
4332 {
4333 FIXME("EM_LINELENGTH: returning number of unselected characters on lines with selection unsupported.\n");
4334 return 0;
4335 }
4336 ME_RunOfsFromCharOfs(editor, wParam, &para, &run, NULL);
4337 item = ME_RowStart(run);
4338 nThisLineOfs = ME_CharOfsFromRunOfs(editor, para, ME_FindItemFwd(item, diRun), 0);
4340 if (item_end->type == diStartRow) {
4341 nNextLineOfs = ME_CharOfsFromRunOfs(editor, para, ME_FindItemFwd(item_end, diRun), 0);
4342 } else {
4343 ME_DisplayItem *endRun = ME_FindItemBack(item_end, diRun);
4344 assert(endRun && endRun->member.run.nFlags & MERF_ENDPARA);
4345 nNextLineOfs = item_end->member.para.nCharOfs - endRun->member.run.len;
4346 }
4347 nChars = nNextLineOfs - nThisLineOfs;
4348 TRACE("EM_LINELENGTH(%ld)==%d\n",wParam, nChars);
4349 return nChars;
4350 }
4351 case EM_EXLIMITTEXT:
4352 {
4353 if ((int)lParam < 0)
4354 return 0;
4355 if (lParam == 0)
4356 editor->nTextLimit = 65536;
4357 else
4358 editor->nTextLimit = (int) lParam;
4359 return 0;
4360 }
4361 case EM_LIMITTEXT:
4362 {
4363 if (wParam == 0)
4364 editor->nTextLimit = 65536;
4365 else
4366 editor->nTextLimit = (int) wParam;
4367 return 0;
4368 }
4369 case EM_GETLIMITTEXT:
4370 {
4371 return editor->nTextLimit;
4372 }
4373 case EM_FINDTEXT:
4374 {
4375 LRESULT r;
4376 if(!unicode){
4377 FINDTEXTA *ft = (FINDTEXTA *)lParam;
4378 int nChars = MultiByteToWideChar(CP_ACP, 0, ft->lpstrText, -1, NULL, 0);
4379 WCHAR *tmp;
4380
4381 if ((tmp = heap_alloc(nChars * sizeof(*tmp))) != NULL)
4382 MultiByteToWideChar(CP_ACP, 0, ft->lpstrText, -1, tmp, nChars);
4383 r = ME_FindText(editor, wParam, &ft->chrg, tmp, NULL);
4384 heap_free(tmp);
4385 }else{
4386 FINDTEXTW *ft = (FINDTEXTW *)lParam;
4387 r = ME_FindText(editor, wParam, &ft->chrg, ft->lpstrText, NULL);
4388 }
4389 return r;
4390 }
4391 case EM_FINDTEXTEX:
4392 {
4393 LRESULT r;
4394 if(!unicode){
4396 int nChars = MultiByteToWideChar(CP_ACP, 0, ex->lpstrText, -1, NULL, 0);
4397 WCHAR *tmp;
4398
4399 if ((tmp = heap_alloc(nChars * sizeof(*tmp))) != NULL)
4400 MultiByteToWideChar(CP_ACP, 0, ex->lpstrText, -1, tmp, nChars);
4401 r = ME_FindText(editor, wParam, &ex->chrg, tmp, &ex->chrgText);
4402 heap_free(tmp);
4403 }else{
4405 r = ME_FindText(editor, wParam, &ex->chrg, ex->lpstrText, &ex->chrgText);
4406 }
4407 return r;
4408 }
4409 case EM_FINDTEXTW:
4410 {
4411 FINDTEXTW *ft = (FINDTEXTW *)lParam;
4412 return ME_FindText(editor, wParam, &ft->chrg, ft->lpstrText, NULL);
4413 }
4414 case EM_FINDTEXTEXW:
4415 {
4417 return ME_FindText(editor, wParam, &ex->chrg, ex->lpstrText, &ex->chrgText);
4418 }
4419 case EM_GETZOOM:
4420 if (!wParam || !lParam)
4421 return FALSE;
4422 *(int *)wParam = editor->nZoomNumerator;
4423 *(int *)lParam = editor->nZoomDenominator;
4424 return TRUE;
4425 case EM_SETZOOM:
4426 return ME_SetZoom(editor, wParam, lParam);
4427 case EM_CHARFROMPOS:
4428 {
4430 if (ME_CharFromPos(editor, ((POINTL *)lParam)->x, ((POINTL *)lParam)->y,
4431 &cursor, NULL))
4432 return ME_GetCursorOfs(&cursor);
4433 else
4434 return -1;
4435 }
4436 case EM_POSFROMCHAR:
4437 {
4438 ME_DisplayItem *pPara, *pRun;
4439 int nCharOfs, nOffset, nLength;
4440 POINTL pt = {0,0};
4441
4442 nCharOfs = wParam;
4443 /* detect which API version we're dealing with */
4444 if (wParam >= 0x40000)
4445 nCharOfs = lParam;
4446 nLength = ME_GetTextLength(editor);
4447 nCharOfs = min(nCharOfs, nLength);
4448 nCharOfs = max(nCharOfs, 0);
4449
4450 ME_RunOfsFromCharOfs(editor, nCharOfs, &pPara, &pRun, &nOffset);
4451 assert(pRun->type == diRun);
4452 pt.y = pRun->member.run.pt.y;
4453 pt.x = pRun->member.run.pt.x + ME_PointFromChar(editor, &pRun->member.run, nOffset, TRUE);
4454 pt.y += pPara->member.para.pt.y + editor->rcFormat.top;
4455 pt.x += editor->rcFormat.left;
4456
4457 pt.x -= editor->horz_si.nPos;
4458 pt.y -= editor->vert_si.nPos;
4459
4460 if (wParam >= 0x40000) {
4461 *(POINTL *)wParam = pt;
4462 }
4463 return (wParam >= 0x40000) ? 0 : MAKELONG( pt.x, pt.y );
4464 }
4465 case WM_CREATE:
4466 return ME_WmCreate(editor, lParam, unicode);
4467 case WM_DESTROY:
4468 ME_DestroyEditor(editor);
4469 return 0;
4470 case WM_SETCURSOR:
4471 {
4472 POINT cursor_pos;
4473 if (wParam == (WPARAM)editor->hWnd && GetCursorPos(&cursor_pos) &&
4474 ScreenToClient(editor->hWnd, &cursor_pos))
4475 ME_LinkNotify(editor, msg, 0, MAKELPARAM(cursor_pos.x, cursor_pos.y));
4476 return ME_SetCursor(editor);
4477 }
4478 case WM_LBUTTONDBLCLK:
4479 case WM_LBUTTONDOWN:
4480 {
4481 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4482 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4483 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4484 return 0;
4486 ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam),
4489 editor->bMouseCaptured = TRUE;
4490 ME_LinkNotify(editor, msg, wParam, lParam);
4491 if (!ME_SetCursor(editor)) goto do_default;
4492 break;
4493 }
4494 case WM_MOUSEMOVE:
4495 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4496 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4497 return 0;
4498 if (editor->bMouseCaptured)
4499 ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
4500 else
4501 ME_LinkNotify(editor, msg, wParam, lParam);
4502 /* Set cursor if mouse is captured, since WM_SETCURSOR won't be received. */
4503 if (editor->bMouseCaptured)
4504 ME_SetCursor(editor);
4505 break;
4506 case WM_LBUTTONUP:
4507 if (editor->bMouseCaptured) {
4509 editor->bMouseCaptured = FALSE;
4510 }
4511 if (editor->nSelectionType == stDocument)
4512 editor->nSelectionType = stPosition;
4513 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4514 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4515 return 0;
4516 else
4517 {
4518 ME_SetCursor(editor);
4519 ME_LinkNotify(editor, msg, wParam, lParam);
4520 }
4521 break;
4522 case WM_RBUTTONUP:
4523 case WM_RBUTTONDOWN:
4524 case WM_RBUTTONDBLCLK:
4525 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4526 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4527 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4528 return 0;
4529 ME_LinkNotify(editor, msg, wParam, lParam);
4530 goto do_default;
4531 case WM_CONTEXTMENU:
4532 if (!ME_ShowContextMenu(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)))
4533 goto do_default;
4534 break;
4535 case WM_SETFOCUS:
4536 editor->bHaveFocus = TRUE;
4537 create_caret(editor);
4538 update_caret(editor);
4540 if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL))
4541 ME_InvalidateSelection( editor );
4542 return 0;
4543 case WM_KILLFOCUS:
4544 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4545 editor->bHaveFocus = FALSE;
4546 editor->wheel_remain = 0;
4547 hide_caret(editor);
4548 DestroyCaret();
4550 if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL))
4551 ME_InvalidateSelection( editor );
4552 return 0;
4553 case WM_COMMAND:
4554 TRACE("editor wnd command = %d\n", LOWORD(wParam));
4555 return 0;
4556 case WM_KEYUP:
4557 if ((editor->nEventMask & ENM_KEYEVENTS) &&
4558 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4559 return 0;
4560 goto do_default;
4561 case WM_KEYDOWN:
4562 if ((editor->nEventMask & ENM_KEYEVENTS) &&
4563 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4564 return 0;
4565 if (ME_KeyDown(editor, LOWORD(wParam)))
4566 return 0;
4567 goto do_default;
4568 case WM_CHAR:
4569 if ((editor->nEventMask & ENM_KEYEVENTS) &&
4570 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4571 return 0;
4572 return ME_Char(editor, wParam, lParam, unicode);
4573 case WM_UNICHAR:
4574 if (unicode)
4575 {
4576 if(wParam == UNICODE_NOCHAR) return TRUE;
4577 if(wParam <= 0x000fffff)
4578 {
4579 if(wParam > 0xffff) /* convert to surrogates */
4580 {
4581 wParam -= 0x10000;
4582 ME_Char(editor, (wParam >> 10) + 0xd800, 0, TRUE);
4583 ME_Char(editor, (wParam & 0x03ff) + 0xdc00, 0, TRUE);
4584 } else {
4585 ME_Char(editor, wParam, 0, TRUE);
4586 }
4587 }
4588 return 0;
4589 }
4590 break;
4591 case EM_STOPGROUPTYPING:
4592 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4593 return 0;
4594 case WM_HSCROLL:
4595 {
4596 const int scrollUnit = 7;
4597
4598 switch(LOWORD(wParam))
4599 {
4600 case SB_LEFT:
4601 ME_ScrollAbs(editor, 0, 0);
4602 break;
4603 case SB_RIGHT:
4604 ME_ScrollAbs(editor,
4605 editor->horz_si.nMax - (int)editor->horz_si.nPage,
4606 editor->vert_si.nMax - (int)editor->vert_si.nPage);
4607 break;
4608 case SB_LINELEFT:
4609 ME_ScrollLeft(editor, scrollUnit);
4610 break;
4611 case SB_LINERIGHT:
4612 ME_ScrollRight(editor, scrollUnit);
4613 break;
4614 case SB_PAGELEFT:
4615 ME_ScrollLeft(editor, editor->sizeWindow.cx);
4616 break;
4617 case SB_PAGERIGHT:
4618 ME_ScrollRight(editor, editor->sizeWindow.cx);
4619 break;
4620 case SB_THUMBTRACK:
4621 case SB_THUMBPOSITION:
4622 {
4623 int pos = HIWORD(wParam);
4624 if (editor->horz_si.nMax > 0xffff)
4625 pos = MulDiv(pos, editor->horz_si.nMax, 0xffff);
4626 ME_HScrollAbs(editor, pos);
4627 break;
4628 }
4629 }
4630 break;
4631 }
4632 case EM_SCROLL: /* fall through */
4633 case WM_VSCROLL:
4634 {
4635 int origNPos;
4636 int lineHeight = get_default_line_height( editor );
4637
4638 origNPos = editor->vert_si.nPos;
4639
4640 switch(LOWORD(wParam))
4641 {
4642 case SB_TOP:
4643 ME_ScrollAbs(editor, 0, 0);
4644 break;
4645 case SB_BOTTOM:
4646 ME_ScrollAbs(editor,
4647 editor->horz_si.nMax - (int)editor->horz_si.nPage,
4648 editor->vert_si.nMax - (int)editor->vert_si.nPage);
4649 break;
4650 case SB_LINEUP:
4651 ME_ScrollUp(editor,lineHeight);
4652 break;
4653 case SB_LINEDOWN:
4654 ME_ScrollDown(editor,lineHeight);
4655 break;
4656 case SB_PAGEUP:
4657 ME_ScrollUp(editor,editor->sizeWindow.cy);
4658 break;
4659 case SB_PAGEDOWN:
4660 ME_ScrollDown(editor,editor->sizeWindow.cy);
4661 break;
4662 case SB_THUMBTRACK:
4663 case SB_THUMBPOSITION:
4664 {
4665 int pos = HIWORD(wParam);
4666 if (editor->vert_si.nMax > 0xffff)
4667 pos = MulDiv(pos, editor->vert_si.nMax, 0xffff);
4668 ME_VScrollAbs(editor, pos);
4669 break;
4670 }
4671 }
4672 if (msg == EM_SCROLL)
4673 return 0x00010000 | (((editor->vert_si.nPos - origNPos)/lineHeight) & 0xffff);
4674 break;
4675 }
4676 case WM_MOUSEWHEEL:
4677 {
4678 int delta;
4679 BOOL ctrl_is_down;
4680
4681 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4682 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4683 return 0;
4684
4685 ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
4686
4687 delta = GET_WHEEL_DELTA_WPARAM(wParam);
4688
4689 /* if scrolling changes direction, ignore left overs */
4690 if ((delta < 0 && editor->wheel_remain < 0) ||
4691 (delta > 0 && editor->wheel_remain > 0))
4692 editor->wheel_remain += delta;
4693 else
4694 editor->wheel_remain = delta;
4695
4696 if (editor->wheel_remain)
4697 {
4698 if (ctrl_is_down) {
4699 int numerator;
4700 if (!editor->nZoomNumerator || !editor->nZoomDenominator)
4701 {
4702 numerator = 100;
4703 } else {
4704 numerator = editor->nZoomNumerator * 100 / editor->nZoomDenominator;
4705 }
4706 numerator += calc_wheel_change( &editor->wheel_remain, 10 );
4707 if (numerator >= 10 && numerator <= 500)
4708 ME_SetZoom(editor, numerator, 100);
4709 } else {
4710 UINT max_lines = 3;
4711 int lines = 0;
4712
4713 SystemParametersInfoW( SPI_GETWHEELSCROLLLINES, 0, &max_lines, 0 );
4714 if (max_lines)
4715 lines = calc_wheel_change( &editor->wheel_remain, (int)max_lines );
4716 if (lines)
4717 ME_ScrollDown( editor, -lines * get_default_line_height( editor ) );
4718 }
4719 }
4720 break;
4721 }
4722 case EM_GETRECT:
4723 {
4724 *((RECT *)lParam) = editor->rcFormat;
4725 if (editor->bDefaultFormatRect)
4726 ((RECT *)lParam)->left -= editor->selofs;
4727 return 0;
4728 }
4729 case EM_SETRECT:
4730 case EM_SETRECTNP:
4731 {
4732 if (lParam)
4733 {
4734 int border = 0;
4735 RECT clientRect;
4736 RECT *rc = (RECT *)lParam;
4737
4738 border = editor->exStyleFlags & WS_EX_CLIENTEDGE ? 1 : 0;
4739 ITextHost_TxGetClientRect(editor->texthost, &clientRect);
4740 if (wParam == 0)
4741 {
4742 editor->rcFormat.top = max(0, rc->top - border);
4743 editor->rcFormat.left = max(0, rc->left - border);
4744 editor->rcFormat.bottom = min(clientRect.bottom, rc->bottom);
4745 editor->rcFormat.right = min(clientRect.right, rc->right + border);
4746 } else if (wParam == 1) {
4747 /* MSDN incorrectly says a wParam value of 1 causes the
4748 * lParam rect to be used as a relative offset,
4749 * however, the tests show it just prevents min/max bound
4750 * checking. */
4751 editor->rcFormat.top = rc->top - border;
4752 editor->rcFormat.left = rc->left - border;
4753 editor->rcFormat.bottom = rc->bottom;
4754 editor->rcFormat.right = rc->right + border;
4755 } else {
4756 return 0;
4757 }
4758 editor->bDefaultFormatRect = FALSE;
4759 }
4760 else
4761 {
4763 editor->bDefaultFormatRect = TRUE;
4764 }
4765 ME_MarkAllForWrapping(editor);
4767 ME_UpdateScrollBar(editor);
4768 if (msg != EM_SETRECTNP)
4769 ME_Repaint(editor);
4770 return 0;
4771 }
4772 case EM_REQUESTRESIZE:
4773 ME_SendRequestResize(editor, TRUE);
4774 return 0;
4775 case WM_SETREDRAW:
4776 goto do_default;
4778 {
4779 RECT clientRect;
4780 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
4781
4782 if (winpos->flags & SWP_NOCLIENTSIZE) goto do_default;
4783 ITextHost_TxGetClientRect(editor->texthost, &clientRect);
4784 if (editor->bDefaultFormatRect) {
4786 } else {
4787 editor->rcFormat.right += clientRect.right - editor->prevClientRect.right;
4788 editor->rcFormat.bottom += clientRect.bottom - editor->prevClientRect.bottom;
4789 }
4790 editor->prevClientRect = clientRect;
4791 ME_RewrapRepaint(editor);
4792 goto do_default;
4793 }
4794#ifndef __REACTOS__
4795 /* IME messages to make richedit controls IME aware */
4796#endif
4797 case WM_IME_SETCONTEXT:
4798#ifdef __REACTOS__
4799 {
4800 if (FALSE) /* FIXME: Condition */
4801 lParam &= ~ISC_SHOWUICOMPOSITIONWINDOW;
4802
4803 if (wParam)
4804 {
4805 HIMC hIMC = ImmGetContext(editor->hWnd);
4807 if (pIC)
4808 {
4809 pIC->dwUIFlags &= ~0x40000;
4810 ImmUnlockIMC(hIMC);
4811 }
4812 if (FALSE) /* FIXME: Condition */
4814 ImmReleaseContext(editor->hWnd, hIMC);
4815 }
4816
4817 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4818 }
4819#endif
4820 case WM_IME_CONTROL:
4821#ifdef __REACTOS__
4822 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4823#endif
4824 case WM_IME_SELECT:
4825#ifdef __REACTOS__
4826 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4827#endif
4829 return 0;
4830 case WM_IME_STARTCOMPOSITION:
4831 {
4832#ifdef __REACTOS__
4833 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4834#else
4835 editor->imeStartIndex=ME_GetCursorOfs(&editor->pCursors[0]);
4836 ME_DeleteSelection(editor);
4837 ME_CommitUndo(editor);
4838 ME_UpdateRepaint(editor, FALSE);
4839#endif
4840 return 0;
4841 }
4842 case WM_IME_COMPOSITION:
4843 {
4844 HIMC hIMC;
4845
4846 ME_Style *style = ME_GetInsertStyle(editor, 0);
4847 hIMC = ITextHost_TxImmGetContext(editor->texthost);
4848 ME_DeleteSelection(editor);
4849 ME_SaveTempStyle(editor, style);
4851 {
4852 LPWSTR lpCompStr = NULL;
4854 DWORD dwIndex = lParam & GCS_RESULTSTR;
4855 if (!dwIndex)
4856 dwIndex = GCS_COMPSTR;
4857
4858 dwBufLen = ImmGetCompositionStringW(hIMC, dwIndex, NULL, 0);
4859 lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR));
4860 ImmGetCompositionStringW(hIMC, dwIndex, lpCompStr, dwBufLen);
4861 lpCompStr[dwBufLen/sizeof(WCHAR)] = 0;
4862#ifndef __REACTOS__
4863 ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style);
4864#endif
4865 HeapFree(GetProcessHeap(), 0, lpCompStr);
4866
4867#ifndef __REACTOS__
4868 if (dwIndex == GCS_COMPSTR)
4869 set_selection_cursors(editor,editor->imeStartIndex,
4870 editor->imeStartIndex + dwBufLen/sizeof(WCHAR));
4871#endif
4872 }
4874 ME_CommitUndo(editor);
4875 ME_UpdateRepaint(editor, FALSE);
4876#ifdef __REACTOS__
4877 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4878#else
4879 return 0;
4880#endif
4881 }
4882 case WM_IME_ENDCOMPOSITION:
4883 {
4884#ifdef __REACTOS__
4885 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4886#else
4887 ME_DeleteSelection(editor);
4888 editor->imeStartIndex=-1;
4889 return 0;
4890#endif
4891 }
4892 case EM_GETOLEINTERFACE:
4893 {
4894 if (!editor->reOle)
4895 if (!CreateIRichEditOle(NULL, editor, (LPVOID *)&editor->reOle))
4896 return 0;
4897 if (IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (LPVOID *)lParam) == S_OK)
4898 return 1;
4899 return 0;
4900 }
4901 case EM_GETPASSWORDCHAR:
4902 {
4903 return editor->cPasswordMask;
4904 }
4905 case EM_SETOLECALLBACK:
4906 if(editor->lpOleCallback)
4907 IRichEditOleCallback_Release(editor->lpOleCallback);
4909 if(editor->lpOleCallback)
4910 IRichEditOleCallback_AddRef(editor->lpOleCallback);
4911 return TRUE;
4913 return (LRESULT)editor->pfnWordBreak;
4915 {
4916 EDITWORDBREAKPROCW pfnOld = editor->pfnWordBreak;
4917
4919 return (LRESULT)pfnOld;
4920 }
4921 case EM_GETTEXTMODE:
4922 return editor->mode;
4923 case EM_SETTEXTMODE:
4924 {
4925 int mask = 0;
4926 int changes = 0;
4927
4928 if (ME_GetTextLength(editor) ||
4929 !list_empty( &editor->undo_stack ) || !list_empty( &editor->redo_stack ))
4930 return E_UNEXPECTED;
4931
4932 /* Check for mutually exclusive flags in adjacent bits of wParam */
4935 return E_INVALIDARG;
4936
4938 {
4941 if (wParam & TM_PLAINTEXT) {
4942 /* Clear selection since it should be possible to select the
4943 * end of text run for rich text */
4944 ME_InvalidateSelection(editor);
4945 ME_SetCursorToStart(editor, &editor->pCursors[0]);
4946 editor->pCursors[1] = editor->pCursors[0];
4947 /* plain text can only have the default style. */
4948 ME_ClearTempStyle(editor);
4951 editor->pCursors[0].pRun->member.run.style = editor->pBuffer->pDefaultStyle;
4952 }
4953 }
4954 /* FIXME: Currently no support for undo level and code page options */
4955 editor->mode = (editor->mode & ~mask) | changes;
4956 return 0;
4957 }
4958 case EM_SETPASSWORDCHAR:
4959 {
4960 editor->cPasswordMask = wParam;
4961 ME_RewrapRepaint(editor);
4962 return 0;
4963 }
4964 case EM_SETTARGETDEVICE:
4965 if (wParam == 0)
4966 {
4967 BOOL new = (lParam == 0 && (editor->styleFlags & ES_MULTILINE));
4968 if (editor->nAvailWidth || editor->bWordWrap != new)
4969 {
4970 editor->bWordWrap = new;
4971 editor->nAvailWidth = 0; /* wrap to client area */
4972 ME_RewrapRepaint(editor);
4973 }
4974 } else {
4975 int width = max(0, lParam);
4976 if ((editor->styleFlags & ES_MULTILINE) &&
4977 (!editor->bWordWrap || editor->nAvailWidth != width))
4978 {
4979 editor->nAvailWidth = width;
4980 editor->bWordWrap = TRUE;
4981 ME_RewrapRepaint(editor);
4982 }
4983 FIXME("EM_SETTARGETDEVICE doesn't use non-NULL target devices\n");
4984 }
4985 return TRUE;
4986 default:
4987 do_default:
4988 *phresult = S_FALSE;
4989 break;
4990 }
4991 return 0L;
4992}
static HDC hDC
Definition: 3dtext.c:33
struct mke2fs_defaults settings[]
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
int nRows
Definition: appswitch.c:56
static int list_empty(struct list_entry *head)
Definition: list.h:58
#define SWP_NOCLIENTSIZE
Definition: msg.h:29
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:899
#define E_INVALIDARG
Definition: ddrawi.h:101
DWORD HIMC
Definition: dimm.idl:75
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
Definition: ime.c:1744
BOOL WINAPI ImmIsIME(HKL hKL)
Definition: ime.c:880
BOOL WINAPI ImmNotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD_PTR dwValue)
Definition: ime.c:907
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1066
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1044
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:1085
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1057
void ME_DeleteSelection(ME_TextEditor *editor)
Definition: caret.c:1584
void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum)
Definition: caret.c:1204
int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how)
Definition: caret.c:91
void hide_caret(ME_TextEditor *editor)
Definition: caret.c:288
void ME_MouseMove(ME_TextEditor *editor, int x, int y)
Definition: caret.c:1266
BOOL ME_CharFromPos(ME_TextEditor *editor, int x, int y, ME_Cursor *cursor, BOOL *isExact)
Definition: caret.c:1122
int set_selection_cursors(ME_TextEditor *editor, int from, int to)
Definition: caret.c:132
void create_caret(ME_TextEditor *editor)
Definition: caret.c:272
void update_caret(ME_TextEditor *editor)
Definition: caret.c:298
ME_Style * ME_GetSelectionInsertStyle(ME_TextEditor *editor)
Definition: caret.c:1593
static void ME_StreamInRTFString(ME_TextEditor *editor, BOOL selection, char *string)
Definition: editor.c:1841
static BOOL paste_special(ME_TextEditor *editor, UINT cf, REPASTESPECIAL *ps, BOOL check_only)
Definition: editor.c:2292
#define UNSUPPORTED_MSG(e)
Definition: editor.c:3593
static int ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCHAR *text, CHARRANGE *chrgText)
Definition: editor.c:1856
static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stream, BOOL stripLastCR)
Definition: editor.c:1585
static void ME_SetText(ME_TextEditor *editor, void *text, BOOL unicode)
Definition: editor.c:3487
void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len)
Definition: editor.c:3463
static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode, LPARAM flags, BOOL unicode)
Definition: editor.c:2745
static BOOL ME_SetCursor(ME_TextEditor *editor)
Definition: editor.c:2897
static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y)
Definition: editor.c:3038
#define STACK_SIZE_MAX
Definition: editor.c:247
static void ME_SetDefaultFormatRect(ME_TextEditor *editor)
Definition: editor.c:2989
static int ME_GetTextRange(ME_TextEditor *editor, WCHAR *strText, const ME_Cursor *start, int nLen, BOOL unicode)
Definition: editor.c:2140
void ME_SendOldNotify(ME_TextEditor *editor, int nCode)
Definition: editor.c:5175
static LRESULT handle_EM_SETCHARFORMAT(ME_TextEditor *editor, WPARAM flags, const CHARFORMAT2W *fmt_in)
Definition: editor.c:3543
static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText)
Definition: editor.c:2088
static int calc_wheel_change(int *remain, int amount_per_click)
Definition: editor.c:3280
static BOOL ME_FilterEvent(ME_TextEditor *editor, UINT msg, WPARAM *wParam, LPARAM *lParam)
Definition: editor.c:2390
#define STACK_SIZE_DEFAULT
Definition: editor.c:246
static BOOL copy_or_cut(ME_TextEditor *editor, BOOL cut)
Definition: editor.c:2364
static int get_default_line_height(ME_TextEditor *editor)
Definition: editor.c:3269
static LONG ME_GetSelectionType(ME_TextEditor *editor)
Definition: editor.c:2997
static LRESULT ME_WmCreate(ME_TextEditor *editor, LPARAM lParam, BOOL unicode)
Definition: editor.c:3497
static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: editor.c:3423
static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int nChars)
Definition: editor.c:5533
void ME_DestroyEditor(ME_TextEditor *editor)
Definition: editor.c:3194
static BOOL ME_KeyDown(ME_TextEditor *editor, WORD nKey)
Definition: editor.c:2614
static int ME_CalculateClickCount(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: editor.c:2842
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define pt(x, y)
Definition: drawing.c:79
#define ITextHost_TxShowScrollBar(This, a, b)
Definition: editor.h:289
#define ITextHost_TxSetFocus(This)
Definition: editor.h:302
void ME_AddRefStyle(ME_Style *item) DECLSPEC_HIDDEN
Definition: style.c:454
void ME_ScrollRight(ME_TextEditor *editor, int cx) DECLSPEC_HIDDEN
Definition: paint.c:1131
#define ITextHost_TxInvalidateRect(This, a, b)
Definition: editor.h:293
void ME_ScrollAbs(ME_TextEditor *editor, int x, int y) DECLSPEC_HIDDEN
Definition: paint.c:1043
BOOL ME_SetZoom(ME_TextEditor *editor, int numerator, int denominator) DECLSPEC_HIDDEN
Definition: paint.c:1373
void ME_SendRequestResize(ME_TextEditor *editor, BOOL force) DECLSPEC_HIDDEN
Definition: wrap.c:1198
BOOL ME_Redo(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: undo.c:453
void ME_RunOfsFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_DisplayItem **ppPara, ME_DisplayItem **ppRun, int *pOfs) DECLSPEC_HIDDEN
Definition: run.c:184
void ME_GetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
Definition: run.c:790
#define ITextHost_TxSetCapture(This, a)
Definition: editor.h:301
#define ITextHost_TxGetSysColor(This, a)
Definition: editor.h:312
void ME_CharFormatFromLogFont(HDC hDC, const LOGFONTW *lf, CHARFORMAT2W *fmt) DECLSPEC_HIDDEN
Definition: style.c:331
void ME_EndToUnicode(LONG codepage, LPVOID psz) DECLSPEC_HIDDEN
Definition: string.c:248
void ME_ScrollLeft(ME_TextEditor *editor, int cx) DECLSPEC_HIDDEN
Definition: paint.c:1126
void ME_EnsureVisible(ME_TextEditor *editor, ME_Cursor *pCursor) DECLSPEC_HIDDEN
Definition: paint.c:1275
ME_DisplayItem * ME_GetParagraph(ME_DisplayItem *run) DECLSPEC_HIDDEN
Definition: para.c:815
void ME_VScrollAbs(ME_TextEditor *editor, int y) DECLSPEC_HIDDEN
Definition: paint.c:1111
#define ITextHost_TxGetClientRect(This, a)
Definition: editor.h:308
#define ITextHost_TxGetDC(This)
Definition: editor.h:287
void ME_ScrollUp(ME_TextEditor *editor, int cy) DECLSPEC_HIDDEN
Definition: paint.c:1116
void ME_InvalidateSelection(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: paint.c:1322
int ME_RowNumberFromCharOfs(ME_TextEditor *editor, int nOfs) DECLSPEC_HIDDEN
Definition: row.c:64
void ME_HScrollAbs(ME_TextEditor *editor, int x) DECLSPEC_HIDDEN
Definition: paint.c:1106
int ME_CharOfsFromRunOfs(ME_TextEditor *editor, const ME_DisplayItem *pPara, const ME_DisplayItem *pRun, int nOfs) DECLSPEC_HIDDEN
Definition: run.c:156
void ME_GetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
Definition: run.c:801
void ME_RewrapRepaint(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: paint.c:142
BOOL ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
Definition: para.c:907
#define ITextHost_TxReleaseDC(This, a)
Definition: editor.h:288
ME_DisplayItem * ME_FindRowWithNumber(ME_TextEditor *editor, int nRow) DECLSPEC_HIDDEN
Definition: row.c:44
void ME_Repaint(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: paint.c:106
#define ITextHost_TxImmGetContext(This)
Definition: editor.h:323
ME_DisplayItem * ME_RowStart(ME_DisplayItem *item) DECLSPEC_HIDDEN
Definition: row.c:31
void ME_ScrollDown(ME_TextEditor *editor, int cy) DECLSPEC_HIDDEN
Definition: paint.c:1121
void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
Definition: para.c:937
BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from) DECLSPEC_HIDDEN
Definition: style.c:79
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN
Definition: run.c:598
void ME_MarkAllForWrapping(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: para.c:236
LPWSTR ME_ToUnicode(LONG codepage, LPVOID psz, INT *len) DECLSPEC_HIDDEN
Definition: string.c:226
LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream) DECLSPEC_HIDDEN
Definition: writer.c:1179
BOOL ME_Undo(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: undo.c:414
@ diStartRow
Definition: editstr.h:88
@ diStartRowOrParagraphOrEnd
Definition: editstr.h:93
@ diRunOrStartRow
Definition: editstr.h:95
#define SELECTIONBAR_WIDTH
Definition: editstr.h:100
@ stPosition
Definition: editstr.h:357
@ stDocument
Definition: editstr.h:361
POINTL point
Definition: edittest.c:50
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
GLenum GLint GLuint mask
Definition: glext.h:6028
GLenum GLenum dst
Definition: glext.h:6340
GLenum GLsizei len
Definition: glext.h:6722
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
#define CPS_CANCEL
Definition: imm.h:181
#define GCS_RESULTSTR
Definition: imm.h:234
#define GCS_COMPSTR
Definition: imm.h:227
#define NI_COMPOSITIONSTR
Definition: immdev.h:403
JSAMPARRAY JDIMENSION max_lines
Definition: jpeglib.h:1058
#define debugstr_a
Definition: kernel32.h:31
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HDC
Definition: imagelist.c:92
static char * dest
Definition: rtl.c:135
static ATOM item
Definition: dde.c:856
#define set_selection(hctl, start, end)
unsigned int * PUINT
Definition: ndis.h:50
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
#define L(x)
Definition: ntvdm.h:50
#define ES_NOHIDESEL
Definition: pedump.c:673
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
#define TM_RICHTEXT
Definition: richedit.h:1029
#define ECO_NOHIDESEL
Definition: richedit.h:459
#define TM_MULTILEVELUNDO
Definition: richedit.h:1031
#define EM_GETAUTOURLDETECT
Definition: richedit.h:126
#define EM_CANREDO
Definition: richedit.h:118
#define EM_SCROLLCARET
Definition: richedit.h:81
#define ECO_WANTRETURN
Definition: richedit.h:461
#define EM_SETPALETTE
Definition: richedit.h:127
#define EM_SETOLECALLBACK
Definition: richedit.h:103
#define EM_GETREDONAME
Definition: richedit.h:120
#define GTL_CLOSE
Definition: richedit.h:1057
#define EM_GETEVENTMASK
Definition: richedit.h:92
#define EM_REDO
Definition: richedit.h:117
#define EM_REQUESTRESIZE
Definition: richedit.h:98
#define EM_GETSELTEXT
Definition: richedit.h:95
#define EM_SETBIDIOPTIONS
Definition: richedit.h:154
#define EM_AUTOURLDETECT
Definition: richedit.h:125
#define EM_FORMATRANGE
Definition: richedit.h:90
#define EM_SETZOOM
Definition: richedit.h:170
#define EM_STREAMIN
Definition: richedit.h:106
#define EM_SETSCROLLPOS
Definition: richedit.h:166
#define ECO_AUTOWORDSELECTION
Definition: richedit.h:456
#define ST_SELECTION
Definition: richedit.h:1072
#define EM_SETEVENTMASK
Definition: richedit.h:102
#define EM_SETOPTIONS
Definition: richedit.h:110
#define WM_UNICHAR
Definition: richedit.h:67
#define ECO_VERTICAL
Definition: richedit.h:464
#define ST_KEEPUNDO
Definition: richedit.h:1071
#define EM_GETUNDONAME
Definition: richedit.h:119
#define EM_GETTEXTMODE
Definition: richedit.h:124
#define EM_GETWORDBREAKPROCEX
Definition: richedit.h:113
#define EM_GETBIDIOPTIONS
Definition: richedit.h:155
#define EM_SETBKGNDCOLOR
Definition: richedit.h:100
#define EM_SETTEXTEX
Definition: richedit.h:131
#define EM_HIDESELECTION
Definition: richedit.h:96
#define EM_POSFROMCHAR
Definition: richedit.h:77
#define EM_GETCHARFORMAT
Definition: richedit.h:91
#define GTL_NUMCHARS
Definition: richedit.h:1058
#define TM_SINGLECODEPAGE
Definition: richedit.h:1032
struct _charformatw CHARFORMATW
#define EM_SETCHARFORMAT
Definition: richedit.h:101
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define EM_SETFONTSIZE
Definition: richedit.h:168
#define EM_GETLANGOPTIONS
Definition: richedit.h:144
#define EM_GETPARAFORMAT
Definition: richedit.h:94
#define EM_SHOWSCROLLBAR
Definition: richedit.h:130
#define ENM_KEYEVENTS
Definition: richedit.h:475
#define EM_SETWORDBREAKPROCEX
Definition: richedit.h:114
#define EM_GETOPTIONS
Definition: richedit.h:111
#define EM_DISPLAYBAND
Definition: richedit.h:84
#define EM_SETLANGOPTIONS
Definition: richedit.h:143
#define ECO_AUTOHSCROLL
Definition: richedit.h:458
#define EM_GETEDITSTYLE
Definition: richedit.h:161
#define EM_GETTEXTRANGE
Definition: richedit.h:108
#define EM_SETTEXTMODE
Definition: richedit.h:123
#define CFM_SIZE
Definition: richedit.h:362
#define EM_FINDTEXTW
Definition: richedit.h:147
#define EM_GETZOOM
Definition: richedit.h:169
#define EM_EXSETSEL
Definition: richedit.h:88
#define ECOOP_XOR
Definition: richedit.h:453
#define EM_GETSCROLLPOS
Definition: richedit.h:165
#define EM_EXLIMITTEXT
Definition: richedit.h:86
#define EM_PASTESPECIAL
Definition: richedit.h:97
#define EM_SELECTIONTYPE
Definition: richedit.h:99
#define EM_FINDTEXT
Definition: richedit.h:89
#define EM_STOPGROUPTYPING
Definition: richedit.h:121
#define ES_SAVESEL
Definition: richedit.h:226
#define ECO_READONLY
Definition: richedit.h:460
#define ECOOP_OR
Definition: richedit.h:451
#define EM_SETTYPOGRAPHYOPTIONS
Definition: richedit.h:157
#define EM_GETTEXTLENGTHEX
Definition: richedit.h:129
#define ECOOP_SET
Definition: richedit.h:450
#define EM_SETTARGETDEVICE
Definition: richedit.h:105
struct _charformat2w CHARFORMAT2W
#define EM_GETLIMITTEXT
Definition: richedit.h:74
#define EM_EXLINEFROMCHAR
Definition: richedit.h:87
#define EM_GETIMECOMPMODE
Definition: richedit.h:145
#define EM_GETOLEINTERFACE
Definition: richedit.h:93
#define ECO_AUTOVSCROLL
Definition: richedit.h:457
#define EM_GETTEXTEX
Definition: richedit.h:128
#define EM_SETPARAFORMAT
Definition: richedit.h:104
#define EM_FINDTEXTEXW
Definition: richedit.h:148
#define TM_SINGLELEVELUNDO
Definition: richedit.h:1030
#define EM_EXGETSEL
Definition: richedit.h:85
#define EM_GETTYPOGRAPHYOPTIONS
Definition: richedit.h:158
#define EM_FINDTEXTEX
Definition: richedit.h:112
#define ENM_MOUSEEVENTS
Definition: richedit.h:476
#define EM_SETUNDOLIMIT
Definition: richedit.h:116
#define GTL_USECRLF
Definition: richedit.h:1055
#define EM_FINDWORDBREAK
Definition: richedit.h:109
#define TM_MULTICODEPAGE
Definition: richedit.h:1033
#define ECO_SELECTIONBAR
Definition: richedit.h:463
#define EM_SETEDITSTYLE
Definition: richedit.h:160
#define ECOOP_AND
Definition: richedit.h:452
#define EM_STREAMOUT
Definition: richedit.h:107
#define CP_UTF8
Definition: nls.h:20
static char utf8_bom[3]
Definition: file.c:108
static CHANGE * changes
Definition: io.c:49
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
UINT flags
Definition: winuser.h:3594
CHARRANGE chrg
Definition: richedit.h:581
LPCSTR lpstrText
Definition: richedit.h:582
CHARRANGE chrg
Definition: richedit.h:586
LPCWSTR lpstrText
Definition: richedit.h:587
UINT codepage
Definition: richedit.h:1066
DWORD flags
Definition: richedit.h:1065
CHARRANGE chrg
Definition: richedit.h:514
LPWSTR lpstrText
Definition: richedit.h:515
Definition: inflate.c:139
ME_DIType type
Definition: editstr.h:256
POINT pt
Definition: editstr.h:167
ME_DisplayItem * pLast
Definition: editstr.h:268
EDITWORDBREAKPROCW pfnWordBreak
Definition: editstr.h:417
struct list redo_stack
Definition: editstr.h:403
int nZoomNumerator
Definition: editstr.h:411
BOOL bDefaultFormatRect
Definition: editstr.h:414
SCROLLINFO vert_si
Definition: editstr.h:441
RECT prevClientRect
Definition: editstr.h:412
ME_SelectionType nSelectionType
Definition: editstr.h:434
BOOL AutoURLDetect_bEnable
Definition: editstr.h:425
SCROLLINFO horz_si
Definition: editstr.h:441
int nZoomDenominator
Definition: editstr.h:411
struct list undo_stack
Definition: editstr.h:402
BOOL bHideSelection
Definition: editstr.h:424
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define max(a, b)
Definition: svc.c:63
#define WM_MOUSEWHEEL
Definition: treelist.c:96
eMaj lines
Definition: tritemp.h:206
#define MAKELONG(a, b)
Definition: typedefs.h:249
int codepage
Definition: win_iconv.c:156
_In_ DWORD nLength
Definition: wincon.h:473
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_ DWORD _In_ DWORD dwBufLen
Definition: wincrypt.h:4246
#define E_UNEXPECTED
Definition: winerror.h:2456
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
#define SYSTEM_FONT
Definition: wingdi.h:911
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define EM_SETREADONLY
Definition: winuser.h:2015
#define EM_GETIMESTATUS
Definition: winuser.h:1987
#define WM_GETTEXTLENGTH
Definition: winuser.h:1619
#define EM_GETRECT
Definition: winuser.h:1996
HKL WINAPI GetKeyboardLayout(_In_ DWORD)
#define EM_LIMITTEXT
Definition: winuser.h:2000
#define SB_THUMBTRACK
Definition: winuser.h:573
#define EM_LINEFROMCHAR
Definition: winuser.h:2001
#define SB_LINEUP
Definition: winuser.h:564
#define WM_HSCROLL
Definition: winuser.h:1743
#define WM_PASTE
Definition: winuser.h:1863
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
#define WM_KEYUP
Definition: winuser.h:1716
#define EN_KILLFOCUS
Definition: winuser.h:2025
#define EM_GETWORDBREAKPROC
Definition: winuser.h:1999
#define COLOR_WINDOW
Definition: winuser.h:918
#define EM_FMTLINES
Definition: winuser.h:1986
#define EM_GETPASSWORDCHAR
Definition: winuser.h:1995
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_VSCROLL
Definition: winuser.h:1744
#define WM_CREATE
Definition: winuser.h:1608
#define DLGC_WANTCHARS
Definition: winuser.h:2618
#define DLGC_WANTTAB
Definition: winuser.h:2611
#define EM_SETIMESTATUS
Definition: winuser.h:2010
#define EN_SETFOCUS
Definition: winuser.h:2027
#define EM_SETPASSWORDCHAR
Definition: winuser.h:2014
#define EM_GETMODIFY
Definition: winuser.h:1994
#define SB_PAGERIGHT
Definition: winuser.h:571
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define SB_VERT
Definition: winuser.h:553
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:1985
#define SB_LEFT
Definition: winuser.h:575
#define SB_BOTTOM
Definition: winuser.h:577
#define WM_COMMAND
Definition: winuser.h:1740
#define EM_REPLACESEL
Definition: winuser.h:2006
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2701
#define EM_SETRECT
Definition: winuser.h:2016
#define WM_RBUTTONUP
Definition: winuser.h:1780
#define WM_SETFOCUS
Definition: winuser.h:1613
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define WM_GETTEXT
Definition: winuser.h:1618
#define WM_CUT
Definition: winuser.h:1861
#define SB_LINERIGHT
Definition: winuser.h:567
#define EM_LINEINDEX
Definition: winuser.h:2002
#define EM_LINESCROLL
Definition: winuser.h:2004
#define EM_GETFIRSTVISIBLELINE
Definition: winuser.h:1988
#define WM_UNDO
Definition: winuser.h:1865
#define WM_IME_SETCONTEXT
Definition: winuser.h:1829
#define WM_SETTEXT
Definition: winuser.h:1617
#define EM_CANUNDO
Definition: winuser.h:1983
#define EM_LINELENGTH
Definition: winuser.h:2003
#define EM_GETLINE
Definition: winuser.h:1991
#define EM_SETRECTNP
Definition: winuser.h:2017
#define SB_LINELEFT
Definition: winuser.h:566
#define WM_SETFONT
Definition: winuser.h:1650
#define EM_UNDO
Definition: winuser.h:2021
#define DLGC_WANTARROWS
Definition: winuser.h:2610
#define EM_SCROLL
Definition: winuser.h:2007
#define SB_PAGEDOWN
Definition: winuser.h:569
#define EM_SETWORDBREAKPROC
Definition: winuser.h:2020
#define SB_BOTH
Definition: winuser.h:555
#define SB_LINEDOWN
Definition: winuser.h:565
#define EM_SETSEL
Definition: winuser.h:2018
int(CALLBACK * EDITWORDBREAKPROCW)(LPWSTR, int, int, int)
Definition: winuser.h:2905
#define WM_LBUTTONUP
Definition: winuser.h:1777
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define WM_IME_COMPOSITIONFULL
Definition: winuser.h:1832
#define WM_CHAR
Definition: winuser.h:1717
#define SB_TOP
Definition: winuser.h:578
#define WM_COPY
Definition: winuser.h:1862
#define WM_SETCURSOR
Definition: winuser.h:1636
#define WM_IME_CONTROL
Definition: winuser.h:1831
#define EM_SETTABSTOPS
Definition: winuser.h:2019
#define DLGC_WANTMESSAGE
Definition: winuser.h:2613
#define WM_IME_SELECT
Definition: winuser.h:1833
#define WM_DESTROY
Definition: winuser.h:1609
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WM_CLEAR
Definition: winuser.h:1864
#define EM_GETLINECOUNT
Definition: winuser.h:1992
#define SB_RIGHT
Definition: winuser.h:576
BOOL WINAPI DestroyCaret(void)
Definition: caret.c:35
#define EM_SETMARGINS
Definition: winuser.h:2012
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1662
#define DLGC_HASSETSEL
Definition: winuser.h:2614
#define WM_KILLFOCUS
Definition: winuser.h:1614
#define SB_PAGEUP
Definition: winuser.h:568
#define WM_GETDLGCODE
Definition: winuser.h:1689
#define EM_SETMODIFY
Definition: winuser.h:2013
#define SB_HORZ
Definition: winuser.h:552
#define SB_PAGELEFT
Definition: winuser.h:570
#define WM_SETREDRAW
Definition: winuser.h:1616
#define SB_THUMBPOSITION
Definition: winuser.h:572
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
const char * LPCSTR
Definition: xmlstorage.h:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by fnTextSrv_TxSendMessage(), and RichEditWndProc_common().

◆ ME_IsCandidateAnURL()

static BOOL ME_IsCandidateAnURL ( ME_TextEditor editor,
const ME_Cursor start,
int  nChars 
)
static

This proc evaluates the selection and returns TRUE if it can be considered an URL

Definition at line 5486 of file editor.c.

5487{
5488#define MAX_PREFIX_LEN 9
5489 struct prefix_s {
5490 const WCHAR text[MAX_PREFIX_LEN];
5491 int length;
5492 }prefixes[] = {
5493 {{'p','r','o','s','p','e','r','o',':'}, 9},
5494 {{'t','e','l','n','e','t',':'}, 7},
5495 {{'g','o','p','h','e','r',':'}, 7},
5496 {{'m','a','i','l','t','o',':'}, 7},
5497 {{'h','t','t','p','s',':'}, 6},
5498 {{'f','i','l','e',':'}, 5},
5499 {{'n','e','w','s',':'}, 5},
5500 {{'w','a','i','s',':'}, 5},
5501 {{'n','n','t','p',':'}, 5},
5502 {{'h','t','t','p',':'}, 5},
5503 {{'w','w','w','.'}, 4},
5504 {{'f','t','p',':'}, 4},
5505 };
5506 WCHAR bufferW[MAX_PREFIX_LEN + 1];
5507 unsigned int i;
5508
5509 ME_GetTextW(editor, bufferW, MAX_PREFIX_LEN, start, nChars, FALSE, FALSE);
5510 for (i = 0; i < ARRAY_SIZE(prefixes); i++)
5511 {
5512 if (nChars < prefixes[i].length) continue;
5513 if (!memcmp(prefixes[i].text, bufferW, prefixes[i].length * sizeof(WCHAR)))
5514 return TRUE;
5515 }
5516 return FALSE;
5517#undef MAX_PREFIX_LEN
5518}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define MAX_PREFIX_LEN
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
static int prefixes
Definition: i386-dis.c:276

Referenced by ME_UpdateLinkAttribute().

◆ ME_KeyDown()

static BOOL ME_KeyDown ( ME_TextEditor editor,
WORD  nKey 
)
static

Definition at line 2614 of file editor.c.

2615{
2616 BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
2617 BOOL shift_is_down = GetKeyState(VK_SHIFT) & 0x8000;
2618
2619 if (editor->bMouseCaptured)
2620 return FALSE;
2621 if (nKey != VK_SHIFT && nKey != VK_CONTROL && nKey != VK_MENU)
2622 editor->nSelectionType = stPosition;
2623
2624 switch (nKey)
2625 {
2626 case VK_LEFT:
2627 case VK_RIGHT:
2628 case VK_HOME:
2629 case VK_END:
2630 editor->nUDArrowX = -1;
2631 /* fall through */
2632 case VK_UP:
2633 case VK_DOWN:
2634 case VK_PRIOR:
2635 case VK_NEXT:
2636 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
2637 ME_ArrowKey(editor, nKey, shift_is_down, ctrl_is_down);
2638 return TRUE;
2639 case VK_BACK:
2640 case VK_DELETE:
2641 editor->nUDArrowX = -1;
2642 /* FIXME backspace and delete aren't the same, they act different wrt paragraph style of the merged paragraph */
2643 if (editor->styleFlags & ES_READONLY)
2644 return FALSE;
2645 if (ME_IsSelection(editor))
2646 {
2647 ME_DeleteSelection(editor);
2648 ME_CommitUndo(editor);
2649 }
2650 else if (nKey == VK_DELETE)
2651 {
2652 /* Delete stops group typing.
2653 * (See MSDN remarks on EM_STOPGROUPTYPING message) */
2654 ME_DeleteTextAtCursor(editor, 1, 1);
2655 ME_CommitUndo(editor);
2656 }
2657 else if (ME_ArrowKey(editor, VK_LEFT, FALSE, FALSE))
2658 {
2659 BOOL bDeletionSucceeded;
2660 /* Backspace can be grouped for a single undo */
2662 bDeletionSucceeded = ME_DeleteTextAtCursor(editor, 1, 1);
2663 if (!bDeletionSucceeded && !editor->bEmulateVersion10) { /* v4.1 */
2664 /* Deletion was prevented so the cursor is moved back to where it was.
2665 * (e.g. this happens when trying to delete cell boundaries)
2666 */
2667 ME_ArrowKey(editor, VK_RIGHT, FALSE, FALSE);
2668 }
2670 }
2671 else
2672 return TRUE;
2675 ME_UpdateRepaint(editor, FALSE);
2676 ME_SendRequestResize(editor, FALSE);
2677 return TRUE;
2678 case VK_RETURN:
2679 if (!editor->bEmulateVersion10)
2680 return handle_enter(editor);
2681 break;
2682 case VK_ESCAPE:
2683 if (editor->bDialogMode && editor->hwndParent)
2684 PostMessageW(editor->hwndParent, WM_CLOSE, 0, 0);
2685 return TRUE;
2686 case VK_TAB:
2687 if (editor->bDialogMode && editor->hwndParent)
2688 SendMessageW(editor->hwndParent,