ReactOS  0.4.14-dev-98-gb0d4763
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)
 
#define EDIT_NOTIFY_PARENT(es, wNotifyCode)
 

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 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 53 of file edit.c.

◆ EDIT_NOTIFY_PARENT

#define EDIT_NOTIFY_PARENT (   es,
  wNotifyCode 
)
Value:
do \
{ /* Notify parent which has created this edit control */ \
TRACE("notification " #wNotifyCode " sent to hwnd=%p\n", es->hwndParent); \
SendMessageW(es->hwndParent, WM_COMMAND, \
MAKEWPARAM(GetWindowLongPtrW((es->hwndSelf),GWLP_ID), wNotifyCode), \
(LPARAM)(es->hwndSelf)); \
} while(0)
#define MAKEWPARAM(l, h)
Definition: winuser.h:3948
#define GetWindowLongPtrW
Definition: winuser.h:4730
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_COMMAND
Definition: winuser.h:1722
#define es
Definition: i386-dis.c:431
#define GWLP_ID
Definition: winuser.h:854

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

◆ EF_DIALOGMODE

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

Definition at line 69 of file edit.c.

◆ EF_FOCUSED

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

Definition at line 62 of file edit.c.

◆ EF_HSCROLL_TRACK

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

Definition at line 65 of file edit.c.

◆ EF_MODIFIED

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

Definition at line 61 of file edit.c.

◆ EF_UPDATE

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

Definition at line 63 of file edit.c.

◆ EF_USE_SOFTBRK

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

Definition at line 68 of file edit.c.

◆ EF_VSCROLL_TRACK

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

Definition at line 64 of file edit.c.

◆ GROWLENGTH

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

Definition at line 54 of file edit.c.

◆ HSCROLL_FRACTION

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

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

◆ ROUND_TO_GROW

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

Definition at line 55 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 153 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 71 of file edit.c.

72 {
73  END_0 = 0, /* line ends with terminating '\0' character */
74  END_WRAP, /* line is wrapped */
75  END_HARD, /* line ends with a hard return '\r\n' */
76  END_SOFT, /* line ends with a soft return '\r\r\n' */
77  END_RICH /* line ends with a single '\n' */
78 } LINE_END;
LINE_END
Definition: edit.c:78
Definition: edit.c:83
Definition: edit.c:80
Definition: edit.c:81
Definition: edit.c:82
Definition: edit.c:84

Function Documentation

◆ DefWindowProcT()

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

Definition at line 4728 of file edit.c.

4729 {
4730  if(unicode)
4731  return DefWindowProcW(hwnd, msg, wParam, lParam);
4732  else
4733  return DefWindowProcA(hwnd, msg, wParam, lParam);
4734 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define msg(x)
Definition: auth_time.c:54
LPARAM lParam
Definition: combotst.c:139

Referenced by EditWndProc_common().

◆ EDIT_AdjustFormatRect()

static void EDIT_AdjustFormatRect ( EDITSTATE es)
static

Definition at line 2353 of file edit.c.

2354 {
2355  RECT ClientRect;
2356 
2357  es->format_rect.right = max(es->format_rect.right, es->format_rect.left + es->char_width);
2358  if (es->style & ES_MULTILINE)
2359  {
2360  INT fw, vlc, max_x_offset, max_y_offset;
2361 
2362  vlc = get_vertical_line_count(es);
2363  es->format_rect.bottom = es->format_rect.top + vlc * es->line_height;
2364 
2365  /* correct es->x_offset */
2366  fw = es->format_rect.right - es->format_rect.left;
2367  max_x_offset = es->text_width - fw;
2368  if(max_x_offset < 0) max_x_offset = 0;
2369  if(es->x_offset > max_x_offset)
2370  es->x_offset = max_x_offset;
2371 
2372  /* correct es->y_offset */
2373  max_y_offset = es->line_count - vlc;
2374  if(max_y_offset < 0) max_y_offset = 0;
2375  if(es->y_offset > max_y_offset)
2376  es->y_offset = max_y_offset;
2377 
2378  /* force scroll info update */
2380  }
2381  else
2382  /* Windows doesn't care to fix text placement for SL controls */
2383  es->format_rect.bottom = es->format_rect.top + es->line_height;
2384 
2385  /* Always stay within the client area */
2386  GetClientRect(es->hwndSelf, &ClientRect);
2387  es->format_rect.bottom = min(es->format_rect.bottom, ClientRect.bottom);
2388 
2389  if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL))
2391 
2392  EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP);
2393 }
#define max(a, b)
Definition: svc.c:63
static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap)
Definition: edit.c:1864
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:56
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:250
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define EF_AFTER_WRAP
Definition: edit.c:66
#define min(a, b)
Definition: monoChain.cc:55
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1701
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:505
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:490
LONG bottom
Definition: windef.h:294
#define es
Definition: i386-dis.c:431
#define ES_AUTOHSCROLL
Definition: pedump.c:672

Referenced by EDIT_EM_SetMargins(), and EDIT_SetRectNP().

◆ EDIT_BuildLineDefs_ML()

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

Definition at line 505 of file edit.c.

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

Referenced by EDIT_AdjustFormatRect(), EDIT_EM_ReplaceSel(), EDIT_EM_SetHandle(), EDIT_EM_SetWordBreakProc(), and EDIT_WM_SetFont().

◆ EDIT_CalcLineWidth_SL()

static void EDIT_CalcLineWidth_SL ( EDITSTATE es)
static

Definition at line 842 of file edit.c.

843 {
845  if (es->ssa)
846  {
847  const SIZE *size;
848  size = ScriptString_pSize(es->ssa);
849  es->text_width = size->cx;
850  }
851  else
852  es->text_width = 0;
853 }
smooth NULL
Definition: ftsmooth.c:416
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, INT line)
Definition: edit.c:438
GLsizeiptr size
Definition: glext.h:5919
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3871
#define es
Definition: i386-dis.c:431

Referenced by EDIT_EM_ReplaceSel(), and EDIT_WM_SetFont().

◆ EDIT_CallWordBreakProc()

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

Definition at line 328 of file edit.c.

329 {
330  INT ret;
331 
332  if (es->word_break_proc)
333  {
334  if(es->is_unicode)
335  {
336  EDITWORDBREAKPROCW wbpW = (EDITWORDBREAKPROCW)es->word_break_proc;
337 
338  TRACE_(relay)("(UNICODE wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
339  es->word_break_proc, debugstr_wn(es->text + start, count), index, count, action);
340  ret = wbpW(es->text + start, index, count, action);
341  }
342  else
343  {
344  EDITWORDBREAKPROCA wbpA = (EDITWORDBREAKPROCA)es->word_break_proc;
345  INT countA;
346  CHAR *textA;
347 
348  countA = WideCharToMultiByte(CP_ACP, 0, es->text + start, count, NULL, 0, NULL, NULL);
349  textA = HeapAlloc(GetProcessHeap(), 0, countA);
350 #ifdef __REACTOS__
351  /* ReactOS r33503 */
352  if (textA == NULL) return 0;
353 #endif
354  WideCharToMultiByte(CP_ACP, 0, es->text + start, count, textA, countA, NULL, NULL);
355  TRACE_(relay)("(ANSI wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
356  es->word_break_proc, debugstr_an(textA, countA), index, countA, action);
357  ret = wbpA(textA, index, countA, action);
359  }
360  }
361  else
363 
364  return ret;
365 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
GLuint GLuint GLsizei count
Definition: gl.h:1545
char CHAR
Definition: xmlstorage.h:175
int32_t INT
Definition: typedefs.h:56
int(CALLBACK * EDITWORDBREAKPROCA)(LPSTR, int, int, int)
Definition: winuser.h:2878
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define TRACE_(x)
Definition: compat.h:66
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static const char textA[]
Definition: registrar.c:40
int ret
#define index(s, c)
Definition: various.h:29
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:47
int(CALLBACK * EDITWORDBREAKPROCW)(LPWSTR, int, int, int)
Definition: winuser.h:2879
#define debugstr_wn
Definition: kernel32.h:33
const WCHAR * action
Definition: action.c:7783
GLuint start
Definition: gl.h:1545
#define es
Definition: i386-dis.c:431
static INT EDIT_WordBreakProc(EDITSTATE *es, LPWSTR s, INT index, INT count, INT action)
Definition: edit.c:270
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by EDIT_BuildLineDefs_ML(), EDIT_MoveWordBackward(), EDIT_MoveWordForward(), and EDIT_WM_LButtonDblClk().

◆ EDIT_CharFromPos()

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

Definition at line 865 of file edit.c.

866 {
867  INT index;
868 
869  if (es->style & ES_MULTILINE) {
870  int trailing;
871  INT line = (y - es->format_rect.top) / es->line_height + es->y_offset;
872  INT line_index = 0;
873  LINEDEF *line_def = es->first_line_def;
875  while ((line > 0) && line_def->next) {
876  line_index += line_def->length;
877  line_def = line_def->next;
878  line--;
879  }
880 
881  x += es->x_offset - es->format_rect.left;
882  if (es->style & ES_RIGHT)
883  x -= (es->format_rect.right - es->format_rect.left) - line_def->width;
884  else if (es->style & ES_CENTER)
885  x -= ((es->format_rect.right - es->format_rect.left) - line_def->width) / 2;
886  if (x >= line_def->width) {
887  if (after_wrap)
888  *after_wrap = (line_def->ending == END_WRAP);
889  return line_index + line_def->net_length;
890  }
891  if (x <= 0 || !line_def->ssa) {
892  if (after_wrap)
893  *after_wrap = FALSE;
894  return line_index;
895  }
896 
897  ScriptStringXtoCP(line_def->ssa, x , &index, &trailing);
898  if (trailing) index++;
899  index += line_index;
900  if (after_wrap)
901  *after_wrap = ((index == line_index + line_def->net_length) &&
902  (line_def->ending == END_WRAP));
903  } else {
904  INT xoff = 0;
905  INT trailing;
906  if (after_wrap)
907  *after_wrap = FALSE;
908  x -= es->format_rect.left;
909  if (!x)
910  return es->x_offset;
911 
912  if (!es->x_offset)
913  {
914  INT indent = (es->format_rect.right - es->format_rect.left) - es->text_width;
915  if (es->style & ES_RIGHT)
916  x -= indent;
917  else if (es->style & ES_CENTER)
918  x -= indent / 2;
919  }
920 
922  if (es->x_offset)
923  {
924  if (es->ssa)
925  {
926  if (es->x_offset>= get_text_length(es))
927  {
928  const SIZE *size;
929  size = ScriptString_pSize(es->ssa);
930  xoff = size->cx;
931  }
932  ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
933  }
934  else
935  xoff = 0;
936  }
937  if (x < 0)
938  {
939  if (x + xoff > 0 || !es->ssa)
940  {
941  ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
942  if (trailing) index++;
943  }
944  else
945  index = 0;
946  }
947  else
948  {
949  if (x)
950  {
951  const SIZE *size = NULL;
952  if (es->ssa)
953  size = ScriptString_pSize(es->ssa);
954  if (!size)
955  index = 0;
956  else if (x > size->cx)
958  else if (es->ssa)
959  {
960  ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
961  if (trailing) index++;
962  }
963  else
964  index = 0;
965  }
966  else
967  index = es->x_offset;
968  }
969  }
970  return index;
971 }
#define ES_CENTER
Definition: pedump.c:665
static const WCHAR indent[]
Definition: object.c:1156
#define ES_MULTILINE
Definition: pedump.c:667
HRESULT WINAPI ScriptStringXtoCP(SCRIPT_STRING_ANALYSIS ssa, int iX, int *piCh, int *piTrailing)
Definition: usp10.c:2472
Definition: edit.c:81
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:56
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:250
#define ES_RIGHT
Definition: pedump.c:666
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
GLuint index
Definition: glext.h:6031
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, INT line)
Definition: edit.c:438
GLsizeiptr size
Definition: glext.h:5919
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define index(s, c)
Definition: various.h:29
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3871
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int *pX)
Definition: usp10.c:2409
#define es
Definition: i386-dis.c:431

Referenced by EDIT_EM_CharFromPos(), EDIT_MoveDown_ML(), EDIT_MoveEnd(), EDIT_MoveHome(), EDIT_MovePageDown_ML(), EDIT_MovePageUp_ML(), EDIT_MoveUp_ML(), EDIT_WM_LButtonDown(), and EDIT_WM_MouseMove().

◆ EDIT_CheckCombo()

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

Definition at line 3435 of file edit.c.

3436 {
3437  HWND hLBox = es->hwndListBox;
3438  HWND hCombo;
3439  BOOL bDropped;
3440  int nEUI;
3441 
3442  if (!hLBox)
3443  return FALSE;
3444 
3445  hCombo = GetParent(es->hwndSelf);
3446  bDropped = TRUE;
3447  nEUI = 0;
3448 
3449  TRACE_(combo)("[%p]: handling msg %x (%x)\n", es->hwndSelf, msg, key);
3450 
3451  if (key == VK_UP || key == VK_DOWN)
3452  {
3453  if (SendMessageW(hCombo, CB_GETEXTENDEDUI, 0, 0))
3454  nEUI = 1;
3455 
3456  if (msg == WM_KEYDOWN || nEUI)
3457  bDropped = (BOOL)SendMessageW(hCombo, CB_GETDROPPEDSTATE, 0, 0);
3458  }
3459 
3460  switch (msg)
3461  {
3462  case WM_KEYDOWN:
3463  if (!bDropped && nEUI && (key == VK_UP || key == VK_DOWN))
3464  {
3465  /* make sure ComboLBox pops up */
3466  SendMessageW(hCombo, CB_SETEXTENDEDUI, FALSE, 0);
3467  key = VK_F4;
3468  nEUI = 2;
3469  }
3470 
3471  SendMessageW(hLBox, WM_KEYDOWN, key, 0);
3472  break;
3473 
3474  case WM_SYSKEYDOWN: /* Handle Alt+up/down arrows */
3475  if (nEUI)
3476  SendMessageW(hCombo, CB_SHOWDROPDOWN, !bDropped, 0);
3477  else
3478  SendMessageW(hLBox, WM_KEYDOWN, VK_F4, 0);
3479  break;
3480  }
3481 
3482  if(nEUI == 2)
3483  SendMessageW(hCombo, CB_SETEXTENDEDUI, TRUE, 0);
3484 
3485  return TRUE;
3486 }
#define TRUE
Definition: types.h:120
#define CB_GETDROPPEDSTATE
Definition: winuser.h:1927
#define VK_DOWN
Definition: winuser.h:2202
#define BOOL
Definition: nt_native.h:43
#define VK_UP
Definition: winuser.h:2200
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CB_SHOWDROPDOWN
Definition: winuser.h:1952
#define VK_F4
Definition: winuser.h:2233
#define WM_KEYDOWN
Definition: winuser.h:1697
#define TRACE_(x)
Definition: compat.h:66
HKEY key
Definition: reg.c:42
HWND WINAPI GetParent(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CB_SETEXTENDEDUI
Definition: winuser.h:1946
#define msg(x)
Definition: auth_time.c:54
#define WM_SYSKEYDOWN
Definition: winuser.h:1701
#define CB_GETEXTENDEDUI
Definition: winuser.h:1930
#define es
Definition: i386-dis.c:431
Definition: path.c:42

Referenced by EDIT_WM_KeyDown(), and EDIT_WM_SysKeyDown().

◆ EDIT_ConfinePoint()

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

Definition at line 982 of file edit.c.

983 {
984  *x = min(max(*x, es->format_rect.left), es->format_rect.right - 1);
985  *y = min(max(*y, es->format_rect.top), es->format_rect.bottom - 1);
986 }
#define max(a, b)
Definition: svc.c:63
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define min(a, b)
Definition: monoChain.cc:55
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define es
Definition: i386-dis.c:431

Referenced by EDIT_WM_LButtonDown(), and EDIT_WM_MouseMove().

◆ EDIT_ContextMenuCommand()

static void EDIT_ContextMenuCommand ( EDITSTATE es,
UINT  id 
)
static

Definition at line 3312 of file edit.c.

3313 {
3314  switch (id) {
3315  case EM_UNDO:
3316  SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
3317  break;
3318  case WM_CUT:
3319  SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
3320  break;
3321  case WM_COPY:
3322  SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
3323  break;
3324  case WM_PASTE:
3325  SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3326  break;
3327  case WM_CLEAR:
3328  SendMessageW(es->hwndSelf, WM_CLEAR, 0, 0);
3329  break;
3330  case EM_SETSEL:
3331  SendMessageW(es->hwndSelf, EM_SETSEL, 0, -1);
3332  break;
3333  default:
3334  ERR("unknown menu item, please report\n");
3335  break;
3336  }
3337 }
#define WM_CUT
Definition: winuser.h:1843
#define WM_PASTE
Definition: winuser.h:1845
#define WM_CLEAR
Definition: winuser.h:1846
#define WM_COPY
Definition: winuser.h:1844
#define EM_SETSEL
Definition: winuser.h:2000
#define EM_UNDO
Definition: winuser.h:2003
#define ERR(fmt,...)
Definition: debug.h:109
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_UNDO
Definition: winuser.h:1847
#define es
Definition: i386-dis.c:431

Referenced by EDIT_WM_ContextMenu().

◆ EDIT_EM_CanUndo()

static BOOL EDIT_EM_CanUndo ( const EDITSTATE es)
inlinestatic

Definition at line 174 of file edit.c.

175 {
176  return (es->undo_insert_count || strlenW(es->undo_text));
177 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define es
Definition: i386-dis.c:431

Referenced by EDIT_WM_ContextMenu(), EDIT_WM_SysKeyDown(), and EditWndProc_common().

◆ EDIT_EM_CharFromPos()

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

Definition at line 2453 of file edit.c.

2454 {
2455  POINT pt;
2456  RECT rc;
2457  INT index;
2458 
2459  pt.x = x;
2460  pt.y = y;
2461  GetClientRect(es->hwndSelf, &rc);
2462  if (!PtInRect(&rc, pt))
2463  return -1;
2464 
2465  index = EDIT_CharFromPos(es, x, y, NULL);
2467 }
#define pt(x, y)
Definition: drawing.c:79
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:56
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:865
#define index(s, c)
Definition: various.h:29
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:994
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define es
Definition: i386-dis.c:431

◆ EDIT_EM_EmptyUndoBuffer()

static void EDIT_EM_EmptyUndoBuffer ( EDITSTATE es)
inlinestatic

Definition at line 185 of file edit.c.

186 {
187  es->undo_insert_count = 0;
188  *es->undo_text = '\0';
189 }
#define es
Definition: i386-dis.c:431

Referenced by EDIT_EM_ReplaceSel(), EDIT_EM_SetHandle(), EDIT_EM_Undo(), EDIT_WM_Create(), and EditWndProc_common().

◆ EDIT_EM_FmtLines()

static BOOL EDIT_EM_FmtLines ( EDITSTATE es,
BOOL  add_eol 
)
static

Definition at line 2481 of file edit.c.

2482 {
2483  es->flags &= ~EF_USE_SOFTBRK;
2484  if (add_eol) {
2485  es->flags |= EF_USE_SOFTBRK;
2486  FIXME("soft break enabled, not implemented\n");
2487  }
2488  return add_eol;
2489 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define EF_USE_SOFTBRK
Definition: edit.c:68
#define es
Definition: i386-dis.c:431

Referenced by EditWndProc_common().

◆ EDIT_EM_GetHandle()

static HLOCAL EDIT_EM_GetHandle ( EDITSTATE es)
static

Definition at line 2503 of file edit.c.

2504 {
2505  HLOCAL hLocal;
2506 
2507  if (!(es->style & ES_MULTILINE))
2508  return 0;
2509 
2510  if(es->is_unicode)
2511  hLocal = es->hloc32W;
2512  else
2513  {
2514  if(!es->hloc32A)
2515  {
2516  CHAR *textA;
2517  UINT countA, alloc_size;
2518  TRACE("Allocating 32-bit ANSI alias buffer\n");
2519  countA = WideCharToMultiByte(CP_ACP, 0, es->text, -1, NULL, 0, NULL, NULL);
2520  alloc_size = ROUND_TO_GROW(countA);
2521  if(!(es->hloc32A = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, alloc_size)))
2522  {
2523  ERR("Could not allocate %d bytes for 32-bit ANSI alias buffer\n", alloc_size);
2524  return 0;
2525  }
2526  textA = LocalLock(es->hloc32A);
2527  WideCharToMultiByte(CP_ACP, 0, es->text, -1, textA, countA, NULL, NULL);
2528  LocalUnlock(es->hloc32A);
2529  }
2530  hLocal = es->hloc32A;
2531  }
2532 
2534 
2535  /* The text buffer handle belongs to the app */
2536  es->hlocapp = hLocal;
2537 
2538  TRACE("Returning %p, LocalSize() = %ld\n", hLocal, LocalSize(hLocal));
2539  return hLocal;
2540 }
#define TRUE
Definition: types.h:120
#define ROUND_TO_GROW(size)
Definition: edit.c:55
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
#define ES_MULTILINE
Definition: pedump.c:667
static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
Definition: edit.c:1353
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define LMEM_ZEROINIT
Definition: winbase.h:356
static const char textA[]
Definition: registrar.c:40
#define LMEM_MOVEABLE
Definition: winbase.h:350
#define ERR(fmt,...)
Definition: debug.h:109
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1599
unsigned int UINT
Definition: ndis.h:50
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
#define es
Definition: i386-dis.c:431

Referenced by EditWndProc_common().

◆ EDIT_EM_GetLine()

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

Definition at line 2548 of file edit.c.

2549 {
2550  LPWSTR src;
2551  INT line_len, dst_len;
2552  INT i;
2553 
2554  if (es->style & ES_MULTILINE) {
2555  if (line >= es->line_count)
2556  return 0;
2557  } else
2558  line = 0;
2559  i = EDIT_EM_LineIndex(es, line);
2560  src = es->text + i;
2561  line_len = EDIT_EM_LineLength(es, i);
2562  dst_len = *(WORD *)dst;
2563  if(unicode)
2564  {
2565  if(dst_len <= line_len)
2566  {
2567  memcpy(dst, src, dst_len * sizeof(WCHAR));
2568  return dst_len;
2569  }
2570  else /* Append 0 if enough space */
2571  {
2572  memcpy(dst, src, line_len * sizeof(WCHAR));
2573  dst[line_len] = 0;
2574  return line_len;
2575  }
2576  }
2577  else
2578  {
2579  INT ret = WideCharToMultiByte(CP_ACP, 0, src, line_len, (LPSTR)dst, dst_len, NULL, NULL);
2580  if(!ret && line_len) /* Insufficient buffer size */
2581  return dst_len;
2582  if(ret < dst_len) /* Append 0 if enough space */
2583  ((LPSTR)dst)[ret] = 0;
2584  return ret;
2585  }
2586 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
#define ES_MULTILINE
Definition: pedump.c:667
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:56
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
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
__wchar_t WCHAR
Definition: xmlstorage.h:180
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:1058
unsigned short WORD
Definition: ntddk_ex.h:93
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:1023
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define es
Definition: i386-dis.c:431

Referenced by EditWndProc_common().

◆ EDIT_EM_GetSel()

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

Definition at line 2594 of file edit.c.

2595 {
2596  UINT s = es->selection_start;
2597  UINT e = es->selection_end;
2598 
2599  ORDER_UINT(s, e);
2600  if (start)
2601  *start = s;
2602  if (end)
2603  *end = e;
2604  return MAKELONG(s, e);
2605 }
GLuint GLuint end
Definition: gl.h:1545
#define e
Definition: ke_i.h:82
#define MAKELONG(a, b)
Definition: typedefs.h:248
GLdouble s
Definition: gl.h:2039
#define ORDER_UINT(x, y)
Definition: edit.c:154
GLuint start
Definition: gl.h:1545
unsigned int UINT
Definition: ndis.h:50
#define es
Definition: i386-dis.c:431

Referenced by EditWndProc_common().

◆ EDIT_EM_GetThumb()

static LRESULT EDIT_EM_GetThumb ( EDITSTATE es)
static

Definition at line 4382 of file edit.c.

4383 {
4384  return MAKELONG(EDIT_WM_VScroll(es, EM_GETTHUMB, 0),
4386 }
static LRESULT EDIT_WM_VScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:4262
#define MAKELONG(a, b)
Definition: typedefs.h:248
static LRESULT EDIT_WM_HScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:4130
#define es
Definition: i386-dis.c:431
#define EM_GETTHUMB
Definition: winuser.h:1980

Referenced by EditWndProc_common().

◆ EDIT_EM_LineFromChar()

static INT EDIT_EM_LineFromChar ( EDITSTATE es,
INT  index 
)
static

Definition at line 994 of file edit.c.

995 {
996  INT line;
997  LINEDEF *line_def;
998 
999  if (!(es->style & ES_MULTILINE))
1000  return 0;
1001  if (index > (INT)get_text_length(es))
1002  return es->line_count - 1;
1003  if (index == -1)
1004  index = min(es->selection_start, es->selection_end);
1005 
1006  line = 0;
1007  line_def = es->first_line_def;
1008  index -= line_def->length;
1009  while ((index >= 0) && line_def->next) {
1010  line++;
1011  line_def = line_def->next;
1012  index -= line_def->length;
1013  }
1014  return line;
1015 }
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:56
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:250
Definition: parser.c:48
GLuint index
Definition: glext.h:6031
struct tagLINEDEF * next
Definition: edit.c:94
char line[200]
Definition: main.c:97
#define min(a, b)
Definition: monoChain.cc:55
#define es
Definition: i386-dis.c:431
INT length
Definition: edit.c:88

Referenced by EDIT_EM_CharFromPos(), EDIT_EM_LineLength(), EDIT_EM_PosFromChar(), EDIT_EM_ScrollCaret(), EDIT_ML_InvalidateText(), EDIT_MoveWordBackward(), EDIT_MoveWordForward(), EDIT_WM_LButtonDblClk(), and EditWndProc_common().

◆ EDIT_EM_LineIndex()

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

Definition at line 1023 of file edit.c.

1024 {
1025  INT line_index;
1026  const LINEDEF *line_def;
1027 
1028  if (!(es->style & ES_MULTILINE))
1029  return 0;
1030  if (line >= es->line_count)
1031  return -1;
1032 
1033  line_index = 0;
1034  line_def = es->first_line_def;
1035  if (line == -1) {
1036  INT index = es->selection_end - line_def->length;
1037  while ((index >= 0) && line_def->next) {
1038  line_index += line_def->length;
1039  line_def = line_def->next;
1040  index -= line_def->length;
1041  }
1042  } else {
1043  while (line > 0) {
1044  line_index += line_def->length;
1045  line_def = line_def->next;
1046  line--;
1047  }
1048  }
1049  return line_index;
1050 }
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:56
Definition: parser.c:48
GLuint index
Definition: glext.h:6031
struct tagLINEDEF * next
Definition: edit.c:94
#define es
Definition: i386-dis.c:431
INT length
Definition: edit.c:88

Referenced by EDIT_EM_GetLine(), EDIT_EM_LineLength(), EDIT_EM_PosFromChar(), EDIT_ML_InvalidateText(), EDIT_MoveWordBackward(), EDIT_MoveWordForward(), EDIT_PaintLine(), EDIT_PaintText(), EDIT_WM_LButtonDblClk(), and EditWndProc_common().

◆ EDIT_EM_LineLength()

static INT EDIT_EM_LineLength ( EDITSTATE es,
INT  index 
)
static

Definition at line 1058 of file edit.c.

1059 {
1060  LINEDEF *line_def;
1061 
1062  if (!(es->style & ES_MULTILINE))
1063  return get_text_length(es);
1064 
1065  if (index == -1) {
1066  /* get the number of remaining non-selected chars of selected lines */
1067  INT32 l; /* line number */
1068  INT32 li; /* index of first char in line */
1069  INT32 count;
1070  l = EDIT_EM_LineFromChar(es, es->selection_start);
1071  /* # chars before start of selection area */
1072  count = es->selection_start - EDIT_EM_LineIndex(es, l);
1073  l = EDIT_EM_LineFromChar(es, es->selection_end);
1074  /* # chars after end of selection */
1075  li = EDIT_EM_LineIndex(es, l);
1076  count += li + EDIT_EM_LineLength(es, li) - es->selection_end;
1077  return count;
1078  }
1079  line_def = es->first_line_def;
1080  index -= line_def->length;
1081  while ((index >= 0) && line_def->next) {
1082  line_def = line_def->next;
1083  index -= line_def->length;
1084  }
1085  return line_def->net_length;
1086 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ES_MULTILINE
Definition: pedump.c:667
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:250
INT net_length
Definition: edit.c:89
GLuint index
Definition: glext.h:6031
r l[0]
Definition: byte_order.h:167
struct tagLINEDEF * next
Definition: edit.c:94
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:1058
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:994
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:1023
signed int INT32
#define es
Definition: i386-dis.c:431
INT length
Definition: edit.c:88

Referenced by EDIT_EM_GetLine(), EDIT_ML_InvalidateText(), EDIT_MoveWordBackward(), EDIT_MoveWordForward(), EDIT_PaintLine(), EDIT_WM_LButtonDblClk(), and EditWndProc_common().

◆ EDIT_EM_LineScroll()

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

Definition at line 1798 of file edit.c.

1799 {
1800  if (!(es->style & ES_MULTILINE))
1801  return FALSE;
1802 
1803  dx *= es->char_width;
1804  return EDIT_EM_LineScroll_internal(es, dx, dy);
1805 }
static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1742
GLint dy
Definition: linetemp.h:97
#define ES_MULTILINE
Definition: pedump.c:667
GLint dx
Definition: linetemp.h:97
#define es
Definition: i386-dis.c:431

Referenced by EDIT_EM_Scroll(), EDIT_WM_VScroll(), and EditWndProc_common().

◆ EDIT_EM_LineScroll_internal()

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

Definition at line 1742 of file edit.c.

1743 {
1744  INT nyoff;
1745  INT x_offset_in_pixels;
1746  INT lines_per_page = (es->format_rect.bottom - es->format_rect.top) /
1747  es->line_height;
1748 
1749  if (es->style & ES_MULTILINE)
1750  {
1751  x_offset_in_pixels = es->x_offset;
1752  }
1753  else
1754  {
1755  dy = 0;
1756  x_offset_in_pixels = (short)LOWORD(EDIT_EM_PosFromChar(es, es->x_offset, FALSE));
1757  }
1758 
1759  if (-dx > x_offset_in_pixels)
1760  dx = -x_offset_in_pixels;
1761  if (dx > es->text_width - x_offset_in_pixels)
1762  dx = es->text_width - x_offset_in_pixels;
1763  nyoff = max(0, es->y_offset + dy);
1764  if (nyoff >= es->line_count - lines_per_page)
1765  nyoff = max(0, es->line_count - lines_per_page);
1766  dy = (es->y_offset - nyoff) * es->line_height;
1767  if (dx || dy) {
1768  RECT rc1;
1769  RECT rc;
1770 
1771  es->y_offset = nyoff;
1772  if(es->style & ES_MULTILINE)
1773  es->x_offset += dx;
1774  else
1775  es->x_offset += dx / es->char_width;
1776 
1777  GetClientRect(es->hwndSelf, &rc1);
1778  IntersectRect(&rc, &rc1, &es->format_rect);
1779  ScrollWindowEx(es->hwndSelf, -dx, dy,
1780  NULL, &rc, NULL, NULL, SW_INVALIDATE);
1781  /* force scroll info update */
1783  }
1784  if (dx && !(es->flags & EF_HSCROLL_TRACK))
1786  if (dy && !(es->flags & EF_VSCROLL_TRACK))
1788  return TRUE;
1789 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define EF_VSCROLL_TRACK
Definition: edit.c:64
GLint dy
Definition: linetemp.h:97
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:56
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
smooth NULL
Definition: ftsmooth.c:416
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
#define EDIT_NOTIFY_PARENT(es, wNotifyCode)
Definition: edit.c:157
if(!(yy_init))
Definition: macro.lex.yy.c:714
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define EN_HSCROLL
Definition: winuser.h:2006
#define EF_HSCROLL_TRACK
Definition: edit.c:65
#define SW_INVALIDATE
Definition: winuser.h:2554
#define EN_VSCROLL
Definition: winuser.h:2011
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1701
GLint dx
Definition: linetemp.h:97
#define es
Definition: i386-dis.c:431
#define LOWORD(l)
Definition: pedump.c:82
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1094

Referenced by EDIT_EM_LineScroll(), EDIT_EM_ScrollCaret(), and EDIT_WM_HScroll().

◆ EDIT_EM_PosFromChar()

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

Definition at line 1094 of file edit.c.

1095 {
1097  INT l;
1098  INT li;
1099  INT x = 0;
1100  INT y = 0;
1101  INT w;
1102  INT lw;
1103  LINEDEF *line_def;
1104 
1105  index = min(index, len);
1106  if (es->style & ES_MULTILINE) {
1109 
1110  y = (l - es->y_offset) * es->line_height;
1111  li = EDIT_EM_LineIndex(es, l);
1112  if (after_wrap && (li == index) && l) {
1113  INT l2 = l - 1;
1114  line_def = es->first_line_def;
1115  while (l2) {
1116  line_def = line_def->next;
1117  l2--;
1118  }
1119  if (line_def->ending == END_WRAP) {
1120  l--;
1121  y -= es->line_height;
1122  li = EDIT_EM_LineIndex(es, l);
1123  }
1124  }
1125 
1126  line_def = es->first_line_def;
1127  while (line_def->index != li)
1128  line_def = line_def->next;
1129 
1130  lw = line_def->width;
1131  w = es->format_rect.right - es->format_rect.left;
1132  if (line_def->ssa)
1133  {
1134  ScriptStringCPtoX(line_def->ssa, (index - 1) - li, TRUE, &x);
1135  x -= es->x_offset;
1136  }
1137  else
1138 #ifdef __REACTOS__ /* CORE-15780 */
1139  x = (lw > 0 ? es->x_offset : x - es->x_offset);
1140 #else
1141  x = es->x_offset;
1142 #endif
1143 
1144  if (es->style & ES_RIGHT)
1145  x = w - (lw - x);
1146  else if (es->style & ES_CENTER)
1147  x += (w - lw) / 2;
1148  } else {
1149  INT xoff = 0;
1150  INT xi = 0;
1152  if (es->x_offset)
1153  {
1154  if (es->ssa)
1155  {
1156  if (es->x_offset >= get_text_length(es))
1157  {
1158  int leftover = es->x_offset - get_text_length(es);
1159  if (es->ssa)
1160  {
1161  const SIZE *size;
1162  size = ScriptString_pSize(es->ssa);
1163  xoff = size->cx;
1164  }
1165  else
1166  xoff = 0;
1167  xoff += es->char_width * leftover;
1168  }
1169  else
1170  ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
1171  }
1172  else
1173  xoff = 0;
1174  }
1175  if (index)
1176  {
1177  if (index >= get_text_length(es))
1178  {
1179  if (es->ssa)
1180  {
1181  const SIZE *size;
1182  size = ScriptString_pSize(es->ssa);
1183  xi = size->cx;
1184  }
1185  else
1186  xi = 0;
1187  }
1188  else if (es->ssa)
1189  ScriptStringCPtoX(es->ssa, index, FALSE, &xi);
1190  else
1191  xi = 0;
1192  }
1193  x = xi - xoff;
1194 
1195  if (index >= es->x_offset) {
1196  if (!es->x_offset && (es->style & (ES_RIGHT | ES_CENTER)))
1197  {
1198  w = es->format_rect.right - es->format_rect.left;
1199  if (w > es->text_width)
1200  {
1201  if (es->style & ES_RIGHT)
1202  x += w - es->text_width;
1203  else if (es->style & ES_CENTER)
1204  x += (w - es->text_width) / 2;
1205  }
1206  }
1207  }
1208  y = 0;
1209  }
1210  x += es->format_rect.left;
1211  y += es->format_rect.top;
1212  return MAKELONG((INT16)x, (INT16)y);
1213 }
#define ES_CENTER
Definition: pedump.c:665
#define TRUE
Definition: types.h:120
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
LINE_END ending
Definition: edit.c:90
#define ES_MULTILINE
Definition: pedump.c:667
Definition: edit.c:81
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:56
INT width
Definition: edit.c:91
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:250
#define ES_RIGHT
Definition: pedump.c:666
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, INT line)
Definition: edit.c:438
r l[0]
Definition: byte_order.h:167
GLsizeiptr size
Definition: glext.h:5919
struct tagLINEDEF * next
Definition: edit.c:94
GLenum GLsizei len
Definition: glext.h:6722
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:994
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3871
#define min(a, b)
Definition: monoChain.cc:55
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:1023
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int *pX)
Definition: usp10.c:2409
#define es
Definition: i386-dis.c:431
INT index
Definition: edit.c:92
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:93
signed short INT16

Referenced by EDIT_BuildLineDefs_ML(), EDIT_EM_LineScroll_internal(), EDIT_EM_ScrollCaret(), EDIT_GetLineRect(), EDIT_MoveDown_ML(), EDIT_MoveEnd(), EDIT_MoveHome(), EDIT_MovePageDown_ML(), EDIT_MovePageUp_ML(), EDIT_MoveUp_ML(), EDIT_PaintLine(), and EDIT_SetCaretPos().

◆ 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 2615 of file edit.c.

2616 {
2617  UINT strl = strlenW(lpsz_replace);
2618  UINT tl = get_text_length(es);
2619  UINT utl;
2620  UINT s;
2621  UINT e;
2622  UINT i;
2623  UINT size;
2624  LPWSTR p;
2625  HRGN hrgn = 0;
2626  LPWSTR buf = NULL;
2627  UINT bufl;
2628 
2629  TRACE("%s, can_undo %d, send_update %d\n",
2630  debugstr_w(lpsz_replace), can_undo, send_update);
2631 
2632  s = es->selection_start;
2633  e = es->selection_end;
2634 
2636  if ((s == e) && !strl)
2637  return;
2638 
2639  ORDER_UINT(s, e);
2640 
2641  size = tl - (e - s) + strl;
2642  if (!size)
2643  es->text_width = 0;
2644 
2645  /* Issue the EN_MAXTEXT notification and continue with replacing text
2646  * so that buffer limit is honored. */
2647  if ((honor_limit) && (size > es->buffer_limit)) {
2649  /* Buffer limit can be smaller than the actual length of text in combobox */
2650  if (es->buffer_limit < (tl - (e-s)))
2651  strl = 0;
2652  else
2653  strl = min(strl, es->buffer_limit - (tl - (e-s)));
2654  }
2655 
2656  if (!EDIT_MakeFit(es, tl - (e - s) + strl))
2657  return;
2658 
2659  if (e != s) {
2660  /* there is something to be deleted */
2661  TRACE("deleting stuff.\n");
2662  bufl = e - s;
2663  buf = HeapAlloc(GetProcessHeap(), 0, (bufl + 1) * sizeof(WCHAR));
2664  if (!buf) return;
2665  memcpy(buf, es->text + s, bufl * sizeof(WCHAR));
2666  buf[bufl] = 0; /* ensure 0 termination */
2667  /* now delete */
2668  strcpyW(es->text + s, es->text + e);
2670  }
2671  if (strl) {
2672  /* there is an insertion */
2673  tl = get_text_length(es);
2674  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));
2675  for (p = es->text + tl ; p >= es->text + s ; p--)
2676  p[strl] = p[0];
2677  for (i = 0 , p = es->text + s ; i < strl ; i++)
2678  p[i] = lpsz_replace[i];
2679  if(es->style & ES_UPPERCASE)
2680  CharUpperBuffW(p, strl);
2681  else if(es->style & ES_LOWERCASE)
2682  CharLowerBuffW(p, strl);
2684  }
2685  if (es->style & ES_MULTILINE)
2686  {
2687  INT st = min(es->selection_start, es->selection_end);
2689 
2690  hrgn = CreateRectRgn(0, 0, 0, 0);
2691  EDIT_BuildLineDefs_ML(es, st, st + strl,
2692  strl - abs(es->selection_end - es->selection_start), hrgn);
2693  /* if text is too long undo all changes */
2694  if (honor_limit && !(es->style & ES_AUTOVSCROLL) && (es->line_count > vlc)) {
2695  if (strl)
2696  strcpyW(es->text + e, es->text + e + strl);
2697  if (e != s)
2698  for (i = 0 , p = es->text ; i < e - s ; i++)
2699  p[i + s] = buf[i];
2702  abs(es->selection_end - es->selection_start) - strl, hrgn);
2703  strl = 0;
2704  e = s;
2705  hrgn = CreateRectRgn(0, 0, 0, 0);
2707  }
2708  }
2709  else {
2710  INT fw = es->format_rect.right - es->format_rect.left;
2713  /* remove chars that don't fit */
2714  if (honor_limit && !(es->style & ES_AUTOHSCROLL) && (es->text_width > fw)) {
2715  while ((es->text_width > fw) && s + strl >= s) {
2716  strcpyW(es->text + s + strl - 1, es->text + s + strl);
2717  strl--;
2718  es->text_length = -1;
2721  }
2724  }
2725  }
2726 
2727  if (e != s) {
2728  if (can_undo) {
2729  utl = strlenW(es->undo_text);
2730  if (!es->undo_insert_count && (*es->undo_text && (s == es->undo_position))) {
2731  /* undo-buffer is extended to the right */
2732  EDIT_MakeUndoFit(es, utl + e - s);
2733  memcpy(es->undo_text + utl, buf, (e - s)*sizeof(WCHAR));
2734  (es->undo_text + utl)[e - s] = 0; /* ensure 0 termination */
2735  } else if (!es->undo_insert_count && (*es->undo_text && (e == es->undo_position))) {
2736  /* undo-buffer is extended to the left */
2737  EDIT_MakeUndoFit(es, utl + e - s);
2738  for (p = es->undo_text + utl ; p >= es->undo_text ; p--)
2739  p[e - s] = p[0];
2740  for (i = 0 , p = es->undo_text ; i < e - s ; i++)
2741  p[i] = buf[i];
2742  es->undo_position = s;
2743  } else {
2744  /* new undo-buffer */
2745  EDIT_MakeUndoFit(es, e - s);
2746  memcpy(es->undo_text, buf, (e - s)*sizeof(WCHAR));
2747  es->undo_text[e - s] = 0; /* ensure 0 termination */
2748  es->undo_position = s;
2749  }
2750  /* any deletion makes the old insertion-undo invalid */
2751  es->undo_insert_count = 0;
2752  } else
2754  }
2755  if (strl) {
2756  if (can_undo) {
2757  if ((s == es->undo_position) ||
2758  ((es->undo_insert_count) &&
2759  (s == es->undo_position + es->undo_insert_count)))
2760  /*
2761  * insertion is new and at delete position or
2762  * an extension to either left or right
2763  */
2764  es->undo_insert_count += strl;
2765  else {
2766  /* new insertion undo */
2767  es->undo_position = s;
2768  es->undo_insert_count = strl;
2769  /* new insertion makes old delete-buffer invalid */
2770  *es->undo_text = '\0';
2771  }
2772  } else
2774  }
2775 
2776  HeapFree(GetProcessHeap(), 0, buf);
2777 
2778  s += strl;
2779 
2780  /* If text has been deleted and we're right or center aligned then scroll rightward */
2781  if (es->style & (ES_RIGHT | ES_CENTER))
2782  {
2783  INT delta = strl - abs(es->selection_end - es->selection_start);
2784 
2785  if (delta < 0 && es->x_offset)
2786  {
2787  if (abs(delta) > es->x_offset)
2788  es->x_offset = 0;
2789  else
2790  es->x_offset += delta;
2791  }
2792  }
2793 
2794  EDIT_EM_SetSel(es, s, s, FALSE);
2795  es->flags |= EF_MODIFIED;
2796  if (send_update) es->flags |= EF_UPDATE;
2797  if (hrgn)
2798  {
2800  DeleteObject(hrgn);
2801  }
2802  else
2804 
2806 
2807  /* force scroll info update */
2809 
2810 
2811  if(send_update || (es->flags & EF_UPDATE))
2812  {
2813  es->flags &= ~EF_UPDATE;
2815  }
2817 }
#define ES_CENTER
Definition: pedump.c:665
#define abs(i)
Definition: fconv.c:206
static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1635
#define EN_MAXTEXT
Definition: winuser.h:2008
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1505
#define ES_MULTILINE
Definition: pedump.c:667
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
static void text_buffer_changed(EDITSTATE *es)
Definition: edit.c:1275
int32_t INT
Definition: typedefs.h:56
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:250
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 ES_RIGHT
Definition: pedump.c:666
#define e
Definition: ke_i.h:82
#define debugstr_w
Definition: kernel32.h:32
#define ES_UPPERCASE
Definition: pedump.c:668
smooth NULL
Definition: ftsmooth.c:416
#define EDIT_NOTIFY_PARENT(es, wNotifyCode)
Definition: edit.c:157
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
static void EDIT_CalcLineWidth_SL(EDITSTATE *es)
Definition: edit.c:842
#define ES_AUTOVSCROLL
Definition: pedump.c:671
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD WINAPI CharUpperBuffW(_Inout_updates_(cchLength) LPWSTR lpsz, _In_ DWORD cchLength)
static void EDIT_UpdateTextRegion(EDITSTATE *es, HRGN hrgn, BOOL bErase)
Definition: edit.c:1490
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:185
static HRGN hrgn
Definition: win.c:55
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLdouble s
Definition: gl.h:2039
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1878
#define ORDER_UINT(x, y)
Definition: edit.c:154
DWORD WINAPI CharLowerBuffW(_Inout_updates_(cchLength) LPWSTR lpsz, _In_ DWORD cchLength)
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:376
static BOOL EDIT_MakeUndoFit(EDITSTATE *es, UINT size)
Definition: edit.c:1463
#define EF_UPDATE
Definition: edit.c:63
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1701
#define EF_MODIFIED
Definition: edit.c:61
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:505
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:490
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define es
Definition: i386-dis.c:431
#define ES_AUTOHSCROLL
Definition: pedump.c:672
#define HeapFree(x, y, z)
Definition: compat.h:394
static BOOL EDIT_MakeFit(EDITSTATE *es, UINT size)
Definition: edit.c:1422
#define ES_LOWERCASE
Definition: pedump.c:669
#define EN_CHANGE
Definition: winuser.h:2004

Referenced by EDIT_EM_Undo(), EDIT_GetCompositionStr(), EDIT_GetResultStr(), EDIT_ImeComposition(), EDIT_WM_Char(), EDIT_WM_Clear(), EDIT_WM_Create(), EDIT_WM_Paste(), EDIT_WM_SetText(), and EditWndProc_common().

◆ EDIT_EM_Scroll()

static LRESULT EDIT_EM_Scroll ( EDITSTATE es,
INT  action 
)
static

Definition at line 1813 of file edit.c.

1814 {
1815  INT dy;
1816 
1817  if (!(es->style & ES_MULTILINE))
1818  return (LRESULT)FALSE;
1819 
1820  dy = 0;
1821 
1822  switch (action) {
1823  case SB_LINEUP:
1824  if (es->y_offset)
1825  dy = -1;
1826  break;
1827  case SB_LINEDOWN:
1828  if (es->y_offset < es->line_count - 1)
1829  dy = 1;
1830  break;
1831  case SB_PAGEUP:
1832  if (es->y_offset)
1833  dy = -(es->format_rect.bottom - es->format_rect.top) / es->line_height;
1834  break;
1835  case SB_PAGEDOWN:
1836  if (es->y_offset < es->line_count - 1)
1837  dy = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
1838  break;
1839  default:
1840  return (LRESULT)FALSE;
1841  }
1842  if (dy) {
1844  /* check if we are going to move too far */
1845  if(es->y_offset + dy > es->line_count - vlc)
1846  dy = max(es->line_count - vlc, 0) - es->y_offset;
1847 
1848  /* Notification is done in EDIT_EM_LineScroll */
1849  if(dy) {
1850  EDIT_EM_LineScroll(es, 0, dy);
1851  return MAKELONG(dy, TRUE);
1852  }
1853 
1854  }
1855  return (LRESULT)FALSE;
1856 }
#define SB_PAGEDOWN
Definition: winuser.h:569
return
Definition: dirsup.c:529
#define SB_PAGEUP
Definition: winuser.h:568
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
GLint dy
Definition: linetemp.h:97
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:56
static BOOL EDIT_EM_LineScroll(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1798
#define MAKELONG(a, b)
Definition: typedefs.h:248
if(!(yy_init))
Definition: macro.lex.yy.c:714
const WCHAR * action
Definition: action.c:7783
#define SB_LINEDOWN
Definition: winuser.h:565
#define SB_LINEUP
Definition: winuser.h:564
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:490
LONG_PTR LRESULT
Definition: windef.h:209
#define es
Definition: i386-dis.c:431

Referenced by EDIT_WM_VScroll(), and EditWndProc_common().

◆ EDIT_EM_ScrollCaret()

static void EDIT_EM_ScrollCaret ( EDITSTATE es)
static

Definition at line 1878 of file edit.c.

1879 {
1880  if (es->style & ES_MULTILINE) {
1881  INT l;
1882  INT vlc;
1883  INT ww;
1884  INT cw = es->char_width;
1885  INT x;
1886  INT dy = 0;
1887  INT dx = 0;
1888 
1889  l = EDIT_EM_LineFromChar(es, es->selection_end);
1890  x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP));
1891  vlc = get_vertical_line_count(es);
1892  if (l >= es->y_offset + vlc)
1893  dy = l - vlc + 1 - es->y_offset;
1894  if (l < es->y_offset)
1895  dy = l - es->y_offset;
1896  ww = es->format_rect.right - es->format_rect.left;
1897  if (x < es->format_rect.left)
1898  dx = x - es->format_rect.left - ww / HSCROLL_FRACTION / cw * cw;
1899  if (x > es->format_rect.right)
1900  dx = x - es->format_rect.left - (HSCROLL_FRACTION - 1) * ww / HSCROLL_FRACTION / cw * cw;
1901  if (dy || dx || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1902  {
1903  /* check if we are going to move too far */
1904  if(es->x_offset + dx + ww > es->text_width)
1905  dx = es->text_width - ww - es->x_offset;
1906  if(dx || dy || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1908  }
1909  } else {
1910  INT x;
1911  INT goal;
1912  INT format_width;
1913 
1914  x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1915  format_width = es->format_rect.right - es->format_rect.left;
1916  if (x < es->format_rect.left) {
1917  goal = es->format_rect.left + format_width / HSCROLL_FRACTION;
1918  do {
1919  es->x_offset--;
1920  x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1921  } while ((x < goal) && es->x_offset);
1922  /* FIXME: use ScrollWindow() somehow to improve performance */
1924  } else if (x > es->format_rect.right) {
1925  INT x_last;
1927  goal = es->format_rect.right - format_width / HSCROLL_FRACTION;
1928  do {
1929  es->x_offset++;
1930  x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1931  x_last = (short)LOWORD(EDIT_EM_PosFromChar(es, len, FALSE));
1932  } while ((x > goal) && (x_last > es->format_rect.right));
1933  /* FIXME: use ScrollWindow() somehow to improve performance */
1935  }
1936  }
1937 
1938  if(es->flags & EF_FOCUSED)
1939  EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP);
1940 }
#define TRUE
Definition: types.h:120
static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1742
static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap)
Definition: edit.c:1864
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1505
GLint dy
Definition: linetemp.h:97
#define ES_MULTILINE
Definition: pedump.c:667
#define EF_FOCUSED
Definition: edit.c:62
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:56
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:250
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
GLenum GLsizei len
Definition: glext.h:6722
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:994
#define EF_AFTER_WRAP
Definition: edit.c:66
GLint dx
Definition: linetemp.h:97
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:490
#define HSCROLL_FRACTION
Definition: edit.c:56
#define es
Definition: i386-dis.c:431
#define LOWORD(l)
Definition: pedump.c:82
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1094

Referenced by EDIT_EM_ReplaceSel(), EDIT_EM_SetHandle(), EDIT_EM_Undo(), EDIT_MoveBackward(), EDIT_MoveDown_ML(), EDIT_MoveEnd(), EDIT_MoveForward(), EDIT_MoveHome(), EDIT_MovePageDown_ML(), EDIT_MovePageUp_ML(), EDIT_MoveUp_ML(), EDIT_MoveWordBackward(), EDIT_MoveWordForward(), EDIT_WM_Create(), EDIT_WM_LButtonDblClk(), EDIT_WM_LButtonDown(), EDIT_WM_SetText(), and EditWndProc_common().

◆ EDIT_EM_SetHandle()

static void EDIT_EM_SetHandle ( EDITSTATE es,
HLOCAL  hloc 
)
static

Definition at line 2827 of file edit.c.

2828 {
2829  if (!(es->style & ES_MULTILINE))
2830  return;
2831 
2832  if (!hloc) {
2833  WARN("called with NULL handle\n");
2834  return;
2835  }
2836 
2838 
2839  if(es->is_unicode)
2840  {
2841  if(es->hloc32A)
2842  {
2843  LocalFree(es->hloc32A);
2844  es->hloc32A = NULL;
2845  }
2846  es->hloc32W = hloc;
2847  }
2848  else
2849  {
2850  INT countW, countA;
2851  HLOCAL hloc32W_new;
2852  WCHAR *textW;
2853  CHAR *textA;
2854 
2855  countA = LocalSize(hloc);
2856  textA = LocalLock(hloc);
2857  countW = MultiByteToWideChar(CP_ACP, 0, textA, countA, NULL, 0);
2858  if(!(hloc32W_new = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, countW * sizeof(WCHAR))))
2859  {
2860  ERR("Could not allocate new unicode buffer\n");
2861  return;
2862  }
2863  textW = LocalLock(hloc32W_new);
2864  MultiByteToWideChar(CP_ACP, 0, textA, countA, textW, countW);
2865  LocalUnlock(hloc32W_new);
2866  LocalUnlock(hloc);
2867 
2868  if(es->hloc32W)
2869  LocalFree(es->hloc32W);
2870 
2871  es->hloc32W = hloc32W_new;
2872  es->hloc32A = hloc;
2873  }
2874 
2875  es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1;
2876 
2877  /* The text buffer handle belongs to the control */
2878  es->hlocapp = NULL;
2879 
2882 
2883  es->x_offset = es->y_offset = 0;
2884  es->selection_start = es->selection_end = 0;
2886  es->flags &= ~EF_MODIFIED;
2887  es->flags &= ~EF_UPDATE;
2891  /* force scroll info update */
2893 }
#define TRUE
Definition: types.h:120
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1505
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
#define WARN(fmt,...)
Definition: debug.h:111
#define ES_MULTILINE
Definition: pedump.c:667
static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
Definition: edit.c:1353
static void text_buffer_changed(EDITSTATE *es)
Definition: edit.c:1275
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777
int32_t INT
Definition: typedefs.h:56
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:250
smooth NULL
Definition: ftsmooth.c:416
static void EDIT_LockBuffer(EDITSTATE *es)
Definition: edit.c:1288
#define LMEM_ZEROINIT
Definition: winbase.h:356
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const char textA[]
Definition: registrar.c:40
#define LMEM_MOVEABLE
Definition: winbase.h:350
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:185
static const WCHAR textW[]
Definition: itemdlg.c:1559
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1878
#define ERR(fmt,...)
Definition: debug.h:109
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1599
#define EF_UPDATE
Definition: edit.c:63
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1701
#define EF_MODIFIED
Definition: edit.c:61
#define MultiByteToWideChar
Definition: compat.h:100
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:505
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
#define es
Definition: i386-dis.c:431

Referenced by EditWndProc_common().

◆ EDIT_EM_SetLimitText()

static void EDIT_EM_SetLimitText ( EDITSTATE es,
UINT  limit 
)
static

Definition at line 2903 of file edit.c.

2904 {
2905  if (!limit) limit = ~0u;
2906  if (!(es->style & ES_MULTILINE)) limit = min(limit, 0x7ffffffe);
2907  es->buffer_limit = limit;
2908 }
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
#define ES_MULTILINE
Definition: pedump.c:667
GLint limit
Definition: glext.h:10326
#define min(a, b)
Definition: monoChain.cc:55
#define es
Definition: i386-dis.c:431

Referenced by EditWndProc_common().

◆ EDIT_EM_SetMargins()

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

Definition at line 2939 of file edit.c.

2941 {
2942  TEXTMETRICW tm;
2943  INT default_left_margin = 0; /* in pixels */
2944  INT default_right_margin = 0; /* in pixels */
2945 
2946  /* Set the default margins depending on the font */
2947  if (es->font && (left == EC_USEFONTINFO || right == EC_USEFONTINFO)) {
2948  HDC dc = GetDC(es->hwndSelf);
2949  HFONT old_font = SelectObject(dc, es->font);
2951  RECT rc;
2952 
2953  /* The default margins are only non zero for TrueType or Vector fonts */
2954  if (tm.tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE )) {
2955  if (!is_cjk(tm.tmCharSet)) {
2956  default_left_margin = width / 2;
2957  default_right_margin = width / 2;
2958 
2959  GetClientRect(es->hwndSelf, &rc);
2960  if (rc.right - rc.left < (width / 2 + width) * 2 &&
2961  (width >= 28 || !IsRectEmpty(&rc)) ) {
2962  default_left_margin = es->left_margin;
2963  default_right_margin = es->right_margin;
2964  }
2965  } else {
2966  /* FIXME: figure out the CJK values. They are not affected by the client rect. */
2967  default_left_margin = width / 2;
2968  default_right_margin = width / 2;
2969  }
2970  }
2971  SelectObject(dc, old_font);
2972  ReleaseDC(es->hwndSelf, dc);
2973  }
2974 
2975  if (action & EC_LEFTMARGIN) {
2976  es->format_rect.left -= es->left_margin;
2977  if (left != EC_USEFONTINFO)
2978  es->left_margin = left;
2979  else
2980  es->left_margin = default_left_margin;
2981  es->format_rect.left += es->left_margin;
2982  }
2983 
2984  if (action & EC_RIGHTMARGIN) {
2985  es->format_rect.right += es->right_margin;
2986  if (right != EC_USEFONTINFO)
2987  es->right_margin = right;
2988  else
2989  es->right_margin = default_right_margin;
2990  es->format_rect.right -= es->right_margin;
2991  }
2992 
2993  if (action & (EC_LEFTMARGIN | EC_RIGHTMARGIN)) {
2995  if (repaint) EDIT_UpdateText(es, NULL, TRUE);
2996  }
2997 
2998  TRACE("left=%d, right=%d\n", es->left_margin, es->right_margin);
2999 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define EC_RIGHTMARGIN
Definition: winuser.h:2582
#define TRUE
Definition: types.h:120
HDC WINAPI GetDC(_In_opt_ HWND)
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1505
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
HDC dc
Definition: cylfrac.c:34
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
long LONG
Definition: pedump.c:60
#define TMPF_TRUETYPE
Definition: wingdi.h:1312
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
static void EDIT_AdjustFormatRect(EDITSTATE *es)
Definition: edit.c:2353
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
#define EC_LEFTMARGIN
Definition: winuser.h:2581
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
static BOOL is_cjk(UINT charset)
Definition: edit.c:2924
Definition: time.h:76
#define TMPF_VECTOR
Definition: wingdi.h:1311
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *)
Definition: font.c:2145
const WCHAR * action
Definition: action.c:7783
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define es
Definition: i386-dis.c:431
#define EC_USEFONTINFO
Definition: winuser.h:2583

Referenced by EDIT_WM_SetFont().

◆ EDIT_EM_SetPasswordChar()

static void EDIT_EM_SetPasswordChar ( EDITSTATE es,
WCHAR  c 
)
static

Definition at line 3007 of file edit.c.

3008 {
3009  LONG style;
3010 
3011  if (es->style & ES_MULTILINE)
3012  return;
3013 
3014  if (es->password_char == c)
3015  return;
3016 
3017  style = GetWindowLongW( es->hwndSelf, GWL_STYLE );
3018  es->password_char = c;
3019  if (c) {
3020  SetWindowLongW( es->hwndSelf, GWL_STYLE, style | ES_PASSWORD );
3021  es->style |= ES_PASSWORD;
3022  } else {
3023  SetWindowLongW( es->hwndSelf, GWL_STYLE, style & ~ES_PASSWORD );
3024  es->style &= ~ES_PASSWORD;
3025  }
3028 }
#define TRUE
Definition: types.h:120
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1505
#define ES_MULTILINE
Definition: pedump.c:667
#define ES_PASSWORD
Definition: pedump.c:670
long LONG
Definition: pedump.c:60
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
const GLubyte * c
Definition: glext.h:8905
#define GWL_STYLE
Definition: winuser.h:846
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:376
#define c
Definition: ke_i.h:80
#define es
Definition: i386-dis.c:431
Arabic default style
Definition: afstyles.h:93

Referenced by EditWndProc_common().

◆ EDIT_EM_SetSel()

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

Definition at line 1635 of file edit.c.

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

Referenced by EDIT_EM_ReplaceSel(), EDIT_EM_Undo(), EDIT_MoveBackward(), EDIT_MoveDown_ML(), EDIT_MoveEnd(), EDIT_MoveForward(), EDIT_MoveHome(), EDIT_MovePageDown_ML(), EDIT_MovePageUp_ML(), EDIT_MoveUp_ML(), EDIT_MoveWordBackward(), EDIT_MoveWordForward(), EDIT_WM_Char(), EDIT_WM_KeyDown(), EDIT_WM_LButtonDblClk(), EDIT_WM_LButtonDown(), EDIT_WM_MouseMove(), EDIT_WM_SetText(), and EditWndProc_common().

◆ EDIT_EM_SetTabStops()

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

Definition at line 3036 of file edit.c.

3037 {
3038  if (!(es->style & ES_MULTILINE))
3039  return FALSE;
3040  HeapFree(GetProcessHeap(), 0, es->tabs);
3041  es->tabs_count = count;
3042  if (!count)
3043  es->tabs = NULL;
3044  else {
3045  es->tabs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
3046 #ifdef __REACTOS__
3047  /* ReactOS r33503 */
3048  if (es->tabs == NULL)
3049  {
3050  es->tabs_count = 0;
3051  return FALSE;
3052  }
3053 #endif
3054  memcpy(es->tabs, tabs, count * sizeof(INT));
3055  }
3057  return TRUE;
3058 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:376
#define es
Definition: i386-dis.c:431
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by EditWndProc_common().

◆ EDIT_EM_SetWordBreakProc()

static void EDIT_EM_SetWordBreakProc ( EDITSTATE es,
void wbp 
)
static

Definition at line 3066 of file edit.c.

3067 {
3068  if (es->word_break_proc == wbp)
3069  return;
3070 
3071  es->word_break_proc = wbp;
3072 
3073  if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
3076  }
3077 }
#define TRUE
Definition: types.h:120
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1505
#define ES_MULTILINE
Definition: pedump.c:667
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:250
smooth NULL
Definition: ftsmooth.c:416
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:505
#define es
Definition: i386-dis.c:431
#define ES_AUTOHSCROLL
Definition: pedump.c:672

Referenced by EditWndProc_common().

◆ EDIT_EM_Undo()

static BOOL EDIT_EM_Undo ( EDITSTATE es)
static

Definition at line 3085 of file edit.c.

3086 {
3087  INT ulength;
3088  LPWSTR utext;
3089 
3090  /* As per MSDN spec, for a single-line edit control,
3091  the return value is always TRUE */
3092  if( es->style & ES_READONLY )
3093  return !(es->style & ES_MULTILINE);
3094 
3095  ulength = strlenW(es->undo_text);
3096 
3097  utext = HeapAlloc(GetProcessHeap(), 0, (ulength + 1) * sizeof(WCHAR));
3098 #ifdef __REACTOS__
3099  /* ReactOS r33503 */
3100  if (utext == NULL)
3101  return FALSE;
3102 #endif
3103 
3104  strcpyW(utext, es->undo_text);
3105 
3106  TRACE("before UNDO:insertion length = %d, deletion buffer = %s\n",
3107  es->undo_insert_count, debugstr_w(utext));
3108 
3109  EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
3111  EDIT_EM_ReplaceSel(es, TRUE, utext, TRUE, TRUE);
3112  EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
3113  /* send the notification after the selection start and end are set */
3116  HeapFree(GetProcessHeap(), 0, utext);
3117 
3118  TRACE("after UNDO:insertion length = %d, deletion buffer = %s\n",
3119  es->undo_insert_count, debugstr_w(es->undo_text));
3120  return TRUE;
3121 }
static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1635
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ES_MULTILINE
Definition: pedump.c:667
#define ES_READONLY
Definition: pedump.c:675
int32_t INT
Definition: typedefs.h:56
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define EDIT_NOTIFY_PARENT(es, wNotifyCode)
Definition: edit.c:157
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2615
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:185
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1878
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define es
Definition: i386-dis.c:431
#define HeapFree(x, y, z)
Definition: compat.h:394
#define EN_CHANGE
Definition: winuser.h:2004

Referenced by EDIT_WM_SysKeyDown(), and EditWndProc_common().

◆ EDIT_GetCompositionStr()

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

Definition at line 4394 of file edit.c.

4395 {
4396  LONG buflen;
4397  LPWSTR lpCompStr;
4398  LPSTR lpCompStrAttr = NULL;
4399  DWORD dwBufLenAttr;
4400 
4401  buflen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
4402 
4403  if (buflen < 0)
4404  {
4405  return;
4406  }
4407 
4408  lpCompStr = HeapAlloc(GetProcessHeap(),0,buflen + sizeof(WCHAR));
4409  if (!lpCompStr)
4410  {
4411  ERR("Unable to allocate IME CompositionString\n");
4412  return;
4413  }
4414 
4415  if (buflen)
4416  ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, buflen);
4417  lpCompStr[buflen/sizeof(WCHAR)] = 0;
4418 
4419  if (CompFlag & GCS_COMPATTR)
4420  {
4421  /*
4422  * We do not use the attributes yet. it would tell us what characters
4423  * are in transition and which are converted or decided upon
4424  */
4425  dwBufLenAttr = ImmGetCompositionStringW(hIMC, GCS_COMPATTR, NULL, 0);
4426  if (dwBufLenAttr)
4427  {
4428  dwBufLenAttr ++;
4429  lpCompStrAttr = HeapAlloc(GetProcessHeap(),0,dwBufLenAttr+1);
4430  if (!lpCompStrAttr)
4431  {
4432  ERR("Unable to allocate IME Attribute String\n");
4433  HeapFree(GetProcessHeap(),0,lpCompStr);
4434  return;
4435  }
4436  ImmGetCompositionStringW(hIMC,GCS_COMPATTR, lpCompStrAttr,
4437  dwBufLenAttr);
4438  lpCompStrAttr[dwBufLenAttr] = 0;
4439  }
4440  }
4441 
4442  /* check for change in composition start */
4443  if (es->selection_end < es->composition_start)
4444  es->composition_start = es->selection_end;
4445 
4446  /* replace existing selection string */
4447  es->selection_start = es->composition_start;
4448 
4449  if (es->composition_len > 0)
4450  es->selection_end = es->composition_start + es->composition_len;
4451  else
4452  es->selection_end = es->selection_start;
4453 
4454  EDIT_EM_ReplaceSel(es, FALSE, lpCompStr, TRUE, TRUE);
4455  es->composition_len = abs(es->composition_start - es->selection_end);
4456 
4457  es->selection_start = es->composition_start;
4458  es->selection_end = es->selection_start + es->composition_len;
4459 
4460  HeapFree(GetProcessHeap(),0,lpCompStrAttr);
4461  HeapFree(GetProcessHeap(),0,lpCompStr);
4462 }
#define abs(i)
Definition: fconv.c:206
#define TRUE
Definition: types.h:120
char * LPSTR
Definition: xmlstorage.h:182
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2615
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: imm.c:1469
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GCS_COMPATTR
Definition: imm.h:360
#define ERR(fmt,...)
Definition: debug.h:109
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define es
Definition: i386-dis.c:431
#define GCS_COMPSTR
Definition: imm.h:359
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by EDIT_ImeComposition().

◆ EDIT_GetLineRect()

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

Definition at line 1224 of file edit.c.

1225 {
1227  INT line_index = 0;
1228  INT pt1, pt2, pt3;
1229 
1230  if (es->style & ES_MULTILINE)
1231  {
1232  const LINEDEF *line_def = NULL;
1233  rc->top = es->format_rect.top + (line - es->y_offset) * es->line_height;
1234  if (line >= es->line_count)
1235  return;
1236 
1237  line_def = es->first_line_def;
1238  if (line == -1) {
1239  INT index = es->selection_end - line_def->length;
1240  while ((index >= 0) && line_def->next) {
1241  line_index += line_def->length;
1242  line_def = line_def->next;
1243  index -= line_def->length;
1244  }
1245  } else {
1246  while (line > 0) {
1247  line_index += line_def->length;
1248  line_def = line_def->next;
1249  line--;
1250  }
1251  }
1252  ssa = line_def->ssa;
1253  }
1254  else
1255  {
1256  line_index = 0;
1257  rc->top = es->format_rect.top;
1258  ssa = es->ssa;
1259  }
1260 
1261  rc->bottom = rc->top + es->line_height;
1262  pt1 = (scol == 0) ? es->format_rect.left : (short)LOWORD(EDIT_EM_PosFromChar(es, line_index + scol, TRUE));
1263  pt2 = (ecol == -1) ? es->format_rect.right : (short)LOWORD(EDIT_EM_PosFromChar(es, line_index + ecol, TRUE));
1264  if (ssa)
1265  {
1266  ScriptStringCPtoX(ssa, scol, FALSE, &pt3);
1267  pt3+=es->format_rect.left;
1268  }
1269  else pt3 = pt1;
1270  rc->right = max(max(pt1 , pt2),pt3);
1271  rc->left = min(min(pt1, pt2),pt3);
1272 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define ES_MULTILINE
Definition: pedump.c:667
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
GLuint index
Definition: glext.h:6031
if(!(yy_init))
Definition: macro.lex.yy.c:714
struct tagLINEDEF * next
Definition: edit.c:94
#define min(a, b)
Definition: monoChain.cc:55
LONG bottom
Definition: windef.h:294
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int *pX)
Definition: usp10.c:2409
#define es
Definition: i386-dis.c:431
#define LOWORD(l)
Definition: pedump.c:82
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:93
INT length
Definition: edit.c:88
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1094

Referenced by EDIT_ML_InvalidateText(), EDIT_SL_InvalidateText(), and EDIT_WM_Paint().

◆ EDIT_GetResultStr()

static void EDIT_GetResultStr ( HIMC  hIMC,
EDITSTATE es 
)
static

Definition at line 4464 of file edit.c.

4465 {
4466  LONG buflen;
4467  LPWSTR lpResultStr;
4468 
4469  buflen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
4470  if (buflen <= 0)
4471  {
4472  return;
4473  }
4474 
4475  lpResultStr = HeapAlloc(GetProcessHeap(),0, buflen+sizeof(WCHAR));
4476  if (!lpResultStr)
4477  {
4478  ERR("Unable to alloc buffer for IME string\n");
4479  return;
4480  }
4481 
4482  ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpResultStr, buflen);
4483  lpResultStr[buflen/sizeof(WCHAR)] = 0;
4484 
4485  /* check for change in composition start */
4486  if (es->selection_end < es->composition_start)
4487  es->composition_start = es->selection_end;
4488 
4489  es->selection_start = es->composition_start;
4490  es->selection_end = es->composition_start + es->composition_len;
4491  EDIT_EM_ReplaceSel(es, TRUE, lpResultStr, TRUE, TRUE);
4492  es->composition_start = es->selection_end;
4493  es->composition_len = 0;
4494 
4495  HeapFree(GetProcessHeap(),0,lpResultStr);
4496 }
#define TRUE
Definition: types.h:120
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define GCS_RESULTSTR
Definition: imm.h:366
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2615
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: imm.c:1469
#define ERR(fmt,...)
Definition: debug.h:109
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define es
Definition: i386-dis.c:431
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by EDIT_ImeComposition().

◆ EDIT_ImeComposition()

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

Definition at line 4498 of file edit.c.

4499 {
4500  HIMC hIMC;
4501  int cursor;
4502 
4503  if (es->composition_len == 0 && es->selection_start != es->selection_end)
4504  {
4506  es->composition_start = es->selection_end;
4507  }
4508 
4509  hIMC = ImmGetContext(hwnd);
4510  if (!hIMC)
4511  return;
4512 
4513  if (CompFlag & GCS_RESULTSTR)
4514  {
4515  EDIT_GetResultStr(hIMC, es);
4516  cursor = 0;
4517  }
4518  else
4519  {
4520  if (CompFlag & GCS_COMPSTR)
4521  EDIT_GetCompositionStr(hIMC, CompFlag, es);
4523  }
4524  ImmReleaseContext(hwnd, hIMC);
4525  EDIT_SetCaretPos(es, es->selection_start + cursor, es->flags & EF_AFTER_WRAP);
4526 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
static void EDIT_GetCompositionStr(HIMC hIMC, LPARAM CompFlag, EDITSTATE *es)
Definition: edit.c:4394
static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap)
Definition: edit.c:1864
#define GCS_CURSORPOS
Definition: imm.h:362
#define GCS_RESULTSTR
Definition: imm.h:366
DWORD HIMC
Definition: dimm.idl:75
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2615
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: imm.c:1469
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1496
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:2253
const char cursor[]
Definition: icontest.c:13
#define EF_AFTER_WRAP
Definition: edit.c:66
#define es
Definition: i386-dis.c:431
#define GCS_COMPSTR
Definition: imm.h:359
static const WCHAR empty_stringW[]
Definition: edit.c:166
static void EDIT_GetResultStr(HIMC hIMC, EDITSTATE *es)
Definition: edit.c:4464

◆ EDIT_InvalidateText()

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

Definition at line 1605 of file edit.c.

1606 {
1607  if (end == start)
1608  return;
1609 
1610  if (end == -1)
1611  end = get_text_length(es);
1612 
1613  if (end < start) {
1614  INT tmp = start;
1615  start = end;
1616  end = tmp;
1617  }
1618 
1619  if (es->style & ES_MULTILINE)
1621  else
1623 }
static void EDIT_SL_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1522
#define ES_MULTILINE
Definition: pedump.c:667
GLuint GLuint end
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:56
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:250
static void EDIT_ML_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1540
GLuint start
Definition: gl.h:1545
#define es
Definition: i386-dis.c:431

Referenced by EDIT_EM_SetSel(), EDIT_WM_KillFocus(), and EDIT_WM_SetFocus().

◆ EDIT_InvalidateUniscribeData()

static void EDIT_InvalidateUniscribeData ( EDITSTATE es)
inlinestatic

Definition at line 376 of file edit.c.

377 {
378  LINEDEF *line_def = es->first_line_def;
379  while (line_def)
380  {
382  line_def = line_def->next;
383  }
384  if (es->ssa)
385  {
386  ScriptStringFree(&es->ssa);
387  es->ssa = NULL;
388  }
389 }
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:2554
struct tagLINEDEF * next
Definition: edit.c:94
static void EDIT_InvalidateUniscribeData_linedef(LINEDEF *line_def)
Definition: edit.c:367
#define es
Definition: i386-dis.c:431

Referenced by EDIT_EM_ReplaceSel(), EDIT_EM_SetPasswordChar(), EDIT_EM_SetTabStops(), EDIT_WM_NCCreate(), EDIT_WM_NCDestroy(), EDIT_WM_Paint(), EDIT_WM_SetFont(), EDIT_WM_SetText(), and text_buffer_changed().

◆ EDIT_InvalidateUniscribeData_linedef()

static void EDIT_InvalidateUniscribeData_linedef ( LINEDEF line_def)
inlinestatic

Definition at line 367 of file edit.c.

368 {
369  if (line_def->ssa)
370  {
371  ScriptStringFree(&line_def->ssa);
372  line_def->ssa = NULL;
373  }
374 }
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:2554
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:93

Referenced by EDIT_BuildLineDefs_ML(), and EDIT_InvalidateUniscribeData().

◆ EDIT_IsInsideDialog()

static BOOL EDIT_IsInsideDialog ( EDITSTATE es)
inlinestatic

Definition at line 3131 of file edit.c.

3132 {
3133  return (es->flags & EF_DIALOGMODE);
3134 }
#define EF_DIALOGMODE
Definition: edit.c:69
#define es
Definition: i386-dis.c:431

Referenced by EDIT_WM_Char(), and EDIT_WM_KeyDown().

◆ EDIT_LockBuffer()

static void EDIT_LockBuffer ( EDITSTATE es)
static

Definition at line 1288 of file edit.c.

1289 {
1290  if (es->hlocapp) return;
1291 
1292  if (!es->text) {
1293 
1294 #ifdef __REACTOS__
1295 /* FIXME: What is this ? */
1296  CHAR *textA = NULL; // ReactOS Hacked! r45670
1297  //UINT countA = 0;
1298 
1299  if(es->hloc32W)
1300  {
1301  if(es->hloc32A)
1302  {
1303  TRACE("Synchronizing with 32-bit ANSI buffer\n");
1304  textA = LocalLock(es->hloc32A);
1305  //countA = strlen(textA) + 1;
1306  }
1307  }
1308  else {
1309  ERR("no buffer ... please report\n");
1310  return;
1311  }
1312 
1313  if (textA)
1314  {
1315 #else
1316  if(!es->hloc32W) return;
1317 
1318  if(es->hloc32A)
1319  {
1320  CHAR *textA = LocalLock(es->hloc32A);
1321 #endif
1322  HLOCAL hloc32W_new;
1323  UINT countW_new = MultiByteToWideChar(CP_ACP, 0, textA, -1, NULL, 0);
1324  if(countW_new > es->buffer_size + 1)
1325  {
1326  UINT alloc_size = ROUND_TO_GROW(countW_new * sizeof(WCHAR));
1327  TRACE("Resizing 32-bit UNICODE buffer from %d+1 to %d WCHARs\n", es->buffer_size, countW_new);
1328  hloc32W_new = LocalReAlloc(es->hloc32W, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT);
1329  if(hloc32W_new)
1330  {
1331  es->hloc32W = hloc32W_new;
1332  es->buffer_size = LocalSize(hloc32W_new)/sizeof(WCHAR) - 1;
1333  TRACE("Real new size %d+1 WCHARs\n", es->buffer_size);
1334  }
1335  else
1336  WARN("FAILED! Will synchronize partially\n");
1337  }
1338  es->text = LocalLock(es->hloc32W);
1339  MultiByteToWideChar(CP_ACP, 0, textA, -1, es->text, es->buffer_size + 1);
1340  LocalUnlock(es->hloc32A);
1341  }
1342  else es->text = LocalLock(es->hloc32W);
1343  }
1344  es->lock_count++;
1345 }
#define ROUND_TO_GROW(size)
Definition: edit.c:55
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
#define WARN(fmt,...)
Definition: debug.h:111
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define LMEM_ZEROINIT
Definition: winbase.h:356
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const char textA[]
Definition: registrar.c:40
#define LMEM_MOVEABLE
Definition: winbase.h:350
#define ERR(fmt,...)
Definition: debug.h:109
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1608
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1599
unsigned int UINT
Definition: ndis.h:50
#define MultiByteToWideChar
Definition: compat.h:100
#define es
Definition: i386-dis.c:431

Referenced by EDIT_EM_SetHandle(), EDIT_MakeFit(), and EditWndProc_common().

◆ EDIT_MakeFit()

static BOOL EDIT_MakeFit ( EDITSTATE es,
UINT  size 
)
static

Definition at line 1422 of file edit.c.

1423 {
1424  HLOCAL hNew32W;
1425 
1427  return TRUE;
1428 
1429  TRACE("trying to ReAlloc to %d+1 characters\n", size);
1430 
1431  /* Force edit to unlock its buffer. es->text now NULL */
1433 
1434  if (es->hloc32W) {
1435  UINT alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1436  if ((hNew32W = LocalReAlloc(es->hloc32W, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT))) {
1437  TRACE("Old 32 bit handle %p, new handle %p\n", es->hloc32W, hNew32W);
1438  es->hloc32W = hNew32W;
1439  es->buffer_size = LocalSize(hNew32W)/sizeof(WCHAR) - 1;
1440  }
1441  }
1442 
1444 
1445  if (es->buffer_size < size) {
1446  WARN("FAILED ! We now have %d+1\n", es->buffer_size);
1448  return FALSE;
1449  } else {
1450  TRACE("We now have %d+1\n", es->buffer_size);
1451  return TRUE;
1452  }
1453 }
#define TRUE
Definition: types.h:120
#define ROUND_TO_GROW(size)
Definition: edit.c:55
#define WARN(fmt,...)
Definition: debug.h:111
static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
Definition: edit.c:1353
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:927
#define EN_ERRSPACE
Definition: winuser.h:2005
#define EDIT_NOTIFY_PARENT(es, wNotifyCode)
Definition: edit.c:157
#define TRACE(s)
Definition: solgame.cpp:4
static void EDIT_LockBuffer(EDITSTATE *es)
Definition: edit.c:1288
GLsizeiptr size
Definition: glext.h:5919
#define LMEM_ZEROINIT
Definition: winbase.h:356
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LMEM_MOVEABLE
Definition: winbase.h:350
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1608
unsigned int UINT
Definition: ndis.h:50
#define es
Definition: i386-dis.c:431

Referenced by EDIT_EM_ReplaceSel().

◆ EDIT_MakeUndoFit()

static BOOL EDIT_MakeUndoFit ( EDITSTATE es,
UINT  size 
)
static

Definition at line 1463 of file edit.c.

1464 {
1465  UINT alloc_size;
1466 
1467  if (size <= es->undo_buffer_size)
1468  return TRUE;
1469 
1470  TRACE("trying to ReAlloc to %d+1\n", size);
1471 
1472  alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1473  if ((es->undo_text = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, es->undo_text, alloc_size))) {
1474  es->undo_buffer_size = alloc_size/sizeof(WCHAR) - 1;
1475  return TRUE;
1476  }
1477  else
1478  {
1479  WARN("FAILED ! We now have %d+1\n", es->undo_buffer_size);
1480  return FALSE;
1481  }
1482 }
#define TRUE
Definition: types.h:120
#define ROUND_TO_GROW(size)
Definition: edit.c:55
#define WARN(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define HeapReAlloc
Definition: compat.h:393
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define es
Definition: i386-dis.c:431

Referenced by EDIT_EM_ReplaceSel().

◆ EDIT_ML_InvalidateText()

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

Definition at line 1540 of file edit.c.

1541 {
1544  INT el = EDIT_EM_LineFromChar(es, end);
1545  INT sc;
1546  INT ec;
1547  RECT rc1;
1548  RECT rcWnd;
1549  RECT rcLine;
1550  RECT rcUpdate;
1551  INT l;
1552 
1553  if ((el < es->y_offset) || (sl > es->y_offset + vlc))
1554  return;
1555 
1556  sc = start - EDIT_EM_LineIndex(es, sl);
1557  ec = end - EDIT_EM_LineIndex(es, el);
1558  if (sl < es->y_offset) {
1559  sl = es->y_offset;
1560  sc = 0;
1561  }
1562  if (el > es->y_offset + vlc) {
1563  el = es->y_offset + vlc;
1565  }
1566  GetClientRect(es->hwndSelf, &rc1);
1567  IntersectRect(&rcWnd, &rc1, &es->format_rect);
1568  if (sl == el) {
1569  EDIT_GetLineRect(es, sl, sc, ec, &rcLine);
1570  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1571  EDIT_UpdateText(es, &rcUpdate, TRUE);
1572  } else {
1573  EDIT_GetLineRect(es, sl, sc,
1575  EDIT_EM_LineIndex(es, sl)),
1576  &rcLine);
1577  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1578  EDIT_UpdateText(es, &rcUpdate, TRUE);
1579  for (l = sl + 1 ; l < el ; l++) {
1580  EDIT_GetLineRect(es, l, 0,
1582  EDIT_EM_LineIndex(es, l)),
1583  &rcLine);
1584  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1585  EDIT_UpdateText(es, &rcUpdate, TRUE);
1586  }
1587  EDIT_GetLineRect(es, el, 0, ec, &rcLine);
1588  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1589  EDIT_UpdateText(es, &rcUpdate, TRUE);
1590  }
1591 }
#define TRUE
Definition: types.h:120
static void EDIT_GetLineRect(EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc)
Definition: edit.c:1224
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1505
GLuint GLuint end
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:56
r l[0]
Definition: byte_order.h:167
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:1058
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:994
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
GLuint start
Definition: gl.h:1545
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:1023
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:490
#define es
Definition: i386-dis.c:431

Referenced by EDIT_InvalidateText().

◆ EDIT_MoveBackward()

static void EDIT_MoveBackward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1948 of file edit.c.

1949 {
1950  INT e = es->selection_end;
1951 
1952  if (e) {
1953  e--;
1954  if ((es->style & ES_MULTILINE) && e &&
1955  (es->text[e - 1] == '\r') && (es->text[e] == '\n')) {
1956  e--;
1957  if (e && (es->text[e - 1] == '\r'))
1958  e--;
1959  }
1960  }
1961  EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);
1963 }
static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1635
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:56
#define e
Definition: ke_i.h:82
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1878
#define es
Definition: i386-dis.c:431

Referenced by EDIT_WM_Char(), EDIT_WM_KeyDown(), and EDIT_WM_Timer().

◆ EDIT_MoveDown_ML()

static void EDIT_MoveDown_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1975 of file edit.c.

1976 {
1977  INT s = es->selection_start;
1978  INT e = es->selection_end;
1979  BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
1980  LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
1981  INT x = (short)LOWORD(pos);
1982  INT y = (short)HIWORD(pos);
1983 
1984  e = EDIT_CharFromPos(es, x, y + es->line_height, &after_wrap);
1985  if (!extend)
1986  s = e;
1987  EDIT_EM_SetSel(es, s, e, after_wrap);
1989 }
static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1635
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:56
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
#define e
Definition: ke_i.h:82
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:865
GLdouble s
Definition: gl.h:2039
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1878
#define EF_AFTER_WRAP
Definition: edit.c:66
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define HIWORD(l)
Definition: typedefs.h:246
LONG_PTR LRESULT
Definition: windef.h:209
#define es
Definition: i386-dis.c:431
#define LOWORD(l)
Definition: pedump.c:82
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1094

Referenced by EDIT_WM_Char(), and EDIT_WM_KeyDown().

◆ EDIT_MoveEnd()

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

Definition at line 1997 of file edit.c.

1998 {
1999  BOOL after_wrap = FALSE;
2000  INT e;
2001 
2002  /* Pass a high value in x to make sure of receiving the end of the line */
2003  if (!ctrl && (es->style & ES_MULTILINE))
2004  e = EDIT_CharFromPos(es, 0x3fffffff,
2005  HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap);
2006  else
2007  e = get_text_length(es);
2008  EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, after_wrap);
2010 }
static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1635
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:56
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:250
unsigned int BOOL
Definition: ntddk_ex.h:94
#define e
Definition: ke_i.h:82
#define ctrl
Definition: input.c:1669
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:865
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1878
#define EF_AFTER_WRAP
Definition: edit.c:66
#define HIWORD(l)
Definition: typedefs.h:246
#define es
Definition: i386-dis.c:431
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1094

Referenced by EDIT_WM_KeyDown().

◆ EDIT_MoveForward()

static void EDIT_MoveForward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2018 of file edit.c.

2019 {
2020  INT e = es->selection_end;
2021 
2022  if (es->text[e]) {
2023  e++;
2024  if ((es->style & ES_MULTILINE) && (es->text[e - 1] == '\r')) {
2025  if (es->text[e] == '\n')
2026  e++;
2027  else if ((es->text[e] == '\r') && (es->text[e + 1] == '\n'))
2028  e += 2;
2029  }
2030  }
2031  EDIT_EM_SetSel(es, extend ? es->selec