ReactOS 0.4.16-dev-1311-g81a4d83
edit.c File Reference
#include <user32.h>
#include <usp10.h>
Include dependency graph for edit.c:

Go to the source code of this file.

Classes

struct  tagLINEDEF
 
struct  EDITSTATE
 

Macros

#define WIN32_LEAN_AND_MEAN
 
#define BUFLIMIT_INITIAL   30000 /* initial buffer size */
 
#define GROWLENGTH   32 /* buffers granularity in bytes: must be power of 2 */
 
#define ROUND_TO_GROW(size)   (((size) + (GROWLENGTH - 1)) & ~(GROWLENGTH - 1))
 
#define HSCROLL_FRACTION   3 /* scroll window by 1/3 width */
 
#define EF_MODIFIED   0x0001 /* text has been modified */
 
#define EF_FOCUSED   0x0002 /* we have input focus */
 
#define EF_UPDATE   0x0004 /* notify parent of changed state */
 
#define EF_VSCROLL_TRACK   0x0008 /* don't SetScrollPos() since we are tracking the thumb */
 
#define EF_HSCROLL_TRACK   0x0010 /* don't SetScrollPos() since we are tracking the thumb */
 
#define EF_AFTER_WRAP
 
#define EF_USE_SOFTBRK   0x0100 /* Enable soft breaks in text. */
 
#define EF_DIALOGMODE   0x0200 /* Indicates that we are inside a dialog window */
 
#define SWAP_UINT32(x, y)   do { UINT temp = (UINT)(x); (x) = (UINT)(y); (y) = temp; } while(0)
 
#define ORDER_UINT(x, y)   do { if ((UINT)(y) < (UINT)(x)) SWAP_UINT32((x),(y)); } while(0)
 

Typedefs

typedef struct tagLINEDEF LINEDEF
 

Enumerations

enum  LINE_END {
  END_0 = 0 , END_WRAP , END_HARD , END_SOFT ,
  END_RICH , END_0 = 0 , END_WRAP , END_HARD ,
  END_SOFT , END_RICH
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (edit)
 
 WINE_DECLARE_DEBUG_CHANNEL (combo)
 
 WINE_DECLARE_DEBUG_CHANNEL (relay)
 
static BOOL notify_parent (const EDITSTATE *es, INT code)
 
static LRESULT EDIT_EM_PosFromChar (EDITSTATE *es, INT index, BOOL after_wrap)
 
static BOOL EDIT_EM_CanUndo (const EDITSTATE *es)
 
static void EDIT_EM_EmptyUndoBuffer (EDITSTATE *es)
 
static DWORD get_app_version (void)
 
static HBRUSH EDIT_NotifyCtlColor (EDITSTATE *es, HDC hdc)
 
static UINT get_text_length (EDITSTATE *es)
 
static INT EDIT_WordBreakProc (EDITSTATE *es, LPWSTR s, INT index, INT count, INT action)
 
static INT EDIT_CallWordBreakProc (EDITSTATE *es, INT start, INT index, INT count, INT action)
 
static void EDIT_InvalidateUniscribeData_linedef (LINEDEF *line_def)
 
static void EDIT_InvalidateUniscribeData (EDITSTATE *es)
 
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData_linedef (EDITSTATE *es, HDC dc, LINEDEF *line_def)
 
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData (EDITSTATE *es, HDC dc, INT line)
 
static INT get_vertical_line_count (EDITSTATE *es)
 
static void EDIT_BuildLineDefs_ML (EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
 
static void EDIT_CalcLineWidth_SL (EDITSTATE *es)
 
static INT EDIT_CharFromPos (EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
 
static void EDIT_ConfinePoint (const EDITSTATE *es, LPINT x, LPINT y)
 
static INT EDIT_EM_LineFromChar (EDITSTATE *es, INT index)
 
static INT EDIT_EM_LineIndex (const EDITSTATE *es, INT line)
 
static INT EDIT_EM_LineLength (EDITSTATE *es, INT index)
 
static void EDIT_GetLineRect (EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc)
 
static void text_buffer_changed (EDITSTATE *es)
 
static void EDIT_LockBuffer (EDITSTATE *es)
 
static void EDIT_UnlockBuffer (EDITSTATE *es, BOOL force)
 
static BOOL EDIT_MakeFit (EDITSTATE *es, UINT size)
 
static BOOL EDIT_MakeUndoFit (EDITSTATE *es, UINT size)
 
static void EDIT_UpdateTextRegion (EDITSTATE *es, HRGN hrgn, BOOL bErase)
 
static void EDIT_UpdateText (EDITSTATE *es, const RECT *rc, BOOL bErase)
 
static void EDIT_SL_InvalidateText (EDITSTATE *es, INT start, INT end)
 
static void EDIT_ML_InvalidateText (EDITSTATE *es, INT start, INT end)
 
static void EDIT_InvalidateText (EDITSTATE *es, INT start, INT end)
 
static void EDIT_EM_SetSel (EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
 
static void EDIT_UpdateScrollInfo (EDITSTATE *es)
 
static BOOL EDIT_EM_LineScroll_internal (EDITSTATE *es, INT dx, INT dy)
 
static BOOL EDIT_EM_LineScroll (EDITSTATE *es, INT dx, INT dy)
 
static LRESULT EDIT_EM_Scroll (EDITSTATE *es, INT action)
 
static void EDIT_SetCaretPos (EDITSTATE *es, INT pos, BOOL after_wrap)
 
static void EDIT_EM_ScrollCaret (EDITSTATE *es)
 
static void EDIT_MoveBackward (EDITSTATE *es, BOOL extend)
 
static void EDIT_MoveDown_ML (EDITSTATE *es, BOOL extend)
 
static void EDIT_MoveEnd (EDITSTATE *es, BOOL extend, BOOL ctrl)
 
static void EDIT_MoveForward (EDITSTATE *es, BOOL extend)
 
static void EDIT_MoveHome (EDITSTATE *es, BOOL extend, BOOL ctrl)
 
static void EDIT_MovePageDown_ML (EDITSTATE *es, BOOL extend)
 
static void EDIT_MovePageUp_ML (EDITSTATE *es, BOOL extend)
 
static void EDIT_MoveUp_ML (EDITSTATE *es, BOOL extend)
 
static void EDIT_MoveWordBackward (EDITSTATE *es, BOOL extend)
 
static void EDIT_MoveWordForward (EDITSTATE *es, BOOL extend)
 
static INT EDIT_PaintText (EDITSTATE *es, HDC dc, INT x, INT y, INT line, INT col, INT count, BOOL rev)
 
static void EDIT_PaintLine (EDITSTATE *es, HDC dc, INT line, BOOL rev)
 
static void EDIT_AdjustFormatRect (EDITSTATE *es)
 
static void EDIT_SetRectNP (EDITSTATE *es, const RECT *rc)
 
static LRESULT EDIT_EM_CharFromPos (EDITSTATE *es, INT x, INT y)
 
static BOOL EDIT_EM_FmtLines (EDITSTATE *es, BOOL add_eol)
 
static HLOCAL EDIT_EM_GetHandle (EDITSTATE *es)
 
static INT EDIT_EM_GetLine (EDITSTATE *es, INT line, LPWSTR dst, BOOL unicode)
 
static LRESULT EDIT_EM_GetSel (const EDITSTATE *es, PUINT start, PUINT end)
 
static void EDIT_EM_ReplaceSel (EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update, BOOL honor_limit)
 
static void EDIT_EM_SetHandle (EDITSTATE *es, HLOCAL hloc)
 
static void EDIT_EM_SetLimitText (EDITSTATE *es, UINT limit)
 
static BOOL is_cjk (UINT charset)
 
static void EDIT_EM_SetMargins (EDITSTATE *es, INT action, WORD left, WORD right, BOOL repaint)
 
static void EDIT_EM_SetPasswordChar (EDITSTATE *es, WCHAR c)
 
static BOOL EDIT_EM_SetTabStops (EDITSTATE *es, INT count, const INT *tabs)
 
static void EDIT_EM_SetWordBreakProc (EDITSTATE *es, void *wbp)
 
static BOOL EDIT_EM_Undo (EDITSTATE *es)
 
static BOOL EDIT_IsInsideDialog (EDITSTATE *es)
 
static void EDIT_WM_Paste (EDITSTATE *es)
 
static void EDIT_WM_Copy (EDITSTATE *es)
 
static void EDIT_WM_Clear (EDITSTATE *es)
 
static void EDIT_WM_Cut (EDITSTATE *es)
 
static LRESULT EDIT_WM_Char (EDITSTATE *es, WCHAR c)
 
static void EDIT_ContextMenuCommand (EDITSTATE *es, UINT id)
 
static void EDIT_WM_ContextMenu (EDITSTATE *es, INT x, INT y)
 
static INT EDIT_WM_GetText (const EDITSTATE *es, INT count, LPWSTR dst, BOOL unicode)
 
static BOOL EDIT_CheckCombo (EDITSTATE *es, UINT msg, INT key)
 
static LRESULT EDIT_WM_KeyDown (EDITSTATE *es, INT key)
 
static LRESULT EDIT_WM_KillFocus (EDITSTATE *es)
 
static LRESULT EDIT_WM_LButtonDblClk (EDITSTATE *es)
 
static LRESULT EDIT_WM_LButtonDown (EDITSTATE *es, DWORD keys, INT x, INT y)
 
static LRESULT EDIT_WM_LButtonUp (EDITSTATE *es)
 
static LRESULT EDIT_WM_MButtonDown (EDITSTATE *es)
 
static LRESULT EDIT_WM_MouseMove (EDITSTATE *es, INT x, INT y)
 
static void EDIT_WM_Paint (EDITSTATE *es, HDC hdc)
 
static void EDIT_WM_SetFocus (EDITSTATE *es)
 
static void EDIT_WM_SetFont (EDITSTATE *es, HFONT font, BOOL redraw)
 
static void EDIT_WM_SetText (EDITSTATE *es, LPCWSTR text, BOOL unicode)
 
static void EDIT_WM_Size (EDITSTATE *es, UINT action)
 
static LRESULT EDIT_WM_StyleChanged (EDITSTATE *es, WPARAM which, const STYLESTRUCT *style)
 
static LRESULT EDIT_WM_SysKeyDown (EDITSTATE *es, INT key, DWORD key_data)
 
static void EDIT_WM_Timer (EDITSTATE *es)
 
static LRESULT EDIT_WM_HScroll (EDITSTATE *es, INT action, INT pos)
 
static LRESULT EDIT_WM_VScroll (EDITSTATE *es, INT action, INT pos)
 
static LRESULT EDIT_EM_GetThumb (EDITSTATE *es)
 
static void EDIT_GetCompositionStr (HIMC hIMC, LPARAM CompFlag, EDITSTATE *es)
 
static void EDIT_GetResultStr (HIMC hIMC, EDITSTATE *es)
 
static void EDIT_ImeComposition (HWND hwnd, LPARAM CompFlag, EDITSTATE *es)
 
static LRESULT EDIT_WM_NCCreate (HWND hwnd, LPCREATESTRUCTW lpcs, BOOL unicode)
 
static LRESULT EDIT_WM_Create (EDITSTATE *es, LPCWSTR name)
 
static LRESULT EDIT_WM_NCDestroy (EDITSTATE *es)
 
static LRESULT DefWindowProcT (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
 
LRESULT WINAPI EditWndProc_common (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
 

Variables

static const WCHAR empty_stringW [] = {0}
 
static const WCHAR editW [] = {'E','d','i','t',0}
 
const struct builtin_class_descr EDIT_builtin_class
 

Macro Definition Documentation

◆ BUFLIMIT_INITIAL

#define BUFLIMIT_INITIAL   30000 /* initial buffer size */

Definition at line 66 of file edit.c.

◆ EF_AFTER_WRAP

#define EF_AFTER_WRAP
Value:
0x0080 /* the caret is displayed after the last character of a
wrapped line, instead of in front of the next character */

Definition at line 79 of file edit.c.

◆ EF_DIALOGMODE

#define EF_DIALOGMODE   0x0200 /* Indicates that we are inside a dialog window */

Definition at line 81 of file edit.c.

◆ EF_FOCUSED

#define EF_FOCUSED   0x0002 /* we have input focus */

Definition at line 75 of file edit.c.

◆ EF_HSCROLL_TRACK

#define EF_HSCROLL_TRACK   0x0010 /* don't SetScrollPos() since we are tracking the thumb */

Definition at line 78 of file edit.c.

◆ EF_MODIFIED

#define EF_MODIFIED   0x0001 /* text has been modified */

Definition at line 74 of file edit.c.

◆ EF_UPDATE

#define EF_UPDATE   0x0004 /* notify parent of changed state */

Definition at line 76 of file edit.c.

◆ EF_USE_SOFTBRK

#define EF_USE_SOFTBRK   0x0100 /* Enable soft breaks in text. */

Definition at line 80 of file edit.c.

◆ EF_VSCROLL_TRACK

#define EF_VSCROLL_TRACK   0x0008 /* don't SetScrollPos() since we are tracking the thumb */

Definition at line 77 of file edit.c.

◆ GROWLENGTH

#define GROWLENGTH   32 /* buffers granularity in bytes: must be power of 2 */

Definition at line 67 of file edit.c.

◆ HSCROLL_FRACTION

#define HSCROLL_FRACTION   3 /* scroll window by 1/3 width */

Definition at line 69 of file edit.c.

◆ ORDER_UINT

#define ORDER_UINT (   x,
  y 
)    do { if ((UINT)(y) < (UINT)(x)) SWAP_UINT32((x),(y)); } while(0)

Definition at line 171 of file edit.c.

◆ ROUND_TO_GROW

#define ROUND_TO_GROW (   size)    (((size) + (GROWLENGTH - 1)) & ~(GROWLENGTH - 1))

Definition at line 68 of file edit.c.

◆ SWAP_UINT32

#define SWAP_UINT32 (   x,
  y 
)    do { UINT temp = (UINT)(x); (x) = (UINT)(y); (y) = temp; } while(0)

Definition at line 170 of file edit.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 46 of file edit.c.

Typedef Documentation

◆ LINEDEF

Enumeration Type Documentation

◆ LINE_END

Enumerator
END_0 
END_WRAP 
END_HARD 
END_SOFT 
END_RICH 
END_0 
END_WRAP 
END_HARD 
END_SOFT 
END_RICH 

Definition at line 83 of file edit.c.

85{
86 END_0 = 0, /* line ends with terminating '\0' character */
87 END_WRAP, /* line is wrapped */
88 END_HARD, /* line ends with a hard return '\r\n' */
89 END_SOFT, /* line ends with a soft return '\r\r\n' */
90 END_RICH /* line ends with a single '\n' */
@ END_SOFT
Definition: edit.c:81
@ END_RICH
Definition: edit.c:82
@ END_HARD
Definition: edit.c:80
@ END_0
Definition: edit.c:78
@ END_WRAP
Definition: edit.c:79

Function Documentation

◆ DefWindowProcT()

static LRESULT DefWindowProcT ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  unicode 
)
inlinestatic

Definition at line 4840 of file edit.c.

4842{
4843 if(unicode)
4844 return DefWindowProcW(hwnd, msg, wParam, lParam);
4845 else
4846 return DefWindowProcA(hwnd, msg, wParam, lParam);
#define msg(x)
Definition: auth_time.c:54
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by EditWndProc_common().

◆ EDIT_AdjustFormatRect()

static void EDIT_AdjustFormatRect ( EDITSTATE es)
static

Definition at line 2413 of file edit.c.

2415{
2416 RECT ClientRect;
2417
2418 es->format_rect.right = max(es->format_rect.right, es->format_rect.left + es->char_width);
2419 if (es->style & ES_MULTILINE)
2420 {
2421 INT fw, vlc, max_x_offset, max_y_offset;
2422
2424 es->format_rect.bottom = es->format_rect.top + vlc * es->line_height;
2425
2426 /* correct es->x_offset */
2427 fw = es->format_rect.right - es->format_rect.left;
2428 max_x_offset = es->text_width - fw;
2429 if(max_x_offset < 0) max_x_offset = 0;
2430 if(es->x_offset > max_x_offset)
2431 es->x_offset = max_x_offset;
2432
2433 /* correct es->y_offset */
2434 max_y_offset = es->line_count - vlc;
2435 if(max_y_offset < 0) max_y_offset = 0;
2436 if(es->y_offset > max_y_offset)
2437 es->y_offset = max_y_offset;
2438
2439 /* force scroll info update */
2441 }
2442 else
2443 /* Windows doesn't care to fix text placement for SL controls */
2444 es->format_rect.bottom = es->format_rect.top + es->line_height;
2445
2446 /* Always stay within the client area */
2447 GetClientRect(es->hwndSelf, &ClientRect);
2448 es->format_rect.bottom = min(es->format_rect.bottom, ClientRect.bottom);
2449
2450 if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL))
2452
2453 EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP);
#define NULL
Definition: types.h:112
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:414
#define EF_AFTER_WRAP
Definition: edit.c:70
static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap)
Definition: edit.c:1750
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:429
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:216
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1560
#define es
Definition: i386-dis.c:440
#define min(a, b)
Definition: monoChain.cc:55
#define ES_AUTOHSCROLL
Definition: pedump.c:672
#define ES_MULTILINE
Definition: pedump.c:667
LONG bottom
Definition: windef.h:309
#define max(a, b)
Definition: svc.c:63
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

◆ EDIT_BuildLineDefs_ML()

static void EDIT_BuildLineDefs_ML ( EDITSTATE es,
INT  istart,
INT  iend,
INT  delta,
HRGN  hrgn 
)
static

Definition at line 520 of file edit.c.

522{
523 LPWSTR current_position, cp;
524 INT fw;
525 LINEDEF *current_line;
526 LINEDEF *previous_line;
527 LINEDEF *start_line;
528 INT line_index = 0, nstart_line, nstart_index;
529 INT line_count = es->line_count;
530 INT orig_net_length;
531 RECT rc;
532 INT vlc;
533
534 if (istart == iend && delta == 0)
535 return;
536
537 previous_line = NULL;
538 current_line = es->first_line_def;
539
540 /* Find starting line. istart must lie inside an existing line or
541 * at the end of buffer */
542 do {
543 if (istart < current_line->index + current_line->length ||
544 current_line->ending == END_0)
545 break;
546
547 previous_line = current_line;
548 current_line = current_line->next;
549 line_index++;
550 } while (current_line);
551
552 if (!current_line) /* Error occurred start is not inside previous buffer */
553 {
554 FIXME(" modification occurred outside buffer\n");
555 return;
556 }
557
558 /* Remember start of modifications in order to calculate update region */
559 nstart_line = line_index;
560 nstart_index = current_line->index;
561
562 /* We must start to reformat from the previous line since the modifications
563 * may have caused the line to wrap upwards. */
564 if (!(es->style & ES_AUTOHSCROLL) && line_index > 0)
565 {
566 line_index--;
567 current_line = previous_line;
568 }
569 start_line = current_line;
570
571 fw = es->format_rect.right - es->format_rect.left;
572 current_position = es->text + current_line->index;
574 do {
575 if (current_line != start_line)
576 {
577 if (!current_line || current_line->index + delta > current_position - es->text)
578 {
579 /* The buffer has been expanded, create a new line and
580 insert it into the link list */
582#ifdef __REACTOS__
583 /* ReactOS r33509 */
584 if (new_line == NULL)
585 break;
586#endif
587 new_line->next = previous_line->next;
588 previous_line->next = new_line;
589 current_line = new_line;
590 es->line_count++;
591 }
592 else if (current_line->index + delta < current_position - es->text)
593 {
594 /* The previous line merged with this line so we delete this extra entry */
595 previous_line->next = current_line->next;
596 HeapFree(GetProcessHeap(), 0, current_line);
597 current_line = previous_line->next;
598 es->line_count--;
599 continue;
600 }
601 else /* current_line->index + delta == current_position */
602 {
603 if (current_position - es->text > iend)
604 break; /* We reached end of line modifications */
605 /* else recalculate this line */
606 }
607 }
608
609 current_line->index = current_position - es->text;
610 orig_net_length = current_line->net_length;
611
612 /* Find end of line */
613 cp = current_position;
614 while (*cp) {
615 if (*cp == '\n') break;
616 if ((*cp == '\r') && (*(cp + 1) == '\n'))
617 break;
618 cp++;
619 }
620
621 /* Mark type of line termination */
622 if (!(*cp)) {
623 current_line->ending = END_0;
624 current_line->net_length = strlenW(current_position);
625 } else if ((cp > current_position) && (*(cp - 1) == '\r')) {
626 current_line->ending = END_SOFT;
627 current_line->net_length = cp - current_position - 1;
628 } else if (*cp == '\n') {
629 current_line->ending = END_RICH;
630 current_line->net_length = cp - current_position;
631 } else {
632 current_line->ending = END_HARD;
633 current_line->net_length = cp - current_position;
634 }
635
636 if (current_line->net_length)
637 {
638 const SIZE *sz;
641 if (current_line->ssa)
642 {
643 sz = ScriptString_pSize(current_line->ssa);
644 /* Calculate line width */
645 current_line->width = sz->cx;
646 }
647 else current_line->width = es->char_width * current_line->net_length;
648 }
649 else current_line->width = 0;
650
651 /* FIXME: check here for lines that are too wide even in AUTOHSCROLL (> 32767 ???) */
652
653/* Line breaks just look back from the end and find the next break and try that. */
654
655 if (!(es->style & ES_AUTOHSCROLL)) {
656 if (current_line->width > fw && fw > es->char_width) {
657
658 INT prev, next;
659 int w;
660 const SIZE *sz;
661 float d;
662
663 prev = current_line->net_length - 1;
664 w = current_line->net_length;
665 d = (float)current_line->width/(float)fw;
666 if (d > 1.2f) d -= 0.2f;
667 next = prev/d;
668 if (next >= prev) next = prev-1;
669 do {
670 prev = EDIT_CallWordBreakProc(es, current_position - es->text,
671 next, current_line->net_length, WB_LEFT);
672 current_line->net_length = prev;
675 if (current_line->ssa)
676 sz = ScriptString_pSize(current_line->ssa);
677 else sz = 0;
678 if (sz)
679 current_line->width = sz->cx;
680 else
681 prev = 0;
682 next = prev - 1;
683 } while (prev && current_line->width > fw);
684 current_line->net_length = w;
685
686 if (prev == 0) { /* Didn't find a line break so force a break */
687 INT *piDx;
688 const INT *count;
689
692
693 if (current_line->ssa)
694 {
695 count = ScriptString_pcOutChars(current_line->ssa);
696 piDx = HeapAlloc(GetProcessHeap(),0,sizeof(INT) * (*count));
697 ScriptStringGetLogicalWidths(current_line->ssa,piDx);
698
699 prev = current_line->net_length-1;
700 do {
701 current_line->width -= piDx[prev];
702 prev--;
703 } while ( prev > 0 && current_line->width > fw);
704 if (prev<=0)
705 prev = 1;
706 HeapFree(GetProcessHeap(),0,piDx);
707 }
708 else
709 prev = (fw / es->char_width);
710 }
711
712 /* If the first line we are calculating, wrapped before istart, we must
713 * adjust istart in order for this to be reflected in the update region. */
714 if (current_line->index == nstart_index && istart > current_line->index + prev)
715 istart = current_line->index + prev;
716 /* else if we are updating the previous line before the first line we
717 * are re-calculating and it expanded */
718 else if (current_line == start_line &&
719 current_line->index != nstart_index && orig_net_length < prev)
720 {
721 /* Line expanded due to an upwards line wrap so we must partially include
722 * previous line in update region */
723 nstart_line = line_index;
724 nstart_index = current_line->index;
725 istart = current_line->index + orig_net_length;
726 }
727
728 current_line->net_length = prev;
729 current_line->ending = END_WRAP;
730
731 if (current_line->net_length > 0)
732 {
734 if (current_line->ssa)
735 {
736 sz = ScriptString_pSize(current_line->ssa);
737 current_line->width = sz->cx;
738 }
739 else
740 current_line->width = 0;
741 }
742 else current_line->width = 0;
743 }
744 else if (current_line == start_line &&
745 current_line->index != nstart_index &&
746 orig_net_length < current_line->net_length) {
747 /* The previous line expanded but it's still not as wide as the client rect */
748 /* The expansion is due to an upwards line wrap so we must partially include
749 it in the update region */
750 nstart_line = line_index;
751 nstart_index = current_line->index;
752 istart = current_line->index + orig_net_length;
753 }
754 }
755
756
757 /* Adjust length to include line termination */
758 switch (current_line->ending) {
759 case END_SOFT:
760 current_line->length = current_line->net_length + 3;
761 break;
762 case END_RICH:
763 current_line->length = current_line->net_length + 1;
764 break;
765 case END_HARD:
766 current_line->length = current_line->net_length + 2;
767 break;
768 case END_WRAP:
769 case END_0:
770 current_line->length = current_line->net_length;
771 break;
772 }
773 es->text_width = max(es->text_width, current_line->width);
774 current_position += current_line->length;
775 previous_line = current_line;
776
777 /* Discard data for non-visible lines. It will be calculated as needed */
778 if ((line_index < es->y_offset) || (line_index > es->y_offset + vlc))
780
781 current_line = current_line->next;
782 line_index++;
783 } while (previous_line->ending != END_0);
784
785 /* Finish adjusting line indexes by delta or remove hanging lines */
786 if (previous_line->ending == END_0)
787 {
788 LINEDEF *pnext = NULL;
789
790 previous_line->next = NULL;
791 while (current_line)
792 {
793 pnext = current_line->next;
795 HeapFree(GetProcessHeap(), 0, current_line);
796 current_line = pnext;
797 es->line_count--;
798 }
799 }
800 else if (delta != 0)
801 {
802 while (current_line)
803 {
804 current_line->index += delta;
805 current_line = current_line->next;
806 }
807 }
808
809 /* Calculate rest of modification rectangle */
810 if (hrgn)
811 {
812 HRGN tmphrgn;
813 /*
814 * We calculate two rectangles. One for the first line which may have
815 * an indent with respect to the format rect. The other is a format-width
816 * rectangle that spans the rest of the lines that changed or moved.
817 */
818 rc.top = es->format_rect.top + nstart_line * es->line_height -
819 (es->y_offset * es->line_height); /* Adjust for vertical scrollbar */
820 rc.bottom = rc.top + es->line_height;
821 if ((es->style & ES_CENTER) || (es->style & ES_RIGHT))
822 rc.left = es->format_rect.left;
823 else
824#ifdef __REACTOS__ /* CORE-11475 */
825 rc.left = (short)LOWORD(EDIT_EM_PosFromChar(es, nstart_index, FALSE));
826#else
827 rc.left = LOWORD(EDIT_EM_PosFromChar(es, nstart_index, FALSE));
828#endif
829 rc.right = es->format_rect.right;
830 SetRectRgn(hrgn, rc.left, rc.top, rc.right, rc.bottom);
831
832 rc.top = rc.bottom;
833 rc.left = es->format_rect.left;
834 rc.right = es->format_rect.right;
835 /*
836 * If lines were added or removed we must re-paint the remainder of the
837 * lines since the remaining lines were either shifted up or down.
838 */
839 if (line_count < es->line_count) /* We added lines */
840 rc.bottom = es->line_count * es->line_height;
841 else if (line_count > es->line_count) /* We removed lines */
842 rc.bottom = line_count * es->line_height;
843 else
844 rc.bottom = line_index * es->line_height;
845 rc.bottom += es->format_rect.top;
846 rc.bottom -= (es->y_offset * es->line_height); /* Adjust for vertical scrollbar */
847 tmphrgn = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);
848 CombineRgn(hrgn, hrgn, tmphrgn, RGN_OR);
849 DeleteObject(tmphrgn);
850 }
static HRGN hrgn
#define FIXME(fmt,...)
Definition: precomp.h:53
#define FALSE
Definition: types.h:117
static void EDIT_InvalidateUniscribeData_linedef(LINEDEF *line_def)
Definition: edit.c:306
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData_linedef(EDITSTATE *es, HDC dc, LINEDEF *line_def)
Definition: edit.c:330
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1013
static INT EDIT_CallWordBreakProc(EDITSTATE *es, INT start, INT index, INT count, INT action)
Definition: edit.c:294
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
const WCHAR * text
Definition: package.c:1794
HRESULT WINAPI ScriptStringGetLogicalWidths(SCRIPT_STRING_ANALYSIS ssa, int *piDx)
Definition: usp10.c:3825
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3897
const int *WINAPI ScriptString_pcOutChars(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3959
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
pKey DeleteObject()
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint index
Definition: glext.h:6031
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define d
Definition: ke_i.h:81
POINT cp
Definition: magnifier.c:59
static float(__cdecl *square_half_float)(float x
#define LOWORD(l)
Definition: pedump.c:82
#define ES_CENTER
Definition: pedump.c:665
#define ES_RIGHT
Definition: pedump.c:666
static unsigned __int64 next
Definition: rand_nt.c:6
#define strlenW(s)
Definition: unicode.h:34
LONG cx
Definition: kdterminal.h:27
INT width
Definition: edit.c:89
struct tagLINEDEF * next
Definition: edit.c:92
INT length
Definition: edit.c:86
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:91
INT index
Definition: edit.c:90
INT net_length
Definition: edit.c:87
LINE_END ending
Definition: edit.c:88
LONG right
Definition: windef.h:308
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define RGN_OR
Definition: wingdi.h:359
BOOL WINAPI SetRectRgn(_In_ HRGN, _In_ int, _In_ int, _In_ int, _In_ int)
#define WB_LEFT
Definition: winuser.h:550
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ EDIT_CalcLineWidth_SL()

static void EDIT_CalcLineWidth_SL ( EDITSTATE es)
static

Definition at line 857 of file edit.c.

859{
861 if (es->ssa)
862 {
863 const SIZE *size;
864 size = ScriptString_pSize(es->ssa);
865 es->text_width = size->cx;
866 }
867 else
868 es->text_width = 0;
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, INT line)
Definition: edit.c:372
GLsizeiptr size
Definition: glext.h:5919

◆ EDIT_CallWordBreakProc()

static INT EDIT_CallWordBreakProc ( EDITSTATE es,
INT  start,
INT  index,
INT  count,
INT  action 
)
static

Definition at line 343 of file edit.c.

345{
346 INT ret;
347
348 if (es->word_break_proc)
349 {
350 if(es->is_unicode)
351 {
352 EDITWORDBREAKPROCW wbpW = (EDITWORDBREAKPROCW)es->word_break_proc;
353
354 TRACE_(relay)("(UNICODE wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
355 es->word_break_proc, debugstr_wn(es->text + start, count), index, count, action);
356 ret = wbpW(es->text + start, index, count, action);
357 }
358 else
359 {
360 EDITWORDBREAKPROCA wbpA = (EDITWORDBREAKPROCA)es->word_break_proc;
361 INT countA;
362 CHAR *textA;
363
364 countA = WideCharToMultiByte(CP_ACP, 0, es->text + start, count, NULL, 0, NULL, NULL);
365 textA = HeapAlloc(GetProcessHeap(), 0, countA);
366#ifdef __REACTOS__
367 /* ReactOS r33503 */
368 if (textA == NULL) return 0;
369#endif
370 WideCharToMultiByte(CP_ACP, 0, es->text + start, count, textA, countA, NULL, NULL);
371 TRACE_(relay)("(ANSI wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
372 es->word_break_proc, debugstr_an(textA, countA), index, countA, action);
373 ret = wbpA(textA, index, countA, action);
375 }
376 }
377 else
379
380 return ret;
#define index(s, c)
Definition: various.h:29
static INT EDIT_WordBreakProc(EDITSTATE *es, LPWSTR s, INT index, INT count, INT action)
Definition: edit.c:236
#define CP_ACP
Definition: compat.h:109
#define TRACE_(x)
Definition: compat.h:76
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
#define WideCharToMultiByte
Definition: compat.h:111
const WCHAR * action
Definition: action.c:7509
GLuint start
Definition: gl.h:1545
#define debugstr_wn
Definition: kernel32.h:33
static const char textA[]
Definition: registrar.c:40
int ret
int(CALLBACK * EDITWORDBREAKPROCA)(LPSTR, int, int, int)
Definition: winuser.h:2980
int(CALLBACK * EDITWORDBREAKPROCW)(LPWSTR, int, int, int)
Definition: winuser.h:2981
char CHAR
Definition: xmlstorage.h:175

◆ EDIT_CharFromPos()

static INT EDIT_CharFromPos ( EDITSTATE es,
INT  x,
INT  y,
LPBOOL  after_wrap 
)
static

Definition at line 880 of file edit.c.

882{
883 INT index;
884
885 if (es->style & ES_MULTILINE) {
886 int trailing;
887 INT line = (y - es->format_rect.top) / es->line_height + es->y_offset;
888 INT line_index = 0;
889 LINEDEF *line_def = es->first_line_def;
891 while ((line > 0) && line_def->next) {
892 line_index += line_def->length;
893 line_def = line_def->next;
894 line--;
895 }
896
897 x += es->x_offset - es->format_rect.left;
898 if (es->style & ES_RIGHT)
899 x -= (es->format_rect.right - es->format_rect.left) - line_def->width;
900 else if (es->style & ES_CENTER)
901 x -= ((es->format_rect.right - es->format_rect.left) - line_def->width) / 2;
902 if (x >= line_def->width) {
903 if (after_wrap)
904 *after_wrap = (line_def->ending == END_WRAP);
905 return line_index + line_def->net_length;
906 }
907 if (x <= 0 || !line_def->ssa) {
908 if (after_wrap)
909 *after_wrap = FALSE;
910 return line_index;
911 }
912
913 ScriptStringXtoCP(line_def->ssa, x , &index, &trailing);
914 if (trailing) index++;
915 index += line_index;
916 if (after_wrap)
917 *after_wrap = ((index == line_index + line_def->net_length) &&
918 (line_def->ending == END_WRAP));
919 } else {
920 INT xoff = 0;
922 if (after_wrap)
923 *after_wrap = FALSE;
924 x -= es->format_rect.left;
925 if (!x)
926 return es->x_offset;
927
928 if (!es->x_offset)
929 {
930 INT indent = (es->format_rect.right - es->format_rect.left) - es->text_width;
931 if (es->style & ES_RIGHT)
932 x -= indent;
933 else if (es->style & ES_CENTER)
934 x -= indent / 2;
935 }
936
938 if (es->x_offset)
939 {
940 if (es->ssa)
941 {
942 if (es->x_offset>= get_text_length(es))
943 {
944 const SIZE *size;
945 size = ScriptString_pSize(es->ssa);
946 xoff = size->cx;
947 }
948 ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
949 }
950 else
951 xoff = 0;
952 }
953 if (x < 0)
954 {
955 if (x + xoff > 0 || !es->ssa)
956 {
957 ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
958 if (trailing) index++;
959 }
960 else
961 index = 0;
962 }
963 else
964 {
965 if (x)
966 {
967 const SIZE *size = NULL;
968 if (es->ssa)
969 size = ScriptString_pSize(es->ssa);
970 if (!size)
971 index = 0;
972 else if (x > size->cx)
974 else if (es->ssa)
975 {
976 ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
977 if (trailing) index++;
978 }
979 else
980 index = 0;
981 }
982 else
983 index = es->x_offset;
984 }
985 }
986 return index;
static const WCHAR indent[]
Definition: object.c:1156
HRESULT WINAPI ScriptStringXtoCP(SCRIPT_STRING_ANALYSIS ssa, int iX, int *piCh, int *piTrailing)
Definition: usp10.c:2495
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int *pX)
Definition: usp10.c:2432
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
if(dx< 0)
Definition: linetemp.h:194
Definition: parser.c:49

◆ EDIT_CheckCombo()

static BOOL EDIT_CheckCombo ( EDITSTATE es,
UINT  msg,
INT  key 
)
static

Definition at line 3504 of file edit.c.

3506{
3507 HWND hLBox = es->hwndListBox;
3508 HWND hCombo;
3509 BOOL bDropped;
3510 int nEUI;
3511
3512 if (!hLBox)
3513 return FALSE;
3514
3515 hCombo = GetParent(es->hwndSelf);
3516 bDropped = TRUE;
3517 nEUI = 0;
3518
3519 TRACE_(combo)("[%p]: handling msg %x (%x)\n", es->hwndSelf, msg, key);
3520
3521 if (key == VK_UP || key == VK_DOWN)
3522 {
3523 if (SendMessageW(hCombo, CB_GETEXTENDEDUI, 0, 0))
3524 nEUI = 1;
3525
3526 if (msg == WM_KEYDOWN || nEUI)
3527 bDropped = (BOOL)SendMessageW(hCombo, CB_GETDROPPEDSTATE, 0, 0);
3528 }
3529
3530 switch (msg)
3531 {
3532 case WM_KEYDOWN:
3533 if (!bDropped && nEUI && (key == VK_UP || key == VK_DOWN))
3534 {
3535 /* make sure ComboLBox pops up */
3536 SendMessageW(hCombo, CB_SETEXTENDEDUI, FALSE, 0);
3537 key = VK_F4;
3538 nEUI = 2;
3539 }
3540
3541 SendMessageW(hLBox, WM_KEYDOWN, key, 0);
3542 break;
3543
3544 case WM_SYSKEYDOWN: /* Handle Alt+up/down arrows */
3545 if (nEUI)
3546 SendMessageW(hCombo, CB_SHOWDROPDOWN, !bDropped, 0);
3547 else
3548 SendMessageW(hLBox, WM_KEYDOWN, VK_F4, 0);
3549 break;
3550 }
3551
3552 if(nEUI == 2)
3553 SendMessageW(hCombo, CB_SETEXTENDEDUI, TRUE, 0);
3554
3555 return TRUE;
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
#define BOOL
Definition: nt_native.h:43
Definition: copy.c:22
#define CB_SHOWDROPDOWN
Definition: winuser.h:1989
#define VK_UP
Definition: winuser.h:2244
#define VK_F4
Definition: winuser.h:2277
#define CB_GETDROPPEDSTATE
Definition: winuser.h:1964
HWND WINAPI GetParent(_In_ HWND)
#define CB_GETEXTENDEDUI
Definition: winuser.h:1967
#define VK_DOWN
Definition: winuser.h:2246
#define WM_KEYDOWN
Definition: winuser.h:1734
#define CB_SETEXTENDEDUI
Definition: winuser.h:1983
#define WM_SYSKEYDOWN
Definition: winuser.h:1738
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ EDIT_ConfinePoint()

static void EDIT_ConfinePoint ( const EDITSTATE es,
LPINT  x,
LPINT  y 
)
static

Definition at line 997 of file edit.c.

999{
1000 *x = min(max(*x, es->format_rect.left), es->format_rect.right - 1);
1001 *y = min(max(*y, es->format_rect.top), es->format_rect.bottom - 1);

◆ EDIT_ContextMenuCommand()

static void EDIT_ContextMenuCommand ( EDITSTATE es,
UINT  id 
)
static

Definition at line 3381 of file edit.c.

3383{
3384 switch (id) {
3385 case EM_UNDO:
3386 SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
3387 break;
3388 case WM_CUT:
3389 SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
3390 break;
3391 case WM_COPY:
3392 SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
3393 break;
3394 case WM_PASTE:
3395 SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3396 break;
3397 case WM_CLEAR:
3398 SendMessageW(es->hwndSelf, WM_CLEAR, 0, 0);
3399 break;
3400 case EM_SETSEL:
3401 SendMessageW(es->hwndSelf, EM_SETSEL, 0, -1);
3402 break;
3403 default:
3404 ERR("unknown menu item, please report\n");
3405 break;
3406 }
#define ERR(fmt,...)
Definition: precomp.h:57
#define WM_PASTE
Definition: winuser.h:1882
#define WM_CUT
Definition: winuser.h:1880
#define WM_UNDO
Definition: winuser.h:1884
#define EM_UNDO
Definition: winuser.h:2040
#define EM_SETSEL
Definition: winuser.h:2037
#define WM_COPY
Definition: winuser.h:1881
#define WM_CLEAR
Definition: winuser.h:1883

◆ EDIT_EM_CanUndo()

static BOOL EDIT_EM_CanUndo ( const EDITSTATE es)
inlinestatic

Definition at line 189 of file edit.c.

191{
192 return (es->undo_insert_count || strlenW(es->undo_text));

◆ EDIT_EM_CharFromPos()

static LRESULT EDIT_EM_CharFromPos ( EDITSTATE es,
INT  x,
INT  y 
)
static

Definition at line 2513 of file edit.c.

2515{
2516 POINT pt;
2517 RECT rc;
2518 INT index;
2519
2520 pt.x = x;
2521 pt.y = y;
2522 GetClientRect(es->hwndSelf, &rc);
2523 if (!PtInRect(&rc, pt))
2524 return -1;
2525
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:784
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:913
#define pt(x, y)
Definition: drawing.c:79
#define MAKELONG(a, b)
Definition: typedefs.h:249
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)

◆ EDIT_EM_EmptyUndoBuffer()

static void EDIT_EM_EmptyUndoBuffer ( EDITSTATE es)
inlinestatic

Definition at line 200 of file edit.c.

202{
203 es->undo_insert_count = 0;
204 *es->undo_text = '\0';

◆ EDIT_EM_FmtLines()

static BOOL EDIT_EM_FmtLines ( EDITSTATE es,
BOOL  add_eol 
)
static

Definition at line 2541 of file edit.c.

2543{
2544 es->flags &= ~EF_USE_SOFTBRK;
2545 if (add_eol) {
2546 es->flags |= EF_USE_SOFTBRK;
2547 FIXME("soft break enabled, not implemented\n");
2548 }
2549 return add_eol;
#define EF_USE_SOFTBRK
Definition: edit.c:71

◆ EDIT_EM_GetHandle()

static HLOCAL EDIT_EM_GetHandle ( EDITSTATE es)
static

Definition at line 2563 of file edit.c.

2565{
2566 HLOCAL hLocal;
2567
2568 if (!(es->style & ES_MULTILINE))
2569 return 0;
2570
2571 if(es->is_unicode)
2572 hLocal = es->hloc32W;
2573 else
2574 {
2575 if(!es->hloc32A)
2576 {
2577 CHAR *textA;
2578 UINT countA, alloc_size;
2579 TRACE("Allocating 32-bit ANSI alias buffer\n");
2580 countA = WideCharToMultiByte(CP_ACP, 0, es->text, -1, NULL, 0, NULL, NULL);
2581 alloc_size = ROUND_TO_GROW(countA);
2582 if(!(es->hloc32A = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, alloc_size)))
2583 {
2584 ERR("Could not allocate %d bytes for 32-bit ANSI alias buffer\n", alloc_size);
2585 return 0;
2586 }
2587 textA = LocalLock(es->hloc32A);
2588 WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, countA, NULL, NULL);
2589 LocalUnlock(es->hloc32A);
2590 }
2591 hLocal = es->hloc32A;
2592 }
2593
2595
2596 /* The text buffer handle belongs to the app */
2597 es->hlocapp = hLocal;
2598
2599 TRACE("Returning %p, LocalSize() = %ld\n", hLocal, LocalSize(hLocal));
2600 return hLocal;
#define ROUND_TO_GROW(size)
Definition: edit.c:59
static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
Definition: edit.c:1230
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1616
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1805
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1794
unsigned int UINT
Definition: ndis.h:50
#define TRACE(s)
Definition: solgame.cpp:4
#define LMEM_MOVEABLE
Definition: winbase.h:402
#define LMEM_ZEROINIT
Definition: winbase.h:408

◆ EDIT_EM_GetLine()

static INT EDIT_EM_GetLine ( EDITSTATE es,
INT  line,
LPWSTR  dst,
BOOL  unicode 
)
static

Definition at line 2608 of file edit.c.

2610{
2611 LPWSTR src;
2612 INT line_len, dst_len;
2613 INT i;
2614
2615 if (es->style & ES_MULTILINE) {
2616 if (line >= es->line_count)
2617 return 0;
2618 } else
2619 line = 0;
2621 src = es->text + i;
2622 line_len = EDIT_EM_LineLength(es, i);
2623 dst_len = *(WORD *)dst;
2624 if(unicode)
2625 {
2626 if(dst_len <= line_len)
2627 {
2628 memcpy(dst, src, dst_len * sizeof(WCHAR));
2629 return dst_len;
2630 }
2631 else /* Append 0 if enough space */
2632 {
2633 memcpy(dst, src, line_len * sizeof(WCHAR));
2634 dst[line_len] = 0;
2635 return line_len;
2636 }
2637 }
2638 else
2639 {
2640 INT ret = WideCharToMultiByte(CP_ACP, 0, src, line_len, (LPSTR)dst, dst_len, NULL, NULL);
2641 if(!ret && line_len) /* Insufficient buffer size */
2642 return dst_len;
2643 if(ret < dst_len) /* Append 0 if enough space */
2644 ((LPSTR)dst)[ret] = 0;
2645 return ret;
2646 }
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:942
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:977
unsigned short WORD
Definition: ntddk_ex.h:93
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
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
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ EDIT_EM_GetSel()

static LRESULT EDIT_EM_GetSel ( const EDITSTATE es,
PUINT  start,
PUINT  end 
)
static

Definition at line 2654 of file edit.c.

2656{
2657 UINT s = es->selection_start;
2658 UINT e = es->selection_end;
2659
2660 ORDER_UINT(s, e);
2661 if (start)
2662 *start = s;
2663 if (end)
2664 *end = e;
2665 return MAKELONG(s, e);
#define ORDER_UINT(x, y)
Definition: edit.c:164
GLdouble s
Definition: gl.h:2039
GLuint GLuint end
Definition: gl.h:1545
#define e
Definition: ke_i.h:82

◆ EDIT_EM_GetThumb()

static LRESULT EDIT_EM_GetThumb ( EDITSTATE es)
static

Definition at line 4481 of file edit.c.

4483{
static LRESULT EDIT_WM_HScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:4062
static LRESULT EDIT_WM_VScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:4194
#define EM_GETTHUMB
Definition: winuser.h:2017

◆ EDIT_EM_LineFromChar()

static INT EDIT_EM_LineFromChar ( EDITSTATE es,
INT  index 
)
static

Definition at line 1009 of file edit.c.

1011{
1012 INT line;
1013 LINEDEF *line_def;
1014
1015 if (!(es->style & ES_MULTILINE))
1016 return 0;
1017 if (index > (INT)get_text_length(es))
1018 return es->line_count - 1;
1019 if (index == -1)
1020 index = min(es->selection_start, es->selection_end);
1021
1022 line = 0;
1023 line_def = es->first_line_def;
1024 index -= line_def->length;
1025 while ((index >= 0) && line_def->next) {
1026 line++;
1027 line_def = line_def->next;
1028 index -= line_def->length;
1029 }
1030 return line;

◆ EDIT_EM_LineIndex()

static INT EDIT_EM_LineIndex ( const EDITSTATE es,
INT  line 
)
static

Definition at line 1038 of file edit.c.

1040{
1041 INT line_index;
1042 const LINEDEF *line_def;
1043
1044 if (!(es->style & ES_MULTILINE))
1045 return 0;
1046 if (line >= es->line_count)
1047 return -1;
1048
1049 line_index = 0;
1050 line_def = es->first_line_def;
1051 if (line == -1) {
1052 INT index = es->selection_end - line_def->length;
1053 while ((index >= 0) && line_def->next) {
1054 line_index += line_def->length;
1055 line_def = line_def->next;
1056 index -= line_def->length;
1057 }
1058 } else {
1059 while (line > 0) {
1060 line_index += line_def->length;
1061 line_def = line_def->next;
1062 line--;
1063 }
1064 }
1065 return line_index;

◆ EDIT_EM_LineLength()

static INT EDIT_EM_LineLength ( EDITSTATE es,
INT  index 
)
static

Definition at line 1073 of file edit.c.

1075{
1076 LINEDEF *line_def;
1077
1078 if (!(es->style & ES_MULTILINE))
1079 return get_text_length(es);
1080
1081 if (index == -1) {
1082 /* get the number of remaining non-selected chars of selected lines */
1083 INT32 l; /* line number */
1084 INT32 li; /* index of first char in line */
1085 INT32 count;
1086 l = EDIT_EM_LineFromChar(es, es->selection_start);
1087 /* # chars before start of selection area */
1088 count = es->selection_start - EDIT_EM_LineIndex(es, l);
1089 l = EDIT_EM_LineFromChar(es, es->selection_end);
1090 /* # chars after end of selection */
1092 count += li + EDIT_EM_LineLength(es, li) - es->selection_end;
1093 return count;
1094 }
1095 line_def = es->first_line_def;
1096 index -= line_def->length;
1097 while ((index >= 0) && line_def->next) {
1098 line_def = line_def->next;
1099 index -= line_def->length;
1100 }
1101 return line_def->net_length;
signed int INT32
r l[0]
Definition: byte_order.h:168
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235

◆ EDIT_EM_LineScroll()

static BOOL EDIT_EM_LineScroll ( EDITSTATE es,
INT  dx,
INT  dy 
)
static

Definition at line 1809 of file edit.c.

1811{
1812 if (!(es->style & ES_MULTILINE))
1813 return FALSE;
1814
1815 dx *= es->char_width;
static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1601
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97

◆ EDIT_EM_LineScroll_internal()

static BOOL EDIT_EM_LineScroll_internal ( EDITSTATE es,
INT  dx,
INT  dy 
)
static

Definition at line 1753 of file edit.c.

1755{
1756 INT nyoff;
1757 INT x_offset_in_pixels;
1758 INT lines_per_page = (es->format_rect.bottom - es->format_rect.top) /
1759 es->line_height;
1760
1761 if (es->style & ES_MULTILINE)
1762 {
1763 x_offset_in_pixels = es->x_offset;
1764 }
1765 else
1766 {
1767 dy = 0;
1768 x_offset_in_pixels = (short)LOWORD(EDIT_EM_PosFromChar(es, es->x_offset, FALSE));
1769 }
1770
1771 if (-dx > x_offset_in_pixels)
1772 dx = -x_offset_in_pixels;
1773 if (dx > es->text_width - x_offset_in_pixels)
1774 dx = es->text_width - x_offset_in_pixels;
1775 nyoff = max(0, es->y_offset + dy);
1776 if (nyoff >= es->line_count - lines_per_page)
1777 nyoff = max(0, es->line_count - lines_per_page);
1778 dy = (es->y_offset - nyoff) * es->line_height;
1779 if (dx || dy) {
1780 RECT rc1;
1781 RECT rc;
1782
1783 es->y_offset = nyoff;
1784 if(es->style & ES_MULTILINE)
1785 es->x_offset += dx;
1786 else
1787 es->x_offset += dx / es->char_width;
1788
1789 GetClientRect(es->hwndSelf, &rc1);
1790 IntersectRect(&rc, &rc1, &es->format_rect);
1791 ScrollWindowEx(es->hwndSelf, -dx, dy,
1792 NULL, &rc, NULL, NULL, SW_INVALIDATE);
1793 /* force scroll info update */
1795 }
1796 if (dx && !(es->flags & EF_HSCROLL_TRACK))
1798 if (dy && !(es->flags & EF_VSCROLL_TRACK))
1800 return TRUE;
static BOOL notify_parent(const EDITSTATE *es, INT code)
Definition: edit.c:166
#define EF_HSCROLL_TRACK
Definition: edit.c:69
#define EF_VSCROLL_TRACK
Definition: edit.c:68
#define SW_INVALIDATE
Definition: winuser.h:2598
#define EN_HSCROLL
Definition: winuser.h:2043
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define EN_VSCROLL
Definition: winuser.h:2048
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)

◆ EDIT_EM_PosFromChar()

static LRESULT EDIT_EM_PosFromChar ( EDITSTATE es,
INT  index,
BOOL  after_wrap 
)
static

Definition at line 1109 of file edit.c.

1111{
1113 INT l;
1114 INT li;
1115 INT x = 0;
1116 INT y = 0;
1117 INT w;
1118 INT lw;
1119 LINEDEF *line_def;
1120
1121 index = min(index, len);
1122 if (es->style & ES_MULTILINE) {
1125
1126 y = (l - es->y_offset) * es->line_height;
1128 if (after_wrap && (li == index) && l) {
1129 INT l2 = l - 1;
1130 line_def = es->first_line_def;
1131 while (l2) {
1132 line_def = line_def->next;
1133 l2--;
1134 }
1135 if (line_def->ending == END_WRAP) {
1136 l--;
1137 y -= es->line_height;
1139 }
1140 }
1141
1142 line_def = es->first_line_def;
1143 while (line_def->index != li)
1144 line_def = line_def->next;
1145
1146 lw = line_def->width;
1147 w = es->format_rect.right - es->format_rect.left;
1148 if (line_def->ssa)
1149 {
1150 ScriptStringCPtoX(line_def->ssa, (index - 1) - li, TRUE, &x);
1151 x -= es->x_offset;
1152 }
1153 else
1154#ifdef __REACTOS__ /* CORE-15780 */
1155 x = (lw > 0 ? es->x_offset : x - es->x_offset);
1156#else
1157 x = es->x_offset;
1158#endif
1159
1160 if (es->style & ES_RIGHT)
1161 x = w - (lw - x);
1162 else if (es->style & ES_CENTER)
1163 x += (w - lw) / 2;
1164 } else {
1165 INT xoff = 0;
1166 INT xi = 0;
1168 if (es->x_offset)
1169 {
1170 if (es->ssa)
1171 {
1172 if (es->x_offset >= get_text_length(es))
1173 {
1174 int leftover = es->x_offset - get_text_length(es);
1175 if (es->ssa)
1176 {
1177 const SIZE *size;
1178 size = ScriptString_pSize(es->ssa);
1179 xoff = size->cx;
1180 }
1181 else
1182 xoff = 0;
1183 xoff += es->char_width * leftover;
1184 }
1185 else
1186 ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
1187 }
1188 else
1189 xoff = 0;
1190 }
1191 if (index)
1192 {
1193 if (index >= get_text_length(es))
1194 {
1195 if (es->ssa)
1196 {
1197 const SIZE *size;
1198 size = ScriptString_pSize(es->ssa);
1199 xi = size->cx;
1200 }
1201 else
1202 xi = 0;
1203 }
1204 else if (es->ssa)
1205 ScriptStringCPtoX(es->ssa, index, FALSE, &xi);
1206 else
1207 xi = 0;
1208 }
1209 x = xi - xoff;
1210
1211 if (index >= es->x_offset) {
1212 if (!es->x_offset && (es->style & (ES_RIGHT | ES_CENTER)))
1213 {
1214 w = es->format_rect.right - es->format_rect.left;
1215 if (w > es->text_width)
1216 {
1217 if (es->style & ES_RIGHT)
1218 x += w - es->text_width;
1219 else if (es->style & ES_CENTER)
1220 x += (w - es->text_width) / 2;
1221 }
1222 }
1223 }
1224 y = 0;
1225 }
1226 x += es->format_rect.left;
1227 y += es->format_rect.top;
1228 return MAKELONG((INT16)x, (INT16)y);
signed short INT16
GLenum GLsizei len
Definition: glext.h:6722

◆ EDIT_EM_ReplaceSel()

static void EDIT_EM_ReplaceSel ( EDITSTATE es,
BOOL  can_undo,
LPCWSTR  lpsz_replace,
BOOL  send_update,
BOOL  honor_limit 
)
static

Definition at line 2675 of file edit.c.

2677{
2678 UINT strl = strlenW(lpsz_replace);
2679 UINT tl = get_text_length(es);
2680 UINT utl;
2681 UINT s;
2682 UINT e;
2683 UINT i;
2684 UINT size;
2685 LPWSTR p;
2686 HRGN hrgn = 0;
2687 LPWSTR buf = NULL;
2688 UINT bufl;
2689
2690 TRACE("%s, can_undo %d, send_update %d\n",
2691 debugstr_w(lpsz_replace), can_undo, send_update);
2692
2693 s = es->selection_start;
2694 e = es->selection_end;
2695
2697 if ((s == e) && !strl)
2698 return;
2699
2700 ORDER_UINT(s, e);
2701
2702 size = tl - (e - s) + strl;
2703 if (!size)
2704 es->text_width = 0;
2705
2706 /* Issue the EN_MAXTEXT notification and continue with replacing text
2707 * so that buffer limit is honored. */
2708 if ((honor_limit) && (size > es->buffer_limit))
2709 {
2710 if (!notify_parent(es, EN_MAXTEXT)) return;
2711 /* Buffer limit can be smaller than the actual length of text in combobox */
2712 if (es->buffer_limit < (tl - (e-s)))
2713 strl = 0;
2714 else
2715 strl = min(strl, es->buffer_limit - (tl - (e-s)));
2716 }
2717
2718 if (!EDIT_MakeFit(es, tl - (e - s) + strl))
2719 return;
2720
2721 if (e != s) {
2722 /* there is something to be deleted */
2723 TRACE("deleting stuff.\n");
2724 bufl = e - s;
2725 buf = HeapAlloc(GetProcessHeap(), 0, (bufl + 1) * sizeof(WCHAR));
2726 if (!buf) return;
2727 memcpy(buf, es->text + s, bufl * sizeof(WCHAR));
2728 buf[bufl] = 0; /* ensure 0 termination */
2729 /* now delete */
2730 strcpyW(es->text + s, es->text + e);
2732 }
2733 if (strl) {
2734 /* there is an insertion */
2735 tl = get_text_length(es);
2736 TRACE("inserting stuff (tl %d, strl %d, selstart %d (%s), text %s)\n", tl, strl, s, debugstr_w(es->text + s), debugstr_w(es->text));
2737 for (p = es->text + tl ; p >= es->text + s ; p--)
2738 p[strl] = p[0];
2739 for (i = 0 , p = es->text + s ; i < strl ; i++)
2740 p[i] = lpsz_replace[i];
2741 if(es->style & ES_UPPERCASE)
2742 CharUpperBuffW(p, strl);
2743 else if(es->style & ES_LOWERCASE)
2744 CharLowerBuffW(p, strl);
2746 }
2747 if (es->style & ES_MULTILINE)
2748 {
2749 INT st = min(es->selection_start, es->selection_end);
2751
2752 hrgn = CreateRectRgn(0, 0, 0, 0);
2753 EDIT_BuildLineDefs_ML(es, st, st + strl,
2754 strl - abs(es->selection_end - es->selection_start), hrgn);
2755 /* if text is too long undo all changes */
2756 if (honor_limit && !(es->style & ES_AUTOVSCROLL) && (es->line_count > vlc)) {
2757 if (strl)
2758 strcpyW(es->text + e, es->text + e + strl);
2759 if (e != s)
2760 for (i = 0 , p = es->text ; i < e - s ; i++)
2761 p[i + s] = buf[i];
2764 abs(es->selection_end - es->selection_start) - strl, hrgn);
2765 strl = 0;
2766 e = s;
2767 SetRectRgn(hrgn, 0, 0, 0, 0);
2768 if (!notify_parent(es, EN_MAXTEXT)) return;
2769 }
2770 }
2771 else {
2772 INT fw = es->format_rect.right - es->format_rect.left;
2775 /* remove chars that don't fit */
2776 if (honor_limit && !(es->style & ES_AUTOHSCROLL) && (es->text_width > fw)) {
2777 while ((es->text_width > fw) && s + strl >= s) {
2778 strcpyW(es->text + s + strl - 1, es->text + s + strl);
2779 strl--;
2780 es->text_length = -1;
2783 }
2785 if (!notify_parent(es, EN_MAXTEXT)) return;
2786 }
2787 }
2788
2789 if (e != s) {
2790 if (can_undo) {
2791 utl = strlenW(es->undo_text);
2792 if (!es->undo_insert_count && (*es->undo_text && (s == es->undo_position))) {
2793 /* undo-buffer is extended to the right */
2794 EDIT_MakeUndoFit(es, utl + e - s);
2795 memcpy(es->undo_text + utl, buf, (e - s)*sizeof(WCHAR));
2796 (es->undo_text + utl)[e - s] = 0; /* ensure 0 termination */
2797 } else if (!es->undo_insert_count && (*es->undo_text && (e == es->undo_position))) {
2798 /* undo-buffer is extended to the left */
2799 EDIT_MakeUndoFit(es, utl + e - s);
2800 for (p = es->undo_text + utl ; p >= es->undo_text ; p--)
2801 p[e - s] = p[0];
2802 for (i = 0 , p = es->undo_text ; i < e - s ; i++)
2803 p[i] = buf[i];
2804 es->undo_position = s;
2805 } else {
2806 /* new undo-buffer */
2807 EDIT_MakeUndoFit(es, e - s);
2808 memcpy(es->undo_text, buf, (e - s)*sizeof(WCHAR));
2809 es->undo_text[e - s] = 0; /* ensure 0 termination */
2810 es->undo_position = s;
2811 }
2812 /* any deletion makes the old insertion-undo invalid */
2813 es->undo_insert_count = 0;
2814 } else
2816 }
2817 if (strl) {
2818 if (can_undo) {
2819 if ((s == es->undo_position) ||
2820 ((es->undo_insert_count) &&
2821 (s == es->undo_position + es->undo_insert_count)))
2822 /*
2823 * insertion is new and at delete position or
2824 * an extension to either left or right
2825 */
2826 es->undo_insert_count += strl;
2827 else {
2828 /* new insertion undo */
2829 es->undo_position = s;
2830 es->undo_insert_count = strl;
2831 /* new insertion makes old delete-buffer invalid */
2832 *es->undo_text = '\0';
2833 }
2834 } else
2836 }
2837
2839
2840 s += strl;
2841
2842 /* If text has been deleted and we're right or center aligned then scroll rightward */
2843 if (es->style & (ES_RIGHT | ES_CENTER))
2844 {
2845 INT delta = strl - abs(es->selection_end - es->selection_start);
2846
2847 if (delta < 0 && es->x_offset)
2848 {
2849 if (abs(delta) > es->x_offset)
2850 es->x_offset = 0;
2851 else
2852 es->x_offset += delta;
2853 }
2854 }
2855
2857 es->flags |= EF_MODIFIED;
2858 if (send_update) es->flags |= EF_UPDATE;
2859 if (hrgn)
2860 {
2863 }
2864 else
2866
2868
2869 /* force scroll info update */
2871
2872
2873 if(send_update || (es->flags & EF_UPDATE))
2874 {
2875 es->flags &= ~EF_UPDATE;
2876 if (!notify_parent(es, EN_CHANGE)) return;
2877 }
#define EF_MODIFIED
Definition: edit.c:65
static void EDIT_CalcLineWidth_SL(EDITSTATE *es)
Definition: edit.c:761
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1778
#define EF_UPDATE
Definition: edit.c:67
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:315
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:192
static void text_buffer_changed(EDITSTATE *es)
Definition: edit.c:1198
static BOOL EDIT_MakeFit(EDITSTATE *es, UINT size)
Definition: edit.c:1276
static BOOL EDIT_MakeUndoFit(EDITSTATE *es, UINT size)
Definition: edit.c:1317
static void EDIT_UpdateTextRegion(EDITSTATE *es, HRGN hrgn, BOOL bErase)
Definition: edit.c:1344
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1359
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1489
DWORD WINAPI CharLowerBuffW(WCHAR *str, DWORD len)
Definition: string.c:1086
DWORD WINAPI CharUpperBuffW(WCHAR *str, DWORD len)
Definition: string.c:1199
#define abs(i)
Definition: fconv.c:206
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLfloat GLfloat p
Definition: glext.h:8902
#define debugstr_w
Definition: kernel32.h:32
#define ES_LOWERCASE
Definition: pedump.c:669
#define ES_AUTOVSCROLL
Definition: pedump.c:671
#define ES_UPPERCASE
Definition: pedump.c:668
#define strcpyW(d, s)
Definition: unicode.h:35
#define EN_MAXTEXT
Definition: winuser.h:2045
#define EN_CHANGE
Definition: winuser.h:2041

◆ EDIT_EM_Scroll()

static LRESULT EDIT_EM_Scroll ( EDITSTATE es,
INT  action 
)
static

Definition at line 1824 of file edit.c.

1826{
1827 INT dy;
1828
1829 if (!(es->style & ES_MULTILINE))
1830 return (LRESULT)FALSE;
1831
1832 dy = 0;
1833
1834 switch (action) {
1835 case SB_LINEUP:
1836 if (es->y_offset)
1837 dy = -1;
1838 break;
1839 case SB_LINEDOWN:
1840 if (es->y_offset < es->line_count - 1)
1841 dy = 1;
1842 break;
1843 case SB_PAGEUP:
1844 if (es->y_offset)
1845 dy = -(es->format_rect.bottom - es->format_rect.top) / es->line_height;
1846 break;
1847 case SB_PAGEDOWN:
1848 if (es->y_offset < es->line_count - 1)
1849 dy = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
1850 break;
1851 default:
1853 }
1854 if (dy) {
1856 /* check if we are going to move too far */
1857 if(es->y_offset + dy > es->line_count - vlc)
1858 dy = max(es->line_count - vlc, 0) - es->y_offset;
1859
1860 /* Notification is done in EDIT_EM_LineScroll */
1861 if(dy) {
1863 return MAKELONG(dy, TRUE);
1864 }
1865
1866 }
1867 return (LRESULT)FALSE;
return
Definition: dirsup.c:529
static BOOL EDIT_EM_LineScroll(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1657
LONG_PTR LRESULT
Definition: windef.h:209
#define SB_LINEUP
Definition: winuser.h:564
#define SB_PAGEDOWN
Definition: winuser.h:569
#define SB_LINEDOWN
Definition: winuser.h:565
#define SB_PAGEUP
Definition: winuser.h:568

◆ EDIT_EM_ScrollCaret()

static void EDIT_EM_ScrollCaret ( EDITSTATE es)
static

Definition at line 1930 of file edit.c.

1932{
1933 if (es->style & ES_MULTILINE) {
1934 INT l;
1935 INT vlc;
1936 INT ww;
1937 INT cw = es->char_width;
1938 INT x;
1939 INT dy = 0;
1940 INT dx = 0;
1941
1942 l = EDIT_EM_LineFromChar(es, es->selection_end);
1943 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP));
1945 if (l >= es->y_offset + vlc)
1946 dy = l - vlc + 1 - es->y_offset;
1947 if (l < es->y_offset)
1948 dy = l - es->y_offset;
1949 ww = es->format_rect.right - es->format_rect.left;
1950 if (x < es->format_rect.left)
1951 dx = x - es->format_rect.left - ww / HSCROLL_FRACTION / cw * cw;
1952 if (x > es->format_rect.right)
1953 dx = x - es->format_rect.left - (HSCROLL_FRACTION - 1) * ww / HSCROLL_FRACTION / cw * cw;
1954 if (dy || dx || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1955 {
1956 /* check if we are going to move too far */
1957 if(es->x_offset + dx + ww > es->text_width)
1958 dx = es->text_width - ww - es->x_offset;
1959 if(dx || dy || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1961 }
1962 } else {
1963 INT x;
1964 INT goal;
1965 INT format_width;
1966
1967 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1968 format_width = es->format_rect.right - es->format_rect.left;
1969 if (x < es->format_rect.left) {
1970 goal = es->format_rect.left + format_width / HSCROLL_FRACTION;
1971 do {
1972 es->x_offset--;
1973 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1974 } while ((x < goal) && es->x_offset);
1975 /* FIXME: use ScrollWindow() somehow to improve performance */
1977 } else if (x > es->format_rect.right) {
1978 INT x_last;
1980 goal = es->format_rect.right - format_width / HSCROLL_FRACTION;
1981 do {
1982 es->x_offset++;
1983 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1985 } while ((x > goal) && (x_last > es->format_rect.right));
1986 /* FIXME: use ScrollWindow() somehow to improve performance */
1988 }
1989 }
1990
1991 if(es->flags & EF_FOCUSED)
1992 EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP);
#define EF_FOCUSED
Definition: edit.c:66
#define HSCROLL_FRACTION
Definition: edit.c:60

◆ EDIT_EM_SetHandle()

static void EDIT_EM_SetHandle ( EDITSTATE es,
HLOCAL  hloc 
)
static

Definition at line 2888 of file edit.c.

2890{
2891 if (!(es->style & ES_MULTILINE))
2892 return;
2893
2894 if (!hloc) {
2895 WARN("called with NULL handle\n");
2896 return;
2897 }
2898
2899#ifdef __REACTOS__
2900 if (es->text)
2901#endif
2903
2904 if(es->is_unicode)
2905 {
2906 if(es->hloc32A)
2907 {
2908 LocalFree(es->hloc32A);
2909 es->hloc32A = NULL;
2910 }
2911 es->hloc32W = hloc;
2912 }
2913 else
2914 {
2915 INT countW, countA;
2916 HLOCAL hloc32W_new;
2917 WCHAR *textW;
2918 CHAR *textA;
2919
2920 countA = LocalSize(hloc);
2921 textA = LocalLock(hloc);
2922 countW = MultiByteToWideChar(CP_ACP, 0, textA, countA, NULL, 0);
2923 if(!(hloc32W_new = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, countW * sizeof(WCHAR))))
2924 {
2925 ERR("Could not allocate new unicode buffer\n");
2926 return;
2927 }
2928 textW = LocalLock(hloc32W_new);
2929 MultiByteToWideChar(CP_ACP, 0, textA, countA, textW, countW);
2930 LocalUnlock(hloc32W_new);
2931 LocalUnlock(hloc);
2932
2933 if(es->hloc32W)
2934 LocalFree(es->hloc32W);
2935
2936 es->hloc32W = hloc32W_new;
2937 es->hloc32A = hloc;
2938 }
2939
2940 es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1;
2941
2942 /* The text buffer handle belongs to the control */
2943 es->hlocapp = NULL;
2944
2947
2948 es->x_offset = es->y_offset = 0;
2949 es->selection_start = es->selection_end = 0;
2951 es->flags &= ~EF_MODIFIED;
2952 es->flags &= ~EF_UPDATE;
2956 /* force scroll info update */
#define WARN(fmt,...)
Definition: precomp.h:61
static void EDIT_LockBuffer(EDITSTATE *es)
Definition: edit.c:1211
#define MultiByteToWideChar
Definition: compat.h:110
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
static const WCHAR textW[]
Definition: itemdlg.c:1559

◆ EDIT_EM_SetLimitText()

static void EDIT_EM_SetLimitText ( EDITSTATE es,
UINT  limit 
)
static

Definition at line 2967 of file edit.c.

2969{
2970 if (!limit) limit = ~0u;
2971 if (!(es->style & ES_MULTILINE)) limit = min(limit, 0x7ffffffe);
2972 es->buffer_limit = limit;
GLint limit
Definition: glext.h:10326
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 * u
Definition: glfuncs.h:240

◆ EDIT_EM_SetMargins()

static void EDIT_EM_SetMargins ( EDITSTATE es,
INT  action,
WORD  left,
WORD  right,
BOOL  repaint 
)
static

Definition at line 3003 of file edit.c.

3006{
3008 INT default_left_margin = 0; /* in pixels */
3009 INT default_right_margin = 0; /* in pixels */
3010
3011 /* Set the default margins depending on the font */
3012 if (es->font && (left == EC_USEFONTINFO || right == EC_USEFONTINFO)) {
3013 HDC dc = GetDC(es->hwndSelf);
3014 HFONT old_font = SelectObject(dc, es->font);
3016 RECT rc;
3017
3018 /* The default margins are only non zero for TrueType or Vector fonts */
3019 if (tm.tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE )) {
3020 if (!is_cjk(tm.tmCharSet)) {
3021 default_left_margin = width / 2;
3022 default_right_margin = width / 2;
3023
3024 GetClientRect(es->hwndSelf, &rc);
3025 if (rc.right - rc.left < (width / 2 + width) * 2 &&
3026 (width >= 28 || !IsRectEmpty(&rc)) ) {
3027 default_left_margin = es->left_margin;
3028 default_right_margin = es->right_margin;
3029 }
3030 } else {
3031 /* FIXME: figure out the CJK values. They are not affected by the client rect. */
3032 default_left_margin = width / 2;
3033 default_right_margin = width / 2;
3034 }
3035 }
3036 SelectObject(dc, old_font);
3037 ReleaseDC(es->hwndSelf, dc);
3038 }
3039
3040 if (action & EC_LEFTMARGIN) {
3041 es->format_rect.left -= es->left_margin;
3042 if (left != EC_USEFONTINFO)
3043 es->left_margin = left;
3044 else
3045 es->left_margin = default_left_margin;
3046 es->format_rect.left += es->left_margin;
3047 }
3048
3049 if (action & EC_RIGHTMARGIN) {
3050 es->format_rect.right += es->right_margin;
3051 if (right != EC_USEFONTINFO)
3052 es->right_margin = right;
3053 else
3054 es->right_margin = default_right_margin;
3055 es->format_rect.right -= es->right_margin;
3056 }
3057
3060 if (repaint) EDIT_UpdateText(es, NULL, TRUE);
3061 }
3062
3063 TRACE("left=%d, right=%d\n", es->left_margin, es->right_margin);
HDC dc
Definition: cylfrac.c:34
static void EDIT_AdjustFormatRect(EDITSTATE *es)
Definition: edit.c:2266
GLint GLint GLsizei width
Definition: gl.h:1546
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
static HDC
Definition: imagelist.c:88
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static BOOL is_cjk(void)
Definition: dde.c:46
long LONG
Definition: pedump.c:60
Definition: time.h:68
LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *)
Definition: font.c:2293
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define TMPF_TRUETYPE
Definition: wingdi.h:1313
#define TMPF_VECTOR
Definition: wingdi.h:1312
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define EC_RIGHTMARGIN
Definition: winuser.h:2626
#define EC_USEFONTINFO
Definition: winuser.h:2627
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
HDC WINAPI GetDC(_In_opt_ HWND)
#define EC_LEFTMARGIN
Definition: winuser.h:2625

◆ EDIT_EM_SetPasswordChar()

static void EDIT_EM_SetPasswordChar ( EDITSTATE es,
WCHAR  c 
)
static

Definition at line 3071 of file edit.c.

3073{
3074 LONG style;
3075
3076 if (es->style & ES_MULTILINE)
3077 return;
3078
3079 if (es->password_char == c)
3080 return;
3081
3082 style = GetWindowLongW( es->hwndSelf, GWL_STYLE );
3083 es->password_char = c;
3084 if (c) {
3085 SetWindowLongW( es->hwndSelf, GWL_STYLE, style | ES_PASSWORD );
3086 es->style |= ES_PASSWORD;
3087 } else {
3088 SetWindowLongW( es->hwndSelf, GWL_STYLE, style & ~ES_PASSWORD );
3089 es->style &= ~ES_PASSWORD;
3090 }
Arabic default style
Definition: afstyles.h:94
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
#define ES_PASSWORD
Definition: pedump.c:670
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define GWL_STYLE
Definition: winuser.h:863

◆ EDIT_EM_SetSel()

static void EDIT_EM_SetSel ( EDITSTATE es,
UINT  start,
UINT  end,
BOOL  after_wrap 
)
static

Definition at line 1646 of file edit.c.

1648{
1649 UINT old_start = es->selection_start;
1650 UINT old_end = es->selection_end;
1652
1653 if (start == (UINT)-1) {
1654 start = es->selection_end;
1655 end = es->selection_end;
1656 } else {
1657 start = min(start, len);
1658 end = min(end, len);
1659 }
1660 es->selection_start = start;
1661 es->selection_end = end;
1662 if (after_wrap)
1663 es->flags |= EF_AFTER_WRAP;
1664 else
1665 es->flags &= ~EF_AFTER_WRAP;
1666 /* Compute the necessary invalidation region. */
1667 /* Note that we don't need to invalidate regions which have
1668 * "never" been selected, or those which are "still" selected.
1669 * In fact, every time we hit a selection boundary, we can
1670 * *toggle* whether we need to invalidate. Thus we can optimize by
1671 * *sorting* the interval endpoints. Let's assume that we sort them
1672 * in this order:
1673 * start <= end <= old_start <= old_end
1674 * Knuth 5.3.1 (p 183) assures us that this can be done optimally
1675 * in 5 comparisons; i.e. it is impossible to do better than the
1676 * following: */
1677 ORDER_UINT(end, old_end);
1678 ORDER_UINT(start, old_start);
1679 ORDER_UINT(old_start, old_end);
1681 /* Note that at this point 'end' and 'old_start' are not in order, but
1682 * start is definitely the min. and old_end is definitely the max. */
1683 if (end != old_start)
1684 {
1685/*
1686 * One can also do
1687 * ORDER_UINT32(end, old_start);
1688 * EDIT_InvalidateText(es, start, end);
1689 * EDIT_InvalidateText(es, old_start, old_end);
1690 * in place of the following if statement.
1691 * (That would complete the optimal five-comparison four-element sort.)
1692 */
1693 if (old_start > end )
1694 {
1696 EDIT_InvalidateText(es, old_start, old_end);
1697 }
1698 else
1699 {
1700 EDIT_InvalidateText(es, start, old_start);
1701 EDIT_InvalidateText(es, end, old_end);
1702 }
1703 }
1704 else EDIT_InvalidateText(es, start, old_end);
static void EDIT_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1459

◆ EDIT_EM_SetTabStops()

static BOOL EDIT_EM_SetTabStops ( EDITSTATE es,
INT  count,
const INT tabs 
)
static

Definition at line 3100 of file edit.c.

3102{
3103 if (!(es->style & ES_MULTILINE))
3104 return FALSE;
3105 HeapFree(GetProcessHeap(), 0, es->tabs);
3106 es->tabs_count = count;
3107 if (!count)
3108 es->tabs = NULL;
3109 else {
3110 es->tabs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
3111#ifdef __REACTOS__
3112 /* ReactOS r33503 */
3113 if (es->tabs == NULL)
3114 {
3115 es->tabs_count = 0;
3116 return FALSE;
3117 }
3118#endif
3119 memcpy(es->tabs, tabs, count * sizeof(INT));
3120 }
3122 return TRUE;

◆ EDIT_EM_SetWordBreakProc()

static void EDIT_EM_SetWordBreakProc ( EDITSTATE es,
void wbp 
)
static

Definition at line 3130 of file edit.c.

3132{
3133 if (es->word_break_proc == wbp)
3134 return;
3135
3136 es->word_break_proc = wbp;
3137
3138 if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
3141 }

◆ EDIT_EM_Undo()

static BOOL EDIT_EM_Undo ( EDITSTATE es)
static

Definition at line 3149 of file edit.c.

3151{
3152 INT ulength;
3153 LPWSTR utext;
3154
3155 /* As per MSDN spec, for a single-line edit control,
3156 the return value is always TRUE */
3157 if( es->style & ES_READONLY )
3158 return !(es->style & ES_MULTILINE);
3159
3160 ulength = strlenW(es->undo_text);
3161
3162 utext = HeapAlloc(GetProcessHeap(), 0, (ulength + 1) * sizeof(WCHAR));
3163#ifdef __REACTOS__
3164 /* ReactOS r33503 */
3165 if (utext == NULL)
3166 return FALSE;
3167#endif
3168
3169 strcpyW(utext, es->undo_text);
3170
3171 TRACE("before UNDO:insertion length = %d, deletion buffer = %s\n",
3172 es->undo_insert_count, debugstr_w(utext));
3173
3174 EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
3176 EDIT_EM_ReplaceSel(es, TRUE, utext, TRUE, TRUE);
3177 EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
3178 /* send the notification after the selection start and end are set */
3179 if (!notify_parent(es, EN_CHANGE)) return TRUE;
3181 HeapFree(GetProcessHeap(), 0, utext);
3182
3183 TRACE("after UNDO:insertion length = %d, deletion buffer = %s\n",
3184 es->undo_insert_count, debugstr_w(es->undo_text));
3185 return TRUE;
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, const WCHAR *lpsz_replace, UINT strl, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2490
#define ES_READONLY
Definition: pedump.c:675

◆ EDIT_GetCompositionStr()

static void EDIT_GetCompositionStr ( HIMC  hIMC,
LPARAM  CompFlag,
EDITSTATE es 
)
static

Definition at line 4493 of file edit.c.

4495{
4496 LONG buflen;
4497 LPWSTR lpCompStr;
4498 LPSTR lpCompStrAttr = NULL;
4499 DWORD dwBufLenAttr;
4500
4501 buflen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
4502
4503 if (buflen < 0)
4504 {
4505 return;
4506 }
4507
4508 lpCompStr = HeapAlloc(GetProcessHeap(),0,buflen + sizeof(WCHAR));
4509 if (!lpCompStr)
4510 {
4511 ERR("Unable to allocate IME CompositionString\n");
4512 return;
4513 }
4514
4515 if (buflen)
4516 ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, buflen);
4517 lpCompStr[buflen/sizeof(WCHAR)] = 0;
4518
4519 if (CompFlag & GCS_COMPATTR)
4520 {
4521 /*
4522 * We do not use the attributes yet. it would tell us what characters
4523 * are in transition and which are converted or decided upon
4524 */
4525 dwBufLenAttr = ImmGetCompositionStringW(hIMC, GCS_COMPATTR, NULL, 0);
4526 if (dwBufLenAttr)
4527 {
4528 dwBufLenAttr ++;
4529 lpCompStrAttr = HeapAlloc(GetProcessHeap(),0,dwBufLenAttr+1);
4530 if (!lpCompStrAttr)
4531 {
4532 ERR("Unable to allocate IME Attribute String\n");
4533 HeapFree(GetProcessHeap(),0,lpCompStr);
4534 return;
4535 }
4536 ImmGetCompositionStringW(hIMC,GCS_COMPATTR, lpCompStrAttr,
4537 dwBufLenAttr);
4538 lpCompStrAttr[dwBufLenAttr] = 0;
4539 }
4540 }
4541
4542#ifndef __REACTOS__ /* We don't use internal composition string. Rely on the composition window */
4543 /* check for change in composition start */
4544 if (es->selection_end < es->composition_start)
4545 es->composition_start = es->selection_end;
4546
4547 /* replace existing selection string */
4548 es->selection_start = es->composition_start;
4549
4550 if (es->composition_len > 0)
4551 es->selection_end = es->composition_start + es->composition_len;
4552 else
4553 es->selection_end = es->selection_start;
4554
4555 EDIT_EM_ReplaceSel(es, FALSE, lpCompStr, TRUE, TRUE);
4556 es->composition_len = abs(es->composition_start - es->selection_end);
4557
4558 es->selection_start = es->composition_start;
4559 es->selection_end = es->selection_start + es->composition_len;
4560#endif
4561
4562 HeapFree(GetProcessHeap(),0,lpCompStrAttr);
4563 HeapFree(GetProcessHeap(),0,lpCompStr);
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GCS_COMPATTR
Definition: imm.h:228
#define GCS_COMPSTR
Definition: imm.h:227
LONG WINAPI ImmGetCompositionStringW(_In_ HIMC hIMC, _In_ DWORD dwIndex, _Out_writes_bytes_opt_(dwBufLen) LPVOID lpBuf, _In_ DWORD dwBufLen)
Definition: compstr.c:908

◆ EDIT_GetLineRect()

static void EDIT_GetLineRect ( EDITSTATE es,
INT  line,
INT  scol,
INT  ecol,
LPRECT  rc 
)
static

Definition at line 1239 of file edit.c.

1241{
1243 INT line_index = 0;
1244 INT pt1, pt2, pt3;
1245
1246 if (es->style & ES_MULTILINE)
1247 {
1248 const LINEDEF *line_def = NULL;
1249 rc->top = es->format_rect.top + (line - es->y_offset) * es->line_height;
1250 if (line >= es->line_count)
1251 return;
1252
1253 line_def = es->first_line_def;
1254 if (line == -1) {
1255 INT index = es->selection_end - line_def->length;
1256 while ((index >= 0) && line_def->next) {
1257 line_index += line_def->length;
1258 line_def = line_def->next;
1259 index -= line_def->length;
1260 }
1261 } else {
1262 while (line > 0) {
1263 line_index += line_def->length;
1264 line_def = line_def->next;
1265 line--;
1266 }
1267 }
1268 ssa = line_def->ssa;
1269 }
1270 else
1271 {
1272 line_index = 0;
1273 rc->top = es->format_rect.top;
1274 ssa = es->ssa;
1275 }
1276
1277 rc->bottom = rc->top + es->line_height;
1278 pt1 = (scol == 0) ? es->format_rect.left : (short)LOWORD(EDIT_EM_PosFromChar(es, line_index + scol, TRUE));
1279 pt2 = (ecol == -1) ? es->format_rect.right : (short)LOWORD(EDIT_EM_PosFromChar(es, line_index + ecol, TRUE));
1280 if (ssa)
1281 {
1282 ScriptStringCPtoX(ssa, scol, FALSE, &pt3);
1283 pt3+=es->format_rect.left;
1284 }
1285 else pt3 = pt1;
1286 rc->right = max(max(pt1 , pt2),pt3);
1287 rc->left = min(min(pt1, pt2),pt3);

◆ EDIT_GetResultStr()

static void EDIT_GetResultStr ( HIMC  hIMC,
EDITSTATE es 
)
static

Definition at line 4565 of file edit.c.

4567{
4568 LONG buflen;
4569 LPWSTR lpResultStr;
4570
4571 buflen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
4572 if (buflen <= 0)
4573 {
4574 return;
4575 }
4576
4577 lpResultStr = HeapAlloc(GetProcessHeap(),0, buflen+sizeof(WCHAR));
4578 if (!lpResultStr)
4579 {
4580 ERR("Unable to alloc buffer for IME string\n");
4581 return;
4582 }
4583
4584 ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpResultStr, buflen);
4585 lpResultStr[buflen/sizeof(WCHAR)] = 0;
4586
4587#ifndef __REACTOS__
4588 /* check for change in composition start */
4589 if (es->selection_end < es->composition_start)
4590 es->composition_start = es->selection_end;
4591
4592 es->selection_start = es->composition_start;
4593 es->selection_end = es->composition_start + es->composition_len;
4594 EDIT_EM_ReplaceSel(es, TRUE, lpResultStr, TRUE, TRUE);
4595 es->composition_start = es->selection_end;
4596 es->composition_len = 0;
4597#endif
4598
4599 HeapFree(GetProcessHeap(),0,lpResultStr);
#define GCS_RESULTSTR
Definition: imm.h:234

◆ EDIT_ImeComposition()

static void EDIT_ImeComposition ( HWND  hwnd,
LPARAM  CompFlag,
EDITSTATE es 
)
static

Definition at line 4601 of file edit.c.

4603{
4604 HIMC hIMC;
4605 int cursor;
4606
4607#ifdef __REACTOS__
4608 if (es->selection_start != es->selection_end)
4610#else
4611 if (es->composition_len == 0 && es->selection_start != es->selection_end)
4612 {
4614 es->composition_start = es->selection_end;
4615 }
4616#endif
4617
4618 hIMC = ImmGetContext(hwnd);
4619 if (!hIMC)
4620 return;
4621
4622 if (CompFlag & GCS_RESULTSTR)
4623 {
4624 EDIT_GetResultStr(hIMC, es);
4625 cursor = 0;
4626 }
4627 else
4628 {
4629 if (CompFlag & GCS_COMPSTR)
4630 EDIT_GetCompositionStr(hIMC, CompFlag, es);
4631#ifdef __REACTOS__
4632 cursor = 0;
4633#else
4635#endif
4636 }
4637 ImmReleaseContext(hwnd, hIMC);
4638 EDIT_SetCaretPos(es, es->selection_start + cursor, es->flags & EF_AFTER_WRAP);
DWORD HIMC
Definition: dimm.idl:75
static void EDIT_GetResultStr(HIMC hIMC, EDITSTATE *es)
Definition: edit.c:4446
static void EDIT_GetCompositionStr(HIMC hIMC, LPARAM CompFlag, EDITSTATE *es)
Definition: edit.c:4375
const char cursor[]
Definition: icontest.c:13
HIMC WINAPI ImmGetContext(_In_ HWND hWnd)
Definition: imm.c:1065
BOOL WINAPI ImmReleaseContext(_In_ HWND hWnd, _In_ HIMC hIMC)
Definition: imm.c:1109
#define GCS_CURSORPOS
Definition: imm.h:230
static const WCHAR empty_stringW[]
Definition: edit.c:173

◆ EDIT_InvalidateText()

static void EDIT_InvalidateText ( EDITSTATE es,
INT  start,
INT  end 
)
static

Definition at line 1616 of file edit.c.

1618{
1619 if (end == start)
1620 return;
1621
1622 if (end == -1)
1624
1625 if (end < start) {
1626 INT tmp = start;
1627 start = end;
1628 end = tmp;
1629 }
1630
1631 if (es->style & ES_MULTILINE)
1633 else
static void EDIT_ML_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1394
static void EDIT_SL_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1376

◆ EDIT_InvalidateUniscribeData()

static void EDIT_InvalidateUniscribeData ( EDITSTATE es)
inlinestatic

Definition at line 391 of file edit.c.

393{
394 LINEDEF *line_def = es->first_line_def;
395 while (line_def)
396 {
398 line_def = line_def->next;
399 }
400 if (es->ssa)
401 {
402 ScriptStringFree(&es->ssa);
403 es->ssa = NULL;
404 }
HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:2577

◆ EDIT_InvalidateUniscribeData_linedef()

static void EDIT_InvalidateUniscribeData_linedef ( LINEDEF line_def)
inlinestatic

Definition at line 382 of file edit.c.

384{
385 if (line_def->ssa)
386 {
387 ScriptStringFree(&line_def->ssa);
388 line_def->ssa = NULL;
389 }

◆ EDIT_IsInsideDialog()

static BOOL EDIT_IsInsideDialog ( EDITSTATE es)
inlinestatic

Definition at line 3195 of file edit.c.

3197{
3198 return (es->flags & EF_DIALOGMODE);
#define EF_DIALOGMODE
Definition: edit.c:72

◆ EDIT_LockBuffer()

static void EDIT_LockBuffer ( EDITSTATE es)
static

Definition at line 1303 of file edit.c.

1305{
1306 if (!es->text) {
1307
1308#ifdef __REACTOS__
1309/* FIXME: What is this ? */
1310 CHAR *textA = NULL; // ReactOS Hacked! r45670
1311 //UINT countA = 0;
1312
1313 if(es->hloc32W)
1314 {
1315 if(es->hloc32A)
1316 {
1317 TRACE("Synchronizing with 32-bit ANSI buffer\n");
1318 textA = LocalLock(es->hloc32A);
1319 //countA = strlen(textA) + 1;
1320 }
1321 }
1322 else {
1323 ERR("no buffer ... please report\n");
1324 return;
1325 }
1326
1327 if (textA)
1328 {
1329#else
1330 if(!es->hloc32W) return;
1331
1332 if(es->hloc32A)
1333 {
1334 CHAR *textA = LocalLock(es->hloc32A);
1335#endif
1336 HLOCAL hloc32W_new;
1337 UINT countW_new = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
1338 if(countW_new > es->buffer_size + 1)
1339 {
1340 UINT alloc_size = ROUND_TO_GROW(countW_new * sizeof(WCHAR));
1341 TRACE("Resizing 32-bit UNICODE buffer from %d+1 to %d WCHARs\n", es->buffer_size, countW_new);
1342 hloc32W_new = LocalReAlloc(es->hloc32W, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT);
1343 if(hloc32W_new)
1344 {
1345 es->hloc32W = hloc32W_new;
1346 es->buffer_size = LocalSize(hloc32W_new)/sizeof(WCHAR) - 1;
1347 TRACE("Real new size %d+1 WCHARs\n", es->buffer_size);
1348 }
1349 else
1350 WARN("FAILED! Will synchronize partially\n");
1351 }
1352 es->text = LocalLock(es->hloc32W);
1353 MultiByteToWideChar(CP_ACP, 0, textA, -1, es->text, es->buffer_size + 1);
1354 LocalUnlock(es->hloc32A);
1355 }
1356 else es->text = LocalLock(es->hloc32W);
1357 }
1358 es->lock_count++;
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1625

◆ EDIT_MakeFit()

static BOOL EDIT_MakeFit ( EDITSTATE es,
UINT  size 
)
static

Definition at line 1433 of file edit.c.

1435{
1436 HLOCAL hNew32W;
1437
1438 if (size <= es->buffer_size)
1439 return TRUE;
1440
1441 TRACE("trying to ReAlloc to %d+1 characters\n", size);
1442
1443 /* Force edit to unlock its buffer. es->text now NULL */
1445
1446 if (es->hloc32W) {
1447 UINT alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1448 if ((hNew32W = LocalReAlloc(es->hloc32W, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT))) {
1449 TRACE("Old 32 bit handle %p, new handle %p\n", es->hloc32W, hNew32W);
1450 es->hloc32W = hNew32W;
1451 es->buffer_size = LocalSize(hNew32W)/sizeof(WCHAR) - 1;
1452 }
1453 }
1454
1456
1457 if (es->buffer_size < size) {
1458 WARN("FAILED ! We now have %d+1\n", es->buffer_size);
1460 return FALSE;
1461 } else {
1462 TRACE("We now have %d+1\n", es->buffer_size);
1463 return TRUE;
1464 }
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
#define EN_ERRSPACE
Definition: winuser.h:2042

◆ EDIT_MakeUndoFit()

static BOOL EDIT_MakeUndoFit ( EDITSTATE es,
UINT  size 
)
static

Definition at line 1474 of file edit.c.

1476{
1477 UINT alloc_size;
1478
1479 if (size <= es->undo_buffer_size)
1480 return TRUE;
1481
1482 TRACE("trying to ReAlloc to %d+1\n", size);
1483
1484 alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1485 if ((es->undo_text = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, es->undo_text, alloc_size))) {
1486 es->undo_buffer_size = alloc_size/sizeof(WCHAR) - 1;
1487 return TRUE;
1488 }
1489 else
1490 {
1491 WARN("FAILED ! We now have %d+1\n", es->undo_buffer_size);
1492 return FALSE;
1493 }
#define HeapReAlloc
Definition: compat.h:734

◆ EDIT_ML_InvalidateText()

static void EDIT_ML_InvalidateText ( EDITSTATE es,
INT  start,
INT  end 
)
static

Definition at line 1551 of file edit.c.

1553{
1557 INT sc;
1558 INT ec;
1559 RECT rc1;
1560 RECT rcWnd;
1561 RECT rcLine;
1562 RECT rcUpdate;
1563 INT l;
1564
1565 if ((el < es->y_offset) || (sl > es->y_offset + vlc))
1566 return;
1567
1568 sc = start - EDIT_EM_LineIndex(es, sl);
1569 ec = end - EDIT_EM_LineIndex(es, el);
1570 if (sl < es->y_offset) {
1571 sl = es->y_offset;
1572 sc = 0;
1573 }
1574 if (el > es->y_offset + vlc) {
1575 el = es->y_offset + vlc;
1577 }
1578 GetClientRect(es->hwndSelf, &rc1);
1579 IntersectRect(&rcWnd, &rc1, &es->format_rect);
1580 if (sl == el) {
1581 EDIT_GetLineRect(es, sl, sc, ec, &rcLine);
1582 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1583 EDIT_UpdateText(es, &rcUpdate, TRUE);
1584 } else {
1585 EDIT_GetLineRect(es, sl, sc,
1587 EDIT_EM_LineIndex(es, sl)),
1588 &rcLine);
1589 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1590 EDIT_UpdateText(es, &rcUpdate, TRUE);
1591 for (l = sl + 1 ; l < el ; l++) {
1592 EDIT_GetLineRect(es, l, 0,
1595 &rcLine);
1596 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1597 EDIT_UpdateText(es, &rcUpdate, TRUE);
1598 }
1599 EDIT_GetLineRect(es, el, 0, ec, &rcLine);
1600 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1601 EDIT_UpdateText(es, &rcUpdate, TRUE);
1602 }
static void EDIT_GetLineRect(EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc)
Definition: edit.c:1147

◆ EDIT_MoveBackward()

static void EDIT_MoveBackward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2000 of file edit.c.

2002{
2003 INT e = es->selection_end;
2004
2005 if (e) {
2006 e--;
2007 if ((es->style & ES_MULTILINE) && e &&
2008 (es->text[e - 1] == '\r') && (es->text[e] == '\n')) {
2009 e--;
2010 if (e && (es->text[e - 1] == '\r'))
2011 e--;
2012 }
2013 }
2014 EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);

◆ EDIT_MoveDown_ML()

static void EDIT_MoveDown_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2027 of file edit.c.

2029{
2030 INT s = es->selection_start;
2031 INT e = es->selection_end;
2032 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2033 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2034 INT x = (short)LOWORD(pos);
2035 INT y = (short)HIWORD(pos);
2036
2037 e = EDIT_CharFromPos(es, x, y + es->line_height, &after_wrap);
2038 if (!extend)
2039 s = e;
2040 EDIT_EM_SetSel(es, s, e, after_wrap);
#define HIWORD(l)
Definition: typedefs.h:247

◆ EDIT_MoveEnd()

static void EDIT_MoveEnd ( EDITSTATE es,
BOOL  extend,
BOOL  ctrl 
)
static

Definition at line 2049 of file edit.c.

2051{
2052 BOOL after_wrap = FALSE;
2053 INT e;
2054
2055 /* Pass a high value in x to make sure of receiving the end of the line */
2056 if (!ctrl && (es->style & ES_MULTILINE))
2057 e = EDIT_CharFromPos(es, 0x3fffffff,
2058 HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap);
2059 else
2060 e = get_text_length(es);
2061 EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, after_wrap);
#define ctrl
Definition: input.c:1756

◆ EDIT_MoveForward()

static void EDIT_MoveForward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2070 of file edit.c.

2072{
2073 INT e = es->selection_end;
2074
2075 if (es->text[e]) {
2076 e++;
2077 if ((es->style & ES_MULTILINE) && (es->text[e - 1] == '\r')) {
2078 if (es->text[e] == '\n')
2079 e++;
2080 else if ((es->text[e] == '\r') && (es->text[e + 1] == '\n'))
2081 e += 2;
2082 }
2083 }
2084 EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);

◆ EDIT_MoveHome()

static void EDIT_MoveHome ( EDITSTATE es,
BOOL  extend,
BOOL  ctrl 
)
static

Definition at line 2095 of file edit.c.

2097{
2098 INT e;
2099
2100 /* Pass the x_offset in x to make sure of receiving the first position of the line */
2101 if (!ctrl && (es->style & ES_MULTILINE))
2102 e = EDIT_CharFromPos(es, -es->x_offset,
2103 HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL);
2104 else
2105 e = 0;
2106 EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);

◆ EDIT_MovePageDown_ML()

static void EDIT_MovePageDown_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2119 of file edit.c.

2121{
2122 INT s = es->selection_start;
2123 INT e = es->selection_end;
2124 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2125 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2126 INT x = (short)LOWORD(pos);
2127 INT y = (short)HIWORD(pos);
2128
2130 y + (es->format_rect.bottom - es->format_rect.top),
2131 &after_wrap);
2132 if (!extend)
2133 s = e;
2134 EDIT_EM_SetSel(es, s, e, after_wrap);

◆ EDIT_MovePageUp_ML()

static void EDIT_MovePageUp_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2147 of file edit.c.

2149{
2150 INT s = es->selection_start;
2151 INT e = es->selection_end;
2152 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2153 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2154 INT x = (short)LOWORD(pos);
2155 INT y = (short)HIWORD(pos);
2156
2158 y - (es->format_rect.bottom - es->format_rect.top),
2159 &after_wrap);
2160 if (!extend)
2161 s = e;
2162 EDIT_EM_SetSel(es, s, e, after_wrap);

◆ EDIT_MoveUp_ML()

static void EDIT_MoveUp_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2175 of file edit.c.

2177{
2178 INT s = es->selection_start;
2179 INT e = es->selection_end;
2180 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2181 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2182 INT x = (short)LOWORD(pos);
2183 INT y = (short)HIWORD(pos);
2184
2185 e = EDIT_CharFromPos(es, x, y - es->line_height, &after_wrap);
2186 if (!extend)
2187 s = e;
2188 EDIT_EM_SetSel(es, s, e, after_wrap);

◆ EDIT_MoveWordBackward()

static void EDIT_MoveWordBackward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2197 of file edit.c.

2199{
2200 INT s = es->selection_start;
2201 INT e = es->selection_end;
2202 INT l;
2203 INT ll;
2204 INT li;
2205
2209 if (e - li == 0) {
2210 if (l) {
2211 li = EDIT_EM_LineIndex(es, l - 1);
2212 e = li + EDIT_EM_LineLength(es, li);
2213 }
2214 } else {
2216 }
2217 if (!extend)
2218 s = e;
w ll
Definition: byte_order.h:167

◆ EDIT_MoveWordForward()

static void EDIT_MoveWordForward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2228 of file edit.c.

2230{
2231 INT s = es->selection_start;
2232 INT e = es->selection_end;
2233 INT l;
2234 INT ll;
2235 INT li;
2236
2240 if (e - li == ll) {
2241 if ((es->style & ES_MULTILINE) && (l != es->line_count - 1))
2242 e = EDIT_EM_LineIndex(es, l + 1);
2243 } else {
2245 li, e - li + 1, ll, WB_RIGHT);
2246 }
2247 if (!extend)
2248 s = e;
#define WB_RIGHT
Definition: winuser.h:551

◆ EDIT_NotifyCtlColor()

static HBRUSH EDIT_NotifyCtlColor ( EDITSTATE es,
HDC  hdc 
)
static

Definition at line 242 of file edit.c.

244{
245 HBRUSH hbrush;
246 UINT msg;
247
248 if ( get_app_version() >= 0x40000 && (!es->bEnableState || (es->style & ES_READONLY)))
250 else
252
253 /* why do we notify to es->hwndParent, and we send this one to GetParent()? */
254#ifdef __REACTOS__
255 /* ReactOS r54259 */
256 hbrush = GetControlBrush(es->hwndSelf, hdc, msg);
257#else
258 hbrush = (HBRUSH)SendMessageW(GetParent(es->hwndSelf), msg, (WPARAM)hdc, (LPARAM)es->hwndSelf);
259 if (!hbrush)
260 hbrush = (HBRUSH)DefWindowProcW(GetParent(es->hwndSelf), msg, (WPARAM)hdc, (LPARAM)es->hwndSelf);
261#endif
262 return hbrush;
static HBRUSH hbrush
HDC hdc
Definition: main.c:9
HBRUSH FASTCALL GetControlBrush(PWND pwnd, HDC hdc, UINT ctlType)
Definition: misc.c:180
static DWORD get_app_version(void)
Definition: edit.c:223
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1791
#define WM_CTLCOLOREDIT
Definition: winuser.h:1786

◆ EDIT_PaintLine()

static void EDIT_PaintLine ( EDITSTATE es,
HDC  dc,
INT  line,
BOOL  rev 
)
static

Definition at line 2332 of file edit.c.

2334{
2335 INT s = 0;
2336 INT e = 0;
2337 INT li = 0;
2338 INT ll = 0;
2339 INT x;
2340 INT y;
2341 LRESULT pos;
2343
2344 if (es->style & ES_MULTILINE) {
2346
2347 if ((line < es->y_offset) || (line > es->y_offset + vlc) || (line >= es->line_count))
2348 return;
2349 } else if (line)
2350 return;
2351
2352 TRACE("line=%d\n", line);
2353
2356 x = (short)LOWORD(pos);
2357 y = (short)HIWORD(pos);
2358
2359 if (es->style & ES_MULTILINE)
2360 {
2361 int line_idx = line;
2362 x = -es->x_offset;
2363 if (es->style & ES_RIGHT || es->style & ES_CENTER)
2364 {
2365 LINEDEF *line_def = es->first_line_def;
2366 int w, lw;
2367
2368 while (line_def && line_idx)
2369 {
2370 line_def = line_def->next;
2371 line_idx--;
2372 }
2373 w = es->format_rect.right - es->format_rect.left;
2374 lw = line_def->width;
2375
2376 if (es->style & ES_RIGHT)
2377 x = w - (lw - x);
2378 else if (es->style & ES_CENTER)
2379 x += (w - lw) / 2;
2380 }
2381 x += es->format_rect.left;
2382 }
2383
2384 if (rev)
2385 {
2388 s = min(es->selection_start, es->selection_end);
2389 e = max(es->selection_start, es->selection_end);
2390 s = min(li + ll, max(li, s));
2391 e = min(li + ll, max(li, e));
2392 }
2393
2394 if (ssa)
2395 ScriptStringOut(ssa, x, y, 0, &es->format_rect, s - li, e - li, FALSE);
2396 else if (rev && (s != e) &&
2397 ((es->flags & EF_FOCUSED) || (es->style & ES_NOHIDESEL))) {
2398 x += EDIT_PaintText(es, dc, x, y, line, 0, s - li, FALSE);
2399 x += EDIT_PaintText(es, dc, x, y, line, s - li, e - s, TRUE);
2400 x += EDIT_PaintText(es, dc, x, y, line, e - li, li + ll - e, FALSE);
2401 } else
2402 x += EDIT_PaintText(es, dc, x, y, line, 0, ll, FALSE);
int rev
Definition: sort.c:17
static INT EDIT_PaintText(EDITSTATE *es, HDC dc, INT x, INT y, INT line, INT col, INT count, BOOL rev)
Definition: edit.c:2105
HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa, int iX, int iY, UINT uOptions, const RECT *prc, int iMinSel, int iMaxSel, BOOL fDisabled)
Definition: usp10.c:2387
#define ES_NOHIDESEL
Definition: pedump.c:673

◆ EDIT_PaintText()

static INT EDIT_PaintText ( EDITSTATE es,
HDC  dc,
INT  x,
INT  y,
INT  line,
INT  col,
INT  count,
BOOL  rev 
)
static

Definition at line 2258 of file edit.c.

2260{
2261 COLORREF BkColor;
2262 COLORREF TextColor;
2263 LOGFONTW underline_font;
2264 HFONT hUnderline = 0;
2265 HFONT old_font = 0;
2266 INT ret;
2267 INT li;
2268 INT BkMode;
2269 SIZE size;
2270
2271 if (!count)
2272 return 0;
2273 BkMode = GetBkMode(dc);
2274 BkColor = GetBkColor(dc);
2275 TextColor = GetTextColor(dc);
2276 if (rev) {
2277#ifdef __REACTOS__
2278 if (TRUE)
2279#else
2280 if (es->composition_len == 0)
2281#endif
2282 {
2285 SetBkMode( dc, OPAQUE);
2286 }
2287 else
2288 {
2290 GetObjectW(current,sizeof(LOGFONTW),&underline_font);
2291 underline_font.lfUnderline = TRUE;
2292 hUnderline = CreateFontIndirectW(&underline_font);
2293 old_font = SelectObject(dc,hUnderline);
2294 }
2295 }
2297 if (es->style & ES_MULTILINE) {
2298 ret = (INT)LOWORD(TabbedTextOutW(dc, x, y, es->text + li + col, count,
2299 es->tabs_count, es->tabs, es->format_rect.left - es->x_offset));
2300 } else {
2301 TextOutW(dc, x, y, es->text + li + col, count);
2302 GetTextExtentPoint32W(dc, es->text + li + col, count, &size);
2303 ret = size.cx;
2304 }
2305 if (rev) {
2306#ifdef __REACTOS__
2307 if (TRUE)
2308#else
2309 if (es->composition_len == 0)
2310#endif
2311 {
2312 SetBkColor(dc, BkColor);
2313 SetTextColor(dc, TextColor);
2314 SetBkMode( dc, BkMode);
2315 }
2316 else
2317 {
2318 if (old_font)
2319 SelectObject(dc,old_font);
2320 if (hUnderline)
2321 DeleteObject(hUnderline);
2322 }
2323 }
2324 return ret;
struct task_struct * current
Definition: linux.c:32
#define OBJ_FONT
Definition: objidl.idl:1414
#define INT
Definition: polytest.cpp:20
BYTE lfUnderline
Definition: dimm.idl:65
DWORD COLORREF
Definition: windef.h:300
int WINAPI GetBkMode(_In_ HDC)
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
COLORREF WINAPI GetTextColor(_In_ HDC)
Definition: text.c:860
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428
COLORREF WINAPI GetBkColor(_In_ HDC)
Definition: dc.c:978
#define OPAQUE
Definition: wingdi.h:949
BOOL WINAPI TextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCWSTR lpString, _In_ int c)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:938
LONG WINAPI TabbedTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(chCount) LPCWSTR lpString, _In_ int chCount, _In_ int nTabPositions, _In_reads_opt_(nTabPositions) CONST INT *lpnTabStopPositions, _In_ int nTabOrigin)

◆ EDIT_SetCaretPos()

static void EDIT_SetCaretPos ( EDITSTATE es,
INT  pos,
BOOL  after_wrap 
)
static

Definition at line 1902 of file edit.c.

1905{
1906 LRESULT res = EDIT_EM_PosFromChar(es, pos, after_wrap);
1907#ifdef __REACTOS__
1908 HKL hKL = GetKeyboardLayout(0);
1909 POINT pt = { (short)LOWORD(res), (short)HIWORD(res) };
1910
1911 /* Don't set caret if not focused */
1912 if ((es->flags & EF_FOCUSED) == 0)
1913 return;
1914
1915 SetCaretPos(pt.x, pt.y);
1916
1917 if (IS_IME_HKL(hKL))
1918 EDIT_ImmSetCompositionWindow(es, pt);
1919#else
1920 TRACE("%d - %dx%d\n", pos, (short)LOWORD(res), (short)HIWORD(res));
1921 SetCaretPos((short)LOWORD(res), (short)HIWORD(res));
1922#endif
GLuint res
Definition: glext.h:9613
#define IS_IME_HKL(hKL)
Definition: imm32_undoc.h:21
UINT_PTR HKL
Definition: msctf.idl:125
HKL WINAPI GetKeyboardLayout(_In_ DWORD)
BOOL WINAPI SetCaretPos(_In_ int, _In_ int)

◆ EDIT_SetRectNP()

static void EDIT_SetRectNP ( EDITSTATE es,
const RECT rc 
)
static

Definition at line 2464 of file edit.c.

2466{
2468 INT bw, bh;
2470
2471 CopyRect(&es->format_rect, rc);
2472
2473 if (ExStyle & WS_EX_CLIENTEDGE) {
2474 es->format_rect.left++;
2475 es->format_rect.right--;
2476
2477 if (es->format_rect.bottom - es->format_rect.top
2478 >= es->line_height + 2)
2479 {
2480 es->format_rect.top++;
2481 es->format_rect.bottom--;
2482 }
2483 }
2484 else if (es->style & WS_BORDER) {
2486 bh = GetSystemMetrics(SM_CYBORDER) + 1;
2487 es->format_rect.left += bw;
2488 es->format_rect.right -= bw;
2489 if (es->format_rect.bottom - es->format_rect.top
2490 >= es->line_height + 2 * bh)
2491 {
2492 es->format_rect.top += bh;
2493 es->format_rect.bottom -= bh;
2494 }
2495 }
2496
2497 es->format_rect.left += es->left_margin;
2498 es->format_rect.right -= es->right_margin;
static int bw
Definition: maze.c:120
const DWORD ExStyle
Definition: appswitch.c:73
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_BORDER
Definition: pedump.c:625
BOOL WINAPI CopyRect(_Out_ LPRECT, _In_ LPCRECT)
#define GetWindowLongPtrW
Definition: winuser.h:4905
#define SM_CYBORDER
Definition: winuser.h:976
#define SM_CXBORDER
Definition: winuser.h:975
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
int WINAPI GetSystemMetrics(_In_ int)
#define GWL_EXSTYLE
Definition: winuser.h:862

◆ EDIT_SL_InvalidateText()

static void EDIT_SL_InvalidateText ( EDITSTATE es,
INT  start,
INT  end 
)
static

Definition at line 1533 of file edit.c.

1535{
1536 RECT line_rect;
1537 RECT rc;
1538
1539 EDIT_GetLineRect(es, 0, start, end, &line_rect);
1540 if (IntersectRect(&rc, &line_rect, &es->format_rect))
1541 EDIT_UpdateText(es, &rc, TRUE);

◆ EDIT_UnlockBuffer()

static void EDIT_UnlockBuffer ( EDITSTATE es,
BOOL  force 
)
static

Definition at line 1366 of file edit.c.

1368{
1369 /* Edit window might be already destroyed */
1370 if(!IsWindow(es->hwndSelf))
1371 {
1372 WARN("edit hwnd %p already destroyed\n", es->hwndSelf);
1373 return;
1374 }
1375
1376 if (!es->lock_count) {
1377 ERR("lock_count == 0 ... please report\n");
1378 return;
1379 }
1380 if (!es->text) {
1381 ERR("es->text == 0 ... please report\n");
1382 return;
1383 }
1384
1385 if (force || (es->lock_count == 1)) {
1386 if (es->hloc32W) {
1387 UINT countA = 0;
1388 UINT countW = get_text_length(es) + 1;
1389
1390 if(es->hloc32A)
1391 {
1392 UINT countA_new = WideCharToMultiByte(CP_ACP, 0, es->text, countW, NULL, 0, NULL, NULL);
1393 TRACE("Synchronizing with 32-bit ANSI buffer\n");
1394 TRACE("%d WCHARs translated to %d bytes\n", countW, countA_new);
1395 countA = LocalSize(es->hloc32A);
1396 if(countA_new > countA)
1397 {
1398 HLOCAL hloc32A_new;
1399 UINT alloc_size = ROUND_TO_GROW(countA_new);
1400 TRACE("Resizing 32-bit ANSI buffer from %d to %d bytes\n", countA, alloc_size);
1401 hloc32A_new = LocalReAlloc(es->hloc32A, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT);
1402 if(hloc32A_new)
1403 {
1404 es->hloc32A = hloc32A_new;
1405 countA = LocalSize(hloc32A_new);
1406 TRACE("Real new size %d bytes\n", countA);
1407 }
1408 else
1409 WARN("FAILED! Will synchronize partially\n");
1410 }
1411 WideCharToMultiByte(CP_ACP, 0, es->text, countW,
1412 LocalLock(es->hloc32A), countA, NULL, NULL);
1413 LocalUnlock(es->hloc32A);
1414 }
1415
1416 LocalUnlock(es->hloc32W);
1417 es->text = NULL;
1418 }
1419 else {
1420 ERR("no buffer ... please report\n");
1421 return;
1422 }
1423 }
1424 es->lock_count--;
BOOL WINAPI IsWindow(_In_opt_ HWND)

◆ EDIT_UpdateScrollInfo()

static void EDIT_UpdateScrollInfo ( EDITSTATE es)
static

Definition at line 1712 of file edit.c.

1714{
1715 if ((es->style & WS_VSCROLL) && !(es->flags & EF_VSCROLL_TRACK))
1716 {
1717 SCROLLINFO si;
1718 si.cbSize = sizeof(SCROLLINFO);
1720 si.nMin = 0;
1721 si.nMax = es->line_count - 1;
1722 si.nPage = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
1723 si.nPos = es->y_offset;
1724 TRACE("SB_VERT, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n",
1725 si.nMin, si.nMax, si.nPage, si.nPos);
1726 SetScrollInfo(es->hwndSelf, SB_VERT, &si, TRUE);
1727 }
1728
1729 if ((es->style & WS_HSCROLL) && !(es->flags & EF_HSCROLL_TRACK))
1730 {
1731 SCROLLINFO si;
1732 si.cbSize = sizeof(SCROLLINFO);
1734 si.nMin = 0;
1735 si.nMax = es->text_width - 1;
1736 si.nPage = es->format_rect.right - es->format_rect.left;
1737 si.nPos = es->x_offset;
1738 TRACE("SB_HORZ, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n",
1739 si.nMin, si.nMax, si.nPage, si.nPos);
1740 SetScrollInfo(es->hwndSelf, SB_HORZ, &si, TRUE);
1741 }
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
struct tagSCROLLINFO SCROLLINFO
#define SIF_RANGE
Definition: winuser.h:1246
#define SB_VERT
Definition: winuser.h:553
#define SIF_PAGE
Definition: winuser.h:1244
#define SIF_DISABLENOSCROLL
Definition: winuser.h:1247
#define SIF_POS
Definition: winuser.h:1245
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
#define SB_HORZ
Definition: winuser.h:552

◆ EDIT_UpdateText()

static void EDIT_UpdateText ( EDITSTATE es,
const RECT rc,
BOOL  bErase 
)
static

Definition at line 1516 of file edit.c.

1518{
1519 if (es->flags & EF_UPDATE) {
1520 es->flags &= ~EF_UPDATE;
1521 if (!notify_parent(es, EN_UPDATE)) return;
1522 }
1523 InvalidateRect(es->hwndSelf, rc, bErase);
#define EN_UPDATE
Definition: winuser.h:2047
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

◆ EDIT_UpdateTextRegion()

static void EDIT_UpdateTextRegion ( EDITSTATE es,
HRGN  hrgn,
BOOL  bErase 
)
static

Definition at line 1501 of file edit.c.

1503{
1504 if (es->flags & EF_UPDATE) {
1505 es->flags &= ~EF_UPDATE;
1506 if (!notify_parent(es, EN_UPDATE)) return;
1507 }
1508 InvalidateRgn(es->hwndSelf, hrgn, bErase);
BOOL WINAPI InvalidateRgn(_In_ HWND, _In_opt_ HRGN, _In_ BOOL)

◆ EDIT_UpdateUniscribeData()

static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData ( EDITSTATE es,
HDC  dc,
INT  line 
)
static

Definition at line 453 of file edit.c.

455{
456 LINEDEF *line_def;
457
458 if (!(es->style & ES_MULTILINE))
459 {
460 if (!es->ssa)
461 {
463 HFONT old_font = NULL;
464 HDC udc = dc;
465
466 if (!udc)
467 udc = GetDC(es->hwndSelf);
468 if (es->font)
469 old_font = SelectObject(udc, es->font);
470
471 if (es->style & ES_PASSWORD)
472#ifdef __REACTOS__
473 /* ReactOS r57677 */
474 ScriptStringAnalyse(udc, &es->password_char, length, (3*length/2+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS|SSA_PASSWORD, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
475#else
476 ScriptStringAnalyse(udc, &es->password_char, length, (1.5*length+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS|SSA_PASSWORD, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
477#endif
478 else
479#ifdef __REACTOS__
480 /* ReactOS r57677 */
481 ScriptStringAnalyse(udc, es->text, length, (3*length/2+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
482#else
483 ScriptStringAnalyse(udc, es->text, length, (1.5*length+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
484#endif
485
486 if (es->font)
487 SelectObject(udc, old_font);
488 if (udc != dc)
489 ReleaseDC(es->hwndSelf, udc);
490 }
491 return es->ssa;
492 }
493 else
494 {
495 line_def = es->first_line_def;
496 while (line_def && line)
497 {
498 line_def = line_def->next;
499 line--;
500 }
501
502 return EDIT_UpdateUniscribeData_linedef(es,dc,line_def);
503 }
HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString, int cGlyphs, int iCharset, DWORD dwFlags, int iReqWidth, SCRIPT_CONTROL *psControl, SCRIPT_STATE *psState, const int *piDx, SCRIPT_TABDEF *pTabdef, const BYTE *pbInClass, SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:1985
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define SSA_FALLBACK
Definition: usp10.h:38
#define SSA_LINK
Definition: usp10.h:45
#define SSA_PASSWORD
Definition: usp10.h:33
#define SSA_GLYPHS
Definition: usp10.h:40

◆ EDIT_UpdateUniscribeData_linedef()

static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData_linedef ( EDITSTATE es,
HDC  dc,
LINEDEF line_def 
)
static

Definition at line 406 of file edit.c.

408{
409 if (!line_def)
410 return NULL;
411
412 if (line_def->net_length && !line_def->ssa)
413 {
414 int index = line_def->index;
415 HFONT old_font = NULL;
416 HDC udc = dc;
417 SCRIPT_TABDEF tabdef;
418 HRESULT hr;
419
420 if (!udc)
421 udc = GetDC(es->hwndSelf);
422 if (es->font)
423 old_font = SelectObject(udc, es->font);
424
425 tabdef.cTabStops = es->tabs_count;
426 tabdef.iScale = 0;
427 tabdef.pTabStops = es->tabs;
428 tabdef.iTabOrigin = 0;
429
430 hr = ScriptStringAnalyse(udc, &es->text[index], line_def->net_length,
431#ifdef __REACTOS__
432 /* ReactOS r57679 */
433 (3*line_def->net_length/2+16), -1,
434#else
435 (1.5*line_def->net_length+16), -1,
436#endif
438 NULL, NULL, NULL, &tabdef, NULL, &line_def->ssa);
439 if (FAILED(hr))
440 {
441 WARN("ScriptStringAnalyse failed (%x)\n",hr);
442 line_def->ssa = NULL;
443 }
444
445 if (es->font)
446 SelectObject(udc, old_font);
447 if (udc != dc)
448 ReleaseDC(es->hwndSelf, udc);
449 }
450
451 return line_def->ssa;
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
int * pTabStops
Definition: usp10.h:173
else
Definition: tritemp.h:161
#define SSA_TAB
Definition: usp10.h:34

◆ EDIT_WM_Char()

static LRESULT EDIT_WM_Char ( EDITSTATE es,
WCHAR  c 
)
static

Definition at line 3290 of file edit.c.

3292{
3293 BOOL control;
3294
3295#ifdef __REACTOS__
3296 if (es->bCaptureState)
3297 return 0;
3298#endif
3299
3300 control = GetKeyState(VK_CONTROL) & 0x8000;
3301
3302 switch (c) {
3303 case '\r':
3304 /* If it's not a multiline edit box, it would be ignored below.
3305 * For multiline edit without ES_WANTRETURN, we have to make a
3306 * special case.
3307 */
3308 if ((es->style & ES_MULTILINE) && !(es->style & ES_WANTRETURN))
3310 break;
3311 case '\n':
3312 if (es->style & ES_MULTILINE) {
3313 if (es->style & ES_READONLY) {
3316 } else {
3317 static const WCHAR cr_lfW[] = {'\r','\n',0};
3318 EDIT_EM_ReplaceSel(es, TRUE, cr_lfW, TRUE, TRUE);
3319 }
3320 }
3321 break;
3322 case '\t':
3323 if ((es->style & ES_MULTILINE) && !(es->style & ES_READONLY))
3324 {
3325 static const WCHAR tabW[] = {'\t',0};
3327 break;
3329 }
3330 break;
3331 case VK_BACK:
3332 if (!(es->style & ES_READONLY) && !control) {
3333 if (es->selection_start != es->selection_end)
3335 else {
3336 /* delete character left of caret */
3337 EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
3340 }
3341 }
3342 break;
3343 case 0x03: /* ^C */
3344 if (!(es->style & ES_PASSWORD))
3345 SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
3346 break;
3347 case 0x16: /* ^V */
3348 if (!(es->style & ES_READONLY))
3349 SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3350 break;
3351 case 0x18: /* ^X */
3352 if (!((es->style & ES_READONLY) || (es->style & ES_PASSWORD)))
3353 SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
3354 break;
3355 case 0x1A: /* ^Z */
3356 if (!(es->style & ES_READONLY))
3357 SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
3358 break;
3359
3360 default:
3361 /*If Edit control style is ES_NUMBER allow users to key in only numeric values*/
3362 if( (es->style & ES_NUMBER) && !( c >= '0' && c <= '9') )
3363 break;
3364
3365 if (!(es->style & ES_READONLY) && (c >= ' ') && (c != 127)) {
3366 WCHAR str[2];
3367 str[0] = c;
3368 str[1] = '\0';
3370 }
3371 break;
3372 }
3373 return 1;
static BOOL EDIT_IsInsideDialog(EDITSTATE *es)
Definition: edit.c:2982
static void EDIT_MoveBackward(EDITSTATE *es, BOOL extend)
Definition: edit.c:1847
static void EDIT_MoveHome(EDITSTATE *es, BOOL extend, BOOL ctrl)
Definition: edit.c:1942
static void EDIT_WM_Clear(EDITSTATE *es)
Definition: edit.c:3058
static void EDIT_MoveDown_ML(EDITSTATE *es, BOOL extend)
Definition: edit.c:1874
#define ES_WANTRETURN
Definition: pedump.c:676
const WCHAR * str
Definition: dialog.c:52
#define VK_CONTROL
Definition: winuser.h:2222
#define VK_BACK
Definition: winuser.h:2217
#define ES_NUMBER
Definition: winuser.h:301
SHORT WINAPI GetKeyState(_In_ int)

◆ EDIT_WM_Clear()

static void EDIT_WM_Clear ( EDITSTATE es)
inlinestatic

Definition at line 3263 of file edit.c.

3265{
3266 /* Protect read-only edit control from modification */
3267 if(es->style & ES_READONLY)
3268 return;
3269

◆ EDIT_WM_ContextMenu()

static void EDIT_WM_ContextMenu ( EDITSTATE es,
INT  x,
INT  y 
)
static

Definition at line 3425 of file edit.c.

3427{
3428 HMENU menu = LoadMenuA(user32_module, "EDITMENU");
3429 HMENU popup = GetSubMenu(menu, 0);
3430 UINT start = es->selection_start;
3431 UINT end = es->selection_end;
3432 UINT cmd;
3433
3435
3436 /* undo */
3438 /* cut */
3439 EnableMenuItem(popup, 2, MF_BYPOSITION | ((end - start) && !(es->style & ES_PASSWORD) && !(es->style & ES_READONLY) ? MF_ENABLED : MF_GRAYED));
3440 /* copy */
3441 EnableMenuItem(popup, 3, MF_BYPOSITION | ((end - start) && !(es->style & ES_PASSWORD) ? MF_ENABLED : MF_GRAYED));
3442 /* paste */
3444 /* delete */
3445 EnableMenuItem(popup, 5, MF_BYPOSITION | ((end - start) && !(es->style & ES_READONLY) ? MF_ENABLED : MF_GRAYED));
3446 /* select all */
3448
3449 if (x == -1 && y == -1) /* passed via VK_APPS press/release */
3450 {
3451 RECT rc;
3452 /* Windows places the menu at the edit's center in this case */
3453#ifdef __REACTOS__
3454 /* ReactOS r55202 */
3455 GetClientRect(es->hwndSelf, &rc);
3456 MapWindowPoints(es->hwndSelf, 0, (POINT *)&rc, 2);
3457#else
3458 WIN_GetRectangles( es->hwndSelf, COORDS_SCREEN, NULL, &rc );
3459#endif
3460 x = rc.left + (rc.right - rc.left) / 2;
3461 y = rc.top + (rc.bottom - rc.top) / 2;
3462 }
3463
3464 if (!(es->flags & EF_FOCUSED))
3465 SetFocus(es->hwndSelf);
3466
3468 x, y, 0, es->hwndSelf, NULL);
3469
3470 if (cmd)
3472
3473 DestroyMenu(menu);
#define CF_UNICODETEXT
Definition: constants.h:408
static BOOL EDIT_EM_CanUndo(const EDITSTATE *es)
Definition: edit.c:181
static void EDIT_ContextMenuCommand(EDITSTATE *es, UINT id)
Definition: edit.c:3172
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
Definition: ftp_var.h:139
#define user32_module
Definition: user32p.h:40
#define TPM_RIGHTBUTTON
Definition: winuser.h:2399
#define TPM_NONOTIFY
Definition: winuser.h:2405
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define MF_ENABLED
Definition: winuser.h:128
#define TPM_LEFTALIGN
Definition: winuser.h:2396
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI DestroyMenu(_In_ HMENU)
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define TPM_RETURNCMD
Definition: winuser.h:2406
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
#define MF_GRAYED
Definition: winuser.h:129
HMENU WINAPI LoadMenuA(_In_opt_ HINSTANCE, _In_ LPCSTR)

◆ EDIT_WM_Copy()

static void EDIT_WM_Copy ( EDITSTATE es)
static

Definition at line 3234 of file edit.c.

3236{
3237 INT s = min(es->selection_start, es->selection_end);
3238 INT e = max(es->selection_start, es->selection_end);
3239 HGLOBAL hdst;
3240 LPWSTR dst;
3241 DWORD len;
3242
3243 if (e == s) return;
3244
3245 len = e - s;
3246 hdst = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, (len + 1) * sizeof(WCHAR));
3247 dst = GlobalLock(hdst);
3248 memcpy(dst, es->text + s, len * sizeof(WCHAR));
3249 dst[len] = 0; /* ensure 0 termination */
3250 TRACE("%s\n", debugstr_w(dst));
3251 GlobalUnlock(hdst);
3252 OpenClipboard(es->hwndSelf);
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
#define GMEM_MOVEABLE
Definition: winbase.h:327
#define GMEM_DDESHARE
Definition: winbase.h:331
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190

◆ EDIT_WM_Create()

static LRESULT EDIT_WM_Create ( EDITSTATE es,
LPCWSTR  name 
)
static

Definition at line 4762 of file edit.c.

4764{
4765 RECT clientRect;
4766
4767 TRACE("%s\n", debugstr_w(name));
4768 /*
4769 * To initialize some final structure members, we call some helper
4770 * functions. However, since the EDITSTATE is not consistent (i.e.
4771 * not fully initialized), we should be very careful which
4772 * functions can be called, and in what order.
4773 */
4776
4777 /* We need to calculate the format rect
4778 (applications may send EM_SETMARGINS before the control gets visible) */
4779 GetClientRect(es->hwndSelf, &clientRect);
4780 EDIT_SetRectNP(es, &clientRect);
4781
4782 if (name && *name) {
4784 /* if we insert text to the editline, the text scrolls out
4785 * of the window, as the caret is placed after the insert
4786 * pos normally; thus we reset es->selection... to 0 and
4787 * update caret
4788 */
4789 es->selection_start = es->selection_end = 0;
4790 /* Adobe Photoshop does NOT like this. and MSDN says that EN_CHANGE
4791 * Messages are only to be sent when the USER does something to
4792 * change the contents. So I am removing this EN_CHANGE
4793 *
4794 * EDIT_NOTIFY_PARENT(es, EN_CHANGE);
4795 */
4797 }
4798 /* force scroll info update */
4800 /* The rule seems to return 1 here for success */
4801 /* Power Builder masked edit controls will crash */
4802 /* if not. */
4803 /* FIXME: is that in all cases so ? */
4804 return 1;
static void EDIT_WM_SetFont(EDITSTATE *es, HFONT font, BOOL redraw)
Definition: edit.c:3837
static void EDIT_SetRectNP(EDITSTATE *es, const RECT *rc)
Definition: edit.c:2317
Definition: name.c:39

◆ EDIT_WM_Cut()

static void EDIT_WM_Cut ( EDITSTATE es)
inlinestatic

Definition at line 3278 of file edit.c.

3280{
static void EDIT_WM_Copy(EDITSTATE *es)
Definition: edit.c:3029

◆ EDIT_WM_GetText()

static INT EDIT_WM_GetText ( const EDITSTATE es,
INT  count,
LPWSTR  dst,
BOOL  unicode 
)
static

Definition at line 3481 of file edit.c.

3483{
3484 if(!count) return 0;
3485
3486 if(unicode)
3487 {
3488 lstrcpynW(dst, es->text, count);
3489 return strlenW(dst);
3490 }
3491 else
3492 {
3493 LPSTR textA = (LPSTR)dst;
3494 if (!WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, count, NULL, NULL))
3495 textA[count - 1] = 0; /* ensure 0 termination */
3496 return strlen(textA);
3497 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define lstrcpynW
Definition: compat.h:738

◆ EDIT_WM_HScroll()

static LRESULT EDIT_WM_HScroll ( EDITSTATE es,
INT  action,
INT  pos 
)
static

Definition at line 4229 of file edit.c.

4231{
4232 INT dx;
4233 INT fw;
4234
4235 if (!(es->style & ES_MULTILINE))
4236 return 0;
4237
4238 if (!(es->style & ES_AUTOHSCROLL))
4239 return 0;
4240
4241 dx = 0;
4242 fw = es->format_rect.right - es->format_rect.left;
4243 switch (action) {
4244 case SB_LINELEFT:
4245 TRACE("SB_LINELEFT\n");
4246 if (es->x_offset)
4247 dx = -es->char_width;
4248 break;
4249 case SB_LINERIGHT:
4250 TRACE("SB_LINERIGHT\n");
4251 if (es->x_offset < es->text_width)
4252 dx = es->char_width;
4253 break;
4254 case SB_PAGELEFT:
4255 TRACE("SB_PAGELEFT\n");
4256 if (es->x_offset)
4257 dx = -fw / HSCROLL_FRACTION / es->char_width * es->char_width;
4258 break;
4259 case SB_PAGERIGHT:
4260 TRACE("SB_PAGERIGHT\n");
4261 if (es->x_offset < es->text_width)
4262 dx = fw / HSCROLL_FRACTION / es->char_width * es->char_width;
4263 break;
4264 case SB_LEFT:
4265 TRACE("SB_LEFT\n");
4266 if (es->x_offset)
4267 dx = -es->x_offset;
4268 break;
4269 case SB_RIGHT:
4270 TRACE("SB_RIGHT\n");
4271 if (es->x_offset < es->text_width)
4272 dx = es->text_width - es->x_offset;
4273 break;
4274 case SB_THUMBTRACK:
4275 TRACE("SB_THUMBTRACK %d\n", pos);
4276 es->flags |= EF_HSCROLL_TRACK;
4277 if(es->style & WS_HSCROLL)
4278 dx = pos - es->x_offset;
4279 else
4280 {
4281 INT fw, new_x;
4282 /* Sanity check */
4283 if(pos < 0 || pos > 100) return 0;
4284 /* Assume default scroll range 0-100 */
4285 fw = es->format_rect.right - es->format_rect.left;
4286 new_x = pos * (es->text_width - fw) / 100;
4287 dx = es->text_width ? (new_x - es->x_offset) : 0;
4288 }
4289 break;
4290 case SB_THUMBPOSITION:
4291 TRACE("SB_THUMBPOSITION %d\n", pos);
4292 es->flags &= ~EF_HSCROLL_TRACK;
4293 if(GetWindowLongW( es->hwndSelf, GWL_STYLE ) & WS_HSCROLL)
4294 dx = pos - es->x_offset;
4295 else
4296 {
4297 INT fw, new_x;
4298 /* Sanity check */
4299 if(pos < 0 || pos > 100) return 0;
4300 /* Assume default scroll range 0-100 */
4301 fw = es->format_rect.right - es->format_rect.left;
4302 new_x = pos * (es->text_width - fw) / 100;
4303 dx = es->text_width ? (new_x - es->x_offset) : 0;
4304 }
4305 if (!dx) {
4306 /* force scroll info update */
4309 }
4310 break;
4311 case SB_ENDSCROLL:
4312 TRACE("SB_ENDSCROLL\n");
4313 break;
4314 /*
4315 * FIXME : the next two are undocumented !
4316 * Are we doing the right thing ?
4317 * At least Win 3.1 Notepad makes use of EM_GETTHUMB this way,
4318 * although it's also a regular control message.
4319 */
4320 case EM_GETTHUMB: /* this one is used by NT notepad */
4321 {
4322 LRESULT ret;
4323 if(GetWindowLongW( es->hwndSelf, GWL_STYLE ) & WS_HSCROLL)
4324 ret = GetScrollPos(es->hwndSelf, SB_HORZ);
4325 else
4326 {
4327 /* Assume default scroll range 0-100 */
4328 INT fw = es->format_rect.right - es->format_rect.left;
4329 ret = es->text_width ? es->x_offset * 100 / (es->text_width - fw) : 0;
4330 }
4331 TRACE("EM_GETTHUMB: returning %ld\n", ret);
4332 return ret;
4333 }
4334 case EM_LINESCROLL:
4335 TRACE("EM_LINESCROLL16\n");
4336 dx = pos;
4337 break;
4338
4339 default:
4340 ERR("undocumented WM_HSCROLL action %d (0x%04x), please report\n",
4341 action, action);
4342 return 0;
4343 }
4344 if (dx)
4345 {
4346 INT fw = es->format_rect.right - es->format_rect.left;
4347 /* check if we are going to move too far */
4348 if(es->x_offset + dx + fw > es->text_width)
4349 dx = es->text_width - fw - es->x_offset;
4350 if(dx)
4352 }
4353 return 0;
#define SB_THUMBTRACK
Definition: winuser.h:573
#define SB_PAGERIGHT
Definition: winuser.h:571
#define SB_LEFT
Definition: winuser.h:575
#define SB_LINERIGHT
Definition: winuser.h:567
#define EM_LINESCROLL
Definition: winuser.h:2023
#define SB_LINELEFT
Definition: winuser.h:566
#define SB_ENDSCROLL
Definition: winuser.h:574
#define SB_RIGHT
Definition: winuser.h:576
int WINAPI GetScrollPos(_In_ HWND, _In_ int)
#define SB_PAGELEFT
Definition: winuser.h:570
#define SB_THUMBPOSITION
Definition: winuser.h:572

◆ EDIT_WM_KeyDown()

static LRESULT EDIT_WM_KeyDown ( EDITSTATE es,
INT  key 
)
static

Definition at line 3566 of file edit.c.

3568{
3569 BOOL shift;
3570 BOOL control;
3571
3572 if (GetKeyState(VK_MENU) & 0x8000)
3573 return 0;
3574
3575 shift = GetKeyState(VK_SHIFT) & 0x8000;
3576 control = GetKeyState(VK_CONTROL) & 0x8000;
3577
3578 switch (key) {
3579 case VK_F4:
3580 case VK_UP:
3582 break;
3583
3584 /* fall through */
3585 case VK_LEFT:
3586 if ((es->style & ES_MULTILINE) && (key == VK_UP))
3588 else
3589 if (control)
3591 else
3593 break;
3594 case VK_DOWN:
3596 break;
3597 /* fall through */
3598 case VK_RIGHT:
3599 if ((es->style & ES_MULTILINE) && (key == VK_DOWN))
3601 else if (control)
3603 else
3605 break;
3606 case VK_HOME:
3608 break;
3609 case VK_END:
3611 break;
3612 case VK_PRIOR:
3613 if (es->style & ES_MULTILINE)
3615 else
3617 break;
3618 case VK_NEXT:
3619 if (es->style & ES_MULTILINE)
3621 else
3623 break;
3624 case VK_DELETE:
3625 if (!(es->style & ES_READONLY) && !(shift && control)) {
3626 if (es->selection_start != es->selection_end) {
3627 if (shift)
3628 EDIT_WM_Cut(es);
3629 else
3631 } else {
3632 if (shift) {
3633 /* delete character left of caret */
3634 EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
3637 } else if (control) {
3638 /* delete to end of line */
3639 EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
3642 } else {
3643 /* delete character right of caret */
3644 EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
3647 }
3648 }
3649 }
3650 break;
3651 case VK_INSERT:
3652 if (shift) {
3653 if (!(es->style & ES_READONLY))
3655 } else if (control)
3657 break;
3658 case VK_RETURN:
3659 /* If the edit doesn't want the return send a message to the default object */
3660 if(!(es->style & ES_MULTILINE) || !(es->style & ES_WANTRETURN))
3661 {
3662 DWORD dw;
3663
3664 if (!EDIT_IsInsideDialog(es)) break;
3665 if (control) break;
3666 dw = SendMessageW(es->hwndParent, DM_GETDEFID, 0, 0);
3667 if (HIWORD(dw) == DC_HASDEFID)
3668 {
3669 HWND hwDefCtrl = GetDlgItem(es->hwndParent, LOWORD(dw));
3670 if (hwDefCtrl)
3671 {
3672 SendMessageW(es->hwndParent, WM_NEXTDLGCTL, (WPARAM)hwDefCtrl, TRUE);
3673 PostMessageW(hwDefCtrl, WM_KEYDOWN, VK_RETURN, 0);
3674 }
3675 }
3676 }
3677 break;
3678 case VK_ESCAPE:
3679 if ((es->style & ES_MULTILINE) && EDIT_IsInsideDialog(es))
3680 PostMessageW(es->hwndParent, WM_CLOSE, 0, 0);
3681 break;
3682 case VK_TAB:
3683 if ((es->style & ES_MULTILINE) && EDIT_IsInsideDialog(es))
3684 SendMessageW(es->hwndParent, WM_NEXTDLGCTL, shift, 0);
3685 break;
3686#ifdef __REACTOS__
3687 /* ReactOS CORE-1419 */
3688 case VK_BACK:
3689 if (control)
3690 {
3691 FIXME("Ctrl+Backspace\n");
3692 }
3693 break;
3694#endif
3695 }
3696 return TRUE;
static void EDIT_MoveEnd(EDITSTATE *es, BOOL extend, BOOL ctrl)
Definition: edit.c:1896
static BOOL EDIT_CheckCombo(EDITSTATE *es, UINT msg, INT key)
Definition: edit.c:3286
static void EDIT_MoveUp_ML(EDITSTATE *es, BOOL extend)
Definition: edit.c:2022
static void EDIT_WM_Cut(EDITSTATE *es)
Definition: edit.c:3073
static void EDIT_MovePageUp_ML(EDITSTATE *es, BOOL extend)
Definition: edit.c:1994
static void EDIT_WM_Paste(EDITSTATE *es)
Definition: edit.c:2993
static void EDIT_MovePageDown_ML(EDITSTATE *es, BOOL extend)
Definition: edit.c:1966
static void EDIT_MoveWordForward(EDITSTATE *es, BOOL extend)
Definition: edit.c:2075
static void EDIT_MoveWordBackward(EDITSTATE *es, BOOL extend)
Definition: edit.c:2044
static void EDIT_MoveForward(EDITSTATE *es, BOOL extend)
Definition: edit.c:1917
REFIID LPVOID DWORD_PTR dw
Definition: atlbase.h:40
#define shift
Definition: input.c:1755
#define WM_CLOSE
Definition: winuser.h:1640
#define VK_TAB
Definition: winuser.h:2218
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DC_HASDEFID
Definition: winuser.h:2628
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_NEXTDLGCTL
Definition: winuser.h:1662
#define VK_NEXT
Definition: winuser.h:2240
#define VK_RETURN
Definition: winuser.h:2220
#define VK_END
Definition: winuser.h:2241
#define VK_HOME
Definition: winuser.h:2242
#define VK_LEFT
Definition: winuser.h:2243
#define VK_RIGHT
Definition: winuser.h:2245
#define VK_SHIFT
Definition: winuser.h:2221
#define VK_PRIOR
Definition: winuser.h:2239
#define VK_DELETE
Definition: winuser.h:2252
#define DM_GETDEFID
Definition: winuser.h:2117
#define VK_ESCAPE
Definition: winuser.h:2233
#define VK_INSERT
Definition: winuser.h:2251
#define VK_MENU
Definition: winuser.h:2223

◆ EDIT_WM_KillFocus()

static LRESULT EDIT_WM_KillFocus ( EDITSTATE es)
static

Definition at line 3704 of file edit.c.

3706{
3707#ifdef __REACTOS__
3708 HWND hCombo;
3709 LONG lStyles;
3710
3711 es->flags &= ~EF_FOCUSED;
3712 DestroyCaret();
3713 if(!(es->style & ES_NOHIDESEL))
3714 EDIT_InvalidateText(es, es->selection_start, es->selection_end);
3715
3716 /* throw away left over scroll when we lose focus */
3717 es->wheelDeltaRemainder = 0;
3718
3719 if (es->hwndListBox == NULL) {
3720 if (!notify_parent(es, EN_KILLFOCUS)) return 0;
3721 } else
3722 { /* send the undocumented WM_CBLOSTTEXTFOCUS message to combobox */
3723 hCombo = GetParent(es->hwndSelf);
3724 lStyles = GetWindowLong(hCombo, GWL_STYLE);
3725 if ((lStyles & CBS_DROPDOWN) || (lStyles & CBS_SIMPLE))
3726 SendMessage(hCombo, WM_CBLOSTTEXTFOCUS, 0, 0);
3727 }
3728#else
3729 es->flags &= ~EF_FOCUSED;
3730 DestroyCaret();
3731 if(!(es->style & ES_NOHIDESEL))
3732 EDIT_InvalidateText(es, es->selection_start, es->selection_end);
3733 if (!notify_parent(es, EN_KILLFOCUS)) return 0;
3734 /* throw away left over scroll when we lose focus */
3735 es->wheelDeltaRemainder = 0;
3736#endif
3737 return 0;
#define WM_CBLOSTTEXTFOCUS
Definition: undocuser.h:52
#define EN_KILLFOCUS
Definition: winuser.h:2044
#define CBS_SIMPLE
Definition: winuser.h:291
#define SendMessage
Definition: winuser.h:5928
#define CBS_DROPDOWN
Definition: winuser.h:283
#define GetWindowLong
Definition: winuser.h:5881
BOOL WINAPI DestroyCaret(void)
Definition: caret.c:35

◆ EDIT_WM_LButtonDblClk()

static LRESULT EDIT_WM_LButtonDblClk ( EDITSTATE es)
static

Definition at line 3747 of file edit.c.

3749{
3750 INT s;
3751 INT e = es->selection_end;
3752 INT l;
3753 INT li;
3754 INT ll;
3755
3756 es->bCaptureState = TRUE;
3757 SetCapture(es->hwndSelf);
3758
3766 es->region_posx = es->region_posy = 0;
3767 SetTimer(es->hwndSelf, 0, 100, NULL);
3768 return 0;
HWND WINAPI SetCapture(_In_ HWND hWnd)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)

◆ EDIT_WM_LButtonDown()

static LRESULT EDIT_WM_LButtonDown ( EDITSTATE es,
DWORD  keys,
INT  x,
INT  y 
)
static

Definition at line 3776 of file edit.c.

3778{
3779 INT e;
3780 BOOL after_wrap;
3781
3782 es->bCaptureState = TRUE;
3783 SetCapture(es->hwndSelf);
3784 EDIT_ConfinePoint(es, &x, &y);
3785 e = EDIT_CharFromPos(es, x, y, &after_wrap);
3786 EDIT_EM_SetSel(es, (keys & MK_SHIFT) ? es->selection_start : e, e, after_wrap);
3788 es->region_posx = es->region_posy = 0;
3789 SetTimer(es->hwndSelf, 0, 100, NULL);
3790
3791 if (!(es->flags & EF_FOCUSED))
3792 SetFocus(es->hwndSelf);
3793
3794 return 0;
static void EDIT_ConfinePoint(const EDITSTATE *es, LPINT x, LPINT y)
Definition: edit.c:901
const UINT * keys
Definition: locale.c:416
#define MK_SHIFT
Definition: winuser.h:2388

◆ EDIT_WM_LButtonUp()

static LRESULT EDIT_WM_LButtonUp ( EDITSTATE es)
static

Definition at line 3802 of file edit.c.

3804{
3805 if (es->bCaptureState) {
3806 KillTimer(es->hwndSelf, 0);
3807 if (GetCapture() == es->hwndSelf) ReleaseCapture();
3808 }
3809 es->bCaptureState = FALSE;
3810 return 0;
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
HWND WINAPI GetCapture(void)
Definition: message.c:2881
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

◆ EDIT_WM_MButtonDown()

static LRESULT EDIT_WM_MButtonDown ( EDITSTATE es)
static

Definition at line 3818 of file edit.c.

3820{
3821 SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3822 return 0;

◆ EDIT_WM_MouseMove()

static LRESULT EDIT_WM_MouseMove ( EDITSTATE es,
INT  x,
INT  y 
)
static

Definition at line 3830 of file edit.c.

3832{
3833 INT e;
3834 BOOL after_wrap;
3835 INT prex, prey;
3836
3837 /* If the mouse has been captured by process other than the edit control itself,
3838 * the windows edit controls will not select the strings with mouse move.
3839 */
3840 if (!es->bCaptureState || GetCapture() != es->hwndSelf)
3841 return 0;
3842
3843 /*
3844 * FIXME: gotta do some scrolling if outside client
3845 * area. Maybe reset the timer ?
3846 */
3847 prex = x; prey = y;
3848 EDIT_ConfinePoint(es, &x, &y);
3849 es->region_posx = (prex < x) ? -1 : ((prex > x) ? 1 : 0);
3850 es->region_posy = (prey < y) ? -1 : ((prey > y) ? 1 : 0);
3851 e = EDIT_CharFromPos(es, x, y, &after_wrap);
3852 EDIT_EM_SetSel(es, es->selection_start, e, after_wrap);
3853 EDIT_SetCaretPos(es,es->selection_end,es->flags & EF_AFTER_WRAP);
3854 return 0;

◆ EDIT_WM_NCCreate()

static LRESULT EDIT_WM_NCCreate ( HWND  hwnd,
LPCREATESTRUCTW  lpcs,
BOOL  unicode 
)
static

Definition at line 4647 of file edit.c.

4649{
4650 EDITSTATE *es;
4651 UINT alloc_size;
4652
4653 TRACE("Creating %s edit control, style = %08x\n",
4654 unicode ? "Unicode" : "ANSI", lpcs->style);
4655
4656 if (!(es = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*es))))
4657 return FALSE;
4659
4660 /*
4661 * Note: since the EDITSTATE has not been fully initialized yet,
4662 * we can't use any API calls that may send
4663 * WM_XXX messages before WM_NCCREATE is completed.
4664 */
4665
4666 es->is_unicode = unicode;
4667 es->style = lpcs->style;
4668
4669 es->bEnableState = !(es->style & WS_DISABLED);
4670
4671 es->hwndSelf = hwnd;
4672 /* Save parent, which will be notified by EN_* messages */
4673 es->hwndParent = lpcs->hwndParent;
4674
4675 if (es->style & ES_COMBO)
4676 es->hwndListBox = GetDlgItem(es->hwndParent, ID_CB_LISTBOX);
4677
4678 /* FIXME: should we handle changes to WS_EX_RIGHT style after creation? */
4679 if (lpcs->dwExStyle & WS_EX_RIGHT) es->style |= ES_RIGHT;
4680
4681 /* Number overrides lowercase overrides uppercase (at least it
4682 * does in Win95). However I'll bet that ES_NUMBER would be
4683 * invalid under Win 3.1.
4684 */
4685 if (es->style & ES_NUMBER) {
4686 ; /* do not override the ES_NUMBER */
4687 } else if (es->style & ES_LOWERCASE) {
4688 es->style &= ~ES_UPPERCASE;
4689 }
4690 if (es->style & ES_MULTILINE) {
4691 es->buffer_limit = BUFLIMIT_INITIAL;
4692 if (es->style & WS_VSCROLL)
4693 es->style |= ES_AUTOVSCROLL;
4694 if (es->style & WS_HSCROLL)
4695 es->style |= ES_AUTOHSCROLL;
4696 es->style &= ~ES_PASSWORD;
4697 if ((es->style & ES_CENTER) || (es->style & ES_RIGHT)) {
4698 /* Confirmed - RIGHT overrides CENTER */
4699 if (es->style & ES_RIGHT)
4700 es->style &= ~ES_CENTER;
4701 es->style &= ~WS_HSCROLL;
4702 es->style &= ~ES_AUTOHSCROLL;
4703 }
4704 } else {
4705 es->buffer_limit = BUFLIMIT_INITIAL;
4706 if ((es->style & ES_RIGHT) && (es->style & ES_CENTER))
4707 es->style &= ~ES_CENTER;
4708 es->style &= ~WS_HSCROLL;
4709 es->style &= ~WS_VSCROLL;
4710 if (es->style & ES_PASSWORD)
4711 es->password_char = '*';
4712 }
4713
4714 alloc_size = ROUND_TO_GROW((es->buffer_size + 1) * sizeof(WCHAR));
4715 if(!(es->hloc32W = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, alloc_size)))
4716 goto cleanup;
4717 es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1;
4718
4719 if (!(es->undo_text = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (es->buffer_size + 1) * sizeof(WCHAR))))
4720 goto cleanup;
4721 es->undo_buffer_size = es->buffer_size;
4722
4723 if (es->style & ES_MULTILINE)
4724 if (!(es->first_line_def = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LINEDEF))))
4725 goto cleanup;
4726 es->line_count = 1;
4727
4728 /*
4729 * In Win95 look and feel, the WS_BORDER style is replaced by the
4730 * WS_EX_CLIENTEDGE style for the edit control. This gives the edit
4731 * control a nonclient area so we don't need to draw the border.
4732 * If WS_BORDER without WS_EX_CLIENTEDGE is specified we shouldn't have
4733 * a nonclient area and we should handle painting the border ourselves.
4734 *
4735 * When making modifications please ensure that the code still works
4736 * for edit controls created directly with style 0x50800000, exStyle 0
4737 * (which should have a single pixel border)
4738 */
4739 if (lpcs->dwExStyle & WS_EX_CLIENTEDGE)
4740 es->style &= ~WS_BORDER;
4741 else if (es->style & WS_BORDER)
4743
4744 return TRUE;
4745
4746cleanup:
4747 SetWindowLongPtrW(es->hwndSelf, 0, 0);
4749 HeapFree(GetProcessHeap(), 0, es->first_line_def);
4750 HeapFree(GetProcessHeap(), 0, es->undo_text);
4751 if (es->hloc32W) LocalFree(es->hloc32W);
4752 HeapFree(GetProcessHeap(), 0, es->logAttr);
4753 HeapFree(GetProcessHeap(), 0, es);
4754 return FALSE;
#define ID_CB_LISTBOX
Definition: edit.c:74
#define BUFLIMIT_INITIAL
Definition: edit.c:57
static void cleanup(void)
Definition: main.c:1335
#define ES_COMBO
Definition: edit.c:29
#define WS_DISABLED
Definition: pedump.c:621
Definition: edit.c:96
#define SetWindowLongPtrW
Definition: winuser.h:5431
#define WS_EX_RIGHT
Definition: winuser.h:400

◆ EDIT_WM_NCDestroy()

static LRESULT EDIT_WM_NCDestroy ( EDITSTATE es)
static

Definition at line 4812 of file edit.c.

4814{
4815 LINEDEF *pc, *pp;
4816
4817 /* The app can own the text buffer handle */
4818 if (es->hloc32W && (es->hloc32W != es->hlocapp)) {
4819 LocalFree(es->hloc32W);
4820 }
4821 if (es->hloc32A && (es->hloc32A != es->hlocapp)) {
4822 LocalFree(es->hloc32A);
4823 }
4825 pc = es->first_line_def;
4826 while (pc)
4827 {
4828 pp = pc->next;
4829 HeapFree(GetProcessHeap(), 0, pc);
4830 pc = pp;
4831 }
4832
4833 SetWindowLongPtrW( es->hwndSelf, 0, 0 );
4834 HeapFree(GetProcessHeap(), 0, es->undo_text);
4835 HeapFree(GetProcessHeap(), 0, es);
4836
4837 return 0;

◆ EDIT_WM_Paint()

static void EDIT_WM_Paint ( EDITSTATE es,
HDC  hdc 
)
static

Definition at line 3862 of file edit.c.

3864{
3865 PAINTSTRUCT ps;
3866 INT i;
3867 HDC dc;
3868 HFONT old_font = 0;
3869 RECT rc;
3870 RECT rcClient;
3871 RECT rcLine;
3872 RECT rcRgn;
3873 HBRUSH brush;
3874 HBRUSH old_brush;
3875 INT bw, bh;
3876 BOOL rev = es->bEnableState &&
3877 ((es->flags & EF_FOCUSED) ||
3878 (es->style & ES_NOHIDESEL));
3879 dc = hdc ? hdc : BeginPaint(es->hwndSelf, &ps);
3880
3881 /* The dc we use for calculating may not be the one we paint into.
3882 This is the safest action. */
3884 GetClientRect(es->hwndSelf, &rcClient);
3885
3886 /* get the background brush */
3887 brush = EDIT_NotifyCtlColor(es, dc);
3888
3889 /* paint the border and the background */
3890 IntersectClipRect(dc, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
3891
3892 if(es->style & WS_BORDER) {
3895 rc = rcClient;
3896 if(es->style & ES_MULTILINE) {
3897 if(es->style & WS_HSCROLL) rc.bottom+=bh;
3898 if(es->style & WS_VSCROLL) rc.right+=bw;
3899 }
3900
3901 /* Draw the frame. Same code as in nonclient.c */
3903 PatBlt(dc, rc.left, rc.top, rc.right - rc.left, bh, PATCOPY);
3904 PatBlt(dc, rc.left, rc.top, bw, rc.bottom - rc.top, PATCOPY);
3905 PatBlt(dc, rc.left, rc.bottom - 1, rc.right - rc.left, -bw, PATCOPY);
3906 PatBlt(dc, rc.right - 1, rc.top, -bw, rc.bottom - rc.top, PATCOPY);
3907 SelectObject(dc, old_brush);
3908
3909 /* Keep the border clean */
3910 IntersectClipRect(dc, rc.left+bw, rc.top+bh,
3911 max(rc.right-bw, rc.left+bw), max(rc.bottom-bh, rc.top+bh));
3912 }
3913
3914 GetClipBox(dc, &rc);
3915 FillRect(dc, &rc, brush);
3916
3917 IntersectClipRect(dc, es->format_rect.left,
3918 es->format_rect.top,
3919 es->format_rect.right,
3920 es->format_rect.bottom);
3921 if (es->style & ES_MULTILINE) {
3922 rc = rcClient;
3923 IntersectClipRect(dc, rc.left, rc.top, rc.right, rc.bottom);
3924 }
3925 if (es->font)
3926 old_font = SelectObject(dc, es->font);
3927
3928 if (!es->bEnableState)
3930 GetClipBox(dc, &rcRgn);
3931 if (es->style & ES_MULTILINE) {
3933 for (i = es->y_offset ; i <= min(es->y_offset + vlc, es->y_offset + es->line_count - 1) ; i++) {
3935 EDIT_GetLineRect(es, i, 0, -1, &rcLine);
3936 if (IntersectRect(&rc, &rcRgn, &rcLine))
3937 EDIT_PaintLine(es, dc, i, rev);
3938 }
3939 } else {
3941 EDIT_GetLineRect(es, 0, 0, -1, &rcLine);
3942 if (IntersectRect(&rc, &rcRgn, &rcLine))
3943 EDIT_PaintLine(es, dc, 0, rev);
3944 }
3945 if (es->font)
3946 SelectObject(dc, old_font);
3947
3948 if (!hdc)
3949 EndPaint(es->hwndSelf, &ps);
static void EDIT_PaintLine(EDITSTATE *es, HDC dc, INT line, BOOL rev)
Definition: edit.c:2179
static HBRUSH EDIT_NotifyCtlColor(EDITSTATE *es, HDC hdc)
Definition: edit.c:198
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define PATCOPY
Definition: wingdi.h:335
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define COLOR_GRAYTEXT
Definition: winuser.h:943
#define COLOR_WINDOWFRAME
Definition: winuser.h:930
HBRUSH WINAPI GetSysColorBrush(_In_ int)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

◆ EDIT_WM_Paste()

static void EDIT_WM_Paste ( EDITSTATE es)
static

Definition at line 3206 of file edit.c.

3208{
3209 HGLOBAL hsrc;
3210 LPWSTR src;
3211
3212 /* Protect read-only edit control from modification */
3213 if(es->style & ES_READONLY)
3214 return;
3215
3216 OpenClipboard(es->hwndSelf);
3217 if ((hsrc = GetClipboardData(CF_UNICODETEXT))) {
3218 src = GlobalLock(hsrc);
3220 GlobalUnlock(hsrc);
3221 }
3222 else if (es->style & ES_PASSWORD) {
3223 /* clear selected text in password edit box even with empty clipboard */
3225 }
HANDLE WINAPI GetClipboardData(_In_ UINT)

◆ EDIT_WM_SetFocus()

static void EDIT_WM_SetFocus ( EDITSTATE es)
static

Definition at line 3957 of file edit.c.

3959{
3960 es->flags |= EF_FOCUSED;
3961
3962 if (!(es->style & ES_NOHIDESEL))
3963 EDIT_InvalidateText(es, es->selection_start, es->selection_end);
3964
3965 /* single line edit updates itself */
3966 if (IsWindowVisible(es->hwndSelf) && !(es->style & ES_MULTILINE))
3967 {
3968 HDC hdc = GetDC(es->hwndSelf);
3970 ReleaseDC(es->hwndSelf, hdc);
3971 }
3972
3973#ifdef __REACTOS__
3974 SystemParametersInfo(SPI_GETCARETWIDTH, 0, &es->dwCaretWidth, 0);
3975 CreateCaret(es->hwndSelf, NULL, es->dwCaretWidth, es->line_height);
3976#else
3977 CreateCaret(es->hwndSelf, 0, 1, es->line_height);
3978#endif
3979 EDIT_SetCaretPos(es, es->selection_end,
3980 es->flags & EF_AFTER_WRAP);
3981 ShowCaret(es->hwndSelf);
static void EDIT_WM_Paint(EDITSTATE *es, HDC hdc)
Definition: edit.c:3628
BOOL WINAPI ShowCaret(_In_opt_ HWND)
#define EN_SETFOCUS
Definition: winuser.h:2046
BOOL WINAPI CreateCaret(_In_ HWND, _In_opt_ HBITMAP, _In_ int, _In_ int)
#define SystemParametersInfo
Definition: winuser.h:5943
BOOL WINAPI IsWindowVisible(_In_ HWND)

◆ EDIT_WM_SetFont()

static void EDIT_WM_SetFont ( EDITSTATE es,
HFONT  font,
BOOL  redraw 
)
static

Definition at line 3994 of file edit.c.

3996{
3998 HDC dc;
3999 HFONT old_font = 0;
4000 RECT clientRect;
4001
4002 es->font = font;
4004 dc = GetDC(es->hwndSelf);
4005 if (font)
4006 old_font = SelectObject(dc, font);
4008 es->line_height = tm.tmHeight;
4009 es->char_width = tm.tmAveCharWidth;
4010 if (font)
4011 SelectObject(dc, old_font);
4012 ReleaseDC(es->hwndSelf, dc);
4013
4014 /* Reset the format rect and the margins */
4015 GetClientRect(es->hwndSelf, &clientRect);
4016 EDIT_SetRectNP(es, &clientRect);
4019
4020 if (es->style & ES_MULTILINE)
4022 else
4024
4025 if (redraw)
4027 if (es->flags & EF_FOCUSED) {
4028 DestroyCaret();
4029#ifdef __REACTOS__
4030 CreateCaret(es->hwndSelf, NULL, es->dwCaretWidth, es->line_height);
4031#else
4032 CreateCaret(es->hwndSelf, 0, 1, es->line_height);
4033#endif
4034 EDIT_SetCaretPos(es, es->selection_end,
4035 es->flags & EF_AFTER_WRAP);
4036 ShowCaret(es->hwndSelf);
4037 }
4038#ifdef __REACTOS__
4040 {
4041 LOGFONTW lf;
4042 HIMC hIMC = ImmGetContext(es->hwndSelf);
4043 if (font == NULL)
4045 GetObjectW(font, sizeof(lf), &lf);
4046 ImmSetCompositionFontW(hIMC, &lf);
4047 ImmReleaseContext(es->hwndSelf, hIMC);
4048 }
4049#endif
static void EDIT_EM_SetMargins(EDITSTATE *es, INT action, WORD left, WORD right, BOOL repaint)
Definition: edit.c:2799
BOOL WINAPI ImmSetCompositionFontW(_In_ HIMC hIMC, _In_ LPLOGFONTW lplf)
Definition: ime.c:1322
Definition: mk_font.cpp:20
void redraw(int x, int y, int cx, int cy)
Definition: qtewin.cpp:1248
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909

◆ EDIT_WM_SetText()

static void EDIT_WM_SetText ( EDITSTATE es,
LPCWSTR  text,
BOOL  unicode 
)
static

Definition at line 4064 of file edit.c.

4066{
4067 LPWSTR textW = NULL;
4068 if (!unicode && text)
4069 {
4071 INT countW = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
4072 textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR));
4073 if (textW)
4074 MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW);
4075 text = textW;
4076 }
4077
4078 if (es->flags & EF_UPDATE)
4079 /* fixed this bug once; complain if we see it about to happen again. */
4080 ERR("SetSel may generate UPDATE message whose handler may reset "
4081 "selection.\n");
4082
4083 EDIT_EM_SetSel(es, 0, (UINT)-1, FALSE);
4084 if (text)
4085 {
4086 TRACE("%s\n", debugstr_w(text));
4088 if(!unicode)
4090 }
4091 else
4092 {
4093 TRACE("<NULL>\n");
4095 }
4096 es->x_offset = 0;
4097 es->flags &= ~EF_MODIFIED;
4098 EDIT_EM_SetSel(es, 0, 0, FALSE);
4099
4100 /* Send the notification after the selection start and end have been set
4101 * edit control doesn't send notification on WM_SETTEXT
4102 * if it is multiline, or it is part of combobox
4103 */
4104 if( !((es->style & ES_MULTILINE) || es->hwndListBox))
4105 {
4106 if (!notify_parent(es, EN_UPDATE)) return;
4107 if (!notify_parent(es, EN_CHANGE)) return;
4108 }
const char * LPCSTR
Definition: xmlstorage.h:183

◆ EDIT_WM_Size()

static void EDIT_WM_Size ( EDITSTATE es,
UINT  action 
)
static

Definition at line 4119 of file edit.c.

4121{
4122 if ((action == SIZE_MAXIMIZED) || (action == SIZE_RESTORED)) {
4123 RECT rc;
4124 GetClientRect(es->hwndSelf, &rc);
4125 EDIT_SetRectNP(es, &rc);
4127 }
#define SIZE_MAXIMIZED
Definition: winuser.h:2526
#define SIZE_RESTORED
Definition: winuser.h:2524

◆ EDIT_WM_StyleChanged()

static LRESULT EDIT_WM_StyleChanged ( EDITSTATE es,
WPARAM  which,
const STYLESTRUCT style 
)
static

Definition at line 4152 of file edit.c.

4154{
4155 if (GWL_STYLE == which) {
4156 DWORD style_change_mask;
4157 DWORD new_style;
4158 /* Only a subset of changes can be applied after the control
4159 * has been created.
4160 */
4161 style_change_mask = ES_UPPERCASE | ES_LOWERCASE |
4162 ES_NUMBER;
4163 if (es->style & ES_MULTILINE)
4164 style_change_mask |= ES_WANTRETURN;
4165
4166 new_style = style->styleNew & style_change_mask;
4167
4168 /* Number overrides lowercase overrides uppercase (at least it
4169 * does in Win95). However I'll bet that ES_NUMBER would be
4170 * invalid under Win 3.1.
4171 */
4172 if (new_style & ES_NUMBER) {
4173 ; /* do not override the ES_NUMBER */
4174 } else if (new_style & ES_LOWERCASE) {
4175 new_style &= ~ES_UPPERCASE;
4176 }
4177
4178 es->style = (es->style & ~style_change_mask) | new_style;
4179 } else if (GWL_EXSTYLE == which) {
4180 ; /* FIXME - what is needed here */
4181 } else {
4182 WARN ("Invalid style change %ld\n",which);
4183 }
4184
4185 return 0;
static GLenum which
Definition: wgl_font.c:159

◆ EDIT_WM_SysKeyDown()

static LRESULT EDIT_WM_SysKeyDown ( EDITSTATE es,
INT  key,
DWORD  key_data 
)
static

Definition at line 4192 of file edit.c.

4194{
4195 if ((key == VK_BACK) && (key_data & 0x2000)) {
4196 if (EDIT_EM_CanUndo(es))
4198 return 0;
4199 } else if (key == VK_UP || key == VK_DOWN) {
4201 return 0;
4202 }
4203 return DefWindowProcW(es->hwndSelf, WM_SYSKEYDOWN, key, key_data);
static BOOL EDIT_EM_Undo(EDITSTATE *es)
Definition: edit.c:2941

◆ EDIT_WM_Timer()

static void EDIT_WM_Timer ( EDITSTATE es)
static

Definition at line 4211 of file edit.c.

4213{
4214 if (es->region_posx < 0) {
4216 } else if (es->region_posx > 0) {
4218 }
4219/*
4220 * FIXME: gotta do some vertical scrolling here, like
4221 * EDIT_EM_LineScroll(hwnd, 0, 1);
4222 */

◆ EDIT_WM_VScroll()

static LRESULT EDIT_WM_VScroll ( EDITSTATE es,
INT  action,
INT  pos 
)
static

Definition at line 4361 of file edit.c.

4363{
4364 INT dy;
4365
4366 if (!(es->style & ES_MULTILINE))
4367 return 0;
4368
4369 if (!(es->style & ES_AUTOVSCROLL))
4370 return 0;
4371
4372 dy = 0;
4373 switch (action) {
4374 case SB_LINEUP:
4375 case SB_LINEDOWN:
4376 case SB_PAGEUP:
4377 case SB_PAGEDOWN:
4378 TRACE("action %d (%s)\n", action, (action == SB_LINEUP ? "SB_LINEUP" :
4379 (action == SB_LINEDOWN ? "SB_LINEDOWN" :
4380 (action == SB_PAGEUP ? "SB_PAGEUP" :
4381 "SB_PAGEDOWN"))));
4383 return 0;
4384 case SB_TOP:
4385 TRACE("SB_TOP\n");
4386 dy = -es->y_offset;
4387 break;
4388 case SB_BOTTOM:
4389 TRACE("SB_BOTTOM\n");
4390 dy = es->line_count - 1 - es->y_offset;
4391 break;
4392 case SB_THUMBTRACK:
4393 TRACE("SB_THUMBTRACK %d\n", pos);
4394 es->flags |= EF_VSCROLL_TRACK;
4395 if(es->style & WS_VSCROLL)
4396 dy = pos - es->y_offset;
4397 else
4398 {
4399 /* Assume default scroll range 0-100 */
4400 INT vlc, new_y;
4401 /* Sanity check */
4402 if(pos < 0 || pos > 100) return 0;
4404 new_y = pos * (es->line_count - vlc) / 100;
4405 dy = es->line_count ? (new_y - es->y_offset) : 0;
4406 TRACE("line_count=%d, y_offset=%d, pos=%d, dy = %d\n",
4407 es->line_count, es->y_offset, pos, dy);
4408 }
4409 break;
4410 case SB_THUMBPOSITION:
4411 TRACE("SB_THUMBPOSITION %d\n", pos);
4412 es->flags &= ~EF_VSCROLL_TRACK;
4413 if(es->style & WS_VSCROLL)
4414 dy = pos - es->y_offset;
4415 else
4416 {
4417 /* Assume default scroll range 0-100 */
4418 INT vlc, new_y;
4419 /* Sanity check */
4420 if(pos < 0 || pos > 100) return 0;
4422 new_y = pos * (es->line_count - vlc) / 100;
4423 dy = es->line_count ? (new_y - es->y_offset) : 0;
4424 TRACE("line_count=%d, y_offset=%d, pos=%d, dy = %d\n",
4425 es->line_count, es->y_offset, pos, dy);
4426 }
4427 if (!dy)
4428 {
4429 /* force scroll info update */
4432 }
4433 break;
4434 case SB_ENDSCROLL:
4435 TRACE("SB_ENDSCROLL\n");
4436 break;
4437 /*
4438 * FIXME : the next two are undocumented !
4439 * Are we doing the right thing ?
4440 * At least Win 3.1 Notepad makes use of EM_GETTHUMB this way,
4441 * although it's also a regular control message.
4442 */
4443 case EM_GETTHUMB: /* this one is used by NT notepad */
4444 {
4445 LRESULT ret;
4446 if(GetWindowLongW( es->hwndSelf, GWL_STYLE ) & WS_VSCROLL)
4447 ret = GetScrollPos(es->hwndSelf, SB_VERT);
4448 else
4449 {
4450 /* Assume default scroll range 0-100 */
4452 ret = es->line_count ? es->y_offset * 100 / (es->line_count - vlc) : 0;
4453 }
4454 TRACE("EM_GETTHUMB: returning %ld\n", ret);
4455 return ret;
4456 }
4457 case EM_LINESCROLL:
4458 TRACE("EM_LINESCROLL %d\n", pos);
4459 dy = pos;
4460 break;
4461
4462 default:
4463 ERR("undocumented WM_VSCROLL action %d (0x%04x), please report\n",
4464 action, action);
4465 return 0;
4466 }
4467 if (dy)
4469 return 0;
static LRESULT EDIT_EM_Scroll(EDITSTATE *es, INT action)
Definition: edit.c:1672
#define SB_BOTTOM
Definition: winuser.h:577
#define SB_TOP
Definition: winuser.h:578

◆ EDIT_WordBreakProc()

static INT EDIT_WordBreakProc ( EDITSTATE es,
LPWSTR  s,
INT  index,
INT  count,
INT  action 
)
static

Definition at line 285 of file edit.c.

287{
288 INT ret = 0;
289
290 TRACE("s=%p, index=%d, count=%d, action=%d\n", s, index, count, action);
291
292 if(!s) return 0;
293
294 if (!es->logAttr)
295 {
297
298 memset(&psa,0,sizeof(SCRIPT_ANALYSIS));
299 psa.eScript = SCRIPT_UNDEFINED;
300
301 es->logAttr = HeapAlloc(GetProcessHeap(), 0, sizeof(SCRIPT_LOGATTR) * get_text_length(es));
302 ScriptBreak(es->text, get_text_length(es), &psa, es->logAttr);
303 }
304
305 switch (action) {
306 case WB_LEFT:
307 if (index)
308 index--;
309 while (index && !es->logAttr[index].fSoftBreak)
310 index--;
311 ret = index;
312 break;
313 case WB_RIGHT:
314 if (!count)
315 break;
316 while (index < count && s[index] && !es->logAttr[index].fSoftBreak)
317 index++;
318 ret = index;
319 break;
320 case WB_ISDELIMITER:
321 ret = es->logAttr[index].fWhiteSpace;
322 break;
323 default:
324 ERR("unknown action code, please report !\n");
325 break;
326 }
327 return ret;
HRESULT WINAPI ScriptBreak(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT_LOGATTR *la)
Definition: usp10.c:3068
static SCRIPT_CACHE SCRIPT_ANALYSIS * psa
Definition: usp10.c:64
#define memset(x, y, z)
Definition: compat.h:39
#define SCRIPT_UNDEFINED
Definition: usp10.h:69
#define WB_ISDELIMITER
Definition: winuser.h:549

◆ EditWndProc_common()

LRESULT WINAPI EditWndProc_common ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  unicode 
)

Definition at line 4855 of file edit.c.

4857{
4859 LRESULT result = 0;
4860#ifdef __REACTOS__
4861 /* ReactOS r50219 */
4862 PWND pWnd;
4863
4864 pWnd = ValidateHwnd(hwnd);
4865 if (pWnd)
4866 {
4867 if (!pWnd->fnid)
4868 {
4870 }
4871 else
4872 {
4873 if (pWnd->fnid != FNID_EDIT)
4874 {
4875 ERR("Wrong window class for Edit! fnId 0x%x\n",pWnd->fnid);
4876 return 0;
4877 }
4878 }
4879 }
4880#endif
4881
4882 TRACE("hwnd=%p msg=%x (%s) wparam=%lx lparam=%lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), wParam, lParam);
4883
4884 if (!es && msg != WM_NCCREATE)
4885 return DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
4886
4887 if (es && (msg != WM_NCDESTROY)) EDIT_LockBuffer(es);
4888
4889 switch (msg) {
4890 case EM_GETSEL:
4892 break;
4893
4894 case EM_SETSEL:
4897 result = 1;
4898 break;
4899
4900 case EM_GETRECT:
4901 if (lParam)
4902 CopyRect((LPRECT)lParam, &es->format_rect);
4903 break;
4904
4905 case EM_SETRECT:
4906 if ((es->style & ES_MULTILINE) && lParam) {
4909 }
4910 break;
4911
4912 case EM_SETRECTNP:
4913 if ((es->style & ES_MULTILINE) && lParam)
4915 break;
4916
4917 case EM_SCROLL:
4919 break;
4920
4921 case EM_LINESCROLL:
4923 break;
4924
4925 case EM_SCROLLCARET:
4927 result = 1;
4928 break;
4929
4930 case EM_GETMODIFY:
4931 result = ((es->flags & EF_MODIFIED) != 0);
4932 break;
4933
4934 case EM_SETMODIFY:
4935 if (wParam)
4936 es->flags |= EF_MODIFIED;
4937 else
4938 es->flags &= ~(EF_MODIFIED | EF_UPDATE); /* reset pending updates */
4939 break;
4940
4941 case EM_GETLINECOUNT:
4942 result = (es->style & ES_MULTILINE) ? es->line_count : 1;
4943 break;
4944
4945 case EM_LINEINDEX:
4947 break;
4948
4949 case EM_SETHANDLE:
4951 break;
4952
4953 case EM_GETHANDLE:
4955 break;
4956
4957 case EM_GETTHUMB:
4959 break;
4960
4961 /* these messages missing from specs */
4962 case 0x00bf:
4963 case 0x00c0:
4964 case 0x00c3:
4965 case 0x00ca:
4966 FIXME("undocumented message 0x%x, please report\n", msg);
4968 break;
4969
4970 case EM_LINELENGTH:
4972 break;
4973
4974 case EM_REPLACESEL:
4975 {
4976 LPWSTR textW;
4977
4978 if(unicode)
4979 textW = (LPWSTR)lParam;
4980 else
4981 {
4983 INT countW = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
4984 if (!(textW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR)))) break;
4985 MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW);
4986 }
4987
4989 result = 1;
4990
4991 if(!unicode)
4993 break;
4994 }
4995
4996 case EM_GETLINE:
4998 break;
4999
5000 case EM_SETLIMITTEXT:
5002 break;
5003
5004 case EM_CANUNDO:
5006 break;
5007
5008 case EM_UNDO:
5009 case WM_UNDO:
5011 break;
5012
5013 case EM_FMTLINES:
5015 break;
5016
5017 case EM_LINEFROMCHAR:
5019 break;
5020
5021 case EM_SETTABSTOPS:
5023 break;
5024
5025 case EM_SETPASSWORDCHAR:
5026 {
5027 WCHAR charW = 0;
5028
5029 if(unicode)
5030 charW = (WCHAR)wParam;
5031 else
5032 {
5033 CHAR charA = wParam;
5034 MultiByteToWideChar(CP_ACP, 0, &charA, 1, &charW, 1);
5035 }
5036
5038 break;
5039 }
5040
5041 case EM_EMPTYUNDOBUFFER:
5043 break;
5044
5046 result = (es->style & ES_MULTILINE) ? es->y_offset : es->x_offset;
5047 break;
5048
5049 case EM_SETREADONLY:
5050 {
5051 DWORD old_style = es->style;
5052
5053 if (wParam) {
5056 es->style |= ES_READONLY;
5057 } else {
5060 es->style &= ~ES_READONLY;
5061 }
5062
5063 if (old_style ^ es->style)
5064 InvalidateRect(es->hwndSelf, NULL, TRUE);
5065
5066 result = 1;
5067 break;
5068 }
5069
5072 break;
5073
5075 result = (LRESULT)es->word_break_proc;
5076 break;
5077
5078 case EM_GETPASSWORDCHAR:
5079 {
5080 if(unicode)
5081 result = es->password_char;
5082 else
5083 {
5084 WCHAR charW = es->password_char;
5085 CHAR charA = 0;
5086 WideCharToMultiByte(CP_ACP, 0, &charW, 1, &charA, 1, NULL, NULL);
5087 result = charA;
5088 }
5089 break;
5090 }
5091
5092 case EM_SETMARGINS:
5094 break;
5095
5096 case EM_GETMARGINS:
5097 result = MAKELONG(es->left_margin, es->right_margin);
5098 break;
5099
5100 case EM_GETLIMITTEXT:
5101 result = es->buffer_limit;
5102 break;
5103
5104 case EM_POSFROMCHAR:
5105 if ((INT)wParam >= get_text_length(es)) result = -1;
5107 break;
5108
5109 case EM_CHARFROMPOS:
5110 result = EDIT_EM_CharFromPos(es, (short)LOWORD(lParam), (short)HIWORD(lParam));
5111 break;
5112
5113 /* End of the EM_ messages which were in numerical order; what order
5114 * are these in? vaguely alphabetical?
5115 */
5116
5117 case WM_NCCREATE:
5119 break;
5120
5121 case WM_NCDESTROY:
5123#ifdef __REACTOS__
5125#endif
5126 es = NULL;
5127 break;
5128
5129 case WM_GETDLGCODE:
5131
5132 if (es->style & ES_MULTILINE)
5134
5135 if (lParam)
5136 {
5137 es->flags|=EF_DIALOGMODE;
5138
5139 if (((LPMSG)lParam)->message == WM_KEYDOWN)
5140 {
5141 int vk = (int)((LPMSG)lParam)->wParam;
5142
5143 if (es->hwndListBox)
5144 {
5145 if (vk == VK_RETURN || vk == VK_ESCAPE)
5148 }
5149 }
5150 }
5151 break;
5152
5153 case WM_IME_CHAR:
5154#ifdef __REACTOS__
5155 /* Rely on DefWindowProc */
5156 result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
5157 break;
5158#else
5159 if (!unicode)
5160 {
5161 WCHAR charW;
5162 CHAR strng[2];
5163
5164 strng[0] = wParam >> 8;
5165 strng[1] = wParam & 0xff;
5166 if (strng[0]) MultiByteToWideChar(CP_ACP, 0, strng, 2, &charW, 1);
5167 else MultiByteToWideChar(CP_ACP, 0, &strng[1], 1, &charW, 1);
5168 result = EDIT_WM_Char(es, charW);
5169 break;
5170 }
5171 /* fall through */
5172#endif
5173 case WM_CHAR:
5174 {
5175 WCHAR charW;
5176
5177 if(unicode)
5178 charW = wParam;
5179 else
5180 {
5181 CHAR charA = wParam;
5182 MultiByteToWideChar(CP_ACP, 0, &charA, 1, &charW, 1);
5183 }
5184
5185 if (es->hwndListBox)
5186 {
5187 if (charW == VK_RETURN || charW == VK_ESCAPE)
5188 {
5191 break;
5192 }
5193 }
5194 result = EDIT_WM_Char(es, charW);
5195 break;
5196 }
5197
5198 case WM_UNICHAR:
5199 if (unicode)
5200 {
5201 if (wParam == UNICODE_NOCHAR) return TRUE;
5202 if (wParam <= 0x000fffff)
5203 {
5204 if(wParam > 0xffff) /* convert to surrogates */
5205 {
5206 wParam -= 0x10000;
5207 EDIT_WM_Char(es, (wParam >> 10) + 0xd800);
5208 EDIT_WM_Char(es, (wParam & 0x03ff) + 0xdc00);
5209 }
5210 else EDIT_WM_Char(es, wParam);
5211 }
5212 return 0;
5213 }
5214 break;
5215
5216 case WM_CLEAR:
5218 break;
5219
5220 case WM_CONTEXTMENU:
5221 EDIT_WM_ContextMenu(es, (short)LOWORD(lParam), (short)HIWORD(lParam));
5222 break;
5223
5224 case WM_COPY:
5226 break;
5227
5228 case WM_CREATE:
5229 if(unicode)
5231 else
5232 {
5233 LPCSTR nameA = ((LPCREATESTRUCTA)lParam)->lpszName;
5234 LPWSTR nameW = NULL;
5235 if(nameA)
5236 {
5237 INT countW = MultiByteToWideChar(CP_ACP, 0, nameA, -1, NULL, 0);
5238 if((nameW = HeapAlloc(GetProcessHeap(), 0, countW * sizeof(WCHAR))))
5239 MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, countW);
5240 }
5243 }
5244 break;
5245
5246 case WM_CUT:
5247 EDIT_WM_Cut(es);
5248 break;
5249
5250 case WM_ENABLE:
5251 es->bEnableState = (BOOL) wParam;
5253 break;
5254
5255 case WM_ERASEBKGND:
5256 /* we do the proper erase in EDIT_WM_Paint */
5257 result = 1;
5258 break;
5259
5260 case WM_GETFONT:
5261 result = (LRESULT)es->font;
5262 break;
5263
5264 case WM_GETTEXT:
5266 break;
5267
5268 case WM_GETTEXTLENGTH:
5269 if (unicode) result = get_text_length(es);
5271 NULL, 0, NULL, NULL );
5272 break;
5273
5274 case WM_HSCROLL:
5276 break;
5277
5278 case WM_KEYDOWN:
5280 break;
5281
5282 case WM_KILLFOCUS:
5284 break;
5285
5286 case WM_LBUTTONDBLCLK:
5288 break;
5289
5290 case WM_LBUTTONDOWN:
5292 break;
5293
5294 case WM_LBUTTONUP:
5296 break;
5297
5298 case WM_MBUTTONDOWN:
5300 break;
5301
5302 case WM_MOUSEMOVE:
5303 result = EDIT_WM_MouseMove(es, (short)LOWORD(lParam), (short)HIWORD(lParam));
5304 break;
5305
5306 case WM_PRINTCLIENT:
5307 case WM_PAINT:
5309 break;
5310
5311 case WM_PASTE:
5313 break;
5314
5315 case WM_SETFOCUS:
5317 break;
5318
5319 case WM_SETFONT:
5321 break;
5322
5323 case WM_SETREDRAW:
5324 /* FIXME: actually set an internal flag and behave accordingly */
5325 break;
5326
5327 case WM_SETTEXT:
5328 EDIT_WM_SetText(es, (LPCWSTR)lParam, unicode);
5329 result = TRUE;
5330 break;
5331
5332 case WM_SIZE:
5334 break;
5335
5336 case WM_STYLECHANGED:
5338 break;
5339
5340 case WM_STYLECHANGING:
5341 result = 0; /* See EDIT_WM_StyleChanged */
5342 break;
5343
5344 case WM_SYSKEYDOWN:
5346 break;
5347
5348 case WM_TIMER:
5350 break;
5351
5352 case WM_VSCROLL:
5354 break;
5355
5356 case WM_MOUSEWHEEL:
5357 {
5358 int wheelDelta;
5359 UINT pulScrollLines = 3;
5360 SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
5361
5362 if (wParam & (MK_SHIFT | MK_CONTROL)) {
5364 break;
5365 }
5366 wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam);
5367 /* if scrolling changes direction, ignore left overs */
5368 if ((wheelDelta < 0 && es->wheelDeltaRemainder < 0) ||
5369 (wheelDelta > 0 && es->wheelDeltaRemainder > 0))
5370 es->wheelDeltaRemainder += wheelDelta;
5371 else
5372 es->wheelDeltaRemainder = wheelDelta;
5373 if (es->wheelDeltaRemainder && pulScrollLines)
5374 {
5375 int cLineScroll;
5376 pulScrollLines = (int) min((UINT) es->line_count, pulScrollLines);
5377 cLineScroll = pulScrollLines * (float)es->wheelDeltaRemainder / WHEEL_DELTA;
5378 es->wheelDeltaRemainder -= WHEEL_DELTA * cLineScroll / (int)pulScrollLines;
5379 result = EDIT_EM_LineScroll(es, 0, -cLineScroll);
5380 }
5381 }
5382 break;
5383
5384
5385 /* IME messages to make the edit control IME aware */
5386 case WM_IME_SETCONTEXT:
5387#ifdef __REACTOS__
5388 {
5389 HKL hKL = GetKeyboardLayout(0);
5390
5391 /* Korean doesn't want composition window */
5392 if (PRIMARYLANGID(LOWORD(hKL)) == LANG_KOREAN)
5393 lParam &= ~ISC_SHOWUICOMPOSITIONWINDOW;
5394
5395 if (wParam)
5396 {
5397 HIMC hIMC = ImmGetContext(hwnd);
5399 if (pIC)
5400 {
5401 pIC->dwUIFlags &= ~0x40000;
5402 ImmUnlockIMC(hIMC);
5403 }
5404 if (GetWin32ClientInfo()->CI_flags & CI_WOW)
5406 ImmReleaseContext(hwnd, hIMC);
5407 }
5408
5410 }
5411#endif
5412 break;
5413
5414 case WM_IME_STARTCOMPOSITION:
5415#ifdef __REACTOS__
5416 {
5417 HKL hKL = GetKeyboardLayout(0);
5418
5419 /* Korean doesn't want composition window */
5420 if (PRIMARYLANGID(LOWORD(hKL)) == LANG_KOREAN)
5421 return TRUE;
5422
5423 result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
5424 }
5425#else
5426 es->composition_start = es->selection_end;
5427 es->composition_len = 0;
5428#endif
5429 break;
5430
5431 case WM_IME_COMPOSITION:
5433#ifdef __REACTOS__
5434 result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
5435#endif
5436 break;
5437
5438 case WM_IME_ENDCOMPOSITION:
5439#ifdef __REACTOS__
5440 result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
5441#else
5442 if (es->composition_len > 0)
5443 {
5445 es->selection_end = es->selection_start;
5446 es->composition_len= 0;
5447 }
5448#endif
5449 break;
5450
5452 break;
5453
5454 case WM_IME_SELECT:
5455#ifdef __REACTOS__
5456 result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
5457#endif
5458 break;
5459
5460 case WM_IME_CONTROL:
5461#ifdef __REACTOS__
5462 result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
5463#endif
5464 break;
5465
5466 case WM_IME_REQUEST:
5467 switch (wParam)
5468 {
5469 case IMR_QUERYCHARPOSITION:
5470 {
5471 LRESULT pos;
5472 IMECHARPOSITION *chpos = (IMECHARPOSITION *)lParam;
5473
5474 pos = EDIT_EM_PosFromChar(es, es->selection_start + chpos->dwCharPos, FALSE);
5475 chpos->pt.x = LOWORD(pos);
5476 chpos->pt.y = HIWORD(pos);
5477 chpos->cLineHeight = es->line_height;
5478 chpos->rcDocument = es->format_rect;
5479 MapWindowPoints(hwnd, 0, &chpos->pt, 1);
5480 MapWindowPoints(hwnd, 0, (POINT*)&chpos->rcDocument, 2);
5481 result = 1;
5482 break;
5483 }
5484 }
5485 break;
5486
5487 default:
5488 result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
5489 break;
5490 }
5491
5492#ifdef __REACTOS__
5493 /* ReactOS: check GetWindowLong in case es has been destroyed during processing */
5494 if (IsWindow(hwnd) && es && msg != EM_GETHANDLE && GetWindowLongPtrW(hwnd, 0))
5495#else
5496 if (IsWindow(hwnd) && es && msg != EM_GETHANDLE)
5497#endif
5499
5500 TRACE("hwnd=%p msg=%x (%s) -- 0x%08lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), result);
5501
5502 return result;
static const WCHAR nameW[]
Definition: main.c:49
static LRESULT EDIT_WM_LButtonDblClk(EDITSTATE *es)
Definition: edit.c:3513
static LRESULT EDIT_WM_Char(EDITSTATE *es, WCHAR c)
Definition: edit.c:3085
static LRESULT EDIT_WM_MButtonDown(EDITSTATE *es)
Definition: edit.c:3584
static BOOL EDIT_EM_FmtLines(EDITSTATE *es, BOOL add_eol)
Definition: edit.c:2389
static LRESULT EDIT_EM_CharFromPos(EDITSTATE *es, INT x, INT y)
Definition: edit.c:2361
static void EDIT_EM_SetPasswordChar(EDITSTATE *es, WCHAR c)
Definition: edit.c:2871
static INT EDIT_WM_GetText(const EDITSTATE *es, INT count, LPWSTR dst)
Definition: edit.c:3272
static void EDIT_WM_ContextMenu(EDITSTATE *es, INT x, INT y)
Definition: edit.c:3216
static LRESULT EDIT_WM_MouseMove(EDITSTATE *es, INT x, INT y)
Definition: edit.c:3596
static LRESULT EDIT_WM_NCDestroy(EDITSTATE *es)
Definition: edit.c:4695
static LRESULT EDIT_WM_LButtonDown(EDITSTATE *es, DWORD keys, INT x, INT y)
Definition: edit.c:3542
static HLOCAL EDIT_EM_GetHandle(EDITSTATE *es)
Definition: edit.c:2411
static INT EDIT_EM_GetLine(EDITSTATE *es, INT line, LPWSTR dst)
Definition: edit.c:2431
static LRESULT EDIT_WM_KillFocus(HTHEME theme, EDITSTATE *es)
Definition: edit.c:3485
static LRESULT EDIT_WM_SysKeyDown(EDITSTATE *es, INT key, DWORD key_data)
Definition: edit.c:4025
static LRESULT EDIT_EM_GetThumb(EDITSTATE *es)
Definition: edit.c:4314
static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
Definition: edit.c:4527
static LRESULT EDIT_WM_LButtonUp(EDITSTATE *es)
Definition: edit.c:3568
static void EDIT_WM_SetFocus(HTHEME theme, EDITSTATE *es)
Definition: edit.c:3779
static void EDIT_EM_SetHandle(EDITSTATE *es, HLOCAL hloc)
Definition: edit.c:2707
static LRESULT EDIT_WM_Create(EDITSTATE *es, const WCHAR *name)
Definition: edit.c:4640
static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT key)
Definition: edit.c:3348
static void EDIT_EM_SetLimitText(EDITSTATE *es, UINT limit)
Definition: edit.c:2749
static void EDIT_WM_Timer(EDITSTATE *es)
Definition: edit.c:4044
static LRESULT EDIT_EM_GetSel(const EDITSTATE *es, PUINT start, PUINT end)
Definition: edit.c:2469
static void EDIT_EM_SetWordBreakProc(EDITSTATE *es, EDITWORDBREAKPROCW wbp)
Definition: edit.c:2922
static LRESULT EDIT_WM_StyleChanged(EDITSTATE *es, WPARAM which, const STYLESTRUCT *style)
Definition: edit.c:3985
static void EDIT_WM_SetText(EDITSTATE *es, LPCWSTR text)
Definition: edit.c:3910
static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, const INT *tabs)
Definition: edit.c:2900
static void EDIT_ImeComposition(HWND hwnd, LPARAM CompFlag, EDITSTATE *es)
Definition: edit.c:4481
static void EDIT_WM_Size(EDITSTATE *es, UINT action)
Definition: edit.c:3952
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLuint64EXT * result
Definition: glext.h:11304
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
#define CPS_CANCEL
Definition: imm.h:181
BOOL WINAPI ImmNotifyIME(_In_ HIMC hIMC, _In_ DWORD dwAction, _In_ DWORD dwIndex, _In_ DWORD_PTR dwValue)
Definition: ime.c:458
LPINPUTCONTEXT WINAPI ImmLockIMC(_In_ HIMC hIMC)
Definition: imm.c:1079
#define NI_COMPOSITIONSTR
Definition: immdev.h:381
BOOL WINAPI ImmUnlockIMC(_In_ HIMC hIMC)
Definition: imm.c:1089
#define FNID_DESTROY
Definition: ntuser.h:898
#define FNID_EDIT
Definition: ntuser.h:870
#define GetWin32ClientInfo()
Definition: ntuser.h:352
#define CI_WOW
Definition: ntuser.h:302
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4348
WORD vk
Definition: input.c:77
unsigned int * PUINT
Definition: ndis.h:50
#define LRESULT
Definition: ole.h:14
#define EM_SCROLLCARET
Definition: richedit.h:81
#define WM_UNICHAR
Definition: richedit.h:67
#define EM_POSFROMCHAR
Definition: richedit.h:77
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define EM_CHARFROMPOS
Definition: richedit.h:78
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define EM_GETLIMITTEXT
Definition: richedit.h:74
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define LANG_KOREAN
Definition: nls.h:84
Definition: ntuser.h:694
DWORD fnid
Definition: ntuser.h:709
Definition: tftpd.h:60
#define WHEEL_DELTA
Definition: treelist.c:99
#define WM_MOUSEWHEEL
Definition: treelist.c:96
const char * SPY_GetMsgName(UINT msg, HWND hWnd)
Definition: spy.c:2218
#define ValidateHwnd(hwnd)
Definition: precomp.h:101
static LRESULT DefWindowProcT(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: edit.c:4840
int * LPINT
Definition: windef.h:178
#define WM_PAINT
Definition: winuser.h:1639
#define EM_SETREADONLY
Definition: winuser.h:2034
#define WM_ERASEBKGND
Definition: winuser.h:1644
#define WM_GETTEXTLENGTH
Definition: winuser.h:1638
#define EM_GETRECT
Definition: winuser.h:2015
#define WM_IME_REQUEST
Definition: winuser.h:1855
#define EM_LINEFROMCHAR
Definition: winuser.h:2020
#define WM_ENABLE
Definition: winuser.h:1634
#define WM_HSCROLL
Definition: winuser.h:1762
#define EM_GETWORDBREAKPROC
Definition: winuser.h:2018
#define EM_FMTLINES
Definition: winuser.h:2005
#define EM_GETPASSWORDCHAR
Definition: winuser.h:2014
#define WM_VSCROLL
Definition: winuser.h:1763
#define WM_CREATE
Definition: winuser.h:1627
#define DLGC_WANTCHARS
Definition: winuser.h:2637
#define EM_GETSEL
Definition: winuser.h:2016
#define EM_SETPASSWORDCHAR
Definition: winuser.h:2033
#define EM_GETMODIFY
Definition: winuser.h:2013
#define WM_SIZE
Definition: winuser.h:1630
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:2004
#define DLGC_WANTALLKEYS
Definition: winuser.h:2631
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1797
#define EM_REPLACESEL
Definition: winuser.h:2025
struct tagCREATESTRUCTA * LPCREATESTRUCTA
#define EM_SETRECT
Definition: winuser.h:2035
#define WM_SETFOCUS
Definition: winuser.h:1632
#define WM_MOUSEMOVE
Definition: winuser.h:1794
#define WM_GETTEXT
Definition: winuser.h:1637
#define WM_LBUTTONDOWN
Definition: winuser.h:1795
#define EM_LINEINDEX
Definition: winuser.h:2021
#define WM_GETFONT
Definition: winuser.h:1670
#define EM_GETFIRSTVISIBLELINE
Definition: winuser.h:2007
#define EM_GETHANDLE
Definition: winuser.h:2008
#define WM_NCCREATE
Definition: winuser.h:1702
#define WM_IME_SETCONTEXT
Definition: winuser.h:1848
#define WM_SETTEXT
Definition: winuser.h:1636
#define EM_CANUNDO
Definition: winuser.h:2002
#define EM_LINELENGTH
Definition: winuser.h:2022
#define WM_IME_CHAR
Definition: winuser.h:1853
#define EM_SETHANDLE
Definition: winuser.h:2028
#define EM_GETLINE
Definition: winuser.h:2010
#define EM_SETRECTNP
Definition: winuser.h:2036
#define MK_CONTROL
Definition: winuser.h:2389
#define EM_SETLIMITTEXT
Definition: winuser.h:2030
#define WM_SETFONT
Definition: winuser.h:1669
#define WM_TIMER
Definition: winuser.h:1761
#define DLGC_WANTARROWS
Definition: winuser.h:2629
#define EM_SCROLL
Definition: winuser.h:2026
#define EM_SETWORDBREAKPROC
Definition: winuser.h:2039
#define WM_LBUTTONUP
Definition: winuser.h:1796
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define WM_IME_COMPOSITIONFULL
Definition: winuser.h:1851
#define WM_CHAR
Definition: winuser.h:1736
#define WM_NCDESTROY
Definition: winuser.h:1703
#define EM_GETMARGINS
Definition: winuser.h:2012
#define WM_IME_CONTROL
Definition: winuser.h:1850
#define EM_SETTABSTOPS
Definition: winuser.h:2038
#define DLGC_WANTMESSAGE
Definition: winuser.h:2632
#define WM_IME_SELECT
Definition: winuser.h:1852
#define EM_GETLINECOUNT
Definition: winuser.h:2011
#define EM_SETMARGINS
Definition: winuser.h:2031
#define DLGC_HASSETSEL
Definition: winuser.h:2633
#define WM_KILLFOCUS
Definition: winuser.h:1633
#define WM_GETDLGCODE
Definition: winuser.h:1708
#define WM_MBUTTONDOWN
Definition: winuser.h:1801
#define EM_SETMODIFY
Definition: winuser.h:2032
#define WM_SETREDRAW
Definition: winuser.h:1635
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by RegisterClientPFN().

◆ get_app_version()

static DWORD get_app_version ( void  )
static

Definition at line 223 of file edit.c.

225{
226 static DWORD version;
227 if (!version)
228 {
229 DWORD dwEmulatedVersion;
231 DWORD dwProcVersion = GetProcessVersion(0);
232
233 info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
235 dwEmulatedVersion = MAKELONG( info.dwMinorVersion, info.dwMajorVersion );
236 /* FIXME: this may not be 100% correct; see discussion on the
237 * wine developer list in Nov 1999 */
238 version = dwProcVersion < dwEmulatedVersion ? dwProcVersion : dwEmulatedVersion;
239 }
240 return version;
static const WCHAR version[]
Definition: asmname.c:66
DWORD WINAPI GetProcessVersion(IN DWORD ProcessId)
Definition: proc.c:1766
BOOL WINAPI GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
Definition: version.c:37
struct _OSVERSIONINFOW OSVERSIONINFOW

Referenced by EDIT_NotifyCtlColor().

◆ get_text_length()

static UINT get_text_length ( EDITSTATE es)
inlinestatic

Definition at line 265 of file edit.c.

267{
268 if(es->text_length == (UINT)-1)
269 es->text_length = strlenW(es->text);
270 return es->text_length;

◆ get_vertical_line_count()

static INT get_vertical_line_count ( EDITSTATE es)
inlinestatic

Definition at line 505 of file edit.c.

507{
508 INT vlc = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
509 return max(1,vlc);

◆ is_cjk()

static BOOL is_cjk ( UINT  charset)
static

Definition at line 2988 of file edit.c.

2990{
2991 switch(charset)
2992 {
2993 case SHIFTJIS_CHARSET:
2994 case HANGUL_CHARSET:
2995 case GB2312_CHARSET:
2997 return TRUE;
2998 }
2999 /* HANGUL_CHARSET is strange, though treated as CJK by Win 8, it is
3000 * not by other versions including Win 10. */
3001 return FALSE;
CFF_Charset charset
Definition: cffcmap.c:138
#define HANGUL_CHARSET
Definition: wingdi.h:388
#define CHINESEBIG5_CHARSET
Definition: wingdi.h:390
#define SHIFTJIS_CHARSET
Definition: wingdi.h:386
#define GB2312_CHARSET
Definition: wingdi.h:389

◆ notify_parent()

static BOOL notify_parent ( const EDITSTATE es,
INT  code 
)
inlinestatic

Definition at line 174 of file edit.c.

174 {0};
175static inline BOOL notify_parent(const EDITSTATE *es, INT code)
176{
177 HWND hwnd = es->hwndSelf;
178 TRACE("notification %d sent to %p.\n", code, es->hwndParent);
179 SendMessageW(es->hwndParent, WM_COMMAND, MAKEWPARAM(GetWindowLongPtrW(es->hwndSelf, GWLP_ID), code), (LPARAM)es->hwndSelf);
180 return IsWindow(hwnd);
Definition: inflate.c:139
#define MAKEWPARAM(l, h)
Definition: winuser.h:4085
#define WM_COMMAND
Definition: winuser.h:1759
#define GWLP_ID
Definition: winuser.h:871

◆ text_buffer_changed()

static void text_buffer_changed ( EDITSTATE es)
inlinestatic

Definition at line 1290 of file edit.c.

1292{
1293 es->text_length = (UINT)-1;
1294
1295 HeapFree( GetProcessHeap(), 0, es->logAttr );
1296 es->logAttr = NULL;

◆ WINE_DECLARE_DEBUG_CHANNEL() [1/2]

WINE_DECLARE_DEBUG_CHANNEL ( combo  )

◆ WINE_DECLARE_DEBUG_CHANNEL() [2/2]

WINE_DECLARE_DEBUG_CHANNEL ( relay  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( edit  )

Variable Documentation

◆ EDIT_builtin_class

const struct builtin_class_descr EDIT_builtin_class
Initial value:
=
{
WINPROC_EDIT,
sizeof(EDITSTATE *) + sizeof(WORD),
0
}
static const WCHAR editW[]
Definition: edit.c:5529
#define CS_DBLCLKS
Definition: winuser.h:659
#define IDC_IBEAM
Definition: winuser.h:696
#define CS_PARENTDC
Definition: winuser.h:664

Definition at line 5530 of file edit.c.

◆ editW

const WCHAR editW[] = {'E','d','i','t',0}
static

Definition at line 5529 of file edit.c.

Referenced by create_editcontrolW().

◆ empty_stringW