ReactOS 0.4.15-dev-5858-g16decc6
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 58 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 71 of file edit.c.

◆ EF_DIALOGMODE

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

Definition at line 73 of file edit.c.

◆ EF_FOCUSED

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

Definition at line 67 of file edit.c.

◆ EF_HSCROLL_TRACK

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

Definition at line 70 of file edit.c.

◆ EF_MODIFIED

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

Definition at line 66 of file edit.c.

◆ EF_UPDATE

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

Definition at line 68 of file edit.c.

◆ EF_USE_SOFTBRK

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

Definition at line 72 of file edit.c.

◆ EF_VSCROLL_TRACK

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

Definition at line 69 of file edit.c.

◆ GROWLENGTH

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

Definition at line 59 of file edit.c.

◆ HSCROLL_FRACTION

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

Definition at line 61 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 161 of file edit.c.

◆ ROUND_TO_GROW

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

Definition at line 60 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 160 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 75 of file edit.c.

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

Function Documentation

◆ DefWindowProcT()

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

Definition at line 4748 of file edit.c.

4750{
4751 if(unicode)
4752 return DefWindowProcW(hwnd, msg, wParam, lParam);
4753 else
4754 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 2354 of file edit.c.

2356{
2357 RECT ClientRect;
2358
2359 es->format_rect.right = max(es->format_rect.right, es->format_rect.left + es->char_width);
2360 if (es->style & ES_MULTILINE)
2361 {
2362 INT fw, vlc, max_x_offset, max_y_offset;
2363
2365 es->format_rect.bottom = es->format_rect.top + vlc * es->line_height;
2366
2367 /* correct es->x_offset */
2368 fw = es->format_rect.right - es->format_rect.left;
2369 max_x_offset = es->text_width - fw;
2370 if(max_x_offset < 0) max_x_offset = 0;
2371 if(es->x_offset > max_x_offset)
2372 es->x_offset = max_x_offset;
2373
2374 /* correct es->y_offset */
2375 max_y_offset = es->line_count - vlc;
2376 if(max_y_offset < 0) max_y_offset = 0;
2377 if(es->y_offset > max_y_offset)
2378 es->y_offset = max_y_offset;
2379
2380 /* force scroll info update */
2382 }
2383 else
2384 /* Windows doesn't care to fix text placement for SL controls */
2385 es->format_rect.bottom = es->format_rect.top + es->line_height;
2386
2387 /* Always stay within the client area */
2388 GetClientRect(es->hwndSelf, &ClientRect);
2389 es->format_rect.bottom = min(es->format_rect.bottom, ClientRect.bottom);
2390
2391 if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL))
2393
2394 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:410
#define EF_AFTER_WRAP
Definition: edit.c:71
static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap)
Definition: edit.c:1715
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:425
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1552
#define es
Definition: i386-dis.c:441
#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 510 of file edit.c.

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

849{
851 if (es->ssa)
852 {
853 const SIZE *size;
854 size = ScriptString_pSize(es->ssa);
855 es->text_width = size->cx;
856 }
857 else
858 es->text_width = 0;
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, INT line)
Definition: edit.c:368
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 333 of file edit.c.

335{
336 INT ret;
337
338 if (es->word_break_proc)
339 {
340 if(es->is_unicode)
341 {
342 EDITWORDBREAKPROCW wbpW = (EDITWORDBREAKPROCW)es->word_break_proc;
343
344 TRACE_(relay)("(UNICODE wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
345 es->word_break_proc, debugstr_wn(es->text + start, count), index, count, action);
346 ret = wbpW(es->text + start, index, count, action);
347 }
348 else
349 {
350 EDITWORDBREAKPROCA wbpA = (EDITWORDBREAKPROCA)es->word_break_proc;
351 INT countA;
352 CHAR *textA;
353
354 countA = WideCharToMultiByte(CP_ACP, 0, es->text + start, count, NULL, 0, NULL, NULL);
355 textA = HeapAlloc(GetProcessHeap(), 0, countA);
356#ifdef __REACTOS__
357 /* ReactOS r33503 */
358 if (textA == NULL) return 0;
359#endif
360 WideCharToMultiByte(CP_ACP, 0, es->text + start, count, textA, countA, NULL, NULL);
361 TRACE_(relay)("(ANSI wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
362 es->word_break_proc, debugstr_an(textA, countA), index, countA, action);
363 ret = wbpA(textA, index, countA, action);
365 }
366 }
367 else
369
370 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:232
#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:7479
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:2894
int(CALLBACK * EDITWORDBREAKPROCW)(LPWSTR, int, int, int)
Definition: winuser.h:2895
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 870 of file edit.c.

872{
873 INT index;
874
875 if (es->style & ES_MULTILINE) {
876 int trailing;
877 INT line = (y - es->format_rect.top) / es->line_height + es->y_offset;
878 INT line_index = 0;
879 LINEDEF *line_def = es->first_line_def;
881 while ((line > 0) && line_def->next) {
882 line_index += line_def->length;
883 line_def = line_def->next;
884 line--;
885 }
886
887 x += es->x_offset - es->format_rect.left;
888 if (es->style & ES_RIGHT)
889 x -= (es->format_rect.right - es->format_rect.left) - line_def->width;
890 else if (es->style & ES_CENTER)
891 x -= ((es->format_rect.right - es->format_rect.left) - line_def->width) / 2;
892 if (x >= line_def->width) {
893 if (after_wrap)
894 *after_wrap = (line_def->ending == END_WRAP);
895 return line_index + line_def->net_length;
896 }
897 if (x <= 0 || !line_def->ssa) {
898 if (after_wrap)
899 *after_wrap = FALSE;
900 return line_index;
901 }
902
903 ScriptStringXtoCP(line_def->ssa, x , &index, &trailing);
904 if (trailing) index++;
905 index += line_index;
906 if (after_wrap)
907 *after_wrap = ((index == line_index + line_def->net_length) &&
908 (line_def->ending == END_WRAP));
909 } else {
910 INT xoff = 0;
911 INT trailing;
912 if (after_wrap)
913 *after_wrap = FALSE;
914 x -= es->format_rect.left;
915 if (!x)
916 return es->x_offset;
917
918 if (!es->x_offset)
919 {
920 INT indent = (es->format_rect.right - es->format_rect.left) - es->text_width;
921 if (es->style & ES_RIGHT)
922 x -= indent;
923 else if (es->style & ES_CENTER)
924 x -= indent / 2;
925 }
926
928 if (es->x_offset)
929 {
930 if (es->ssa)
931 {
932 if (es->x_offset>= get_text_length(es))
933 {
934 const SIZE *size;
935 size = ScriptString_pSize(es->ssa);
936 xoff = size->cx;
937 }
938 ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
939 }
940 else
941 xoff = 0;
942 }
943 if (x < 0)
944 {
945 if (x + xoff > 0 || !es->ssa)
946 {
947 ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
948 if (trailing) index++;
949 }
950 else
951 index = 0;
952 }
953 else
954 {
955 if (x)
956 {
957 const SIZE *size = NULL;
958 if (es->ssa)
959 size = ScriptString_pSize(es->ssa);
960 if (!size)
961 index = 0;
962 else if (x > size->cx)
964 else if (es->ssa)
965 {
966 ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
967 if (trailing) index++;
968 }
969 else
970 index = 0;
971 }
972 else
973 index = es->x_offset;
974 }
975 }
976 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:2474
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int *pX)
Definition: usp10.c:2411
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 3437 of file edit.c.

3439{
3440 HWND hLBox = es->hwndListBox;
3441 HWND hCombo;
3442 BOOL bDropped;
3443 int nEUI;
3444
3445 if (!hLBox)
3446 return FALSE;
3447
3448 hCombo = GetParent(es->hwndSelf);
3449 bDropped = TRUE;
3450 nEUI = 0;
3451
3452 TRACE_(combo)("[%p]: handling msg %x (%x)\n", es->hwndSelf, msg, key);
3453
3454 if (key == VK_UP || key == VK_DOWN)
3455 {
3456 if (SendMessageW(hCombo, CB_GETEXTENDEDUI, 0, 0))
3457 nEUI = 1;
3458
3459 if (msg == WM_KEYDOWN || nEUI)
3460 bDropped = (BOOL)SendMessageW(hCombo, CB_GETDROPPEDSTATE, 0, 0);
3461 }
3462
3463 switch (msg)
3464 {
3465 case WM_KEYDOWN:
3466 if (!bDropped && nEUI && (key == VK_UP || key == VK_DOWN))
3467 {
3468 /* make sure ComboLBox pops up */
3469 SendMessageW(hCombo, CB_SETEXTENDEDUI, FALSE, 0);
3470 key = VK_F4;
3471 nEUI = 2;
3472 }
3473
3474 SendMessageW(hLBox, WM_KEYDOWN, key, 0);
3475 break;
3476
3477 case WM_SYSKEYDOWN: /* Handle Alt+up/down arrows */
3478 if (nEUI)
3479 SendMessageW(hCombo, CB_SHOWDROPDOWN, !bDropped, 0);
3480 else
3481 SendMessageW(hLBox, WM_KEYDOWN, VK_F4, 0);
3482 break;
3483 }
3484
3485 if(nEUI == 2)
3486 SendMessageW(hCombo, CB_SETEXTENDEDUI, TRUE, 0);
3487
3488 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:1960
#define VK_UP
Definition: winuser.h:2215
#define VK_F4
Definition: winuser.h:2248
#define CB_GETDROPPEDSTATE
Definition: winuser.h:1935
HWND WINAPI GetParent(_In_ HWND)
#define CB_GETEXTENDEDUI
Definition: winuser.h:1938
#define VK_DOWN
Definition: winuser.h:2217
#define WM_KEYDOWN
Definition: winuser.h:1705
#define CB_SETEXTENDEDUI
Definition: winuser.h:1954
#define WM_SYSKEYDOWN
Definition: winuser.h:1709
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 987 of file edit.c.

989{
990 *x = min(max(*x, es->format_rect.left), es->format_rect.right - 1);
991 *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 3314 of file edit.c.

3316{
3317 switch (id) {
3318 case EM_UNDO:
3319 SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
3320 break;
3321 case WM_CUT:
3322 SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
3323 break;
3324 case WM_COPY:
3325 SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
3326 break;
3327 case WM_PASTE:
3328 SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3329 break;
3330 case WM_CLEAR:
3331 SendMessageW(es->hwndSelf, WM_CLEAR, 0, 0);
3332 break;
3333 case EM_SETSEL:
3334 SendMessageW(es->hwndSelf, EM_SETSEL, 0, -1);
3335 break;
3336 default:
3337 ERR("unknown menu item, please report\n");
3338 break;
3339 }
#define ERR(fmt,...)
Definition: debug.h:110
#define WM_PASTE
Definition: winuser.h:1853
#define WM_CUT
Definition: winuser.h:1851
#define WM_UNDO
Definition: winuser.h:1855
#define EM_UNDO
Definition: winuser.h:2011
#define EM_SETSEL
Definition: winuser.h:2008
#define WM_COPY
Definition: winuser.h:1852
#define WM_CLEAR
Definition: winuser.h:1854

◆ EDIT_EM_CanUndo()

static BOOL EDIT_EM_CanUndo ( const EDITSTATE es)
inlinestatic

Definition at line 179 of file edit.c.

181{
182 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 2454 of file edit.c.

2456{
2457 POINT pt;
2458 RECT rc;
2459 INT index;
2460
2461 pt.x = x;
2462 pt.y = y;
2463 GetClientRect(es->hwndSelf, &rc);
2464 if (!PtInRect(&rc, pt))
2465 return -1;
2466
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:780
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:909
#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 190 of file edit.c.

192{
193 es->undo_insert_count = 0;
194 *es->undo_text = '\0';

◆ EDIT_EM_FmtLines()

static BOOL EDIT_EM_FmtLines ( EDITSTATE es,
BOOL  add_eol 
)
static

Definition at line 2482 of file edit.c.

2484{
2485 es->flags &= ~EF_USE_SOFTBRK;
2486 if (add_eol) {
2487 es->flags |= EF_USE_SOFTBRK;
2488 FIXME("soft break enabled, not implemented\n");
2489 }
2490 return add_eol;
#define EF_USE_SOFTBRK
Definition: edit.c:72

◆ EDIT_EM_GetHandle()

static HLOCAL EDIT_EM_GetHandle ( EDITSTATE es)
static

Definition at line 2504 of file edit.c.

2506{
2507 HLOCAL hLocal;
2508
2509 if (!(es->style & ES_MULTILINE))
2510 return 0;
2511
2512 if(es->is_unicode)
2513 hLocal = es->hloc32W;
2514 else
2515 {
2516 if(!es->hloc32A)
2517 {
2518 CHAR *textA;
2519 UINT countA, alloc_size;
2520 TRACE("Allocating 32-bit ANSI alias buffer\n");
2521 countA = WideCharToMultiByte(CP_ACP, 0, es->text, -1, NULL, 0, NULL, NULL);
2522 alloc_size = ROUND_TO_GROW(countA);
2523 if(!(es->hloc32A = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, alloc_size)))
2524 {
2525 ERR("Could not allocate %d bytes for 32-bit ANSI alias buffer\n", alloc_size);
2526 return 0;
2527 }
2528 textA = LocalLock(es->hloc32A);
2529 WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, countA, NULL, NULL);
2530 LocalUnlock(es->hloc32A);
2531 }
2532 hLocal = es->hloc32A;
2533 }
2534
2536
2537 /* The text buffer handle belongs to the app */
2538 es->hlocapp = hLocal;
2539
2540 TRACE("Returning %p, LocalSize() = %ld\n", hLocal, LocalSize(hLocal));
2541 return hLocal;
#define ROUND_TO_GROW(size)
Definition: edit.c:60
static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
Definition: edit.c:1222
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1599
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777
unsigned int UINT
Definition: ndis.h:50
#define TRACE(s)
Definition: solgame.cpp:4
#define LMEM_MOVEABLE
Definition: winbase.h:369
#define LMEM_ZEROINIT
Definition: winbase.h:375

◆ EDIT_EM_GetLine()

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

Definition at line 2549 of file edit.c.

2551{
2552 LPWSTR src;
2553 INT line_len, dst_len;
2554 INT i;
2555
2556 if (es->style & ES_MULTILINE) {
2557 if (line >= es->line_count)
2558 return 0;
2559 } else
2560 line = 0;
2562 src = es->text + i;
2563 line_len = EDIT_EM_LineLength(es, i);
2564 dst_len = *(WORD *)dst;
2565 if(unicode)
2566 {
2567 if(dst_len <= line_len)
2568 {
2569 memcpy(dst, src, dst_len * sizeof(WCHAR));
2570 return dst_len;
2571 }
2572 else /* Append 0 if enough space */
2573 {
2574 memcpy(dst, src, line_len * sizeof(WCHAR));
2575 dst[line_len] = 0;
2576 return line_len;
2577 }
2578 }
2579 else
2580 {
2581 INT ret = WideCharToMultiByte(CP_ACP, 0, src, line_len, (LPSTR)dst, dst_len, NULL, NULL);
2582 if(!ret && line_len) /* Insufficient buffer size */
2583 return dst_len;
2584 if(ret < dst_len) /* Append 0 if enough space */
2585 ((LPSTR)dst)[ret] = 0;
2586 return ret;
2587 }
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:938
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:973
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 2595 of file edit.c.

2597{
2598 UINT s = es->selection_start;
2599 UINT e = es->selection_end;
2600
2601 ORDER_UINT(s, e);
2602 if (start)
2603 *start = s;
2604 if (end)
2605 *end = e;
2606 return MAKELONG(s, e);
#define ORDER_UINT(x, y)
Definition: edit.c:160
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 4402 of file edit.c.

4404{
static LRESULT EDIT_WM_HScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:3932
static LRESULT EDIT_WM_VScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:4064
#define EM_GETTHUMB
Definition: winuser.h:1988

◆ EDIT_EM_LineFromChar()

static INT EDIT_EM_LineFromChar ( EDITSTATE es,
INT  index 
)
static

Definition at line 999 of file edit.c.

1001{
1002 INT line;
1003 LINEDEF *line_def;
1004
1005 if (!(es->style & ES_MULTILINE))
1006 return 0;
1007 if (index > (INT)get_text_length(es))
1008 return es->line_count - 1;
1009 if (index == -1)
1010 index = min(es->selection_start, es->selection_end);
1011
1012 line = 0;
1013 line_def = es->first_line_def;
1014 index -= line_def->length;
1015 while ((index >= 0) && line_def->next) {
1016 line++;
1017 line_def = line_def->next;
1018 index -= line_def->length;
1019 }
1020 return line;

◆ EDIT_EM_LineIndex()

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

Definition at line 1028 of file edit.c.

1030{
1031 INT line_index;
1032 const LINEDEF *line_def;
1033
1034 if (!(es->style & ES_MULTILINE))
1035 return 0;
1036 if (line >= es->line_count)
1037 return -1;
1038
1039 line_index = 0;
1040 line_def = es->first_line_def;
1041 if (line == -1) {
1042 INT index = es->selection_end - line_def->length;
1043 while ((index >= 0) && line_def->next) {
1044 line_index += line_def->length;
1045 line_def = line_def->next;
1046 index -= line_def->length;
1047 }
1048 } else {
1049 while (line > 0) {
1050 line_index += line_def->length;
1051 line_def = line_def->next;
1052 line--;
1053 }
1054 }
1055 return line_index;

◆ EDIT_EM_LineLength()

static INT EDIT_EM_LineLength ( EDITSTATE es,
INT  index 
)
static

Definition at line 1063 of file edit.c.

1065{
1066 LINEDEF *line_def;
1067
1068 if (!(es->style & ES_MULTILINE))
1069 return get_text_length(es);
1070
1071 if (index == -1) {
1072 /* get the number of remaining non-selected chars of selected lines */
1073 INT32 l; /* line number */
1074 INT32 li; /* index of first char in line */
1075 INT32 count;
1076 l = EDIT_EM_LineFromChar(es, es->selection_start);
1077 /* # chars before start of selection area */
1078 count = es->selection_start - EDIT_EM_LineIndex(es, l);
1079 l = EDIT_EM_LineFromChar(es, es->selection_end);
1080 /* # chars after end of selection */
1082 count += li + EDIT_EM_LineLength(es, li) - es->selection_end;
1083 return count;
1084 }
1085 line_def = es->first_line_def;
1086 index -= line_def->length;
1087 while ((index >= 0) && line_def->next) {
1088 line_def = line_def->next;
1089 index -= line_def->length;
1090 }
1091 return line_def->net_length;
signed int INT32
r l[0]
Definition: byte_order.h:167
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 1799 of file edit.c.

1801{
1802 if (!(es->style & ES_MULTILINE))
1803 return FALSE;
1804
1805 dx *= es->char_width;
static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1593
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 1743 of file edit.c.

1745{
1746 INT nyoff;
1747 INT x_offset_in_pixels;
1748 INT lines_per_page = (es->format_rect.bottom - es->format_rect.top) /
1749 es->line_height;
1750
1751 if (es->style & ES_MULTILINE)
1752 {
1753 x_offset_in_pixels = es->x_offset;
1754 }
1755 else
1756 {
1757 dy = 0;
1758 x_offset_in_pixels = (short)LOWORD(EDIT_EM_PosFromChar(es, es->x_offset, FALSE));
1759 }
1760
1761 if (-dx > x_offset_in_pixels)
1762 dx = -x_offset_in_pixels;
1763 if (dx > es->text_width - x_offset_in_pixels)
1764 dx = es->text_width - x_offset_in_pixels;
1765 nyoff = max(0, es->y_offset + dy);
1766 if (nyoff >= es->line_count - lines_per_page)
1767 nyoff = max(0, es->line_count - lines_per_page);
1768 dy = (es->y_offset - nyoff) * es->line_height;
1769 if (dx || dy) {
1770 RECT rc1;
1771 RECT rc;
1772
1773 es->y_offset = nyoff;
1774 if(es->style & ES_MULTILINE)
1775 es->x_offset += dx;
1776 else
1777 es->x_offset += dx / es->char_width;
1778
1779 GetClientRect(es->hwndSelf, &rc1);
1780 IntersectRect(&rc, &rc1, &es->format_rect);
1781 ScrollWindowEx(es->hwndSelf, -dx, dy,
1782 NULL, &rc, NULL, NULL, SW_INVALIDATE);
1783 /* force scroll info update */
1785 }
1786 if (dx && !(es->flags & EF_HSCROLL_TRACK))
1788 if (dy && !(es->flags & EF_VSCROLL_TRACK))
1790 return TRUE;
static BOOL notify_parent(const EDITSTATE *es, INT code)
Definition: edit.c:162
#define EF_HSCROLL_TRACK
Definition: edit.c:70
#define EF_VSCROLL_TRACK
Definition: edit.c:69
#define SW_INVALIDATE
Definition: winuser.h:2569
#define EN_HSCROLL
Definition: winuser.h:2014
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define EN_VSCROLL
Definition: winuser.h:2019
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 1099 of file edit.c.

1101{
1103 INT l;
1104 INT li;
1105 INT x = 0;
1106 INT y = 0;
1107 INT w;
1108 INT lw;
1109 LINEDEF *line_def;
1110
1111 index = min(index, len);
1112 if (es->style & ES_MULTILINE) {
1115
1116 y = (l - es->y_offset) * es->line_height;
1118 if (after_wrap && (li == index) && l) {
1119 INT l2 = l - 1;
1120 line_def = es->first_line_def;
1121 while (l2) {
1122 line_def = line_def->next;
1123 l2--;
1124 }
1125 if (line_def->ending == END_WRAP) {
1126 l--;
1127 y -= es->line_height;
1129 }
1130 }
1131
1132 line_def = es->first_line_def;
1133 while (line_def->index != li)
1134 line_def = line_def->next;
1135
1136 lw = line_def->width;
1137 w = es->format_rect.right - es->format_rect.left;
1138 if (line_def->ssa)
1139 {
1140 ScriptStringCPtoX(line_def->ssa, (index - 1) - li, TRUE, &x);
1141 x -= es->x_offset;
1142 }
1143 else
1144#ifdef __REACTOS__ /* CORE-15780 */
1145 x = (lw > 0 ? es->x_offset : x - es->x_offset);
1146#else
1147 x = es->x_offset;
1148#endif
1149
1150 if (es->style & ES_RIGHT)
1151 x = w - (lw - x);
1152 else if (es->style & ES_CENTER)
1153 x += (w - lw) / 2;
1154 } else {
1155 INT xoff = 0;
1156 INT xi = 0;
1158 if (es->x_offset)
1159 {
1160 if (es->ssa)
1161 {
1162 if (es->x_offset >= get_text_length(es))
1163 {
1164 int leftover = es->x_offset - get_text_length(es);
1165 if (es->ssa)
1166 {
1167 const SIZE *size;
1168 size = ScriptString_pSize(es->ssa);
1169 xoff = size->cx;
1170 }
1171 else
1172 xoff = 0;
1173 xoff += es->char_width * leftover;
1174 }
1175 else
1176 ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
1177 }
1178 else
1179 xoff = 0;
1180 }
1181 if (index)
1182 {
1183 if (index >= get_text_length(es))
1184 {
1185 if (es->ssa)
1186 {
1187 const SIZE *size;
1188 size = ScriptString_pSize(es->ssa);
1189 xi = size->cx;
1190 }
1191 else
1192 xi = 0;
1193 }
1194 else if (es->ssa)
1195 ScriptStringCPtoX(es->ssa, index, FALSE, &xi);
1196 else
1197 xi = 0;
1198 }
1199 x = xi - xoff;
1200
1201 if (index >= es->x_offset) {
1202 if (!es->x_offset && (es->style & (ES_RIGHT | ES_CENTER)))
1203 {
1204 w = es->format_rect.right - es->format_rect.left;
1205 if (w > es->text_width)
1206 {
1207 if (es->style & ES_RIGHT)
1208 x += w - es->text_width;
1209 else if (es->style & ES_CENTER)
1210 x += (w - es->text_width) / 2;
1211 }
1212 }
1213 }
1214 y = 0;
1215 }
1216 x += es->format_rect.left;
1217 y += es->format_rect.top;
1218 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 2616 of file edit.c.

2618{
2619 UINT strl = strlenW(lpsz_replace);
2620 UINT tl = get_text_length(es);
2621 UINT utl;
2622 UINT s;
2623 UINT e;
2624 UINT i;
2625 UINT size;
2626 LPWSTR p;
2627 HRGN hrgn = 0;
2628 LPWSTR buf = NULL;
2629 UINT bufl;
2630
2631 TRACE("%s, can_undo %d, send_update %d\n",
2632 debugstr_w(lpsz_replace), can_undo, send_update);
2633
2634 s = es->selection_start;
2635 e = es->selection_end;
2636
2638 if ((s == e) && !strl)
2639 return;
2640
2641 ORDER_UINT(s, e);
2642
2643 size = tl - (e - s) + strl;
2644 if (!size)
2645 es->text_width = 0;
2646
2647 /* Issue the EN_MAXTEXT notification and continue with replacing text
2648 * so that buffer limit is honored. */
2649 if ((honor_limit) && (size > es->buffer_limit))
2650 {
2651 if (!notify_parent(es, EN_MAXTEXT)) return;
2652 /* Buffer limit can be smaller than the actual length of text in combobox */
2653 if (es->buffer_limit < (tl - (e-s)))
2654 strl = 0;
2655 else
2656 strl = min(strl, es->buffer_limit - (tl - (e-s)));
2657 }
2658
2659 if (!EDIT_MakeFit(es, tl - (e - s) + strl))
2660 return;
2661
2662 if (e != s) {
2663 /* there is something to be deleted */
2664 TRACE("deleting stuff.\n");
2665 bufl = e - s;
2666 buf = HeapAlloc(GetProcessHeap(), 0, (bufl + 1) * sizeof(WCHAR));
2667 if (!buf) return;
2668 memcpy(buf, es->text + s, bufl * sizeof(WCHAR));
2669 buf[bufl] = 0; /* ensure 0 termination */
2670 /* now delete */
2671 strcpyW(es->text + s, es->text + e);
2673 }
2674 if (strl) {
2675 /* there is an insertion */
2676 tl = get_text_length(es);
2677 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));
2678 for (p = es->text + tl ; p >= es->text + s ; p--)
2679 p[strl] = p[0];
2680 for (i = 0 , p = es->text + s ; i < strl ; i++)
2681 p[i] = lpsz_replace[i];
2682 if(es->style & ES_UPPERCASE)
2683 CharUpperBuffW(p, strl);
2684 else if(es->style & ES_LOWERCASE)
2685 CharLowerBuffW(p, strl);
2687 }
2688 if (es->style & ES_MULTILINE)
2689 {
2690 INT st = min(es->selection_start, es->selection_end);
2692
2693 hrgn = CreateRectRgn(0, 0, 0, 0);
2694 EDIT_BuildLineDefs_ML(es, st, st + strl,
2695 strl - abs(es->selection_end - es->selection_start), hrgn);
2696 /* if text is too long undo all changes */
2697 if (honor_limit && !(es->style & ES_AUTOVSCROLL) && (es->line_count > vlc)) {
2698 if (strl)
2699 strcpyW(es->text + e, es->text + e + strl);
2700 if (e != s)
2701 for (i = 0 , p = es->text ; i < e - s ; i++)
2702 p[i + s] = buf[i];
2705 abs(es->selection_end - es->selection_start) - strl, hrgn);
2706 strl = 0;
2707 e = s;
2708 hrgn = CreateRectRgn(0, 0, 0, 0);
2709 if (!notify_parent(es, EN_MAXTEXT)) return;
2710 }
2711 }
2712 else {
2713 INT fw = es->format_rect.right - es->format_rect.left;
2716 /* remove chars that don't fit */
2717 if (honor_limit && !(es->style & ES_AUTOHSCROLL) && (es->text_width > fw)) {
2718 while ((es->text_width > fw) && s + strl >= s) {
2719 strcpyW(es->text + s + strl - 1, es->text + s + strl);
2720 strl--;
2721 es->text_length = -1;
2724 }
2726 if (!notify_parent(es, EN_MAXTEXT)) return;
2727 }
2728 }
2729
2730 if (e != s) {
2731 if (can_undo) {
2732 utl = strlenW(es->undo_text);
2733 if (!es->undo_insert_count && (*es->undo_text && (s == es->undo_position))) {
2734 /* undo-buffer is extended to the right */
2735 EDIT_MakeUndoFit(es, utl + e - s);
2736 memcpy(es->undo_text + utl, buf, (e - s)*sizeof(WCHAR));
2737 (es->undo_text + utl)[e - s] = 0; /* ensure 0 termination */
2738 } else if (!es->undo_insert_count && (*es->undo_text && (e == es->undo_position))) {
2739 /* undo-buffer is extended to the left */
2740 EDIT_MakeUndoFit(es, utl + e - s);
2741 for (p = es->undo_text + utl ; p >= es->undo_text ; p--)
2742 p[e - s] = p[0];
2743 for (i = 0 , p = es->undo_text ; i < e - s ; i++)
2744 p[i] = buf[i];
2745 es->undo_position = s;
2746 } else {
2747 /* new undo-buffer */
2748 EDIT_MakeUndoFit(es, e - s);
2749 memcpy(es->undo_text, buf, (e - s)*sizeof(WCHAR));
2750 es->undo_text[e - s] = 0; /* ensure 0 termination */
2751 es->undo_position = s;
2752 }
2753 /* any deletion makes the old insertion-undo invalid */
2754 es->undo_insert_count = 0;
2755 } else
2757 }
2758 if (strl) {
2759 if (can_undo) {
2760 if ((s == es->undo_position) ||
2761 ((es->undo_insert_count) &&
2762 (s == es->undo_position + es->undo_insert_count)))
2763 /*
2764 * insertion is new and at delete position or
2765 * an extension to either left or right
2766 */
2767 es->undo_insert_count += strl;
2768 else {
2769 /* new insertion undo */
2770 es->undo_position = s;
2771 es->undo_insert_count = strl;
2772 /* new insertion makes old delete-buffer invalid */
2773 *es->undo_text = '\0';
2774 }
2775 } else
2777 }
2778
2780
2781 s += strl;
2782
2783 /* If text has been deleted and we're right or center aligned then scroll rightward */
2784 if (es->style & (ES_RIGHT | ES_CENTER))
2785 {
2786 INT delta = strl - abs(es->selection_end - es->selection_start);
2787
2788 if (delta < 0 && es->x_offset)
2789 {
2790 if (abs(delta) > es->x_offset)
2791 es->x_offset = 0;
2792 else
2793 es->x_offset += delta;
2794 }
2795 }
2796
2798 es->flags |= EF_MODIFIED;
2799 if (send_update) es->flags |= EF_UPDATE;
2800 if (hrgn)
2801 {
2804 }
2805 else
2807
2809
2810 /* force scroll info update */
2812
2813
2814 if(send_update || (es->flags & EF_UPDATE))
2815 {
2816 es->flags &= ~EF_UPDATE;
2817 if (!notify_parent(es, EN_CHANGE)) return;
2818 }
#define EF_MODIFIED
Definition: edit.c:66
static void EDIT_CalcLineWidth_SL(EDITSTATE *es)
Definition: edit.c:757
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1729
#define EF_UPDATE
Definition: edit.c:68
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:311
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:188
static void text_buffer_changed(EDITSTATE *es)
Definition: edit.c:1190
static BOOL EDIT_MakeFit(EDITSTATE *es, UINT size)
Definition: edit.c:1268
static BOOL EDIT_MakeUndoFit(EDITSTATE *es, UINT size)
Definition: edit.c:1309
static void EDIT_UpdateTextRegion(EDITSTATE *es, HRGN hrgn, BOOL bErase)
Definition: edit.c:1336
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1351
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1481
#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:29
#define EN_MAXTEXT
Definition: winuser.h:2016
DWORD WINAPI CharUpperBuffW(_Inout_updates_(cchLength) LPWSTR lpsz, _In_ DWORD cchLength)
#define EN_CHANGE
Definition: winuser.h:2012
DWORD WINAPI CharLowerBuffW(_Inout_updates_(cchLength) LPWSTR lpsz, _In_ DWORD cchLength)

◆ EDIT_EM_Scroll()

static LRESULT EDIT_EM_Scroll ( EDITSTATE es,
INT  action 
)
static

Definition at line 1814 of file edit.c.

1816{
1817 INT dy;
1818
1819 if (!(es->style & ES_MULTILINE))
1820 return (LRESULT)FALSE;
1821
1822 dy = 0;
1823
1824 switch (action) {
1825 case SB_LINEUP:
1826 if (es->y_offset)
1827 dy = -1;
1828 break;
1829 case SB_LINEDOWN:
1830 if (es->y_offset < es->line_count - 1)
1831 dy = 1;
1832 break;
1833 case SB_PAGEUP:
1834 if (es->y_offset)
1835 dy = -(es->format_rect.bottom - es->format_rect.top) / es->line_height;
1836 break;
1837 case SB_PAGEDOWN:
1838 if (es->y_offset < es->line_count - 1)
1839 dy = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
1840 break;
1841 default:
1843 }
1844 if (dy) {
1846 /* check if we are going to move too far */
1847 if(es->y_offset + dy > es->line_count - vlc)
1848 dy = max(es->line_count - vlc, 0) - es->y_offset;
1849
1850 /* Notification is done in EDIT_EM_LineScroll */
1851 if(dy) {
1853 return MAKELONG(dy, TRUE);
1854 }
1855
1856 }
1857 return (LRESULT)FALSE;
return
Definition: dirsup.c:529
static BOOL EDIT_EM_LineScroll(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1649
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 1879 of file edit.c.

1881{
1882 if (es->style & ES_MULTILINE) {
1883 INT l;
1884 INT vlc;
1885 INT ww;
1886 INT cw = es->char_width;
1887 INT x;
1888 INT dy = 0;
1889 INT dx = 0;
1890
1891 l = EDIT_EM_LineFromChar(es, es->selection_end);
1892 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP));
1894 if (l >= es->y_offset + vlc)
1895 dy = l - vlc + 1 - es->y_offset;
1896 if (l < es->y_offset)
1897 dy = l - es->y_offset;
1898 ww = es->format_rect.right - es->format_rect.left;
1899 if (x < es->format_rect.left)
1900 dx = x - es->format_rect.left - ww / HSCROLL_FRACTION / cw * cw;
1901 if (x > es->format_rect.right)
1902 dx = x - es->format_rect.left - (HSCROLL_FRACTION - 1) * ww / HSCROLL_FRACTION / cw * cw;
1903 if (dy || dx || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1904 {
1905 /* check if we are going to move too far */
1906 if(es->x_offset + dx + ww > es->text_width)
1907 dx = es->text_width - ww - es->x_offset;
1908 if(dx || dy || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1910 }
1911 } else {
1912 INT x;
1913 INT goal;
1914 INT format_width;
1915
1916 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1917 format_width = es->format_rect.right - es->format_rect.left;
1918 if (x < es->format_rect.left) {
1919 goal = es->format_rect.left + format_width / HSCROLL_FRACTION;
1920 do {
1921 es->x_offset--;
1922 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1923 } while ((x < goal) && es->x_offset);
1924 /* FIXME: use ScrollWindow() somehow to improve performance */
1926 } else if (x > es->format_rect.right) {
1927 INT x_last;
1929 goal = es->format_rect.right - format_width / HSCROLL_FRACTION;
1930 do {
1931 es->x_offset++;
1932 x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1934 } while ((x > goal) && (x_last > es->format_rect.right));
1935 /* FIXME: use ScrollWindow() somehow to improve performance */
1937 }
1938 }
1939
1940 if(es->flags & EF_FOCUSED)
1941 EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP);
#define EF_FOCUSED
Definition: edit.c:67
#define HSCROLL_FRACTION
Definition: edit.c:61

◆ EDIT_EM_SetHandle()

static void EDIT_EM_SetHandle ( EDITSTATE es,
HLOCAL  hloc 
)
static

Definition at line 2829 of file edit.c.

2831{
2832 if (!(es->style & ES_MULTILINE))
2833 return;
2834
2835 if (!hloc) {
2836 WARN("called with NULL handle\n");
2837 return;
2838 }
2839
2841
2842 if(es->is_unicode)
2843 {
2844 if(es->hloc32A)
2845 {
2846 LocalFree(es->hloc32A);
2847 es->hloc32A = NULL;
2848 }
2849 es->hloc32W = hloc;
2850 }
2851 else
2852 {
2853 INT countW, countA;
2854 HLOCAL hloc32W_new;
2855 WCHAR *textW;
2856 CHAR *textA;
2857
2858 countA = LocalSize(hloc);
2859 textA = LocalLock(hloc);
2860 countW = MultiByteToWideChar(CP_ACP, 0, textA, countA, NULL, 0);
2861 if(!(hloc32W_new = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, countW * sizeof(WCHAR))))
2862 {
2863 ERR("Could not allocate new unicode buffer\n");
2864 return;
2865 }
2866 textW = LocalLock(hloc32W_new);
2867 MultiByteToWideChar(CP_ACP, 0, textA, countA, textW, countW);
2868 LocalUnlock(hloc32W_new);
2869 LocalUnlock(hloc);
2870
2871 if(es->hloc32W)
2872 LocalFree(es->hloc32W);
2873
2874 es->hloc32W = hloc32W_new;
2875 es->hloc32A = hloc;
2876 }
2877
2878 es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1;
2879
2880 /* The text buffer handle belongs to the control */
2881 es->hlocapp = NULL;
2882
2885
2886 es->x_offset = es->y_offset = 0;
2887 es->selection_start = es->selection_end = 0;
2889 es->flags &= ~EF_MODIFIED;
2890 es->flags &= ~EF_UPDATE;
2894 /* force scroll info update */
#define WARN(fmt,...)
Definition: debug.h:112
static void EDIT_LockBuffer(EDITSTATE *es)
Definition: edit.c:1203
#define MultiByteToWideChar
Definition: compat.h:110
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
static const WCHAR textW[]
Definition: itemdlg.c:1559

◆ EDIT_EM_SetLimitText()

static void EDIT_EM_SetLimitText ( EDITSTATE es,
UINT  limit 
)
static

Definition at line 2905 of file edit.c.

2907{
2908 if (!limit) limit = ~0u;
2909 if (!(es->style & ES_MULTILINE)) limit = min(limit, 0x7ffffffe);
2910 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 2941 of file edit.c.

2944{
2946 INT default_left_margin = 0; /* in pixels */
2947 INT default_right_margin = 0; /* in pixels */
2948
2949 /* Set the default margins depending on the font */
2950 if (es->font && (left == EC_USEFONTINFO || right == EC_USEFONTINFO)) {
2951 HDC dc = GetDC(es->hwndSelf);
2952 HFONT old_font = SelectObject(dc, es->font);
2954 RECT rc;
2955
2956 /* The default margins are only non zero for TrueType or Vector fonts */
2957 if (tm.tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE )) {
2958 if (!is_cjk(tm.tmCharSet)) {
2959 default_left_margin = width / 2;
2960 default_right_margin = width / 2;
2961
2962 GetClientRect(es->hwndSelf, &rc);
2963 if (rc.right - rc.left < (width / 2 + width) * 2 &&
2964 (width >= 28 || !IsRectEmpty(&rc)) ) {
2965 default_left_margin = es->left_margin;
2966 default_right_margin = es->right_margin;
2967 }
2968 } else {
2969 /* FIXME: figure out the CJK values. They are not affected by the client rect. */
2970 default_left_margin = width / 2;
2971 default_right_margin = width / 2;
2972 }
2973 }
2974 SelectObject(dc, old_font);
2975 ReleaseDC(es->hwndSelf, dc);
2976 }
2977
2978 if (action & EC_LEFTMARGIN) {
2979 es->format_rect.left -= es->left_margin;
2980 if (left != EC_USEFONTINFO)
2981 es->left_margin = left;
2982 else
2983 es->left_margin = default_left_margin;
2984 es->format_rect.left += es->left_margin;
2985 }
2986
2987 if (action & EC_RIGHTMARGIN) {
2988 es->format_rect.right += es->right_margin;
2989 if (right != EC_USEFONTINFO)
2990 es->right_margin = right;
2991 else
2992 es->right_margin = default_right_margin;
2993 es->format_rect.right -= es->right_margin;
2994 }
2995
2998 if (repaint) EDIT_UpdateText(es, NULL, TRUE);
2999 }
3000
3001 TRACE("left=%d, right=%d\n", es->left_margin, es->right_margin);
static void EDIT_AdjustFormatRect(EDITSTATE *es)
Definition: edit.c:2204
GLint GLint GLsizei width
Definition: gl.h:1546
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
static const WCHAR dc[]
static HDC
Definition: imagelist.c:92
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:2145
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#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:2597
#define EC_USEFONTINFO
Definition: winuser.h:2598
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
HDC WINAPI GetDC(_In_opt_ HWND)
#define EC_LEFTMARGIN
Definition: winuser.h:2596

◆ EDIT_EM_SetPasswordChar()

static void EDIT_EM_SetPasswordChar ( EDITSTATE es,
WCHAR  c 
)
static

Definition at line 3009 of file edit.c.

3011{
3012 LONG style;
3013
3014 if (es->style & ES_MULTILINE)
3015 return;
3016
3017 if (es->password_char == c)
3018 return;
3019
3020 style = GetWindowLongW( es->hwndSelf, GWL_STYLE );
3021 es->password_char = c;
3022 if (c) {
3023 SetWindowLongW( es->hwndSelf, GWL_STYLE, style | ES_PASSWORD );
3024 es->style |= ES_PASSWORD;
3025 } else {
3026 SetWindowLongW( es->hwndSelf, GWL_STYLE, style & ~ES_PASSWORD );
3027 es->style &= ~ES_PASSWORD;
3028 }
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:846

◆ EDIT_EM_SetSel()

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

Definition at line 1636 of file edit.c.

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

◆ EDIT_EM_SetTabStops()

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

Definition at line 3038 of file edit.c.

3040{
3041 if (!(es->style & ES_MULTILINE))
3042 return FALSE;
3043 HeapFree(GetProcessHeap(), 0, es->tabs);
3044 es->tabs_count = count;
3045 if (!count)
3046 es->tabs = NULL;
3047 else {
3048 es->tabs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
3049#ifdef __REACTOS__
3050 /* ReactOS r33503 */
3051 if (es->tabs == NULL)
3052 {
3053 es->tabs_count = 0;
3054 return FALSE;
3055 }
3056#endif
3057 memcpy(es->tabs, tabs, count * sizeof(INT));
3058 }
3060 return TRUE;

◆ EDIT_EM_SetWordBreakProc()

static void EDIT_EM_SetWordBreakProc ( EDITSTATE es,
void wbp 
)
static

Definition at line 3068 of file edit.c.

3070{
3071 if (es->word_break_proc == wbp)
3072 return;
3073
3074 es->word_break_proc = wbp;
3075
3076 if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
3079 }

◆ EDIT_EM_Undo()

static BOOL EDIT_EM_Undo ( EDITSTATE es)
static

Definition at line 3087 of file edit.c.

3089{
3090 INT ulength;
3091 LPWSTR utext;
3092
3093 /* As per MSDN spec, for a single-line edit control,
3094 the return value is always TRUE */
3095 if( es->style & ES_READONLY )
3096 return !(es->style & ES_MULTILINE);
3097
3098 ulength = strlenW(es->undo_text);
3099
3100 utext = HeapAlloc(GetProcessHeap(), 0, (ulength + 1) * sizeof(WCHAR));
3101#ifdef __REACTOS__
3102 /* ReactOS r33503 */
3103 if (utext == NULL)
3104 return FALSE;
3105#endif
3106
3107 strcpyW(utext, es->undo_text);
3108
3109 TRACE("before UNDO:insertion length = %d, deletion buffer = %s\n",
3110 es->undo_insert_count, debugstr_w(utext));
3111
3112 EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
3114 EDIT_EM_ReplaceSel(es, TRUE, utext, TRUE, TRUE);
3115 EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
3116 /* send the notification after the selection start and end are set */
3117 if (!notify_parent(es, EN_CHANGE)) return TRUE;
3119 HeapFree(GetProcessHeap(), 0, utext);
3120
3121 TRACE("after UNDO:insertion length = %d, deletion buffer = %s\n",
3122 es->undo_insert_count, debugstr_w(es->undo_text));
3123 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:2428
#define ES_READONLY
Definition: pedump.c:675

◆ EDIT_GetCompositionStr()

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

Definition at line 4414 of file edit.c.

4416{
4417 LONG buflen;
4418 LPWSTR lpCompStr;
4419 LPSTR lpCompStrAttr = NULL;
4420 DWORD dwBufLenAttr;
4421
4422 buflen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
4423
4424 if (buflen < 0)
4425 {
4426 return;
4427 }
4428
4429 lpCompStr = HeapAlloc(GetProcessHeap(),0,buflen + sizeof(WCHAR));
4430 if (!lpCompStr)
4431 {
4432 ERR("Unable to allocate IME CompositionString\n");
4433 return;
4434 }
4435
4436 if (buflen)
4437 ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, buflen);
4438 lpCompStr[buflen/sizeof(WCHAR)] = 0;
4439
4440 if (CompFlag & GCS_COMPATTR)
4441 {
4442 /*
4443 * We do not use the attributes yet. it would tell us what characters
4444 * are in transition and which are converted or decided upon
4445 */
4446 dwBufLenAttr = ImmGetCompositionStringW(hIMC, GCS_COMPATTR, NULL, 0);
4447 if (dwBufLenAttr)
4448 {
4449 dwBufLenAttr ++;
4450 lpCompStrAttr = HeapAlloc(GetProcessHeap(),0,dwBufLenAttr+1);
4451 if (!lpCompStrAttr)
4452 {
4453 ERR("Unable to allocate IME Attribute String\n");
4454 HeapFree(GetProcessHeap(),0,lpCompStr);
4455 return;
4456 }
4457 ImmGetCompositionStringW(hIMC,GCS_COMPATTR, lpCompStrAttr,
4458 dwBufLenAttr);
4459 lpCompStrAttr[dwBufLenAttr] = 0;
4460 }
4461 }
4462
4463 /* check for change in composition start */
4464 if (es->selection_end < es->composition_start)
4465 es->composition_start = es->selection_end;
4466
4467 /* replace existing selection string */
4468 es->selection_start = es->composition_start;
4469
4470 if (es->composition_len > 0)
4471 es->selection_end = es->composition_start + es->composition_len;
4472 else
4473 es->selection_end = es->selection_start;
4474
4475 EDIT_EM_ReplaceSel(es, FALSE, lpCompStr, TRUE, TRUE);
4476 es->composition_len = abs(es->composition_start - es->selection_end);
4477
4478 es->selection_start = es->composition_start;
4479 es->selection_end = es->selection_start + es->composition_len;
4480
4481 HeapFree(GetProcessHeap(),0,lpCompStrAttr);
4482 HeapFree(GetProcessHeap(),0,lpCompStr);
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:899
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GCS_COMPATTR
Definition: imm.h:368
#define GCS_COMPSTR
Definition: imm.h:367

◆ EDIT_GetLineRect()

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

Definition at line 1229 of file edit.c.

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

◆ EDIT_GetResultStr()

static void EDIT_GetResultStr ( HIMC  hIMC,
EDITSTATE es 
)
static

Definition at line 4484 of file edit.c.

4486{
4487 LONG buflen;
4488 LPWSTR lpResultStr;
4489
4490 buflen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
4491 if (buflen <= 0)
4492 {
4493 return;
4494 }
4495
4496 lpResultStr = HeapAlloc(GetProcessHeap(),0, buflen+sizeof(WCHAR));
4497 if (!lpResultStr)
4498 {
4499 ERR("Unable to alloc buffer for IME string\n");
4500 return;
4501 }
4502
4503 ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpResultStr, buflen);
4504 lpResultStr[buflen/sizeof(WCHAR)] = 0;
4505
4506 /* check for change in composition start */
4507 if (es->selection_end < es->composition_start)
4508 es->composition_start = es->selection_end;
4509
4510 es->selection_start = es->composition_start;
4511 es->selection_end = es->composition_start + es->composition_len;
4512 EDIT_EM_ReplaceSel(es, TRUE, lpResultStr, TRUE, TRUE);
4513 es->composition_start = es->selection_end;
4514 es->composition_len = 0;
4515
4516 HeapFree(GetProcessHeap(),0,lpResultStr);
#define GCS_RESULTSTR
Definition: imm.h:374

◆ EDIT_ImeComposition()

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

Definition at line 4518 of file edit.c.

4520{
4521 HIMC hIMC;
4522 int cursor;
4523
4524 if (es->composition_len == 0 && es->selection_start != es->selection_end)
4525 {
4527 es->composition_start = es->selection_end;
4528 }
4529
4530 hIMC = ImmGetContext(hwnd);
4531 if (!hIMC)
4532 return;
4533
4534 if (CompFlag & GCS_RESULTSTR)
4535 {
4536 EDIT_GetResultStr(hIMC, es);
4537 cursor = 0;
4538 }
4539 else
4540 {
4541 if (CompFlag & GCS_COMPSTR)
4542 EDIT_GetCompositionStr(hIMC, CompFlag, es);
4544 }
4545 ImmReleaseContext(hwnd, hIMC);
4546 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:4265
static void EDIT_GetCompositionStr(HIMC hIMC, LPARAM CompFlag, EDITSTATE *es)
Definition: edit.c:4196
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1057
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:1098
const char cursor[]
Definition: icontest.c:13
#define GCS_CURSORPOS
Definition: imm.h:370
static const WCHAR empty_stringW[]
Definition: edit.c:163

◆ EDIT_InvalidateText()

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

Definition at line 1606 of file edit.c.

1608{
1609 if (end == start)
1610 return;
1611
1612 if (end == -1)
1614
1615 if (end < start) {
1616 INT tmp = start;
1617 start = end;
1618 end = tmp;
1619 }
1620
1621 if (es->style & ES_MULTILINE)
1623 else
static void EDIT_ML_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1386
static void EDIT_SL_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1368

◆ EDIT_InvalidateUniscribeData()

static void EDIT_InvalidateUniscribeData ( EDITSTATE es)
inlinestatic

Definition at line 381 of file edit.c.

383{
384 LINEDEF *line_def = es->first_line_def;
385 while (line_def)
386 {
388 line_def = line_def->next;
389 }
390 if (es->ssa)
391 {
392 ScriptStringFree(&es->ssa);
393 es->ssa = NULL;
394 }
HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:2556

◆ EDIT_InvalidateUniscribeData_linedef()

static void EDIT_InvalidateUniscribeData_linedef ( LINEDEF line_def)
inlinestatic

Definition at line 372 of file edit.c.

374{
375 if (line_def->ssa)
376 {
377 ScriptStringFree(&line_def->ssa);
378 line_def->ssa = NULL;
379 }

◆ EDIT_IsInsideDialog()

static BOOL EDIT_IsInsideDialog ( EDITSTATE es)
inlinestatic

Definition at line 3133 of file edit.c.

3135{
3136 return (es->flags & EF_DIALOGMODE);
#define EF_DIALOGMODE
Definition: edit.c:73

◆ EDIT_LockBuffer()

static void EDIT_LockBuffer ( EDITSTATE es)
static

Definition at line 1293 of file edit.c.

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

◆ EDIT_MakeFit()

static BOOL EDIT_MakeFit ( EDITSTATE es,
UINT  size 
)
static

Definition at line 1423 of file edit.c.

1425{
1426 HLOCAL hNew32W;
1427
1428 if (size <= es->buffer_size)
1429 return TRUE;
1430
1431 TRACE("trying to ReAlloc to %d+1 characters\n", size);
1432
1433 /* Force edit to unlock its buffer. es->text now NULL */
1435
1436 if (es->hloc32W) {
1437 UINT alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1438 if ((hNew32W = LocalReAlloc(es->hloc32W, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT))) {
1439 TRACE("Old 32 bit handle %p, new handle %p\n", es->hloc32W, hNew32W);
1440 es->hloc32W = hNew32W;
1441 es->buffer_size = LocalSize(hNew32W)/sizeof(WCHAR) - 1;
1442 }
1443 }
1444
1446
1447 if (es->buffer_size < size) {
1448 WARN("FAILED ! We now have %d+1\n", es->buffer_size);
1450 return FALSE;
1451 } else {
1452 TRACE("We now have %d+1\n", es->buffer_size);
1453 return TRUE;
1454 }
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
#define EN_ERRSPACE
Definition: winuser.h:2013

◆ EDIT_MakeUndoFit()

static BOOL EDIT_MakeUndoFit ( EDITSTATE es,
UINT  size 
)
static

Definition at line 1464 of file edit.c.

1466{
1467 UINT alloc_size;
1468
1469 if (size <= es->undo_buffer_size)
1470 return TRUE;
1471
1472 TRACE("trying to ReAlloc to %d+1\n", size);
1473
1474 alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1475 if ((es->undo_text = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, es->undo_text, alloc_size))) {
1476 es->undo_buffer_size = alloc_size/sizeof(WCHAR) - 1;
1477 return TRUE;
1478 }
1479 else
1480 {
1481 WARN("FAILED ! We now have %d+1\n", es->undo_buffer_size);
1482 return FALSE;
1483 }
#define HeapReAlloc
Definition: compat.h:734

◆ EDIT_ML_InvalidateText()

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

Definition at line 1541 of file edit.c.

1543{
1547 INT sc;
1548 INT ec;
1549 RECT rc1;
1550 RECT rcWnd;
1551 RECT rcLine;
1552 RECT rcUpdate;
1553 INT l;
1554
1555 if ((el < es->y_offset) || (sl > es->y_offset + vlc))
1556 return;
1557
1558 sc = start - EDIT_EM_LineIndex(es, sl);
1559 ec = end - EDIT_EM_LineIndex(es, el);
1560 if (sl < es->y_offset) {
1561 sl = es->y_offset;
1562 sc = 0;
1563 }
1564 if (el > es->y_offset + vlc) {
1565 el = es->y_offset + vlc;
1567 }
1568 GetClientRect(es->hwndSelf, &rc1);
1569 IntersectRect(&rcWnd, &rc1, &es->format_rect);
1570 if (sl == el) {
1571 EDIT_GetLineRect(es, sl, sc, ec, &rcLine);
1572 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1573 EDIT_UpdateText(es, &rcUpdate, TRUE);
1574 } else {
1575 EDIT_GetLineRect(es, sl, sc,
1577 EDIT_EM_LineIndex(es, sl)),
1578 &rcLine);
1579 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1580 EDIT_UpdateText(es, &rcUpdate, TRUE);
1581 for (l = sl + 1 ; l < el ; l++) {
1582 EDIT_GetLineRect(es, l, 0,
1585 &rcLine);
1586 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1587 EDIT_UpdateText(es, &rcUpdate, TRUE);
1588 }
1589 EDIT_GetLineRect(es, el, 0, ec, &rcLine);
1590 if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1591 EDIT_UpdateText(es, &rcUpdate, TRUE);
1592 }
static void EDIT_GetLineRect(EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc)
Definition: edit.c:1139

◆ EDIT_MoveBackward()

static void EDIT_MoveBackward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1949 of file edit.c.

1951{
1952 INT e = es->selection_end;
1953
1954 if (e) {
1955 e--;
1956 if ((es->style & ES_MULTILINE) && e &&
1957 (es->text[e - 1] == '\r') && (es->text[e] == '\n')) {
1958 e--;
1959 if (e && (es->text[e - 1] == '\r'))
1960 e--;
1961 }
1962 }
1963 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 1976 of file edit.c.

1978{
1979 INT s = es->selection_start;
1980 INT e = es->selection_end;
1981 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
1982 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
1983 INT x = (short)LOWORD(pos);
1984 INT y = (short)HIWORD(pos);
1985
1986 e = EDIT_CharFromPos(es, x, y + es->line_height, &after_wrap);
1987 if (!extend)
1988 s = e;
1989 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 1998 of file edit.c.

2000{
2001 BOOL after_wrap = FALSE;
2002 INT e;
2003
2004 /* Pass a high value in x to make sure of receiving the end of the line */
2005 if (!ctrl && (es->style & ES_MULTILINE))
2006 e = EDIT_CharFromPos(es, 0x3fffffff,
2007 HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap);
2008 else
2009 e = get_text_length(es);
2010 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 2019 of file edit.c.

2021{
2022 INT e = es->selection_end;
2023
2024 if (es->text[e]) {
2025 e++;
2026 if ((es->style & ES_MULTILINE) && (es->text[e - 1] == '\r')) {
2027 if (es->text[e] == '\n')
2028 e++;
2029 else if ((es->text[e] == '\r') && (es->text[e + 1] == '\n'))
2030 e += 2;
2031 }
2032 }
2033 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 2044 of file edit.c.

2046{
2047 INT e;
2048
2049 /* Pass the x_offset in x to make sure of receiving the first position of the line */
2050 if (!ctrl && (es->style & ES_MULTILINE))
2051 e = EDIT_CharFromPos(es, -es->x_offset,
2052 HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL);
2053 else
2054 e = 0;
2055 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 2068 of file edit.c.

2070{
2071 INT s = es->selection_start;
2072 INT e = es->selection_end;
2073 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2074 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2075 INT x = (short)LOWORD(pos);
2076 INT y = (short)HIWORD(pos);
2077
2079 y + (es->format_rect.bottom - es->format_rect.top),
2080 &after_wrap);
2081 if (!extend)
2082 s = e;
2083 EDIT_EM_SetSel(es, s, e, after_wrap);

◆ EDIT_MovePageUp_ML()

static void EDIT_MovePageUp_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2096 of file edit.c.

2098{
2099 INT s = es->selection_start;
2100 INT e = es->selection_end;
2101 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2102 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2103 INT x = (short)LOWORD(pos);
2104 INT y = (short)HIWORD(pos);
2105
2107 y - (es->format_rect.bottom - es->format_rect.top),
2108 &after_wrap);
2109 if (!extend)
2110 s = e;
2111 EDIT_EM_SetSel(es, s, e, after_wrap);

◆ EDIT_MoveUp_ML()

static void EDIT_MoveUp_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2124 of file edit.c.

2126{
2127 INT s = es->selection_start;
2128 INT e = es->selection_end;
2129 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2130 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2131 INT x = (short)LOWORD(pos);
2132 INT y = (short)HIWORD(pos);
2133
2134 e = EDIT_CharFromPos(es, x, y - es->line_height, &after_wrap);
2135 if (!extend)
2136 s = e;
2137 EDIT_EM_SetSel(es, s, e, after_wrap);

◆ EDIT_MoveWordBackward()

static void EDIT_MoveWordBackward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2146 of file edit.c.

2148{
2149 INT s = es->selection_start;
2150 INT e = es->selection_end;
2151 INT l;
2152 INT ll;
2153 INT li;
2154
2158 if (e - li == 0) {
2159 if (l) {
2160 li = EDIT_EM_LineIndex(es, l - 1);
2161 e = li + EDIT_EM_LineLength(es, li);
2162 }
2163 } else {
2165 }
2166 if (!extend)
2167 s = e;
w ll
Definition: byte_order.h:166

◆ EDIT_MoveWordForward()

static void EDIT_MoveWordForward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2177 of file edit.c.

2179{
2180 INT s = es->selection_start;
2181 INT e = es->selection_end;
2182 INT l;
2183 INT ll;
2184 INT li;
2185
2189 if (e - li == ll) {
2190 if ((es->style & ES_MULTILINE) && (l != es->line_count - 1))
2191 e = EDIT_EM_LineIndex(es, l + 1);
2192 } else {
2194 li, e - li + 1, ll, WB_RIGHT);
2195 }
2196 if (!extend)
2197 s = e;
#define WB_RIGHT
Definition: winuser.h:551

◆ EDIT_NotifyCtlColor()

static HBRUSH EDIT_NotifyCtlColor ( EDITSTATE es,
HDC  hdc 
)
static

Definition at line 232 of file edit.c.

234{
235 HBRUSH hbrush;
236 UINT msg;
237
238 if ( get_app_version() >= 0x40000 && (!es->bEnableState || (es->style & ES_READONLY)))
240 else
242
243 /* why do we notify to es->hwndParent, and we send this one to GetParent()? */
244#ifdef __REACTOS__
245 /* ReactOS r54259 */
246 hbrush = GetControlBrush(es->hwndSelf, hdc, msg);
247#else
248 hbrush = (HBRUSH)SendMessageW(GetParent(es->hwndSelf), msg, (WPARAM)hdc, (LPARAM)es->hwndSelf);
249 if (!hbrush)
250 hbrush = (HBRUSH)DefWindowProcW(GetParent(es->hwndSelf), msg, (WPARAM)hdc, (LPARAM)es->hwndSelf);
251#endif
252 return hbrush;
static HBRUSH hbrush
HDC hdc
Definition: main.c:9
HBRUSH FASTCALL GetControlBrush(PWND pwnd, HDC hdc, UINT ctlType)
Definition: misc.c:172
static DWORD get_app_version(void)
Definition: edit.c:213
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1762
#define WM_CTLCOLOREDIT
Definition: winuser.h:1757

◆ EDIT_PaintLine()

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

Definition at line 2273 of file edit.c.

2275{
2276 INT s = 0;
2277 INT e = 0;
2278 INT li = 0;
2279 INT ll = 0;
2280 INT x;
2281 INT y;
2282 LRESULT pos;
2284
2285 if (es->style & ES_MULTILINE) {
2287
2288 if ((line < es->y_offset) || (line > es->y_offset + vlc) || (line >= es->line_count))
2289 return;
2290 } else if (line)
2291 return;
2292
2293 TRACE("line=%d\n", line);
2294
2297 x = (short)LOWORD(pos);
2298 y = (short)HIWORD(pos);
2299
2300 if (es->style & ES_MULTILINE)
2301 {
2302 int line_idx = line;
2303 x = -es->x_offset;
2304 if (es->style & ES_RIGHT || es->style & ES_CENTER)
2305 {
2306 LINEDEF *line_def = es->first_line_def;
2307 int w, lw;
2308
2309 while (line_def && line_idx)
2310 {
2311 line_def = line_def->next;
2312 line_idx--;
2313 }
2314 w = es->format_rect.right - es->format_rect.left;
2315 lw = line_def->width;
2316
2317 if (es->style & ES_RIGHT)
2318 x = w - (lw - x);
2319 else if (es->style & ES_CENTER)
2320 x += (w - lw) / 2;
2321 }
2322 x += es->format_rect.left;
2323 }
2324
2325 if (rev)
2326 {
2329 s = min(es->selection_start, es->selection_end);
2330 e = max(es->selection_start, es->selection_end);
2331 s = min(li + ll, max(li, s));
2332 e = min(li + ll, max(li, e));
2333 }
2334
2335 if (ssa)
2336 ScriptStringOut(ssa, x, y, 0, &es->format_rect, s - li, e - li, FALSE);
2337 else if (rev && (s != e) &&
2338 ((es->flags & EF_FOCUSED) || (es->style & ES_NOHIDESEL))) {
2339 x += EDIT_PaintText(es, dc, x, y, line, 0, s - li, FALSE);
2340 x += EDIT_PaintText(es, dc, x, y, line, s - li, e - s, TRUE);
2341 x += EDIT_PaintText(es, dc, x, y, line, e - li, li + ll - e, FALSE);
2342 } else
2343 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:2057
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:2366
#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 2207 of file edit.c.

2209{
2210 COLORREF BkColor;
2211 COLORREF TextColor;
2212 LOGFONTW underline_font;
2213 HFONT hUnderline = 0;
2214 HFONT old_font = 0;
2215 INT ret;
2216 INT li;
2217 INT BkMode;
2218 SIZE size;
2219
2220 if (!count)
2221 return 0;
2222 BkMode = GetBkMode(dc);
2223 BkColor = GetBkColor(dc);
2224 TextColor = GetTextColor(dc);
2225 if (rev) {
2226 if (es->composition_len == 0)
2227 {
2230 SetBkMode( dc, OPAQUE);
2231 }
2232 else
2233 {
2235 GetObjectW(current,sizeof(LOGFONTW),&underline_font);
2236 underline_font.lfUnderline = TRUE;
2237 hUnderline = CreateFontIndirectW(&underline_font);
2238 old_font = SelectObject(dc,hUnderline);
2239 }
2240 }
2242 if (es->style & ES_MULTILINE) {
2243 ret = (INT)LOWORD(TabbedTextOutW(dc, x, y, es->text + li + col, count,
2244 es->tabs_count, es->tabs, es->format_rect.left - es->x_offset));
2245 } else {
2246 TextOutW(dc, x, y, es->text + li + col, count);
2247 GetTextExtentPoint32W(dc, es->text + li + col, count, &size);
2248 ret = size.cx;
2249 }
2250 if (rev) {
2251 if (es->composition_len == 0)
2252 {
2253 SetBkColor(dc, BkColor);
2254 SetTextColor(dc, TextColor);
2255 SetBkMode( dc, BkMode);
2256 }
2257 else
2258 {
2259 if (old_font)
2260 SelectObject(dc,old_font);
2261 if (hUnderline)
2262 DeleteObject(hUnderline);
2263 }
2264 }
2265 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:861
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:918
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:920
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:921
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 1865 of file edit.c.

1868{
1869 LRESULT res = EDIT_EM_PosFromChar(es, pos, after_wrap);
1870 TRACE("%d - %dx%d\n", pos, (short)LOWORD(res), (short)HIWORD(res));
1871 SetCaretPos((short)LOWORD(res), (short)HIWORD(res));
GLuint res
Definition: glext.h:9613
BOOL WINAPI SetCaretPos(_In_ int, _In_ int)

◆ EDIT_SetRectNP()

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

Definition at line 2405 of file edit.c.

2407{
2409 INT bw, bh;
2411
2412 CopyRect(&es->format_rect, rc);
2413
2414 if (ExStyle & WS_EX_CLIENTEDGE) {
2415 es->format_rect.left++;
2416 es->format_rect.right--;
2417
2418 if (es->format_rect.bottom - es->format_rect.top
2419 >= es->line_height + 2)
2420 {
2421 es->format_rect.top++;
2422 es->format_rect.bottom--;
2423 }
2424 }
2425 else if (es->style & WS_BORDER) {
2427 bh = GetSystemMetrics(SM_CYBORDER) + 1;
2428 es->format_rect.left += bw;
2429 es->format_rect.right -= bw;
2430 if (es->format_rect.bottom - es->format_rect.top
2431 >= es->line_height + 2 * bh)
2432 {
2433 es->format_rect.top += bh;
2434 es->format_rect.bottom -= bh;
2435 }
2436 }
2437
2438 es->format_rect.left += es->left_margin;
2439 es->format_rect.right -= es->right_margin;
static int bw
Definition: maze.c:120
const DWORD ExStyle
Definition: appswitch.c:72
__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:4819
#define SM_CYBORDER
Definition: winuser.h:959
#define SM_CXBORDER
Definition: winuser.h:958
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
int WINAPI GetSystemMetrics(_In_ int)
#define GWL_EXSTYLE
Definition: winuser.h:845

◆ EDIT_SL_InvalidateText()

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

Definition at line 1523 of file edit.c.

1525{
1526 RECT line_rect;
1527 RECT rc;
1528
1529 EDIT_GetLineRect(es, 0, start, end, &line_rect);
1530 if (IntersectRect(&rc, &line_rect, &es->format_rect))
1531 EDIT_UpdateText(es, &rc, TRUE);

◆ EDIT_UnlockBuffer()

static void EDIT_UnlockBuffer ( EDITSTATE es,
BOOL  force 
)
static

Definition at line 1356 of file edit.c.

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

◆ EDIT_UpdateScrollInfo()

static void EDIT_UpdateScrollInfo ( EDITSTATE es)
static

Definition at line 1702 of file edit.c.

1704{
1705 if ((es->style & WS_VSCROLL) && !(es->flags & EF_VSCROLL_TRACK))
1706 {
1707 SCROLLINFO si;
1708 si.cbSize = sizeof(SCROLLINFO);
1710 si.nMin = 0;
1711 si.nMax = es->line_count - 1;
1712 si.nPage = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
1713 si.nPos = es->y_offset;
1714 TRACE("SB_VERT, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n",
1715 si.nMin, si.nMax, si.nPage, si.nPos);
1716 SetScrollInfo(es->hwndSelf, SB_VERT, &si, TRUE);
1717 }
1718
1719 if ((es->style & WS_HSCROLL) && !(es->flags & EF_HSCROLL_TRACK))
1720 {
1721 SCROLLINFO si;
1722 si.cbSize = sizeof(SCROLLINFO);
1724 si.nMin = 0;
1725 si.nMax = es->text_width - 1;
1726 si.nPage = es->format_rect.right - es->format_rect.left;
1727 si.nPos = es->x_offset;
1728 TRACE("SB_HORZ, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n",
1729 si.nMin, si.nMax, si.nPage, si.nPos);
1730 SetScrollInfo(es->hwndSelf, SB_HORZ, &si, TRUE);
1731 }
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
struct tagSCROLLINFO SCROLLINFO
#define SIF_RANGE
Definition: winuser.h:1225
#define SB_VERT
Definition: winuser.h:553
#define SIF_PAGE
Definition: winuser.h:1223
#define SIF_DISABLENOSCROLL
Definition: winuser.h:1226
#define SIF_POS
Definition: winuser.h:1224
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 1506 of file edit.c.

1508{
1509 if (es->flags & EF_UPDATE) {
1510 es->flags &= ~EF_UPDATE;
1511 if (!notify_parent(es, EN_UPDATE)) return;
1512 }
1513 InvalidateRect(es->hwndSelf, rc, bErase);
#define EN_UPDATE
Definition: winuser.h:2018
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 1491 of file edit.c.

1493{
1494 if (es->flags & EF_UPDATE) {
1495 es->flags &= ~EF_UPDATE;
1496 if (!notify_parent(es, EN_UPDATE)) return;
1497 }
1498 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 443 of file edit.c.

445{
446 LINEDEF *line_def;
447
448 if (!(es->style & ES_MULTILINE))
449 {
450 if (!es->ssa)
451 {
453 HFONT old_font = NULL;
454 HDC udc = dc;
455
456 if (!udc)
457 udc = GetDC(es->hwndSelf);
458 if (es->font)
459 old_font = SelectObject(udc, es->font);
460
461 if (es->style & ES_PASSWORD)
462#ifdef __REACTOS__
463 /* ReactOS r57677 */
464 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);
465#else
466 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);
467#endif
468 else
469#ifdef __REACTOS__
470 /* ReactOS r57677 */
471 ScriptStringAnalyse(udc, es->text, length, (3*length/2+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
472#else
473 ScriptStringAnalyse(udc, es->text, length, (1.5*length+16), -1, SSA_LINK|SSA_FALLBACK|SSA_GLYPHS, -1, NULL, NULL, NULL, NULL, NULL, &es->ssa);
474#endif
475
476 if (es->font)
477 SelectObject(udc, old_font);
478 if (udc != dc)
479 ReleaseDC(es->hwndSelf, udc);
480 }
481 return es->ssa;
482 }
483 else
484 {
485 line_def = es->first_line_def;
486 while (line_def && line)
487 {
488 line_def = line_def->next;
489 line--;
490 }
491
492 return EDIT_UpdateUniscribeData_linedef(es,dc,line_def);
493 }
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 396 of file edit.c.

398{
399 if (!line_def)
400 return NULL;
401
402 if (line_def->net_length && !line_def->ssa)
403 {
404 int index = line_def->index;
405 HFONT old_font = NULL;
406 HDC udc = dc;
407 SCRIPT_TABDEF tabdef;
408 HRESULT hr;
409
410 if (!udc)
411 udc = GetDC(es->hwndSelf);
412 if (es->font)
413 old_font = SelectObject(udc, es->font);
414
415 tabdef.cTabStops = es->tabs_count;
416 tabdef.iScale = 0;
417 tabdef.pTabStops = es->tabs;
418 tabdef.iTabOrigin = 0;
419
420 hr = ScriptStringAnalyse(udc, &es->text[index], line_def->net_length,
421#ifdef __REACTOS__
422 /* ReactOS r57679 */
423 (3*line_def->net_length/2+16), -1,
424#else
425 (1.5*line_def->net_length+16), -1,
426#endif
428 NULL, NULL, NULL, &tabdef, NULL, &line_def->ssa);
429 if (FAILED(hr))
430 {
431 WARN("ScriptStringAnalyse failed (%x)\n",hr);
432 line_def->ssa = NULL;
433 }
434
435 if (es->font)
436 SelectObject(udc, old_font);
437 if (udc != dc)
438 ReleaseDC(es->hwndSelf, udc);
439 }
440
441 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 3228 of file edit.c.

3230{
3231 BOOL control;
3232
3233 control = GetKeyState(VK_CONTROL) & 0x8000;
3234
3235 switch (c) {
3236 case '\r':
3237 /* If it's not a multiline edit box, it would be ignored below.
3238 * For multiline edit without ES_WANTRETURN, we have to make a
3239 * special case.
3240 */
3241 if ((es->style & ES_MULTILINE) && !(es->style & ES_WANTRETURN))
3243 break;
3244 case '\n':
3245 if (es->style & ES_MULTILINE) {
3246 if (es->style & ES_READONLY) {
3249 } else {
3250 static const WCHAR cr_lfW[] = {'\r','\n',0};
3251 EDIT_EM_ReplaceSel(es, TRUE, cr_lfW, TRUE, TRUE);
3252 }
3253 }
3254 break;
3255 case '\t':
3256 if ((es->style & ES_MULTILINE) && !(es->style & ES_READONLY))
3257 {
3258 static const WCHAR tabW[] = {'\t',0};
3260 break;
3262 }
3263 break;
3264 case VK_BACK:
3265 if (!(es->style & ES_READONLY) && !control) {
3266 if (es->selection_start != es->selection_end)
3268 else {
3269 /* delete character left of caret */
3270 EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
3273 }
3274 }
3275 break;
3276 case 0x03: /* ^C */
3277 if (!(es->style & ES_PASSWORD))
3278 SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
3279 break;
3280 case 0x16: /* ^V */
3281 if (!(es->style & ES_READONLY))
3282 SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3283 break;
3284 case 0x18: /* ^X */
3285 if (!((es->style & ES_READONLY) || (es->style & ES_PASSWORD)))
3286 SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
3287 break;
3288 case 0x1A: /* ^Z */
3289 if (!(es->style & ES_READONLY))
3290 SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
3291 break;
3292
3293 default:
3294 /*If Edit control style is ES_NUMBER allow users to key in only numeric values*/
3295 if( (es->style & ES_NUMBER) && !( c >= '0' && c <= '9') )
3296 break;
3297
3298 if (!(es->style & ES_READONLY) && (c >= ' ') && (c != 127)) {
3299 WCHAR str[2];
3300 str[0] = c;
3301 str[1] = '\0';
3303 }
3304 break;
3305 }
3306 return 1;
static BOOL EDIT_IsInsideDialog(EDITSTATE *es)
Definition: edit.c:2895
static void EDIT_MoveBackward(EDITSTATE *es, BOOL extend)
Definition: edit.c:1799
static void EDIT_MoveHome(EDITSTATE *es, BOOL extend, BOOL ctrl)
Definition: edit.c:1894
static void EDIT_WM_Clear(EDITSTATE *es)
Definition: edit.c:2971
static void EDIT_MoveDown_ML(EDITSTATE *es, BOOL extend)
Definition: edit.c:1826
#define ES_WANTRETURN
Definition: pedump.c:676
const WCHAR * str
#define VK_CONTROL
Definition: winuser.h:2193
#define VK_BACK
Definition: winuser.h:2188
#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 3201 of file edit.c.

3203{
3204 /* Protect read-only edit control from modification */
3205 if(es->style & ES_READONLY)
3206 return;
3207

◆ EDIT_WM_ContextMenu()

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

Definition at line 3358 of file edit.c.

3360{
3361 HMENU menu = LoadMenuA(user32_module, "EDITMENU");
3362 HMENU popup = GetSubMenu(menu, 0);
3363 UINT start = es->selection_start;
3364 UINT end = es->selection_end;
3365 UINT cmd;
3366
3368
3369 /* undo */
3371 /* cut */
3372 EnableMenuItem(popup, 2, MF_BYPOSITION | ((end - start) && !(es->style & ES_PASSWORD) && !(es->style & ES_READONLY) ? MF_ENABLED : MF_GRAYED));
3373 /* copy */
3374 EnableMenuItem(popup, 3, MF_BYPOSITION | ((end - start) && !(es->style & ES_PASSWORD) ? MF_ENABLED : MF_GRAYED));
3375 /* paste */
3377 /* delete */
3378 EnableMenuItem(popup, 5, MF_BYPOSITION | ((end - start) && !(es->style & ES_READONLY) ? MF_ENABLED : MF_GRAYED));
3379 /* select all */
3381
3382 if (x == -1 && y == -1) /* passed via VK_APPS press/release */
3383 {
3384 RECT rc;
3385 /* Windows places the menu at the edit's center in this case */
3386#ifdef __REACTOS__
3387 /* ReactOS r55202 */
3388 GetClientRect(es->hwndSelf, &rc);
3389 MapWindowPoints(es->hwndSelf, 0, (POINT *)&rc, 2);
3390#else
3391 WIN_GetRectangles( es->hwndSelf, COORDS_SCREEN, NULL, &rc );
3392#endif
3393 x = rc.left + (rc.right - rc.left) / 2;
3394 y = rc.top + (rc.bottom - rc.top) / 2;
3395 }
3396
3397 if (!(es->flags & EF_FOCUSED))
3398 SetFocus(es->hwndSelf);
3399
3401 x, y, 0,