ReactOS  0.4.15-dev-4574-g434cf85
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 58 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:3989
#define GetWindowLongPtrW
Definition: winuser.h:4809
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_COMMAND
Definition: winuser.h:1727
#define GWLP_ID
Definition: winuser.h:854
#define es
Definition: i386-dis.c:433

Definition at line 162 of file edit.c.

◆ EF_AFTER_WRAP

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

Definition at line 71 of file edit.c.

◆ EF_DIALOGMODE

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

Definition at line 74 of file edit.c.

◆ EF_FOCUSED

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

Definition at line 67 of file edit.c.

◆ EF_HSCROLL_TRACK

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

Definition at line 70 of file edit.c.

◆ EF_MODIFIED

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

Definition at line 66 of file edit.c.

◆ EF_UPDATE

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

Definition at line 68 of file edit.c.

◆ EF_USE_SOFTBRK

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

Definition at line 73 of file edit.c.

◆ EF_VSCROLL_TRACK

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

Definition at line 69 of file edit.c.

◆ GROWLENGTH

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

Definition at line 59 of file edit.c.

◆ HSCROLL_FRACTION

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

Definition at line 61 of file edit.c.

◆ ORDER_UINT

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

Definition at line 159 of file edit.c.

◆ ROUND_TO_GROW

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

Definition at line 60 of file edit.c.

◆ SWAP_UINT32

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

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

77 {
78  END_0 = 0, /* line ends with terminating '\0' character */
79  END_WRAP, /* line is wrapped */
80  END_HARD, /* line ends with a hard return '\r\n' */
81  END_SOFT, /* line ends with a soft return '\r\r\n' */
82  END_RICH /* line ends with a single '\n' */
83 } 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 4742 of file edit.c.

4743 {
4744  if(unicode)
4745  return DefWindowProcW(hwnd, msg, wParam, lParam);
4746  else
4747  return DefWindowProcA(hwnd, msg, wParam, lParam);
4748 }
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
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
LPARAM lParam
Definition: combotst.c:139

Referenced by EditWndProc_common().

◆ EDIT_AdjustFormatRect()

static void EDIT_AdjustFormatRect ( EDITSTATE es)
static

Definition at line 2358 of file edit.c.

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

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

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

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

848 {
850  if (es->ssa)
851  {
852  const SIZE *size;
853  size = ScriptString_pSize(es->ssa);
854  es->text_width = size->cx;
855  }
856  else
857  es->text_width = 0;
858 }
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, INT line)
Definition: edit.c:443
GLsizeiptr size
Definition: glext.h:5919
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3876
#define NULL
Definition: types.h:112
#define es
Definition: i386-dis.c:433

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

334 {
335  INT ret;
336 
337  if (es->word_break_proc)
338  {
339  if(es->is_unicode)
340  {
341  EDITWORDBREAKPROCW wbpW = (EDITWORDBREAKPROCW)es->word_break_proc;
342 
343  TRACE_(relay)("(UNICODE wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
344  es->word_break_proc, debugstr_wn(es->text + start, count), index, count, action);
345  ret = wbpW(es->text + start, index, count, action);
346  }
347  else
348  {
349  EDITWORDBREAKPROCA wbpA = (EDITWORDBREAKPROCA)es->word_break_proc;
350  INT countA;
351  CHAR *textA;
352 
353  countA = WideCharToMultiByte(CP_ACP, 0, es->text + start, count, NULL, 0, NULL, NULL);
354  textA = HeapAlloc(GetProcessHeap(), 0, countA);
355 #ifdef __REACTOS__
356  /* ReactOS r33503 */
357  if (textA == NULL) return 0;
358 #endif
359  WideCharToMultiByte(CP_ACP, 0, es->text + start, count, textA, countA, NULL, NULL);
360  TRACE_(relay)("(ANSI wordbrk=%p,str=%s,idx=%d,cnt=%d,act=%d)\n",
361  es->word_break_proc, debugstr_an(textA, countA), index, countA, action);
362  ret = wbpA(textA, index, countA, action);
364  }
365  }
366  else
368 
369  return ret;
370 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
GLuint GLuint GLsizei count
Definition: gl.h:1545
char CHAR
Definition: xmlstorage.h:175
int32_t INT
Definition: typedefs.h:58
int(CALLBACK * EDITWORDBREAKPROCA)(LPSTR, int, int, int)
Definition: winuser.h:2884
GLuint index
Definition: glext.h:6031
#define TRACE_(x)
Definition: compat.h:76
#define GetProcessHeap()
Definition: compat.h:595
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:55
int(CALLBACK * EDITWORDBREAKPROCW)(LPWSTR, int, int, int)
Definition: winuser.h:2885
#define debugstr_wn
Definition: kernel32.h:33
const WCHAR * action
Definition: action.c:7479
GLuint start
Definition: gl.h:1545
#define NULL
Definition: types.h:112
static INT EDIT_WordBreakProc(EDITSTATE *es, LPWSTR s, INT index, INT count, INT action)
Definition: edit.c:275
#define HeapFree(x, y, z)
Definition: compat.h:594
#define es
Definition: i386-dis.c:433

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

871 {
872  INT index;
873 
874  if (es->style & ES_MULTILINE) {
875  int trailing;
876  INT line = (y - es->format_rect.top) / es->line_height + es->y_offset;
877  INT line_index = 0;
878  LINEDEF *line_def = es->first_line_def;
880  while ((line > 0) && line_def->next) {
881  line_index += line_def->length;
882  line_def = line_def->next;
883  line--;
884  }
885 
886  x += es->x_offset - es->format_rect.left;
887  if (es->style & ES_RIGHT)
888  x -= (es->format_rect.right - es->format_rect.left) - line_def->width;
889  else if (es->style & ES_CENTER)
890  x -= ((es->format_rect.right - es->format_rect.left) - line_def->width) / 2;
891  if (x >= line_def->width) {
892  if (after_wrap)
893  *after_wrap = (line_def->ending == END_WRAP);
894  return line_index + line_def->net_length;
895  }
896  if (x <= 0 || !line_def->ssa) {
897  if (after_wrap)
898  *after_wrap = FALSE;
899  return line_index;
900  }
901 
902  ScriptStringXtoCP(line_def->ssa, x , &index, &trailing);
903  if (trailing) index++;
904  index += line_index;
905  if (after_wrap)
906  *after_wrap = ((index == line_index + line_def->net_length) &&
907  (line_def->ending == END_WRAP));
908  } else {
909  INT xoff = 0;
910  INT trailing;
911  if (after_wrap)
912  *after_wrap = FALSE;
913  x -= es->format_rect.left;
914  if (!x)
915  return es->x_offset;
916 
917  if (!es->x_offset)
918  {
919  INT indent = (es->format_rect.right - es->format_rect.left) - es->text_width;
920  if (es->style & ES_RIGHT)
921  x -= indent;
922  else if (es->style & ES_CENTER)
923  x -= indent / 2;
924  }
925 
927  if (es->x_offset)
928  {
929  if (es->ssa)
930  {
931  if (es->x_offset>= get_text_length(es))
932  {
933  const SIZE *size;
934  size = ScriptString_pSize(es->ssa);
935  xoff = size->cx;
936  }
937  ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
938  }
939  else
940  xoff = 0;
941  }
942  if (x < 0)
943  {
944  if (x + xoff > 0 || !es->ssa)
945  {
946  ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
947  if (trailing) index++;
948  }
949  else
950  index = 0;
951  }
952  else
953  {
954  if (x)
955  {
956  const SIZE *size = NULL;
957  if (es->ssa)
958  size = ScriptString_pSize(es->ssa);
959  if (!size)
960  index = 0;
961  else if (x > size->cx)
963  else if (es->ssa)
964  {
965  ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
966  if (trailing) index++;
967  }
968  else
969  index = 0;
970  }
971  else
972  index = es->x_offset;
973  }
974  }
975  return index;
976 }
#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:2474
Definition: edit.c:81
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
if(dx==0 &&dy==0)
Definition: linetemp.h:174
int32_t INT
Definition: typedefs.h:58
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:255
#define FALSE
Definition: types.h:117
#define ES_RIGHT
Definition: pedump.c:666
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:443
GLsizeiptr size
Definition: glext.h:5919
#define index(s, c)
Definition: various.h:29
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3876
#define NULL
Definition: types.h:112
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:2411
#define es
Definition: i386-dis.c:433

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

3441 {
3442  HWND hLBox = es->hwndListBox;
3443  HWND hCombo;
3444  BOOL bDropped;
3445  int nEUI;
3446 
3447  if (!hLBox)
3448  return FALSE;
3449 
3450  hCombo = GetParent(es->hwndSelf);
3451  bDropped = TRUE;
3452  nEUI = 0;
3453 
3454  TRACE_(combo)("[%p]: handling msg %x (%x)\n", es->hwndSelf, msg, key);
3455 
3456  if (key == VK_UP || key == VK_DOWN)
3457  {
3458  if (SendMessageW(hCombo, CB_GETEXTENDEDUI, 0, 0))
3459  nEUI = 1;
3460 
3461  if (msg == WM_KEYDOWN || nEUI)
3462  bDropped = (BOOL)SendMessageW(hCombo, CB_GETDROPPEDSTATE, 0, 0);
3463  }
3464 
3465  switch (msg)
3466  {
3467  case WM_KEYDOWN:
3468  if (!bDropped && nEUI && (key == VK_UP || key == VK_DOWN))
3469  {
3470  /* make sure ComboLBox pops up */
3471  SendMessageW(hCombo, CB_SETEXTENDEDUI, FALSE, 0);
3472  key = VK_F4;
3473  nEUI = 2;
3474  }
3475 
3476  SendMessageW(hLBox, WM_KEYDOWN, key, 0);
3477  break;
3478 
3479  case WM_SYSKEYDOWN: /* Handle Alt+up/down arrows */
3480  if (nEUI)
3481  SendMessageW(hCombo, CB_SHOWDROPDOWN, !bDropped, 0);
3482  else
3483  SendMessageW(hLBox, WM_KEYDOWN, VK_F4, 0);
3484  break;
3485  }
3486 
3487  if(nEUI == 2)
3488  SendMessageW(hCombo, CB_SETEXTENDEDUI, TRUE, 0);
3489 
3490  return TRUE;
3491 }
#define CB_GETDROPPEDSTATE
Definition: winuser.h:1932
#define TRUE
Definition: types.h:120
#define VK_DOWN
Definition: winuser.h:2207
#define BOOL
Definition: nt_native.h:43
#define VK_UP
Definition: winuser.h:2205
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CB_SHOWDROPDOWN
Definition: winuser.h:1957
#define VK_F4
Definition: winuser.h:2238
#define WM_KEYDOWN
Definition: winuser.h:1702
#define TRACE_(x)
Definition: compat.h:76
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:1951
#define msg(x)
Definition: auth_time.c:54
#define WM_SYSKEYDOWN
Definition: winuser.h:1706
#define CB_GETEXTENDEDUI
Definition: winuser.h:1935
#define es
Definition: i386-dis.c:433
Definition: path.c:41

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

988 {
989  *x = min(max(*x, es->format_rect.left), es->format_rect.right - 1);
990  *y = min(max(*y, es->format_rect.top), es->format_rect.bottom - 1);
991 }
#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:433

Referenced by EDIT_WM_LButtonDown(), and EDIT_WM_MouseMove().

◆ EDIT_ContextMenuCommand()

static void EDIT_ContextMenuCommand ( EDITSTATE es,
UINT  id 
)
static

Definition at line 3317 of file edit.c.

3318 {
3319  switch (id) {
3320  case EM_UNDO:
3321  SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
3322  break;
3323  case WM_CUT:
3324  SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
3325  break;
3326  case WM_COPY:
3327  SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
3328  break;
3329  case WM_PASTE:
3330  SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3331  break;
3332  case WM_CLEAR:
3333  SendMessageW(es->hwndSelf, WM_CLEAR, 0, 0);
3334  break;
3335  case EM_SETSEL:
3336  SendMessageW(es->hwndSelf, EM_SETSEL, 0, -1);
3337  break;
3338  default:
3339  ERR("unknown menu item, please report\n");
3340  break;
3341  }
3342 }
#define WM_CUT
Definition: winuser.h:1848
#define WM_PASTE
Definition: winuser.h:1850
#define WM_CLEAR
Definition: winuser.h:1851
#define WM_COPY
Definition: winuser.h:1849
#define EM_SETSEL
Definition: winuser.h:2005
#define EM_UNDO
Definition: winuser.h:2008
#define ERR(fmt,...)
Definition: debug.h:110
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_UNDO
Definition: winuser.h:1852
#define es
Definition: i386-dis.c:433

Referenced by EDIT_WM_ContextMenu().

◆ EDIT_EM_CanUndo()

static BOOL EDIT_EM_CanUndo ( const EDITSTATE es)
inlinestatic

Definition at line 179 of file edit.c.

180 {
181  return (es->undo_insert_count || strlenW(es->undo_text));
182 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define es
Definition: i386-dis.c:433

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

2459 {
2460  POINT pt;
2461  RECT rc;
2462  INT index;
2463 
2464  pt.x = x;
2465  pt.y = y;
2466  GetClientRect(es->hwndSelf, &rc);
2467  if (!PtInRect(&rc, pt))
2468  return -1;
2469 
2470  index = EDIT_CharFromPos(es, x, y, NULL);
2472 }
#define pt(x, y)
Definition: drawing.c:79
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:58
#define MAKELONG(a, b)
Definition: typedefs.h:249
GLuint index
Definition: glext.h:6031
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:870
#define index(s, c)
Definition: various.h:29
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:999
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define es
Definition: i386-dis.c:433

◆ EDIT_EM_EmptyUndoBuffer()

static void EDIT_EM_EmptyUndoBuffer ( EDITSTATE es)
inlinestatic

Definition at line 190 of file edit.c.

191 {
192  es->undo_insert_count = 0;
193  *es->undo_text = '\0';
194 }
#define es
Definition: i386-dis.c:433

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

2487 {
2488  es->flags &= ~EF_USE_SOFTBRK;
2489  if (add_eol) {
2490  es->flags |= EF_USE_SOFTBRK;
2491  FIXME("soft break enabled, not implemented\n");
2492  }
2493  return add_eol;
2494 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define EF_USE_SOFTBRK
Definition: edit.c:73
#define es
Definition: i386-dis.c:433

Referenced by EditWndProc_common().

◆ EDIT_EM_GetHandle()

static HLOCAL EDIT_EM_GetHandle ( EDITSTATE es)
static

Definition at line 2508 of file edit.c.

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

Referenced by EditWndProc_common().

◆ EDIT_EM_GetLine()

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

Definition at line 2553 of file edit.c.

2554 {
2555  LPWSTR src;
2556  INT line_len, dst_len;
2557  INT i;
2558 
2559  if (es->style & ES_MULTILINE) {
2560  if (line >= es->line_count)
2561  return 0;
2562  } else
2563  line = 0;
2564  i = EDIT_EM_LineIndex(es, line);
2565  src = es->text + i;
2566  line_len = EDIT_EM_LineLength(es, i);
2567  dst_len = *(WORD *)dst;
2568  if(unicode)
2569  {
2570  if(dst_len <= line_len)
2571  {
2572  memcpy(dst, src, dst_len * sizeof(WCHAR));
2573  return dst_len;
2574  }
2575  else /* Append 0 if enough space */
2576  {
2577  memcpy(dst, src, line_len * sizeof(WCHAR));
2578  dst[line_len] = 0;
2579  return line_len;
2580  }
2581  }
2582  else
2583  {
2584  INT ret = WideCharToMultiByte(CP_ACP, 0, src, line_len, (LPSTR)dst, dst_len, NULL, NULL);
2585  if(!ret && line_len) /* Insufficient buffer size */
2586  return dst_len;
2587  if(ret < dst_len) /* Append 0 if enough space */
2588  ((LPSTR)dst)[ret] = 0;
2589  return ret;
2590  }
2591 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
#define ES_MULTILINE
Definition: pedump.c:667
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:58
Definition: parser.c:48
__wchar_t WCHAR
Definition: xmlstorage.h:180
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:1063
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
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
GLenum GLenum dst
Definition: glext.h:6340
#define NULL
Definition: types.h:112
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:1028
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define es
Definition: i386-dis.c:433

Referenced by EditWndProc_common().

◆ EDIT_EM_GetSel()

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

Definition at line 2599 of file edit.c.

2600 {
2601  UINT s = es->selection_start;
2602  UINT e = es->selection_end;
2603 
2604  ORDER_UINT(s, e);
2605  if (start)
2606  *start = s;
2607  if (end)
2608  *end = e;
2609  return MAKELONG(s, e);
2610 }
#define e
Definition: ke_i.h:82
#define MAKELONG(a, b)
Definition: typedefs.h:249
GLuint GLuint end
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
#define ORDER_UINT(x, y)
Definition: edit.c:159
GLuint start
Definition: gl.h:1545
unsigned int UINT
Definition: ndis.h:50
#define es
Definition: i386-dis.c:433

Referenced by EditWndProc_common().

◆ EDIT_EM_GetThumb()

static LRESULT EDIT_EM_GetThumb ( EDITSTATE es)
static

Definition at line 4396 of file edit.c.

4397 {
4398  return MAKELONG(EDIT_WM_VScroll(es, EM_GETTHUMB, 0),
4400 }
static LRESULT EDIT_WM_VScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:4276
#define MAKELONG(a, b)
Definition: typedefs.h:249
static LRESULT EDIT_WM_HScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:4144
#define es
Definition: i386-dis.c:433
#define EM_GETTHUMB
Definition: winuser.h:1985

Referenced by EditWndProc_common().

◆ EDIT_EM_LineFromChar()

static INT EDIT_EM_LineFromChar ( EDITSTATE es,
INT  index 
)
static

Definition at line 999 of file edit.c.

1000 {
1001  INT line;
1002  LINEDEF *line_def;
1003 
1004  if (!(es->style & ES_MULTILINE))
1005  return 0;
1006  if (index > (INT)get_text_length(es))
1007  return es->line_count - 1;
1008  if (index == -1)
1009  index = min(es->selection_start, es->selection_end);
1010 
1011  line = 0;
1012  line_def = es->first_line_def;
1013  index -= line_def->length;
1014  while ((index >= 0) && line_def->next) {
1015  line++;
1016  line_def = line_def->next;
1017  index -= line_def->length;
1018  }
1019  return line;
1020 }
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:58
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:255
Definition: parser.c:48
GLuint index
Definition: glext.h:6031
struct tagLINEDEF * next
Definition: edit.c:94
IN PCTCH line
Definition: pager.h:36
#define min(a, b)
Definition: monoChain.cc:55
INT length
Definition: edit.c:88
#define es
Definition: i386-dis.c:433

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

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

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

1064 {
1065  LINEDEF *line_def;
1066 
1067  if (!(es->style & ES_MULTILINE))
1068  return get_text_length(es);
1069 
1070  if (index == -1) {
1071  /* get the number of remaining non-selected chars of selected lines */
1072  INT32 l; /* line number */
1073  INT32 li; /* index of first char in line */
1074  INT32 count;
1075  l = EDIT_EM_LineFromChar(es, es->selection_start);
1076  /* # chars before start of selection area */
1077  count = es->selection_start - EDIT_EM_LineIndex(es, l);
1078  l = EDIT_EM_LineFromChar(es, es->selection_end);
1079  /* # chars after end of selection */
1080  li = EDIT_EM_LineIndex(es, l);
1081  count += li + EDIT_EM_LineLength(es, li) - es->selection_end;
1082  return count;
1083  }
1084  line_def = es->first_line_def;
1085  index -= line_def->length;
1086  while ((index >= 0) && line_def->next) {
1087  line_def = line_def->next;
1088  index -= line_def->length;
1089  }
1090  return line_def->net_length;
1091 }
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:255
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:1063
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:999
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:1028
signed int INT32
INT length
Definition: edit.c:88
#define es
Definition: i386-dis.c:433
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235

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

1804 {
1805  if (!(es->style & ES_MULTILINE))
1806  return FALSE;
1807 
1808  dx *= es->char_width;
1809  return EDIT_EM_LineScroll_internal(es, dx, dy);
1810 }
static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1747
GLint dy
Definition: linetemp.h:97
#define ES_MULTILINE
Definition: pedump.c:667
#define FALSE
Definition: types.h:117
GLint dx
Definition: linetemp.h:97
#define es
Definition: i386-dis.c:433

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

1748 {
1749  INT nyoff;
1750  INT x_offset_in_pixels;
1751  INT lines_per_page = (es->format_rect.bottom - es->format_rect.top) /
1752  es->line_height;
1753 
1754  if (es->style & ES_MULTILINE)
1755  {
1756  x_offset_in_pixels = es->x_offset;
1757  }
1758  else
1759  {
1760  dy = 0;
1761  x_offset_in_pixels = (short)LOWORD(EDIT_EM_PosFromChar(es, es->x_offset, FALSE));
1762  }
1763 
1764  if (-dx > x_offset_in_pixels)
1765  dx = -x_offset_in_pixels;
1766  if (dx > es->text_width - x_offset_in_pixels)
1767  dx = es->text_width - x_offset_in_pixels;
1768  nyoff = max(0, es->y_offset + dy);
1769  if (nyoff >= es->line_count - lines_per_page)
1770  nyoff = max(0, es->line_count - lines_per_page);
1771  dy = (es->y_offset - nyoff) * es->line_height;
1772  if (dx || dy) {
1773  RECT rc1;
1774  RECT rc;
1775 
1776  es->y_offset = nyoff;
1777  if(es->style & ES_MULTILINE)
1778  es->x_offset += dx;
1779  else
1780  es->x_offset += dx / es->char_width;
1781 
1782  GetClientRect(es->hwndSelf, &rc1);
1783  IntersectRect(&rc, &rc1, &es->format_rect);
1784  ScrollWindowEx(es->hwndSelf, -dx, dy,
1785  NULL, &rc, NULL, NULL, SW_INVALIDATE);
1786  /* force scroll info update */
1788  }
1789  if (dx && !(es->flags & EF_HSCROLL_TRACK))
1791  if (dy && !(es->flags & EF_VSCROLL_TRACK))
1793  return TRUE;
1794 }
#define max(a, b)
Definition: svc.c:63
#define EF_VSCROLL_TRACK
Definition: edit.c:69
#define TRUE
Definition: types.h:120
GLint dy
Definition: linetemp.h:97
#define ES_MULTILINE
Definition: pedump.c:667
if(dx==0 &&dy==0)
Definition: linetemp.h:174
int32_t INT
Definition: typedefs.h:58
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define FALSE
Definition: types.h:117
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:162
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define EN_HSCROLL
Definition: winuser.h:2011
#define EF_HSCROLL_TRACK
Definition: edit.c:70
#define SW_INVALIDATE
Definition: winuser.h:2559
#define EN_VSCROLL
Definition: winuser.h:2016
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define NULL
Definition: types.h:112
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1706
GLint dx
Definition: linetemp.h:97
#define LOWORD(l)
Definition: pedump.c:82
#define es
Definition: i386-dis.c:433
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1099

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

1100 {
1102  INT l;
1103  INT li;
1104  INT x = 0;
1105  INT y = 0;
1106  INT w;
1107  INT lw;
1108  LINEDEF *line_def;
1109 
1110  index = min(index, len);
1111  if (es->style & ES_MULTILINE) {
1114 
1115  y = (l - es->y_offset) * es->line_height;
1116  li = EDIT_EM_LineIndex(es, l);
1117  if (after_wrap && (li == index) && l) {
1118  INT l2 = l - 1;
1119  line_def = es->first_line_def;
1120  while (l2) {
1121  line_def = line_def->next;
1122  l2--;
1123  }
1124  if (line_def->ending == END_WRAP) {
1125  l--;
1126  y -= es->line_height;
1127  li = EDIT_EM_LineIndex(es, l);
1128  }
1129  }
1130 
1131  line_def = es->first_line_def;
1132  while (line_def->index != li)
1133  line_def = line_def->next;
1134 
1135  lw = line_def->width;
1136  w = es->format_rect.right - es->format_rect.left;
1137  if (line_def->ssa)
1138  {
1139  ScriptStringCPtoX(line_def->ssa, (index - 1) - li, TRUE, &x);
1140  x -= es->x_offset;
1141  }
1142  else
1143 #ifdef __REACTOS__ /* CORE-15780 */
1144  x = (lw > 0 ? es->x_offset : x - es->x_offset);
1145 #else
1146  x = es->x_offset;
1147 #endif
1148 
1149  if (es->style & ES_RIGHT)
1150  x = w - (lw - x);
1151  else if (es->style & ES_CENTER)
1152  x += (w - lw) / 2;
1153  } else {
1154  INT xoff = 0;
1155  INT xi = 0;
1157  if (es->x_offset)
1158  {
1159  if (es->ssa)
1160  {
1161  if (es->x_offset >= get_text_length(es))
1162  {
1163  int leftover = es->x_offset - get_text_length(es);
1164  if (es->ssa)
1165  {
1166  const SIZE *size;
1167  size = ScriptString_pSize(es->ssa);
1168  xoff = size->cx;
1169  }
1170  else
1171  xoff = 0;
1172  xoff += es->char_width * leftover;
1173  }
1174  else
1175  ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
1176  }
1177  else
1178  xoff = 0;
1179  }
1180  if (index)
1181  {
1182  if (index >= get_text_length(es))
1183  {
1184  if (es->ssa)
1185  {
1186  const SIZE *size;
1187  size = ScriptString_pSize(es->ssa);
1188  xi = size->cx;
1189  }
1190  else
1191  xi = 0;
1192  }
1193  else if (es->ssa)
1194  ScriptStringCPtoX(es->ssa, index, FALSE, &xi);
1195  else
1196  xi = 0;
1197  }
1198  x = xi - xoff;
1199 
1200  if (index >= es->x_offset) {
1201  if (!es->x_offset && (es->style & (ES_RIGHT | ES_CENTER)))
1202  {
1203  w = es->format_rect.right - es->format_rect.left;
1204  if (w > es->text_width)
1205  {
1206  if (es->style & ES_RIGHT)
1207  x += w - es->text_width;
1208  else if (es->style & ES_CENTER)
1209  x += (w - es->text_width) / 2;
1210  }
1211  }
1212  }
1213  y = 0;
1214  }
1215  x += es->format_rect.left;
1216  y += es->format_rect.top;
1217  return MAKELONG((INT16)x, (INT16)y);
1218 }
#define ES_CENTER
Definition: pedump.c:665
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define TRUE
Definition: types.h:120
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:58
INT width
Definition: edit.c:91
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:255
#define FALSE
Definition: types.h:117
#define ES_RIGHT
Definition: pedump.c:666
#define MAKELONG(a, b)
Definition: typedefs.h:249
GLuint index
Definition: glext.h:6031
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, INT line)
Definition: edit.c:443
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:999
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3876
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:1028
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:2411
INT index
Definition: edit.c:92
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:93
#define es
Definition: i386-dis.c:433
LARGE_INTEGER li
Definition: fxtimerapi.cpp:235
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 2620 of file edit.c.

2621 {
2622  UINT strl = strlenW(lpsz_replace);
2623  UINT tl = get_text_length(es);
2624  UINT utl;
2625  UINT s;
2626  UINT e;
2627  UINT i;
2628  UINT size;
2629  LPWSTR p;
2630  HRGN hrgn = 0;
2631  LPWSTR buf = NULL;
2632  UINT bufl;
2633 
2634  TRACE("%s, can_undo %d, send_update %d\n",
2635  debugstr_w(lpsz_replace), can_undo, send_update);
2636 
2637  s = es->selection_start;
2638  e = es->selection_end;
2639 
2641  if ((s == e) && !strl)
2642  return;
2643 
2644  ORDER_UINT(s, e);
2645 
2646  size = tl - (e - s) + strl;
2647  if (!size)
2648  es->text_width = 0;
2649 
2650  /* Issue the EN_MAXTEXT notification and continue with replacing text
2651  * so that buffer limit is honored. */
2652  if ((honor_limit) && (size > es->buffer_limit)) {
2654  /* Buffer limit can be smaller than the actual length of text in combobox */
2655  if (es->buffer_limit < (tl - (e-s)))
2656  strl = 0;
2657  else
2658  strl = min(strl, es->buffer_limit - (tl - (e-s)));
2659  }
2660 
2661  if (!EDIT_MakeFit(es, tl - (e - s) + strl))
2662  return;
2663 
2664  if (e != s) {
2665  /* there is something to be deleted */
2666  TRACE("deleting stuff.\n");
2667  bufl = e - s;
2668  buf = HeapAlloc(GetProcessHeap(), 0, (bufl + 1) * sizeof(WCHAR));
2669  if (!buf) return;
2670  memcpy(buf, es->text + s, bufl * sizeof(WCHAR));
2671  buf[bufl] = 0; /* ensure 0 termination */
2672  /* now delete */
2673  strcpyW(es->text + s, es->text + e);
2675  }
2676  if (strl) {
2677  /* there is an insertion */
2678  tl = get_text_length(es);
2679  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));
2680  for (p = es->text + tl ; p >= es->text + s ; p--)
2681  p[strl] = p[0];
2682  for (i = 0 , p = es->text + s ; i < strl ; i++)
2683  p[i] = lpsz_replace[i];
2684  if(es->style & ES_UPPERCASE)
2685  CharUpperBuffW(p, strl);
2686  else if(es->style & ES_LOWERCASE)
2687  CharLowerBuffW(p, strl);
2689  }
2690  if (es->style & ES_MULTILINE)
2691  {
2692  INT st = min(es->selection_start, es->selection_end);
2694 
2695  hrgn = CreateRectRgn(0, 0, 0, 0);
2696  EDIT_BuildLineDefs_ML(es, st, st + strl,
2697  strl - abs(es->selection_end - es->selection_start), hrgn);
2698  /* if text is too long undo all changes */
2699  if (honor_limit && !(es->style & ES_AUTOVSCROLL) && (es->line_count > vlc)) {
2700  if (strl)
2701  strcpyW(es->text + e, es->text + e + strl);
2702  if (e != s)
2703  for (i = 0 , p = es->text ; i < e - s ; i++)
2704  p[i + s] = buf[i];
2707  abs(es->selection_end - es->selection_start) - strl, hrgn);
2708  strl = 0;
2709  e = s;
2710  hrgn = CreateRectRgn(0, 0, 0, 0);
2712  }
2713  }
2714  else {
2715  INT fw = es->format_rect.right - es->format_rect.left;
2718  /* remove chars that don't fit */
2719  if (honor_limit && !(es->style & ES_AUTOHSCROLL) && (es->text_width > fw)) {
2720  while ((es->text_width > fw) && s + strl >= s) {
2721  strcpyW(es->text + s + strl - 1, es->text + s + strl);
2722  strl--;
2723  es->text_length = -1;
2726  }
2729  }
2730  }
2731 
2732  if (e != s) {
2733  if (can_undo) {
2734  utl = strlenW(es->undo_text);
2735  if (!es->undo_insert_count && (*es->undo_text && (s == es->undo_position))) {
2736  /* undo-buffer is extended to the right */
2737  EDIT_MakeUndoFit(es, utl + e - s);
2738  memcpy(es->undo_text + utl, buf, (e - s)*sizeof(WCHAR));
2739  (es->undo_text + utl)[e - s] = 0; /* ensure 0 termination */
2740  } else if (!es->undo_insert_count && (*es->undo_text && (e == es->undo_position))) {
2741  /* undo-buffer is extended to the left */
2742  EDIT_MakeUndoFit(es, utl + e - s);
2743  for (p = es->undo_text + utl ; p >= es->undo_text ; p--)
2744  p[e - s] = p[0];
2745  for (i = 0 , p = es->undo_text ; i < e - s ; i++)
2746  p[i] = buf[i];
2747  es->undo_position = s;
2748  } else {
2749  /* new undo-buffer */
2750  EDIT_MakeUndoFit(es, e - s);
2751  memcpy(es->undo_text, buf, (e - s)*sizeof(WCHAR));
2752  es->undo_text[e - s] = 0; /* ensure 0 termination */
2753  es->undo_position = s;
2754  }
2755  /* any deletion makes the old insertion-undo invalid */
2756  es->undo_insert_count = 0;
2757  } else
2759  }
2760  if (strl) {
2761  if (can_undo) {
2762  if ((s == es->undo_position) ||
2763  ((es->undo_insert_count) &&
2764  (s == es->undo_position + es->undo_insert_count)))
2765  /*
2766  * insertion is new and at delete position or
2767  * an extension to either left or right
2768  */
2769  es->undo_insert_count += strl;
2770  else {
2771  /* new insertion undo */
2772  es->undo_position = s;
2773  es->undo_insert_count = strl;
2774  /* new insertion makes old delete-buffer invalid */
2775  *es->undo_text = '\0';
2776  }
2777  } else
2779  }
2780 
2781  HeapFree(GetProcessHeap(), 0, buf);
2782 
2783  s += strl;
2784 
2785  /* If text has been deleted and we're right or center aligned then scroll rightward */
2786  if (es->style & (ES_RIGHT | ES_CENTER))
2787  {
2788  INT delta = strl - abs(es->selection_end - es->selection_start);
2789 
2790  if (delta < 0 && es->x_offset)
2791  {
2792  if (abs(delta) > es->x_offset)
2793  es->x_offset = 0;
2794  else
2795  es->x_offset += delta;
2796  }
2797  }
2798 
2799  EDIT_EM_SetSel(es, s, s, FALSE);
2800  es->flags |= EF_MODIFIED;
2801  if (send_update) es->flags |= EF_UPDATE;
2802  if (hrgn)
2803  {
2805  DeleteObject(hrgn);
2806  }
2807  else
2809 
2811 
2812  /* force scroll info update */
2814 
2815 
2816  if(send_update || (es->flags & EF_UPDATE))
2817  {
2818  es->flags &= ~EF_UPDATE;
2820  }
2822 }
#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:1640
#define EN_MAXTEXT
Definition: winuser.h:2013
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define TRUE
Definition: types.h:120
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1510
#define ES_MULTILINE
Definition: pedump.c:667
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
static void text_buffer_changed(EDITSTATE *es)
Definition: edit.c:1280
int32_t INT
Definition: typedefs.h:58
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:255
#define FALSE
Definition: types.h:117
#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
#define EDIT_NOTIFY_PARENT(es, wNotifyCode)
Definition: edit.c:162
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
static void EDIT_CalcLineWidth_SL(EDITSTATE *es)
Definition: edit.c:847
#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:595
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:1495
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:190
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:1883
#define ORDER_UINT(x, y)
Definition: edit.c:159
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
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
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:381
static BOOL EDIT_MakeUndoFit(EDITSTATE *es, UINT size)
Definition: edit.c:1468
#define EF_UPDATE
Definition: edit.c:68
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1706
#define EF_MODIFIED
Definition: edit.c:66
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:510
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:495
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define ES_AUTOHSCROLL
Definition: pedump.c:672
#define HeapFree(x, y, z)
Definition: compat.h:594
static BOOL EDIT_MakeFit(EDITSTATE *es, UINT size)
Definition: edit.c:1427
#define es
Definition: i386-dis.c:433
#define ES_LOWERCASE
Definition: pedump.c:669
#define EN_CHANGE
Definition: winuser.h:2009

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

1819 {
1820  INT dy;
1821 
1822  if (!(es->style & ES_MULTILINE))
1823  return (LRESULT)FALSE;
1824 
1825  dy = 0;
1826 
1827  switch (action) {
1828  case SB_LINEUP:
1829  if (es->y_offset)
1830  dy = -1;
1831  break;
1832  case SB_LINEDOWN:
1833  if (es->y_offset < es->line_count - 1)
1834  dy = 1;
1835  break;
1836  case SB_PAGEUP:
1837  if (es->y_offset)
1838  dy = -(es->format_rect.bottom - es->format_rect.top) / es->line_height;
1839  break;
1840  case SB_PAGEDOWN:
1841  if (es->y_offset < es->line_count - 1)
1842  dy = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
1843  break;
1844  default:
1845  return (LRESULT)FALSE;
1846  }
1847  if (dy) {
1849  /* check if we are going to move too far */
1850  if(es->y_offset + dy > es->line_count - vlc)
1851  dy = max(es->line_count - vlc, 0) - es->y_offset;
1852 
1853  /* Notification is done in EDIT_EM_LineScroll */
1854  if(dy) {
1855  EDIT_EM_LineScroll(es, 0, dy);
1856  return MAKELONG(dy, TRUE);
1857  }
1858 
1859  }
1860  return (LRESULT)FALSE;
1861 }
#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
if(dx==0 &&dy==0)
Definition: linetemp.h:174
int32_t INT
Definition: typedefs.h:58
static BOOL EDIT_EM_LineScroll(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1803
#define FALSE
Definition: types.h:117
#define MAKELONG(a, b)
Definition: typedefs.h:249
const WCHAR * action
Definition: action.c:7479
#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:495
LONG_PTR LRESULT
Definition: windef.h:209
#define es
Definition: i386-dis.c:433

Referenced by EDIT_WM_VScroll(), and EditWndProc_common().

◆ EDIT_EM_ScrollCaret()

static void EDIT_EM_ScrollCaret ( EDITSTATE es)
static

Definition at line 1883 of file edit.c.

1884 {
1885  if (es->style & ES_MULTILINE) {
1886  INT l;
1887  INT vlc;
1888  INT ww;
1889  INT cw = es->char_width;
1890  INT x;
1891  INT dy = 0;
1892  INT dx = 0;
1893 
1894  l = EDIT_EM_LineFromChar(es, es->selection_end);
1895  x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP));
1896  vlc = get_vertical_line_count(es);
1897  if (l >= es->y_offset + vlc)
1898  dy = l - vlc + 1 - es->y_offset;
1899  if (l < es->y_offset)
1900  dy = l - es->y_offset;
1901  ww = es->format_rect.right - es->format_rect.left;
1902  if (x < es->format_rect.left)
1903  dx = x - es->format_rect.left - ww / HSCROLL_FRACTION / cw * cw;
1904  if (x > es->format_rect.right)
1905  dx = x - es->format_rect.left - (HSCROLL_FRACTION - 1) * ww / HSCROLL_FRACTION / cw * cw;
1906  if (dy || dx || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1907  {
1908  /* check if we are going to move too far */
1909  if(es->x_offset + dx + ww > es->text_width)
1910  dx = es->text_width - ww - es->x_offset;
1911  if(dx || dy || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1913  }
1914  } else {
1915  INT x;
1916  INT goal;
1917  INT format_width;
1918 
1919  x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1920  format_width = es->format_rect.right - es->format_rect.left;
1921  if (x < es->format_rect.left) {
1922  goal = es->format_rect.left + format_width / HSCROLL_FRACTION;
1923  do {
1924  es->x_offset--;
1925  x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1926  } while ((x < goal) && es->x_offset);
1927  /* FIXME: use ScrollWindow() somehow to improve performance */
1929  } else if (x > es->format_rect.right) {
1930  INT x_last;
1932  goal = es->format_rect.right - format_width / HSCROLL_FRACTION;
1933  do {
1934  es->x_offset++;
1935  x = (short)LOWORD(EDIT_EM_PosFromChar(es, es->selection_end, FALSE));
1936  x_last = (short)LOWORD(EDIT_EM_PosFromChar(es, len, FALSE));
1937  } while ((x > goal) && (x_last > es->format_rect.right));
1938  /* FIXME: use ScrollWindow() somehow to improve performance */
1940  }
1941  }
1942 
1943  if(es->flags & EF_FOCUSED)
1944  EDIT_SetCaretPos(es, es->selection_end, es->flags & EF_AFTER_WRAP);
1945 }
static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1747
static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap)
Definition: edit.c:1869
#define TRUE
Definition: types.h:120
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1510
GLint dy
Definition: linetemp.h:97
#define ES_MULTILINE
Definition: pedump.c:667
#define EF_FOCUSED
Definition: edit.c:67
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:58
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:255
#define FALSE
Definition: types.h:117
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:999
#define EF_AFTER_WRAP
Definition: edit.c:71
#define NULL
Definition: types.h:112
GLint dx
Definition: linetemp.h:97
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:495
#define HSCROLL_FRACTION
Definition: edit.c:61
#define LOWORD(l)
Definition: pedump.c:82
#define es
Definition: i386-dis.c:433
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1099

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

2833 {
2834  if (!(es->style & ES_MULTILINE))
2835  return;
2836 
2837  if (!hloc) {
2838  WARN("called with NULL handle\n");
2839  return;
2840  }
2841 
2843 
2844  if(es->is_unicode)
2845  {
2846  if(es->hloc32A)
2847  {
2848  LocalFree(es->hloc32A);
2849  es->hloc32A = NULL;
2850  }
2851  es->hloc32W = hloc;
2852  }
2853  else
2854  {
2855  INT countW, countA;
2856  HLOCAL hloc32W_new;
2857  WCHAR *textW;
2858  CHAR *textA;
2859 
2860  countA = LocalSize(hloc);
2861  textA = LocalLock(hloc);
2862  countW = MultiByteToWideChar(CP_ACP, 0, textA, countA, NULL, 0);
2863  if(!(hloc32W_new = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, countW * sizeof(WCHAR))))
2864  {
2865  ERR("Could not allocate new unicode buffer\n");
2866  return;
2867  }
2868  textW = LocalLock(hloc32W_new);
2869  MultiByteToWideChar(CP_ACP, 0, textA, countA, textW, countW);
2870  LocalUnlock(hloc32W_new);
2871  LocalUnlock(hloc);
2872 
2873  if(es->hloc32W)
2874  LocalFree(es->hloc32W);
2875 
2876  es->hloc32W = hloc32W_new;
2877  es->hloc32A = hloc;
2878  }
2879 
2880  es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1;
2881 
2882  /* The text buffer handle belongs to the control */
2883  es->hlocapp = NULL;
2884 
2887 
2888  es->x_offset = es->y_offset = 0;
2889  es->selection_start = es->selection_end = 0;
2891  es->flags &= ~EF_MODIFIED;
2892  es->flags &= ~EF_UPDATE;
2896  /* force scroll info update */
2898 }
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1788
#define TRUE
Definition: types.h:120
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1510
#define CP_ACP
Definition: compat.h:109
char CHAR
Definition: xmlstorage.h:175
#define WARN(fmt,...)
Definition: debug.h:112
#define ES_MULTILINE
Definition: pedump.c:667
static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
Definition: edit.c:1358
static void text_buffer_changed(EDITSTATE *es)
Definition: edit.c:1280
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777
int32_t INT
Definition: typedefs.h:58
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:255
static void EDIT_LockBuffer(EDITSTATE *es)
Definition: edit.c:1293
#define LMEM_ZEROINIT
Definition: winbase.h:372
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const char textA[]
Definition: registrar.c:40
#define LMEM_MOVEABLE
Definition: winbase.h:366
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:190
static const WCHAR textW[]
Definition: itemdlg.c:1559
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1883
#define ERR(fmt,...)
Definition: debug.h:110
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1599
#define EF_UPDATE
Definition: edit.c:68
#define NULL
Definition: types.h:112
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1706
#define EF_MODIFIED
Definition: edit.c:66
#define MultiByteToWideChar
Definition: compat.h:110
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:510
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
#define es
Definition: i386-dis.c:433

Referenced by EditWndProc_common().

◆ EDIT_EM_SetLimitText()

static void EDIT_EM_SetLimitText ( EDITSTATE es,
UINT  limit 
)
static

Definition at line 2908 of file edit.c.

2909 {
2910  if (!limit) limit = ~0u;
2911  if (!(es->style & ES_MULTILINE)) limit = min(limit, 0x7ffffffe);
2912  es->buffer_limit = limit;
2913 }
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:433

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

2946 {
2947  TEXTMETRICW tm;
2948  INT default_left_margin = 0; /* in pixels */
2949  INT default_right_margin = 0; /* in pixels */
2950 
2951  /* Set the default margins depending on the font */
2952  if (es->font && (left == EC_USEFONTINFO || right == EC_USEFONTINFO)) {
2953  HDC dc = GetDC(es->hwndSelf);
2954  HFONT old_font = SelectObject(dc, es->font);
2956  RECT rc;
2957 
2958  /* The default margins are only non zero for TrueType or Vector fonts */
2959  if (tm.tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE )) {
2960  if (!is_cjk(tm.tmCharSet)) {
2961  default_left_margin = width / 2;
2962  default_right_margin = width / 2;
2963 
2964  GetClientRect(es->hwndSelf, &rc);
2965  if (rc.right - rc.left < (width / 2 + width) * 2 &&
2966  (width >= 28 || !IsRectEmpty(&rc)) ) {
2967  default_left_margin = es->left_margin;
2968  default_right_margin = es->right_margin;
2969  }
2970  } else {
2971  /* FIXME: figure out the CJK values. They are not affected by the client rect. */
2972  default_left_margin = width / 2;
2973  default_right_margin = width / 2;
2974  }
2975  }
2976  SelectObject(dc, old_font);
2977  ReleaseDC(es->hwndSelf, dc);
2978  }
2979 
2980  if (action & EC_LEFTMARGIN) {
2981  es->format_rect.left -= es->left_margin;
2982  if (left != EC_USEFONTINFO)
2983  es->left_margin = left;
2984  else
2985  es->left_margin = default_left_margin;
2986  es->format_rect.left += es->left_margin;
2987  }
2988 
2989  if (action & EC_RIGHTMARGIN) {
2990  es->format_rect.right += es->right_margin;
2991  if (right != EC_USEFONTINFO)
2992  es->right_margin = right;
2993  else
2994  es->right_margin = default_right_margin;
2995  es->format_rect.right -= es->right_margin;
2996  }
2997 
2998  if (action & (EC_LEFTMARGIN | EC_RIGHTMARGIN)) {
3000  if (repaint) EDIT_UpdateText(es, NULL, TRUE);
3001  }
3002 
3003  TRACE("left=%d, right=%d\n", es->left_margin, es->right_margin);
3004 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define EC_RIGHTMARGIN
Definition: winuser.h:2587
HDC WINAPI GetDC(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1510
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:58
long LONG
Definition: pedump.c:60
#define TMPF_TRUETYPE
Definition: wingdi.h:1313
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
static void EDIT_AdjustFormatRect(EDITSTATE *es)
Definition: edit.c:2358
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
#define EC_LEFTMARGIN
Definition: winuser.h:2586
#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:2929
Definition: time.h:68
#define TMPF_VECTOR
Definition: wingdi.h:1312
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *)
Definition: font.c:2145
const WCHAR * action
Definition: action.c:7479
#define NULL
Definition: types.h:112
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static const WCHAR dc[]
#define EC_USEFONTINFO
Definition: winuser.h:2588
#define es
Definition: i386-dis.c:433

Referenced by EDIT_WM_SetFont().

◆ EDIT_EM_SetPasswordChar()

static void EDIT_EM_SetPasswordChar ( EDITSTATE es,
WCHAR  c 
)
static

Definition at line 3012 of file edit.c.

3013 {
3014  LONG style;
3015 
3016  if (es->style & ES_MULTILINE)
3017  return;
3018 
3019  if (es->password_char == c)
3020  return;
3021 
3022  style = GetWindowLongW( es->hwndSelf, GWL_STYLE );
3023  es->password_char = c;
3024  if (c) {
3025  SetWindowLongW( es->hwndSelf, GWL_STYLE, style | ES_PASSWORD );
3026  es->style |= ES_PASSWORD;
3027  } else {
3028  SetWindowLongW( es->hwndSelf, GWL_STYLE, style & ~ES_PASSWORD );
3029  es->style &= ~ES_PASSWORD;
3030  }
3033 }
#define TRUE
Definition: types.h:120
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1510
#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)
const GLubyte * c
Definition: glext.h:8905
#define GWL_STYLE
Definition: winuser.h:846
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:381
#define NULL
Definition: types.h:112
#define c
Definition: ke_i.h:80
Arabic default style
Definition: afstyles.h:93
#define es
Definition: i386-dis.c:433

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

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

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

3042 {
3043  if (!(es->style & ES_MULTILINE))
3044  return FALSE;
3045  HeapFree(GetProcessHeap(), 0, es->tabs);
3046  es->tabs_count = count;
3047  if (!count)
3048  es->tabs = NULL;
3049  else {
3050  es->tabs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(INT));
3051 #ifdef __REACTOS__
3052  /* ReactOS r33503 */
3053  if (es->tabs == NULL)
3054  {
3055  es->tabs_count = 0;
3056  return FALSE;
3057  }
3058 #endif
3059  memcpy(es->tabs, tabs, count * sizeof(INT));
3060  }
3062  return TRUE;
3063 }
#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:58
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:595
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:381
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
#define es
Definition: i386-dis.c:433

Referenced by EditWndProc_common().

◆ EDIT_EM_SetWordBreakProc()

static void EDIT_EM_SetWordBreakProc ( EDITSTATE es,
void wbp 
)
static

Definition at line 3071 of file edit.c.

3072 {
3073  if (es->word_break_proc == wbp)
3074  return;
3075 
3076  es->word_break_proc = wbp;
3077 
3078  if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
3081  }
3082 }
#define TRUE
Definition: types.h:120
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1510
#define ES_MULTILINE
Definition: pedump.c:667
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:255
#define NULL
Definition: types.h:112
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:510
#define ES_AUTOHSCROLL
Definition: pedump.c:672
#define es
Definition: i386-dis.c:433

Referenced by EditWndProc_common().

◆ EDIT_EM_Undo()

static BOOL EDIT_EM_Undo ( EDITSTATE es)
static

Definition at line 3090 of file edit.c.

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

Referenced by EDIT_WM_SysKeyDown(), and EditWndProc_common().

◆ EDIT_GetCompositionStr()

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

Definition at line 4408 of file edit.c.

4409 {
4410  LONG buflen;
4411  LPWSTR lpCompStr;
4412  LPSTR lpCompStrAttr = NULL;
4413  DWORD dwBufLenAttr;
4414 
4415  buflen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
4416 
4417  if (buflen < 0)
4418  {
4419  return;
4420  }
4421 
4422  lpCompStr = HeapAlloc(GetProcessHeap(),0,buflen + sizeof(WCHAR));
4423  if (!lpCompStr)
4424  {
4425  ERR("Unable to allocate IME CompositionString\n");
4426  return;
4427  }
4428 
4429  if (buflen)
4430  ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, buflen);
4431  lpCompStr[buflen/sizeof(WCHAR)] = 0;
4432 
4433  if (CompFlag & GCS_COMPATTR)
4434  {
4435  /*
4436  * We do not use the attributes yet. it would tell us what characters
4437  * are in transition and which are converted or decided upon
4438  */
4439  dwBufLenAttr = ImmGetCompositionStringW(hIMC, GCS_COMPATTR, NULL, 0);
4440  if (dwBufLenAttr)
4441  {
4442  dwBufLenAttr ++;
4443  lpCompStrAttr = HeapAlloc(GetProcessHeap(),0,dwBufLenAttr+1);
4444  if (!lpCompStrAttr)
4445  {
4446  ERR("Unable to allocate IME Attribute String\n");
4447  HeapFree(GetProcessHeap(),0,lpCompStr);
4448  return;
4449  }
4450  ImmGetCompositionStringW(hIMC,GCS_COMPATTR, lpCompStrAttr,
4451  dwBufLenAttr);
4452  lpCompStrAttr[dwBufLenAttr] = 0;
4453  }
4454  }
4455 
4456  /* check for change in composition start */
4457  if (es->selection_end < es->composition_start)
4458  es->composition_start = es->selection_end;
4459 
4460  /* replace existing selection string */
4461  es->selection_start = es->composition_start;
4462 
4463  if (es->composition_len > 0)
4464  es->selection_end = es->composition_start + es->composition_len;
4465  else
4466  es->selection_end = es->selection_start;
4467 
4468  EDIT_EM_ReplaceSel(es, FALSE, lpCompStr, TRUE, TRUE);
4469  es->composition_len = abs(es->composition_start - es->selection_end);
4470 
4471  es->selection_start = es->composition_start;
4472  es->selection_end = es->selection_start + es->composition_len;
4473 
4474  HeapFree(GetProcessHeap(),0,lpCompStrAttr);
4475  HeapFree(GetProcessHeap(),0,lpCompStr);
4476 }
#define abs(i)
Definition: fconv.c:206
#define TRUE
Definition: types.h:120
char * LPSTR
Definition: xmlstorage.h:182
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define GCS_COMPATTR
Definition: imm.h:368
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2620
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:892
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define GCS_COMPSTR
Definition: imm.h:367
#define HeapFree(x, y, z)
Definition: compat.h:594
#define es
Definition: i386-dis.c:433

Referenced by EDIT_ImeComposition().

◆ EDIT_GetLineRect()

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

Definition at line 1229 of file edit.c.

1230 {
1232  INT line_index = 0;
1233  INT pt1, pt2, pt3;
1234 
1235  if (es->style & ES_MULTILINE)
1236  {
1237  const LINEDEF *line_def = NULL;
1238  rc->top = es->format_rect.top + (line - es->y_offset) * es->line_height;
1239  if (line >= es->line_count)
1240  return;
1241 
1242  line_def = es->first_line_def;
1243  if (line == -1) {
1244  INT index = es->selection_end - line_def->length;
1245  while ((index >= 0) && line_def->next) {
1246  line_index += line_def->length;
1247  line_def = line_def->next;
1248  index -= line_def->length;
1249  }
1250  } else {
1251  while (line > 0) {
1252  line_index += line_def->length;
1253  line_def = line_def->next;
1254  line--;
1255  }
1256  }
1257  ssa = line_def->ssa;
1258  }
1259  else
1260  {
1261  line_index = 0;
1262  rc->top = es->format_rect.top;
1263  ssa = es->ssa;
1264  }
1265 
1266  rc->bottom = rc->top + es->line_height;
1267  pt1 = (scol == 0) ? es->format_rect.left : (short)LOWORD(EDIT_EM_PosFromChar(es, line_index + scol, TRUE));
1268  pt2 = (ecol == -1) ? es->format_rect.right : (short)LOWORD(EDIT_EM_PosFromChar(es, line_index + ecol, TRUE));
1269  if (ssa)
1270  {
1271  ScriptStringCPtoX(ssa, scol, FALSE, &pt3);
1272  pt3+=es->format_rect.left;
1273  }
1274  else pt3 = pt1;
1275  rc->right = max(max(pt1 , pt2),pt3);
1276  rc->left = min(min(pt1, pt2),pt3);
1277 }
#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:307
LONG left
Definition: windef.h:306
if(dx==0 &&dy==0)
Definition: linetemp.h:174
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
Definition: parser.c:48
GLuint index
Definition: glext.h:6031
struct tagLINEDEF * next
Definition: edit.c:94
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
LONG bottom
Definition: windef.h:309
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int *pX)
Definition: usp10.c:2411
#define LOWORD(l)
Definition: pedump.c:82
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:93
INT length
Definition: edit.c:88
#define es
Definition: i386-dis.c:433
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1099

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

4479 {
4480  LONG buflen;
4481  LPWSTR lpResultStr;
4482 
4483  buflen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
4484  if (buflen <= 0)
4485  {
4486  return;
4487  }
4488 
4489  lpResultStr = HeapAlloc(GetProcessHeap(),0, buflen+sizeof(WCHAR));
4490  if (!lpResultStr)
4491  {
4492  ERR("Unable to alloc buffer for IME string\n");
4493  return;
4494  }
4495 
4496  ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpResultStr, buflen);
4497  lpResultStr[buflen/sizeof(WCHAR)] = 0;
4498 
4499  /* check for change in composition start */
4500  if (es->selection_end < es->composition_start)
4501  es->composition_start = es->selection_end;
4502 
4503  es->selection_start = es->composition_start;
4504  es->selection_end = es->composition_start + es->composition_len;
4505  EDIT_EM_ReplaceSel(es, TRUE, lpResultStr, TRUE, TRUE);
4506  es->composition_start = es->selection_end;
4507  es->composition_len = 0;
4508 
4509  HeapFree(GetProcessHeap(),0,lpResultStr);
4510 }
#define TRUE
Definition: types.h:120
long LONG
Definition: pedump.c:60
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2620
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:892
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
#define GCS_RESULTSTR
Definition: imm.h:374
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:594
#define es
Definition: i386-dis.c:433

Referenced by EDIT_ImeComposition().

◆ EDIT_ImeComposition()

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

Definition at line 4512 of file edit.c.

4513 {
4514  HIMC hIMC;
4515  int cursor;
4516 
4517  if (es->composition_len == 0 && es->selection_start != es->selection_end)
4518  {
4520  es->composition_start = es->selection_end;
4521  }
4522 
4523  hIMC = ImmGetContext(hwnd);
4524  if (!hIMC)
4525  return;
4526 
4527  if (CompFlag & GCS_RESULTSTR)
4528  {
4529  EDIT_GetResultStr(hIMC, es);
4530  cursor = 0;
4531  }
4532  else
4533  {
4534  if (CompFlag & GCS_COMPSTR)
4535  EDIT_GetCompositionStr(hIMC, CompFlag, es);
4537  }
4538  ImmReleaseContext(hwnd, hIMC);
4539  EDIT_SetCaretPos(es, es->selection_start + cursor, es->flags & EF_AFTER_WRAP);
4540 }
static void EDIT_GetCompositionStr(HIMC hIMC, LPARAM CompFlag, EDITSTATE *es)
Definition: edit.c:4408
static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap)
Definition: edit.c:1869
#define TRUE
Definition: types.h:120
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:2620
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:892
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1010
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:1051
#define GCS_CURSORPOS
Definition: imm.h:370
const char cursor[]
Definition: icontest.c:13
#define EF_AFTER_WRAP
Definition: edit.c:71
#define GCS_RESULTSTR
Definition: imm.h:374
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
#define GCS_COMPSTR
Definition: imm.h:367
static const WCHAR empty_stringW[]
Definition: edit.c:171
static void EDIT_GetResultStr(HIMC hIMC, EDITSTATE *es)
Definition: edit.c:4478
#define es
Definition: i386-dis.c:433

◆ EDIT_InvalidateText()

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

Definition at line 1610 of file edit.c.

1611 {
1612  if (end == start)
1613  return;
1614 
1615  if (end == -1)
1616  end = get_text_length(es);
1617 
1618  if (end < start) {
1619  INT tmp = start;
1620  start = end;
1621  end = tmp;
1622  }
1623 
1624  if (es->style & ES_MULTILINE)
1626  else
1628 }
static void EDIT_SL_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1527
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:58
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:255
static void EDIT_ML_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1545
GLuint GLuint end
Definition: gl.h:1545
GLuint start
Definition: gl.h:1545
#define es
Definition: i386-dis.c:433

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

◆ EDIT_InvalidateUniscribeData()

static void EDIT_InvalidateUniscribeData ( EDITSTATE es)
inlinestatic

Definition at line 381 of file edit.c.

382 {
383  LINEDEF *line_def = es->first_line_def;
384  while (line_def)
385  {
387  line_def = line_def->next;
388  }
389  if (es->ssa)
390  {
391  ScriptStringFree(&es->ssa);
392  es->ssa = NULL;
393  }
394 }
HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:2556
struct tagLINEDEF * next
Definition: edit.c:94
static void EDIT_InvalidateUniscribeData_linedef(LINEDEF *line_def)
Definition: edit.c:372
#define NULL
Definition: types.h:112
#define es
Definition: i386-dis.c:433

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

373 {
374  if (line_def->ssa)
375  {
376  ScriptStringFree(&line_def->ssa);
377  line_def->ssa = NULL;
378  }
379 }
HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:2556
#define NULL
Definition: types.h:112
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 3136 of file edit.c.

3137 {
3138  return (es->flags & EF_DIALOGMODE);
3139 }
#define EF_DIALOGMODE
Definition: edit.c:74
#define es
Definition: i386-dis.c:433

Referenced by EDIT_WM_Char(), and EDIT_WM_KeyDown().

◆ EDIT_LockBuffer()

static void EDIT_LockBuffer ( EDITSTATE es)
static

Definition at line 1293 of file edit.c.

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

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

◆ EDIT_MakeFit()

static BOOL EDIT_MakeFit ( EDITSTATE es,
UINT  size 
)
static

Definition at line 1427 of file edit.c.

1428 {
1429  HLOCAL hNew32W;
1430 
1432  return TRUE;
1433 
1434  TRACE("trying to ReAlloc to %d+1 characters\n", size);
1435 
1436  /* Force edit to unlock its buffer. es->text now NULL */
1438 
1439  if (es->hloc32W) {
1440  UINT alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1441  if ((hNew32W = LocalReAlloc(es->hloc32W, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT))) {
1442  TRACE("Old 32 bit handle %p, new handle %p\n", es->hloc32W, hNew32W);
1443  es->hloc32W = hNew32W;
1444  es->buffer_size = LocalSize(hNew32W)/sizeof(WCHAR) - 1;
1445  }
1446  }
1447 
1449 
1450  if (es->buffer_size < size) {
1451  WARN("FAILED ! We now have %d+1\n", es->buffer_size);
1453  return FALSE;
1454  } else {
1455  TRACE("We now have %d+1\n", es->buffer_size);
1456  return TRUE;
1457  }
1458 }
#define ROUND_TO_GROW(size)
Definition: edit.c:60
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
Definition: edit.c:1358
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777
#define FALSE
Definition: types.h:117
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888
#define EN_ERRSPACE
Definition: winuser.h:2010
#define EDIT_NOTIFY_PARENT(es, wNotifyCode)
Definition: edit.c:162
#define TRACE(s)
Definition: solgame.cpp:4
static void EDIT_LockBuffer(EDITSTATE *es)
Definition: edit.c:1293
GLsizeiptr size
Definition: glext.h:5919
#define LMEM_ZEROINIT
Definition: winbase.h:372
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LMEM_MOVEABLE
Definition: winbase.h:366
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:433

Referenced by EDIT_EM_ReplaceSel().

◆ EDIT_MakeUndoFit()

static BOOL EDIT_MakeUndoFit ( EDITSTATE es,
UINT  size 
)
static

Definition at line 1468 of file edit.c.

1469 {
1470  UINT alloc_size;
1471 
1472  if (size <= es->undo_buffer_size)
1473  return TRUE;
1474 
1475  TRACE("trying to ReAlloc to %d+1\n", size);
1476 
1477  alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1478  if ((es->undo_text = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, es->undo_text, alloc_size))) {
1479  es->undo_buffer_size = alloc_size/sizeof(WCHAR) - 1;
1480  return TRUE;
1481  }
1482  else
1483  {
1484  WARN("FAILED ! We now have %d+1\n", es->undo_buffer_size);
1485  return FALSE;
1486  }
1487 }
#define ROUND_TO_GROW(size)
Definition: edit.c:60
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define HeapReAlloc
Definition: compat.h:593
unsigned int UINT
Definition: ndis.h:50
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define es
Definition: i386-dis.c:433

Referenced by EDIT_EM_ReplaceSel().

◆ EDIT_ML_InvalidateText()

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

Definition at line 1545 of file edit.c.

1546 {
1549  INT el = EDIT_EM_LineFromChar(es, end);
1550  INT sc;
1551  INT ec;
1552  RECT rc1;
1553  RECT rcWnd;
1554  RECT rcLine;
1555  RECT rcUpdate;
1556  INT l;
1557 
1558  if ((el < es->y_offset) || (sl > es->y_offset + vlc))
1559  return;
1560 
1561  sc = start - EDIT_EM_LineIndex(es, sl);
1562  ec = end - EDIT_EM_LineIndex(es, el);
1563  if (sl < es->y_offset) {
1564  sl = es->y_offset;
1565  sc = 0;
1566  }
1567  if (el > es->y_offset + vlc) {
1568  el = es->y_offset + vlc;
1570  }
1571  GetClientRect(es->hwndSelf, &rc1);
1572  IntersectRect(&rcWnd, &rc1, &es->format_rect);
1573  if (sl == el) {
1574  EDIT_GetLineRect(es, sl, sc, ec, &rcLine);
1575  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1576  EDIT_UpdateText(es, &rcUpdate, TRUE);
1577  } else {
1578  EDIT_GetLineRect(es, sl, sc,
1580  EDIT_EM_LineIndex(es, sl)),
1581  &rcLine);
1582  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1583  EDIT_UpdateText(es, &rcUpdate, TRUE);
1584  for (l = sl + 1 ; l < el ; l++) {
1585  EDIT_GetLineRect(es, l, 0,
1587  EDIT_EM_LineIndex(es, l)),
1588  &rcLine);
1589  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1590  EDIT_UpdateText(es, &rcUpdate, TRUE);
1591  }
1592  EDIT_GetLineRect(es, el, 0, ec, &rcLine);
1593  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1594  EDIT_UpdateText(es, &rcUpdate, TRUE);
1595  }
1596 }
static void EDIT_GetLineRect(EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc)
Definition: edit.c:1229
#define TRUE
Definition: types.h:120
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1510
int32_t INT
Definition: typedefs.h:58
r l[0]
Definition: byte_order.h:167
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:1063
GLuint GLuint end
Definition: gl.h:1545
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:999
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:1028
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:495
#define es
Definition: i386-dis.c:433

Referenced by EDIT_InvalidateText().

◆ EDIT_MoveBackward()

static void EDIT_MoveBackward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1953 of file edit.c.

1954 {
1955  INT e = es->selection_end;
1956 
1957  if (e) {
1958  e--;
1959  if ((es->style & ES_MULTILINE) && e &&
1960  (es->text[e - 1] == '\r') && (es->text[e] == '\n')) {
1961  e--;
1962  if (e && (es->text[e - 1] == '\r'))
1963  e--;
1964  }
1965  }
1966  EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);
1968 }
static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1640
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
#define e
Definition: ke_i.h:82
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1883
#define es
Definition: i386-dis.c:433

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

1981 {
1982  INT s = es->selection_start;
1983  INT e = es->selection_end;
1984  BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
1985  LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
1986  INT x = (short)LOWORD(pos);
1987  INT y = (short)HIWORD(pos);
1988 
1989  e = EDIT_CharFromPos(es, x, y + es->line_height, &after_wrap);
1990  if (!extend)
1991  s = e;
1992  EDIT_EM_SetSel(es, s, e, after_wrap);
1994 }
static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1640
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int32_t INT
Definition: typedefs.h:58
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
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:870
GLdouble s
Definition: gl.h:2039
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1883
#define EF_AFTER_WRAP
Definition: edit.c:71
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define HIWORD(l)
Definition: typedefs.h:247
LONG_PTR LRESULT
Definition: windef.h:209
#define LOWORD(l)
Definition: pedump.c:82
#define es
Definition: i386-dis.c:433
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1099

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

2003 {
2004  BOOL after_wrap = FALSE;
2005  INT e;
2006 
2007  /* Pass a high value in x to make sure of receiving the end of the line */
2008  if (!ctrl && (es->style & ES_MULTILINE))
2009  e = EDIT_CharFromPos(es, 0x3fffffff,
2010  HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap);
2011  else
2012  e = get_text_length(es);
2013  EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, after_wrap);
2015 }
static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1640
#define ES_MULTILINE
Definition: pedump.c:667
int32_t INT
Definition: typedefs.h:58
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:255
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define e
Definition: ke_i.h:82
#define ctrl
Definition: input.c:1757
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:870
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1883
#define EF_AFTER_WRAP
Definition: edit.c:71
#define HIWORD(l)
Definition: typedefs.h:247
#define es
Definition: i386-dis.c:433
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1099

Referenced by EDIT_WM_KeyDown().

◆ EDIT_MoveForward()

static void EDIT_MoveForward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 2023 of file edit.c.

2024 {
2025  INT e = es->selection_end;
2026 
2027  if (es->text[e]) {
2028  e++;
2029  if ((es->style & ES_MULTILINE) && (es->text[e - 1] == '\r')) {
2030  if (es->text[e] == '\n')
2031  e++;
2032  else if ((es->text[e] == '\r') && (es->text[e + 1] == '\n'))
2033