ReactOS 0.4.15-dev-6694-g4ba8af9
edit.c File Reference
#include <user32.h>
#include <usp10.h>
Include dependency graph for edit.c:

Go to the source code of this file.

Classes

struct  tagLINEDEF
 
struct  EDITSTATE
 

Macros

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

Typedefs

typedef struct tagLINEDEF LINEDEF
 

Enumerations

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

Functions

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

Variables

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

Macro Definition Documentation

◆ BUFLIMIT_INITIAL

#define BUFLIMIT_INITIAL   30000 /* initial buffer size */

Definition at line 66 of file edit.c.

◆ EF_AFTER_WRAP

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

Definition at line 79 of file edit.c.

◆ EF_DIALOGMODE

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

Definition at line 81 of file edit.c.

◆ EF_FOCUSED

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

Definition at line 75 of file edit.c.

◆ EF_HSCROLL_TRACK

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

Definition at line 78 of file edit.c.

◆ EF_MODIFIED

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

Definition at line 74 of file edit.c.

◆ EF_UPDATE

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

Definition at line 76 of file edit.c.

◆ EF_USE_SOFTBRK

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

Definition at line 80 of file edit.c.

◆ EF_VSCROLL_TRACK

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

Definition at line 77 of file edit.c.

◆ GROWLENGTH

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

Definition at line 67 of file edit.c.

◆ HSCROLL_FRACTION

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

Definition at line 69 of file edit.c.

◆ ORDER_UINT

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

Definition at line 171 of file edit.c.

◆ ROUND_TO_GROW

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

Definition at line 68 of file edit.c.

◆ SWAP_UINT32

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

Definition at line 170 of file edit.c.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 46 of file edit.c.

Typedef Documentation

◆ LINEDEF

Enumeration Type Documentation

◆ LINE_END

Enumerator
END_0 
END_WRAP 
END_HARD 
END_SOFT 
END_RICH 
END_0 
END_WRAP 
END_HARD 
END_SOFT 
END_RICH 

Definition at line 83 of file edit.c.

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

Function Documentation

◆ DefWindowProcT()

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

Definition at line 4829 of file edit.c.

4831{
4832 if(unicode)
4833 return DefWindowProcW(hwnd, msg, wParam, lParam);
4834 else
4835 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 2410 of file edit.c.

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

◆ EDIT_BuildLineDefs_ML()

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

Definition at line 520 of file edit.c.

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

◆ EDIT_CalcLineWidth_SL()

static void EDIT_CalcLineWidth_SL ( EDITSTATE es)
static

Definition at line 857 of file edit.c.

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

◆ EDIT_CallWordBreakProc()

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

Definition at line 343 of file edit.c.

345{
346 INT ret;
347
348 if (es->word_break_proc)
349 {
350 if(es->is_unicode)
351 {
352 EDITWORDBREAKPROCW wbpW = (EDITWORDBREAKPROCW)es->word_break_proc;
353
354 TRACE_(relay)("(UNICODE wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
355 es->word_break_proc, debugstr_wn(es->text + start, count), index, count, action);
356 ret = wbpW(es->text + start, index, count, action);
357 }
358 else
359 {
360 EDITWORDBREAKPROCA wbpA = (EDITWORDBREAKPROCA)es->word_break_proc;
361 INT countA;
362 CHAR *textA;
363
364 countA = WideCharToMultiByte(CP_ACP, 0, es->text + start, count, NULL, 0, NULL, NULL);
365 textA = HeapAlloc(GetProcessHeap(), 0, countA);
366#ifdef __REACTOS__
367 /* ReactOS r33503 */
368 if (textA == NULL) return 0;
369#endif
370 WideCharToMultiByte(CP_ACP, 0, es->text + start, count, textA, countA, NULL, NULL);
371 TRACE_(relay)("(ANSI wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
372 es->word_break_proc, debugstr_an(textA, countA), index, countA, action);
373 ret = wbpA(textA, index, countA, action);
375 }
376 }
377 else
379
380 return ret;
#define index(s, c)
Definition: various.h:29
static INT EDIT_WordBreakProc(EDITSTATE *es, LPWSTR s, INT index, INT count, INT action)
Definition: edit.c:237
#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 880 of file edit.c.

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

3495{
3496 HWND hLBox = es->hwndListBox;
3497 HWND hCombo;
3498 BOOL bDropped;
3499 int nEUI;
3500
3501 if (!hLBox)
3502 return FALSE;
3503
3504 hCombo = GetParent(es->hwndSelf);
3505 bDropped = TRUE;
3506 nEUI = 0;
3507
3508 TRACE_(combo)("[%p]: handling msg %x (%x)\n", es->hwndSelf, msg, key);
3509
3510 if (key == VK_UP || key == VK_DOWN)
3511 {
3512 if (SendMessageW(hCombo, CB_GETEXTENDEDUI, 0, 0))
3513 nEUI = 1;
3514
3515 if (msg == WM_KEYDOWN || nEUI)
3516 bDropped = (BOOL)SendMessageW(hCombo, CB_GETDROPPEDSTATE, 0, 0);
3517 }
3518
3519 switch (msg)
3520 {
3521 case WM_KEYDOWN:
3522 if (!bDropped && nEUI && (key == VK_UP || key == VK_DOWN))
3523 {
3524 /* make sure ComboLBox pops up */
3525 SendMessageW(hCombo, CB_SETEXTENDEDUI, FALSE, 0);
3526 key = VK_F4;
3527 nEUI = 2;
3528 }
3529
3530 SendMessageW(hLBox, WM_KEYDOWN, key, 0);
3531 break;
3532
3533 case WM_SYSKEYDOWN: /* Handle Alt+up/down arrows */
3534 if (nEUI)
3535 SendMessageW(hCombo, CB_SHOWDROPDOWN, !bDropped, 0);
3536 else
3537 SendMessageW(hLBox, WM_KEYDOWN, VK_F4, 0);
3538 break;
3539 }
3540
3541 if(nEUI == 2)
3542 SendMessageW(hCombo, CB_SETEXTENDEDUI, TRUE, 0);
3543
3544 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 997 of file edit.c.

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

◆ EDIT_ContextMenuCommand()

static void EDIT_ContextMenuCommand ( EDITSTATE es,
UINT  id 
)
static

Definition at line 3370 of file edit.c.

3372{
3373 switch (id) {
3374 case EM_UNDO:
3375 SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
3376 break;
3377 case WM_CUT:
3378 SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
3379 break;
3380 case WM_COPY:
3381 SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
3382 break;
3383 case WM_PASTE:
3384 SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3385 break;
3386 case WM_CLEAR:
3387 SendMessageW(es->hwndSelf, WM_CLEAR, 0, 0);
3388 break;
3389 case EM_SETSEL:
3390 SendMessageW(es->hwndSelf, EM_SETSEL, 0, -1);
3391 break;
3392 default:
3393 ERR("unknown menu item, please report\n");
3394 break;
3395 }
#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 189 of file edit.c.

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

◆ EDIT_EM_CharFromPos()

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

Definition at line 2510 of file edit.c.

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

◆ EDIT_EM_EmptyUndoBuffer()

static void EDIT_EM_EmptyUndoBuffer ( EDITSTATE es)
inlinestatic

Definition at line 200 of file edit.c.

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

◆ EDIT_EM_FmtLines()

static BOOL EDIT_EM_FmtLines ( EDITSTATE es,
BOOL  add_eol 
)
static

Definition at line 2538 of file edit.c.

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

◆ EDIT_EM_GetHandle()

static HLOCAL EDIT_EM_GetHandle ( EDITSTATE es)
static

Definition at line 2560 of file edit.c.

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

2607{
2608 LPWSTR src;
2609 INT line_len, dst_len;
2610 INT i;
2611
2612 if (es->style & ES_MULTILINE) {
2613 if (line >= es->line_count)
2614 return 0;
2615 } else
2616 line = 0;
2618 src = es->text + i;
2619 line_len = EDIT_EM_LineLength(es, i);
2620 dst_len = *(WORD *)dst;
2621 if(unicode)
2622 {
2623 if(dst_len <= line_len)
2624 {
2625 memcpy(dst, src, dst_len * sizeof(WCHAR));
2626 return dst_len;
2627 }
2628 else /* Append 0 if enough space */
2629 {
2630 memcpy(dst, src, line_len * sizeof(WCHAR));
2631 dst[line_len] = 0;
2632 return line_len;
2633 }
2634 }
2635 else
2636 {
2637 INT ret = WideCharToMultiByte(CP_ACP, 0, src, line_len, (LPSTR)dst, dst_len, NULL, NULL);
2638 if(!ret && line_len) /* Insufficient buffer size */
2639 return dst_len;
2640 if(ret < dst_len) /* Append 0 if enough space */
2641 ((LPSTR)dst)[ret] = 0;
2642 return ret;
2643 }
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:943
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:978
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 2651 of file edit.c.

2653{
2654 UINT s = es->selection_start;
2655 UINT e = es->selection_end;
2656
2657 ORDER_UINT(s, e);
2658 if (start)
2659 *start = s;
2660 if (end)
2661 *end = e;
2662 return MAKELONG(s, e);
#define ORDER_UINT(x, y)
Definition: edit.c:165
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 4470 of file edit.c.

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

◆ EDIT_EM_LineFromChar()

static INT EDIT_EM_LineFromChar ( EDITSTATE es,
INT  index 
)
static

Definition at line 1009 of file edit.c.

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

◆ EDIT_EM_LineIndex()

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

Definition at line 1038 of file edit.c.

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

◆ EDIT_EM_LineLength()

static INT EDIT_EM_LineLength ( EDITSTATE es,
INT  index 
)
static

Definition at line 1073 of file edit.c.

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

◆ EDIT_EM_LineScroll()

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

Definition at line 1809 of file edit.c.

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

◆ EDIT_EM_LineScroll_internal()

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

Definition at line 1753 of file edit.c.

1755{
1756 INT nyoff;
1757 INT x_offset_in_pixels;
1758 INT lines_per_page = (es->format_rect.bottom - es->format_rect.top) /
1759 es->line_height;
1760
1761 if (es->style & ES_MULTILINE)
1762 {
1763 x_offset_in_pixels = es->x_offset;
1764 }
1765 else
1766 {
1767 dy = 0;
1768 x_offset_in_pixels = (short)LOWORD(EDIT_EM_PosFromChar(es, es->x_offset, FALSE));
1769 }
1770
1771 if (-dx > x_offset_in_pixels)
1772 dx = -x_offset_in_pixels;
1773 if (dx > es->text_width - x_offset_in_pixels)
1774 dx = es->text_width - x_offset_in_pixels;
1775 nyoff = max(0, es->y_offset + dy);
1776 if (nyoff >= es->line_count - lines_per_page)
1777 nyoff = max(0, es->line_count - lines_per_page);
1778 dy = (es->y_offset - nyoff) * es->line_height;
1779 if (dx || dy) {
1780 RECT rc1;
1781 RECT rc;
1782
1783 es->y_offset = nyoff;
1784 if(es->style & ES_MULTILINE)
1785 es->x_offset += dx;
1786 else
1787 es->x_offset += dx / es->char_width;
1788
1789 GetClientRect(es->hwndSelf, &rc1);
1790 IntersectRect(&rc, &rc1, &es->format_rect);
1791 ScrollWindowEx(es->hwndSelf, -dx, dy,
1792 NULL, &rc, NULL, NULL, SW_INVALIDATE);
1793 /* force scroll info update */
1795 }
1796 if (dx && !(es->flags & EF_HSCROLL_TRACK))
1798 if (dy && !(es->flags & EF_VSCROLL_TRACK))
1800 return TRUE;
static BOOL notify_parent(const EDITSTATE *es, INT code)
Definition: edit.c:167
#define EF_HSCROLL_TRACK
Definition: edit.c:73
#define EF_VSCROLL_TRACK
Definition: edit.c:72
#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 1109 of file edit.c.

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

◆ EDIT_EM_ReplaceSel()

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

Definition at line 2672 of file edit.c.

2674{
2675 UINT strl = strlenW(lpsz_replace);
2676 UINT tl = get_text_length(es);
2677 UINT utl;
2678 UINT s;
2679 UINT e;
2680 UINT i;
2681 UINT size;
2682 LPWSTR p;
2683 HRGN hrgn = 0;
2684 LPWSTR buf = NULL;
2685 UINT bufl;
2686
2687 TRACE("%s, can_undo %d, send_update %d\n",
2688 debugstr_w(lpsz_replace), can_undo, send_update);
2689
2690 s = es->selection_start;
2691 e = es->selection_end;
2692
2694 if ((s == e) && !strl)
2695 return;
2696
2697 ORDER_UINT(s, e);
2698
2699 size = tl - (e - s) + strl;
2700 if (!size)
2701 es->text_width = 0;
2702
2703 /* Issue the EN_MAXTEXT notification and continue with replacing text
2704 * so that buffer limit is honored. */
2705 if ((honor_limit) && (size > es->buffer_limit))
2706 {
2707 if (!notify_parent(es, EN_MAXTEXT)) return;
2708 /* Buffer limit can be smaller than the actual length of text in combobox */
2709 if (es->buffer_limit < (tl - (e-s)))
2710 strl = 0;
2711 else
2712 strl = min(strl, es->buffer_limit - (tl - (e-s)));
2713 }
2714
2715 if (!EDIT_MakeFit(es, tl - (e - s) + strl))
2716 return;
2717
2718 if (e != s) {
2719 /* there is something to be deleted */
2720 TRACE("deleting stuff.\n");
2721 bufl = e - s;
2722 buf = HeapAlloc(GetProcessHeap(), 0, (bufl + 1) * sizeof(WCHAR));
2723 if (!buf) return;
2724 memcpy(buf, es->text + s, bufl * sizeof(WCHAR));
2725 buf[bufl] = 0; /* ensure 0 termination */
2726 /* now delete */
2727 strcpyW(es->text + s, es->text + e);
2729 }
2730 if (strl) {
2731 /* there is an insertion */
2732 tl = get_text_length(es);
2733 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));
2734 for (p = es->text + tl ; p >= es->text + s ; p--)
2735 p[strl] = p[0];
2736 for (i = 0 , p = es->text + s ; i < strl ; i++)
2737 p[i] = lpsz_replace[i];
2738 if(es->style & ES_UPPERCASE)
2739 CharUpperBuffW(p, strl);
2740 else if(es->style & ES_LOWERCASE)
2741 CharLowerBuffW(p, strl);
2743 }
2744 if (es->style & ES_MULTILINE)
2745 {
2746 INT st = min(es->selection_start, es->selection_end);
2748
2749 hrgn = CreateRectRgn(0, 0, 0, 0);
2750 EDIT_BuildLineDefs_ML(es, st, st + strl,
2751 strl - abs(es->selection_end - es->selection_start), hrgn);
2752 /* if text is too long undo all changes */
2753 if (honor_limit && !(es->style & ES_AUTOVSCROLL) && (es->line_count > vlc)) {
2754 if (strl)
2755 strcpyW(es->text + e, es->text + e + strl);
2756 if (e != s)
2757 for (i = 0 , p = es->text ; i < e - s ; i++)
2758 p[i + s] = buf[i];
2761 abs(es->selection_end - es->selection_start) - strl, hrgn);
2762 strl = 0;
2763 e = s;
2764 hrgn = CreateRectRgn(0, 0, 0, 0);
2765 if (!notify_parent(es, EN_MAXTEXT)) return;
2766 }
2767 }
2768 else {
2769 INT fw = es->format_rect.right - es->format_rect.left;
2772 /* remove chars that don't fit */
2773 if (honor_limit && !(es->style & ES_AUTOHSCROLL) && (es->text_width > fw)) {
2774 while ((es->text_width > fw) && s + strl >= s) {
2775 strcpyW(es->text + s + strl - 1, es->text + s + strl);
2776 strl--;
2777 es->text_length = -1;
2780 }
2782 if (!notify_parent(es, EN_MAXTEXT)) return;
2783 }
2784 }
2785
2786 if (e != s) {
2787 if (can_undo) {
2788 utl = strlenW(es->undo_text);
2789 if (!es->undo_insert_count && (*es->undo_text && (s == es->undo_position))) {
2790 /* undo-buffer is extended to the right */
2791 EDIT_MakeUndoFit(es, utl + e - s);
2792 memcpy(es->undo_text + utl, buf, (e - s)*sizeof(WCHAR));
2793 (es->undo_text + utl)[e - s] = 0; /* ensure 0 termination */
2794 } else if (!es->undo_insert_count && (*es->undo_text && (e == es->undo_position))) {
2795 /* undo-buffer is extended to the left */
2796 EDIT_MakeUndoFit(es, utl + e - s);
2797 for (p = es->undo_text + utl ; p >= es->undo_text ; p--)
2798 p[e - s] = p[0];
2799 for (i = 0 , p = es->undo_text ; i < e - s ; i++)
2800 p[i] = buf[i];
2801 es->undo_position = s;
2802 } else {
2803 /* new undo-buffer */
2804 EDIT_MakeUndoFit(es, e - s);
2805 memcpy(es->undo_text, buf, (e - s)*sizeof(WCHAR));
2806 es->undo_text[e - s] = 0; /* ensure 0 termination */
2807 es->undo_position = s;
2808 }
2809 /* any deletion makes the old insertion-undo invalid */
2810 es->undo_insert_count = 0;
2811 } else
2813 }
2814 if (strl) {
2815 if (can_undo) {
2816 if ((s == es->undo_position) ||
2817 ((es->undo_insert_count) &&
2818 (s == es->undo_position + es->undo_insert_count)))
2819 /*
2820 * insertion is new and at delete position or
2821 * an extension to either left or right
2822 */
2823 es->undo_insert_count += strl;
2824 else {
2825 /* new insertion undo */
2826 es->undo_position = s;
2827 es->undo_insert_count = strl;
2828 /* new insertion makes old delete-buffer invalid */
2829 *es->undo_text = '\0';
2830 }
2831 } else
2833 }
2834
2836
2837 s += strl;
2838
2839 /* If text has been deleted and we're right or center aligned then scroll rightward */
2840 if (es->style & (ES_RIGHT | ES_CENTER))
2841 {
2842 INT delta = strl - abs(es->selection_end - es->selection_start);
2843
2844 if (delta < 0 && es->x_offset)
2845 {
2846 if (abs(delta) > es->x_offset)
2847 es->x_offset = 0;
2848 else
2849 es->x_offset += delta;
2850 }
2851 }
2852
2854 es->flags |= EF_MODIFIED;
2855 if (send_update) es->flags |= EF_UPDATE;
2856 if (hrgn)
2857 {
2860 }
2861 else
2863
2865
2866 /* force scroll info update */
2868
2869
2870 if(send_update || (es->flags & EF_UPDATE))
2871 {
2872 es->flags &= ~EF_UPDATE;
2873 if (!notify_parent(es, EN_CHANGE)) return;
2874 }
#define EF_MODIFIED
Definition: edit.c:69
static void EDIT_CalcLineWidth_SL(EDITSTATE *es)
Definition: edit.c:762
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1772
#define EF_UPDATE
Definition: edit.c:71
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:316
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:193
static void text_buffer_changed(EDITSTATE *es)
Definition: edit.c:1195
static BOOL EDIT_MakeFit(EDITSTATE *es, UINT size)
Definition: edit.c:1273
static BOOL EDIT_MakeUndoFit(EDITSTATE *es, UINT size)
Definition: edit.c:1314
static void EDIT_UpdateTextRegion(EDITSTATE *es, HRGN hrgn, BOOL bErase)
Definition: edit.c:1341
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1356
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1486
#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 1824 of file edit.c.

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

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

◆ EDIT_EM_SetHandle()

static void EDIT_EM_SetHandle ( EDITSTATE es,
HLOCAL  hloc 
)
static

Definition at line 2885 of file edit.c.

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

◆ EDIT_EM_SetLimitText()

static void EDIT_EM_SetLimitText ( EDITSTATE es,
UINT  limit 
)
static

Definition at line 2961 of file edit.c.

2963{
2964 if (!limit) limit = ~0u;
2965 if (!(es->style & ES_MULTILINE)) limit = min(limit, 0x7ffffffe);
2966 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 2997 of file edit.c.

3000{
3002 INT default_left_margin = 0; /* in pixels */
3003 INT default_right_margin = 0; /* in pixels */
3004
3005 /* Set the default margins depending on the font */
3006 if (es->font && (left == EC_USEFONTINFO || right == EC_USEFONTINFO)) {
3007 HDC dc = GetDC(es->hwndSelf);
3008 HFONT old_font = SelectObject(dc, es->font);
3010 RECT rc;
3011
3012 /* The default margins are only non zero for TrueType or Vector fonts */
3013 if (tm.tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE )) {
3014 if (!is_cjk(tm.tmCharSet)) {
3015 default_left_margin = width / 2;
3016 default_right_margin = width / 2;
3017
3018 GetClientRect(es->hwndSelf, &rc);
3019 if (rc.right - rc.left < (width / 2 + width) * 2 &&
3020 (width >= 28 || !IsRectEmpty(&rc)) ) {
3021 default_left_margin = es->left_margin;
3022 default_right_margin = es->right_margin;
3023 }
3024 } else {
3025 /* FIXME: figure out the CJK values. They are not affected by the client rect. */
3026 default_left_margin = width / 2;
3027 default_right_margin = width / 2;
3028 }
3029 }
3030 SelectObject(dc, old_font);
3031 ReleaseDC(es->hwndSelf, dc);
3032 }
3033
3034 if (action & EC_LEFTMARGIN) {
3035 es->format_rect.left -= es->left_margin;
3036 if (left != EC_USEFONTINFO)
3037 es->left_margin = left;
3038 else
3039 es->left_margin = default_left_margin;
3040 es->format_rect.left += es->left_margin;
3041 }
3042
3043 if (action & EC_RIGHTMARGIN) {
3044 es->format_rect.right += es->right_margin;
3045 if (right != EC_USEFONTINFO)
3046 es->right_margin = right;
3047 else
3048 es->right_margin = default_right_margin;
3049 es->format_rect.right -= es->right_margin;
3050 }
3051
3054 if (repaint) EDIT_UpdateText(es, NULL, TRUE);
3055 }
3056
3057 TRACE("left=%d, right=%d\n", es->left_margin, es->right_margin);
static void EDIT_AdjustFormatRect(EDITSTATE *es)
Definition: edit.c:2255
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 3065 of file edit.c.

3067{
3068 LONG style;
3069
3070 if (es->style & ES_MULTILINE)
3071 return;
3072
3073 if (es->password_char == c)
3074 return;
3075
3076 style = GetWindowLongW( es->hwndSelf, GWL_STYLE );
3077 es->password_char = c;
3078 if (c) {
3079 SetWindowLongW( es->hwndSelf, GWL_STYLE, style | ES_PASSWORD );
3080 es->style |= ES_PASSWORD;
3081 } else {
3082 SetWindowLongW( es->hwndSelf, GWL_STYLE, style & ~ES_PASSWORD );
3083 es->style &= ~ES_PASSWORD;
3084 }
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 1646 of file edit.c.

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

◆ EDIT_EM_SetTabStops()

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

Definition at line 3094 of file edit.c.

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

◆ EDIT_EM_SetWordBreakProc()

static void EDIT_EM_SetWordBreakProc ( EDITSTATE es,
void wbp 
)
static

Definition at line 3124 of file edit.c.

3126{
3127 if (es->word_break_proc == wbp)
3128 return;
3129
3130 es->word_break_proc = wbp;
3131
3132 if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
3135 }

◆ EDIT_EM_Undo()

static BOOL EDIT_EM_Undo ( EDITSTATE es)
static

Definition at line 3143 of file edit.c.

3145{
3146 INT ulength;
3147 LPWSTR utext;
3148
3149 /* As per MSDN spec, for a single-line edit control,
3150 the return value is always TRUE */
3151 if( es->style & ES_READONLY )
3152 return !(es->style & ES_MULTILINE);
3153
3154 ulength = strlenW(es->undo_text);
3155
3156 utext = HeapAlloc(GetProcessHeap(), 0, (ulength + 1) * sizeof(WCHAR));
3157#ifdef __REACTOS__
3158 /* ReactOS r33503 */
3159 if (utext == NULL)
3160 return FALSE;
3161#endif
3162
3163 strcpyW(utext, es->undo_text);
3164
3165 TRACE("before UNDO:insertion length = %d, deletion buffer = %s\n",
3166 es->undo_insert_count, debugstr_w(utext));
3167
3168 EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
3170 EDIT_EM_ReplaceSel(es, TRUE, utext, TRUE, TRUE);
3171 EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
3172 /* send the notification after the selection start and end are set */
3173 if (!notify_parent(es, EN_CHANGE)) return TRUE;
3175 HeapFree(GetProcessHeap(), 0, utext);
3176
3177 TRACE("after UNDO:insertion length = %d, deletion buffer = %s\n",
3178 es->undo_insert_count, debugstr_w(es->undo_text));
3179 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:2479
#define ES_READONLY
Definition: pedump.c:675

◆ EDIT_GetCompositionStr()

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

Definition at line 4482 of file edit.c.

4484{
4485 LONG buflen;
4486 LPWSTR lpCompStr;
4487 LPSTR lpCompStrAttr = NULL;
4488 DWORD dwBufLenAttr;
4489
4490 buflen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
4491
4492 if (buflen < 0)
4493 {
4494 return;
4495 }
4496
4497 lpCompStr = HeapAlloc(GetProcessHeap(),0,buflen + sizeof(WCHAR));
4498 if (!lpCompStr)
4499 {
4500 ERR("Unable to allocate IME CompositionString\n");
4501 return;
4502 }
4503
4504 if (buflen)
4505 ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, buflen);
4506 lpCompStr[buflen/sizeof(WCHAR)] = 0;
4507
4508 if (CompFlag & GCS_COMPATTR)
4509 {
4510 /*
4511 * We do not use the attributes yet. it would tell us what characters
4512 * are in transition and which are converted or decided upon
4513 */
4514 dwBufLenAttr = ImmGetCompositionStringW(hIMC, GCS_COMPATTR, NULL, 0);
4515 if (dwBufLenAttr)
4516 {
4517 dwBufLenAttr ++;
4518 lpCompStrAttr = HeapAlloc(GetProcessHeap(),0,dwBufLenAttr+1);
4519 if (!lpCompStrAttr)
4520 {
4521 ERR("Unable to allocate IME Attribute String\n");
4522 HeapFree(GetProcessHeap(),0,lpCompStr);
4523 return;
4524 }
4525 ImmGetCompositionStringW(hIMC,GCS_COMPATTR, lpCompStrAttr,
4526 dwBufLenAttr);
4527 lpCompStrAttr[dwBufLenAttr] = 0;
4528 }
4529 }
4530
4531#ifndef __REACTOS__ /* We don't use internal composition string. Rely on the composition window */
4532 /* check for change in composition start */
4533 if (es->selection_end < es->composition_start)
4534 es->composition_start = es->selection_end;
4535
4536 /* replace existing selection string */
4537 es->selection_start = es->composition_start;
4538
4539 if (es->composition_len > 0)
4540 es->selection_end = es->composition_start + es->composition_len;
4541 else
4542 es->selection_end = es->selection_start;
4543
4544 EDIT_EM_ReplaceSel(es, FALSE, lpCompStr, TRUE, TRUE);
4545 es->composition_len = abs(es->composition_start - es->selection_end);
4546
4547 es->selection_start = es->composition_start;
4548 es->selection_end = es->selection_start + es->composition_len;
4549#endif
4550
4551 HeapFree(GetProcessHeap(),0,lpCompStrAttr);
4552 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 1239 of file edit.c.

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

◆ EDIT_GetResultStr()

static void EDIT_GetResultStr ( HIMC  hIMC,
EDITSTATE es 
)
static

Definition at line 4554 of file edit.c.

4556{
4557 LONG buflen;
4558 LPWSTR lpResultStr;
4559
4560 buflen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
4561 if (buflen <= 0)
4562 {
4563 return;
4564 }
4565
4566 lpResultStr = HeapAlloc(GetProcessHeap(),0, buflen+sizeof(WCHAR));
4567 if (!lpResultStr)
4568 {
4569 ERR("Unable to alloc buffer for IME string\n");
4570 return;
4571 }
4572
4573 ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpResultStr, buflen);
4574 lpResultStr[buflen/sizeof(WCHAR)] = 0;
4575
4576#ifndef __REACTOS__
4577 /* check for change in composition start */
4578 if (es->selection_end < es->composition_start)
4579 es->composition_start = es->selection_end;
4580
4581 es->selection_start = es->composition_start;
4582 es->selection_end = es->composition_start + es->composition_len;
4583 EDIT_EM_ReplaceSel(es, TRUE, lpResultStr, TRUE, TRUE);
4584 es->composition_start = es->selection_end;
4585 es->composition_len = 0;
4586#endif
4587
4588 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 4590 of file edit.c.

4592{
4593 HIMC hIMC;
4594 int cursor;
4595
4596#ifdef __REACTOS__
4597 if (es->selection_start != es->selection_end)
4599#else
4600 if (es->composition_len == 0 && es->selection_start != es->selection_end)
4601 {
4603 es->composition_start = es->selection_end;
4604 }
4605#endif
4606
4607 hIMC = ImmGetContext(hwnd);
4608 if (!hIMC)
4609 return;
4610
4611 if (CompFlag & GCS_RESULTSTR)
4612 {
4613 EDIT_GetResultStr(hIMC, es);
4614 cursor = 0;
4615 }
4616 else
4617 {
4618 if (CompFlag & GCS_COMPSTR)
4619 EDIT_GetCompositionStr(hIMC, CompFlag, es);
4620#ifdef __REACTOS__
4621 cursor = 0;
4622#else
4624#endif
4625 }
4626 ImmReleaseContext(hwnd, hIMC);
4627 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:4330
static void EDIT_GetCompositionStr(HIMC hIMC, LPARAM CompFlag, EDITSTATE *es)
Definition: edit.c:4259
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:173

◆ EDIT_InvalidateText()

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

Definition at line 1616 of file edit.c.

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

◆ EDIT_InvalidateUniscribeData()

static void EDIT_InvalidateUniscribeData ( EDITSTATE es)
inlinestatic

Definition at line 391 of file edit.c.

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

◆ EDIT_InvalidateUniscribeData_linedef()

static void EDIT_InvalidateUniscribeData_linedef ( LINEDEF line_def)
inlinestatic

Definition at line 382 of file edit.c.

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

◆ EDIT_IsInsideDialog()

static BOOL EDIT_IsInsideDialog ( EDITSTATE es)
inlinestatic

Definition at line 3189 of file edit.c.

3191{
3192 return (es->flags & EF_DIALOGMODE);
#define EF_DIALOGMODE
Definition: edit.c:76

◆ EDIT_LockBuffer()

static void EDIT_LockBuffer ( EDITSTATE es)
static

Definition at line 1303 of file edit.c.

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

◆ EDIT_MakeFit()

static BOOL EDIT_MakeFit ( EDITSTATE es,
UINT  size 
)
static

Definition at line 1433 of file edit.c.

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

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

◆ EDIT_ML_InvalidateText()

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

Definition at line 1551 of file edit.c.

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

◆ EDIT_MoveBackward()

static void EDIT_MoveBackward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1997 of file edit.c.

1999{
2000 INT e = es->selection_end;
2001
2002 if (e) {
2003 e--;
2004 if ((es->style & ES_MULTILINE) && e &&
2005 (es->text[e - 1] == '\r') && (es->text[e] == '\n')) {
2006 e--;
2007 if (e && (es->text[e - 1] == '\r'))
2008 e--;
2009 }
2010 }
2011 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 2024 of file edit.c.

2026{
2027 INT s = es->selection_start;
2028 INT e = es->selection_end;
2029 BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
2030 LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
2031 INT x = (short)LOWORD(pos);
2032 INT y = (short)HIWORD(pos);
2033
2034 e = EDIT_CharFromPos(es, x, y + es->line_height, &after_wrap);
2035 if (!extend)
2036 s = e;
2037 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 2046 of file edit.c.

2048{
2049 BOOL after_wrap = FALSE;
2050 INT e;
2051
2052 /* Pass a high value in x to make sure of receiving the end of the line */
2053 if (!ctrl && (es->style & ES_MULTILINE))
2054 e = EDIT_CharFromPos(es, 0x3fffffff,
2055 HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap);
2056 else
2057 e = get_text_length(es);
2058 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 2067 of file edit.c.

2069{
2070 INT e = es->selection_end;
2071
2072 if (es->text[e]) {
2073 e++;
2074 if ((es->style & ES_MULTILINE) && (es->text[e - 1] == '\r')) {
2075 if (es->text[e] == '\n')
2076 e++;
2077 else if ((es->text[e] == '\r') && (es->text[e + 1] == '\n'))
2078 e += 2;
2079 }
2080 }
2081 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 2092 of file edit.c.

2094{
2095 INT e;
2096
2097 /* Pass the x_offset in x to make sure of receiving the first position of the line */
2098 if (!ctrl && (es->style & ES_MULTILINE))
2099 e = EDIT_CharFromPos(es, -es->x_offset,
2100 HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL);
2101 else
2102 e = 0;
2103 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 2116 of file edit.c.

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

◆ EDIT_MovePageUp_ML()

static void EDIT_MovePageUp_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2144 of file edit.c.

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

◆ EDIT_MoveUp_ML()

static void EDIT_MoveUp_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2172 of file edit.c.

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

◆ EDIT_MoveWordBackward()

static void EDIT_MoveWordBackward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2194 of file edit.c.

2196{
2197 INT s = es->selection_start;
2198 INT e = es->selection_end;
2199 INT l;
2200 INT ll;
2201 INT li;
2202
2206 if (e - li == 0) {
2207 if (l) {
2208 li = EDIT_EM_LineIndex(es, l - 1);
2209 e = li + EDIT_EM_LineLength(es, li);
2210 }
2211 } else {
2213 }
2214 if (!extend)
2215 s = e;
w ll
Definition: byte_order.h:167

◆ EDIT_MoveWordForward()

static void EDIT_MoveWordForward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2225 of file edit.c.

2227{
2228 INT s = es->selection_start;
2229 INT e = es->selection_end;
2230 INT l;
2231 INT ll;
2232 INT li;
2233
2237 if (e - li == ll) {
2238 if ((es->style & ES_MULTILINE) && (l != es->line_count - 1))
2239 e = EDIT_EM_LineIndex(es, l + 1);
2240 } else {
2242 li, e - li + 1, ll, WB_RIGHT);
2243 }
2244 if (!extend)
2245 s = e;
#define WB_RIGHT
Definition: winuser.h:551

◆ EDIT_NotifyCtlColor()

static HBRUSH EDIT_NotifyCtlColor ( EDITSTATE es,
HDC  hdc 
)
static

Definition at line 242 of file edit.c.

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

2331{
2332 INT s = 0;
2333 INT e = 0;
2334 INT li = 0;
2335 INT ll = 0;
2336 INT x;
2337 INT y;
2338 LRESULT pos;
2340
2341 if (es->style & ES_MULTILINE) {
2343
2344 if ((line < es->y_offset) || (line > es->y_offset + vlc) || (line >= es->line_count))
2345 return;
2346 } else if (line)
2347 return;
2348
2349 TRACE("line=%d\n", line);
2350
2353 x = (short)LOWORD(pos);
2354 y = (short)HIWORD(pos);
2355
2356 if (es->style & ES_MULTILINE)
2357 {
2358 int line_idx = line;
2359 x = -es->x_offset;
2360 if (es->style & ES_RIGHT || es->style & ES_CENTER)
2361 {
2362 LINEDEF *line_def = es->first_line_def;
2363 int w, lw;
2364
2365 while (line_def && line_idx)
2366 {
2367 line_def = line_def->next;
2368 line_idx--;
2369 }
2370 w = es->format_rect.right - es->format_rect.left;
2371 lw = line_def->width;
2372
2373 if (es->style & ES_RIGHT)
2374 x = w - (lw - x);
2375 else if (es->style & ES_CENTER)
2376 x += (w - lw) / 2;
2377 }
2378 x += es->format_rect.left;
2379 }
2380
2381 if (rev)
2382 {
2385 s = min(es->selection_start, es->selection_end);
2386 e = max(es->selection_start, es->selection_end);
2387 s = min(li + ll, max(li, s));
2388 e = min(li + ll, max(li, e));
2389 }
2390
2391 if (ssa)
2392 ScriptStringOut(ssa, x, y, 0, &es->format_rect, s - li, e - li, FALSE);
2393 else if (rev && (s != e) &&
2394 ((es->flags & EF_FOCUSED) || (es->style & ES_NOHIDESEL))) {
2395 x += EDIT_PaintText(es, dc, x, y, line, 0, s - li, FALSE);
2396 x += EDIT_PaintText(es, dc, x, y, line, s - li, e - s, TRUE);
2397 x += EDIT_PaintText(es, dc, x, y, line, e - li, li + ll - e, FALSE);
2398 } else
2399 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:2100
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 2255 of file edit.c.

2257{
2258 COLORREF BkColor;
2259 COLORREF TextColor;
2260 LOGFONTW underline_font;
2261 HFONT hUnderline = 0;
2262 HFONT old_font = 0;
2263 INT ret;
2264 INT li;
2265 INT BkMode;
2266 SIZE size;
2267
2268 if (!count)
2269 return 0;
2270 BkMode = GetBkMode(dc);
2271 BkColor = GetBkColor(dc);
2272 TextColor = GetTextColor(dc);
2273 if (rev) {
2274#ifdef __REACTOS__
2275 if (TRUE)
2276#else
2277 if (es->composition_len == 0)
2278#endif
2279 {
2282 SetBkMode( dc, OPAQUE);
2283 }
2284 else
2285 {
2287 GetObjectW(current,sizeof(LOGFONTW),&underline_font);
2288 underline_font.lfUnderline = TRUE;
2289 hUnderline = CreateFontIndirectW(&underline_font);
2290 old_font = SelectObject(dc,hUnderline);
2291 }
2292 }
2294 if (es->style & ES_MULTILINE) {
2295 ret = (INT)LOWORD(TabbedTextOutW(dc, x, y, es->text + li + col, count,
2296 es->tabs_count, es->tabs, es->format_rect.left - es->x_offset));
2297 } else {
2298 TextOutW(dc, x, y, es->text + li + col, count);
2299 GetTextExtentPoint32W(dc, es->text + li + col, count, &size);
2300 ret = size.cx;
2301 }
2302 if (rev) {
2303#ifdef __REACTOS__
2304 if (TRUE)
2305#else
2306 if (es->composition_len == 0)
2307#endif
2308 {
2309 SetBkColor(dc, BkColor);
2310 SetTextColor(dc, TextColor);
2311 SetBkMode( dc, BkMode);
2312 }
2313 else
2314 {
2315 if (old_font)
2316 SelectObject(dc,old_font);
2317 if (hUnderline)
2318 DeleteObject(hUnderline);
2319 }
2320 }
2321 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 1902 of file edit.c.

1905{
1906 LRESULT res = EDIT_EM_PosFromChar(es, pos, after_wrap);
1907#ifdef __REACTOS__
1908 HKL hKL = GetKeyboardLayout(0);
1909 POINT pt = { (short)LOWORD(res), (short)HIWORD(res) };
1910 SetCaretPos(pt.x, pt.y);
1911
1912 if (!ImmIsIME(hKL))
1913 return;
1914
1915 EDIT_ImmSetCompositionWindow(es, pt);
1916#else
1917 TRACE("%d - %dx%d\n", pos, (short)LOWORD(res), (short)HIWORD(res));
1918 SetCaretPos((short)LOWORD(res), (short)HIWORD(res));
1919#endif
BOOL WINAPI ImmIsIME(HKL hKL)
Definition: ime.c:880
GLuint res
Definition: glext.h:9613
UINT_PTR HKL
Definition: msctf.idl:104
HKL WINAPI GetKeyboardLayout(_In_ DWORD)
BOOL WINAPI SetCaretPos(_In_ int, _In_ int)

◆ EDIT_SetRectNP()

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

Definition at line 2461 of file edit.c.

2463{
2465 INT bw, bh;
2467
2468 CopyRect(&es->format_rect, rc);
2469
2470 if (ExStyle & WS_EX_CLIENTEDGE) {
2471 es->format_rect.left++;
2472 es->format_rect.right--;
2473
2474 if (es->format_rect.bottom - es->format_rect.top
2475 >= es->line_height + 2)
2476 {
2477 es->format_rect.top++;
2478 es->format_rect.bottom--;
2479 }
2480 }
2481 else if (es->style & WS_BORDER) {
2483 bh = GetSystemMetrics(SM_CYBORDER) + 1;
2484 es->format_rect.left += bw;
2485 es->format_rect.right -= bw;
2486 if (es->format_rect.bottom - es->format_rect.top
2487 >= es->line_height + 2 * bh)
2488 {
2489 es->format_rect.top += bh;
2490 es->format_rect.bottom -= bh;
2491 }
2492 }
2493
2494 es->format_rect.left += es->left_margin;
2495 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 1533 of file edit.c.

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

◆ EDIT_UnlockBuffer()

static void EDIT_UnlockBuffer ( EDITSTATE es,
BOOL  force 
)
static

Definition at line 1366 of file edit.c.

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

◆ EDIT_UpdateScrollInfo()

static void EDIT_UpdateScrollInfo ( EDITSTATE es)
static

Definition at line 1712 of file edit.c.

1714{
1715 if ((es->style & WS_VSCROLL) && !(es->flags & EF_VSCROLL_TRACK))
1716 {
1717 SCROLLINFO si;
1718 si.cbSize = sizeof(SCROLLINFO);
1720 si.nMin = 0;
1721 si.nMax = es->line_count - 1;
1722 si.nPage = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
1723 si.nPos = es->y_offset;
1724 TRACE("SB_VERT, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n",
1725 si.nMin, si.nMax, si.nPage, si.nPos);
1726 SetScrollInfo(es->hwndSelf, SB_VERT, &si, TRUE);
1727 }
1728
1729 if ((es->style & WS_HSCROLL) && !(es->flags & EF_HSCROLL_TRACK))
1730 {
1731 SCROLLINFO si;
1732 si.cbSize = sizeof(SCROLLINFO);
1734 si.nMin = 0;
1735 si.nMax = es->text_width - 1;
1736 si.nPage = es->format_rect.right - es->format_rect.left;
1737 si.nPos = es->x_offset;
1738 TRACE("SB_HORZ, nMin=%d, nMax=%d, nPage=%d, nPos=%d\n",
1739 si.nMin, si.nMax, si.nPage, si.nPos);
1740 SetScrollInfo(es->hwndSelf, SB_HORZ, &si, TRUE);
1741 }
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
struct tagSCROLLINFO SCROLLINFO
#define SIF_RANGE
Definition: winuser.h: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 1516 of file edit.c.

1518{
1519 if (es->flags & EF_UPDATE) {
1520 es->flags &= ~EF_UPDATE;
1521 if (!notify_parent(es, EN_UPDATE)) return;
1522 }
1523 InvalidateRect(es->hwndSelf, rc, bErase);
#define EN_UPDATE
Definition: winuser.h: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 1501 of file edit.c.

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

◆ EDIT_UpdateUniscribeData()

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

Definition at line 453 of file edit.c.

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

◆ EDIT_UpdateUniscribeData_linedef()

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

Definition at line 406 of file edit.c.

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

◆ EDIT_WM_Char()

static LRESULT EDIT_WM_Char ( EDITSTATE es,
WCHAR  c 
)
static

Definition at line 3284 of file edit.c.

3286{
3287 BOOL control;
3288
3289 control = GetKeyState(VK_CONTROL) & 0x8000;
3290
3291 switch (c) {
3292 case '\r':
3293 /* If it's not a multiline edit box, it would be ignored below.
3294 * For multiline edit without ES_WANTRETURN, we have to make a
3295 * special case.
3296 */
3297 if ((es->style & ES_MULTILINE) && !(es->style & ES_WANTRETURN))
3299 break;
3300 case '\n':
3301 if (es->style & ES_MULTILINE) {
3302 if (es->style & ES_READONLY) {
3305 } else {
3306 static const WCHAR cr_lfW[] = {'\r','\n',0};
3307 EDIT_EM_ReplaceSel(es, TRUE, cr_lfW, TRUE, TRUE);
3308 }
3309 }
3310 break;
3311 case '\t':
3312 if ((es->style & ES_MULTILINE) && !(es->style & ES_READONLY))
3313 {
3314 static const WCHAR tabW[] = {'\t',0};
3316 break;
3318 }
3319 break;
3320 case VK_BACK:
3321 if (!(es->style & ES_READONLY) && !control) {
3322 if (es->selection_start != es->selection_end)
3324 else {
3325 /* delete character left of caret */
3326 EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
3329 }
3330 }
3331 break;
3332 case 0x03: /* ^C */
3333 if (!(es->style & ES_PASSWORD))
3334 SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
3335 break;
3336 case 0x16: /* ^V */
3337 if (!(es->style & ES_READONLY))
3338 SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3339 break;
3340 case 0x18: /* ^X */
3341 if (!((es->style & ES_READONLY) || (es->style & ES_PASSWORD)))
3342 SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
3343 break;
3344 case 0x1A: /* ^Z */
3345 if (!(es->style & ES_READONLY))
3346 SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
3347 break;
3348
3349 default:
3350 /*If Edit control style is ES_NUMBER allow users to key in only numeric values*/
3351 if( (es->style & ES_NUMBER) && !( c >= '0' && c <= '9') )
3352 break;
3353
3354 if (!(es->style & ES_READONLY) && (c >= ' ') && (c != 127)) {
3355 WCHAR str[2];
3356 str[0] = c;
3357 str[1] = '\0';
3359 }
3360 break;
3361 }
3362 return 1;
static BOOL EDIT_IsInsideDialog(EDITSTATE *es)
Definition: edit.c:2946
static void EDIT_MoveBackward(EDITSTATE *es, BOOL extend)
Definition: edit.c:1842
static void EDIT_MoveHome(EDITSTATE *es, BOOL extend, BOOL ctrl)
Definition: edit.c:1937
static void EDIT_WM_Clear(EDITSTATE *es)
Definition: edit.c:3022
static void EDIT_MoveDown_ML(EDITSTATE *es, BOOL extend)
Definition: edit.c:1869
#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 3257 of file edit.c.

3259{
3260 /* Protect read-only edit control from modification */
3261 if(es->style & ES_READONLY)
3262 return;
3263

◆ EDIT_WM_ContextMenu()

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

Definition at line 3414 of file edit.c.

3416{
3417 HMENU menu = LoadMenuA(user32_module, "EDITMENU");
3418 HMENU popup = GetSubMenu(menu, 0);
3419 UINT start = es->selection_start;
3420 UINT end = es->selection_end;
3421 UINT cmd;
3422
3424
3425 /* undo */
3427 /* cut */
3428 EnableMenuItem(popup, 2, MF_BYPOSITION | ((end - start) && !(es->style & ES_PASSWORD) && !(es->style & ES_READONLY) ? MF_ENABLED : MF_GRAYED));
3429 /* copy */
3430 EnableMenuItem(popup, 3, MF_BYPOSITION | ((end - start) && !(es->style & ES_PASSWORD) ? MF_ENABLED : MF_GRAYED));
3431 /* paste */
3433