ReactOS 0.4.15-dev-6675-gcbc63d8
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 245 of file editor.c.

◆ STACK_SIZE_MAX

#define STACK_SIZE_MAX   1000

Definition at line 246 of file editor.c.

◆ TEXT_LIMIT_DEFAULT

#define TEXT_LIMIT_DEFAULT   32767

Definition at line 248 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 3592 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 3279 of file editor.c.

3280{
3281 int change = amount_per_click * (float)*remain / WHEEL_DELTA;
3282 *remain -= WHEEL_DELTA * change / amount_per_click;
3283 return change;
3284}
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 2363 of file editor.c.

2364{
2365 BOOL result;
2366 int offs, num_chars;
2367 int start_cursor = ME_GetSelectionOfs(editor, &offs, &num_chars);
2368 ME_Cursor *sel_start = &editor->pCursors[start_cursor];
2369
2370 if (cut && (editor->styleFlags & ES_READONLY))
2371 {
2373 return FALSE;
2374 }
2375
2376 num_chars -= offs;
2377 result = ME_Copy(editor, sel_start, num_chars);
2378 if (result && cut)
2379 {
2380 ME_InternalDeleteText(editor, sel_start, num_chars, FALSE);
2381 ME_CommitUndo(editor);
2382 ME_UpdateRepaint(editor, TRUE);
2383 }
2384 return result;
2385}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, int nChars, BOOL bForce)
Definition: caret.c:360
int ME_GetSelectionOfs(ME_TextEditor *editor, int *from, int *to)
Definition: caret.c:42
static BOOL ME_Copy(ME_TextEditor *editor, const ME_Cursor *start, int nChars)
Definition: editor.c:2339
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 4993 of file editor.c.

4994{
4995 ITextHost *host = ME_CreateTextHost( hwnd, create, emulate_10 );
4996 ME_TextEditor *editor;
4997
4998 if (!host) return FALSE;
4999
5000 editor = ME_MakeEditor( host, emulate_10 );
5001 if (!editor)
5002 {
5003 ITextHost_Release( host );
5004 return FALSE;
5005 }
5006
5009 editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */
5010 editor->hwndParent = create->hwndParent;
5011
5012 SetWindowLongPtrW( hwnd, 0, (LONG_PTR)editor );
5013
5014 return TRUE;
5015}
ME_TextEditor * ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
Definition: editor.c:3055
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 3237 of file editor.c.

3238{
3239 TRACE("\n");
3240 switch (fdwReason)
3241 {
3242 case DLL_PROCESS_ATTACH:
3243 DisableThreadLibraryCalls(hinstDLL);
3244 me_heap = HeapCreate (0, 0x10000, 0);
3245 if (!ME_RegisterEditorClass(hinstDLL)) return FALSE;
3247 LookupInit();
3248 break;
3249
3250 case DLL_PROCESS_DETACH:
3251 if (lpvReserved) break;
3255 UnregisterClassA("RichEdit50A", 0);
3260 LookupCleanup();
3263 break;
3264 }
3265 return TRUE;
3266}
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:260
static const WCHAR REListBox20W[]
Definition: editor.c:255
static BOOL ME_ListBoxRegistered
Definition: editor.c:262
static BOOL ME_ComboBoxRegistered
Definition: editor.c:263
static HCURSOR hLeft
Definition: editor.c:257
static const WCHAR REComboBox20W[]
Definition: editor.c:256
static BOOL ME_RegisterEditorClass(HINSTANCE)
Definition: editor.c:5252
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 3268 of file editor.c.

3269{
3270 int height = 0;
3271
3272 if (editor->pBuffer && editor->pBuffer->pDefaultStyle)
3274 if (height <= 0) height = 24;
3275
3276 return height;
3277}
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 3413 of file editor.c.

3414{
3415 if (msg >= EM_GETSEL && msg <= EM_CHARFROMPOS)
3416 return edit_messages[msg - EM_GETSEL];
3417 if (msg >= EM_CANPASTE && msg <= EM_GETIMEMODEBIAS)
3419 return "";
3420}
#define msg(x)
Definition: auth_time.c:54
static const char *const richedit_messages[]
Definition: editor.c:3331
static const char *const edit_messages[]
Definition: editor.c:3286
#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 3542 of file editor.c.

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

Referenced by ME_HandleMessage().

◆ handle_enter()

static BOOL handle_enter ( ME_TextEditor editor)
static

Definition at line 2437 of file editor.c.

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

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

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

Referenced by ME_RTFReadPictGroup(), and paste_emf().

◆ is_link()

static BOOL is_link ( ME_Run run)
static

Definition at line 2891 of file editor.c.

2892{
2893 return (run->style->fmt.dwMask & CFM_LINK) && (run->style->fmt.dwEffects & CFE_LINK);
2894}
#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 265 of file editor.c.

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

Referenced by ME_RegisterEditorClass().

◆ isurlneutral()

static BOOL isurlneutral ( WCHAR  c)
static

Definition at line 5367 of file editor.c.

5368{
5369 /* NB this list is sorted */
5370 static const WCHAR neutral_chars[] = {'!','\"','\'','(',')',',','-','.',':',';','<','>','?','[',']','{','}'};
5371
5372 /* Some shortcuts */
5373 if (isalnum( c )) return FALSE;
5374 if (c > neutral_chars[ARRAY_SIZE( neutral_chars ) - 1]) return FALSE;
5375
5376 return !!bsearch( &c, neutral_chars, ARRAY_SIZE( neutral_chars ), sizeof(c), wchar_comp );
5377}
#define ARRAY_SIZE(A)
Definition: main.h:33
static int __cdecl wchar_comp(const void *key, const void *elem)
Definition: editor.c:5360
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 398 of file editor.c.

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

2843{
2844 static int clickNum = 0;
2845 if (msg < WM_MOUSEFIRST || msg > WM_MOUSELAST)
2846 return 0;
2847
2848 if ((msg == WM_LBUTTONDBLCLK) ||
2849 (msg == WM_RBUTTONDBLCLK) ||
2850 (msg == WM_MBUTTONDBLCLK) ||
2851 (msg == WM_XBUTTONDBLCLK))
2852 {
2854 }
2855
2856 if ((msg == WM_LBUTTONDOWN) ||
2857 (msg == WM_RBUTTONDOWN) ||
2858 (msg == WM_MBUTTONDOWN) ||
2859 (msg == WM_XBUTTONDOWN))
2860 {
2861 static MSG prevClickMsg;
2862 MSG clickMsg;
2863 /* Compare the editor instead of the hwnd so that the this
2864 * can still be done for windowless richedit controls. */
2865 clickMsg.hwnd = (HWND)editor;
2866 clickMsg.message = msg;
2867 clickMsg.wParam = wParam;
2868 clickMsg.lParam = lParam;
2869 clickMsg.time = GetMessageTime();
2870 clickMsg.pt.x = (short)LOWORD(lParam);
2871 clickMsg.pt.y = (short)HIWORD(lParam);
2872 if ((clickNum != 0) &&
2873 (clickMsg.message == prevClickMsg.message) &&
2874 (clickMsg.hwnd == prevClickMsg.hwnd) &&
2875 (clickMsg.wParam == prevClickMsg.wParam) &&
2876 (clickMsg.time - prevClickMsg.time < GetDoubleClickTime()) &&
2877 (abs(clickMsg.pt.x - prevClickMsg.pt.x) < GetSystemMetrics(SM_CXDOUBLECLK)/2) &&
2878 (abs(clickMsg.pt.y - prevClickMsg.pt.y) < GetSystemMetrics(SM_CYDOUBLECLK)/2))
2879 {
2880 clickNum++;
2881 } else {
2882 clickNum = 1;
2883 }
2884 prevClickMsg = clickMsg;
2885 } else {
2886 return 0;
2887 }
2888 return clickNum;
2889}
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 2744 of file editor.c.

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

Referenced by ME_HandleMessage().

◆ ME_Copy()

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

Definition at line 2339 of file editor.c.

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

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

Referenced by ITextServicesImpl_Release(), and ME_HandleMessage().

◆ ME_FilterEvent()

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

Definition at line 2389 of file editor.c.

2390{
2391 MSGFILTER msgf;
2392
2393 if (!editor->hWnd || !editor->hwndParent) return FALSE;
2394 msgf.nmhdr.hwndFrom = editor->hWnd;
2395 msgf.nmhdr.idFrom = GetWindowLongW(editor->hWnd, GWLP_ID);
2396 msgf.nmhdr.code = EN_MSGFILTER;
2397 msgf.msg = msg;
2398 msgf.wParam = *wParam;
2399 msgf.lParam = *lParam;
2400 if (SendMessageW(editor->hwndParent, WM_NOTIFY, msgf.nmhdr.idFrom, (LPARAM)&msgf))
2401 return FALSE;
2402 *wParam = msgf.wParam;
2403 *lParam = msgf.lParam;
2404 msgf.wParam = *wParam;
2405
2406 return TRUE;
2407}
#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 5386 of file editor.c.

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

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

Referenced by ME_HandleMessage().

◆ ME_GetSelectionType()

static LONG ME_GetSelectionType ( ME_TextEditor editor)
static

Definition at line 2996 of file editor.c.

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

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

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

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

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

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

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

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

Referenced by ME_UpdateLinkAttribute().

◆ ME_KeyDown()

static BOOL ME_KeyDown ( ME_TextEditor editor,
WORD  nKey 
)
static

Definition at line 2613 of file editor.c.

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