ReactOS  0.4.12-dev-18-gf469aca
edit.c File Reference
#include "config.h"
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "imm.h"
#include "usp10.h"
#include "commctrl.h"
#include "uxtheme.h"
#include "vsstyle.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/heap.h"
Include dependency graph for edit.c:

Go to the source code of this file.

Classes

struct  tagLINEDEF
 
struct  EDITSTATE
 

Macros

#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 ID_CB_LISTBOX   1000
 
#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)
 
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 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 BOOL 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)
 
static LRESULT EDIT_EM_GetSel (const EDITSTATE *es, PUINT start, PUINT end)
 
static void EDIT_EM_ReplaceSel (EDITSTATE *es, BOOL can_undo, const WCHAR *lpsz_replace, UINT strl, 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, EDITWORDBREAKPROCW 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)
 
static BOOL EDIT_CheckCombo (EDITSTATE *es, UINT msg, INT key)
 
static LRESULT EDIT_WM_KeyDown (EDITSTATE *es, INT key)
 
static LRESULT EDIT_WM_KillFocus (HTHEME theme, 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_NCPaint (HWND hwnd, HRGN region)
 
static void EDIT_WM_SetFocus (HTHEME theme, EDITSTATE *es)
 
static void EDIT_WM_SetFont (EDITSTATE *es, HFONT font, BOOL redraw)
 
static void EDIT_WM_SetText (EDITSTATE *es, LPCWSTR text)
 
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)
 
static LRESULT EDIT_WM_Create (EDITSTATE *es, const WCHAR *name)
 
static LRESULT EDIT_WM_NCDestroy (EDITSTATE *es)
 
static LRESULT CALLBACK EDIT_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
void EDIT_Register (void)
 

Macro Definition Documentation

◆ BUFLIMIT_INITIAL

#define BUFLIMIT_INITIAL   30000 /* initial buffer size */

Definition at line 58 of file edit.c.

Referenced by EDIT_WM_NCCreate().

◆ 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:3916
#define GetWindowLongPtrW
Definition: winuser.h:4698
LONG_PTR LPARAM
Definition: windef.h:208
#define WM_COMMAND
Definition: winuser.h:1716
#define es
Definition: i386-dis.c:431
#define GWLP_ID
Definition: winuser.h:854

Definition at line 161 of file edit.c.

Referenced by EDIT_EM_LineScroll_internal(), EDIT_EM_ReplaceSel(), EDIT_EM_Undo(), EDIT_MakeFit(), EDIT_UpdateText(), EDIT_UpdateTextRegion(), EDIT_WM_HScroll(), EDIT_WM_KeyDown(), EDIT_WM_KillFocus(), EDIT_WM_SetFocus(), EDIT_WM_SetText(), and EDIT_WM_VScroll().

◆ 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.

Referenced by EDIT_AdjustFormatRect(), EDIT_EM_ScrollCaret(), EDIT_EM_SetSel(), EDIT_ImeComposition(), EDIT_MoveDown_ML(), EDIT_MoveEnd(), EDIT_MoveHome(), EDIT_MovePageDown_ML(), EDIT_MovePageUp_ML(), EDIT_MoveUp_ML(), EDIT_WM_MouseMove(), EDIT_WM_SetFocus(), and EDIT_WM_SetFont().

◆ EF_DIALOGMODE

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

Definition at line 74 of file edit.c.

Referenced by EDIT_IsInsideDialog(), and EDIT_WindowProc().

◆ EF_FOCUSED

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

◆ 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.

Referenced by EDIT_EM_LineScroll_internal(), EDIT_UpdateScrollInfo(), and EDIT_WM_HScroll().

◆ EF_MODIFIED

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

Definition at line 66 of file edit.c.

Referenced by EDIT_EM_ReplaceSel(), EDIT_EM_SetHandle(), EDIT_WindowProc(), and EDIT_WM_SetText().

◆ EF_UPDATE

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

◆ EF_USE_SOFTBRK

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

Definition at line 73 of file edit.c.

Referenced by EDIT_EM_FmtLines().

◆ 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.

Referenced by EDIT_EM_LineScroll_internal(), EDIT_UpdateScrollInfo(), and EDIT_WM_VScroll().

◆ 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.

Referenced by EDIT_EM_ScrollCaret(), and EDIT_WM_HScroll().

◆ ID_CB_LISTBOX

#define ID_CB_LISTBOX   1000

Definition at line 76 of file edit.c.

Referenced by EDIT_WM_NCCreate().

◆ ORDER_UINT

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

Definition at line 158 of file edit.c.

Referenced by EDIT_EM_GetSel(), EDIT_EM_ReplaceSel(), EDIT_EM_SetSel(), and EDIT_WM_ContextMenu().

◆ ROUND_TO_GROW

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

Definition at line 60 of file edit.c.

Referenced by EDIT_MakeFit(), EDIT_MakeUndoFit(), and EDIT_WM_NCCreate().

◆ SWAP_UINT32

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

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

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

◆ EDIT_AdjustFormatRect()

static void EDIT_AdjustFormatRect ( EDITSTATE es)
static

Definition at line 2196 of file edit.c.

Referenced by EDIT_EM_SetMargins(), and EDIT_SetRectNP().

2197 {
2198  RECT ClientRect;
2199 
2201  if (es->style & ES_MULTILINE)
2202  {
2203  INT fw, vlc, max_x_offset, max_y_offset;
2204 
2205  vlc = get_vertical_line_count(es);
2206  es->format_rect.bottom = es->format_rect.top + vlc * es->line_height;
2207 
2208  /* correct es->x_offset */
2209  fw = es->format_rect.right - es->format_rect.left;
2210  max_x_offset = es->text_width - fw;
2211  if(max_x_offset < 0) max_x_offset = 0;
2212  if(es->x_offset > max_x_offset)
2213  es->x_offset = max_x_offset;
2214 
2215  /* correct es->y_offset */
2216  max_y_offset = es->line_count - vlc;
2217  if(max_y_offset < 0) max_y_offset = 0;
2218  if(es->y_offset > max_y_offset)
2219  es->y_offset = max_y_offset;
2220 
2221  /* force scroll info update */
2223  }
2224  else
2225  /* Windows doesn't care to fix text placement for SL controls */
2226  es->format_rect.bottom = es->format_rect.top + es->line_height;
2227 
2228  /* Always stay within the client area */
2229  GetClientRect(es->hwndSelf, &ClientRect);
2230  es->format_rect.bottom = min(es->format_rect.bottom, ClientRect.bottom);
2231 
2232  if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL))
2233  EDIT_BuildLineDefs_ML(es, 0, get_text_length(es), 0, NULL);
2234 
2236 }
#define max(a, b)
Definition: svc.c:63
INT line_height
Definition: edit.c:106
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1544
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:410
INT text_width
Definition: edit.c:120
#define ES_MULTILINE
Definition: pedump.c:667
INT line_count
Definition: edit.c:125
INT x_offset
Definition: edit.c:104
LONG top
Definition: windef.h:297
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:425
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
DWORD style
Definition: edit.c:108
static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap)
Definition: edit.c:1707
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
#define EF_AFTER_WRAP
Definition: edit.c:71
smooth NULL
Definition: ftsmooth.c:416
RECT format_rect
Definition: edit.c:119
INT y_offset
Definition: edit.c:126
INT char_width
Definition: edit.c:107
WORD flags
Definition: edit.c:109
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND hwndSelf
Definition: edit.c:129
#define min(a, b)
Definition: monoChain.cc:55
INT selection_end
Definition: edit.c:115
LONG bottom
Definition: windef.h:299
#define ES_AUTOHSCROLL
Definition: pedump.c:672

◆ EDIT_BuildLineDefs_ML()

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

Definition at line 425 of file edit.c.

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

426 {
427  LPWSTR current_position, cp;
428  INT fw;
429  LINEDEF *current_line;
430  LINEDEF *previous_line;
431  LINEDEF *start_line;
432  INT line_index = 0, nstart_line, nstart_index;
433  INT line_count = es->line_count;
434  INT orig_net_length;
435  RECT rc;
436  INT vlc;
437 
438  if (istart == iend && delta == 0)
439  return;
440 
441  previous_line = NULL;
442  current_line = es->first_line_def;
443 
444  /* Find starting line. istart must lie inside an existing line or
445  * at the end of buffer */
446  do {
447  if (istart < current_line->index + current_line->length ||
448  current_line->ending == END_0)
449  break;
450 
451  previous_line = current_line;
452  current_line = current_line->next;
453  line_index++;
454  } while (current_line);
455 
456  if (!current_line) /* Error occurred start is not inside previous buffer */
457  {
458  FIXME(" modification occurred outside buffer\n");
459  return;
460  }
461 
462  /* Remember start of modifications in order to calculate update region */
463  nstart_line = line_index;
464  nstart_index = current_line->index;
465 
466  /* We must start to reformat from the previous line since the modifications
467  * may have caused the line to wrap upwards. */
468  if (!(es->style & ES_AUTOHSCROLL) && line_index > 0)
469  {
470  line_index--;
471  current_line = previous_line;
472  }
473  start_line = current_line;
474 
475  fw = es->format_rect.right - es->format_rect.left;
476  current_position = es->text + current_line->index;
477  vlc = get_vertical_line_count(es);
478  do {
479  if (current_line != start_line)
480  {
481  if (!current_line || current_line->index + delta > current_position - es->text)
482  {
483  /* The buffer has been expanded, create a new line and
484  insert it into the link list */
485  LINEDEF *new_line = heap_alloc_zero(sizeof(*new_line));
486  new_line->next = previous_line->next;
487  previous_line->next = new_line;
488  current_line = new_line;
489  es->line_count++;
490  }
491  else if (current_line->index + delta < current_position - es->text)
492  {
493  /* The previous line merged with this line so we delete this extra entry */
494  previous_line->next = current_line->next;
495  heap_free(current_line);
496  current_line = previous_line->next;
497  es->line_count--;
498  continue;
499  }
500  else /* current_line->index + delta == current_position */
501  {
502  if (current_position - es->text > iend)
503  break; /* We reached end of line modifications */
504  /* else recalculate this line */
505  }
506  }
507 
508  current_line->index = current_position - es->text;
509  orig_net_length = current_line->net_length;
510 
511  /* Find end of line */
512  cp = current_position;
513  while (*cp) {
514  if (*cp == '\n') break;
515  if ((*cp == '\r') && (*(cp + 1) == '\n'))
516  break;
517  cp++;
518  }
519 
520  /* Mark type of line termination */
521  if (!(*cp)) {
522  current_line->ending = END_0;
523  current_line->net_length = strlenW(current_position);
524  } else if ((cp > current_position) && (*(cp - 1) == '\r')) {
525  current_line->ending = END_SOFT;
526  current_line->net_length = cp - current_position - 1;
527  } else if (*cp == '\n') {
528  current_line->ending = END_RICH;
529  current_line->net_length = cp - current_position;
530  } else {
531  current_line->ending = END_HARD;
532  current_line->net_length = cp - current_position;
533  }
534 
535  if (current_line->net_length)
536  {
537  const SIZE *sz;
539  EDIT_UpdateUniscribeData_linedef(es, NULL, current_line);
540  if (current_line->ssa)
541  {
542  sz = ScriptString_pSize(current_line->ssa);
543  /* Calculate line width */
544  current_line->width = sz->cx;
545  }
546  else current_line->width = es->char_width * current_line->net_length;
547  }
548  else current_line->width = 0;
549 
550  /* FIXME: check here for lines that are too wide even in AUTOHSCROLL (> 32767 ???) */
551 
552 /* Line breaks just look back from the end and find the next break and try that. */
553 
554  if (!(es->style & ES_AUTOHSCROLL)) {
555  if (current_line->width > fw && fw > es->char_width) {
556 
557  INT prev, next;
558  int w;
559  const SIZE *sz;
560  float d;
561 
562  prev = current_line->net_length - 1;
563  w = current_line->net_length;
564  d = (float)current_line->width/(float)fw;
565  if (d > 1.2f) d -= 0.2f;
566  next = prev/d;
567  if (next >= prev) next = prev-1;
568  do {
569  prev = EDIT_CallWordBreakProc(es, current_position - es->text,
570  next, current_line->net_length, WB_LEFT);
571  current_line->net_length = prev;
573  EDIT_UpdateUniscribeData_linedef(es, NULL, current_line);
574  if (current_line->ssa)
575  sz = ScriptString_pSize(current_line->ssa);
576  else sz = 0;
577  if (sz)
578  current_line->width = sz->cx;
579  else
580  prev = 0;
581  next = prev - 1;
582  } while (prev && current_line->width > fw);
583  current_line->net_length = w;
584 
585  if (prev == 0) { /* Didn't find a line break so force a break */
586  INT *piDx;
587  const INT *count;
588 
590  EDIT_UpdateUniscribeData_linedef(es, NULL, current_line);
591 
592  if (current_line->ssa)
593  {
594  count = ScriptString_pcOutChars(current_line->ssa);
595  piDx = heap_alloc(sizeof(INT) * (*count));
596  ScriptStringGetLogicalWidths(current_line->ssa,piDx);
597 
598  prev = current_line->net_length-1;
599  do {
600  current_line->width -= piDx[prev];
601  prev--;
602  } while ( prev > 0 && current_line->width > fw);
603  if (prev<=0)
604  prev = 1;
605  heap_free(piDx);
606  }
607  else
608  prev = (fw / es->char_width);
609  }
610 
611  /* If the first line we are calculating, wrapped before istart, we must
612  * adjust istart in order for this to be reflected in the update region. */
613  if (current_line->index == nstart_index && istart > current_line->index + prev)
614  istart = current_line->index + prev;
615  /* else if we are updating the previous line before the first line we
616  * are re-calculating and it expanded */
617  else if (current_line == start_line &&
618  current_line->index != nstart_index && orig_net_length < prev)
619  {
620  /* Line expanded due to an upwards line wrap so we must partially include
621  * previous line in update region */
622  nstart_line = line_index;
623  nstart_index = current_line->index;
624  istart = current_line->index + orig_net_length;
625  }
626 
627  current_line->net_length = prev;
628  current_line->ending = END_WRAP;
629 
630  if (current_line->net_length > 0)
631  {
632  EDIT_UpdateUniscribeData_linedef(es, NULL, current_line);
633  if (current_line->ssa)
634  {
635  sz = ScriptString_pSize(current_line->ssa);
636  current_line->width = sz->cx;
637  }
638  else
639  current_line->width = 0;
640  }
641  else current_line->width = 0;
642  }
643  else if (current_line == start_line &&
644  current_line->index != nstart_index &&
645  orig_net_length < current_line->net_length) {
646  /* The previous line expanded but it's still not as wide as the client rect */
647  /* The expansion is due to an upwards line wrap so we must partially include
648  it in the update region */
649  nstart_line = line_index;
650  nstart_index = current_line->index;
651  istart = current_line->index + orig_net_length;
652  }
653  }
654 
655 
656  /* Adjust length to include line termination */
657  switch (current_line->ending) {
658  case END_SOFT:
659  current_line->length = current_line->net_length + 3;
660  break;
661  case END_RICH:
662  current_line->length = current_line->net_length + 1;
663  break;
664  case END_HARD:
665  current_line->length = current_line->net_length + 2;
666  break;
667  case END_WRAP:
668  case END_0:
669  current_line->length = current_line->net_length;
670  break;
671  }
672  es->text_width = max(es->text_width, current_line->width);
673  current_position += current_line->length;
674  previous_line = current_line;
675 
676  /* Discard data for non-visible lines. It will be calculated as needed */
677  if ((line_index < es->y_offset) || (line_index > es->y_offset + vlc))
679 
680  current_line = current_line->next;
681  line_index++;
682  } while (previous_line->ending != END_0);
683 
684  /* Finish adjusting line indexes by delta or remove hanging lines */
685  if (previous_line->ending == END_0)
686  {
687  LINEDEF *pnext = NULL;
688 
689  previous_line->next = NULL;
690  while (current_line)
691  {
692  pnext = current_line->next;
694  heap_free(current_line);
695  current_line = pnext;
696  es->line_count--;
697  }
698  }
699  else if (delta != 0)
700  {
701  while (current_line)
702  {
703  current_line->index += delta;
704  current_line = current_line->next;
705  }
706  }
707 
708  /* Calculate rest of modification rectangle */
709  if (hrgn)
710  {
711  HRGN tmphrgn;
712  /*
713  * We calculate two rectangles. One for the first line which may have
714  * an indent with respect to the format rect. The other is a format-width
715  * rectangle that spans the rest of the lines that changed or moved.
716  */
717  rc.top = es->format_rect.top + nstart_line * es->line_height -
718  (es->y_offset * es->line_height); /* Adjust for vertical scrollbar */
719  rc.bottom = rc.top + es->line_height;
720  if ((es->style & ES_CENTER) || (es->style & ES_RIGHT))
721  rc.left = es->format_rect.left;
722  else
723  rc.left = LOWORD(EDIT_EM_PosFromChar(es, nstart_index, FALSE));
724  rc.right = es->format_rect.right;
725  SetRectRgn(hrgn, rc.left, rc.top, rc.right, rc.bottom);
726 
727  rc.top = rc.bottom;
728  rc.left = es->format_rect.left;
729  rc.right = es->format_rect.right;
730  /*
731  * If lines were added or removed we must re-paint the remainder of the
732  * lines since the remaining lines were either shifted up or down.
733  */
734  if (line_count < es->line_count) /* We added lines */
735  rc.bottom = es->line_count * es->line_height;
736  else if (line_count > es->line_count) /* We removed lines */
737  rc.bottom = line_count * es->line_height;
738  else
739  rc.bottom = line_index * es->line_height;
740  rc.bottom += es->format_rect.top;
741  rc.bottom -= (es->y_offset * es->line_height); /* Adjust for vertical scrollbar */
742  tmphrgn = CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);
743  CombineRgn(hrgn, hrgn, tmphrgn, RGN_OR);
744  DeleteObject(tmphrgn);
745  }
746 }
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
INT line_height
Definition: edit.c:106
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData_linedef(EDITSTATE *es, HDC dc, LINEDEF *line_def)
Definition: edit.c:326
Definition: edit.c:83
Definition: edit.c:80
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:410
LINEDEF * first_line_def
Definition: edit.c:141
const WCHAR * text
Definition: package.c:1827
INT text_width
Definition: edit.c:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
LINE_END ending
Definition: edit.c:90
#define HRGN
Definition: msvc.h:39
INT line_count
Definition: edit.c:125
Definition: edit.c:81
LONG top
Definition: windef.h:297
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
DWORD style
Definition: edit.c:108
static void EDIT_InvalidateUniscribeData_linedef(LINEDEF *line_def)
Definition: edit.c:302
LONG left
Definition: windef.h:296
Definition: edit.c:82
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
#define WB_LEFT
Definition: winuser.h:550
INT width
Definition: edit.c:91
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
static INT EDIT_CallWordBreakProc(EDITSTATE *es, INT start, INT index, INT count, INT action)
Definition: edit.c:290
INT net_length
Definition: edit.c:89
#define ES_RIGHT
Definition: pedump.c:666
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1005
#define RGN_OR
Definition: wingdi.h:357
LONG cx
Definition: windef.h:324
Definition: edit.c:84
GLuint index
Definition: glext.h:6031
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 d
Definition: ke_i.h:81
struct tagLINEDEF * next
Definition: edit.c:94
RECT format_rect
Definition: edit.c:119
INT y_offset
Definition: edit.c:126
HRESULT WINAPI ScriptStringGetLogicalWidths(SCRIPT_STRING_ANALYSIS ssa, int *piDx)
Definition: usp10.c:3795
INT char_width
Definition: edit.c:107
static HRGN hrgn
Definition: win.c:55
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3867
static unsigned __int64 next
Definition: rand_nt.c:6
POINT cp
Definition: magnifier.c:60
LONG bottom
Definition: windef.h:299
const int *WINAPI ScriptString_pcOutChars(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3928
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
LPWSTR text
Definition: edit.c:99
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:93
INT length
Definition: edit.c:88
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ EDIT_CalcLineWidth_SL()

static void EDIT_CalcLineWidth_SL ( EDITSTATE es)
static

Definition at line 753 of file edit.c.

Referenced by EDIT_EM_ReplaceSel(), and EDIT_WM_SetFont().

754 {
756  if (es->ssa)
757  {
758  const SIZE *size;
759  size = ScriptString_pSize(es->ssa);
760  es->text_width = size->cx;
761  }
762  else
763  es->text_width = 0;
764 }
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, INT line)
Definition: edit.c:368
INT text_width
Definition: edit.c:120
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:324
GLsizeiptr size
Definition: glext.h:5919
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:153
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3867

◆ EDIT_CallWordBreakProc()

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

Definition at line 290 of file edit.c.

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

291 {
292  INT ret;
293 
294  if (es->word_break_proc)
295  ret = es->word_break_proc(es->text + start, index, count, action);
296  else
297  ret = EDIT_WordBreakProc(es, es->text, index + start, count + start, action) - start;
298 
299  return ret;
300 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:56
GLuint index
Definition: glext.h:6031
int ret
EDITWORDBREAKPROCW word_break_proc
Definition: edit.c:124
const WCHAR * action
Definition: action.c:7779
static INT EDIT_WordBreakProc(EDITSTATE *es, LPWSTR s, INT index, INT count, INT action)
Definition: edit.c:232
GLuint start
Definition: gl.h:1545
LPWSTR text
Definition: edit.c:99

◆ EDIT_CharFromPos()

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

Definition at line 776 of file edit.c.

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().

777 {
778  INT index;
779 
780  if (es->style & ES_MULTILINE) {
781  int trailing;
782  INT line = (y - es->format_rect.top) / es->line_height + es->y_offset;
783  INT line_index = 0;
784  LINEDEF *line_def = es->first_line_def;
785  EDIT_UpdateUniscribeData(es, NULL, line);
786  while ((line > 0) && line_def->next) {
787  line_index += line_def->length;
788  line_def = line_def->next;
789  line--;
790  }
791 
792  x += es->x_offset - es->format_rect.left;
793  if (es->style & ES_RIGHT)
794  x -= (es->format_rect.right - es->format_rect.left) - line_def->width;
795  else if (es->style & ES_CENTER)
796  x -= ((es->format_rect.right - es->format_rect.left) - line_def->width) / 2;
797  if (x >= line_def->width) {
798  if (after_wrap)
799  *after_wrap = (line_def->ending == END_WRAP);
800  return line_index + line_def->net_length;
801  }
802  if (x <= 0 || !line_def->ssa) {
803  if (after_wrap)
804  *after_wrap = FALSE;
805  return line_index;
806  }
807 
808  ScriptStringXtoCP(line_def->ssa, x , &index, &trailing);
809  if (trailing) index++;
810  index += line_index;
811  if (after_wrap)
812  *after_wrap = ((index == line_index + line_def->net_length) &&
813  (line_def->ending == END_WRAP));
814  } else {
815  INT xoff = 0;
816  INT trailing;
817  if (after_wrap)
818  *after_wrap = FALSE;
819  x -= es->format_rect.left;
820  if (!x)
821  return es->x_offset;
822 
823  if (!es->x_offset)
824  {
825  INT indent = (es->format_rect.right - es->format_rect.left) - es->text_width;
826  if (es->style & ES_RIGHT)
827  x -= indent;
828  else if (es->style & ES_CENTER)
829  x -= indent / 2;
830  }
831 
833  if (es->x_offset)
834  {
835  if (es->ssa)
836  {
837  if (es->x_offset>= get_text_length(es))
838  {
839  const SIZE *size;
840  size = ScriptString_pSize(es->ssa);
841  xoff = size->cx;
842  }
843  ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
844  }
845  else
846  xoff = 0;
847  }
848  if (x < 0)
849  {
850  if (x + xoff > 0 || !es->ssa)
851  {
852  ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
853  if (trailing) index++;
854  }
855  else
856  index = 0;
857  }
858  else
859  {
860  if (x)
861  {
862  const SIZE *size = NULL;
863  if (es->ssa)
864  size = ScriptString_pSize(es->ssa);
865  if (!size)
866  index = 0;
867  else if (x > size->cx)
868  index = get_text_length(es);
869  else if (es->ssa)
870  {
871  ScriptStringXtoCP(es->ssa, x+xoff, &index, &trailing);
872  if (trailing) index++;
873  }
874  else
875  index = 0;
876  }
877  else
878  index = es->x_offset;
879  }
880  }
881  return index;
882 }
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, INT line)
Definition: edit.c:368
#define ES_CENTER
Definition: pedump.c:665
INT line_height
Definition: edit.c:106
static const WCHAR indent[]
Definition: object.c:1156
LINEDEF * first_line_def
Definition: edit.c:141
INT text_width
Definition: edit.c:120
#define ES_MULTILINE
Definition: pedump.c:667
HRESULT WINAPI ScriptStringXtoCP(SCRIPT_STRING_ANALYSIS ssa, int iX, int *piCh, int *piTrailing)
Definition: usp10.c:2472
Definition: edit.c:81
INT x_offset
Definition: edit.c:104
LONG top
Definition: windef.h:297
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
DWORD style
Definition: edit.c:108
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
INT INT y
Definition: msvc.h:62
#define ES_RIGHT
Definition: pedump.c:666
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:324
Definition: parser.c:48
GLsizeiptr size
Definition: glext.h:5919
if(!(yy_init))
Definition: macro.lex.yy.c:717
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:153
RECT format_rect
Definition: edit.c:119
INT y_offset
Definition: edit.c:126
#define index(s, c)
Definition: various.h:29
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3867
INT x
Definition: msvc.h:62
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int *pX)
Definition: usp10.c:2409

◆ EDIT_CheckCombo()

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

Definition at line 3185 of file edit.c.

Referenced by EDIT_WM_KeyDown(), and EDIT_WM_SysKeyDown().

3186 {
3187  HWND hLBox = es->hwndListBox;
3188  HWND hCombo;
3189  BOOL bDropped;
3190  int nEUI;
3191 
3192  if (!hLBox)
3193  return FALSE;
3194 
3195  hCombo = GetParent(es->hwndSelf);
3196  bDropped = TRUE;
3197  nEUI = 0;
3198 
3199  TRACE("[%p]: handling msg %x (%x)\n", es->hwndSelf, msg, key);
3200 
3201  if (key == VK_UP || key == VK_DOWN)
3202  {
3203  if (SendMessageW(hCombo, CB_GETEXTENDEDUI, 0, 0))
3204  nEUI = 1;
3205 
3206  if (msg == WM_KEYDOWN || nEUI)
3207  bDropped = (BOOL)SendMessageW(hCombo, CB_GETDROPPEDSTATE, 0, 0);
3208  }
3209 
3210  switch (msg)
3211  {
3212  case WM_KEYDOWN:
3213  if (!bDropped && nEUI && (key == VK_UP || key == VK_DOWN))
3214  {
3215  /* make sure ComboLBox pops up */
3216  SendMessageW(hCombo, CB_SETEXTENDEDUI, FALSE, 0);
3217  key = VK_F4;
3218  nEUI = 2;
3219  }
3220 
3221  SendMessageW(hLBox, WM_KEYDOWN, key, 0);
3222  break;
3223 
3224  case WM_SYSKEYDOWN: /* Handle Alt+up/down arrows */
3225  if (nEUI)
3226  SendMessageW(hCombo, CB_SHOWDROPDOWN, !bDropped, 0);
3227  else
3228  SendMessageW(hLBox, WM_KEYDOWN, VK_F4, 0);
3229  break;
3230  }
3231 
3232  if (nEUI == 2)
3233  SendMessageW(hCombo, CB_SETEXTENDEDUI, TRUE, 0);
3234 
3235  return TRUE;
3236 }
#define TRUE
Definition: types.h:120
#define CB_GETDROPPEDSTATE
Definition: winuser.h:1906
#define VK_DOWN
Definition: winuser.h:2181
#define VK_UP
Definition: winuser.h:2179
#define CB_SHOWDROPDOWN
Definition: winuser.h:1931
#define VK_F4
Definition: winuser.h:2212
UINT msg
Definition: msvc.h:92
#define WM_KEYDOWN
Definition: winuser.h:1691
HWND hwndListBox
Definition: edit.c:133
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
HWND WINAPI GetParent(_In_ HWND)
HWND hwndSelf
Definition: edit.c:129
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CB_SETEXTENDEDUI
Definition: winuser.h:1925
#define WM_SYSKEYDOWN
Definition: winuser.h:1695
#define CB_GETEXTENDEDUI
Definition: winuser.h:1909
#define BOOL
Definition: msvc.h:23
Definition: path.c:42

◆ EDIT_ConfinePoint()

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

Definition at line 893 of file edit.c.

Referenced by EDIT_WM_LButtonDown(), and EDIT_WM_MouseMove().

894 {
895  *x = min(max(*x, es->format_rect.left), es->format_rect.right - 1);
896  *y = min(max(*y, es->format_rect.top), es->format_rect.bottom - 1);
897 }
#define max(a, b)
Definition: svc.c:63
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
INT INT y
Definition: msvc.h:62
RECT format_rect
Definition: edit.c:119
INT x
Definition: msvc.h:62
#define min(a, b)
Definition: monoChain.cc:55
LONG bottom
Definition: windef.h:299

◆ EDIT_ContextMenuCommand()

static void EDIT_ContextMenuCommand ( EDITSTATE es,
UINT  id 
)
static

Definition at line 3071 of file edit.c.

Referenced by EDIT_WM_ContextMenu().

3072 {
3073  switch (id) {
3074  case EM_UNDO:
3075  SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
3076  break;
3077  case WM_CUT:
3078  SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
3079  break;
3080  case WM_COPY:
3081  SendMessageW(es->hwndSelf, WM_COPY, 0, 0);
3082  break;
3083  case WM_PASTE:
3084  SendMessageW(es->hwndSelf, WM_PASTE, 0, 0);
3085  break;
3086  case WM_CLEAR:
3087  SendMessageW(es->hwndSelf, WM_CLEAR, 0, 0);
3088  break;
3089  case EM_SETSEL:
3090  SendMessageW(es->hwndSelf, EM_SETSEL, 0, -1);
3091  break;
3092  default:
3093  ERR("unknown menu item, please report\n");
3094  break;
3095  }
3096 }
#define WM_CUT
Definition: winuser.h:1822
#define WM_PASTE
Definition: winuser.h:1824
#define WM_CLEAR
Definition: winuser.h:1825
#define WM_COPY
Definition: winuser.h:1823
#define EM_SETSEL
Definition: winuser.h:1979
#define EM_UNDO
Definition: winuser.h:1982
#define ERR(fmt,...)
Definition: debug.h:109
HWND hwndSelf
Definition: edit.c:129
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_UNDO
Definition: winuser.h:1826

◆ EDIT_EM_CanUndo()

static BOOL EDIT_EM_CanUndo ( const EDITSTATE es)
inlinestatic

Definition at line 177 of file edit.c.

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

178 {
179  return (es->undo_insert_count || strlenW(es->undo_text));
180 }
LPWSTR undo_text
Definition: edit.c:112
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
INT undo_insert_count
Definition: edit.c:110

◆ EDIT_EM_CharFromPos()

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

Definition at line 2291 of file edit.c.

Referenced by EDIT_WindowProc().

2292 {
2293  POINT pt;
2294  RECT rc;
2295  INT index;
2296 
2297  pt.x = x;
2298  pt.y = y;
2299  GetClientRect(es->hwndSelf, &rc);
2300  if (!PtInRect(&rc, pt))
2301  return -1;
2302 
2303  index = EDIT_CharFromPos(es, x, y, NULL);
2304  return MAKELONG(index, EDIT_EM_LineFromChar(es, index));
2305 }
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:905
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
int32_t INT
Definition: typedefs.h:56
INT INT y
Definition: msvc.h:62
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define index(s, c)
Definition: various.h:29
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND hwndSelf
Definition: edit.c:129
INT x
Definition: msvc.h:62
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:776
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)

◆ EDIT_EM_EmptyUndoBuffer()

static void EDIT_EM_EmptyUndoBuffer ( EDITSTATE es)
inlinestatic

Definition at line 188 of file edit.c.

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

189 {
190  es->undo_insert_count = 0;
191  *es->undo_text = '\0';
192 }
LPWSTR undo_text
Definition: edit.c:112
INT undo_insert_count
Definition: edit.c:110

◆ EDIT_EM_FmtLines()

static BOOL EDIT_EM_FmtLines ( EDITSTATE es,
BOOL  add_eol 
)
static

Definition at line 2319 of file edit.c.

Referenced by EDIT_WindowProc().

2320 {
2321  es->flags &= ~EF_USE_SOFTBRK;
2322  if (add_eol) {
2323  es->flags |= EF_USE_SOFTBRK;
2324  FIXME("soft break enabled, not implemented\n");
2325  }
2326  return add_eol;
2327 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define EF_USE_SOFTBRK
Definition: edit.c:73
WORD flags
Definition: edit.c:109

◆ EDIT_EM_GetHandle()

static HLOCAL EDIT_EM_GetHandle ( EDITSTATE es)
static

Definition at line 2341 of file edit.c.

Referenced by EDIT_WindowProc().

2342 {
2343  if (!(es->style & ES_MULTILINE))
2344  return 0;
2345 
2346  EDIT_UnlockBuffer(es, TRUE);
2347 
2348  /* The text buffer handle belongs to the app */
2349  es->hlocapp = es->hloc32W;
2350 
2351  TRACE("Returning %p, LocalSize() = %ld\n", es->hlocapp, LocalSize(es->hlocapp));
2352  return es->hlocapp;
2353 }
#define TRUE
Definition: types.h:120
#define ES_MULTILINE
Definition: pedump.c:667
DWORD style
Definition: edit.c:108
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777
static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
Definition: edit.c:1214
#define TRACE(s)
Definition: solgame.cpp:4
HLOCAL hloc32W
Definition: edit.c:142
HLOCAL hlocapp
Definition: edit.c:143

◆ EDIT_EM_GetLine()

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

Definition at line 2361 of file edit.c.

Referenced by EDIT_WindowProc().

2362 {
2363  INT line_len, dst_len;
2364  LPWSTR src;
2365  INT i;
2366 
2367  if (es->style & ES_MULTILINE)
2368  {
2369  if (line >= es->line_count)
2370  return 0;
2371  }
2372  else
2373  line = 0;
2374 
2375  i = EDIT_EM_LineIndex(es, line);
2376  src = es->text + i;
2377  line_len = EDIT_EM_LineLength(es, i);
2378  dst_len = *(WORD *)dst;
2379 
2380  if (dst_len <= line_len)
2381  {
2382  memcpy(dst, src, dst_len * sizeof(WCHAR));
2383  return dst_len;
2384  }
2385  else /* Append 0 if enough space */
2386  {
2387  memcpy(dst, src, line_len * sizeof(WCHAR));
2388  dst[line_len] = 0;
2389  return line_len;
2390  }
2391 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ES_MULTILINE
Definition: pedump.c:667
INT line_count
Definition: edit.c:125
DWORD style
Definition: edit.c:108
int32_t INT
Definition: typedefs.h:56
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:934
GLenum GLclampf GLint i
Definition: glfuncs.h:14
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:969
Definition: parser.c:48
unsigned short WORD
Definition: ntddk_ex.h:93
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPWSTR text
Definition: edit.c:99

◆ EDIT_EM_GetSel()

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

Definition at line 2399 of file edit.c.

Referenced by EDIT_WindowProc().

2400 {
2401  UINT s = es->selection_start;
2402  UINT e = es->selection_end;
2403 
2404  ORDER_UINT(s, e);
2405  if (start)
2406  *start = s;
2407  if (end)
2408  *end = e;
2409  return MAKELONG(s, e);
2410 }
GLuint GLuint end
Definition: gl.h:1545
#define ORDER_UINT(x, y)
Definition: edit.c:158
INT selection_start
Definition: edit.c:114
#define e
Definition: ke_i.h:82
#define MAKELONG(a, b)
Definition: typedefs.h:248
unsigned int UINT
Definition: ndis.h:50
GLdouble s
Definition: gl.h:2039
GLuint start
Definition: gl.h:1545
INT selection_end
Definition: edit.c:115

◆ EDIT_EM_GetThumb()

static LRESULT EDIT_EM_GetThumb ( EDITSTATE es)
static

Definition at line 4165 of file edit.c.

Referenced by EDIT_WindowProc().

4166 {
4167  return MAKELONG(EDIT_WM_VScroll(es, EM_GETTHUMB, 0),
4168  EDIT_WM_HScroll(es, EM_GETTHUMB, 0));
4169 }
#define MAKELONG(a, b)
Definition: typedefs.h:248
static LRESULT EDIT_WM_HScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:3913
static LRESULT EDIT_WM_VScroll(EDITSTATE *es, INT action, INT pos)
Definition: edit.c:4045
#define EM_GETTHUMB
Definition: winuser.h:1959

◆ EDIT_EM_LineFromChar()

static INT EDIT_EM_LineFromChar ( EDITSTATE es,
INT  index 
)
static

Definition at line 905 of file edit.c.

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

906 {
907  INT line;
908  LINEDEF *line_def;
909 
910  if (!(es->style & ES_MULTILINE))
911  return 0;
912  if (index > (INT)get_text_length(es))
913  return es->line_count - 1;
914  if (index == -1)
916 
917  line = 0;
918  line_def = es->first_line_def;
919  index -= line_def->length;
920  while ((index >= 0) && line_def->next) {
921  line++;
922  line_def = line_def->next;
923  index -= line_def->length;
924  }
925  return line;
926 }
LINEDEF * first_line_def
Definition: edit.c:141
#define ES_MULTILINE
Definition: pedump.c:667
INT line_count
Definition: edit.c:125
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
DWORD style
Definition: edit.c:108
int32_t INT
Definition: typedefs.h:56
INT selection_start
Definition: edit.c:114
GLuint index
Definition: glext.h:6031
struct tagLINEDEF * next
Definition: edit.c:94
char line[200]
Definition: main.c:97
#define min(a, b)
Definition: monoChain.cc:55
INT selection_end
Definition: edit.c:115
INT length
Definition: edit.c:88

◆ EDIT_EM_LineIndex()

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

Definition at line 934 of file edit.c.

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

935 {
936  INT line_index;
937  const LINEDEF *line_def;
938 
939  if (!(es->style & ES_MULTILINE))
940  return 0;
941  if (line >= es->line_count)
942  return -1;
943 
944  line_index = 0;
945  line_def = es->first_line_def;
946  if (line == -1) {
947  INT index = es->selection_end - line_def->length;
948  while ((index >= 0) && line_def->next) {
949  line_index += line_def->length;
950  line_def = line_def->next;
951  index -= line_def->length;
952  }
953  } else {
954  while (line > 0) {
955  line_index += line_def->length;
956  line_def = line_def->next;
957  line--;
958  }
959  }
960  return line_index;
961 }
LINEDEF * first_line_def
Definition: edit.c:141
#define ES_MULTILINE
Definition: pedump.c:667
INT line_count
Definition: edit.c:125
DWORD style
Definition: edit.c:108
int32_t INT
Definition: typedefs.h:56
Definition: parser.c:48
GLuint index
Definition: glext.h:6031
struct tagLINEDEF * next
Definition: edit.c:94
INT selection_end
Definition: edit.c:115
INT length
Definition: edit.c:88

◆ EDIT_EM_LineLength()

static INT EDIT_EM_LineLength ( EDITSTATE es,
INT  index 
)
static

Definition at line 969 of file edit.c.

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

970 {
971  LINEDEF *line_def;
972 
973  if (!(es->style & ES_MULTILINE))
974  return get_text_length(es);
975 
976  if (index == -1) {
977  /* get the number of remaining non-selected chars of selected lines */
978  INT32 l; /* line number */
979  INT32 li; /* index of first char in line */
980  INT32 count;
982  /* # chars before start of selection area */
983  count = es->selection_start - EDIT_EM_LineIndex(es, l);
984  l = EDIT_EM_LineFromChar(es, es->selection_end);
985  /* # chars after end of selection */
986  li = EDIT_EM_LineIndex(es, l);
987  count += li + EDIT_EM_LineLength(es, li) - es->selection_end;
988  return count;
989  }
990  line_def = es->first_line_def;
991  index -= line_def->length;
992  while ((index >= 0) && line_def->next) {
993  line_def = line_def->next;
994  index -= line_def->length;
995  }
996  return line_def->net_length;
997 }
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:905
LINEDEF * first_line_def
Definition: edit.c:141
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:212
DWORD style
Definition: edit.c:108
INT selection_start
Definition: edit.c:114
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:934
INT net_length
Definition: edit.c:89
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:969
GLuint index
Definition: glext.h:6031
r l[0]
Definition: byte_order.h:167
struct tagLINEDEF * next
Definition: edit.c:94
INT selection_end
Definition: edit.c:115
signed int INT32
INT length
Definition: edit.c:88

◆ EDIT_EM_LineScroll()

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

Definition at line 1641 of file edit.c.

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

1642 {
1643  if (!(es->style & ES_MULTILINE))
1644  return FALSE;
1645 
1646  dx *= es->char_width;
1647  return EDIT_EM_LineScroll_internal(es, dx, dy);
1648 }
#define ES_MULTILINE
Definition: pedump.c:667
DWORD style
Definition: edit.c:108
static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1585
INT char_width
Definition: edit.c:107
INT INT dy
Definition: msvc.h:65
INT dx
Definition: msvc.h:65

◆ EDIT_EM_LineScroll_internal()

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

Definition at line 1585 of file edit.c.

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

1586 {
1587  INT nyoff;
1588  INT x_offset_in_pixels;
1589  INT lines_per_page = (es->format_rect.bottom - es->format_rect.top) /
1590  es->line_height;
1591 
1592  if (es->style & ES_MULTILINE)
1593  {
1594  x_offset_in_pixels = es->x_offset;
1595  }
1596  else
1597  {
1598  dy = 0;
1599  x_offset_in_pixels = (short)LOWORD(EDIT_EM_PosFromChar(es, es->x_offset, FALSE));
1600  }
1601 
1602  if (-dx > x_offset_in_pixels)
1603  dx = -x_offset_in_pixels;
1604  if (dx > es->text_width - x_offset_in_pixels)
1605  dx = es->text_width - x_offset_in_pixels;
1606  nyoff = max(0, es->y_offset + dy);
1607  if (nyoff >= es->line_count - lines_per_page)
1608  nyoff = max(0, es->line_count - lines_per_page);
1609  dy = (es->y_offset - nyoff) * es->line_height;
1610  if (dx || dy) {
1611  RECT rc1;
1612  RECT rc;
1613 
1614  es->y_offset = nyoff;
1615  if(es->style & ES_MULTILINE)
1616  es->x_offset += dx;
1617  else
1618  es->x_offset += dx / es->char_width;
1619 
1620  GetClientRect(es->hwndSelf, &rc1);
1621  IntersectRect(&rc, &rc1, &es->format_rect);
1622  ScrollWindowEx(es->hwndSelf, -dx, dy,
1623  NULL, &rc, NULL, NULL, SW_INVALIDATE);
1624  /* force scroll info update */
1626  }
1627  if (dx && !(es->flags & EF_HSCROLL_TRACK))
1629  if (dy && !(es->flags & EF_VSCROLL_TRACK))
1631  return TRUE;
1632 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
INT line_height
Definition: edit.c:106
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1544
INT text_width
Definition: edit.c:120
#define ES_MULTILINE
Definition: pedump.c:667
INT line_count
Definition: edit.c:125
#define EF_VSCROLL_TRACK
Definition: edit.c:69
INT x_offset
Definition: edit.c:104
LONG top
Definition: windef.h:297
#define EDIT_NOTIFY_PARENT(es, wNotifyCode)
Definition: edit.c:161
DWORD style
Definition: edit.c:108
int32_t INT
Definition: typedefs.h:56
#define EF_HSCROLL_TRACK
Definition: edit.c:70
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
smooth NULL
Definition: ftsmooth.c:416
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1005
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
if(!(yy_init))
Definition: macro.lex.yy.c:717
RECT format_rect
Definition: edit.c:119
INT y_offset
Definition: edit.c:126
INT char_width
Definition: edit.c:107
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define EN_HSCROLL
Definition: winuser.h:1985
#define SW_INVALIDATE
Definition: winuser.h:2533
WORD flags
Definition: edit.c:109
#define EN_VSCROLL
Definition: winuser.h:1990
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
INT INT dy
Definition: msvc.h:65
HWND hwndSelf
Definition: edit.c:129
LONG bottom
Definition: windef.h:299
#define LOWORD(l)
Definition: pedump.c:82
INT dx
Definition: msvc.h:65

◆ EDIT_EM_PosFromChar()

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

Definition at line 1005 of file edit.c.

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(), EDIT_SetCaretPos(), and EDIT_WindowProc().

1006 {
1007  INT len = get_text_length(es);
1008  INT l;
1009  INT li;
1010  INT x = 0;
1011  INT y = 0;
1012  INT w;
1013  INT lw;
1014  LINEDEF *line_def;
1015 
1016  index = min(index, len);
1017  if (es->style & ES_MULTILINE) {
1018  l = EDIT_EM_LineFromChar(es, index);
1020 
1021  y = (l - es->y_offset) * es->line_height;
1022  li = EDIT_EM_LineIndex(es, l);
1023  if (after_wrap && (li == index) && l) {
1024  INT l2 = l - 1;
1025  line_def = es->first_line_def;
1026  while (l2) {
1027  line_def = line_def->next;
1028  l2--;
1029  }
1030  if (line_def->ending == END_WRAP) {
1031  l--;
1032  y -= es->line_height;
1033  li = EDIT_EM_LineIndex(es, l);
1034  }
1035  }
1036 
1037  line_def = es->first_line_def;
1038  while (line_def->index != li)
1039  line_def = line_def->next;
1040 
1041  lw = line_def->width;
1042  w = es->format_rect.right - es->format_rect.left;
1043  if (line_def->ssa)
1044  {
1045  ScriptStringCPtoX(line_def->ssa, (index - 1) - li, TRUE, &x);
1046  x -= es->x_offset;
1047  }
1048  else
1049  x = es->x_offset;
1050 
1051  if (es->style & ES_RIGHT)
1052  x = w - (lw - x);
1053  else if (es->style & ES_CENTER)
1054  x += (w - lw) / 2;
1055  } else {
1056  INT xoff = 0;
1057  INT xi = 0;
1059  if (es->x_offset)
1060  {
1061  if (es->ssa)
1062  {
1063  if (es->x_offset >= get_text_length(es))
1064  {
1065  int leftover = es->x_offset - get_text_length(es);
1066  if (es->ssa)
1067  {
1068  const SIZE *size;
1069  size = ScriptString_pSize(es->ssa);
1070  xoff = size->cx;
1071  }
1072  else
1073  xoff = 0;
1074  xoff += es->char_width * leftover;
1075  }
1076  else
1077  ScriptStringCPtoX(es->ssa, es->x_offset, FALSE, &xoff);
1078  }
1079  else
1080  xoff = 0;
1081  }
1082  if (index)
1083  {
1084  if (index >= get_text_length(es))
1085  {
1086  if (es->ssa)
1087  {
1088  const SIZE *size;
1089  size = ScriptString_pSize(es->ssa);
1090  xi = size->cx;
1091  }
1092  else
1093  xi = 0;
1094  }
1095  else if (es->ssa)
1096  ScriptStringCPtoX(es->ssa, index, FALSE, &xi);
1097  else
1098  xi = 0;
1099  }
1100  x = xi - xoff;
1101 
1102  if (index >= es->x_offset) {
1103  if (!es->x_offset && (es->style & (ES_RIGHT | ES_CENTER)))
1104  {
1105  w = es->format_rect.right - es->format_rect.left;
1106  if (w > es->text_width)
1107  {
1108  if (es->style & ES_RIGHT)
1109  x += w - es->text_width;
1110  else if (es->style & ES_CENTER)
1111  x += (w - es->text_width) / 2;
1112  }
1113  }
1114  }
1115  y = 0;
1116  }
1117  x += es->format_rect.left;
1118  y += es->format_rect.top;
1119  return MAKELONG((INT16)x, (INT16)y);
1120 }
static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, INT line)
Definition: edit.c:368
#define ES_CENTER
Definition: pedump.c:665
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:905
#define TRUE
Definition: types.h:120
INT line_height
Definition: edit.c:106
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
LINEDEF * first_line_def
Definition: edit.c:141
INT text_width
Definition: edit.c:120
LINE_END ending
Definition: edit.c:90
#define ES_MULTILINE
Definition: pedump.c:667
Definition: edit.c:81
INT x_offset
Definition: edit.c:104
LONG top
Definition: windef.h:297
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
DWORD style
Definition: edit.c:108
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
INT width
Definition: edit.c:91
INT INT y
Definition: msvc.h:62
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:934
#define ES_RIGHT
Definition: pedump.c:666
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:324
GLuint index
Definition: glext.h:6031
r l[0]
Definition: byte_order.h:167
GLsizeiptr size
Definition: glext.h:5919
struct tagLINEDEF * next
Definition: edit.c:94
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:153
RECT format_rect
Definition: edit.c:119
INT y_offset
Definition: edit.c:126
INT char_width
Definition: edit.c:107
GLenum GLsizei len
Definition: glext.h:6722
const SIZE *WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
Definition: usp10.c:3867
INT x
Definition: msvc.h:62
#define min(a, b)
Definition: monoChain.cc:55
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int *pX)
Definition: usp10.c:2409
INT index
Definition: edit.c:92
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:93
signed short INT16

◆ EDIT_EM_ReplaceSel()

static void EDIT_EM_ReplaceSel ( EDITSTATE es,
BOOL  can_undo,
const WCHAR lpsz_replace,
UINT  strl,
BOOL  send_update,
BOOL  honor_limit 
)
static

Definition at line 2420 of file edit.c.

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

2422 {
2423  UINT tl = get_text_length(es);
2424  UINT utl;
2425  UINT s;
2426  UINT e;
2427  UINT i;
2428  UINT size;
2429  LPWSTR p;
2430  HRGN hrgn = 0;
2431  LPWSTR buf = NULL;
2432  UINT bufl;
2433 
2434  TRACE("%s, can_undo %d, send_update %d\n",
2435  debugstr_wn(lpsz_replace, strl), can_undo, send_update);
2436 
2437  s = es->selection_start;
2438  e = es->selection_end;
2439 
2441  if ((s == e) && !strl)
2442  return;
2443 
2444  ORDER_UINT(s, e);
2445 
2446  size = tl - (e - s) + strl;
2447  if (!size)
2448  es->text_width = 0;
2449 
2450  /* Issue the EN_MAXTEXT notification and continue with replacing text
2451  * so that buffer limit is honored. */
2452  if ((honor_limit) && (size > es->buffer_limit)) {
2454  /* Buffer limit can be smaller than the actual length of text in combobox */
2455  if (es->buffer_limit < (tl - (e-s)))
2456  strl = 0;
2457  else
2458  strl = min(strl, es->buffer_limit - (tl - (e-s)));
2459  }
2460 
2461  if (!EDIT_MakeFit(es, tl - (e - s) + strl))
2462  return;
2463 
2464  if (e != s) {
2465  /* there is something to be deleted */
2466  TRACE("deleting stuff.\n");
2467  bufl = e - s;
2468  buf = heap_alloc((bufl + 1) * sizeof(WCHAR));
2469  if (!buf) return;
2470  memcpy(buf, es->text + s, bufl * sizeof(WCHAR));
2471  buf[bufl] = 0; /* ensure 0 termination */
2472  /* now delete */
2473  strcpyW(es->text + s, es->text + e);
2474  text_buffer_changed(es);
2475  }
2476  if (strl) {
2477  /* there is an insertion */
2478  tl = get_text_length(es);
2479  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));
2480  for (p = es->text + tl ; p >= es->text + s ; p--)
2481  p[strl] = p[0];
2482  for (i = 0 , p = es->text + s ; i < strl ; i++)
2483  p[i] = lpsz_replace[i];
2484  if(es->style & ES_UPPERCASE)
2485  CharUpperBuffW(p, strl);
2486  else if(es->style & ES_LOWERCASE)
2487  CharLowerBuffW(p, strl);
2488  text_buffer_changed(es);
2489  }
2490  if (es->style & ES_MULTILINE)
2491  {
2492  INT st = min(es->selection_start, es->selection_end);
2493  INT vlc = get_vertical_line_count(es);
2494 
2495  hrgn = CreateRectRgn(0, 0, 0, 0);
2496  EDIT_BuildLineDefs_ML(es, st, st + strl,
2497  strl - abs(es->selection_end - es->selection_start), hrgn);
2498  /* if text is too long undo all changes */
2499  if (honor_limit && !(es->style & ES_AUTOVSCROLL) && (es->line_count > vlc)) {
2500  if (strl)
2501  strcpyW(es->text + e, es->text + e + strl);
2502  if (e != s)
2503  for (i = 0 , p = es->text ; i < e - s ; i++)
2504  p[i + s] = buf[i];
2505  text_buffer_changed(es);
2506  EDIT_BuildLineDefs_ML(es, s, e,
2507  abs(es->selection_end - es->selection_start) - strl, hrgn);
2508  strl = 0;
2509  e = s;
2510  hrgn = CreateRectRgn(0, 0, 0, 0);
2512  }
2513  }
2514  else {
2515  INT fw = es->format_rect.right - es->format_rect.left;
2518  /* remove chars that don't fit */
2519  if (honor_limit && !(es->style & ES_AUTOHSCROLL) && (es->text_width > fw)) {
2520  while ((es->text_width > fw) && s + strl >= s) {
2521  strcpyW(es->text + s + strl - 1, es->text + s + strl);
2522  strl--;
2523  es->text_length = -1;
2526  }
2527  text_buffer_changed(es);
2529  }
2530  }
2531 
2532  if (e != s) {
2533  if (can_undo) {
2534  utl = strlenW(es->undo_text);
2535  if (!es->undo_insert_count && (*es->undo_text && (s == es->undo_position))) {
2536  /* undo-buffer is extended to the right */
2537  EDIT_MakeUndoFit(es, utl + e - s);
2538  memcpy(es->undo_text + utl, buf, (e - s)*sizeof(WCHAR));
2539  (es->undo_text + utl)[e - s] = 0; /* ensure 0 termination */
2540  } else if (!es->undo_insert_count && (*es->undo_text && (e == es->undo_position))) {
2541  /* undo-buffer is extended to the left */
2542  EDIT_MakeUndoFit(es, utl + e - s);
2543  for (p = es->undo_text + utl ; p >= es->undo_text ; p--)
2544  p[e - s] = p[0];
2545  for (i = 0 , p = es->undo_text ; i < e - s ; i++)
2546  p[i] = buf[i];
2547  es->undo_position = s;
2548  } else {
2549  /* new undo-buffer */
2550  EDIT_MakeUndoFit(es, e - s);
2551  memcpy(es->undo_text, buf, (e - s)*sizeof(WCHAR));
2552  es->undo_text[e - s] = 0; /* ensure 0 termination */
2553  es->undo_position = s;
2554  }
2555  /* any deletion makes the old insertion-undo invalid */
2556  es->undo_insert_count = 0;
2557  } else
2559  }
2560  if (strl) {
2561  if (can_undo) {
2562  if ((s == es->undo_position) ||
2563  ((es->undo_insert_count) &&
2564  (s == es->undo_position + es->undo_insert_count)))
2565  /*
2566  * insertion is new and at delete position or
2567  * an extension to either left or right
2568  */
2569  es->undo_insert_count += strl;
2570  else {
2571  /* new insertion undo */
2572  es->undo_position = s;
2573  es->undo_insert_count = strl;
2574  /* new insertion makes old delete-buffer invalid */
2575  *es->undo_text = '\0';
2576  }
2577  } else
2579  }
2580 
2581  heap_free(buf);
2582 
2583  s += strl;
2584 
2585  /* If text has been deleted and we're right or center aligned then scroll rightward */
2586  if (es->style & (ES_RIGHT | ES_CENTER))
2587  {
2588  INT delta = strl - abs(es->selection_end - es->selection_start);
2589 
2590  if (delta < 0 && es->x_offset)
2591  {
2592  if (abs(delta) > es->x_offset)
2593  es->x_offset = 0;
2594  else
2595  es->x_offset += delta;
2596  }
2597  }
2598 
2599  EDIT_EM_SetSel(es, s, s, FALSE);
2600  es->flags |= EF_MODIFIED;
2601  if (send_update) es->flags |= EF_UPDATE;
2602  if (hrgn)
2603  {
2604  EDIT_UpdateTextRegion(es, hrgn, TRUE);
2605  DeleteObject(hrgn);
2606  }
2607  else
2608  EDIT_UpdateText(es, NULL, TRUE);
2609 
2610  EDIT_EM_ScrollCaret(es);
2611 
2612  /* force scroll info update */
2614 
2615 
2616  if(send_update || (es->flags & EF_UPDATE))
2617  {
2618  es->flags &= ~EF_UPDATE;
2620  }
2622 }
static BOOL EDIT_MakeUndoFit(EDITSTATE *es, UINT size)
Definition: edit.c:1301
#define ES_CENTER
Definition: pedump.c:665
#define abs(i)
Definition: fconv.c:206
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1343
#define EF_UPDATE
Definition: edit.c:68
LPWSTR undo_text
Definition: edit.c:112
#define EN_MAXTEXT
Definition: winuser.h:1987
#define TRUE
Definition: types.h:120
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1473
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:188
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1544
__wchar_t WCHAR
Definition: xmlstorage.h:180
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:410
INT text_width
Definition: edit.c:120
#define ES_MULTILINE
Definition: pedump.c:667
#define HRGN
Definition: msvc.h:39
INT line_count
Definition: edit.c:125
INT x_offset
Definition: edit.c:104
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1721
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:425
static void EDIT_UpdateTextRegion(EDITSTATE *es, HRGN hrgn, BOOL bErase)
Definition: edit.c:1328
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
#define EDIT_NOTIFY_PARENT(es, wNotifyCode)
Definition: edit.c:161
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
DWORD style
Definition: edit.c:108
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
#define ORDER_UINT(x, y)
Definition: edit.c:158
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
INT selection_start
Definition: edit.c:114
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define ES_RIGHT
Definition: pedump.c:666
#define e
Definition: ke_i.h:82
#define EF_MODIFIED
Definition: edit.c:66
#define debugstr_w
Definition: kernel32.h:32
UINT text_length
Definition: edit.c:100
static void EDIT_CalcLineWidth_SL(EDITSTATE *es)
Definition: edit.c:753
#define ES_UPPERCASE
Definition: pedump.c:668
smooth NULL
Definition: ftsmooth.c:416
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:311
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define ES_AUTOVSCROLL
Definition: pedump.c:671
UINT undo_position
Definition: edit.c:111
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
unsigned int UINT
Definition: ndis.h:50
DWORD WINAPI CharUpperBuffW(_Inout_updates_(cchLength) LPWSTR lpsz, _In_ DWORD cchLength)
RECT format_rect
Definition: edit.c:119
static HRGN hrgn
Definition: win.c:55
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLdouble s
Definition: gl.h:2039
#define debugstr_wn
Definition: kernel32.h:33
WORD flags
Definition: edit.c:109
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
UINT buffer_limit
Definition: edit.c:102
static void text_buffer_changed(EDITSTATE *es)
Definition: edit.c:1182
#define min(a, b)
Definition: monoChain.cc:55
INT undo_insert_count
Definition: edit.c:110
INT selection_end
Definition: edit.c:115
static BOOL EDIT_MakeFit(EDITSTATE *es, UINT size)
Definition: edit.c:1260
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define ES_AUTOHSCROLL
Definition: pedump.c:672
LPWSTR text
Definition: edit.c:99
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define ES_LOWERCASE
Definition: pedump.c:669
#define EN_CHANGE
Definition: winuser.h:1983

◆ EDIT_EM_Scroll()

static LRESULT EDIT_EM_Scroll ( EDITSTATE es,
INT  action 
)
static

Definition at line 1656 of file edit.c.

Referenced by EDIT_WindowProc(), and EDIT_WM_VScroll().

1657 {
1658  INT dy;
1659 
1660  if (!(es->style & ES_MULTILINE))
1661  return (LRESULT)FALSE;
1662 
1663  dy = 0;
1664 
1665  switch (action) {
1666  case SB_LINEUP:
1667  if (es->y_offset)
1668  dy = -1;
1669  break;
1670  case SB_LINEDOWN:
1671  if (es->y_offset < es->line_count - 1)
1672  dy = 1;
1673  break;
1674  case SB_PAGEUP:
1675  if (es->y_offset)
1676  dy = -(es->format_rect.bottom - es->format_rect.top) / es->line_height;
1677  break;
1678  case SB_PAGEDOWN:
1679  if (es->y_offset < es->line_count - 1)
1680  dy = (es->format_rect.bottom - es->format_rect.top) / es->line_height;
1681  break;
1682  default:
1683  return (LRESULT)FALSE;
1684  }
1685  if (dy) {
1686  INT vlc = get_vertical_line_count(es);
1687  /* check if we are going to move too far */
1688  if(es->y_offset + dy > es->line_count - vlc)
1689  dy = max(es->line_count - vlc, 0) - es->y_offset;
1690 
1691  /* Notification is done in EDIT_EM_LineScroll */
1692  if(dy) {
1693  EDIT_EM_LineScroll(es, 0, dy);
1694  return MAKELONG(dy, TRUE);
1695  }
1696 
1697  }
1698  return (LRESULT)FALSE;
1699 }
#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
INT line_height
Definition: edit.c:106
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:410
#define ES_MULTILINE
Definition: pedump.c:667
INT line_count
Definition: edit.c:125
LONG top
Definition: windef.h:297
DWORD style
Definition: edit.c:108
int32_t INT
Definition: typedefs.h:56
#define MAKELONG(a, b)
Definition: typedefs.h:248
if(!(yy_init))
Definition: macro.lex.yy.c:717
RECT format_rect
Definition: edit.c:119
INT y_offset
Definition: edit.c:126
const WCHAR * action
Definition: action.c:7779
INT INT dy
Definition: msvc.h:65
static BOOL EDIT_EM_LineScroll(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1641
#define SB_LINEDOWN
Definition: winuser.h:565
#define SB_LINEUP
Definition: winuser.h:564
LONG bottom
Definition: windef.h:299
LONG_PTR LRESULT
Definition: windef.h:209

◆ EDIT_EM_ScrollCaret()

static void EDIT_EM_ScrollCaret ( EDITSTATE es)
static

Definition at line 1721 of file edit.c.

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_WindowProc(), EDIT_WM_Create(), EDIT_WM_LButtonDblClk(), EDIT_WM_LButtonDown(), and EDIT_WM_SetText().

1722 {
1723  if (es->style & ES_MULTILINE) {
1724  INT l;
1725  INT vlc;
1726  INT ww;
1727  INT cw = es->char_width;
1728  INT x;
1729  INT dy = 0;
1730  INT dx = 0;
1731 
1732  l = EDIT_EM_LineFromChar(es, es->selection_end);
1734  vlc = get_vertical_line_count(es);
1735  if (l >= es->y_offset + vlc)
1736  dy = l - vlc + 1 - es->y_offset;
1737  if (l < es->y_offset)
1738  dy = l - es->y_offset;
1739  ww = es->format_rect.right - es->format_rect.left;
1740  if (x < es->format_rect.left)
1741  dx = x - es->format_rect.left - ww / HSCROLL_FRACTION / cw * cw;
1742  if (x > es->format_rect.right)
1743  dx = x - es->format_rect.left - (HSCROLL_FRACTION - 1) * ww / HSCROLL_FRACTION / cw * cw;
1744  if (dy || dx || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1745  {
1746  /* check if we are going to move too far */
1747  if(es->x_offset + dx + ww > es->text_width)
1748  dx = es->text_width - ww - es->x_offset;
1749  if(dx || dy || (es->y_offset && (es->line_count - es->y_offset < vlc)))
1750  EDIT_EM_LineScroll_internal(es, dx, dy);
1751  }
1752  } else {
1753  INT x;
1754  INT goal;
1755  INT format_width;
1756 
1758  format_width = es->format_rect.right - es->format_rect.left;
1759  if (x < es->format_rect.left) {
1760  goal = es->format_rect.left + format_width / HSCROLL_FRACTION;
1761  do {
1762  es->x_offset--;
1764  } while ((x < goal) && es->x_offset);
1765  /* FIXME: use ScrollWindow() somehow to improve performance */
1766  EDIT_UpdateText(es, NULL, TRUE);
1767  } else if (x > es->format_rect.right) {
1768  INT x_last;
1769  INT len = get_text_length(es);
1770  goal = es->format_rect.right - format_width / HSCROLL_FRACTION;
1771  do {
1772  es->x_offset++;
1774  x_last = (short)LOWORD(EDIT_EM_PosFromChar(es, len, FALSE));
1775  } while ((x > goal) && (x_last > es->format_rect.right));
1776  /* FIXME: use ScrollWindow() somehow to improve performance */
1777  EDIT_UpdateText(es, NULL, TRUE);
1778  }
1779  }
1780 
1781  if(es->flags & EF_FOCUSED)
1783 }
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1343
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:905
#define TRUE
Definition: types.h:120
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:410
INT text_width
Definition: edit.c:120
#define ES_MULTILINE
Definition: pedump.c:667
INT line_count
Definition: edit.c:125
INT x_offset
Definition: edit.c:104
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
DWORD style
Definition: edit.c:108
static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap)
Definition: edit.c:1707
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy)
Definition: edit.c:1585
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
#define EF_AFTER_WRAP
Definition: edit.c:71
smooth NULL
Definition: ftsmooth.c:416
#define EF_FOCUSED
Definition: edit.c:67
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1005
r l[0]
Definition: byte_order.h:167
RECT format_rect
Definition: edit.c:119
INT y_offset
Definition: edit.c:126
#define HSCROLL_FRACTION
Definition: edit.c:61
INT char_width
Definition: edit.c:107
GLenum GLsizei len
Definition: glext.h:6722
WORD flags
Definition: edit.c:109
INT INT dy
Definition: msvc.h:65
INT x
Definition: msvc.h:62
INT selection_end
Definition: edit.c:115
#define LOWORD(l)
Definition: pedump.c:82
INT dx
Definition: msvc.h:65

◆ EDIT_EM_SetHandle()

static void EDIT_EM_SetHandle ( EDITSTATE es,
HLOCAL  hloc 
)
static

Definition at line 2632 of file edit.c.

Referenced by EDIT_WindowProc().

2633 {
2634  if (!(es->style & ES_MULTILINE))
2635  return;
2636 
2637  if (!hloc)
2638  return;
2639 
2640  EDIT_UnlockBuffer(es, TRUE);
2641 
2642  es->hloc32W = hloc;
2643  es->buffer_size = LocalSize(es->hloc32W)/sizeof(WCHAR) - 1;
2644 
2645  /* The text buffer handle belongs to the control */
2646  es->hlocapp = NULL;
2647 
2648  EDIT_LockBuffer(es);
2649  text_buffer_changed(es);
2650 
2651  es->x_offset = es->y_offset = 0;
2652  es->selection_start = es->selection_end = 0;
2654  es->flags &= ~EF_MODIFIED;
2655  es->flags &= ~EF_UPDATE;
2656  EDIT_BuildLineDefs_ML(es, 0, get_text_length(es), 0, NULL);
2657  EDIT_UpdateText(es, NULL, TRUE);
2658  EDIT_EM_ScrollCaret(es);
2659  /* force scroll info update */
2661 }
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1343
#define EF_UPDATE
Definition: edit.c:68
#define TRUE
Definition: types.h:120
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:188
static void EDIT_UpdateScrollInfo(EDITSTATE *es)
Definition: edit.c:1544
#define ES_MULTILINE
Definition: pedump.c:667
INT x_offset
Definition: edit.c:104
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1721
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:425
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
DWORD style
Definition: edit.c:108
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777
static void EDIT_LockBuffer(EDITSTATE *es)
Definition: edit.c:1195
#define WCHAR
Definition: msvc.h:43
static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
Definition: edit.c:1214
INT selection_start
Definition: edit.c:114
#define EF_MODIFIED
Definition: edit.c:66
smooth NULL
Definition: ftsmooth.c:416
HLOCAL hloc32W
Definition: edit.c:142
UINT buffer_size
Definition: edit.c:101
INT y_offset
Definition: edit.c:126
WORD flags
Definition: edit.c:109
HLOCAL hlocapp
Definition: edit.c:143
static void text_buffer_changed(EDITSTATE *es)
Definition: edit.c:1182
INT selection_end
Definition: edit.c:115

◆ EDIT_EM_SetLimitText()

static void EDIT_EM_SetLimitText ( EDITSTATE es,
UINT  limit 
)
static

Definition at line 2671 of file edit.c.

Referenced by EDIT_WindowProc().

2672 {
2673  if (!limit) limit = ~0u;
2674  if (!(es->style & ES_MULTILINE)) limit = min(limit, 0x7ffffffe);
2675  es->buffer_limit = limit;
2676 }
#define ES_MULTILINE
Definition: pedump.c:667
DWORD style
Definition: edit.c:108
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble * u
Definition: glfuncs.h:88
GLint limit
Definition: glext.h:10326
UINT buffer_limit
Definition: edit.c:102
#define min(a, b)
Definition: monoChain.cc:55

◆ EDIT_EM_SetMargins()

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

Definition at line 2707 of file edit.c.

Referenced by EDIT_WindowProc(), and EDIT_WM_SetFont().

2709 {
2710  TEXTMETRICW tm;
2711  INT default_left_margin = 0; /* in pixels */
2712  INT default_right_margin = 0; /* in pixels */
2713 
2714  /* Set the default margins depending on the font */
2715  if (es->font && (left == EC_USEFONTINFO || right == EC_USEFONTINFO)) {
2716  HDC dc = GetDC(es->hwndSelf);
2717  HFONT old_font = SelectObject(dc, es->font);
2718  LONG width = GdiGetCharDimensions(dc, &tm, NULL);
2719  RECT rc;
2720 
2721  /* The default margins are only non zero for TrueType or Vector fonts */
2722  if (tm.tmPitchAndFamily & ( TMPF_VECTOR | TMPF_TRUETYPE )) {
2723  if (!is_cjk(tm.tmCharSet)) {
2724  default_left_margin = width / 2;
2725  default_right_margin = width / 2;
2726 
2727  GetClientRect(es->hwndSelf, &rc);
2728  if (rc.right - rc.left < (width / 2 + width) * 2 &&
2729  (width >= 28 || !IsRectEmpty(&rc)) ) {
2730  default_left_margin = es->left_margin;
2731  default_right_margin = es->right_margin;
2732  }
2733  } else {
2734  /* FIXME: figure out the CJK values. They are not affected by the client rect. */
2735  default_left_margin = width / 2;
2736  default_right_margin = width / 2;
2737  }
2738  }
2739  SelectObject(dc, old_font);
2740  ReleaseDC(es->hwndSelf, dc);
2741  }
2742 
2743  if (action & EC_LEFTMARGIN) {
2744  es->format_rect.left -= es->left_margin;
2745  if (left != EC_USEFONTINFO)
2746  es->left_margin = left;
2747  else
2748  es->left_margin = default_left_margin;
2749  es->format_rect.left += es->left_margin;
2750  }
2751 
2752  if (action & EC_RIGHTMARGIN) {
2753  es->format_rect.right += es->right_margin;
2754  if (right != EC_USEFONTINFO)
2755  es->right_margin = right;
2756  else
2757  es->right_margin = default_right_margin;
2758  es->format_rect.right -= es->right_margin;
2759  }
2760 
2761  if (action & (EC_LEFTMARGIN | EC_RIGHTMARGIN)) {
2763  if (repaint) EDIT_UpdateText(es, NULL, TRUE);
2764  }
2765 
2766  TRACE("left=%d, right=%d\n", es->left_margin, es->right_margin);
2767 }
#define HDC
Definition: msvc.h:22
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1343
GLint GLint GLsizei width
Definition: gl.h:1546
#define EC_RIGHTMARGIN
Definition: winuser.h:2561
#define TRUE
Definition: types.h:120
HDC WINAPI GetDC(_In_opt_ HWND)
INT right_margin
Definition: edit.c:118
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
HDC dc
Definition: cylfrac.c:34
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
HFONT font
Definition: edit.c:103
long LONG
Definition: pedump.c:60
#define TMPF_TRUETYPE
Definition: wingdi.h:1294
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
BYTE tmPitchAndFamily
Definition: wingdi.h:2378
#define EC_LEFTMARGIN
Definition: winuser.h:2560
smooth NULL
Definition: ftsmooth.c:416
static void EDIT_AdjustFormatRect(EDITSTATE *es)
Definition: edit.c:2196
#define TRACE(s)
Definition: solgame.cpp:4
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859
RECT format_rect
Definition: edit.c:119
BYTE tmCharSet
Definition: wingdi.h:2379
Definition: time.h:76
#define TMPF_VECTOR
Definition: wingdi.h:1293
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LONG WINAPI GdiGetCharDimensions(HDC, LPTEXTMETRICW, LONG *)
Definition: font.c:1922
const WCHAR * action
Definition: action.c:7779
HWND hwndSelf
Definition: edit.c:129
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static BOOL is_cjk(UINT charset)
Definition: edit.c:2692
#define EC_USEFONTINFO
Definition: winuser.h:2562
INT left_margin
Definition: edit.c:117

◆ EDIT_EM_SetPasswordChar()

static void EDIT_EM_SetPasswordChar ( EDITSTATE es,
WCHAR  c 
)
static

Definition at line 2775 of file edit.c.

Referenced by EDIT_WindowProc().

2776 {
2777  LONG style;
2778 
2779  if (es->style & ES_MULTILINE)
2780  return;
2781 
2782  if (es->password_char == c)
2783  return;
2784 
2785  style = GetWindowLongW( es->hwndSelf, GWL_STYLE );
2786  es->password_char = c;
2787  if (c) {
2788  SetWindowLongW( es->hwndSelf, GWL_STYLE, style | ES_PASSWORD );
2789  es->style |= ES_PASSWORD;
2790  } else {
2791  SetWindowLongW( es->hwndSelf, GWL_STYLE, style & ~ES_PASSWORD );
2792  es->style &= ~ES_PASSWORD;
2793  }
2795  EDIT_UpdateText(es, NULL, TRUE);
2796 }
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1343
#define TRUE
Definition: types.h:120
#define ES_MULTILINE
Definition: pedump.c:667
DWORD style
Definition: edit.c:108
#define ES_PASSWORD
Definition: pedump.c:670
long LONG
Definition: pedump.c:60
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:311
const GLubyte * c
Definition: glext.h:8905
#define GWL_STYLE
Definition: winuser.h:846
HWND hwndSelf
Definition: edit.c:129
WCHAR password_char
Definition: edit.c:116
#define c
Definition: ke_i.h:80
Arabic default style
Definition: afstyles.h:93

◆ EDIT_EM_SetSel()

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

Definition at line 1473 of file edit.c.

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_WindowProc(), EDIT_WM_Char(), EDIT_WM_KeyDown(), EDIT_WM_LButtonDblClk(), EDIT_WM_LButtonDown(), EDIT_WM_MouseMove(), and EDIT_WM_SetText().

1474 {
1475  UINT old_start = es->selection_start;
1476  UINT old_end = es->selection_end;
1477  UINT len = get_text_length(es);
1478 
1479  if (start == old_start && end == old_end)
1480  return FALSE;
1481 
1482  if (start == (UINT)-1) {
1483  start = es->selection_end;
1484  end = es->selection_end;
1485  } else {
1486  start = min(start, len);
1487  end = min(end, len);
1488  }
1489  es->selection_start = start;
1490  es->selection_end = end;
1491  if (after_wrap)
1492  es->flags |= EF_AFTER_WRAP;
1493  else
1494  es->flags &= ~EF_AFTER_WRAP;
1495  /* Compute the necessary invalidation region. */
1496  /* Note that we don't need to invalidate regions which have
1497  * "never" been selected, or those which are "still" selected.
1498  * In fact, every time we hit a selection boundary, we can
1499  * *toggle* whether we need to invalidate. Thus we can optimize by
1500  * *sorting* the interval endpoints. Let's assume that we sort them
1501  * in this order:
1502  * start <= end <= old_start <= old_end
1503  * Knuth 5.3.1 (p 183) assures us that this can be done optimally
1504  * in 5 comparisons; i.e. it is impossible to do better than the
1505  * following: */
1506  ORDER_UINT(end, old_end);
1507  ORDER_UINT(start, old_start);
1508  ORDER_UINT(old_start, old_end);
1509  ORDER_UINT(start, end);
1510  /* Note that at this point 'end' and 'old_start' are not in order, but
1511  * start is definitely the min. and old_end is definitely the max. */
1512  if (end != old_start)
1513  {
1514 /*
1515  * One can also do
1516  * ORDER_UINT32(end, old_start);
1517  * EDIT_InvalidateText(es, start, end);
1518  * EDIT_InvalidateText(es, old_start, old_end);
1519  * in place of the following if statement.
1520  * (That would complete the optimal five-comparison four-element sort.)
1521  */
1522  if (old_start > end )
1523  {
1525  EDIT_InvalidateText(es, old_start, old_end);
1526  }
1527  else
1528  {
1529  EDIT_InvalidateText(es, start, old_start);
1530  EDIT_InvalidateText(es, end, old_end);
1531  }
1532  }
1533  else EDIT_InvalidateText(es, start, old_end);
1534 
1535  return TRUE;
1536 }
#define TRUE
Definition: types.h:120
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
GLuint GLuint end
Definition: gl.h:1545
#define ORDER_UINT(x, y)
Definition: edit.c:158
INT selection_start
Definition: edit.c:114
#define EF_AFTER_WRAP
Definition: edit.c:71
static void EDIT_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1443
unsigned int UINT
Definition: ndis.h:50
GLenum GLsizei len
Definition: glext.h:6722
WORD flags
Definition: edit.c:109
GLuint start
Definition: gl.h:1545
#define min(a, b)
Definition: monoChain.cc:55
INT selection_end
Definition: edit.c:115

◆ EDIT_EM_SetTabStops()

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

Definition at line 2804 of file edit.c.

Referenced by EDIT_WindowProc().

2805 {
2806  if (!(es->style & ES_MULTILINE))
2807  return FALSE;
2808  heap_free(es->tabs);
2809  es->tabs_count = count;
2810  if (!count)
2811  es->tabs = NULL;
2812  else {
2813  es->tabs = heap_alloc(count * sizeof(INT));
2814  memcpy(es->tabs, tabs, count * sizeof(INT));
2815  }
2817  return TRUE;
2818 }
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ES_MULTILINE
Definition: pedump.c:667
INT tabs_count
Definition: edit.c:139
DWORD style
Definition: edit.c:108
int32_t INT
Definition: typedefs.h:56
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
smooth NULL
Definition: ftsmooth.c:416
static void EDIT_InvalidateUniscribeData(EDITSTATE *es)
Definition: edit.c:311
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LPINT tabs
Definition: edit.c:140
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ EDIT_EM_SetWordBreakProc()

static void EDIT_EM_SetWordBreakProc ( EDITSTATE es,
EDITWORDBREAKPROCW  wbp 
)
static

Definition at line 2826 of file edit.c.

Referenced by EDIT_WindowProc().

2827 {
2828  if (es->word_break_proc == wbp)
2829  return;
2830 
2831  es->word_break_proc = wbp;
2832 
2833  if ((es->style & ES_MULTILINE) && !(es->style & ES_AUTOHSCROLL)) {
2834  EDIT_BuildLineDefs_ML(es, 0, get_text_length(es), 0, NULL);
2835  EDIT_UpdateText(es, NULL, TRUE);
2836  }
2837 }
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1343
#define TRUE
Definition: types.h:120
#define ES_MULTILINE
Definition: pedump.c:667
static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta, HRGN hrgn)
Definition: edit.c:425
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
DWORD style
Definition: edit.c:108
smooth NULL
Definition: ftsmooth.c:416
EDITWORDBREAKPROCW word_break_proc
Definition: edit.c:124
#define ES_AUTOHSCROLL
Definition: pedump.c:672

◆ EDIT_EM_Undo()

static BOOL EDIT_EM_Undo ( EDITSTATE es)
static

Definition at line 2845 of file edit.c.

Referenced by EDIT_WindowProc(), and EDIT_WM_SysKeyDown().

2846 {
2847  INT ulength;
2848  LPWSTR utext;
2849 
2850  /* As per MSDN spec, for a single-line edit control,
2851  the return value is always TRUE */
2852  if( es->style & ES_READONLY )
2853  return !(es->style & ES_MULTILINE);
2854 
2855  ulength = strlenW(es->undo_text);
2856 
2857  utext = heap_alloc((ulength + 1) * sizeof(WCHAR));
2858 
2859  strcpyW(utext, es->undo_text);
2860 
2861  TRACE("before UNDO:insertion length = %d, deletion buffer = %s\n",
2862  es->undo_insert_count, debugstr_w(utext));
2863 
2866  EDIT_EM_ReplaceSel(es, TRUE, utext, ulength, TRUE, TRUE);
2868  /* send the notification after the selection start and end are set */
2870  EDIT_EM_ScrollCaret(es);
2871  heap_free(utext);
2872 
2873  TRACE("after UNDO:insertion length = %d, deletion buffer = %s\n",
2875  return TRUE;
2876 }
LPWSTR undo_text
Definition: edit.c:112
#define TRUE
Definition: types.h:120
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1473
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
static void EDIT_EM_EmptyUndoBuffer(EDITSTATE *es)
Definition: edit.c:188
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ES_MULTILINE
Definition: pedump.c:667
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1721
#define EDIT_NOTIFY_PARENT(es, wNotifyCode)
Definition: edit.c:161
DWORD style
Definition: edit.c:108
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, const WCHAR *lpsz_replace, UINT strl, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2420
#define ES_READONLY
Definition: pedump.c:675
int32_t INT
Definition: typedefs.h:56
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define debugstr_w
Definition: kernel32.h:32
UINT undo_position
Definition: edit.c:111
#define TRACE(s)
Definition: solgame.cpp:4
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
INT undo_insert_count
Definition: edit.c:110
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
#define EN_CHANGE
Definition: winuser.h:1983

◆ EDIT_GetCompositionStr()

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

Definition at line 4177 of file edit.c.

Referenced by EDIT_ImeComposition().

4178 {
4179  LONG buflen;
4180  LPWSTR lpCompStr;
4181  LPSTR lpCompStrAttr = NULL;
4182  DWORD dwBufLenAttr;
4183 
4184  buflen = ImmGetCompositionStringW(hIMC, GCS_COMPSTR, NULL, 0);
4185 
4186  if (buflen < 0)
4187  {
4188  return;
4189  }
4190 
4191  lpCompStr = heap_alloc(buflen);
4192  if (!lpCompStr)
4193  {
4194  ERR("Unable to allocate IME CompositionString\n");
4195  return;
4196  }
4197 
4198  if (buflen)
4199  ImmGetCompositionStringW(hIMC, GCS_COMPSTR, lpCompStr, buflen);
4200 
4201  if (CompFlag & GCS_COMPATTR)
4202  {
4203  /*
4204  * We do not use the attributes yet. it would tell us what characters
4205  * are in transition and which are converted or decided upon
4206  */
4207  dwBufLenAttr = ImmGetCompositionStringW(hIMC, GCS_COMPATTR, NULL, 0);
4208  if (dwBufLenAttr)
4209  {
4210  dwBufLenAttr ++;
4211  lpCompStrAttr = heap_alloc(dwBufLenAttr + 1);
4212  if (!lpCompStrAttr)
4213  {
4214  ERR("Unable to allocate IME Attribute String\n");
4215  heap_free(lpCompStr);
4216  return;
4217  }
4218  ImmGetCompositionStringW(hIMC,GCS_COMPATTR, lpCompStrAttr,
4219  dwBufLenAttr);
4220  lpCompStrAttr[dwBufLenAttr] = 0;
4221  }
4222  }
4223 
4224  /* check for change in composition start */
4225  if (es->selection_end < es->composition_start)
4226  es->composition_start = es->selection_end;
4227 
4228  /* replace existing selection string */
4230 
4231  if (es->composition_len > 0)
4233  else
4234  es->selection_end = es->selection_start;
4235 
4236  EDIT_EM_ReplaceSel(es, FALSE, lpCompStr, buflen / sizeof(WCHAR), TRUE, TRUE);
4238 
4241 
4242  heap_free(lpCompStrAttr);
4243  heap_free(lpCompStr);
4244 }
#define abs(i)
Definition: fconv.c:206
#define TRUE
Definition: types.h:120
UINT composition_len
Definition: edit.c:147
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, const WCHAR *lpsz_replace, UINT strl, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2420
char * LPSTR
Definition: xmlstorage.h:182
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
INT selection_start
Definition: edit.c:114
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: imm.c:1466
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GCS_COMPATTR
Definition: imm.h:360
#define ERR(fmt,...)
Definition: debug.h:109
int composition_start
Definition: edit.c:148
INT selection_end
Definition: edit.c:115
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define GCS_COMPSTR
Definition: imm.h:359
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ EDIT_GetLineRect()

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

Definition at line 1131 of file edit.c.

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

1132 {
1134  INT line_index = 0;
1135  INT pt1, pt2, pt3;
1136 
1137  if (es->style & ES_MULTILINE)
1138  {
1139  const LINEDEF *line_def = NULL;
1140  rc->top = es->format_rect.top + (line - es->y_offset) * es->line_height;
1141  if (line >= es->line_count)
1142  return;
1143 
1144  line_def = es->first_line_def;
1145  if (line == -1) {
1146  INT index = es->selection_end - line_def->length;
1147  while ((index >= 0) && line_def->next) {
1148  line_index += line_def->length;
1149  line_def = line_def->next;
1150  index -= line_def->length;
1151  }
1152  } else {
1153  while (line > 0) {
1154  line_index += line_def->length;
1155  line_def = line_def->next;
1156  line--;
1157  }
1158  }
1159  ssa = line_def->ssa;
1160  }
1161  else
1162  {
1163  line_index = 0;
1164  rc->top = es->format_rect.top;
1165  ssa = es->ssa;
1166  }
1167 
1168  rc->bottom = rc->top + es->line_height;
1169  pt1 = (scol == 0) ? es->format_rect.left : (short)LOWORD(EDIT_EM_PosFromChar(es, line_index + scol, TRUE));
1170  pt2 = (ecol == -1) ? es->format_rect.right : (short)LOWORD(EDIT_EM_PosFromChar(es, line_index + ecol, TRUE));
1171  if (ssa)
1172  {
1173  ScriptStringCPtoX(ssa, scol, FALSE, &pt3);
1174  pt3+=es->format_rect.left;
1175  }
1176  else pt3 = pt1;
1177  rc->right = max(max(pt1 , pt2),pt3);
1178  rc->left = min(min(pt1, pt2),pt3);
1179 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
INT line_height
Definition: edit.c:106
LINEDEF * first_line_def
Definition: edit.c:141
#define ES_MULTILINE
Definition: pedump.c:667
INT line_count
Definition: edit.c:125
LONG top
Definition: windef.h:297
DWORD style
Definition: edit.c:108
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1005
Definition: parser.c:48
GLuint index
Definition: glext.h:6031
if(!(yy_init))
Definition: macro.lex.yy.c:717
struct tagLINEDEF * next
Definition: edit.c:94
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:153
RECT format_rect
Definition: edit.c:119
INT y_offset
Definition: edit.c:126
#define min(a, b)
Definition: monoChain.cc:55
INT selection_end
Definition: edit.c:115
LONG bottom
Definition: windef.h:299
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int *pX)
Definition: usp10.c:2409
#define LOWORD(l)
Definition: pedump.c:82
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:93
INT length
Definition: edit.c:88

◆ EDIT_GetResultStr()

static void EDIT_GetResultStr ( HIMC  hIMC,
EDITSTATE es 
)
static

Definition at line 4246 of file edit.c.

Referenced by EDIT_ImeComposition().

4247 {
4248  LONG buflen;
4249  LPWSTR lpResultStr;
4250 
4251  buflen = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
4252  if (buflen <= 0)
4253  {
4254  return;
4255  }
4256 
4257  lpResultStr = heap_alloc(buflen);
4258  if (!lpResultStr)
4259  {
4260  ERR("Unable to alloc buffer for IME string\n");
4261  return;
4262  }
4263 
4264  ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpResultStr, buflen);
4265 
4266  /* check for change in composition start */
4267  if (es->selection_end < es->composition_start)
4268  es->composition_start = es->selection_end;
4269 
4272  EDIT_EM_ReplaceSel(es, TRUE, lpResultStr, buflen / sizeof(WCHAR), TRUE, TRUE);
4273  es->composition_start = es->selection_end;
4274  es->composition_len = 0;
4275 
4276  heap_free(lpResultStr);
4277 }
#define TRUE
Definition: types.h:120
UINT composition_len
Definition: edit.c:147
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, const WCHAR *lpsz_replace, UINT strl, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2420
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
INT selection_start
Definition: edit.c:114
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define GCS_RESULTSTR
Definition: imm.h:366
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: imm.c:1466
#define ERR(fmt,...)
Definition: debug.h:109
int composition_start
Definition: edit.c:148
INT selection_end
Definition: edit.c:115
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ EDIT_ImeComposition()

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

Definition at line 4279 of file edit.c.

Referenced by EDIT_WindowProc().

4280 {
4281  HIMC hIMC;
4282  int cursor;
4283 
4284  if (es->composition_len == 0 && es->selection_start != es->selection_end)
4285  {
4286  EDIT_EM_ReplaceSel(es, TRUE, NULL, 0, TRUE, TRUE);
4287  es->composition_start = es->selection_end;
4288  }
4289 
4290  hIMC = ImmGetContext(hwnd);
4291  if (!hIMC)
4292  return;
4293 
4294  if (CompFlag & GCS_RESULTSTR)
4295  {
4296  EDIT_GetResultStr(hIMC, es);
4297  cursor = 0;
4298  }
4299  else
4300  {
4301  if (CompFlag & GCS_COMPSTR)
4302  EDIT_GetCompositionStr(hIMC, CompFlag, es);
4303  cursor = ImmGetCompositionStringW(hIMC, GCS_CURSORPOS, 0, 0);
4304  }
4305  ImmReleaseContext(hwnd, hIMC);
4306  EDIT_SetCaretPos(es, es->selection_start + cursor, es->flags & EF_AFTER_WRAP);
4307 }
#define TRUE
Definition: types.h:120
UINT composition_len
Definition: edit.c:147
static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, const WCHAR *lpsz_replace, UINT strl, BOOL send_update, BOOL honor_limit)
Definition: edit.c:2420
static void EDIT_SetCaretPos(EDITSTATE *es, INT pos, BOOL after_wrap)
Definition: edit.c:1707
#define GCS_CURSORPOS
Definition: imm.h:362
INT selection_start
Definition: edit.c:114
#define EF_AFTER_WRAP
Definition: edit.c:71
static void EDIT_GetResultStr(HIMC hIMC, EDITSTATE *es)
Definition: edit.c:4246
smooth NULL
Definition: ftsmooth.c:416
#define GCS_RESULTSTR
Definition: imm.h:366
DWORD HIMC
Definition: dimm.idl:75
static void EDIT_GetCompositionStr(HIMC hIMC, LPARAM CompFlag, EDITSTATE *es)
Definition: edit.c:4177
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: imm.c:1466
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1493
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:2250
WORD flags
Definition: edit.c:109
const char cursor[]
Definition: icontest.c:13
int composition_start
Definition: edit.c:148
INT selection_end
Definition: edit.c:115
#define GCS_COMPSTR
Definition: imm.h:359

◆ EDIT_InvalidateText()

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

Definition at line 1443 of file edit.c.

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

1444 {
1445  if (end == start)
1446  return;
1447 
1448  if (end == -1)
1449  end = get_text_length(es);
1450 
1451  if (end < start) {
1452  INT tmp = start;
1453  start = end;
1454  end = tmp;
1455  }
1456 
1457  if (es->style & ES_MULTILINE)
1459  else
1461 }
#define ES_MULTILINE
Definition: pedump.c:667
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
DWORD style
Definition: edit.c:108
GLuint GLuint end
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:56
GLuint start
Definition: gl.h:1545
static void EDIT_ML_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1378
static void EDIT_SL_InvalidateText(EDITSTATE *es, INT start, INT end)
Definition: edit.c:1360

◆ EDIT_InvalidateUniscribeData()

static void EDIT_InvalidateUniscribeData ( EDITSTATE es)
inlinestatic

Definition at line 311 of file edit.c.

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().

312 {
313  LINEDEF *line_def = es->first_line_def;
314  while (line_def)
315  {
317  line_def = line_def->next;
318  }
319  if (es->ssa)
320  {
321  ScriptStringFree(&es->ssa);
322  es->ssa = NULL;
323  }
324 }
LINEDEF * first_line_def
Definition: edit.c:141
static void EDIT_InvalidateUniscribeData_linedef(LINEDEF *line_def)
Definition: edit.c:302
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:2554
struct tagLINEDEF * next
Definition: edit.c:94
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:153

◆ EDIT_InvalidateUniscribeData_linedef()

static void EDIT_InvalidateUniscribeData_linedef ( LINEDEF line_def)
inlinestatic

Definition at line 302 of file edit.c.

Referenced by EDIT_BuildLineDefs_ML(), and EDIT_InvalidateUniscribeData().

303 {
304  if (line_def->ssa)
305  {
306  ScriptStringFree(&line_def->ssa);
307  line_def->ssa = NULL;
308  }
309 }
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:2554
SCRIPT_STRING_ANALYSIS ssa
Definition: edit.c:93

◆ EDIT_IsInsideDialog()

static BOOL EDIT_IsInsideDialog ( EDITSTATE es)
inlinestatic

Definition at line 2886 of file edit.c.

Referenced by EDIT_WM_Char(), and EDIT_WM_KeyDown().

2887 {
2888  return (es->flags & EF_DIALOGMODE);
2889 }
#define EF_DIALOGMODE
Definition: edit.c:74
WORD flags
Definition: edit.c:109

◆ EDIT_LockBuffer()

static void EDIT_LockBuffer ( EDITSTATE es)
static

Definition at line 1195 of file edit.c.

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

1196 {
1197  if (!es->text)
1198  {
1199  if (!es->hloc32W)
1200  return;
1201 
1202  es->text = LocalLock(es->hloc32W);
1203  }
1204 
1205  es->lock_count++;
1206 }
HLOCAL hloc32W
Definition: edit.c:142
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1599
INT lock_count
Definition: edit.c:138
LPWSTR text
Definition: edit.c:99

◆ EDIT_MakeFit()

static BOOL EDIT_MakeFit ( EDITSTATE es,
UINT  size 
)
static

Definition at line 1260 of file edit.c.

Referenced by EDIT_EM_ReplaceSel().

1261 {
1262  HLOCAL hNew32W;
1263 
1264  if (size <= es->buffer_size)
1265  return TRUE;
1266 
1267  TRACE("trying to ReAlloc to %d+1 characters\n", size);
1268 
1269  /* Force edit to unlock its buffer. es->text now NULL */
1270  EDIT_UnlockBuffer(es, TRUE);
1271 
1272  if (es->hloc32W) {
1273  UINT alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1274  if ((hNew32W = LocalReAlloc(es->hloc32W, alloc_size, LMEM_MOVEABLE | LMEM_ZEROINIT))) {
1275  TRACE("Old 32 bit handle %p, new handle %p\n", es->hloc32W, hNew32W);
1276  es->hloc32W = hNew32W;
1277  es->buffer_size = LocalSize(hNew32W)/sizeof(WCHAR) - 1;
1278  }
1279  }
1280 
1281  EDIT_LockBuffer(es);
1282 
1283  if (es->buffer_size < size) {
1284  WARN("FAILED ! We now have %d+1\n", es->buffer_size);
1286  return FALSE;
1287  } else {
1288  TRACE("We now have %d+1\n", es->buffer_size);
1289  return TRUE;
1290  }
1291 }
#define TRUE
Definition: types.h:120
#define ROUND_TO_GROW(size)
Definition: edit.c:60
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WARN(fmt,...)
Definition: debug.h:111
#define EDIT_NOTIFY_PARENT(es, wNotifyCode)
Definition: edit.c:161
SIZE_T NTAPI LocalSize(HLOCAL hMem)
Definition: heapmem.c:1777
static void EDIT_LockBuffer(EDITSTATE *es)
Definition: edit.c:1195
#define WCHAR
Definition: msvc.h:43
static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
Definition: edit.c:1214
#define EN_ERRSPACE
Definition: winuser.h:1984
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define LMEM_ZEROINIT
Definition: winbase.h:356
HLOCAL hloc32W
Definition: edit.c:142
UINT buffer_size
Definition: edit.c:101
unsigned int UINT
Definition: ndis.h:50
#define LMEM_MOVEABLE
Definition: winbase.h:350
HLOCAL NTAPI LocalReAlloc(HLOCAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:1608

◆ EDIT_MakeUndoFit()

static BOOL EDIT_MakeUndoFit ( EDITSTATE es,
UINT  size 
)
static

Definition at line 1301 of file edit.c.

Referenced by EDIT_EM_ReplaceSel().

1302 {
1303  UINT alloc_size;
1304 
1305  if (size <= es->undo_buffer_size)
1306  return TRUE;
1307 
1308  TRACE("trying to ReAlloc to %d+1\n", size);
1309 
1310  alloc_size = ROUND_TO_GROW((size + 1) * sizeof(WCHAR));
1311  if ((es->undo_text = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, es->undo_text, alloc_size))) {
1312  es->undo_buffer_size = alloc_size/sizeof(WCHAR) - 1;
1313  return TRUE;
1314  }
1315  else
1316  {
1317  WARN("FAILED ! We now have %d+1\n", es->undo_buffer_size);
1318  return FALSE;
1319  }
1320 }
LPWSTR undo_text
Definition: edit.c:112
#define TRUE
Definition: types.h:120
#define ROUND_TO_GROW(size)
Definition: edit.c:60
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WARN(fmt,...)
Definition: debug.h:111
#define WCHAR
Definition: msvc.h:43
UINT undo_buffer_size
Definition: edit.c:113
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
unsigned int UINT
Definition: ndis.h:50
#define HeapReAlloc
Definition: compat.h:393
#define HEAP_ZERO_MEMORY
Definition: compat.h:123

◆ EDIT_ML_InvalidateText()

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

Definition at line 1378 of file edit.c.

Referenced by EDIT_InvalidateText().

1379 {
1380  INT vlc = get_vertical_line_count(es);
1381  INT sl = EDIT_EM_LineFromChar(es, start);
1382  INT el = EDIT_EM_LineFromChar(es, end);
1383  INT sc;
1384  INT ec;
1385  RECT rc1;
1386  RECT rcWnd;
1387  RECT rcLine;
1388  RECT rcUpdate;
1389  INT l;
1390 
1391  if ((el < es->y_offset) || (sl > es->y_offset + vlc))
1392  return;
1393 
1394  sc = start - EDIT_EM_LineIndex(es, sl);
1395  ec = end - EDIT_EM_LineIndex(es, el);
1396  if (sl < es->y_offset) {
1397  sl = es->y_offset;
1398  sc = 0;
1399  }
1400  if (el > es->y_offset + vlc) {
1401  el = es->y_offset + vlc;
1402  ec = EDIT_EM_LineLength(es, EDIT_EM_LineIndex(es, el));
1403  }
1404  GetClientRect(es->hwndSelf, &rc1);
1405  IntersectRect(&rcWnd, &rc1, &es->format_rect);
1406  if (sl == el) {
1407  EDIT_GetLineRect(es, sl, sc, ec, &rcLine);
1408  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1409  EDIT_UpdateText(es, &rcUpdate, TRUE);
1410  } else {
1411  EDIT_GetLineRect(es, sl, sc,
1412  EDIT_EM_LineLength(es,
1413  EDIT_EM_LineIndex(es, sl)),
1414  &rcLine);
1415  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1416  EDIT_UpdateText(es, &rcUpdate, TRUE);
1417  for (l = sl + 1 ; l < el ; l++) {
1418  EDIT_GetLineRect(es, l, 0,
1419  EDIT_EM_LineLength(es,
1420  EDIT_EM_LineIndex(es, l)),
1421  &rcLine);
1422  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1423  EDIT_UpdateText(es, &rcUpdate, TRUE);
1424  }
1425  EDIT_GetLineRect(es, el, 0, ec, &rcLine);
1426  if (IntersectRect(&rcUpdate, &rcWnd, &rcLine))
1427  EDIT_UpdateText(es, &rcUpdate, TRUE);
1428  }
1429 }
static void EDIT_UpdateText(EDITSTATE *es, const RECT *rc, BOOL bErase)
Definition: edit.c:1343
static INT EDIT_EM_LineFromChar(EDITSTATE *es, INT index)
Definition: edit.c:905
#define TRUE
Definition: types.h:120
static INT get_vertical_line_count(EDITSTATE *es)
Definition: edit.c:410
GLuint GLuint end
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:56
static INT EDIT_EM_LineIndex(const EDITSTATE *es, INT line)
Definition: edit.c:934
static INT EDIT_EM_LineLength(EDITSTATE *es, INT index)
Definition: edit.c:969
r l[0]
Definition: byte_order.h:167
RECT format_rect
Definition: edit.c:119
INT y_offset
Definition: edit.c:126
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND hwndSelf
Definition: edit.c:129
GLuint start
Definition: gl.h:1545
static void EDIT_GetLineRect(EDITSTATE *es, INT line, INT scol, INT ecol, LPRECT rc)
Definition: edit.c:1131

◆ EDIT_MoveBackward()

static void EDIT_MoveBackward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1791 of file edit.c.

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

1792 {
1793  INT e = es->selection_end;
1794 
1795  if (e) {
1796  e--;
1797  if ((es->style & ES_MULTILINE) && e &&
1798  (es->text[e - 1] == '\r') && (es->text[e] == '\n')) {
1799  e--;
1800  if (e && (es->text[e - 1] == '\r'))
1801  e--;
1802  }
1803  }
1804  EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);
1805  EDIT_EM_ScrollCaret(es);
1806 }
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1473
#define ES_MULTILINE
Definition: pedump.c:667
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1721
DWORD style
Definition: edit.c:108
int32_t INT
Definition: typedefs.h:56
INT selection_start
Definition: edit.c:114
#define e
Definition: ke_i.h:82
INT selection_end
Definition: edit.c:115
LPWSTR text
Definition: edit.c:99

◆ EDIT_MoveDown_ML()

static void EDIT_MoveDown_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1818 of file edit.c.

Referenced by EDIT_WM_Char(), and EDIT_WM_KeyDown().

1819 {
1820  INT s = es->selection_start;
1821  INT e = es->selection_end;
1822  BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
1823  LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
1824  INT x = (short)LOWORD(pos);
1825  INT y = (short)HIWORD(pos);
1826 
1827  e = EDIT_CharFromPos(es, x, y + es->line_height, &after_wrap);
1828  if (!extend)
1829  s = e;
1830  EDIT_EM_SetSel(es, s, e, after_wrap);
1831  EDIT_EM_ScrollCaret(es);
1832 }
INT line_height
Definition: edit.c:106
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1473
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1721
int32_t INT
Definition: typedefs.h:56
INT INT y
Definition: msvc.h:62
INT selection_start
Definition: edit.c:114
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
#define EF_AFTER_WRAP
Definition: edit.c:71
#define e
Definition: ke_i.h:82
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1005
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble s
Definition: gl.h:2039
WORD flags
Definition: edit.c:109
INT x
Definition: msvc.h:62
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:776
#define HIWORD(l)
Definition: typedefs.h:246
INT selection_end
Definition: edit.c:115
LONG_PTR LRESULT
Definition: windef.h:209
#define LOWORD(l)
Definition: pedump.c:82

◆ EDIT_MoveEnd()

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

Definition at line 1840 of file edit.c.

Referenced by EDIT_WM_KeyDown().

1841 {
1842  BOOL after_wrap = FALSE;
1843  INT e;
1844 
1845  /* Pass a high value in x to make sure of receiving the end of the line */
1846  if (!ctrl && (es->style & ES_MULTILINE))
1847  e = EDIT_CharFromPos(es, 0x3fffffff,
1848  HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap);
1849  else
1850  e = get_text_length(es);
1851  EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, after_wrap);
1852  EDIT_EM_ScrollCaret(es);
1853 }
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1473
#define ES_MULTILINE
Definition: pedump.c:667
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1721
static UINT get_text_length(EDITSTATE *es)
Definition: edit.c:212
DWORD style
Definition: edit.c:108
int32_t INT
Definition: typedefs.h:56
INT selection_start
Definition: edit.c:114
#define EF_AFTER_WRAP
Definition: edit.c:71
#define e
Definition: ke_i.h:82
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1005
#define ctrl
Definition: input.c:1669
unsigned int BOOL
Definition: ntddk_ex.h:94
WORD flags
Definition: edit.c:109
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:776
#define HIWORD(l)
Definition: typedefs.h:246
INT selection_end
Definition: edit.c:115

◆ EDIT_MoveForward()

static void EDIT_MoveForward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1861 of file edit.c.

Referenced by EDIT_WM_KeyDown(), and EDIT_WM_Timer().

1862 {
1863  INT e = es->selection_end;
1864 
1865  if (es->text[e]) {
1866  e++;
1867  if ((es->style & ES_MULTILINE) && (es->text[e - 1] == '\r')) {
1868  if (es->text[e] == '\n')
1869  e++;
1870  else if ((es->text[e] == '\r') && (es->text[e + 1] == '\n'))
1871  e += 2;
1872  }
1873  }
1874  EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);
1875  EDIT_EM_ScrollCaret(es);
1876 }
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1473
#define ES_MULTILINE
Definition: pedump.c:667
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1721
DWORD style
Definition: edit.c:108
int32_t INT
Definition: typedefs.h:56
INT selection_start
Definition: edit.c:114
#define e
Definition: ke_i.h:82
INT selection_end
Definition: edit.c:115
LPWSTR text
Definition: edit.c:99

◆ EDIT_MoveHome()

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

Definition at line 1886 of file edit.c.

Referenced by EDIT_WM_Char(), and EDIT_WM_KeyDown().

1887 {
1888  INT e;
1889 
1890  /* Pass the x_offset in x to make sure of receiving the first position of the line */
1891  if (!ctrl && (es->style & ES_MULTILINE))
1892  e = EDIT_CharFromPos(es, -es->x_offset,
1894  else
1895  e = 0;
1896  EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);
1897  EDIT_EM_ScrollCaret(es);
1898 }
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1473
#define ES_MULTILINE
Definition: pedump.c:667
INT x_offset
Definition: edit.c:104
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1721
DWORD style
Definition: edit.c:108
int32_t INT
Definition: typedefs.h:56
INT selection_start
Definition: edit.c:114
#define EF_AFTER_WRAP
Definition: edit.c:71
#define e
Definition: ke_i.h:82
smooth NULL
Definition: ftsmooth.c:416
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1005
#define ctrl
Definition: input.c:1669
WORD flags
Definition: edit.c:109
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:776
#define HIWORD(l)
Definition: typedefs.h:246
INT selection_end
Definition: edit.c:115

◆ EDIT_MovePageDown_ML()

static void EDIT_MovePageDown_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1910 of file edit.c.

Referenced by EDIT_WM_KeyDown().

1911 {
1912  INT s = es->selection_start;
1913  INT e = es->selection_end;
1914  BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
1915  LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
1916  INT x = (short)LOWORD(pos);
1917  INT y = (short)HIWORD(pos);
1918 
1919  e = EDIT_CharFromPos(es, x,
1920  y + (es->format_rect.bottom - es->format_rect.top),
1921  &after_wrap);
1922  if (!extend)
1923  s = e;
1924  EDIT_EM_SetSel(es, s, e, after_wrap);
1925  EDIT_EM_ScrollCaret(es);
1926 }
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1473
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1721
LONG top
Definition: windef.h:297
int32_t INT
Definition: typedefs.h:56
INT INT y
Definition: msvc.h:62
INT selection_start
Definition: edit.c:114
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
#define EF_AFTER_WRAP
Definition: edit.c:71
#define e
Definition: ke_i.h:82
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1005
unsigned int BOOL
Definition: ntddk_ex.h:94
RECT format_rect
Definition: edit.c:119
GLdouble s
Definition: gl.h:2039
WORD flags
Definition: edit.c:109
INT x
Definition: msvc.h:62
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:776
#define HIWORD(l)
Definition: typedefs.h:246
INT selection_end
Definition: edit.c:115
LONG bottom
Definition: windef.h:299
LONG_PTR LRESULT
Definition: windef.h:209
#define LOWORD(l)
Definition: pedump.c:82

◆ EDIT_MovePageUp_ML()

static void EDIT_MovePageUp_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1938 of file edit.c.

Referenced by EDIT_WM_KeyDown().

1939 {
1940  INT s = es->selection_start;
1941  INT e = es->selection_end;
1942  BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
1943  LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
1944  INT x = (short)LOWORD(pos);
1945  INT y = (short)HIWORD(pos);
1946 
1947  e = EDIT_CharFromPos(es, x,
1948  y - (es->format_rect.bottom - es->format_rect.top),
1949  &after_wrap);
1950  if (!extend)
1951  s = e;
1952  EDIT_EM_SetSel(es, s, e, after_wrap);
1953  EDIT_EM_ScrollCaret(es);
1954 }
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1473
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1721
LONG top
Definition: windef.h:297
int32_t INT
Definition: typedefs.h:56
INT INT y
Definition: msvc.h:62
INT selection_start
Definition: edit.c:114
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
#define EF_AFTER_WRAP
Definition: edit.c:71
#define e
Definition: ke_i.h:82
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1005
unsigned int BOOL
Definition: ntddk_ex.h:94
RECT format_rect
Definition: edit.c:119
GLdouble s
Definition: gl.h:2039
WORD flags
Definition: edit.c:109
INT x
Definition: msvc.h:62
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:776
#define HIWORD(l)
Definition: typedefs.h:246
INT selection_end
Definition: edit.c:115
LONG bottom
Definition: windef.h:299
LONG_PTR LRESULT
Definition: windef.h:209
#define LOWORD(l)
Definition: pedump.c:82

◆ EDIT_MoveUp_ML()

static void EDIT_MoveUp_ML ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1966 of file edit.c.

Referenced by EDIT_WM_KeyDown().

1967 {
1968  INT s = es->selection_start;
1969  INT e = es->selection_end;
1970  BOOL after_wrap = (es->flags & EF_AFTER_WRAP);
1971  LRESULT pos = EDIT_EM_PosFromChar(es, e, after_wrap);
1972  INT x = (short)LOWORD(pos);
1973  INT y = (short)HIWORD(pos);
1974 
1975  e = EDIT_CharFromPos(es, x, y - es->line_height, &after_wrap);
1976  if (!extend)
1977  s = e;
1978  EDIT_EM_SetSel(es, s, e, after_wrap);
1979  EDIT_EM_ScrollCaret(es);
1980 }
INT line_height
Definition: edit.c:106
static BOOL EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
Definition: edit.c:1473
static void EDIT_EM_ScrollCaret(EDITSTATE *es)
Definition: edit.c:1721
int32_t INT
Definition: typedefs.h:56
INT INT y
Definition: msvc.h:62
INT selection_start
Definition: edit.c:114
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
#define EF_AFTER_WRAP
Definition: edit.c:71
#define e
Definition: ke_i.h:82
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap)
Definition: edit.c:1005
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble s
Definition: gl.h:2039
WORD flags
Definition: edit.c:109
INT x
Definition: msvc.h:62
static INT EDIT_CharFromPos(EDITSTATE *es, INT x, INT y, LPBOOL after_wrap)
Definition: edit.c:776
#define HIWORD(l)
Definition: typedefs.h:246
INT selection_end
Definition: edit.c:115
LONG_PTR LRESULT
Definition: windef.h:209
#define LOWORD(l)
Definition: pedump.c:82

◆ EDIT_MoveWordBackward()

static void EDIT_MoveWordBackward ( EDITSTATE es,
BOOL  extend 
)
static

Definition at line 1988 of file edit.c.

Referenced by EDIT_WM_KeyDown().

1989 {
1990  INT s = es->selection_start;
1991  INT e = es->selection_end;
1992  INT l;
1993  INT ll;