ReactOS 0.4.15-dev-5858-g16decc6
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 242 of file editor.c.

◆ STACK_SIZE_MAX

#define STACK_SIZE_MAX   1000

Definition at line 243 of file editor.c.

◆ TEXT_LIMIT_DEFAULT

#define TEXT_LIMIT_DEFAULT   32767

Definition at line 245 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 3589 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 3276 of file editor.c.

3277{
3278 int change = amount_per_click * (float)*remain / WHEEL_DELTA;
3279 *remain -= WHEEL_DELTA * change / amount_per_click;
3280 return change;
3281}
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 2360 of file editor.c.

2361{
2362 BOOL result;
2363 int offs, num_chars;
2364 int start_cursor = ME_GetSelectionOfs(editor, &offs, &num_chars);
2365 ME_Cursor *sel_start = &editor->pCursors[start_cursor];
2366
2367 if (cut && (editor->styleFlags & ES_READONLY))
2368 {
2370 return FALSE;
2371 }
2372
2373 num_chars -= offs;
2374 result = ME_Copy(editor, sel_start, num_chars);
2375 if (result && cut)
2376 {
2377 ME_InternalDeleteText(editor, sel_start, num_chars, FALSE);
2378 ME_CommitUndo(editor);
2379 ME_UpdateRepaint(editor, TRUE);
2380 }
2381 return result;
2382}
#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:315
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:2336
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:781

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 4936 of file editor.c.

4937{
4938 ITextHost *host = ME_CreateTextHost( hwnd, create, emulate_10 );
4939 ME_TextEditor *editor;
4940
4941 if (!host) return FALSE;
4942
4943 editor = ME_MakeEditor( host, emulate_10 );
4944 if (!editor)
4945 {
4946 ITextHost_Release( host );
4947 return FALSE;
4948 }
4949
4952 editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
4953 editor->hwndParent = create->hwndParent;
4954
4955 SetWindowLongPtrW( hwnd, 0, (LONG_PTR)editor );
4956
4957 return TRUE;
4958}
ME_TextEditor * ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
Definition: editor.c:3052
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:5336
#define GWL_STYLE
Definition: winuser.h:846
#define GWL_EXSTYLE
Definition: winuser.h:845

Referenced by RichEdit10ANSIWndProc(), and RichEditWndProc_common().

◆ DllMain()

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

Definition at line 3234 of file editor.c.

3235{
3236 TRACE("\n");
3237 switch (fdwReason)
3238 {
3239 case DLL_PROCESS_ATTACH:
3240 DisableThreadLibraryCalls(hinstDLL);
3241 me_heap = HeapCreate (0, 0x10000, 0);
3242 if (!ME_RegisterEditorClass(hinstDLL)) return FALSE;
3244 LookupInit();
3245 break;
3246
3247 case DLL_PROCESS_DETACH:
3248 if (lpvReserved) break;
3252 UnregisterClassA("RichEdit50A", 0);
3257 LookupCleanup();
3260 break;
3261 }
3262 return TRUE;
3263}
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:257
static const WCHAR REListBox20W[]
Definition: editor.c:252
static BOOL ME_ListBoxRegistered
Definition: editor.c:259
static BOOL ME_ComboBoxRegistered
Definition: editor.c:260
static HCURSOR hLeft
Definition: editor.c:254
static const WCHAR REComboBox20W[]
Definition: editor.c:253
static BOOL ME_RegisterEditorClass(HINSTANCE)
Definition: editor.c:5195
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:2074
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 3265 of file editor.c.

3266{
3267 int height = 0;
3268
3269 if (editor->pBuffer && editor->pBuffer->pDefaultStyle)
3271 if (height <= 0) height = 24;
3272
3273 return height;
3274}
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 3410 of file editor.c.

3411{
3412 if (msg >= EM_GETSEL && msg <= EM_CHARFROMPOS)
3413 return edit_messages[msg - EM_GETSEL];
3414 if (msg >= EM_CANPASTE && msg <= EM_GETIMEMODEBIAS)
3416 return "";
3417}
#define msg(x)
Definition: auth_time.c:54
static const char *const richedit_messages[]
Definition: editor.c:3328
static const char *const edit_messages[]
Definition: editor.c:3283
#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:1987

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 3539 of file editor.c.

3540{
3542 BOOL changed = TRUE;
3544
3545 if (!cfany_to_cf2w( &fmt, fmt_in )) return 0;
3546
3547 if (flags & SCF_ALL)
3548 {
3549 if (editor->mode & TM_PLAINTEXT)
3550 {
3551 ME_SetDefaultCharFormat( editor, &fmt );
3552 }
3553 else
3554 {
3555 ME_SetCursorToStart( editor, &start );
3556 ME_SetCharFormat( editor, &start, NULL, &fmt );
3557 editor->nModifyStep = 1;
3558 }
3559 }
3560 else if (flags & SCF_SELECTION)
3561 {
3562 if (editor->mode & TM_PLAINTEXT) return 0;
3563 if (flags & SCF_WORD)
3564 {
3565 end = editor->pCursors[0];
3566 ME_MoveCursorWords( editor, &end, +1 );
3567 start = end;
3568 ME_MoveCursorWords( editor, &start, -1 );
3569 ME_SetCharFormat( editor, &start, &end, &fmt );
3570 }
3571 changed = ME_IsSelection( editor );
3572 ME_SetSelectionCharFormat( editor, &fmt );
3573 if (changed) editor->nModifyStep = 1;
3574 }
3575 else /* SCF_DEFAULT */
3576 {
3577 ME_SetDefaultCharFormat( editor, &fmt );
3578 }
3579
3580 ME_CommitUndo( editor );
3581 if (changed)
3582 {
3583 ME_WrapMarkedParagraphs( editor );
3584 ME_UpdateScrollBar( editor );
3585 }
3586 return 1;
3587}
#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:1533
BOOL ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
Definition: caret.c:754
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 2434 of file editor.c.

2435{
2436 BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
2437 BOOL shift_is_down = GetKeyState(VK_SHIFT) & 0x8000;
2438
2439 if (editor->bDialogMode)
2440 {
2441 if (ctrl_is_down)
2442 return TRUE;
2443
2444 if (!(editor->styleFlags & ES_WANTRETURN))
2445 {
2446 if (editor->hwndParent)
2447 {
2448 DWORD dw;
2449 dw = SendMessageW(editor->hwndParent, DM_GETDEFID, 0, 0);
2450 if (HIWORD(dw) == DC_HASDEFID)
2451 {
2452 HWND hwDefCtrl = GetDlgItem(editor->hwndParent, LOWORD(dw));
2453 if (hwDefCtrl)
2454 {
2455 SendMessageW(editor->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, TRUE);
2456 PostMessageW(hwDefCtrl, WM_KEYDOWN, VK_RETURN, 0);
2457 }
2458 }
2459 }
2460 return TRUE;
2461 }
2462 }
2463
2464 if (editor->styleFlags & ES_MULTILINE)
2465 {
2466 static const WCHAR endl = '\r';
2467 static const WCHAR endlv10[] = {'\r','\n'};
2468 ME_Cursor cursor = editor->pCursors[0];
2469 ME_DisplayItem *para = cursor.pPara;
2470 int from, to;
2471 ME_Style *style, *eop_style;
2472
2473 if (editor->styleFlags & ES_READONLY)
2474 {
2476 return TRUE;
2477 }
2478
2479 ME_GetSelectionOfs(editor, &from, &to);
2480 if (editor->nTextLimit > ME_GetTextLength(editor) - (to-from))
2481 {
2482 if (!editor->bEmulateVersion10) /* v4.1 */
2483 {
2484 if (para->member.para.nFlags & MEPF_ROWEND)
2485 {
2486 /* Add a new table row after this row. */
2487 para = ME_AppendTableRow(editor, para);
2488 para = para->member.para.next_para;
2489 editor->pCursors[0].pPara = para;
2490 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
2491 editor->pCursors[0].nOffset = 0;
2492 editor->pCursors[1] = editor->pCursors[0];
2493 ME_CommitUndo(editor);
2495 ME_UpdateRepaint(editor, FALSE);
2496 return TRUE;
2497 }
2498 else if (para == editor->pCursors[1].pPara &&
2499 cursor.nOffset + cursor.pRun->member.run.nCharOfs == 0 &&
2500 para->member.para.prev_para->member.para.nFlags & MEPF_ROWSTART &&
2501 !para->member.para.prev_para->member.para.nCharOfs)
2502 {
2503 /* Insert a newline before the table. */
2504 para = para->member.para.prev_para;
2505 para->member.para.nFlags &= ~MEPF_ROWSTART;
2506 editor->pCursors[0].pPara = para;
2507 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
2508 editor->pCursors[1] = editor->pCursors[0];
2509 ME_InsertTextFromCursor(editor, 0, &endl, 1,
2510 editor->pCursors[0].pRun->member.run.style);
2511 para = editor->pBuffer->pFirst->member.para.next_para;
2512 ME_SetDefaultParaFormat(editor, &para->member.para.fmt);
2513 para->member.para.nFlags = 0;
2514 mark_para_rewrap(editor, para);
2515 editor->pCursors[0].pPara = para;
2516 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
2517 editor->pCursors[1] = editor->pCursors[0];
2518 para->member.para.next_para->member.para.nFlags |= MEPF_ROWSTART;
2521 ME_UpdateRepaint(editor, FALSE);
2522 return TRUE;
2523 }
2524 }
2525 else /* v1.0 - 3.0 */
2526 {
2527 ME_DisplayItem *para = cursor.pPara;
2528 if (ME_IsInTable(para))
2529 {
2530 if (cursor.pRun->member.run.nFlags & MERF_ENDPARA)
2531 {
2532 if (from == to)
2533 {
2535 para = ME_AppendTableRow(editor, para);
2536 editor->pCursors[0].pPara = para;
2537 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
2538 editor->pCursors[0].nOffset = 0;
2539 editor->pCursors[1] = editor->pCursors[0];
2541 ME_UpdateRepaint(editor, FALSE);
2542 return TRUE;
2543 }
2544 }
2545 else
2546 {
2548 if (cursor.pRun->member.run.nCharOfs + cursor.nOffset == 0 &&
2550 {
2551 /* Insert newline before table */
2552 cursor.pRun = ME_FindItemBack(para, diRun);
2553 if (cursor.pRun)
2554 {
2555 editor->pCursors[0].pRun = cursor.pRun;
2556 editor->pCursors[0].pPara = para->member.para.prev_para;
2557 }
2558 editor->pCursors[0].nOffset = 0;
2559 editor->pCursors[1] = editor->pCursors[0];
2560 ME_InsertTextFromCursor(editor, 0, &endl, 1,
2561 editor->pCursors[0].pRun->member.run.style);
2562 }
2563 else
2564 {
2565 editor->pCursors[1] = editor->pCursors[0];
2566 para = ME_AppendTableRow(editor, para);
2567 editor->pCursors[0].pPara = para;
2568 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
2569 editor->pCursors[0].nOffset = 0;
2570 editor->pCursors[1] = editor->pCursors[0];
2571 }
2573 ME_UpdateRepaint(editor, FALSE);
2574 return TRUE;
2575 }
2576 }
2577 }
2578
2579 style = ME_GetInsertStyle(editor, 0);
2580
2581 /* Normally the new eop style is the insert style, however in a list it is copied from the existing
2582 eop style (this prevents the list label style changing when the new eop is inserted).
2583 No extra ref is taken here on eop_style. */
2584 if (para->member.para.fmt.wNumbering)
2585 eop_style = para->member.para.eop_run->style;
2586 else
2587 eop_style = style;
2589 if (shift_is_down)
2590 ME_InsertEndRowFromCursor(editor, 0);
2591 else
2592 if (!editor->bEmulateVersion10)
2593 ME_InsertTextFromCursor(editor, 0, &endl, 1, eop_style);
2594 else
2595 ME_InsertTextFromCursor(editor, 0, endlv10, 2, eop_style);
2597 SetCursor(NULL);
2598
2600 ME_UpdateRepaint(editor, FALSE);
2601 ME_SaveTempStyle(editor, style); /* set the temp insert style for the new para */
2603 }
2604 return TRUE;
2605 }
2606 return FALSE;
2607}
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:535
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style)
Definition: caret.c:550
int ME_GetTextLength(ME_TextEditor *editor)
Definition: caret.c:83
static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor)
Definition: editor.c:2406
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::@523 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:2193
#define DC_HASDEFID
Definition: winuser.h:2599
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_NEXTDLGCTL
Definition: winuser.h:1633
#define VK_RETURN
Definition: winuser.h:2191
#define VK_SHIFT
Definition: winuser.h:2192
#define WM_KEYDOWN
Definition: winuser.h:1705
#define DM_GETDEFID
Definition: winuser.h:2088
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 2272 of file editor.c.

2273{
2274 struct paste_format *format;
2275 static int done;
2276
2277 if (!done)
2278 {
2279 for (format = paste_formats; format->fmt.cfFormat; format++)
2280 {
2281 if (format->name)
2282 format->fmt.cfFormat = RegisterClipboardFormatW( format->name );
2283 }
2284 done = 1;
2285 }
2286}
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 1123 of file editor.c.

1125{
1126 LPOLEOBJECT lpObject = NULL;
1127 LPSTORAGE lpStorage = NULL;
1128 LPOLECLIENTSITE lpClientSite = NULL;
1129 LPDATAOBJECT lpDataObject = NULL;
1130 LPOLECACHE lpOleCache = NULL;
1131 LPRICHEDITOLE lpReOle = NULL;
1132 STGMEDIUM stgm;
1133 FORMATETC fm;
1134 CLSID clsid;
1135 HRESULT hr = E_FAIL;
1136 DWORD conn;
1137
1138 if (hemf)
1139 {
1140 stgm.tymed = TYMED_ENHMF;
1141 stgm.u.hEnhMetaFile = hemf;
1142 fm.cfFormat = CF_ENHMETAFILE;
1143 }
1144 else if (hbmp)
1145 {
1146 stgm.tymed = TYMED_GDI;
1147 stgm.u.hBitmap = hbmp;
1148 fm.cfFormat = CF_BITMAP;
1149 }
1150 stgm.pUnkForRelease = NULL;
1151
1152 fm.ptd = NULL;
1153 fm.dwAspect = DVASPECT_CONTENT;
1154 fm.lindex = -1;
1155 fm.tymed = stgm.tymed;
1156
1157 if (!editor->reOle)
1158 {
1159 if (!CreateIRichEditOle(NULL, editor, (LPVOID *)&editor->reOle))
1160 return hr;
1161 }
1162
1163 if (OleCreateDefaultHandler(&CLSID_NULL, NULL, &IID_IOleObject, (void**)&lpObject) == S_OK &&
1164 IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (void**)&lpReOle) == S_OK &&
1165 IRichEditOle_GetClientSite(lpReOle, &lpClientSite) == S_OK &&
1166 IOleObject_SetClientSite(lpObject, lpClientSite) == S_OK &&
1167 IOleObject_GetUserClassID(lpObject, &clsid) == S_OK &&
1168 IOleObject_QueryInterface(lpObject, &IID_IOleCache, (void**)&lpOleCache) == S_OK &&
1169 IOleCache_Cache(lpOleCache, &fm, 0, &conn) == S_OK &&
1170 IOleObject_QueryInterface(lpObject, &IID_IDataObject, (void**)&lpDataObject) == S_OK &&
1171 IDataObject_SetData(lpDataObject, &fm, &stgm, TRUE) == S_OK)
1172 {
1173 REOBJECT reobject;
1174
1175 reobject.cbStruct = sizeof(reobject);
1176 reobject.cp = REO_CP_SELECTION;
1177 reobject.clsid = clsid;
1178 reobject.poleobj = lpObject;
1179 reobject.pstg = lpStorage;
1180 reobject.polesite = lpClientSite;
1181 /* convert from twips to .01 mm */
1182 reobject.sizel.cx = MulDiv(sz->cx, 254, 144);
1183 reobject.sizel.cy = MulDiv(sz->cy, 254, 144);
1184 reobject.dvaspect = DVASPECT_CONTENT;
1185 reobject.dwFlags = 0; /* FIXME */
1186 reobject.dwUser = 0;
1187
1188 ME_InsertOLEFromCursor(editor, &reobject, 0);
1189 hr = S_OK;
1190 }
1191
1192 if (lpObject) IOleObject_Release(lpObject);
1193 if (lpClientSite) IOleClientSite_Release(lpClientSite);
1194 if (lpStorage) IStorage_Release(lpStorage);
1195 if (lpDataObject) IDataObject_Release(lpDataObject);
1196 if (lpOleCache) IOleCache_Release(lpOleCache);
1197 if (lpReOle) IRichEditOle_Release(lpReOle);
1198
1199 return hr;
1200}
#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:501
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
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
LONG cx
Definition: windef.h:334
LONG cy
Definition: windef.h:335

Referenced by ME_RTFReadPictGroup(), and paste_emf().

◆ is_link()

static BOOL is_link ( ME_Run run)
static

Definition at line 2888 of file editor.c.

2889{
2890 return (run->style->fmt.dwMask & CFM_LINK) && (run->style->fmt.dwEffects & CFE_LINK);
2891}
#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 262 of file editor.c.

263{
264 return !(GetVersion() & 0x80000000);
265}
DWORD WINAPI GetVersion()
Definition: redirtest.c:5

Referenced by ME_RegisterEditorClass().

◆ isurlneutral()

static BOOL isurlneutral ( WCHAR  c)
static

Definition at line 5310 of file editor.c.

5311{
5312 /* NB this list is sorted */
5313 static const WCHAR neutral_chars[] = {'!','\"','\'','(',')',',','-','.',':',';','<','>','?','[',']','{','}'};
5314
5315 /* Some shortcuts */
5316 if (isalnum( c )) return FALSE;
5317 if (c > neutral_chars[ARRAY_SIZE( neutral_chars ) - 1]) return FALSE;
5318
5319 return !!bsearch( &c, neutral_chars, ARRAY_SIZE( neutral_chars ), sizeof(c), wchar_comp );
5320}
#define ARRAY_SIZE(A)
Definition: main.h:33
static int __cdecl wchar_comp(const void *key, const void *elem)
Definition: editor.c:5303
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 395 of file editor.c.

398{
399 int i, colorNum;
400 ME_Border *pBorders[] = {&borderRect->top,
401 &borderRect->left,
402 &borderRect->bottom,
403 &borderRect->right};
404 for (i = 0; i < 4; i++)
405 {
406 RTFColor *colorDef = info->colorList;
407 pBorders[i]->width = borderDef[i].width;
408 colorNum = borderDef[i].color;
409 while (colorDef && colorDef->rtfCNum != colorNum)
410 colorDef = colorDef->rtfNextColor;
411 if (colorDef)
412 pBorders[i]->colorRef = RGB(
413 colorDef->rtfCRed >= 0 ? colorDef->rtfCRed : 0,
414 colorDef->rtfCGreen >= 0 ? colorDef->rtfCGreen : 0,
415 colorDef->rtfCBlue >= 0 ? colorDef->rtfCBlue : 0);
416 else
417 pBorders[i]->colorRef = RGB(0, 0, 0);
418 }
419}
#define RGB(r, g, b)
Definition: precomp.h:62
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 2838 of file editor.c.

2840{
2841 static int clickNum = 0;
2842 if (msg < WM_MOUSEFIRST || msg > WM_MOUSELAST)
2843 return 0;
2844
2845 if ((msg == WM_LBUTTONDBLCLK) ||
2846 (msg == WM_RBUTTONDBLCLK) ||
2847 (msg == WM_MBUTTONDBLCLK) ||
2848 (msg == WM_XBUTTONDBLCLK))
2849 {
2851 }
2852
2853 if ((msg == WM_LBUTTONDOWN) ||
2854 (msg == WM_RBUTTONDOWN) ||
2855 (msg == WM_MBUTTONDOWN) ||
2856 (msg == WM_XBUTTONDOWN))
2857 {
2858 static MSG prevClickMsg;
2859 MSG clickMsg;
2860 /* Compare the editor instead of the hwnd so that the this
2861 * can still be done for windowless richedit controls. */
2862 clickMsg.hwnd = (HWND)editor;
2863 clickMsg.message = msg;
2864 clickMsg.wParam = wParam;
2865 clickMsg.lParam = lParam;
2866 clickMsg.time = GetMessageTime();
2867 clickMsg.pt.x = (short)LOWORD(lParam);
2868 clickMsg.pt.y = (short)HIWORD(lParam);
2869 if ((clickNum != 0) &&
2870 (clickMsg.message == prevClickMsg.message) &&
2871 (clickMsg.hwnd == prevClickMsg.hwnd) &&
2872 (clickMsg.wParam == prevClickMsg.wParam) &&
2873 (clickMsg.time - prevClickMsg.time < GetDoubleClickTime()) &&
2874 (abs(clickMsg.pt.x - prevClickMsg.pt.x) < GetSystemMetrics(SM_CXDOUBLECLK)/2) &&
2875 (abs(clickMsg.pt.y - prevClickMsg.pt.y) < GetSystemMetrics(SM_CYDOUBLECLK)/2))
2876 {
2877 clickNum++;
2878 } else {
2879 clickNum = 1;
2880 }
2881 prevClickMsg = clickMsg;
2882 } else {
2883 return 0;
2884 }
2885 return clickNum;
2886}
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:993
#define WM_MOUSELAST
Definition: winuser.h:1791
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1768
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1771
#define SM_CYDOUBLECLK
Definition: winuser.h:994
#define WM_LBUTTONDOWN
Definition: winuser.h:1766
UINT WINAPI GetDoubleClickTime(void)
Definition: ntwrapper.h:314
#define WM_RBUTTONDOWN
Definition: winuser.h:1769
#define WM_MBUTTONDBLCLK
Definition: winuser.h:1774
LONG WINAPI GetMessageTime(void)
Definition: message.c:1361
int WINAPI GetSystemMetrics(_In_ int)
#define WM_MBUTTONDOWN
Definition: winuser.h:1772

Referenced by ME_HandleMessage().

◆ ME_Char()

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

Definition at line 2741 of file editor.c.

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

2337{
2338 LPDATAOBJECT dataObj = NULL;
2339 HRESULT hr = S_OK;
2340
2341 if (editor->cPasswordMask)
2342 return FALSE; /* Copying or Cutting masked text isn't allowed */
2343
2344 if(editor->lpOleCallback)
2345 {
2347 range.cpMin = ME_GetCursorOfs(start);
2348 range.cpMax = range.cpMin + nChars;
2349 hr = IRichEditOleCallback_GetClipboardData(editor->lpOleCallback, &range, RECO_COPY, &dataObj);
2350 }
2351 if(FAILED(hr) || !dataObj)
2352 hr = ME_GetDataObject(editor, start, nChars, &dataObj);
2353 if(SUCCEEDED(hr)) {
2354 hr = OleSetClipboard(dataObj);
2355 IDataObject_Release(dataObj);
2356 }
2357 return SUCCEEDED(hr);
2358}
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 3190 of file editor.c.

3191{
3192 ME_DisplayItem *p = editor->pBuffer->pFirst, *pNext = NULL;
3193 ME_Style *s, *cursor2;
3194 int i;
3195
3196 ME_ClearTempStyle(editor);
3197 ME_EmptyUndoStack(editor);
3198 editor->pBuffer->pFirst = NULL;
3199 while(p) {
3200 pNext = p->next;
3201 if (p->type == diParagraph)
3202 destroy_para(editor, p);
3203 else
3205 p = pNext;
3206 }
3207
3208 LIST_FOR_EACH_ENTRY_SAFE( s, cursor2, &editor->style_list, ME_Style, entry )
3209 ME_DestroyStyle( s );
3210
3212 for (i=0; i<HFONT_CACHE_SIZE; i++)
3213 {
3214 if (editor->pFontCache[i].hFont)
3215 DeleteObject(editor->pFontCache[i].hFont);
3216 }
3217 if (editor->rgbBackColor != -1)
3218 DeleteObject(editor->hbrBackground);
3219 if(editor->lpOleCallback)
3220 IRichEditOleCallback_Release(editor->lpOleCallback);
3221 ITextHost_Release(editor->texthost);
3222 if (editor->reOle)
3223 {
3224 IUnknown_Release(editor->reOle);
3225 editor->reOle = NULL;
3226 }
3228
3229 heap_free(editor->pBuffer);
3230 heap_free(editor->pCursors);
3231 heap_free(editor);
3232}
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
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:445

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 2386 of file editor.c.

2387{
2388 MSGFILTER msgf;
2389
2390 if (!editor->hWnd || !editor->hwndParent) return FALSE;
2391 msgf.nmhdr.hwndFrom = editor->hWnd;
2392 msgf.nmhdr.idFrom = GetWindowLongW(editor->hWnd, GWLP_ID);
2393 msgf.nmhdr.code = EN_MSGFILTER;
2394 msgf.msg = msg;
2395 msgf.wParam = *wParam;
2396 msgf.lParam = *lParam;
2397 if (SendMessageW(editor->hwndParent, WM_NOTIFY, msgf.nmhdr.idFrom, (LPARAM)&msgf))
2398 return FALSE;
2399 *wParam = msgf.wParam;
2400 *lParam = msgf.lParam;
2401 msgf.wParam = *wParam;
2402
2403 return TRUE;
2404}
#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:3148
UINT code
Definition: winuser.h:3149
HWND hwndFrom
Definition: winuser.h:3147
LONG_PTR LPARAM
Definition: windef.h:208
#define GWLP_ID
Definition: winuser.h:854

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 5329 of file editor.c.

5334{
5335 ME_Cursor cursor = *start, neutral_end, space_end;
5336 BOOL candidateStarted = FALSE, quoted = FALSE;
5337 WCHAR c;
5338
5339 while (nChars > 0)
5340 {
5341 WCHAR *str = get_text( &cursor.pRun->member.run, 0 );
5342 int run_len = cursor.pRun->member.run.len;
5343
5344 nChars -= run_len - cursor.nOffset;
5345
5346 /* Find start of candidate */
5347 if (!candidateStarted)
5348 {
5349 while (cursor.nOffset < run_len)
5350 {
5351 c = str[cursor.nOffset];
5352 if (!iswspace( c ) && !isurlneutral( c ))
5353 {
5354 *candidate_min = cursor;
5355 candidateStarted = TRUE;
5356 neutral_end.pPara = NULL;
5357 space_end.pPara = NULL;
5358 cursor.nOffset++;
5359 break;
5360 }
5361 quoted = (c == '<');
5362 cursor.nOffset++;
5363 }
5364 }
5365
5366 /* Find end of candidate */
5367 if (candidateStarted)
5368 {
5369 while (cursor.nOffset < run_len)
5370 {
5371 c = str[cursor.nOffset];
5372 if (iswspace( c ))
5373 {
5374 if (quoted && c != '\r')
5375 {
5376 if (!space_end.pPara)
5377 {
5378 if (neutral_end.pPara)
5379 space_end = neutral_end;
5380 else
5381 space_end = cursor;
5382 }
5383 }
5384 else
5385 goto done;
5386 }
5387 else if (isurlneutral( c ))
5388 {
5389 if (quoted && c == '>')
5390 {
5391 neutral_end.pPara = NULL;
5392 space_end.pPara = NULL;
5393 goto done;
5394 }
5395 if (!neutral_end.pPara)
5396 neutral_end = cursor;
5397 }
5398 else
5399 neutral_end.pPara = NULL;
5400
5401 cursor.nOffset++;
5402 }
5403 }
5404
5405 cursor.nOffset = 0;
5406 if (!ME_NextRun(&cursor.pPara, &cursor.pRun, TRUE))
5407 goto done;
5408 }
5409
5410done:
5411 if (candidateStarted)
5412 {
5413 if (space_end.pPara)
5414 *candidate_max = space_end;
5415 else if (neutral_end.pPara)
5416 *candidate_max = neutral_end;
5417 else
5418 *candidate_max = cursor;
5419 return TRUE;
5420 }
5421 *candidate_max = *candidate_min = cursor;
5422 return FALSE;
5423}
static BOOL isurlneutral(WCHAR c)
Definition: editor.c:5310
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 1852 of file editor.c.

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

2994{
2995 LONG sel_type = SEL_EMPTY;
2996 LONG start, end;
2997
2998 ME_GetSelectionOfs(editor, &start, &end);
2999 if (start == end)
3000 sel_type = SEL_EMPTY;
3001 else
3002 {
3003 LONG object_count = 0, character_count = 0;
3004 int i;
3005
3006 for (i = 0; i < end - start; i++)
3007 {
3009
3010 ME_CursorFromCharOfs(editor, start + i, &cursor);
3011 if (cursor.pRun->member.run.reobj)
3012 object_count++;
3013 else
3014 character_count++;
3015 if (character_count >= 2 && object_count >= 2)
3017 }
3018 if (character_count)
3019 {
3020 sel_type |= SEL_TEXT;
3021 if (character_count >= 2)
3022 sel_type |= SEL_MULTICHAR;
3023 }
3024 if (object_count)
3025 {
3026 sel_type |= SEL_OBJECT;
3027 if (object_count >= 2)
3028 sel_type |= SEL_MULTIOBJECT;
3029 }
3030 }
3031 return sel_type;
3032}
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 2084 of file editor.c.

2085{
2086 int nChars;
2088
2089 if (!ex->cb || !pText) return 0;
2090
2091 if (ex->flags & ~(GT_SELECTION | GT_USECRLF))
2092 FIXME("GETTEXTEX flags 0x%08x not supported\n", ex->flags & ~(GT_SELECTION | GT_USECRLF));
2093
2094 if (ex->flags & GT_SELECTION)
2095 {
2096 int from, to;
2097 int nStartCur = ME_GetSelectionOfs(editor, &from, &to);
2098 start = editor->pCursors[nStartCur];
2099 nChars = to - from;
2100 }
2101 else
2102 {
2103 ME_SetCursorToStart(editor, &start);
2104 nChars = INT_MAX;
2105 }
2106 if (ex->codepage == CP_UNICODE)
2107 {
2108 return ME_GetTextW(editor, (LPWSTR)pText, ex->cb / sizeof(WCHAR) - 1,
2109 &start, nChars, ex->flags & GT_USECRLF, FALSE);
2110 }
2111 else
2112 {
2113 /* potentially each char may be a CR, why calculate the exact value with O(N) when
2114 we can just take a bigger buffer? :)
2115 The above assumption still holds with CR/LF counters, since CR->CRLF expansion
2116 occurs only in richedit 2.0 mode, in which line breaks have only one CR
2117 */
2118 int crlfmul = (ex->flags & GT_USECRLF) ? 2 : 1;
2119 DWORD buflen;
2120 LPWSTR buffer;
2121 LRESULT rc;
2122
2123 buflen = min(crlfmul * nChars, ex->cb - 1);
2124 buffer = heap_alloc((buflen + 1) * sizeof(WCHAR));
2125
2126 nChars = ME_GetTextW(editor, buffer, buflen, &start, nChars, ex->flags & GT_USECRLF, FALSE);
2127 rc = WideCharToMultiByte(ex->codepage, 0, buffer, nChars + 1,
2128 (LPSTR)pText, ex->cb, ex->lpDefaultChar, ex->lpUsedDefChar);
2129 if (rc) rc--; /* do not count 0 terminator */
2130
2132 return rc;
2133 }
2134}
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#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:5134
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 2136 of file editor.c.

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

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 5134 of file editor.c.

5137{
5138 ME_DisplayItem *pRun, *pNextRun;
5139 const WCHAR *pStart = buffer;
5140 const WCHAR cr_lf[] = {'\r', '\n', 0};
5141 const WCHAR *str;
5142 int nLen;
5143
5144 /* bCRLF flag is only honored in 2.0 and up. 1.0 must always return text verbatim */
5145 if (editor->bEmulateVersion10) bCRLF = FALSE;
5146
5147 pRun = start->pRun;
5148 assert(pRun);
5149 pNextRun = ME_FindItemFwd(pRun, diRun);
5150
5151 nLen = pRun->member.run.len - start->nOffset;
5152 str = get_text( &pRun->member.run, start->nOffset );
5153
5154 while (srcChars && buflen && pNextRun)
5155 {
5156 int nFlags = pRun->member.run.nFlags;
5157
5158 if (bCRLF && nFlags & MERF_ENDPARA && ~nFlags & MERF_ENDCELL)
5159 {
5160 if (buflen == 1) break;
5161 /* FIXME: native fails to reduce srcChars here for WM_GETTEXT or
5162 * EM_GETTEXTEX, however, this is done for copying text which
5163 * also uses this function. */
5164 srcChars -= min(nLen, srcChars);
5165 nLen = 2;
5166 str = cr_lf;
5167 } else {
5168 nLen = min(nLen, srcChars);
5169 srcChars -= nLen;
5170 }
5171
5172 nLen = min(nLen, buflen);
5173 buflen -= nLen;
5174
5175 CopyMemory(buffer, str, sizeof(WCHAR) * nLen);
5176
5177 buffer += nLen;
5178
5179 pRun = pNextRun;
5180 pNextRun = ME_FindItemFwd(pRun, diRun);
5181
5182 nLen = pRun->member.run.len;
5183 str = get_text( &pRun->member.run, 0 );
5184 }
5185 /* append '\r' to the last paragraph. */
5186 if (pRun->next->type == diTextEnd && bEOP)
5187 {
5188 *buffer = '\r';
5189 buffer ++;
5190 }
5191 *buffer = 0;
5192 return buffer - pStart;
5193}
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:1668

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 3600 of file editor.c.

3602{
3603 *phresult = S_OK;
3604
3605 switch(msg) {
3606
3629
3630/* Messages specific to Richedit controls */
3631
3632 case EM_STREAMIN:
3633 return ME_StreamIn(editor, wParam, (EDITSTREAM*)lParam, TRUE);
3634 case EM_STREAMOUT:
3635 return ME_StreamOut(editor, wParam, (EDITSTREAM *)lParam);
3636 case WM_GETDLGCODE:
3637 {
3639
3640 if (lParam)
3641 editor->bDialogMode = TRUE;
3642 if (editor->styleFlags & ES_MULTILINE)
3644 if (!(editor->styleFlags & ES_SAVESEL))
3646 return code;
3647 }
3648 case EM_EMPTYUNDOBUFFER:
3649 ME_EmptyUndoStack(editor);
3650 return 0;
3651 case EM_GETSEL:
3652 {
3653 /* Note: wParam/lParam can be NULL */
3654 UINT from, to;
3655 PUINT pfrom = wParam ? (PUINT)wParam : &from;
3656 PUINT pto = lParam ? (PUINT)lParam : &to;
3657 ME_GetSelectionOfs(editor, (int *)pfrom, (int *)pto);
3658 if ((*pfrom|*pto) & 0xFFFF0000)
3659 return -1;
3660 return MAKELONG(*pfrom,*pto);
3661 }
3662 case EM_EXGETSEL:
3663 {
3664 CHARRANGE *pRange = (CHARRANGE *)lParam;
3665 ME_GetSelectionOfs(editor, &pRange->cpMin, &pRange->cpMax);
3666 TRACE("EM_EXGETSEL = (%d,%d)\n", pRange->cpMin, pRange->cpMax);
3667 return 0;
3668 }
3669 case EM_SETUNDOLIMIT:
3670 {
3671 if ((int)wParam < 0)
3673 else
3674 editor->nUndoLimit = min(wParam, STACK_SIZE_MAX);
3675 /* Setting a max stack size keeps wine from getting killed
3676 for hogging memory. Windows allocates all this memory at once, so
3677 no program would realistically set a value above our maximum. */
3678 return editor->nUndoLimit;
3679 }
3680 case EM_CANUNDO:
3681 return !list_empty( &editor->undo_stack );
3682 case EM_CANREDO:
3683 return !list_empty( &editor->redo_stack );
3684 case WM_UNDO: /* FIXME: actually not the same */
3685 case EM_UNDO:
3686 return ME_Undo(editor);
3687 case EM_REDO:
3688 return ME_Redo(editor);
3689 case EM_GETOPTIONS:
3690 {
3691 /* these flags are equivalent to the ES_* counterparts */
3694 DWORD settings = editor->styleFlags & mask;
3695
3696 return settings;
3697 }
3698 case EM_SETFONTSIZE:
3699 {
3701 LONG tmp_size, size;
3702 BOOL is_increase = ((LONG)wParam > 0);
3703
3704 if (editor->mode & TM_PLAINTEXT)
3705 return FALSE;
3706
3707 cf.cbSize = sizeof(cf);
3708 cf.dwMask = CFM_SIZE;
3709 ME_GetSelectionCharFormat(editor, &cf);
3710 tmp_size = (cf.yHeight / 20) + wParam;
3711
3712 if (tmp_size <= 1)
3713 size = 1;
3714 else if (tmp_size > 12 && tmp_size < 28 && tmp_size % 2)
3715 size = tmp_size + (is_increase ? 1 : -1);
3716 else if (tmp_size > 28 && tmp_size < 36)
3717 size = is_increase ? 36 : 28;
3718 else if (tmp_size > 36 && tmp_size < 48)
3719 size = is_increase ? 48 : 36;
3720 else if (tmp_size > 48 && tmp_size < 72)
3721 size = is_increase ? 72 : 48;
3722 else if (tmp_size > 72 && tmp_size < 80)
3723 size = is_increase ? 80 : 72;
3724 else if (tmp_size > 80 && tmp_size < 1638)
3725 size = 10 * (is_increase ? (tmp_size / 10 + 1) : (tmp_size / 10));
3726 else if (tmp_size >= 1638)
3727 size = 1638;
3728 else
3729 size = tmp_size;
3730
3731 cf.yHeight = size * 20; /* convert twips to points */
3732 ME_SetSelectionCharFormat(editor, &cf);
3733 ME_CommitUndo(editor);
3735 ME_UpdateScrollBar(editor);
3736
3737 return TRUE;
3738 }
3739 case EM_SETOPTIONS:
3740 {
3741 /* these flags are equivalent to ES_* counterparts, except for
3742 * ECO_AUTOWORDSELECTION that doesn't have an ES_* counterpart,
3743 * but is still stored in editor->styleFlags. */
3747 DWORD settings = mask & editor->styleFlags;
3748 DWORD oldSettings = settings;
3749 DWORD changedSettings;
3750
3751 switch(wParam)
3752 {
3753 case ECOOP_SET:
3754 settings = lParam;
3755 break;
3756 case ECOOP_OR:
3757 settings |= lParam;
3758 break;
3759 case ECOOP_AND:
3760 settings &= lParam;
3761 break;
3762 case ECOOP_XOR:
3763 settings ^= lParam;
3764 }
3765 changedSettings = oldSettings ^ settings;
3766
3767 if (changedSettings) {
3768 editor->styleFlags = (editor->styleFlags & ~mask) | (settings & mask);
3769
3770 if (changedSettings & ECO_SELECTIONBAR)
3771 {
3773 if (settings & ECO_SELECTIONBAR) {
3774 assert(!editor->selofs);
3775 editor->selofs = SELECTIONBAR_WIDTH;
3776 editor->rcFormat.left += editor->selofs;
3777 } else {
3778 editor->rcFormat.left -= editor->selofs;
3779 editor->selofs = 0;
3780 }
3781 ME_RewrapRepaint(editor);
3782 }
3783
3784 if ((changedSettings & settings & ES_NOHIDESEL) && !editor->bHaveFocus)
3785 ME_InvalidateSelection( editor );
3786
3787 if (changedSettings & settings & ECO_VERTICAL)
3788 FIXME("ECO_VERTICAL not implemented yet!\n");
3789 if (changedSettings & settings & ECO_AUTOHSCROLL)
3790 FIXME("ECO_AUTOHSCROLL not implemented yet!\n");
3791 if (changedSettings & settings & ECO_AUTOVSCROLL)
3792 FIXME("ECO_AUTOVSCROLL not implemented yet!\n");
3793 if (changedSettings & settings & ECO_WANTRETURN)
3794 FIXME("ECO_WANTRETURN not implemented yet!\n");
3795 if (changedSettings & settings & ECO_AUTOWORDSELECTION)
3796 FIXME("ECO_AUTOWORDSELECTION not implemented yet!\n");
3797 }
3798
3799 return settings;
3800 }
3801 case EM_SETSEL:
3802 {
3803 return set_selection( editor, wParam, lParam );
3804 }
3805 case EM_SETSCROLLPOS:
3806 {
3807 POINT *point = (POINT *)lParam;
3808 ME_ScrollAbs(editor, point->x, point->y);
3809 return 0;
3810 }
3811 case EM_AUTOURLDETECT:
3812 {
3813 if (wParam==1 || wParam ==0)
3814 {
3816 return 0;
3817 }
3818 return E_INVALIDARG;
3819 }
3821 {
3822 return editor->AutoURLDetect_bEnable;
3823 }
3824 case EM_EXSETSEL:
3825 {
3827
3828 return set_selection( editor, range.cpMin, range.cpMax );
3829 }
3830 case EM_SHOWSCROLLBAR:
3831 {
3832 DWORD flags;
3833
3834 switch (wParam)
3835 {
3836 case SB_HORZ:
3837 flags = WS_HSCROLL;
3838 break;
3839 case SB_VERT:
3840 flags = WS_VSCROLL;
3841 break;
3842 case SB_BOTH:
3844 break;
3845 default:
3846 return 0;
3847 }
3848
3849 if (lParam) {
3850 editor->styleFlags |= flags;
3851 if (flags & WS_HSCROLL)
3853 editor->nTotalWidth > editor->sizeWindow.cx);
3854 if (flags & WS_VSCROLL)
3856 editor->nTotalLength > editor->sizeWindow.cy);
3857 } else {
3858 editor->styleFlags &= ~flags;
3860 }
3861 return 0;
3862 }
3863 case EM_SETTEXTEX:
3864 {
3865 LPWSTR wszText;
3866 SETTEXTEX *pStruct = (SETTEXTEX *)wParam;
3867 int from, to, len;
3868 ME_Style *style;
3869 BOOL bRtf, bUnicode, bSelection, bUTF8;
3870 int oldModify = editor->nModifyStep;
3871 static const char utf8_bom[] = {0xef, 0xbb, 0xbf};
3872
3873 if (!pStruct) return 0;
3874
3875 /* If we detect ascii rtf at the start of the string,
3876 * we know it isn't unicode. */
3877 bRtf = (lParam && (!strncmp((char *)lParam, "{\\rtf", 5) ||
3878 !strncmp((char *)lParam, "{\\urtf", 6)));
3879 bUnicode = !bRtf && pStruct->codepage == CP_UNICODE;
3880 bUTF8 = (lParam && (!strncmp((char *)lParam, utf8_bom, 3)));
3881
3882 TRACE("EM_SETTEXTEX - %s, flags %d, cp %d\n",
3884 pStruct->flags, pStruct->codepage);
3885
3886 bSelection = (pStruct->flags & ST_SELECTION) != 0;
3887 if (bSelection) {
3888 int nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
3890 ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to - from, FALSE);
3891 } else {
3893 ME_SetCursorToStart(editor, &start);
3895 style = editor->pBuffer->pDefaultStyle;
3896 }
3897
3898 if (bRtf) {
3899 ME_StreamInRTFString(editor, bSelection, (char *)lParam);
3900 if (bSelection) {
3901 /* FIXME: The length returned doesn't include the rtf control
3902 * characters, only the actual text. */
3903 len = lParam ? strlen((char *)lParam) : 0;
3904 }
3905 } else {
3906 if (bUTF8 && !bUnicode) {
3907 wszText = ME_ToUnicode(CP_UTF8, (void *)(lParam+3), &len);
3908 ME_InsertTextFromCursor(editor, 0, wszText, len, style);
3909 ME_EndToUnicode(CP_UTF8, wszText);
3910 } else {
3911 wszText = ME_ToUnicode(pStruct->codepage, (void *)lParam, &len);
3912 ME_InsertTextFromCursor(editor, 0, wszText, len, style);
3913 ME_EndToUnicode(pStruct->codepage, wszText);
3914 }
3915 }
3916
3917 if (bSelection) {
3920 } else {
3922 len = 1;
3923 ME_SetCursorToStart(editor, &cursor);
3925 }
3926 ME_CommitUndo(editor);
3927 if (!(pStruct->flags & ST_KEEPUNDO))
3928 {
3929 editor->nModifyStep = oldModify;
3930 ME_EmptyUndoStack(editor);
3931 }
3932 ME_UpdateRepaint(editor, FALSE);
3933 return len;
3934 }
3935 case EM_SELECTIONTYPE:
3936 return ME_GetSelectionType(editor);
3937 case EM_SETBKGNDCOLOR:
3938 {
3939 LRESULT lColor;
3940 if (editor->rgbBackColor != -1) {
3941 DeleteObject(editor->hbrBackground);
3942 lColor = editor->rgbBackColor;
3943 }
3944 else lColor = ITextHost_TxGetSysColor(editor->texthost, COLOR_WINDOW);
3945
3946 if (wParam)
3947 {
3948 editor->rgbBackColor = -1;
3950 }
3951 else
3952 {
3953 editor->rgbBackColor = lParam;
3954 editor->hbrBackground = CreateSolidBrush(editor->rgbBackColor);
3955 }
3957 return lColor;
3958 }
3959 case EM_GETMODIFY:
3960 return editor->nModifyStep == 0 ? 0 : -1;
3961 case EM_SETMODIFY:
3962 {
3963 if (wParam)
3964 editor->nModifyStep = 1;
3965 else
3966 editor->nModifyStep = 0;
3967
3968 return 0;
3969 }
3970 case EM_SETREADONLY:
3971 {
3972 if (wParam)
3973 editor->styleFlags |= ES_READONLY;
3974 else
3975 editor->styleFlags &= ~ES_READONLY;
3976 return 1;
3977 }
3978 case EM_SETEVENTMASK:
3979 {
3980 DWORD nOldMask = editor->nEventMask;
3981
3982 editor->nEventMask = lParam;
3983 return nOldMask;
3984 }
3985 case EM_GETEVENTMASK:
3986 return editor->nEventMask;
3987 case EM_SETCHARFORMAT:
3988 return handle_EM_SETCHARFORMAT( editor, wParam, (CHARFORMAT2W *)lParam );
3989 case EM_GETCHARFORMAT:
3990 {
3992 if (dst->cbSize != sizeof(CHARFORMATA) &&
3993 dst->cbSize != sizeof(CHARFORMATW) &&
3994 dst->cbSize != sizeof(CHARFORMAT2A) &&
3995 dst->cbSize != sizeof(CHARFORMAT2W))
3996 return 0;
3997 tmp.cbSize = sizeof(tmp);
3998 if (!wParam)
3999 ME_GetDefaultCharFormat(editor, &tmp);
4000 else
4001 ME_GetSelectionCharFormat(editor, &tmp);
4002 cf2w_to_cfany(dst, &tmp);
4003 return tmp.dwMask;
4004 }
4005 case EM_SETPARAFORMAT:
4006 {
4009 ME_UpdateScrollBar(editor);
4010 ME_CommitUndo(editor);
4011 return result;
4012 }
4013 case EM_GETPARAFORMAT:
4015 return ((PARAFORMAT2 *)lParam)->dwMask;
4017 {
4018 ME_DisplayItem *p = editor->pBuffer->pFirst;
4019 int y = editor->vert_si.nPos;
4020 int ypara = 0;
4021 int count = 0;
4022 int ystart, yend;
4023 while(p) {
4025 if (p->type == diTextEnd)
4026 break;
4027 if (p->type == diParagraph) {
4028 ypara = p->member.para.pt.y;
4029 continue;
4030 }
4031 ystart = ypara + p->member.row.pt.y;
4032 yend = ystart + p->member.row.nHeight;
4033 if (y < yend) {
4034 break;
4035 }
4036 count++;
4037 }
4038 return count;
4039 }
4040 case EM_HIDESELECTION:
4041 {
4042 editor->bHideSelection = (wParam != 0);
4043 ME_InvalidateSelection(editor);
4044 return 0;
4045 }
4046 case EM_LINESCROLL:
4047 {
4048 if (!(editor->styleFlags & ES_MULTILINE))
4049 return FALSE;
4050 ME_ScrollDown( editor, lParam * get_default_line_height( editor ) );
4051 return TRUE;
4052 }
4053 case WM_CLEAR:
4054 {
4055 int from, to;
4056 int nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
4057 ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to-from, FALSE);
4058 ME_CommitUndo(editor);
4059 ME_UpdateRepaint(editor, TRUE);
4060 return 0;
4061 }
4062 case EM_REPLACESEL:
4063 {
4064 int len = 0;
4065 LONG codepage = unicode ? CP_UNICODE : CP_ACP;
4066 LPWSTR wszText = ME_ToUnicode(codepage, (void *)lParam, &len);
4067
4068 TRACE("EM_REPLACESEL - %s\n", debugstr_w(wszText));
4069
4070 ME_ReplaceSel(editor, !!wParam, wszText, len);
4071 ME_EndToUnicode(codepage, wszText);
4072 return len;
4073 }
4074 case EM_SCROLLCARET:
4075 ME_EnsureVisible(editor, &editor->pCursors[0]);
4076 return 0;
4077 case WM_SETFONT:
4078 {
4079 LOGFONTW lf;
4081 HDC hDC;
4082 BOOL bRepaint = LOWORD(lParam);
4083
4084 if (!wParam)
4086
4087 if (!GetObjectW((HGDIOBJ)wParam, sizeof(LOGFONTW), &lf))
4088 return 0;
4089
4090 hDC = ITextHost_TxGetDC(editor->texthost);
4093 if (editor->mode & TM_RICHTEXT) {
4095 ME_SetCursorToStart(editor, &start);
4096 ME_SetCharFormat(editor, &start, NULL, &fmt);
4097 }
4098 ME_SetDefaultCharFormat(editor, &fmt);
4099
4100 ME_CommitUndo(editor);
4101 ME_MarkAllForWrapping(editor);
4103 ME_UpdateScrollBar(editor);
4104 if (bRepaint)
4105 ME_Repaint(editor);
4106 return 0;
4107 }
4108 case WM_SETTEXT:
4109 {
4111 ME_SetCursorToStart(editor, &cursor);
4113 if (lParam)
4114 {
4115 TRACE("WM_SETTEXT lParam==%lx\n",lParam);
4116 if (!strncmp((char *)lParam, "{\\rtf", 5) ||
4117 !strncmp((char *)lParam, "{\\urtf", 6))
4118 {
4119 /* Undocumented: WM_SETTEXT supports RTF text */
4120 ME_StreamInRTFString(editor, 0, (char *)lParam);
4121 }
4122 else
4123 ME_SetText(editor, (void*)lParam, unicode);
4124 }
4125 else
4126 TRACE("WM_SETTEXT - NULL\n");
4127 ME_SetCursorToStart(editor, &cursor);
4129 set_selection_cursors(editor, 0, 0);
4130 editor->nModifyStep = 0;
4131 ME_CommitUndo(editor);
4132 ME_EmptyUndoStack(editor);
4133 ME_UpdateRepaint(editor, FALSE);
4134 return 1;
4135 }
4136 case EM_CANPASTE:
4137 return paste_special( editor, 0, NULL, TRUE );
4138 case WM_PASTE:
4139 case WM_MBUTTONDOWN:
4140 wParam = 0;
4141 lParam = 0;
4142 /* fall through */
4143 case EM_PASTESPECIAL:
4145 return 0;
4146 case WM_CUT:
4147 case WM_COPY:
4148 copy_or_cut(editor, msg == WM_CUT);
4149 return 0;
4150 case WM_GETTEXTLENGTH:
4151 {
4152 GETTEXTLENGTHEX how;
4153
4154 /* CR/LF conversion required in 2.0 mode, verbatim in 1.0 mode */
4155 how.flags = GTL_CLOSE | (editor->bEmulateVersion10 ? 0 : GTL_USECRLF) | GTL_NUMCHARS;
4156 how.codepage = unicode ? CP_UNICODE : CP_ACP;
4157 return ME_GetTextLengthEx(editor, &how);
4158 }
4159 case EM_GETTEXTLENGTHEX:
4160 return ME_GetTextLengthEx(editor, (GETTEXTLENGTHEX *)wParam);
4161 case WM_GETTEXT:
4162 {
4163 GETTEXTEX ex;
4164 ex.cb = wParam * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
4165 ex.flags = GT_USECRLF;
4166 ex.codepage = unicode ? CP_UNICODE : CP_ACP;
4167 ex.lpDefaultChar = NULL;
4168 ex.lpUsedDefChar = NULL;
4169 return ME_GetTextEx(editor, &ex, lParam);
4170 }
4171 case EM_GETTEXTEX:
4172 return ME_GetTextEx(editor, (GETTEXTEX*)wParam, lParam);
4173 case EM_GETSELTEXT:
4174 {
4175 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(editor, &nFrom, &nTo);
4176 ME_Cursor *from = &editor->pCursors[nStartCur];
4177 return ME_GetTextRange(editor, (WCHAR *)lParam, from,
4178 nTo - nFrom, unicode);
4179 }
4180 case EM_GETSCROLLPOS:
4181 {
4182 POINT *point = (POINT *)lParam;
4183 point->x = editor->horz_si.nPos;
4184 point->y = editor->vert_si.nPos;
4185 /* 16-bit scaled value is returned as stored in scrollinfo */
4186 if (editor->horz_si.nMax > 0xffff)
4187 point->x = MulDiv(point->x, 0xffff, editor->horz_si.nMax);
4188 if (editor->vert_si.nMax > 0xffff)
4189 point->y = MulDiv(point->y, 0xffff, editor->vert_si.nMax);
4190 return 1;
4191 }
4192 case EM_GETTEXTRANGE:
4193 {
4194 TEXTRANGEW *rng = (TEXTRANGEW *)lParam;
4196 int nStart = rng->chrg.cpMin;
4197 int nEnd = rng->chrg.cpMax;
4198 int textlength = ME_GetTextLength(editor);
4199
4200 TRACE("EM_GETTEXTRANGE min=%d max=%d unicode=%d textlength=%d\n",
4201 rng->chrg.cpMin, rng->chrg.cpMax, unicode, textlength);
4202 if (nStart < 0) return 0;
4203 if ((nStart == 0 && nEnd == -1) || nEnd > textlength)
4204 nEnd = textlength;
4205 if (nStart >= nEnd) return 0;
4206
4207 ME_CursorFromCharOfs(editor, nStart, &start);
4208 return ME_GetTextRange(editor, rng->lpstrText, &start, nEnd - nStart, unicode);
4209 }
4210 case EM_GETLINE:
4211 {
4212 ME_DisplayItem *run;
4213 const unsigned int nMaxChars = *(WORD *) lParam;
4214 unsigned int nCharsLeft = nMaxChars;
4215 char *dest = (char *) lParam;
4216 BOOL wroteNull = FALSE;
4217
4218 TRACE("EM_GETLINE: row=%d, nMaxChars=%d (%s)\n", (int) wParam, nMaxChars,
4219 unicode ? "Unicode" : "Ansi");
4220
4221 run = ME_FindRowWithNumber(editor, wParam);
4222 if (run == NULL)
4223 return 0;
4224
4225 while (nCharsLeft && (run = ME_FindItemFwd(run, diRunOrStartRow))
4226 && run->type == diRun)
4227 {
4228 WCHAR *str = get_text( &run->member.run, 0 );
4229 unsigned int nCopy;
4230
4231 nCopy = min(nCharsLeft, run->member.run.len);
4232
4233 if (unicode)
4234 memcpy(dest, str, nCopy * sizeof(WCHAR));
4235 else
4236 nCopy = WideCharToMultiByte(CP_ACP, 0, str, nCopy, dest,
4237 nCharsLeft, NULL, NULL);
4238 dest += nCopy * (unicode ? sizeof(WCHAR) : 1);
4239 nCharsLeft -= nCopy;
4240 }
4241
4242 /* append line termination, space allowing */
4243 if (nCharsLeft > 0)
4244 {
4245 if (unicode)
4246 *((WCHAR *)dest) = '\0';
4247 else
4248 *dest = '\0';
4249 nCharsLeft--;
4250 wroteNull = TRUE;
4251 }
4252
4253 TRACE("EM_GETLINE: got %u characters\n", nMaxChars - nCharsLeft);
4254 return nMaxChars - nCharsLeft - (wroteNull ? 1 : 0);
4255 }
4256 case EM_GETLINECOUNT:
4257 {
4258 ME_DisplayItem *item = editor->pBuffer->pLast;
4259 int nRows = editor->total_rows;
4260 ME_DisplayItem *prev_para = NULL, *last_para = NULL;
4261
4262 last_para = ME_FindItemBack(item, diRun);
4263 prev_para = ME_FindItemBack(last_para, diRun);
4264 assert(last_para);
4265 assert(last_para->member.run.nFlags & MERF_ENDPARA);
4266 if (editor->bEmulateVersion10 && prev_para &&
4267 last_para->member.run.nCharOfs == 0 &&
4268 prev_para->member.run.len == 1 &&
4269 *get_text( &prev_para->member.run, 0 ) == '\r')
4270 {
4271 /* In 1.0 emulation, the last solitary \r at the very end of the text
4272 (if one exists) is NOT a line break.
4273 FIXME: this is an ugly hack. This should have a more regular model. */
4274 nRows--;
4275 }
4276
4277 TRACE("EM_GETLINECOUNT: nRows==%d\n", nRows);
4278 return max(1, nRows);
4279 }
4280 case EM_LINEFROMCHAR:
4281 {
4282 if (wParam == -1)
4283 return ME_RowNumberFromCharOfs(editor, ME_GetCursorOfs(&editor->pCursors[1]));
4284 else
4285 return ME_RowNumberFromCharOfs(editor, wParam);
4286 }
4287 case EM_EXLINEFROMCHAR:
4288 {
4289 if (lParam == -1)
4290 return ME_RowNumberFromCharOfs(editor, ME_GetCursorOfs(&editor->pCursors[1]));
4291 else
4292 return ME_RowNumberFromCharOfs(editor, lParam);
4293 }
4294 case EM_LINEINDEX:
4295 {
4296 ME_DisplayItem *item, *para;
4297 int nCharOfs;
4298
4299 if (wParam == -1)
4301 else
4302 item = ME_FindRowWithNumber(editor, wParam);
4303 if (!item)
4304 return -1;
4305 para = ME_GetParagraph(item);
4307 nCharOfs = para->member.para.nCharOfs + item->member.run.nCharOfs;
4308 TRACE("EM_LINEINDEX: nCharOfs==%d\n", nCharOfs);
4309 return nCharOfs;
4310 }
4311 case EM_LINELENGTH:
4312 {
4313 ME_DisplayItem *item, *item_end;
4314 int nChars = 0, nThisLineOfs = 0, nNextLineOfs = 0;
4315 ME_DisplayItem *para, *run;
4316
4317 if (wParam > ME_GetTextLength(editor))
4318 return 0;
4319 if (wParam == -1)
4320 {
4321 FIXME("EM_LINELENGTH: returning number of unselected characters on lines with selection unsupported.\n");
4322 return 0;
4323 }
4324 ME_RunOfsFromCharOfs(editor, wParam, &para, &run, NULL);
4325 item = ME_RowStart(run);
4326 nThisLineOfs = ME_CharOfsFromRunOfs(editor, para, ME_FindItemFwd(item, diRun), 0);
4328 if (item_end->type == diStartRow) {
4329 nNextLineOfs = ME_CharOfsFromRunOfs(editor, para, ME_FindItemFwd(item_end, diRun), 0);
4330 } else {
4331 ME_DisplayItem *endRun = ME_FindItemBack(item_end, diRun);
4332 assert(endRun && endRun->member.run.nFlags & MERF_ENDPARA);
4333 nNextLineOfs = item_end->member.para.nCharOfs - endRun->member.run.len;
4334 }
4335 nChars = nNextLineOfs - nThisLineOfs;
4336 TRACE("EM_LINELENGTH(%ld)==%d\n",wParam, nChars);
4337 return nChars;
4338 }
4339 case EM_EXLIMITTEXT:
4340 {
4341 if ((int)lParam < 0)
4342 return 0;
4343 if (lParam == 0)
4344 editor->nTextLimit = 65536;
4345 else
4346 editor->nTextLimit = (int) lParam;
4347 return 0;
4348 }
4349 case EM_LIMITTEXT:
4350 {
4351 if (wParam == 0)
4352 editor->nTextLimit = 65536;
4353 else
4354 editor->nTextLimit = (int) wParam;
4355 return 0;
4356 }
4357 case EM_GETLIMITTEXT:
4358 {
4359 return editor->nTextLimit;
4360 }
4361 case EM_FINDTEXT:
4362 {
4363 LRESULT r;
4364 if(!unicode){
4365 FINDTEXTA *ft = (FINDTEXTA *)lParam;
4366 int nChars = MultiByteToWideChar(CP_ACP, 0, ft->lpstrText, -1, NULL, 0);
4367 WCHAR *tmp;
4368
4369 if ((tmp = heap_alloc(nChars * sizeof(*tmp))) != NULL)
4370 MultiByteToWideChar(CP_ACP, 0, ft->lpstrText, -1, tmp, nChars);
4371 r = ME_FindText(editor, wParam, &ft->chrg, tmp, NULL);
4372 heap_free(tmp);
4373 }else{
4374 FINDTEXTW *ft = (FINDTEXTW *)lParam;
4375 r = ME_FindText(editor, wParam, &ft->chrg, ft->lpstrText, NULL);
4376 }
4377 return r;
4378 }
4379 case EM_FINDTEXTEX:
4380 {
4381 LRESULT r;
4382 if(!unicode){
4384 int nChars = MultiByteToWideChar(CP_ACP, 0, ex->lpstrText, -1, NULL, 0);
4385 WCHAR *tmp;
4386
4387 if ((tmp = heap_alloc(nChars * sizeof(*tmp))) != NULL)
4388 MultiByteToWideChar(CP_ACP, 0, ex->lpstrText, -1, tmp, nChars);
4389 r = ME_FindText(editor, wParam, &ex->chrg, tmp, &ex->chrgText);
4390 heap_free(tmp);
4391 }else{
4393 r = ME_FindText(editor, wParam, &ex->chrg, ex->lpstrText, &ex->chrgText);
4394 }
4395 return r;
4396 }
4397 case EM_FINDTEXTW:
4398 {
4399 FINDTEXTW *ft = (FINDTEXTW *)lParam;
4400 return ME_FindText(editor, wParam, &ft->chrg, ft->lpstrText, NULL);
4401 }
4402 case EM_FINDTEXTEXW:
4403 {
4405 return ME_FindText(editor, wParam, &ex->chrg, ex->lpstrText, &ex->chrgText);
4406 }
4407 case EM_GETZOOM:
4408 if (!wParam || !lParam)
4409 return FALSE;
4410 *(int *)wParam = editor->nZoomNumerator;
4411 *(int *)lParam = editor->nZoomDenominator;
4412 return TRUE;
4413 case EM_SETZOOM:
4414 return ME_SetZoom(editor, wParam, lParam);
4415 case EM_CHARFROMPOS:
4416 {
4418 if (ME_CharFromPos(editor, ((POINTL *)lParam)->x, ((POINTL *)lParam)->y,
4419 &cursor, NULL))
4420 return ME_GetCursorOfs(&cursor);
4421 else
4422 return -1;
4423 }
4424 case EM_POSFROMCHAR:
4425 {
4426 ME_DisplayItem *pPara, *pRun;
4427 int nCharOfs, nOffset, nLength;
4428 POINTL pt = {0,0};
4429
4430 nCharOfs = wParam;
4431 /* detect which API version we're dealing with */
4432 if (wParam >= 0x40000)
4433 nCharOfs = lParam;
4434 nLength = ME_GetTextLength(editor);
4435 nCharOfs = min(nCharOfs, nLength);
4436 nCharOfs = max(nCharOfs, 0);
4437
4438 ME_RunOfsFromCharOfs(editor, nCharOfs, &pPara, &pRun, &nOffset);
4439 assert(pRun->type == diRun);
4440 pt.y = pRun->member.run.pt.y;
4441 pt.x = pRun->member.run.pt.x + ME_PointFromChar(editor, &pRun->member.run, nOffset, TRUE);
4442 pt.y += pPara->member.para.pt.y + editor->rcFormat.top;
4443 pt.x += editor->rcFormat.left;
4444
4445 pt.x -= editor->horz_si.nPos;
4446 pt.y -= editor->vert_si.nPos;
4447
4448 if (wParam >= 0x40000) {
4449 *(POINTL *)wParam = pt;
4450 }
4451 return (wParam >= 0x40000) ? 0 : MAKELONG( pt.x, pt.y );
4452 }
4453 case WM_CREATE:
4454 return ME_WmCreate(editor, lParam, unicode);
4455 case WM_DESTROY:
4456 ME_DestroyEditor(editor);
4457 return 0;
4458 case WM_SETCURSOR:
4459 {
4460 POINT cursor_pos;
4461 if (wParam == (WPARAM)editor->hWnd && GetCursorPos(&cursor_pos) &&
4462 ScreenToClient(editor->hWnd, &cursor_pos))
4463 ME_LinkNotify(editor, msg, 0, MAKELPARAM(cursor_pos.x, cursor_pos.y));
4464 return ME_SetCursor(editor);
4465 }
4466 case WM_LBUTTONDBLCLK:
4467 case WM_LBUTTONDOWN:
4468 {
4469 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4470 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4471 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4472 return 0;
4474 ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam),
4477 editor->bMouseCaptured = TRUE;
4478 ME_LinkNotify(editor, msg, wParam, lParam);
4479 if (!ME_SetCursor(editor)) goto do_default;
4480 break;
4481 }
4482 case WM_MOUSEMOVE:
4483 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4484 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4485 return 0;
4486 if (editor->bMouseCaptured)
4487 ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
4488 else
4489 ME_LinkNotify(editor, msg, wParam, lParam);
4490 /* Set cursor if mouse is captured, since WM_SETCURSOR won't be received. */
4491 if (editor->bMouseCaptured)
4492 ME_SetCursor(editor);
4493 break;
4494 case WM_LBUTTONUP:
4495 if (editor->bMouseCaptured) {
4497 editor->bMouseCaptured = FALSE;
4498 }
4499 if (editor->nSelectionType == stDocument)
4500 editor->nSelectionType = stPosition;
4501 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4502 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4503 return 0;
4504 else
4505 {
4506 ME_SetCursor(editor);
4507 ME_LinkNotify(editor, msg, wParam, lParam);
4508 }
4509 break;
4510 case WM_RBUTTONUP:
4511 case WM_RBUTTONDOWN:
4512 case WM_RBUTTONDBLCLK:
4513 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4514 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4515 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4516 return 0;
4517 ME_LinkNotify(editor, msg, wParam, lParam);
4518 goto do_default;
4519 case WM_CONTEXTMENU:
4520 if (!ME_ShowContextMenu(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)))
4521 goto do_default;
4522 break;
4523 case WM_SETFOCUS:
4524 editor->bHaveFocus = TRUE;
4525 create_caret(editor);
4526 update_caret(editor);
4528 if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL))
4529 ME_InvalidateSelection( editor );
4530 return 0;
4531 case WM_KILLFOCUS:
4532 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4533 editor->bHaveFocus = FALSE;
4534 editor->wheel_remain = 0;
4535 hide_caret(editor);
4536 DestroyCaret();
4538 if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL))
4539 ME_InvalidateSelection( editor );
4540 return 0;
4541 case WM_COMMAND:
4542 TRACE("editor wnd command = %d\n", LOWORD(wParam));
4543 return 0;
4544 case WM_KEYUP:
4545 if ((editor->nEventMask & ENM_KEYEVENTS) &&
4546 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4547 return 0;
4548 goto do_default;
4549 case WM_KEYDOWN:
4550 if ((editor->nEventMask & ENM_KEYEVENTS) &&
4551 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4552 return 0;
4553 if (ME_KeyDown(editor, LOWORD(wParam)))
4554 return 0;
4555 goto do_default;
4556 case WM_CHAR:
4557 if ((editor->nEventMask & ENM_KEYEVENTS) &&
4558 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4559 return 0;
4560 return ME_Char(editor, wParam, lParam, unicode);
4561 case WM_UNICHAR:
4562 if (unicode)
4563 {
4564 if(wParam == UNICODE_NOCHAR) return TRUE;
4565 if(wParam <= 0x000fffff)
4566 {
4567 if(wParam > 0xffff) /* convert to surrogates */
4568 {
4569 wParam -= 0x10000;
4570 ME_Char(editor, (wParam >> 10) + 0xd800, 0, TRUE);
4571 ME_Char(editor, (wParam & 0x03ff) + 0xdc00, 0, TRUE);
4572 } else {
4573 ME_Char(editor, wParam, 0, TRUE);
4574 }
4575 }
4576 return 0;
4577 }
4578 break;
4579 case EM_STOPGROUPTYPING:
4580 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4581 return 0;
4582 case WM_HSCROLL:
4583 {
4584 const int scrollUnit = 7;
4585
4586 switch(LOWORD(wParam))
4587 {
4588 case SB_LEFT:
4589 ME_ScrollAbs(editor, 0, 0);
4590 break;
4591 case SB_RIGHT:
4592 ME_ScrollAbs(editor,
4593 editor->horz_si.nMax - (int)editor->horz_si.nPage,
4594 editor->vert_si.nMax - (int)editor->vert_si.nPage);
4595 break;
4596 case SB_LINELEFT:
4597 ME_ScrollLeft(editor, scrollUnit);
4598 break;
4599 case SB_LINERIGHT:
4600 ME_ScrollRight(editor, scrollUnit);
4601 break;
4602 case SB_PAGELEFT:
4603 ME_ScrollLeft(editor, editor->sizeWindow.cx);
4604 break;
4605 case SB_PAGERIGHT:
4606 ME_ScrollRight(editor, editor->sizeWindow.cx);
4607 break;
4608 case SB_THUMBTRACK:
4609 case SB_THUMBPOSITION:
4610 {
4611 int pos = HIWORD(wParam);
4612 if (editor->horz_si.nMax > 0xffff)
4613 pos = MulDiv(pos, editor->horz_si.nMax, 0xffff);
4614 ME_HScrollAbs(editor, pos);
4615 break;
4616 }
4617 }
4618 break;
4619 }
4620 case EM_SCROLL: /* fall through */
4621 case WM_VSCROLL:
4622 {
4623 int origNPos;
4624 int lineHeight = get_default_line_height( editor );
4625
4626 origNPos = editor->vert_si.nPos;
4627
4628 switch(LOWORD(wParam))
4629 {
4630 case SB_TOP:
4631 ME_ScrollAbs(editor, 0, 0);
4632 break;
4633 case SB_BOTTOM:
4634 ME_ScrollAbs(editor,
4635 editor->horz_si.nMax - (int)editor->horz_si.nPage,
4636 editor->vert_si.nMax - (int)editor->vert_si.nPage);
4637 break;
4638 case SB_LINEUP:
4639 ME_ScrollUp(editor,lineHeight);
4640 break;
4641 case SB_LINEDOWN:
4642 ME_ScrollDown(editor,lineHeight);
4643 break;
4644 case SB_PAGEUP:
4645 ME_ScrollUp(editor,editor->sizeWindow.cy);
4646 break;
4647 case SB_PAGEDOWN:
4648 ME_ScrollDown(editor,editor->sizeWindow.cy);
4649 break;
4650 case SB_THUMBTRACK:
4651 case SB_THUMBPOSITION:
4652 {
4653 int pos = HIWORD(wParam);
4654 if (editor->vert_si.nMax > 0xffff)
4655 pos = MulDiv(pos, editor->vert_si.nMax, 0xffff);
4656 ME_VScrollAbs(editor, pos);
4657 break;
4658 }
4659 }
4660 if (msg == EM_SCROLL)
4661 return 0x00010000 | (((editor->vert_si.nPos - origNPos)/lineHeight) & 0xffff);
4662 break;
4663 }
4664 case WM_MOUSEWHEEL:
4665 {
4666 int delta;
4667 BOOL ctrl_is_down;
4668
4669 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4670 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4671 return 0;
4672
4673 ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
4674
4675 delta = GET_WHEEL_DELTA_WPARAM(wParam);
4676
4677 /* if scrolling changes direction, ignore left overs */
4678 if ((delta < 0 && editor->wheel_remain < 0) ||
4679 (delta > 0 && editor->wheel_remain > 0))
4680 editor->wheel_remain += delta;
4681 else
4682 editor->wheel_remain = delta;
4683
4684 if (editor->wheel_remain)
4685 {
4686 if (ctrl_is_down) {
4687 int numerator;
4688 if (!editor->nZoomNumerator || !editor->nZoomDenominator)
4689 {
4690 numerator = 100;
4691 } else {
4692 numerator = editor->nZoomNumerator * 100 / editor->nZoomDenominator;
4693 }
4694 numerator += calc_wheel_change( &editor->wheel_remain, 10 );
4695 if (numerator >= 10 && numerator <= 500)
4696 ME_SetZoom(editor, numerator, 100);
4697 } else {
4698 UINT max_lines = 3;
4699 int lines = 0;
4700
4701 SystemParametersInfoW( SPI_GETWHEELSCROLLLINES, 0, &max_lines, 0 );
4702 if (max_lines)
4703 lines = calc_wheel_change( &editor->wheel_remain, (int)max_lines );
4704 if (lines)
4705 ME_ScrollDown( editor, -lines * get_default_line_height( editor ) );
4706 }
4707 }
4708 break;
4709 }
4710 case EM_GETRECT:
4711 {
4712 *((RECT *)lParam) = editor->rcFormat;
4713 if (editor->bDefaultFormatRect)
4714 ((RECT *)lParam)->left -= editor->selofs;
4715 return 0;
4716 }
4717 case EM_SETRECT:
4718 case EM_SETRECTNP:
4719 {
4720 if (lParam)
4721 {
4722 int border = 0;
4723 RECT clientRect;
4724 RECT *rc = (RECT *)lParam;
4725
4726 border = editor->exStyleFlags & WS_EX_CLIENTEDGE ? 1 : 0;
4727 ITextHost_TxGetClientRect(editor->texthost, &clientRect);
4728 if (wParam == 0)
4729 {
4730 editor->rcFormat.top = max(0, rc->top - border);
4731 editor->rcFormat.left = max(0, rc->left - border);
4732 editor->rcFormat.bottom = min(clientRect.bottom, rc->bottom);
4733 editor->rcFormat.right = min(clientRect.right, rc->right + border);
4734 } else if (wParam == 1) {
4735 /* MSDN incorrectly says a wParam value of 1 causes the
4736 * lParam rect to be used as a relative offset,
4737 * however, the tests show it just prevents min/max bound
4738 * checking. */
4739 editor->rcFormat.top = rc->top - border;
4740 editor->rcFormat.left = rc->left - border;
4741 editor->rcFormat.bottom = rc->bottom;
4742 editor->rcFormat.right = rc->right + border;
4743 } else {
4744 return 0;
4745 }
4746 editor->bDefaultFormatRect = FALSE;
4747 }
4748 else
4749 {
4751 editor->bDefaultFormatRect = TRUE;
4752 }
4753 ME_MarkAllForWrapping(editor);
4755 ME_UpdateScrollBar(editor);
4756 if (msg != EM_SETRECTNP)
4757 ME_Repaint(editor);
4758 return 0;
4759 }
4760 case EM_REQUESTRESIZE:
4761 ME_SendRequestResize(editor, TRUE);
4762 return 0;
4763 case WM_SETREDRAW:
4764 goto do_default;
4766 {
4767 RECT clientRect;
4768 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
4769
4770 if (winpos->flags & SWP_NOCLIENTSIZE) goto do_default;
4771 ITextHost_TxGetClientRect(editor->texthost, &clientRect);
4772 if (editor->bDefaultFormatRect) {
4774 } else {
4775 editor->rcFormat.right += clientRect.right - editor->prevClientRect.right;
4776 editor->rcFormat.bottom += clientRect.bottom - editor->prevClientRect.bottom;
4777 }
4778 editor->prevClientRect = clientRect;
4779 ME_RewrapRepaint(editor);
4780 goto do_default;
4781 }
4782 /* IME messages to make richedit controls IME aware */
4783 case WM_IME_SETCONTEXT:
4784 case WM_IME_CONTROL:
4785 case WM_IME_SELECT:
4787 return 0;
4788 case WM_IME_STARTCOMPOSITION:
4789 {
4790 editor->imeStartIndex=ME_GetCursorOfs(&editor->pCursors[0]);
4791 ME_DeleteSelection(editor);
4792 ME_CommitUndo(editor);
4793 ME_UpdateRepaint(editor, FALSE);
4794 return 0;
4795 }
4796 case WM_IME_COMPOSITION:
4797 {
4798 HIMC hIMC;
4799
4800 ME_Style *style = ME_GetInsertStyle(editor, 0);
4801 hIMC = ITextHost_TxImmGetContext(editor->texthost);
4802 ME_DeleteSelection(editor);
4803 ME_SaveTempStyle(editor, style);
4805 {
4806 LPWSTR lpCompStr = NULL;
4808 DWORD dwIndex = lParam & GCS_RESULTSTR;
4809 if (!dwIndex)
4810 dwIndex = GCS_COMPSTR;
4811
4812 dwBufLen = ImmGetCompositionStringW(hIMC, dwIndex, NULL, 0);
4813 lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR));
4814 ImmGetCompositionStringW(hIMC, dwIndex, lpCompStr, dwBufLen);
4815 lpCompStr[dwBufLen/sizeof(WCHAR)] = 0;
4816 ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style);
4817 HeapFree(GetProcessHeap(), 0, lpCompStr);
4818
4819 if (dwIndex == GCS_COMPSTR)
4820 set_selection_cursors(editor,editor->imeStartIndex,
4821 editor->imeStartIndex + dwBufLen/sizeof(WCHAR));
4822 }
4824 ME_CommitUndo(editor);
4825 ME_UpdateRepaint(editor, FALSE);
4826 return 0;
4827 }
4828 case WM_IME_ENDCOMPOSITION:
4829 {
4830 ME_DeleteSelection(editor);
4831 editor->imeStartIndex=-1;
4832 return 0;
4833 }
4834 case EM_GETOLEINTERFACE:
4835 {
4836 if (!editor->reOle)
4837 if (!CreateIRichEditOle(NULL, editor, (LPVOID *)&editor->reOle))
4838 return 0;
4839 if (IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (LPVOID *)lParam) == S_OK)
4840 return 1;
4841 return 0;
4842 }
4843 case EM_GETPASSWORDCHAR:
4844 {
4845 return editor->cPasswordMask;
4846 }
4847 case EM_SETOLECALLBACK:
4848 if(editor->lpOleCallback)
4849 IRichEditOleCallback_Release(editor->lpOleCallback);
4851 if(editor->lpOleCallback)
4852 IRichEditOleCallback_AddRef(editor->lpOleCallback);
4853 return TRUE;
4855 return (LRESULT)editor->pfnWordBreak;
4857 {
4858 EDITWORDBREAKPROCW pfnOld = editor->pfnWordBreak;
4859
4861 return (LRESULT)pfnOld;
4862 }
4863 case EM_GETTEXTMODE:
4864 return editor->mode;
4865 case EM_SETTEXTMODE:
4866 {
4867 int mask = 0;
4868 int changes = 0;
4869
4870 if (ME_GetTextLength(editor) ||
4871 !list_empty( &editor->undo_stack ) || !list_empty( &editor->redo_stack ))
4872 return E_UNEXPECTED;
4873
4874 /* Check for mutually exclusive flags in adjacent bits of wParam */
4877 return E_INVALIDARG;
4878
4880 {
4883 if (wParam & TM_PLAINTEXT) {
4884 /* Clear selection since it should be possible to select the
4885 * end of text run for rich text */
4886 ME_InvalidateSelection(editor);
4887 ME_SetCursorToStart(editor, &editor->pCursors[0]);
4888 editor->pCursors[1] = editor->pCursors[0];
4889 /* plain text can only have the default style. */
4890 ME_ClearTempStyle(editor);
4893 editor->pCursors[0].pRun->member.run.style = editor->pBuffer->pDefaultStyle;
4894 }
4895 }
4896 /* FIXME: Currently no support for undo level and code page options */
4897 editor->mode = (editor->mode & ~mask) | changes;
4898 return 0;
4899 }
4900 case EM_SETPASSWORDCHAR:
4901 {
4902 editor->cPasswordMask = wParam;
4903 ME_RewrapRepaint(editor);
4904 return 0;
4905 }
4906 case EM_SETTARGETDEVICE:
4907 if (wParam == 0)
4908 {
4909 BOOL new = (lParam == 0 && (editor->styleFlags & ES_MULTILINE));
4910 if (editor->nAvailWidth || editor->bWordWrap != new)
4911 {
4912 editor->bWordWrap = new;
4913 editor->nAvailWidth = 0; /* wrap to client area */
4914 ME_RewrapRepaint(editor);
4915 }
4916 } else {
4917 int width = max(0, lParam);
4918 if ((editor->styleFlags & ES_MULTILINE) &&
4919 (!editor->bWordWrap || editor->nAvailWidth != width))
4920 {
4921 editor->nAvailWidth = width;
4922 editor->bWordWrap = TRUE;
4923 ME_RewrapRepaint(editor);
4924 }
4925 FIXME("EM_SETTARGETDEVICE doesn't use non-NULL target devices\n");
4926 }
4927 return TRUE;
4928 default:
4929 do_default:
4930 *phresult = S_FALSE;
4931 break;
4932 }
4933 return 0L;
4934}
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
void ME_DeleteSelection(ME_TextEditor *editor)
Definition: caret.c:1539
void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum)
Definition: caret.c:1159
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:1221
BOOL ME_CharFromPos(ME_TextEditor *editor, int x, int y, ME_Cursor *cursor, BOOL *isExact)
Definition: caret.c:1077
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:1548
static void ME_StreamInRTFString(ME_TextEditor *editor, BOOL selection, char *string)
Definition: editor.c:1837
static BOOL paste_special(ME_TextEditor *editor, UINT cf, REPASTESPECIAL *ps, BOOL check_only)
Definition: editor.c:2288
#define UNSUPPORTED_MSG(e)
Definition: editor.c:3589
static int ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCHAR *text, CHARRANGE *chrgText)
Definition: editor.c:1852
static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stream, BOOL stripLastCR)
Definition: editor.c:1581
static void ME_SetText(ME_TextEditor *editor, void *text, BOOL unicode)
Definition: editor.c:3483
void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len)
Definition: editor.c:3459
static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode, LPARAM flags, BOOL unicode)
Definition: editor.c:2741
static BOOL ME_SetCursor(ME_TextEditor *editor)
Definition: editor.c:2893
static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y)
Definition: editor.c:3034
#define STACK_SIZE_MAX
Definition: editor.c:243
static void ME_SetDefaultFormatRect(ME_TextEditor *editor)
Definition: editor.c:2985
static int ME_GetTextRange(ME_TextEditor *editor, WCHAR *strText, const ME_Cursor *start, int nLen, BOOL unicode)
Definition: editor.c:2136
void ME_SendOldNotify(ME_TextEditor *editor, int nCode)
Definition: editor.c:5117
static LRESULT handle_EM_SETCHARFORMAT(ME_TextEditor *editor, WPARAM flags, const CHARFORMAT2W *fmt_in)
Definition: editor.c:3539
static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText)
Definition: editor.c:2084
static int calc_wheel_change(int *remain, int amount_per_click)
Definition: editor.c:3276
static BOOL ME_FilterEvent(ME_TextEditor *editor, UINT msg, WPARAM *wParam, LPARAM *lParam)
Definition: editor.c:2386
#define STACK_SIZE_DEFAULT
Definition: editor.c:242
static BOOL copy_or_cut(ME_TextEditor *editor, BOOL cut)
Definition: editor.c:2360
static int get_default_line_height(ME_TextEditor *editor)
Definition: editor.c:3265
static LONG ME_GetSelectionType(ME_TextEditor *editor)
Definition: editor.c:2993
static LRESULT ME_WmCreate(ME_TextEditor *editor, LPARAM lParam, BOOL unicode)
Definition: editor.c:3493
static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: editor.c:3419
static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int nChars)
Definition: editor.c:5475
void ME_DestroyEditor(ME_TextEditor *editor)
Definition: editor.c:3190
static BOOL ME_KeyDown(ME_TextEditor *editor, WORD nKey)
Definition: editor.c:2610
static int ME_CalculateClickCount(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: editor.c:2838
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
#define GCS_RESULTSTR
Definition: imm.h:374
#define GCS_COMPSTR
Definition: imm.h:367
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:3584
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:439
RECT prevClientRect
Definition: editstr.h:412
ME_SelectionType nSelectionType
Definition: editstr.h:432
BOOL AutoURLDetect_bEnable
Definition: editstr.h:425
SCROLLINFO horz_si
Definition: editstr.h:439
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:2005
#define EM_GETIMESTATUS
Definition: winuser.h:1977
#define WM_GETTEXTLENGTH
Definition: winuser.h:1609
#define EM_GETRECT
Definition: winuser.h:1986
#define EM_LIMITTEXT
Definition: winuser.h:1990
#define SB_THUMBTRACK
Definition: winuser.h:573
#define EM_LINEFROMCHAR
Definition: winuser.h:1991
#define SB_LINEUP
Definition: winuser.h:564
#define WM_HSCROLL
Definition: winuser.h:1733
#define WM_PASTE
Definition: winuser.h:1853
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
#define WM_KEYUP
Definition: winuser.h:1706
#define EN_KILLFOCUS
Definition: winuser.h:2015
#define EM_GETWORDBREAKPROC
Definition: winuser.h:1989
#define COLOR_WINDOW
Definition: winuser.h:912
#define EM_FMTLINES
Definition: winuser.h:1976
#define EM_GETPASSWORDCHAR
Definition: winuser.h:1985
#define WM_VSCROLL
Definition: winuser.h:1734
#define WM_CREATE
Definition: winuser.h:1598
#define DLGC_WANTCHARS
Definition: winuser.h:2608
#define DLGC_WANTTAB
Definition: winuser.h:2601
#define EM_SETIMESTATUS
Definition: winuser.h:2000
#define EN_SETFOCUS
Definition: winuser.h:2017
#define EM_SETPASSWORDCHAR
Definition: winuser.h:2004
#define EM_GETMODIFY
Definition: winuser.h:1984
#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:1975
#define SB_LEFT
Definition: winuser.h:575
#define SB_BOTTOM
Definition: winuser.h:577
#define WM_COMMAND
Definition: winuser.h:1730
#define EM_REPLACESEL
Definition: winuser.h:1996
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2639
#define EM_SETRECT
Definition: winuser.h:2006
#define WM_RBUTTONUP
Definition: winuser.h:1770
#define WM_SETFOCUS
Definition: winuser.h:1603
#define WM_MOUSEMOVE
Definition: winuser.h:1765
#define WM_GETTEXT
Definition: winuser.h:1608
#define WM_CUT
Definition: winuser.h:1851
#define SB_LINERIGHT
Definition: winuser.h:567
#define EM_LINEINDEX
Definition: winuser.h:1992
#define EM_LINESCROLL
Definition: winuser.h:1994
#define EM_GETFIRSTVISIBLELINE
Definition: winuser.h:1978
#define WM_UNDO
Definition: winuser.h:1855
#define WM_IME_SETCONTEXT
Definition: winuser.h:1819
#define WM_SETTEXT
Definition: winuser.h:1607
#define EM_CANUNDO
Definition: winuser.h:1973
#define EM_LINELENGTH
Definition: winuser.h:1993
#define EM_GETLINE
Definition: winuser.h:1981
#define EM_SETRECTNP
Definition: winuser.h:2007
#define SB_LINELEFT
Definition: winuser.h:566
#define WM_SETFONT
Definition: winuser.h:1640
#define EM_UNDO
Definition: winuser.h:2011
#define DLGC_WANTARROWS
Definition: winuser.h:2600
#define EM_SCROLL
Definition: winuser.h:1997
#define SB_PAGEDOWN
Definition: winuser.h:569
#define EM_SETWORDBREAKPROC
Definition: winuser.h:2010
#define SB_BOTH
Definition: winuser.h:555
#define SB_LINEDOWN
Definition: winuser.h:565
#define EM_SETSEL
Definition: winuser.h:2008
int(CALLBACK * EDITWORDBREAKPROCW)(LPWSTR, int, int, int)
Definition: winuser.h:2895
#define WM_LBUTTONUP
Definition: winuser.h:1767
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define WM_IME_COMPOSITIONFULL
Definition: winuser.h:1822
#define WM_CHAR
Definition: winuser.h:1707
#define SB_TOP
Definition: winuser.h:578
#define WM_COPY
Definition: winuser.h:1852
#define WM_SETCURSOR
Definition: winuser.h:1626
#define WM_IME_CONTROL
Definition: winuser.h:1821
#define EM_SETTABSTOPS
Definition: winuser.h:2009
#define DLGC_WANTMESSAGE
Definition: winuser.h:2603
#define WM_IME_SELECT
Definition: winuser.h:1823
#define WM_DESTROY
Definition: winuser.h:1599
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WM_CLEAR
Definition: winuser.h:1854
#define EM_GETLINECOUNT
Definition: winuser.h:1982
#define SB_RIGHT
Definition: winuser.h:576
BOOL WINAPI DestroyCaret(void)
Definition: caret.c:35
#define EM_SETMARGINS
Definition: winuser.h:2002
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1652
#define DLGC_HASSETSEL
Definition: winuser.h:2604
#define WM_KILLFOCUS
Definition: winuser.h:1604
#define SB_PAGEUP
Definition: winuser.h:568
#define WM_GETDLGCODE
Definition: winuser.h:1679
#define EM_SETMODIFY
Definition: winuser.h:2003
#define SB_HORZ
Definition: winuser.h:552
#define SB_PAGELEFT
Definition: winuser.h:570
#define WM_SETREDRAW
Definition: winuser.h:1606
#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 5428 of file editor.c.

5429{
5430#define MAX_PREFIX_LEN 9
5431 struct prefix_s {
5432 const WCHAR text[MAX_PREFIX_LEN];
5433 int length;
5434 }prefixes[] = {
5435 {{'p','r','o','s','p','e','r','o',':'}, 9},
5436 {{'t','e','l','n','e','t',':'}, 7},
5437 {{'g','o','p','h','e','r',':'}, 7},
5438 {{'m','a','i','l','t','o',':'}, 7},
5439 {{'h','t','t','p','s',':'}, 6},
5440 {{'f','i','l','e',':'}, 5},
5441 {{'n','e','w','s',':'}, 5},
5442 {{'w','a','i','s',':'}, 5},
5443 {{'n','n','t','p',':'}, 5},
5444 {{'h','t','t','p',':'}, 5},
5445 {{'w','w','w','.'}, 4},
5446 {{'f','t','p',':'}, 4},
5447 };
5448 WCHAR bufferW[MAX_PREFIX_LEN + 1];
5449 unsigned int i;
5450
5451 ME_GetTextW(editor, bufferW, MAX_PREFIX_LEN, start, nChars, FALSE, FALSE);
5452 for (i = 0; i < ARRAY_SIZE(prefixes); i++)
5453 {
5454 if (nChars < prefixes[i].length) continue;
5455 if (!memcmp(prefixes[i].text, bufferW, prefixes[i].length * sizeof(WCHAR)))
5456 return TRUE;
5457 }
5458 return FALSE;
5459#undef MAX_PREFIX_LEN
5460}
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:277

Referenced by ME_UpdateLinkAttribute().

◆ ME_KeyDown()

static BOOL ME_KeyDown ( ME_TextEditor editor,
WORD  nKey 
)
static

Definition at line 2610 of file editor.c.

2611{
2612 BOOL ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
2613 BOOL shift_is_down = GetKeyState(VK_SHIFT) & 0x8000;
2614
2615 if (editor->bMouseCaptured)
2616 return FALSE;
2617 if (nKey != VK_SHIFT && nKey != VK_CONTROL && nKey != VK_MENU)
2618 editor->nSelectionType = stPosition;
2619
2620 switch (nKey)
2621 {
2622 case VK_LEFT:
2623 case VK_RIGHT:
2624 case VK_HOME:
2625 case VK_END:
2626 editor->nUDArrowX = -1;
2627 /* fall through */
2628 case VK_UP:
2629 case VK_DOWN:
2630 case VK_PRIOR:
2631 case VK_NEXT:
2632 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
2633 ME_ArrowKey(editor, nKey, shift_is_down, ctrl_is_down);
2634 return TRUE;
2635 case VK_BACK:
2636 case VK_DELETE:
2637 editor->nUDArrowX = -1;
2638 /* FIXME backspace and delete aren't the same, they act different wrt paragraph style of the merged paragraph */
2639 if (editor->styleFlags & ES_READONLY)
2640 return FALSE;
2641 if (ME_IsSelection(editor))
2642 {
2643 ME_DeleteSelection(editor);
2644 ME_CommitUndo(editor);
2645 }
2646 else if (nKey == VK_DELETE)
2647 {
2648 /* Delete stops group typing.
2649 * (See MSDN remarks on EM_STOPGROUPTYPING message) */
2650 ME_DeleteTextAtCursor(editor, 1, 1);
2651 ME_CommitUndo(editor);
2652 }
2653 else if (ME_ArrowKey(editor, VK_LEFT, FALSE, FALSE))
2654 {
2655 BOOL bDeletionSucceeded;
2656 /* Backspace can be grouped for a single undo */
2658 bDeletionSucceeded = ME_DeleteTextAtCursor(editor, 1, 1);
2659 if (!bDeletionSucceeded && !editor->bEmulateVersion10) { /* v4.1 */
2660 /* Deletion was prevented so the cursor is moved back to where it was.
2661 * (e.g. this happens when trying to delete cell boundaries)
2662 */
2663 ME_ArrowKey(editor, VK_RIGHT, FALSE, FALSE);
2664 }
2666 }
2667 else
2668 return TRUE;
2671 ME_UpdateRepaint(editor, FALSE);
2672 ME_SendRequestResize(editor, FALSE);
2673 return TRUE;
2674 case VK_RETURN:
2675 if (!editor->bEmulateVersion10)
2676 return handle_enter(editor);
2677 break;
2678 case VK_ESCAPE:
2679 if (editor->bDialogMode && editor->hwndParent)
2680 PostMessageW(editor->hwndParent, WM_CLOSE, 0, 0);
2681 return TRUE;
2682 case VK_TAB:
2683 if (editor->bDialogMode && editor->hwndParent)
2684 SendMessageW(editor->hwndParent, WM_NEXTDLGCTL, shift_is_down, 0);
2685 return TRUE;
2686 case 'A':
2687 if (ctrl_is_down)
2688 {
2689 set_selection( editor, 0, -1 );
2690 return TRUE;
2691 }
2692 break;
2693 case 'V':
2694 if (ctrl_is_down)
2695 return paste_special( editor, 0, NULL, FALSE );
2696 break;
2697 case 'C':
2698 case 'X':
2699 if (ctrl_is_down)
2700 return copy_or_cut(editor, nKey == 'X');
2701 break;
2702 case 'Z':
2703 if (ctrl_is_down)
2704 {
2705 ME_Undo(editor);
2706 return TRUE;
2707 }
2708 break;
2709 case 'Y':
2710 if (ctrl_is_down)
2711 {
2712 ME_Redo(editor);
2713 return TRUE;
2714 }
2715 break;
2716
2717 default:
2718 if (nKey != VK_SHIFT && nKey != VK_CONTROL && nKey && nKey != VK_MENU)
2719 editor->nUDArrowX = -1;
2720 if (ctrl_is_down)
2721 {
2722 if (nKey == 'W')
2723 {
2724 CHARFORMAT2W chf;
2725 char buf[2048];
2726 chf.cbSize = sizeof(chf);
2727
2728 ME_GetSelectionCharFormat(editor, &chf);
2729 ME_DumpStyleToBuf(&chf, buf);
2730 MessageBoxA(NULL, buf, "Style dump", MB_OK);
2731 }
2732 if (nKey == 'Q')
2733 {
2734 ME_CheckCharOffsets(editor);
2735 }
2736 }
2737 }
2738 return FALSE;
2739}
BOOL ME_DeleteTextAtCursor(ME_TextEditor *editor, int nCursor, int nChars)
Definition: caret.c:465
BOOL ME_ArrowKey(ME_TextEditor *editor, int nVKey, BOOL extend, BOOL ctrl)
Definition: caret.c:1585
void ME_MoveCursorFromTableRowStartParagraph(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: table.c:622
void ME_CheckCharOffsets(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: run.c:101
void ME_DumpStyleToBuf(CHARFORMAT2W *pFmt, char buf[2048]) DECLSPEC_HIDDEN
Definition: style.c:250
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define WM_CLOSE
Definition: winuser.h:1611
#define VK_TAB
Definition: winuser.h:2189
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)
#define VK_UP
Definition: winuser.h:2215
#define VK_NEXT
Definition: winuser.h:2211
#define VK_END
Definition: winuser.h:2212
#define VK_HOME
Definition: winuser.h:2213
#define VK_BACK
Definition: winuser.h:2188
#define MB_OK
Definition: winuser.h:784
#define VK_LEFT
Definition: winuser.h:2214
#define VK_RIGHT
Definition: winuser.h:2216
#define VK_DOWN
Definition: winuser.h:2217
#define VK_PRIOR
Definition: winuser.h:2210
#define VK_DELETE
Definition: winuser.h:2223