ReactOS 0.4.15-dev-7953-g1f49173
editor.h File Reference
#include "editstr.h"
Include dependency graph for editor.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RUN_IS_HIDDEN(run)
 
#define InitFormatEtc(fe, cf, med)
 
#define CP_UNICODE   1200
 
#define TXTHOST_VTABLE(This)   (This)->lpVtbl
 
#define ITextHost_TxGetDC(This)   TXTHOST_VTABLE(This)->TxGetDC(This)
 
#define ITextHost_TxReleaseDC(This, a)   TXTHOST_VTABLE(This)->TxReleaseDC(This,a)
 
#define ITextHost_TxShowScrollBar(This, a, b)   TXTHOST_VTABLE(This)->TxShowScrollBar(This,a,b)
 
#define ITextHost_TxEnableScrollBar(This, a, b)   TXTHOST_VTABLE(This)->TxEnableScrollBar(This,a,b)
 
#define ITextHost_TxSetScrollRange(This, a, b, c, d)   TXTHOST_VTABLE(This)->TxSetScrollRange(This,a,b,c,d)
 
#define ITextHost_TxSetScrollPos(This, a, b, c)   TXTHOST_VTABLE(This)->TxSetScrollPos(This,a,b,c)
 
#define ITextHost_TxInvalidateRect(This, a, b)   TXTHOST_VTABLE(This)->TxInvalidateRect(This,a,b)
 
#define ITextHost_TxViewChange(This, a)   TXTHOST_VTABLE(This)->TxViewChange(This,a)
 
#define ITextHost_TxCreateCaret(This, a, b, c)   TXTHOST_VTABLE(This)->TxCreateCaret(This,a,b,c)
 
#define ITextHost_TxShowCaret(This, a)   TXTHOST_VTABLE(This)->TxShowCaret(This,a)
 
#define ITextHost_TxSetCaretPos(This, a, b)   TXTHOST_VTABLE(This)->TxSetCaretPos(This,a,b)
 
#define ITextHost_TxSetTimer(This, a, b)   TXTHOST_VTABLE(This)->TxSetTimer(This,a,b)
 
#define ITextHost_TxKillTimer(This, a)   TXTHOST_VTABLE(This)->TxKillTimer(This,a)
 
#define ITextHost_TxScrollWindowEx(This, a, b, c, d, e, f, g)   TXTHOST_VTABLE(This)->TxScrollWindowEx(This,a,b,c,d,e,f,g)
 
#define ITextHost_TxSetCapture(This, a)   TXTHOST_VTABLE(This)->TxSetCapture(This,a)
 
#define ITextHost_TxSetFocus(This)   TXTHOST_VTABLE(This)->TxSetFocus(This)
 
#define ITextHost_TxSetCursor(This, a, b)   TXTHOST_VTABLE(This)->TxSetCursor(This,a,b)
 
#define ITextHost_TxScreenToClient(This, a)   TXTHOST_VTABLE(This)->TxScreenToClient(This,a)
 
#define ITextHost_TxClientToScreen(This, a)   TXTHOST_VTABLE(This)->TxClientToScreen(This,a)
 
#define ITextHost_TxActivate(This, a)   TXTHOST_VTABLE(This)->TxActivate(This,a)
 
#define ITextHost_TxDeactivate(This, a)   TXTHOST_VTABLE(This)->TxDeactivate(This,a)
 
#define ITextHost_TxGetClientRect(This, a)   TXTHOST_VTABLE(This)->TxGetClientRect(This,a)
 
#define ITextHost_TxGetViewInset(This, a)   TXTHOST_VTABLE(This)->TxGetViewInset(This,a)
 
#define ITextHost_TxGetCharFormat(This, a)   TXTHOST_VTABLE(This)->TxGetCharFormat(This,a)
 
#define ITextHost_TxGetParaFormat(This, a)   TXTHOST_VTABLE(This)->TxGetParaFormat(This,a)
 
#define ITextHost_TxGetSysColor(This, a)   TXTHOST_VTABLE(This)->TxGetSysColor(This,a)
 
#define ITextHost_TxGetBackStyle(This, a)   TXTHOST_VTABLE(This)->TxGetBackStyle(This,a)
 
#define ITextHost_TxGetMaxLength(This, a)   TXTHOST_VTABLE(This)->TxGetMaxLength(This,a)
 
#define ITextHost_TxGetScrollBars(This, a)   TXTHOST_VTABLE(This)->TxGetScrollBars(This,a)
 
#define ITextHost_TxGetPasswordChar(This, a)   TXTHOST_VTABLE(This)->TxGetPasswordChar(This,a)
 
#define ITextHost_TxGetAcceleratorPos(This, a)   TXTHOST_VTABLE(This)->TxGetAcceleratorPos(This,a)
 
#define ITextHost_TxGetExtent(This, a)   TXTHOST_VTABLE(This)->TxGetExtent(This,a)
 
#define ITextHost_OnTxCharFormatChange(This, a)   TXTHOST_VTABLE(This)->OnTxCharFormatChange(This,a)
 
#define ITextHost_OnTxParaFormatChange(This, a)   TXTHOST_VTABLE(This)->OnTxParaFormatChange(This,a)
 
#define ITextHost_TxGetPropertyBits(This, a, b)   TXTHOST_VTABLE(This)->TxGetPropertyBits(This,a,b)
 
#define ITextHost_TxNotify(This, a, b)   TXTHOST_VTABLE(This)->TxNotify(This,a,b)
 
#define ITextHost_TxImmGetContext(This)   TXTHOST_VTABLE(This)->TxImmGetContext(This)
 
#define ITextHost_TxImmReleaseContext(This, a)   TXTHOST_VTABLE(This)->TxImmReleaseContext(This,a)
 
#define ITextHost_TxGetSelectionBarWidth(This, a)   TXTHOST_VTABLE(This)->TxGetSelectionBarWidth(This,a)
 

Functions

static WCHARget_text (const ME_Run *run, int offset)
 
static const chardebugstr_run (const ME_Run *run)
 
ME_StyleME_MakeStyle (CHARFORMAT2W *style) DECLSPEC_HIDDEN
 
void ME_AddRefStyle (ME_Style *item) DECLSPEC_HIDDEN
 
void ME_DestroyStyle (ME_Style *item) DECLSPEC_HIDDEN
 
void ME_ReleaseStyle (ME_Style *item) DECLSPEC_HIDDEN
 
ME_StyleME_GetInsertStyle (ME_TextEditor *editor, int nCursor) DECLSPEC_HIDDEN
 
ME_StyleME_ApplyStyle (ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style) DECLSPEC_HIDDEN
 
void select_style (ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN
 
void ME_InitCharFormat2W (CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
 
void ME_SaveTempStyle (ME_TextEditor *editor, ME_Style *style) DECLSPEC_HIDDEN
 
void ME_ClearTempStyle (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_DumpStyleToBuf (CHARFORMAT2W *pFmt, char buf[2048]) DECLSPEC_HIDDEN
 
void ME_DumpStyle (ME_Style *s) DECLSPEC_HIDDEN
 
BOOL cfany_to_cf2w (CHARFORMAT2W *to, const CHARFORMAT2W *from) DECLSPEC_HIDDEN
 
BOOL cf2w_to_cfany (CHARFORMAT2W *to, const CHARFORMAT2W *from) DECLSPEC_HIDDEN
 
void ME_CopyCharFormat (CHARFORMAT2W *pDest, const CHARFORMAT2W *pSrc) DECLSPEC_HIDDEN
 
void ME_CharFormatFromLogFont (HDC hDC, const LOGFONTW *lf, CHARFORMAT2W *fmt) DECLSPEC_HIDDEN
 
void ME_InsertBefore (ME_DisplayItem *diWhere, ME_DisplayItem *diWhat) DECLSPEC_HIDDEN
 
void ME_Remove (ME_DisplayItem *diWhere) DECLSPEC_HIDDEN
 
BOOL ME_NextRun (ME_DisplayItem **para, ME_DisplayItem **run, BOOL all_para) DECLSPEC_HIDDEN
 
BOOL ME_PrevRun (ME_DisplayItem **para, ME_DisplayItem **run, BOOL all_para) DECLSPEC_HIDDEN
 
ME_DisplayItemME_FindItemBack (ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN
 
ME_DisplayItemME_FindItemFwd (ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN
 
ME_DisplayItemME_FindItemBackOrHere (ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN
 
ME_DisplayItemME_MakeDI (ME_DIType type) DECLSPEC_HIDDEN
 
void ME_DestroyDisplayItem (ME_DisplayItem *item) DECLSPEC_HIDDEN
 
void ME_DumpDocument (ME_TextBuffer *buffer) DECLSPEC_HIDDEN
 
void destroy_para (ME_TextEditor *editor, ME_DisplayItem *item) DECLSPEC_HIDDEN
 
ME_StringME_MakeStringN (LPCWSTR szText, int nMaxChars) DECLSPEC_HIDDEN
 
ME_StringME_MakeStringR (WCHAR cRepeat, int nMaxChars) DECLSPEC_HIDDEN
 
ME_StringME_MakeStringConst (const WCHAR *str, int len) DECLSPEC_HIDDEN
 
ME_StringME_MakeStringEmpty (int len) DECLSPEC_HIDDEN
 
void ME_DestroyString (ME_String *s) DECLSPEC_HIDDEN
 
BOOL ME_AppendString (ME_String *s, const WCHAR *append, int len) DECLSPEC_HIDDEN
 
ME_StringME_VSplitString (ME_String *orig, int nVPos) DECLSPEC_HIDDEN
 
int ME_FindNonWhitespaceV (const ME_String *s, int nVChar) DECLSPEC_HIDDEN
 
int ME_CallWordBreakProc (ME_TextEditor *editor, WCHAR *str, INT len, INT start, INT code) DECLSPEC_HIDDEN
 
void ME_StrDeleteV (ME_String *s, int nVChar, int nChars) DECLSPEC_HIDDEN
 
BOOL ME_InsertString (ME_String *s, int ofs, const WCHAR *insert, int len) DECLSPEC_HIDDEN
 
LPWSTR ME_ToUnicode (LONG codepage, LPVOID psz, INT *len) DECLSPEC_HIDDEN
 
void ME_EndToUnicode (LONG codepage, LPVOID psz) DECLSPEC_HIDDEN
 
static int ME_IsWSpace (WCHAR ch)
 
static int ME_CharCompare (WCHAR a, WCHAR b, int caseSensitive)
 
int ME_ReverseFindNonWhitespaceV (const ME_String *s, int nVChar) DECLSPEC_HIDDEN
 
int ME_ReverseFindWhitespaceV (const ME_String *s, int nVChar) DECLSPEC_HIDDEN
 
ME_DisplayItemME_RowStart (ME_DisplayItem *item) DECLSPEC_HIDDEN
 
ME_DisplayItemME_FindRowWithNumber (ME_TextEditor *editor, int nRow) DECLSPEC_HIDDEN
 
int ME_RowNumberFromCharOfs (ME_TextEditor *editor, int nOfs) DECLSPEC_HIDDEN
 
ME_DisplayItemME_MakeRun (ME_Style *s, int nFlags) DECLSPEC_HIDDEN
 
ME_DisplayItemME_InsertRunAtCursor (ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style, const WCHAR *str, int len, int flags) DECLSPEC_HIDDEN
 
void ME_CheckCharOffsets (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_PropagateCharOffset (ME_DisplayItem *p, int shift) DECLSPEC_HIDDEN
 
int ME_CharFromPointContext (ME_Context *c, int cx, ME_Run *run, BOOL closest, BOOL visual_order) DECLSPEC_HIDDEN
 
int ME_CharFromPoint (ME_TextEditor *editor, int cx, ME_Run *run, BOOL closest, BOOL visual_order) DECLSPEC_HIDDEN
 
int ME_PointFromCharContext (ME_Context *c, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN
 
int ME_PointFromChar (ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN
 
BOOL ME_CanJoinRuns (const ME_Run *run1, const ME_Run *run2) DECLSPEC_HIDDEN
 
void ME_JoinRuns (ME_TextEditor *editor, ME_DisplayItem *p) DECLSPEC_HIDDEN
 
ME_DisplayItemME_SplitRunSimple (ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN
 
void ME_UpdateRunFlags (ME_TextEditor *editor, ME_Run *run) DECLSPEC_HIDDEN
 
SIZE ME_GetRunSizeCommon (ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen, int startx, int *pAscent, int *pDescent) DECLSPEC_HIDDEN
 
void ME_CursorFromCharOfs (ME_TextEditor *editor, int nCharOfs, ME_Cursor *pCursor) DECLSPEC_HIDDEN
 
void ME_RunOfsFromCharOfs (ME_TextEditor *editor, int nCharOfs, ME_DisplayItem **ppPara, ME_DisplayItem **ppRun, int *pOfs) DECLSPEC_HIDDEN
 
int ME_CharOfsFromRunOfs (ME_TextEditor *editor, const ME_DisplayItem *pPara, const ME_DisplayItem *pRun, int nOfs) DECLSPEC_HIDDEN
 
void ME_SkipAndPropagateCharOffset (ME_DisplayItem *p, int shift) DECLSPEC_HIDDEN
 
void ME_SetCharFormat (ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
 
void ME_SetSelectionCharFormat (ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
 
void ME_GetCharFormat (ME_TextEditor *editor, const ME_Cursor *from, const ME_Cursor *to, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
 
void ME_GetSelectionCharFormat (ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
 
void ME_GetDefaultCharFormat (ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
 
void ME_SetDefaultCharFormat (ME_TextEditor *editor, CHARFORMAT2W *mod) DECLSPEC_HIDDEN
 
void ME_SetCursorToStart (ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN
 
int set_selection_cursors (ME_TextEditor *editor, int from, int to) DECLSPEC_HIDDEN
 
BOOL ME_MoveCursorWords (ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs) DECLSPEC_HIDDEN
 
void hide_caret (ME_TextEditor *ed) DECLSPEC_HIDDEN
 
void show_caret (ME_TextEditor *ed) DECLSPEC_HIDDEN
 
void update_caret (ME_TextEditor *ed) DECLSPEC_HIDDEN
 
void create_caret (ME_TextEditor *ed) DECLSPEC_HIDDEN
 
BOOL ME_CharFromPos (ME_TextEditor *editor, int x, int y, ME_Cursor *cursor, BOOL *isExact) DECLSPEC_HIDDEN
 
void ME_LButtonDown (ME_TextEditor *editor, int x, int y, int clickNum) DECLSPEC_HIDDEN
 
void ME_MouseMove (ME_TextEditor *editor, int x, int y) DECLSPEC_HIDDEN
 
BOOL ME_DeleteTextAtCursor (ME_TextEditor *editor, int nCursor, int nChars) DECLSPEC_HIDDEN
 
void ME_InsertTextFromCursor (ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style) DECLSPEC_HIDDEN
 
void ME_InsertEndRowFromCursor (ME_TextEditor *editor, int nCursor) DECLSPEC_HIDDEN
 
int ME_MoveCursorChars (ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BOOL final_eop) DECLSPEC_HIDDEN
 
BOOL ME_ArrowKey (ME_TextEditor *ed, int nVKey, BOOL extend, BOOL ctrl) DECLSPEC_HIDDEN
 
int ME_GetCursorOfs (const ME_Cursor *cursor) DECLSPEC_HIDDEN
 
int ME_GetSelectionOfs (ME_TextEditor *editor, int *from, int *to) DECLSPEC_HIDDEN
 
int ME_GetSelection (ME_TextEditor *editor, ME_Cursor **from, ME_Cursor **to) DECLSPEC_HIDDEN
 
BOOL ME_IsSelection (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_DeleteSelection (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_SendSelChange (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_InsertOLEFromCursor (ME_TextEditor *editor, const REOBJECT *reo, int nCursor) DECLSPEC_HIDDEN
 
BOOL ME_InternalDeleteText (ME_TextEditor *editor, ME_Cursor *start, int nChars, BOOL bForce) DECLSPEC_HIDDEN
 
int ME_GetTextLength (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
int ME_GetTextLengthEx (ME_TextEditor *editor, const GETTEXTLENGTHEX *how) DECLSPEC_HIDDEN
 
ME_StyleME_GetSelectionInsertStyle (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_GetCursorCoordinates (ME_TextEditor *editor, ME_Cursor *pCursor, int *x, int *y, int *height) DECLSPEC_HIDDEN
 
void ME_InitContext (ME_Context *c, ME_TextEditor *editor, HDC hDC) DECLSPEC_HIDDEN
 
void ME_DestroyContext (ME_Context *c) DECLSPEC_HIDDEN
 
BOOL ME_WrapMarkedParagraphs (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_InvalidateParagraphRange (ME_TextEditor *editor, ME_DisplayItem *start_para, ME_DisplayItem *last_para) DECLSPEC_HIDDEN
 
void ME_SendRequestResize (ME_TextEditor *editor, BOOL force) DECLSPEC_HIDDEN
 
ME_DisplayItemME_GetParagraph (ME_DisplayItem *run) DECLSPEC_HIDDEN
 
void ME_GetSelectionParas (ME_TextEditor *editor, ME_DisplayItem **para, ME_DisplayItem **para_end) DECLSPEC_HIDDEN
 
void ME_MakeFirstParagraph (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
ME_DisplayItemME_SplitParagraph (ME_TextEditor *editor, ME_DisplayItem *rp, ME_Style *style, const WCHAR *eol_str, int eol_len, int paraFlags) DECLSPEC_HIDDEN
 
ME_DisplayItemME_JoinParagraphs (ME_TextEditor *editor, ME_DisplayItem *tp, BOOL keepFirstParaFormat) DECLSPEC_HIDDEN
 
void ME_DumpParaStyle (ME_Paragraph *s) DECLSPEC_HIDDEN
 
void ME_DumpParaStyleToBuf (const PARAFORMAT2 *pFmt, char buf[2048]) DECLSPEC_HIDDEN
 
BOOL ME_SetSelectionParaFormat (ME_TextEditor *editor, const PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
 
void ME_GetSelectionParaFormat (ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
 
void ME_MarkAllForWrapping (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_SetDefaultParaFormat (ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
 
void para_num_init (ME_Context *c, ME_Paragraph *para) DECLSPEC_HIDDEN
 
void para_num_clear (struct para_num *pn) DECLSPEC_HIDDEN
 
int get_total_width (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void mark_para_rewrap (ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN
 
ME_DisplayItemget_di_from_para (ME_Paragraph *para) DECLSPEC_HIDDEN
 
void add_marked_para (ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN
 
void remove_marked_para (ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN
 
void ME_PaintContent (ME_TextEditor *editor, HDC hDC, const RECT *rcUpdate) DECLSPEC_HIDDEN
 
void ME_Repaint (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_RewrapRepaint (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_UpdateRepaint (ME_TextEditor *editor, BOOL update_now) DECLSPEC_HIDDEN
 
void ME_EnsureVisible (ME_TextEditor *editor, ME_Cursor *pCursor) DECLSPEC_HIDDEN
 
void ME_InvalidateSelection (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
BOOL ME_SetZoom (ME_TextEditor *editor, int numerator, int denominator) DECLSPEC_HIDDEN
 
int ME_twips2pointsX (const ME_Context *c, int x) DECLSPEC_HIDDEN
 
int ME_twips2pointsY (const ME_Context *c, int y) DECLSPEC_HIDDEN
 
void ME_ScrollAbs (ME_TextEditor *editor, int x, int y) DECLSPEC_HIDDEN
 
void ME_HScrollAbs (ME_TextEditor *editor, int x) DECLSPEC_HIDDEN
 
void ME_VScrollAbs (ME_TextEditor *editor, int y) DECLSPEC_HIDDEN
 
void ME_ScrollUp (ME_TextEditor *editor, int cy) DECLSPEC_HIDDEN
 
void ME_ScrollDown (ME_TextEditor *editor, int cy) DECLSPEC_HIDDEN
 
void ME_ScrollLeft (ME_TextEditor *editor, int cx) DECLSPEC_HIDDEN
 
void ME_ScrollRight (ME_TextEditor *editor, int cx) DECLSPEC_HIDDEN
 
void ME_UpdateScrollBar (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
int ME_GetParaBorderWidth (const ME_Context *c, int flags) DECLSPEC_HIDDEN
 
LRESULT CreateIRichEditOle (IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *ppvObj) DECLSPEC_HIDDEN
 
void ME_DrawOLE (ME_Context *c, int x, int y, ME_Run *run, BOOL selected) DECLSPEC_HIDDEN
 
void ME_GetOLEObjectSize (const ME_Context *c, ME_Run *run, SIZE *pSize) DECLSPEC_HIDDEN
 
void ME_CopyReObject (REOBJECT *dst, const REOBJECT *src, DWORD flags) DECLSPEC_HIDDEN
 
void ME_DeleteReObject (struct re_object *re_object) DECLSPEC_HIDDEN
 
ME_TextEditorME_MakeEditor (ITextHost *texthost, BOOL bEmulateVersion10) DECLSPEC_HIDDEN
 
void ME_DestroyEditor (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
LRESULT ME_HandleMessage (ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode, HRESULT *phresult) DECLSPEC_HIDDEN
 
void ME_SendOldNotify (ME_TextEditor *editor, int nCode) DECLSPEC_HIDDEN
 
int ME_GetTextW (ME_TextEditor *editor, WCHAR *buffer, int buflen, const ME_Cursor *start, int srcChars, BOOL bCRLF, BOOL bEOP) DECLSPEC_HIDDEN
 
void ME_RTFCharAttrHook (struct _RTF_Info *info) DECLSPEC_HIDDEN
 
void ME_RTFParAttrHook (struct _RTF_Info *info) DECLSPEC_HIDDEN
 
void ME_RTFTblAttrHook (struct _RTF_Info *info) DECLSPEC_HIDDEN
 
void ME_RTFSpecialCharHook (struct _RTF_Info *info) DECLSPEC_HIDDEN
 
void ME_StreamInFill (ME_InStream *stream) DECLSPEC_HIDDEN
 
void ME_ReplaceSel (ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len) DECLSPEC_HIDDEN
 
int set_selection (ME_TextEditor *editor, int to, int from) DECLSPEC_HIDDEN
 
BOOL ME_IsInTable (ME_DisplayItem *pItem) DECLSPEC_HIDDEN
 
ME_DisplayItemME_InsertTableRowStartFromCursor (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
ME_DisplayItemME_InsertTableRowStartAtParagraph (ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN
 
ME_DisplayItemME_InsertTableCellFromCursor (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
ME_DisplayItemME_InsertTableRowEndFromCursor (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
ME_DisplayItemME_GetTableRowEnd (ME_DisplayItem *para) DECLSPEC_HIDDEN
 
ME_DisplayItemME_GetTableRowStart (ME_DisplayItem *para) DECLSPEC_HIDDEN
 
ME_DisplayItemME_GetOuterParagraph (ME_DisplayItem *para) DECLSPEC_HIDDEN
 
void ME_CheckTablesForCorruption (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_ProtectPartialTableDeletion (ME_TextEditor *editor, ME_Cursor *c, int *nChars) DECLSPEC_HIDDEN
 
ME_DisplayItemME_AppendTableRow (ME_TextEditor *editor, ME_DisplayItem *table_row) DECLSPEC_HIDDEN
 
void ME_TabPressedInTable (ME_TextEditor *editor, BOOL bSelectedRow) DECLSPEC_HIDDEN
 
void ME_MoveCursorFromTableRowStartParagraph (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
struct RTFTableME_MakeTableDef (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_InitTableDef (ME_TextEditor *editor, struct RTFTable *tableDef) DECLSPEC_HIDDEN
 
ITextHost * ME_CreateTextHost (HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10) DECLSPEC_HIDDEN
 
BOOL add_undo_insert_run (ME_TextEditor *, int pos, const WCHAR *str, int len, int flags, ME_Style *style) DECLSPEC_HIDDEN
 
BOOL add_undo_delete_run (ME_TextEditor *, int pos, int len) DECLSPEC_HIDDEN
 
BOOL add_undo_set_para_fmt (ME_TextEditor *, const ME_Paragraph *para) DECLSPEC_HIDDEN
 
BOOL add_undo_set_char_fmt (ME_TextEditor *, int pos, int len, const CHARFORMAT2W *fmt) DECLSPEC_HIDDEN
 
BOOL add_undo_join_paras (ME_TextEditor *, int pos) DECLSPEC_HIDDEN
 
BOOL add_undo_split_para (ME_TextEditor *, const ME_Paragraph *para, ME_String *eol_str, const ME_Cell *cell) DECLSPEC_HIDDEN
 
void ME_CommitUndo (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_ContinueCoalescingTransaction (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_CommitCoalescingUndo (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
BOOL ME_Undo (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
BOOL ME_Redo (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
void ME_EmptyUndoStack (ME_TextEditor *editor) DECLSPEC_HIDDEN
 
LRESULT ME_StreamOutRange (ME_TextEditor *editor, DWORD dwFormat, const ME_Cursor *start, int nChars, EDITSTREAM *stream) DECLSPEC_HIDDEN
 
LRESULT ME_StreamOut (ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream) DECLSPEC_HIDDEN
 
HRESULT ME_GetDataObject (ME_TextEditor *editor, const ME_Cursor *start, int nChars, LPDATAOBJECT *lplpdataobj) DECLSPEC_HIDDEN
 
void release_typelib (void) DECLSPEC_HIDDEN
 

Variables

HANDLE me_heap DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ CP_UNICODE

#define CP_UNICODE   1200

Definition at line 95 of file editor.h.

◆ InitFormatEtc

#define InitFormatEtc (   fe,
  cf,
  med 
)
Value:
{\
(fe).cfFormat=cf;\
(fe).dwAspect=DVASPECT_CONTENT;\
(fe).ptd=NULL;\
(fe).tymed=med;\
(fe).lindex=-1;\
};
#define NULL
Definition: types.h:112
static DWORD tymed
Definition: url.c:174

Definition at line 32 of file editor.h.

◆ ITextHost_OnTxCharFormatChange

#define ITextHost_OnTxCharFormatChange (   This,
  a 
)    TXTHOST_VTABLE(This)->OnTxCharFormatChange(This,a)

Definition at line 319 of file editor.h.

◆ ITextHost_OnTxParaFormatChange

#define ITextHost_OnTxParaFormatChange (   This,
  a 
)    TXTHOST_VTABLE(This)->OnTxParaFormatChange(This,a)

Definition at line 320 of file editor.h.

◆ ITextHost_TxActivate

#define ITextHost_TxActivate (   This,
  a 
)    TXTHOST_VTABLE(This)->TxActivate(This,a)

Definition at line 306 of file editor.h.

◆ ITextHost_TxClientToScreen

#define ITextHost_TxClientToScreen (   This,
  a 
)    TXTHOST_VTABLE(This)->TxClientToScreen(This,a)

Definition at line 305 of file editor.h.

◆ ITextHost_TxCreateCaret

#define ITextHost_TxCreateCaret (   This,
  a,
  b,
  c 
)    TXTHOST_VTABLE(This)->TxCreateCaret(This,a,b,c)

Definition at line 295 of file editor.h.

◆ ITextHost_TxDeactivate

#define ITextHost_TxDeactivate (   This,
  a 
)    TXTHOST_VTABLE(This)->TxDeactivate(This,a)

Definition at line 307 of file editor.h.

◆ ITextHost_TxEnableScrollBar

#define ITextHost_TxEnableScrollBar (   This,
  a,
  b 
)    TXTHOST_VTABLE(This)->TxEnableScrollBar(This,a,b)

Definition at line 290 of file editor.h.

◆ ITextHost_TxGetAcceleratorPos

#define ITextHost_TxGetAcceleratorPos (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetAcceleratorPos(This,a)

Definition at line 317 of file editor.h.

◆ ITextHost_TxGetBackStyle

#define ITextHost_TxGetBackStyle (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetBackStyle(This,a)

Definition at line 313 of file editor.h.

◆ ITextHost_TxGetCharFormat

#define ITextHost_TxGetCharFormat (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetCharFormat(This,a)

Definition at line 310 of file editor.h.

◆ ITextHost_TxGetClientRect

#define ITextHost_TxGetClientRect (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetClientRect(This,a)

Definition at line 308 of file editor.h.

◆ ITextHost_TxGetDC

#define ITextHost_TxGetDC (   This)    TXTHOST_VTABLE(This)->TxGetDC(This)

Definition at line 287 of file editor.h.

◆ ITextHost_TxGetExtent

#define ITextHost_TxGetExtent (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetExtent(This,a)

Definition at line 318 of file editor.h.

◆ ITextHost_TxGetMaxLength

#define ITextHost_TxGetMaxLength (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetMaxLength(This,a)

Definition at line 314 of file editor.h.

◆ ITextHost_TxGetParaFormat

#define ITextHost_TxGetParaFormat (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetParaFormat(This,a)

Definition at line 311 of file editor.h.

◆ ITextHost_TxGetPasswordChar

#define ITextHost_TxGetPasswordChar (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetPasswordChar(This,a)

Definition at line 316 of file editor.h.

◆ ITextHost_TxGetPropertyBits

#define ITextHost_TxGetPropertyBits (   This,
  a,
  b 
)    TXTHOST_VTABLE(This)->TxGetPropertyBits(This,a,b)

Definition at line 321 of file editor.h.

◆ ITextHost_TxGetScrollBars

#define ITextHost_TxGetScrollBars (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetScrollBars(This,a)

Definition at line 315 of file editor.h.

◆ ITextHost_TxGetSelectionBarWidth

#define ITextHost_TxGetSelectionBarWidth (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetSelectionBarWidth(This,a)

Definition at line 325 of file editor.h.

◆ ITextHost_TxGetSysColor

#define ITextHost_TxGetSysColor (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetSysColor(This,a)

Definition at line 312 of file editor.h.

◆ ITextHost_TxGetViewInset

#define ITextHost_TxGetViewInset (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetViewInset(This,a)

Definition at line 309 of file editor.h.

◆ ITextHost_TxImmGetContext

#define ITextHost_TxImmGetContext (   This)    TXTHOST_VTABLE(This)->TxImmGetContext(This)

Definition at line 323 of file editor.h.

◆ ITextHost_TxImmReleaseContext

#define ITextHost_TxImmReleaseContext (   This,
  a 
)    TXTHOST_VTABLE(This)->TxImmReleaseContext(This,a)

Definition at line 324 of file editor.h.

◆ ITextHost_TxInvalidateRect

#define ITextHost_TxInvalidateRect (   This,
  a,
  b 
)    TXTHOST_VTABLE(This)->TxInvalidateRect(This,a,b)

Definition at line 293 of file editor.h.

◆ ITextHost_TxKillTimer

#define ITextHost_TxKillTimer (   This,
  a 
)    TXTHOST_VTABLE(This)->TxKillTimer(This,a)

Definition at line 299 of file editor.h.

◆ ITextHost_TxNotify

#define ITextHost_TxNotify (   This,
  a,
  b 
)    TXTHOST_VTABLE(This)->TxNotify(This,a,b)

Definition at line 322 of file editor.h.

◆ ITextHost_TxReleaseDC

#define ITextHost_TxReleaseDC (   This,
  a 
)    TXTHOST_VTABLE(This)->TxReleaseDC(This,a)

Definition at line 288 of file editor.h.

◆ ITextHost_TxScreenToClient

#define ITextHost_TxScreenToClient (   This,
  a 
)    TXTHOST_VTABLE(This)->TxScreenToClient(This,a)

Definition at line 304 of file editor.h.

◆ ITextHost_TxScrollWindowEx

#define ITextHost_TxScrollWindowEx (   This,
  a,
  b,
  c,
  d,
  e,
  f,
  g 
)    TXTHOST_VTABLE(This)->TxScrollWindowEx(This,a,b,c,d,e,f,g)

Definition at line 300 of file editor.h.

◆ ITextHost_TxSetCapture

#define ITextHost_TxSetCapture (   This,
  a 
)    TXTHOST_VTABLE(This)->TxSetCapture(This,a)

Definition at line 301 of file editor.h.

◆ ITextHost_TxSetCaretPos

#define ITextHost_TxSetCaretPos (   This,
  a,
  b 
)    TXTHOST_VTABLE(This)->TxSetCaretPos(This,a,b)

Definition at line 297 of file editor.h.

◆ ITextHost_TxSetCursor

#define ITextHost_TxSetCursor (   This,
  a,
  b 
)    TXTHOST_VTABLE(This)->TxSetCursor(This,a,b)

Definition at line 303 of file editor.h.

◆ ITextHost_TxSetFocus

#define ITextHost_TxSetFocus (   This)    TXTHOST_VTABLE(This)->TxSetFocus(This)

Definition at line 302 of file editor.h.

◆ ITextHost_TxSetScrollPos

#define ITextHost_TxSetScrollPos (   This,
  a,
  b,
  c 
)    TXTHOST_VTABLE(This)->TxSetScrollPos(This,a,b,c)

Definition at line 292 of file editor.h.

◆ ITextHost_TxSetScrollRange

#define ITextHost_TxSetScrollRange (   This,
  a,
  b,
  c,
  d 
)    TXTHOST_VTABLE(This)->TxSetScrollRange(This,a,b,c,d)

Definition at line 291 of file editor.h.

◆ ITextHost_TxSetTimer

#define ITextHost_TxSetTimer (   This,
  a,
  b 
)    TXTHOST_VTABLE(This)->TxSetTimer(This,a,b)

Definition at line 298 of file editor.h.

◆ ITextHost_TxShowCaret

#define ITextHost_TxShowCaret (   This,
  a 
)    TXTHOST_VTABLE(This)->TxShowCaret(This,a)

Definition at line 296 of file editor.h.

◆ ITextHost_TxShowScrollBar

#define ITextHost_TxShowScrollBar (   This,
  a,
  b 
)    TXTHOST_VTABLE(This)->TxShowScrollBar(This,a,b)

Definition at line 289 of file editor.h.

◆ ITextHost_TxViewChange

#define ITextHost_TxViewChange (   This,
  a 
)    TXTHOST_VTABLE(This)->TxViewChange(This,a)

Definition at line 294 of file editor.h.

◆ RUN_IS_HIDDEN

#define RUN_IS_HIDDEN (   run)
Value:
((run)->style->fmt.dwMask & CFM_HIDDEN \
&& (run)->style->fmt.dwEffects & CFE_HIDDEN)
Arabic default style
Definition: afstyles.h:94
#define CFE_HIDDEN
Definition: richedit.h:418
#define CFM_HIDDEN
Definition: richedit.h:340

Definition at line 29 of file editor.h.

◆ TXTHOST_VTABLE

#define TXTHOST_VTABLE (   This)    (This)->lpVtbl

Definition at line 284 of file editor.h.

Function Documentation

◆ add_marked_para()

void add_marked_para ( ME_TextEditor editor,
ME_DisplayItem para 
)

Definition at line 112 of file para.c.

113{
114 ME_DisplayItem *iter = editor->first_marked_para;
115
116 if (!iter)
117 {
118 editor->first_marked_para = di;
119 return;
120 }
121 while (iter)
122 {
123 if (iter == di)
124 return;
125 else if (di->member.para.nCharOfs < iter->member.para.nCharOfs)
126 {
127 if (iter == editor->first_marked_para)
128 editor->first_marked_para = di;
129 di->member.para.next_marked = iter;
130 iter->member.para.prev_marked = di;
131 break;
132 }
133 else if (di->member.para.nCharOfs >= iter->member.para.nCharOfs)
134 {
135 if (!iter->member.para.next_marked || di->member.para.nCharOfs < iter->member.para.next_marked->member.para.nCharOfs)
136 {
137 if (iter->member.para.next_marked)
138 {
139 di->member.para.next_marked = iter->member.para.next_marked;
140 iter->member.para.next_marked->member.para.prev_marked = di;
141 }
142 di->member.para.prev_marked = iter;
143 iter->member.para.next_marked = di;
144 break;
145 }
146 }
147 iter = iter->member.para.next_marked;
148 }
149}
union tagME_DisplayItem::@536 member
ME_Paragraph para
Definition: editstr.h:262
struct tagME_DisplayItem * next_marked
Definition: editstr.h:218
struct tagME_DisplayItem * prev_marked
Definition: editstr.h:218
ME_DisplayItem * first_marked_para
Definition: editstr.h:435

Referenced by mark_para_rewrap(), and ME_MakeFirstParagraph().

◆ add_undo_delete_run()

BOOL add_undo_delete_run ( ME_TextEditor editor,
int  pos,
int  len 
)

Definition at line 204 of file undo.c.

205{
206 struct undo_item *undo = add_undo( editor, undo_delete_run );
207 if (!undo) return FALSE;
208
209 undo->u.delete_run.pos = pos;
210 undo->u.delete_run.len = len;
211
212 return TRUE;
213}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ undo_delete_run
Definition: editstr.h:290
GLenum GLsizei len
Definition: glext.h:6722
struct delete_run_item delete_run
Definition: editstr.h:348
union undo_item::@537 u
static struct undo_item * add_undo(ME_TextEditor *editor, enum undo_type type)
Definition: undo.c:72

Referenced by ME_InsertRunAtCursor().

◆ add_undo_insert_run()

BOOL add_undo_insert_run ( ME_TextEditor editor,
int  pos,
const WCHAR str,
int  len,
int  flags,
ME_Style style 
)

Definition at line 131 of file undo.c.

132{
133 struct undo_item *undo = add_undo( editor, undo_insert_run );
134 if (!undo) return FALSE;
135
136 undo->u.insert_run.str = heap_alloc( (len + 1) * sizeof(WCHAR) );
137 if (!undo->u.insert_run.str)
138 {
139 ME_EmptyUndoStack( editor );
140 return FALSE;
141 }
142 memcpy( undo->u.insert_run.str, str, len * sizeof(WCHAR) );
143 undo->u.insert_run.str[len] = 0;
144 undo->u.insert_run.pos = pos;
145 undo->u.insert_run.len = len;
146 undo->u.insert_run.flags = flags;
147 undo->u.insert_run.style = style;
149 return TRUE;
150}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
void ME_AddRefStyle(ME_Style *item) DECLSPEC_HIDDEN
Definition: style.c:454
@ undo_insert_run
Definition: editstr.h:289
GLbitfield flags
Definition: glext.h:7161
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
const WCHAR * str
struct insert_run_item insert_run
Definition: editstr.h:347
void ME_EmptyUndoStack(ME_TextEditor *editor)
Definition: undo.c:53
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ME_InternalDeleteText().

◆ add_undo_join_paras()

BOOL add_undo_join_paras ( ME_TextEditor editor,
int  pos 
)

Definition at line 176 of file undo.c.

177{
178 struct undo_item *undo = add_undo( editor, undo_join_paras );
179 if (!undo) return FALSE;
180
181 undo->u.join_paras.pos = pos;
182 return TRUE;
183}
@ undo_join_paras
Definition: editstr.h:291
struct join_paras_item join_paras
Definition: editstr.h:349

Referenced by ME_SplitParagraph().

◆ add_undo_set_char_fmt()

BOOL add_undo_set_char_fmt ( ME_TextEditor editor,
int  pos,
int  len,
const CHARFORMAT2W fmt 
)

Definition at line 164 of file undo.c.

165{
166 struct undo_item *undo = add_undo( editor, undo_set_char_fmt );
167 if (!undo) return FALSE;
168
169 undo->u.set_char_fmt.pos = pos;
170 undo->u.set_char_fmt.len = len;
171 undo->u.set_char_fmt.fmt = *fmt;
172
173 return TRUE;
174}
@ undo_set_char_fmt
Definition: editstr.h:294
Definition: dsound.c:943
struct set_char_fmt_item set_char_fmt
Definition: editstr.h:352

Referenced by ME_SetCharFormat().

◆ add_undo_set_para_fmt()

BOOL add_undo_set_para_fmt ( ME_TextEditor editor,
const ME_Paragraph para 
)

Definition at line 152 of file undo.c.

153{
154 struct undo_item *undo = add_undo( editor, undo_set_para_fmt );
155 if (!undo) return FALSE;
156
157 undo->u.set_para_fmt.pos = para->nCharOfs;
158 undo->u.set_para_fmt.fmt = para->fmt;
159 undo->u.set_para_fmt.border = para->border;
160
161 return TRUE;
162}
@ undo_set_para_fmt
Definition: editstr.h:293
ME_BorderRect border
Definition: editstr.h:208
PARAFORMAT2 fmt
Definition: editstr.h:204
struct set_para_fmt_item set_para_fmt
Definition: editstr.h:351

Referenced by ME_JoinParagraphs(), ME_PlayUndoItem(), and ME_SetParaFormat().

◆ add_undo_split_para()

BOOL add_undo_split_para ( ME_TextEditor editor,
const ME_Paragraph para,
ME_String eol_str,
const ME_Cell cell 
)

Definition at line 185 of file undo.c.

186{
187 struct undo_item *undo = add_undo( editor, undo_split_para );
188 if (!undo) return FALSE;
189
190 undo->u.split_para.pos = para->nCharOfs - eol_str->nLen;
191 undo->u.split_para.eol_str = eol_str;
192 undo->u.split_para.fmt = para->fmt;
193 undo->u.split_para.border = para->border;
194 undo->u.split_para.flags = para->prev_para->member.para.nFlags & ~MEPF_CELL;
195
196 if (cell)
197 {
198 undo->u.split_para.cell_border = cell->border;
199 undo->u.split_para.cell_right_boundary = cell->nRightBoundary;
200 }
201 return TRUE;
202}
@ undo_split_para
Definition: editstr.h:292
int nRightBoundary
Definition: editstr.h:224
ME_BorderRect border
Definition: editstr.h:225
struct tagME_DisplayItem * prev_para
Definition: editstr.h:217
int nLen
Definition: editstr.h:57
struct split_para_item split_para
Definition: editstr.h:350

Referenced by ME_JoinParagraphs().

◆ cf2w_to_cfany()

BOOL cf2w_to_cfany ( CHARFORMAT2W to,
const CHARFORMAT2W from 
)

Definition at line 79 of file style.c.

80{
81 assert(from->cbSize == sizeof(CHARFORMAT2W));
82 if (to->cbSize == sizeof(CHARFORMATA))
83 {
84 CHARFORMATA *t = (CHARFORMATA *)to;
86 WideCharToMultiByte(CP_ACP, 0, from->szFaceName, -1, t->szFaceName, sizeof(t->szFaceName), NULL, NULL);
87 t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */
88 t->dwMask &= CFM_ALL;
89 t->dwEffects &= CFM_EFFECTS;
90 return TRUE;
91 }
92 if (to->cbSize == sizeof(CHARFORMATW))
93 {
94 CHARFORMATW *t = (CHARFORMATW *)to;
95 CopyMemory(t, from, sizeof(*t));
96 t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */
97 t->dwMask &= CFM_ALL;
98 t->dwEffects &= CFM_EFFECTS;
99 return TRUE;
100 }
101 if (to->cbSize == sizeof(CHARFORMAT2A))
102 {
103 CHARFORMAT2A *t = (CHARFORMAT2A *)to;
104 /* copy the A structure without face name */
105 CopyMemory(t, from, FIELD_OFFSET(CHARFORMATA, szFaceName));
106 /* convert face name */
107 WideCharToMultiByte(CP_ACP, 0, from->szFaceName, -1, t->szFaceName, sizeof(t->szFaceName), NULL, NULL);
108 /* copy the rest of the 2A structure to 2W */
109 CopyMemory(&t->wWeight, &from->wWeight, sizeof(CHARFORMAT2W)-FIELD_OFFSET(CHARFORMAT2W,wWeight));
110 t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */
111 return TRUE;
112 }
113 if (to->cbSize == sizeof(CHARFORMAT2W))
114 {
115 CopyMemory(to, from, sizeof(CHARFORMAT2W));
116 return TRUE;
117 }
118 return FALSE;
119}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
#define assert(x)
Definition: debug.h:53
GLdouble GLdouble t
Definition: gl.h:2047
#define CFM_EFFECTS
Definition: richedit.h:364
#define CFM_ALL
Definition: richedit.h:387
CardRegion * from
Definition: spigame.cpp:19
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define CopyMemory
Definition: winbase.h:1710

Referenced by ME_HandleMessage().

◆ cfany_to_cf2w()

BOOL cfany_to_cf2w ( CHARFORMAT2W to,
const CHARFORMAT2W from 
)

Definition at line 36 of file style.c.

37{
38 if (from->cbSize == sizeof(CHARFORMATA))
39 {
41 CopyMemory(to, f, FIELD_OFFSET(CHARFORMATA, szFaceName));
42 to->cbSize = sizeof(CHARFORMAT2W);
43 if (f->dwMask & CFM_FACE) {
44 MultiByteToWideChar(CP_ACP, 0, f->szFaceName, -1, to->szFaceName, ARRAY_SIZE(to->szFaceName));
45 }
46 return TRUE;
47 }
48 if (from->cbSize == sizeof(CHARFORMATW))
49 {
51 CopyMemory(to, f, sizeof(*f));
52 /* theoretically, we don't need to zero the remaining memory */
54 to->cbSize = sizeof(CHARFORMAT2W);
55 return TRUE;
56 }
57 if (from->cbSize == sizeof(CHARFORMAT2A))
58 {
60 /* copy the A structure without face name */
61 CopyMemory(to, f, FIELD_OFFSET(CHARFORMATA, szFaceName));
62 /* convert face name */
63 if (f->dwMask & CFM_FACE)
64 MultiByteToWideChar(CP_ACP, 0, f->szFaceName, -1, to->szFaceName, ARRAY_SIZE(to->szFaceName));
65 /* copy the rest of the 2A structure to 2W */
66 CopyMemory(&to->wWeight, &f->wWeight, sizeof(CHARFORMAT2A)-FIELD_OFFSET(CHARFORMAT2A, wWeight));
67 to->cbSize = sizeof(CHARFORMAT2W);
68 return TRUE;
69 }
70 if (from->cbSize == sizeof(CHARFORMAT2W))
71 {
72 CopyMemory(to, from, sizeof(CHARFORMAT2W));
73 return TRUE;
74 }
75
76 return FALSE;
77}
#define ARRAY_SIZE(A)
Definition: main.h:33
#define MultiByteToWideChar
Definition: compat.h:110
GLfloat f
Definition: glext.h:7540
struct _charformat2w CHARFORMAT2W
#define CFM_FACE
Definition: richedit.h:360
WCHAR szFaceName[LF_FACESIZE]
Definition: richedit.h:313
WORD wWeight
Definition: richedit.h:314
#define ZeroMemory
Definition: winbase.h:1712

Referenced by handle_EM_SETCHARFORMAT(), and ME_MakeFirstParagraph().

◆ create_caret()

void create_caret ( ME_TextEditor ed)

Definition at line 272 of file caret.c.

273{
274 int x, y, height;
275
276 ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height);
277 ITextHost_TxCreateCaret(editor->texthost, NULL, 0, height);
278 editor->caret_height = height;
279 editor->caret_hidden = TRUE;
280}
void ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor *pCursor, int *x, int *y, int *height)
Definition: caret.c:221
#define ITextHost_TxCreateCaret(This, a, b, c)
Definition: editor.h:295
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546

Referenced by ME_HandleMessage(), and update_caret().

◆ CreateIRichEditOle()

LRESULT CreateIRichEditOle ( IUnknown outer_unk,
ME_TextEditor editor,
LPVOID ppvObj 
)

Definition at line 5688 of file richole.c.

5689{
5690 IRichEditOleImpl *reo;
5691
5692 reo = heap_alloc(sizeof(IRichEditOleImpl));
5693 if (!reo)
5694 return 0;
5695
5696 reo->IUnknown_inner.lpVtbl = &reo_unk_vtbl;
5697 reo->IRichEditOle_iface.lpVtbl = &revt;
5698 reo->ITextDocument2Old_iface.lpVtbl = &tdvt;
5699 reo->ref = 1;
5700 reo->editor = editor;
5701 reo->txtSel = NULL;
5702
5703 TRACE("Created %p\n",reo);
5704 list_init(&reo->rangelist);
5705 list_init(&reo->clientsites);
5706 if (outer_unk)
5707 reo->outer_unk = outer_unk;
5708 else
5709 reo->outer_unk = &reo->IUnknown_inner;
5710 *ppvObj = &reo->IUnknown_inner;
5711
5712 return 1;
5713}
static void list_init(struct list_entry *head)
Definition: list.h:51
static const IRichEditOleVtbl revt
Definition: richole.c:1510
static const ITextDocument2OldVtbl tdvt
Definition: richole.c:4550
static const IUnknownVtbl reo_unk_vtbl
Definition: richole.c:1006
#define TRACE(s)
Definition: solgame.cpp:4
IRichEditOle IRichEditOle_iface
Definition: richole.c:211
ITextSelectionImpl * txtSel
Definition: richole.c:217
ITextDocument2Old ITextDocument2Old_iface
Definition: richole.c:212
IUnknown IUnknown_inner
Definition: richole.c:210
struct list rangelist
Definition: richole.c:219
struct list clientsites
Definition: richole.c:220
IUnknown * outer_unk
Definition: richole.c:213
ME_TextEditor * editor
Definition: richole.c:216

Referenced by insert_static_object(), ITextServicesImpl_QueryInterface(), and ME_HandleMessage().

◆ debugstr_run()

static const char * debugstr_run ( const ME_Run run)
inlinestatic

Definition at line 46 of file editor.h.

47{
48 return debugstr_wn( get_text( run, 0 ), run->len );
49}
static WCHAR * get_text(const ME_Run *run, int offset)
Definition: editor.h:41
#define debugstr_wn
Definition: kernel32.h:33
int len
Definition: editstr.h:163

Referenced by itemize_para(), ME_CheckCharOffsets(), ME_DumpDocument(), ME_InternalDeleteText(), ME_JoinParagraphs(), ME_MaximizeSplit(), ME_PropagateCharOffset(), ME_SplitByBacktracking(), and split_run_extents().

◆ destroy_para()

void destroy_para ( ME_TextEditor editor,
ME_DisplayItem item 
)

Definition at line 48 of file para.c.

49{
50 assert(item->type == diParagraph);
51
52 if (item->member.para.nWidth == editor->nTotalWidth)
53 {
54 item->member.para.nWidth = 0;
55 editor->nTotalWidth = get_total_width(editor);
56 }
57 editor->total_rows -= item->member.para.nRows;
58 ME_DestroyString(item->member.para.text);
59 para_num_clear( &item->member.para.para_num );
60 remove_marked_para(editor, item);
62}
void ME_DestroyDisplayItem(ME_DisplayItem *item) DECLSPEC_HIDDEN
Definition: list.c:160
void ME_DestroyString(ME_String *s) DECLSPEC_HIDDEN
Definition: string.c:96
@ diParagraph
Definition: editstr.h:85
static ATOM item
Definition: dde.c:856
void remove_marked_para(ME_TextEditor *editor, ME_DisplayItem *di)
Definition: para.c:82
void para_num_clear(struct para_num *pn)
Definition: para.c:442
int get_total_width(ME_TextEditor *editor)
Definition: para.c:64

Referenced by ME_DestroyEditor(), and ME_JoinParagraphs().

◆ get_di_from_para()

ME_DisplayItem * get_di_from_para ( ME_Paragraph para)

Definition at line 32 of file para.c.

33{
35}
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define offsetof(TYPE, MEMBER)

Referenced by ME_InsertRunAtCursor(), ME_SetCharFormat(), ME_SetParaFormat(), and para_num_clear_list().

◆ get_text()

◆ get_total_width()

int get_total_width ( ME_TextEditor editor)

Definition at line 64 of file para.c.

65{
66 ME_Paragraph *para;
67 int total_width = 0;
68
69 if (editor->pBuffer->pFirst && editor->pBuffer->pLast)
70 {
71 para = &editor->pBuffer->pFirst->next->member.para;
72 while (para != &editor->pBuffer->pLast->member.para && para->next_para)
73 {
74 total_width = max(total_width, para->nWidth);
75 para = &para->next_para->member.para;
76 }
77 }
78
79 return total_width;
80}
struct tagME_DisplayItem * next
Definition: editstr.h:257
struct tagME_DisplayItem * next_para
Definition: editstr.h:217
ME_DisplayItem * pFirst
Definition: editstr.h:268
ME_DisplayItem * pLast
Definition: editstr.h:268
ME_TextBuffer * pBuffer
Definition: editstr.h:386
#define max(a, b)
Definition: svc.c:63

Referenced by destroy_para(), and ME_WrapMarkedParagraphs().

◆ hide_caret()

void hide_caret ( ME_TextEditor ed)

Definition at line 288 of file caret.c.

289{
290 /* calls to HideCaret are cumulative; do so only once */
291 if (!editor->caret_hidden)
292 {
293 ITextHost_TxShowCaret(editor->texthost, FALSE);
294 editor->caret_hidden = TRUE;
295 }
296}
#define ITextHost_TxShowCaret(This, a)
Definition: editor.h:296

Referenced by ME_ArrowKey(), ME_HandleMessage(), and update_caret().

◆ mark_para_rewrap()

void mark_para_rewrap ( ME_TextEditor editor,
ME_DisplayItem para 
)

Definition at line 26 of file para.c.

27{
29 add_marked_para(editor, para);
30}
#define MEPF_REWRAP
Definition: editstr.h:141
void add_marked_para(ME_TextEditor *editor, ME_DisplayItem *di)
Definition: para.c:112

Referenced by handle_enter(), ME_InsertRunAtCursor(), ME_InternalDeleteText(), ME_JoinParagraphs(), ME_JoinRuns(), ME_MarkForWrapping(), ME_PlayUndoItem(), ME_SetCharFormat(), ME_SetParaFormat(), ME_SplitParagraph(), ME_SplitRunSimple(), and para_num_clear_list().

◆ ME_AddRefStyle()

void ME_AddRefStyle ( ME_Style item)

Definition at line 454 of file style.c.

455{
456 assert(s->nRefs>0); /* style with 0 references isn't supposed to exist */
457 s->nRefs++;
458 all_refs++;
459 TRACE_(richedit_style)("ME_AddRefStyle %p, new refs=%d, total refs=%d\n", s, s->nRefs, all_refs);
460}
#define TRACE_(x)
Definition: compat.h:76
static int all_refs
Definition: style.c:26
GLdouble s
Definition: gl.h:2039

Referenced by add_undo_insert_run(), ME_ApplyStyle(), ME_GetInsertStyle(), ME_HandleMessage(), ME_MakeRun(), ME_RTFReadHook(), ME_SaveTempStyle(), ME_StreamIn(), para_num_init(), and RTFUngetToken().

◆ ME_AppendString()

BOOL ME_AppendString ( ME_String s,
const WCHAR append,
int  len 
)

Definition at line 126 of file string.c.

127{
128 return ME_InsertString( s, s->nLen, append, len );
129}
BOOL ME_InsertString(ME_String *s, int ofs, const WCHAR *insert, int len)
Definition: string.c:103
static void append(struct dump_context *dc, const void *data, unsigned size)
Definition: minidump.c:397

Referenced by ME_JoinParagraphs(), and ME_SplitParagraph().

◆ ME_AppendTableRow()

ME_DisplayItem * ME_AppendTableRow ( ME_TextEditor editor,
ME_DisplayItem table_row 
)

Definition at line 407 of file table.c.

409{
410 WCHAR endl = '\r', tab = '\t';
411 ME_DisplayItem *run;
412 PARAFORMAT2 *pFmt;
413 int i;
414
415 assert(table_row);
416 assert(table_row->type == diParagraph);
417 if (!editor->bEmulateVersion10) { /* v4.1 */
418 ME_DisplayItem *insertedCell, *para, *cell, *prevTableEnd;
419 cell = ME_FindItemFwd(ME_GetTableRowStart(table_row), diCell);
420 prevTableEnd = ME_GetTableRowEnd(table_row);
421 para = prevTableEnd->member.para.next_para;
422 run = ME_FindItemFwd(para, diRun);
423 editor->pCursors[0].pPara = para;
424 editor->pCursors[0].pRun = run;
425 editor->pCursors[0].nOffset = 0;
426 editor->pCursors[1] = editor->pCursors[0];
428 insertedCell = ME_FindItemFwd(para, diCell);
429 /* Copy cell properties */
430 insertedCell->member.cell.nRightBoundary = cell->member.cell.nRightBoundary;
431 insertedCell->member.cell.border = cell->member.cell.border;
432 while (cell->member.cell.next_cell) {
433 cell = cell->member.cell.next_cell;
434 para = ME_InsertTableCellFromCursor(editor);
435 insertedCell = ME_FindItemBack(para, diCell);
436 /* Copy cell properties */
437 insertedCell->member.cell.nRightBoundary = cell->member.cell.nRightBoundary;
438 insertedCell->member.cell.border = cell->member.cell.border;
439 };
440 para = ME_InsertTableRowEndFromCursor(editor);
441 para->member.para.fmt = prevTableEnd->member.para.fmt;
442 /* return the table row start for the inserted paragraph */
444 } else { /* v1.0 - 3.0 */
445 run = ME_FindItemBack(table_row->member.para.next_para, diRun);
446 pFmt = &table_row->member.para.fmt;
447 assert(pFmt->dwMask & PFM_TABLE && pFmt->wEffects & PFE_TABLE);
448 editor->pCursors[0].pPara = table_row;
449 editor->pCursors[0].pRun = run;
450 editor->pCursors[0].nOffset = 0;
451 editor->pCursors[1] = editor->pCursors[0];
452 ME_InsertTextFromCursor(editor, 0, &endl, 1, run->member.run.style);
453 run = editor->pCursors[0].pRun;
454 for (i = 0; i < pFmt->cTabCount; i++) {
455 ME_InsertTextFromCursor(editor, 0, &tab, 1, run->member.run.style);
456 }
457 return table_row->member.para.next_para;
458 }
459}
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style)
Definition: caret.c:595
ME_DisplayItem * ME_GetTableRowEnd(ME_DisplayItem *para)
Definition: table.c:136
ME_DisplayItem * ME_InsertTableRowEndFromCursor(ME_TextEditor *editor)
Definition: table.c:129
ME_DisplayItem * ME_GetTableRowStart(ME_DisplayItem *para)
Definition: table.c:154
ME_DisplayItem * ME_InsertTableRowStartFromCursor(ME_TextEditor *editor)
Definition: table.c:79
ME_DisplayItem * ME_InsertTableCellFromCursor(ME_TextEditor *editor)
Definition: table.c:121
ME_DisplayItem * ME_FindItemBack(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN
Definition: list.c:111
ME_DisplayItem * ME_FindItemFwd(ME_DisplayItem *di, ME_DIType nTypeOrClass) DECLSPEC_HIDDEN
Definition: list.c:134
@ diCell
Definition: editstr.h:86
@ diRun
Definition: editstr.h:87
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define PFM_TABLE
Definition: richedit.h:870
#define PFE_TABLE
Definition: richedit.h:944
DWORD dwMask
Definition: richedit.h:667
SHORT cTabCount
Definition: richedit.h:674
WORD wEffects
Definition: richedit.h:669
struct tagME_DisplayItem * next_cell
Definition: editstr.h:229
ME_DisplayItem * pPara
Definition: editstr.h:275
int nOffset
Definition: editstr.h:277
ME_DisplayItem * pRun
Definition: editstr.h:276
ME_DIType type
Definition: editstr.h:256
ME_Cell cell
Definition: editstr.h:261
ME_Style * style
Definition: editstr.h:160
ME_Cursor * pCursors
Definition: editstr.h:387
BOOL bEmulateVersion10
Definition: editstr.h:385

Referenced by handle_enter(), and ME_SelectOrInsertNextCell().

◆ ME_ApplyStyle()

ME_Style * ME_ApplyStyle ( ME_TextEditor ed,
ME_Style sSrc,
CHARFORMAT2W style 
)

Definition at line 156 of file style.c.

157{
158 CHARFORMAT2W fmt = sSrc->fmt;
159 ME_Style *s;
160
161 assert(mod->cbSize == sizeof(CHARFORMAT2W));
162 COPY_STYLE_ITEM(CFM_ANIMATION, bAnimation);
163 COPY_STYLE_ITEM(CFM_BACKCOLOR, crBackColor);
164 COPY_STYLE_ITEM(CFM_CHARSET, bCharSet);
165 COPY_STYLE_ITEM(CFM_COLOR, crTextColor);
166 COPY_STYLE_ITEM_MEMCPY(CFM_FACE, szFaceName);
167 COPY_STYLE_ITEM(CFM_KERNING, wKerning);
170 COPY_STYLE_ITEM(CFM_REVAUTHOR, bRevAuthor);
171 if (mod->dwMask & CFM_SIZE) {
172 fmt.dwMask |= CFM_SIZE;
173 fmt.yHeight = min(mod->yHeight, yHeightCharPtsMost * 20);
174 }
175 COPY_STYLE_ITEM(CFM_SPACING, sSpacing);
176 COPY_STYLE_ITEM(CFM_STYLE, sStyle);
177 COPY_STYLE_ITEM(CFM_WEIGHT, wWeight);
178 /* FIXME: this is not documented this way, but that's the more logical */
179 COPY_STYLE_ITEM(CFM_FACE, bPitchAndFamily);
180
181 fmt.dwEffects &= ~(mod->dwMask);
182 fmt.dwEffects |= mod->dwEffects & mod->dwMask;
183 fmt.dwMask |= mod->dwMask;
184 if (mod->dwMask & CFM_COLOR)
185 {
186 if (mod->dwEffects & CFE_AUTOCOLOR)
187 fmt.dwEffects |= CFE_AUTOCOLOR;
188 else
189 fmt.dwEffects &= ~CFE_AUTOCOLOR;
190 }
191
192 COPY_STYLE_ITEM(CFM_UNDERLINETYPE, bUnderlineType);
193 /* If the CFM_UNDERLINE effect is not specified, set it appropriately */
194 if ((mod->dwMask & CFM_UNDERLINETYPE) && !(mod->dwMask & CFM_UNDERLINE))
195 {
196 fmt.dwMask |= CFM_UNDERLINE;
197 if (mod->bUnderlineType == CFU_UNDERLINENONE)
198 fmt.dwEffects &= ~CFE_UNDERLINE;
199 else
200 fmt.dwEffects |= CFE_UNDERLINE;
201 }
202
203 if (mod->dwMask & CFM_BOLD && !(mod->dwMask & CFM_WEIGHT))
204 {
205 fmt.wWeight = (mod->dwEffects & CFE_BOLD) ? FW_BOLD : FW_NORMAL;
206 } else if (mod->dwMask & CFM_WEIGHT && !(mod->dwMask & CFM_BOLD)) {
207 if (mod->wWeight > FW_NORMAL)
208 fmt.dwEffects |= CFE_BOLD;
209 else
210 fmt.dwEffects &= ~CFE_BOLD;
211 }
212
213 LIST_FOR_EACH_ENTRY(s, &editor->style_list, ME_Style, entry)
214 {
215 if (!memcmp( &s->fmt, &fmt, sizeof(fmt) ))
216 {
217 TRACE_(richedit_style)("found existing style %p\n", s);
218 ME_AddRefStyle( s );
219 return s;
220 }
221 }
222
223 s = ME_MakeStyle( &fmt );
224 if (s)
225 list_add_head( &editor->style_list, &s->entry );
226 TRACE_(richedit_style)("created new style %p\n", s);
227 return s;
228}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
int yOffset
Definition: appswitch.c:59
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
#define COPY_STYLE_ITEM(mask, member)
Definition: style.c:138
ME_Style * ME_MakeStyle(CHARFORMAT2W *style)
Definition: style.c:121
void ME_AddRefStyle(ME_Style *s)
Definition: style.c:454
#define COPY_STYLE_ITEM_MEMCPY(mask, member)
Definition: style.c:144
static int mod
Definition: i386-dis.c:1288
uint32_t entry
Definition: isohybrid.c:63
#define min(a, b)
Definition: monoChain.cc:55
#define yHeightCharPtsMost
Definition: richedit.h:214
#define CFE_BOLD
Definition: richedit.h:406
#define CFM_STYLE
Definition: richedit.h:351
#define CFE_AUTOCOLOR
Definition: richedit.h:414
#define CFM_OFFSET
Definition: richedit.h:359
#define CFM_WEIGHT
Definition: richedit.h:354
#define CFM_SPACING
Definition: richedit.h:353
#define CFM_CHARSET
Definition: richedit.h:358
#define CFE_UNDERLINE
Definition: richedit.h:408
#define CFM_BACKCOLOR
Definition: richedit.h:357
#define CFM_KERNING
Definition: richedit.h:352
#define CFM_LCID
Definition: richedit.h:356
#define CFM_SIZE
Definition: richedit.h:362
#define CFM_REVAUTHOR
Definition: richedit.h:347
#define CFM_ANIMATION
Definition: richedit.h:350
#define CFM_BOLD
Definition: richedit.h:332
#define CFM_UNDERLINETYPE
Definition: richedit.h:355
#define CFU_UNDERLINENONE
Definition: richedit.h:427
#define CFM_UNDERLINE
Definition: richedit.h:334
#define CFM_COLOR
Definition: richedit.h:361
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
CHARFORMAT2W fmt
Definition: editstr.h:73
#define FW_BOLD
Definition: wingdi.h:378
#define FW_NORMAL
Definition: wingdi.h:373

Referenced by ME_RTFCharAttrHook(), ME_SetCharFormat(), ME_SetDefaultCharFormat(), ME_SetSelectionCharFormat(), and para_num_init().

◆ ME_ArrowKey()

BOOL ME_ArrowKey ( ME_TextEditor ed,
int  nVKey,
BOOL  extend,
BOOL  ctrl 
)

Definition at line 1630 of file caret.c.

1631{
1632 int nCursor = 0;
1633 ME_Cursor *p = &editor->pCursors[nCursor];
1634 ME_Cursor tmp_curs = *p;
1635 BOOL success = FALSE;
1636
1637 ME_CheckCharOffsets(editor);
1638 switch(nVKey) {
1639 case VK_LEFT:
1640 editor->bCaretAtEnd = FALSE;
1641 if (ctrl)
1642 success = ME_MoveCursorWords(editor, &tmp_curs, -1);
1643 else
1644 success = ME_MoveCursorChars(editor, &tmp_curs, -1, extend);
1645 break;
1646 case VK_RIGHT:
1647 editor->bCaretAtEnd = FALSE;
1648 if (ctrl)
1649 success = ME_MoveCursorWords(editor, &tmp_curs, +1);
1650 else
1651 success = ME_MoveCursorChars(editor, &tmp_curs, +1, extend);
1652 break;
1653 case VK_UP:
1654 ME_MoveCursorLines(editor, &tmp_curs, -1, extend);
1655 break;
1656 case VK_DOWN:
1657 ME_MoveCursorLines(editor, &tmp_curs, +1, extend);
1658 break;
1659 case VK_PRIOR:
1660 ME_ArrowPageUp(editor, &tmp_curs);
1661 break;
1662 case VK_NEXT:
1663 ME_ArrowPageDown(editor, &tmp_curs);
1664 break;
1665 case VK_HOME: {
1666 if (ctrl)
1667 ME_ArrowCtrlHome(editor, &tmp_curs);
1668 else
1669 ME_ArrowHome(editor, &tmp_curs);
1670 editor->bCaretAtEnd = FALSE;
1671 break;
1672 }
1673 case VK_END:
1674 if (ctrl)
1675 ME_ArrowCtrlEnd(editor, &tmp_curs);
1676 else
1677 ME_ArrowEnd(editor, &tmp_curs);
1678 break;
1679 }
1680
1681 if (!extend)
1682 editor->pCursors[1] = tmp_curs;
1683 *p = tmp_curs;
1684
1685 ME_InvalidateSelection(editor);
1686 ME_Repaint(editor);
1687 hide_caret(editor);
1688 ME_EnsureVisible(editor, &tmp_curs);
1689 update_caret(editor);
1690 ME_SendSelChange(editor);
1691 return success;
1692}
static void ME_ArrowHome(ME_TextEditor *editor, ME_Cursor *pCursor)
Definition: caret.c:1521
int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BOOL final_eop)
Definition: caret.c:720
BOOL ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
Definition: caret.c:799
static void ME_ArrowPageUp(ME_TextEditor *editor, ME_Cursor *pCursor)
Definition: caret.c:1409
static void ME_MoveCursorLines(ME_TextEditor *editor, ME_Cursor *pCursor, int nRelOfs, BOOL extend)
Definition: caret.c:1323
void hide_caret(ME_TextEditor *editor)
Definition: caret.c:288
static void ME_ArrowCtrlEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
Definition: caret.c:1572
void ME_SendSelChange(ME_TextEditor *editor)
Definition: caret.c:1598
static void ME_ArrowPageDown(ME_TextEditor *editor, ME_Cursor *pCursor)
Definition: caret.c:1463
static void ME_ArrowEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
Definition: caret.c:1547
void update_caret(ME_TextEditor *editor)
Definition: caret.c:298
static void ME_ArrowCtrlHome(ME_TextEditor *editor, ME_Cursor *pCursor)
Definition: caret.c:1541
void ME_CheckCharOffsets(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: run.c:101
void ME_EnsureVisible(ME_TextEditor *editor, ME_Cursor *pCursor) DECLSPEC_HIDDEN
Definition: paint.c:1275
void ME_InvalidateSelection(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: paint.c:1322
void ME_Repaint(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: paint.c:106
unsigned int BOOL
Definition: ntddk_ex.h:94
GLfloat GLfloat p
Definition: glext.h:8902
#define ctrl
Definition: input.c:1756
#define success(from, fromstr, to, tostr)
#define VK_UP
Definition: winuser.h:2225
#define VK_NEXT
Definition: winuser.h:2221
#define VK_END
Definition: winuser.h:2222
#define VK_HOME
Definition: winuser.h:2223
#define VK_LEFT
Definition: winuser.h:2224
#define VK_RIGHT
Definition: winuser.h:2226
#define VK_DOWN
Definition: winuser.h:2227
#define VK_PRIOR
Definition: winuser.h:2220

Referenced by ME_KeyDown().

◆ ME_CallWordBreakProc()

int ME_CallWordBreakProc ( ME_TextEditor editor,
WCHAR str,
INT  len,
INT  start,
INT  code 
)

Definition at line 204 of file string.c.

205{
206 if (!editor->pfnWordBreak) {
207 return ME_WordBreakProc(str, start, len, code);
208 } else if (!editor->bEmulateVersion10) {
209 /* MSDN lied about the third parameter for EditWordBreakProc being the number
210 * of characters, it is actually the number of bytes of the string. */
211 return editor->pfnWordBreak(str, start, len * sizeof(WCHAR), code);
212 } else {
213 int result;
215 NULL, 0, NULL, NULL);
217 if (!buffer) return 0;
222 return result;
223 }
224}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static int ME_WordBreakProc(LPWSTR s, INT start, INT len, INT code)
Definition: string.c:162
GLuint start
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
GLuint64EXT * result
Definition: glext.h:11304
Definition: inflate.c:139
EDITWORDBREAKPROCW pfnWordBreak
Definition: editstr.h:417
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)
Definition: swimpl.c:888

Referenced by ME_MoveCursorWords().

◆ ME_CanJoinRuns()

BOOL ME_CanJoinRuns ( const ME_Run run1,
const ME_Run run2 
)

Definition at line 35 of file run.c.

36{
37 if ((run1->nFlags | run2->nFlags) & MERF_NOJOIN)
38 return FALSE;
39 if (run1->style != run2->style)
40 return FALSE;
41 if ((run1->nFlags & MERF_STYLEFLAGS) != (run2->nFlags & MERF_STYLEFLAGS))
42 return FALSE;
43 return TRUE;
44}
#define MERF_STYLEFLAGS
Definition: editstr.h:103
#define MERF_NOJOIN
Definition: editstr.h:131
int nFlags
Definition: editstr.h:165

Referenced by ME_PrepareParagraphForWrapping().

◆ ME_CharCompare()

static int ME_CharCompare ( WCHAR  a,
WCHAR  b,
int  caseSensitive 
)
inlinestatic

Definition at line 106 of file editor.h.

107{
108 return caseSensitive ? (a == b) : (towupper(a) == towupper(b));
109}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
#define towupper(c)
Definition: wctype.h:99

Referenced by ME_FindText().

◆ ME_CharFormatFromLogFont()

void ME_CharFormatFromLogFont ( HDC  hDC,
const LOGFONTW lf,
CHARFORMAT2W fmt 
)

Definition at line 331 of file style.c.

332{
333 int ry;
334
337 lstrcpyW(fmt->szFaceName, lf->lfFaceName);
338 fmt->dwEffects = 0;
340 fmt->wWeight = lf->lfWeight;
341 fmt->yHeight = -lf->lfHeight*1440/ry;
342 if (lf->lfWeight > FW_NORMAL) fmt->dwEffects |= CFM_BOLD;
343 if (lf->lfItalic) fmt->dwEffects |= CFM_ITALIC;
344 if (lf->lfUnderline) fmt->dwEffects |= CFM_UNDERLINE;
345 fmt->bUnderlineType = CFU_UNDERLINE;
346 if (lf->lfStrikeOut) fmt->dwEffects |= CFM_STRIKEOUT;
347 fmt->bPitchAndFamily = lf->lfPitchAndFamily;
348 fmt->bCharSet = lf->lfCharSet;
349}
static HDC hDC
Definition: 3dtext.c:33
#define lstrcpyW
Definition: compat.h:749
void ME_InitCharFormat2W(CHARFORMAT2W *pFmt)
Definition: style.c:150
#define CFM_STRIKEOUT
Definition: richedit.h:335
#define CFM_ITALIC
Definition: richedit.h:333
#define CFU_UNDERLINE
Definition: richedit.h:428
BYTE lfStrikeOut
Definition: dimm.idl:66
BYTE lfItalic
Definition: dimm.idl:64
LONG lfHeight
Definition: dimm.idl:59
LONG lfWeight
Definition: dimm.idl:63
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
BYTE lfUnderline
Definition: dimm.idl:65
BYTE lfCharSet
Definition: dimm.idl:67
BYTE lfPitchAndFamily
Definition: dimm.idl:71
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define LOGPIXELSY
Definition: wingdi.h:719

Referenced by ME_HandleMessage().

◆ ME_CharFromPoint()

int ME_CharFromPoint ( ME_TextEditor editor,
int  cx,
ME_Run run,
BOOL  closest,
BOOL  visual_order 
)

Definition at line 521 of file run.c.

522{
524 int ret;
525
526 ME_InitContext( &c, editor, ITextHost_TxGetDC( editor->texthost ) );
527 ret = ME_CharFromPointContext( &c, cx, run, closest, visual_order );
529 return ret;
530}
void ME_DestroyContext(ME_Context *c)
Definition: context.c:44
void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
Definition: context.c:23
int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest, BOOL visual_order)
Definition: run.c:462
#define ITextHost_TxGetDC(This)
Definition: editor.h:287
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
_Out_opt_ int * cx
Definition: commctrl.h:585
ITextHost * texthost
Definition: editstr.h:383
int ret

Referenced by ME_FindRunInRow().

◆ ME_CharFromPointContext()

int ME_CharFromPointContext ( ME_Context c,
int  cx,
ME_Run run,
BOOL  closest,
BOOL  visual_order 
)

Definition at line 462 of file run.c.

463{
464 ME_String *mask_text = NULL;
465 WCHAR *str;
466 int fit = 0;
467 SIZE sz, sz2, sz3;
468 if (!run->len || cx <= 0)
469 return 0;
470
471 if (run->nFlags & (MERF_TAB | MERF_ENDCELL))
472 {
473 if (!closest || cx < run->nWidth / 2) return 0;
474 return 1;
475 }
476
477 if (run->nFlags & MERF_GRAPHICS)
478 {
479 SIZE sz;
480 ME_GetOLEObjectSize(c, run, &sz);
481 if (!closest || cx < sz.cx / 2) return 0;
482 return 1;
483 }
484
485 if (run->para->nFlags & MEPF_COMPLEX)
486 {
487 int cp, trailing;
488 if (visual_order && run->script_analysis.fRTL) cx = run->nWidth - cx - 1;
489
490 ScriptXtoCP( cx, run->len, run->num_glyphs, run->clusters, run->vis_attrs, run->advances, &run->script_analysis,
491 &cp, &trailing );
492 TRACE("x %d cp %d trailing %d (run width %d) rtl %d log order %d\n", cx, cp, trailing, run->nWidth,
494 return closest ? cp + trailing : cp;
495 }
496
497 if (c->editor->cPasswordMask)
498 {
499 mask_text = ME_MakeStringR( c->editor->cPasswordMask, run->len );
500 str = mask_text->szData;
501 }
502 else
503 str = get_text( run, 0 );
504
505 select_style(c, run->style);
506 GetTextExtentExPointW(c->hDC, str, run->len,
507 cx, &fit, NULL, &sz);
508 if (closest && fit != run->len)
509 {
510 GetTextExtentPoint32W(c->hDC, str, fit, &sz2);
511 GetTextExtentPoint32W(c->hDC, str, fit + 1, &sz3);
512 if (cx >= (sz2.cx+sz3.cx)/2)
513 fit = fit + 1;
514 }
515
516 ME_DestroyString( mask_text );
517
518 return fit;
519}
HRESULT WINAPI ScriptXtoCP(int iX, int cChars, int cGlyphs, const WORD *pwLogClust, const SCRIPT_VISATTR *psva, const int *piAdvance, const SCRIPT_ANALYSIS *psa, int *piCP, int *piTrailing)
Definition: usp10.c:2854
void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) DECLSPEC_HIDDEN
Definition: richole.c:5727
void select_style(ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN
Definition: style.c:369
ME_String * ME_MakeStringR(WCHAR cRepeat, int nMaxChars) DECLSPEC_HIDDEN
Definition: string.c:85
#define MERF_TAB
Definition: editstr.h:107
#define MERF_ENDCELL
Definition: editstr.h:109
#define MERF_GRAPHICS
Definition: editstr.h:105
#define MEPF_COMPLEX
Definition: editstr.h:146
POINT cp
Definition: magnifier.c:59
LONG cx
Definition: kdterminal.h:27
int num_glyphs
Definition: editstr.h:171
SCRIPT_VISATTR * vis_attrs
Definition: editstr.h:173
int * advances
Definition: editstr.h:174
SCRIPT_ANALYSIS script_analysis
Definition: editstr.h:170
int nWidth
Definition: editstr.h:164
WORD * clusters
Definition: editstr.h:177
WCHAR * szData
Definition: editstr.h:56
WORD fLogicalOrder
Definition: usp10.h:144
BOOL WINAPI GetTextExtentExPointW(_In_ HDC hdc, _In_reads_(cchString) LPCWSTR lpszString, _In_ int cchString, _In_ int nMaxExtent, _Out_opt_ LPINT lpnFit, _Out_writes_to_opt_(cchString, *lpnFit) LPINT lpnDx, _Out_ LPSIZE lpSize)
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)

Referenced by find_split_point(), and ME_CharFromPoint().

◆ ME_CharFromPos()

BOOL ME_CharFromPos ( ME_TextEditor editor,
int  x,
int  y,
ME_Cursor cursor,
BOOL isExact 
)

Definition at line 1122 of file caret.c.

1124{
1125 RECT rc;
1126 BOOL bResult;
1127
1128 ITextHost_TxGetClientRect(editor->texthost, &rc);
1129 if (x < 0 || y < 0 || x >= rc.right || y >= rc.bottom) {
1130 if (isExact) *isExact = FALSE;
1131 return FALSE;
1132 }
1133 x += editor->horz_si.nPos;
1134 y += editor->vert_si.nPos;
1135 bResult = ME_FindPixelPos(editor, x, y, cursor, NULL, FALSE);
1136 if (isExact) *isExact = bResult;
1137 return TRUE;
1138}
static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y, ME_Cursor *result, BOOL *is_eol, BOOL final_eop)
Definition: caret.c:1055
#define ITextHost_TxGetClientRect(This, a)
Definition: editor.h:308
const char cursor[]
Definition: icontest.c:13
SCROLLINFO vert_si
Definition: editstr.h:441
SCROLLINFO horz_si
Definition: editstr.h:441
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309

Referenced by ME_HandleMessage(), ME_LinkNotify(), and ME_SetCursor().

◆ ME_CharOfsFromRunOfs()

int ME_CharOfsFromRunOfs ( ME_TextEditor editor,
const ME_DisplayItem pPara,
const ME_DisplayItem pRun,
int  nOfs 
)

Definition at line 156 of file run.c.

158{
159 assert(pRun && pRun->type == diRun);
160 assert(pPara && pPara->type == diParagraph);
161 return pPara->member.para.nCharOfs + pRun->member.run.nCharOfs + nOfs;
162}

Referenced by ME_HandleMessage().

◆ ME_CheckCharOffsets()

void ME_CheckCharOffsets ( ME_TextEditor editor)

Definition at line 101 of file run.c.

102{
103 ME_DisplayItem *p = editor->pBuffer->pFirst;
104 int ofs = 0, ofsp = 0;
105
106 if (!TRACE_ON(richedit_check))
107 return;
108
109 TRACE_(richedit_check)("Checking begin\n");
110 if(TRACE_ON(richedit_lists))
111 {
112 TRACE_(richedit_lists)("---\n");
113 ME_DumpDocument(editor->pBuffer);
114 }
115 do {
117 switch(p->type) {
118 case diTextEnd:
119 TRACE_(richedit_check)("tend, real ofsp = %d, counted = %d\n", p->member.para.nCharOfs, ofsp+ofs);
120 assert(ofsp+ofs == p->member.para.nCharOfs);
121 TRACE_(richedit_check)("Checking finished\n");
122 return;
123 case diParagraph:
124 TRACE_(richedit_check)("para, real ofsp = %d, counted = %d\n", p->member.para.nCharOfs, ofsp+ofs);
125 assert(ofsp+ofs == p->member.para.nCharOfs);
126 ofsp = p->member.para.nCharOfs;
127 ofs = 0;
128 break;
129 case diRun:
130 TRACE_(richedit_check)("run, real ofs = %d (+ofsp = %d), counted = %d, len = %d, txt = %s, flags=%08x, fx&mask = %08x\n",
131 p->member.run.nCharOfs, p->member.run.nCharOfs+ofsp, ofsp+ofs,
132 p->member.run.len, debugstr_run( &p->member.run ),
133 p->member.run.nFlags,
134 p->member.run.style->fmt.dwMask & p->member.run.style->fmt.dwEffects);
135 assert(ofs == p->member.run.nCharOfs);
136 assert(p->member.run.len);
137 ofs += p->member.run.len;
138 break;
139 case diCell:
140 TRACE_(richedit_check)("cell\n");
141 break;
142 default:
143 assert(0);
144 }
145 } while(1);
146 TRACE_(richedit_check)("Checking finished\n");
147}
#define TRACE_ON(x)
Definition: compat.h:75
void ME_DumpDocument(ME_TextBuffer *buffer) DECLSPEC_HIDDEN
Definition: list.c:187
static const char * debugstr_run(const ME_Run *run)
Definition: editor.h:46
@ diTextEnd
Definition: editstr.h:89
@ diRunOrParagraphOrEnd
Definition: editstr.h:97

Referenced by ME_ArrowKey(), ME_InternalDeleteText(), ME_JoinParagraphs(), ME_JoinRuns(), ME_KeyDown(), ME_MakeEditor(), and split_run_extents().

◆ ME_CheckTablesForCorruption()

void ME_CheckTablesForCorruption ( ME_TextEditor editor)

Definition at line 192 of file table.c.

193{
194 if(TRACE_ON(richedit_lists))
195 {
196 TRACE("---\n");
197 ME_DumpDocument(editor->pBuffer);
198 }
199#ifndef NDEBUG
200 {
201 ME_DisplayItem *p, *pPrev;
202 pPrev = editor->pBuffer->pFirst;
203 p = pPrev->next;
204 if (!editor->bEmulateVersion10) /* v4.1 */
205 {
206 while (p->type == diParagraph)
207 {
208 assert(p->member.para.fmt.dwMask & PFM_TABLE);
209 assert(p->member.para.fmt.dwMask & PFM_TABLEROWDELIMITER);
210 if (p->member.para.pCell)
211 {
212 assert(p->member.para.nFlags & MEPF_CELL);
213 assert(p->member.para.fmt.wEffects & PFE_TABLE);
214 }
215 if (p->member.para.pCell != pPrev->member.para.pCell)
216 {
217 /* There must be a diCell in between the paragraphs if pCell changes. */
219 assert(pCell);
221 }
222 if (p->member.para.nFlags & MEPF_ROWEND)
223 {
224 /* ROWEND must come after a cell. */
225 assert(pPrev->member.para.pCell);
226 assert(p->member.para.pCell
227 == pPrev->member.para.pCell->member.cell.parent_cell);
228 assert(p->member.para.fmt.wEffects & PFE_TABLEROWDELIMITER);
229 }
230 else if (p->member.para.pCell)
231 {
232 assert(!(p->member.para.fmt.wEffects & PFE_TABLEROWDELIMITER));
233 assert(pPrev->member.para.pCell ||
235 if (pPrev->member.para.pCell &&
236 !(pPrev->member.para.nFlags & MEPF_ROWSTART))
237 {
238 assert(p->member.para.pCell->member.cell.parent_cell
239 == pPrev->member.para.pCell->member.cell.parent_cell);
240 if (pPrev->member.para.pCell != p->member.para.pCell)
241 assert(pPrev->member.para.pCell
242 == p->member.para.pCell->member.cell.prev_cell);
243 }
244 }
245 else if (!(p->member.para.nFlags & MEPF_ROWSTART))
246 {
247 assert(!(p->member.para.fmt.wEffects & PFE_TABLEROWDELIMITER));
248 /* ROWSTART must be followed by a cell. */
249 assert(!(p->member.para.nFlags & MEPF_CELL));
250 /* ROWSTART must be followed by a cell. */
252 }
253 pPrev = p;
254 p = p->member.para.next_para;
255 }
256 } else { /* v1.0 - 3.0 */
257 while (p->type == diParagraph)
258 {
259 assert(!(p->member.para.nFlags & (MEPF_ROWSTART|MEPF_ROWEND|MEPF_CELL)));
260 assert(p->member.para.fmt.dwMask & PFM_TABLE);
261 assert(!(p->member.para.fmt.wEffects & PFE_TABLEROWDELIMITER));
262 assert(!p->member.para.pCell);
263 p = p->member.para.next_para;
264 }
265 return;
266 }
267 assert(p->type == diTextEnd);
268 assert(!pPrev->member.para.pCell);
269 }
270#endif
271}
#define MEPF_CELL
Definition: editstr.h:143
#define MEPF_ROWSTART
Definition: editstr.h:144
#define MEPF_ROWEND
Definition: editstr.h:145
#define PFM_TABLEROWDELIMITER
Definition: richedit.h:868
#define PFE_TABLEROWDELIMITER
Definition: richedit.h:942
struct tagME_DisplayItem * pCell
Definition: editstr.h:207

Referenced by handle_enter(), ME_Redo(), ME_StreamIn(), and ME_Undo().

◆ ME_ClearTempStyle()

void ME_ClearTempStyle ( ME_TextEditor editor)

Definition at line 523 of file style.c.

524{
525 if (!editor->pBuffer->pCharStyle) return;
527 editor->pBuffer->pCharStyle = NULL;
528}
void ME_ReleaseStyle(ME_Style *s)
Definition: style.c:462
ME_Style * pCharStyle
Definition: editstr.h:269

Referenced by ME_DestroyEditor(), ME_HandleMessage(), ME_ReplaceSel(), ME_SendSelChange(), and ME_StreamIn().

◆ ME_CommitCoalescingUndo()

void ME_CommitCoalescingUndo ( ME_TextEditor editor)

Commits preceding changes into a undo transaction that can be expanded.

This function allows the transaction to be reopened with ME_ContinueCoalescingTransaction in order to continue the transaction. If an undo item is added to the undo stack as a result of a change without the transaction being reopened, then the transaction will be ended, and the changes will become a part of the next transaction.

This is used to allow typed characters to be grouped together since each typed character results in a single event, and each event adding undo items must be committed. Using this function as opposed to ME_CommitUndo allows multiple events to be grouped, and undone together.

Definition at line 301 of file undo.c.

302{
303 struct undo_item *item;
304 struct list *head;
305
306 if (editor->nUndoMode == umIgnore)
307 return;
308
309 assert(editor->nUndoMode == umAddToUndo);
310
311 head = list_head( &editor->undo_stack );
312 if (!head) return;
313
314 /* no need to commit empty transactions */
315 item = LIST_ENTRY( head, struct undo_item, entry );
316 if (item->type == undo_end_transaction ||
318 return;
319
321}
struct outqueuenode * head
Definition: adnsresfilter.c:66
Definition: list.h:37
@ umAddToUndo
Definition: editstr.h:281
@ umIgnore
Definition: editstr.h:283
@ undo_end_transaction
Definition: editstr.h:295
@ undo_potential_end_transaction
Definition: editstr.h:296
Definition: list.h:15
ME_UndoMode nUndoMode
Definition: editstr.h:406
struct list undo_stack
Definition: editstr.h:402
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by handle_enter(), ME_Char(), and ME_KeyDown().

◆ ME_CommitUndo()

void ME_CommitUndo ( ME_TextEditor editor)

Commits preceding changes into a transaction that can be undone together.

This should be called after all the changes occur associated with an event so that the group of changes can be undone atomically as a transaction.

This will have no effect the undo mode is set to ignore changes, or if no changes preceded calling this function before the last time it was called.

This can also be used to conclude a coalescing transaction (used for grouping typed characters).

Definition at line 227 of file undo.c.

228{
229 struct undo_item *item;
230 struct list *head;
231
232 if (editor->nUndoMode == umIgnore)
233 return;
234
235 assert(editor->nUndoMode == umAddToUndo);
236
237 /* no transactions, no need to commit */
238 head = list_head( &editor->undo_stack );
239 if (!head) return;
240
241 /* no need to commit empty transactions */
242 item = LIST_ENTRY( head, struct undo_item, entry );
243 if (item->type == undo_end_transaction) return;
244
246 {
248 return;
249 }
250
252}

Referenced by copy_or_cut(), handle_EM_SETCHARFORMAT(), handle_enter(), IRichEditOle_fnInsertObject(), ME_Char(), ME_HandleMessage(), ME_KeyDown(), ME_ReplaceSel(), ME_StreamIn(), ME_WmCreate(), and paste_emf().

◆ ME_ContinueCoalescingTransaction()

void ME_ContinueCoalescingTransaction ( ME_TextEditor editor)

Groups subsequent changes with previous ones for an undo if coalescing.

Has no effect if the previous changes were followed by a ME_CommitUndo. This function will only have an affect if the previous changes were followed by a call to ME_CommitCoalescingUndo, which allows the transaction to be continued.

This allows multiple consecutively typed characters to be grouped together to be undone by a single undo operation.

Definition at line 265 of file undo.c.

266{
267 struct undo_item *item;
268 struct list *head;
269
270 if (editor->nUndoMode == umIgnore)
271 return;
272
273 assert(editor->nUndoMode == umAddToUndo);
274
275 head = list_head( &editor->undo_stack );
276 if (!head) return;
277
278 item = LIST_ENTRY( head, struct undo_item, entry );
280 {
281 list_remove( &item->entry );
282 editor->nUndoStackSize--;
284 }
285}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
int nUndoStackSize
Definition: editstr.h:404
static void destroy_undo_item(struct undo_item *undo)
Definition: undo.c:25

Referenced by handle_enter(), ME_Char(), and ME_KeyDown().

◆ ME_CopyCharFormat()

void ME_CopyCharFormat ( CHARFORMAT2W pDest,
const CHARFORMAT2W pSrc 
)

Definition at line 230 of file style.c.

231{
232 /* using this with non-2W structs is forbidden */
233 assert(pSrc->cbSize == sizeof(CHARFORMAT2W));
234 assert(pDest->cbSize == sizeof(CHARFORMAT2W));
235 *pDest = *pSrc;
236}

Referenced by ME_GetDefaultCharFormat(), ME_GetRunCharFormat(), and ME_GetSelectionCharFormat().

◆ ME_CopyReObject()

void ME_CopyReObject ( REOBJECT dst,
const REOBJECT src,
DWORD  flags 
)

Definition at line 5907 of file richole.c.

5908{
5909 *dst = *src;
5910 dst->poleobj = NULL;
5911 dst->pstg = NULL;
5912 dst->polesite = NULL;
5913
5914 if ((flags & REO_GETOBJ_POLEOBJ) && src->poleobj)
5915 {
5916 dst->poleobj = src->poleobj;
5917 IOleObject_AddRef(dst->poleobj);
5918 }
5919 if ((flags & REO_GETOBJ_PSTG) && src->pstg)
5920 {
5921 dst->pstg = src->pstg;
5922 IStorage_AddRef(dst->pstg);
5923 }
5924 if ((flags & REO_GETOBJ_POLESITE) && src->polesite)
5925 {
5926 dst->polesite = src->polesite;
5927 IOleClientSite_AddRef(dst->polesite);
5928 }
5929}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by create_re_object(), and IRichEditOle_fnGetObject().

◆ ME_CreateTextHost()

ITextHost * ME_CreateTextHost ( HWND  hwnd,
CREATESTRUCTW cs,
BOOL  bEmulateVersion10 
)

Definition at line 44 of file txthost.c.

45{
46 ITextHostImpl *texthost;
47
48 texthost = CoTaskMemAlloc(sizeof(*texthost));
49 if (!texthost) return NULL;
50
51 texthost->ITextHost_iface.lpVtbl = &textHostVtbl;
52 texthost->ref = 1;
53 texthost->hWnd = hwnd;
54 texthost->bEmulateVersion10 = bEmulateVersion10;
55 memset( &texthost->para_fmt, 0, sizeof(texthost->para_fmt) );
56 texthost->para_fmt.cbSize = sizeof(texthost->para_fmt);
57 texthost->para_fmt.dwMask = PFM_ALIGNMENT;
58 texthost->para_fmt.wAlignment = PFA_LEFT;
59 if (cs->style & ES_RIGHT)
60 texthost->para_fmt.wAlignment = PFA_RIGHT;
61 if (cs->style & ES_CENTER)
62 texthost->para_fmt.wAlignment = PFA_CENTER;
63
64 return &texthost->ITextHost_iface;
65}
#define cs
Definition: i386-dis.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
#define ES_CENTER
Definition: pedump.c:665
#define ES_RIGHT
Definition: pedump.c:666
#define PFA_RIGHT
Definition: richedit.h:922
#define PFA_CENTER
Definition: richedit.h:923
#define PFA_LEFT
Definition: richedit.h:921
#define PFM_ALIGNMENT
Definition: richedit.h:841
#define memset(x, y, z)
Definition: compat.h:39
BOOL bEmulateVersion10
Definition: txthost.c:38
LONG ref
Definition: txthost.c:36
ITextHost ITextHost_iface
Definition: txthost.c:35
PARAFORMAT2 para_fmt
Definition: txthost.c:39
HWND hWnd
Definition: txthost.c:37
WORD wAlignment
Definition: richedit.h:673
UINT cbSize
Definition: richedit.h:666
static const ITextHostVtbl textHostVtbl
Definition: txthost.c:42
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by create_windowed_editor().

◆ ME_CursorFromCharOfs()

void ME_CursorFromCharOfs ( ME_TextEditor editor,
int  nCharOfs,
ME_Cursor pCursor 
)

◆ ME_DeleteReObject()

void ME_DeleteReObject ( struct re_object re_object)

Definition at line 5899 of file richole.c.

5900{
5901 if (reobj->obj.poleobj) IOleObject_Release(reobj->obj.poleobj);
5902 if (reobj->obj.pstg) IStorage_Release(reobj->obj.pstg);
5903 if (reobj->obj.polesite) IOleClientSite_Release(reobj->obj.polesite);
5904 heap_free(reobj);
5905}

Referenced by ME_DestroyDisplayItem().

◆ ME_DeleteSelection()

void ME_DeleteSelection ( ME_TextEditor editor)

Definition at line 1584 of file caret.c.

1585{
1586 int from, to;
1587 int nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
1588 int nEndCursor = nStartCursor ^ 1;
1589 ME_DeleteTextAtCursor(editor, nStartCursor, to - from);
1590 editor->pCursors[nEndCursor] = editor->pCursors[nStartCursor];
1591}
BOOL ME_DeleteTextAtCursor(ME_TextEditor *editor, int nCursor, int nChars)
Definition: caret.c:510
int ME_GetSelectionOfs(ME_TextEditor *editor, int *from, int *to)
Definition: caret.c:42

Referenced by ME_HandleMessage(), ME_InsertEndRowFromCursor(), ME_InsertOLEFromCursor(), ME_InsertTextFromCursor(), and ME_KeyDown().

◆ ME_DeleteTextAtCursor()

BOOL ME_DeleteTextAtCursor ( ME_TextEditor editor,
int  nCursor,
int  nChars 
)

Definition at line 510 of file caret.c.

511{
512 assert(nCursor>=0 && nCursor<editor->nCursors);
513 /* text operations set modified state */
514 editor->nModifyStep = 1;
515 return ME_InternalDeleteText(editor, &editor->pCursors[nCursor],
516 nChars, FALSE);
517}
BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, int nChars, BOOL bForce)
Definition: caret.c:360

Referenced by ME_DeleteSelection(), and ME_KeyDown().

◆ ME_DestroyContext()

void ME_DestroyContext ( ME_Context c)

Definition at line 44 of file context.c.

45{
47 if (c->hDC) ITextHost_TxReleaseDC( c->editor->texthost, c->hDC );
48}
#define ITextHost_TxReleaseDC(This, a)
Definition: editor.h:288

Referenced by ME_CharFromPoint(), ME_GetCursorCoordinates(), ME_InvalidateParagraphRange(), ME_MakeFirstParagraph(), ME_PaintContent(), ME_PointFromChar(), ME_WrapMarkedParagraphs(), and stream_out_graphics().

◆ ME_DestroyDisplayItem()

void ME_DestroyDisplayItem ( ME_DisplayItem item)

Definition at line 160 of file list.c.

161{
162 if (0)
163 TRACE("type=%s\n", ME_GetDITypeName(item->type));
164 if (item->type==diRun)
165 {
166 if (item->member.run.reobj)
167 {
168 list_remove(&item->member.run.reobj->entry);
169 ME_DeleteReObject(item->member.run.reobj);
170 }
171 heap_free( item->member.run.glyphs );
172 heap_free( item->member.run.clusters );
173 ME_ReleaseStyle(item->member.run.style);
174 }
176}
static const char * ME_GetDITypeName(ME_DIType type)
Definition: list.c:146
void ME_ReleaseStyle(ME_Style *item) DECLSPEC_HIDDEN
Definition: style.c:462
void ME_DeleteReObject(struct re_object *re_object) DECLSPEC_HIDDEN
Definition: richole.c:5899

Referenced by destroy_para(), ME_DestroyEditor(), ME_InternalDeleteText(), ME_JoinParagraphs(), ME_JoinRuns(), and ME_PrepareParagraphForWrapping().

◆ ME_DestroyEditor()

void ME_DestroyEditor ( ME_TextEditor editor)

Definition at line 3194 of file editor.c.

3195{
3196 ME_DisplayItem *p = editor->pBuffer->pFirst, *pNext = NULL;
3197 ME_Style *s, *cursor2;
3198 int i;
3199
3200 ME_ClearTempStyle(editor);
3201 ME_EmptyUndoStack(editor);
3202 editor->pBuffer->pFirst = NULL;
3203 while(p) {
3204 pNext = p->next;
3205 if (p->type == diParagraph)
3206 destroy_para(editor, p);
3207 else
3209 p = pNext;
3210 }
3211
3212 LIST_FOR_EACH_ENTRY_SAFE( s, cursor2, &editor->style_list, ME_Style, entry )
3213 ME_DestroyStyle( s );
3214
3216 for (i=0; i<HFONT_CACHE_SIZE; i++)
3217 {
3218 if (editor->pFontCache[i].hFont)
3219 DeleteObject(editor->pFontCache[i].hFont);
3220 }
3221 if (editor->rgbBackColor != -1)
3222 DeleteObject(editor->hbrBackground);
3223 if(editor->lpOleCallback)
3224 IRichEditOleCallback_Release(editor->lpOleCallback);
3225 ITextHost_Release(editor->texthost);
3226 if (editor->reOle)
3227 {
3228 IUnknown_Release(editor->reOle);
3229 editor->reOle = NULL;
3230 }
3232
3233 heap_free(editor->pBuffer);
3234 heap_free(editor->pCursors);
3235 heap_free(editor);
3236}
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:230
void destroy_para(ME_TextEditor *editor, ME_DisplayItem *item) DECLSPEC_HIDDEN
Definition: para.c:48
void ME_DestroyStyle(ME_Style *item) DECLSPEC_HIDDEN
Definition: style.c:442
void ME_EmptyUndoStack(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: undo.c:53
void ME_ClearTempStyle(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: style.c:523
#define HFONT_CACHE_SIZE
Definition: editstr.h:69
pKey DeleteObject()
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
struct define * next
Definition: compiler.c:65
ME_Style * pDefaultStyle
Definition: editstr.h:270
ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE]
Definition: editstr.h:410
COLORREF rgbBackColor
Definition: editstr.h:397
IUnknown * reOle
Definition: editstr.h:384
LPRICHEDITOLECALLBACK lpOleCallback
Definition: editstr.h:418
HBRUSH hbrBackground
Definition: editstr.h:398
struct list style_list
Definition: editstr.h:447

Referenced by ITextServicesImpl_Release(), and ME_HandleMessage().

◆ ME_DestroyString()

void ME_DestroyString ( ME_String s)

Definition at line 96 of file string.c.

97{
98 if (!s) return;
99 if (s->free) s->free( s );
100 heap_free( s );
101}

Referenced by destroy_para(), destroy_undo_item(), draw_text(), ME_CharFromPointContext(), ME_GetRunSizeCommon(), ME_PointFromCharContext(), and para_num_clear().

◆ ME_DestroyStyle()

void ME_DestroyStyle ( ME_Style item)

Definition at line 442 of file style.c.

443{
444 list_remove( &s->entry );
445 if (s->font_cache)
446 {
447 release_font_cache( s->font_cache );
448 s->font_cache = NULL;
449 }
450 ScriptFreeCache( &s->script_cache );
451 heap_free(s);
452}
static void release_font_cache(ME_FontCacheItem *item)
Definition: style.c:360
HRESULT WINAPI ScriptFreeCache(SCRIPT_CACHE *psc)
Definition: usp10.c:1080

Referenced by ME_DestroyEditor(), and ME_ReleaseStyle().

◆ ME_DrawOLE()

void ME_DrawOLE ( ME_Context c,
int  x,
int  y,
ME_Run run,
BOOL  selected 
)

Definition at line 5804 of file richole.c.

5805{
5806 IDataObject* ido;
5807 FORMATETC fmt;
5808 STGMEDIUM stgm;
5809 DIBSECTION dibsect;
5810 ENHMETAHEADER emh;
5811 HDC hMemDC;
5812 SIZE sz;
5813 BOOL has_size;
5814 HBITMAP old_bm;
5815 RECT rc;
5816
5817 assert(run->nFlags & MERF_GRAPHICS);
5818 assert(run->reobj);
5819 if (IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
5820 {
5821 FIXME("Couldn't get interface\n");
5822 return;
5823 }
5824 has_size = run->reobj->obj.sizel.cx != 0 || run->reobj->obj.sizel.cy != 0;
5825 fmt.cfFormat = CF_BITMAP;
5826 fmt.ptd = NULL;
5827 fmt.dwAspect = DVASPECT_CONTENT;
5828 fmt.lindex = -1;
5829 fmt.tymed = TYMED_GDI;
5830 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
5831 {
5832 fmt.cfFormat = CF_ENHMETAFILE;
5833 fmt.tymed = TYMED_ENHMF;
5834 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
5835 {
5836 FIXME("Couldn't get storage medium\n");
5837 IDataObject_Release(ido);
5838 return;
5839 }
5840 }
5841 IDataObject_Release(ido);
5842
5843 switch (stgm.tymed)
5844 {
5845 case TYMED_GDI:
5846 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
5847 hMemDC = CreateCompatibleDC(c->hDC);
5848 old_bm = SelectObject(hMemDC, stgm.u.hBitmap);
5849 if (has_size)
5850 {
5851 convert_sizel(c, &run->reobj->obj.sizel, &sz);
5852 } else {
5853 sz.cx = dibsect.dsBm.bmWidth;
5854 sz.cy = dibsect.dsBm.bmHeight;
5855 }
5856 if (c->editor->nZoomNumerator != 0)
5857 {
5858 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5859 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5860 }
5861 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
5862 hMemDC, 0, 0, dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight, SRCCOPY);
5863
5864 SelectObject(hMemDC, old_bm);
5865 DeleteDC(hMemDC);
5866 break;
5867 case TYMED_ENHMF:
5868 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
5869 if (has_size)
5870 {
5871 convert_sizel(c, &run->reobj->obj.sizel, &sz);
5872 } else {
5873 sz.cx = emh.rclBounds.right - emh.rclBounds.left;
5874 sz.cy = emh.rclBounds.bottom - emh.rclBounds.top;
5875 }
5876 if (c->editor->nZoomNumerator != 0)
5877 {
5878 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5879 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5880 }
5881
5882 rc.left = x;
5883 rc.top = y - sz.cy;
5884 rc.right = x + sz.cx;
5885 rc.bottom = y;
5886 PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
5887 break;
5888 default:
5889 FIXME("Unsupported tymed %d\n", stgm.tymed);
5890 selected = FALSE;
5891 break;
5892 }
5893 ReleaseStgMedium(&stgm);
5894
5895 if (selected && !c->editor->bHideSelection)
5896 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
5897}
#define CF_BITMAP
Definition: constants.h:397
#define CF_ENHMETAFILE
Definition: constants.h:409
#define FIXME(fmt,...)
Definition: debug.h:111
static char selected[MAX_PATH+1]
Definition: dirdlg.c:7
void WINAPI ReleaseStgMedium(STGMEDIUM *pmedium)
Definition: ole2.c:2033
static void convert_sizel(const ME_Context *c, const SIZEL *szl, SIZE *sz)
Definition: richole.c:5715
#define S_OK
Definition: intsafe.h:52
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
const GUID IID_IDataObject
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
LONG cy
Definition: kdterminal.h:28
LONG bmHeight
Definition: wingdi.h:1423
LONG bmWidth
Definition: wingdi.h:1422
BITMAP dsBm
Definition: wingdi.h:1669
RECTL rclBounds
Definition: wingdi.h:2322
struct re_object * reobj
Definition: editstr.h:168
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define SRCCOPY
Definition: wingdi.h:333
#define DSTINVERT
Definition: wingdi.h:327
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
UINT WINAPI GetEnhMetaFileHeader(_In_ HENHMETAFILE hemf, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPENHMETAHEADER lpEnhMetaHeader)
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI PlayEnhMetaFile(_In_ HDC, _In_ HENHMETAFILE, _In_ LPCRECT)

Referenced by ME_DrawRun().

◆ ME_DumpDocument()

void ME_DumpDocument ( ME_TextBuffer buffer)

Definition at line 187 of file list.c.

188{
189 /* FIXME this is useless, */
190 ME_DisplayItem *pItem = buffer->pFirst;
191 TRACE("DOCUMENT DUMP START\n");
192 while(pItem) {
193 switch(pItem->type)
194 {
195 case diTextStart:
196 TRACE("Start\n");
197 break;
198 case diCell:
199 TRACE("Cell(level=%d%s)\n", pItem->member.cell.nNestingLevel,
200 !pItem->member.cell.next_cell ? ", END" :
201 (!pItem->member.cell.prev_cell ? ", START" :""));
202 break;
203 case diParagraph:
204 TRACE("Paragraph(ofs=%d)\n", pItem->member.para.nCharOfs);
205 if (pItem->member.para.nFlags & MEPF_ROWSTART)
206 TRACE(" - (Table Row Start)\n");
207 if (pItem->member.para.nFlags & MEPF_ROWEND)
208 TRACE(" - (Table Row End)\n");
209 break;
210 case diStartRow:
211 TRACE(" - StartRow\n");
212 break;
213 case diRun:
214 TRACE(" - Run(%s, %d, flags=%x)\n", debugstr_run( &pItem->member.run ),
215 pItem->member.run.nCharOfs, pItem->member.run.nFlags);
216 break;
217 case diTextEnd:
218 TRACE("End(ofs=%d)\n", pItem->member.para.nCharOfs);
219 break;
220 default:
221 break;
222 }
223 pItem = pItem->next;
224 }
225 TRACE("DOCUMENT DUMP END\n");
226}
@ diStartRow
Definition: editstr.h:88
@ diTextStart
Definition: editstr.h:84
struct tagME_DisplayItem * prev_cell
Definition: editstr.h:229
int nNestingLevel
Definition: editstr.h:223

Referenced by ME_CheckCharOffsets(), and ME_CheckTablesForCorruption().

◆ ME_DumpParaStyle()

void ME_DumpParaStyle ( ME_Paragraph s)

◆ ME_DumpParaStyleToBuf()

void ME_DumpParaStyleToBuf ( const PARAFORMAT2 pFmt,
char  buf[2048] 
)

Definition at line 819 of file para.c.

820{
821 char *p;
822 p = buf;
823
824#define DUMP(mask, name, fmt, field) \
825 if (pFmt->dwMask & (mask)) p += sprintf(p, "%-22s" fmt "\n", name, pFmt->field); \
826 else p += sprintf(p, "%-22sN/A\n", name);
827
828/* we take for granted that PFE_xxx is the hiword of the corresponding PFM_xxx */
829#define DUMP_EFFECT(mask, name) \
830 p += sprintf(p, "%-22s%s\n", name, (pFmt->dwMask & (mask)) ? ((pFmt->wEffects & ((mask) >> 16)) ? "yes" : "no") : "N/A");
831
832 DUMP(PFM_NUMBERING, "Numbering:", "%u", wNumbering);
833 DUMP_EFFECT(PFM_DONOTHYPHEN, "Disable auto-hyphen:");
834 DUMP_EFFECT(PFM_KEEP, "No page break in para:");
835 DUMP_EFFECT(PFM_KEEPNEXT, "No page break in para & next:");
836 DUMP_EFFECT(PFM_NOLINENUMBER, "No line number:");
837 DUMP_EFFECT(PFM_NOWIDOWCONTROL, "No widow & orphan:");
838 DUMP_EFFECT(PFM_PAGEBREAKBEFORE, "Page break before:");
839 DUMP_EFFECT(PFM_RTLPARA, "RTL para:");
840 DUMP_EFFECT(PFM_SIDEBYSIDE, "Side by side:");
841 DUMP_EFFECT(PFM_TABLE, "Table:");
842 DUMP(PFM_OFFSETINDENT, "Offset indent:", "%d", dxStartIndent);
843 DUMP(PFM_STARTINDENT, "Start indent:", "%d", dxStartIndent);
844 DUMP(PFM_RIGHTINDENT, "Right indent:", "%d", dxRightIndent);
845 DUMP(PFM_OFFSET, "Offset:", "%d", dxOffset);
846 if (pFmt->dwMask & PFM_ALIGNMENT) {
847 switch (pFmt->wAlignment) {
848 case PFA_LEFT : p += sprintf(p, "Alignment: left\n"); break;
849 case PFA_RIGHT : p += sprintf(p, "Alignment: right\n"); break;
850 case PFA_CENTER : p += sprintf(p, "Alignment: center\n"); break;
851 case PFA_JUSTIFY: p += sprintf(p, "Alignment: justify\n"); break;
852 default : p += sprintf(p, "Alignment: incorrect %d\n", pFmt->wAlignment); break;
853 }
854 }
855 else p += sprintf(p, "Alignment: N/A\n");
856 DUMP(PFM_TABSTOPS, "Tab Stops:", "%d", cTabCount);
857 if (pFmt->dwMask & PFM_TABSTOPS) {
858 int i;
859 p += sprintf(p, "\t");
860 for (i = 0; i < pFmt->cTabCount; i++) p += sprintf(p, "%x ", pFmt->rgxTabs[i]);
861 p += sprintf(p, "\n");
862 }
863 DUMP(PFM_SPACEBEFORE, "Space Before:", "%d", dySpaceBefore);
864 DUMP(PFM_SPACEAFTER, "Space After:", "%d", dySpaceAfter);
865 DUMP(PFM_LINESPACING, "Line spacing:", "%d", dyLineSpacing);
866 DUMP(PFM_STYLE, "Text style:", "%d", sStyle);
867 DUMP(PFM_LINESPACING, "Line spacing rule:", "%u", bLineSpacingRule);
868 /* bOutlineLevel should be 0 */
869 DUMP(PFM_SHADING, "Shading Weight:", "%u", wShadingWeight);
870 DUMP(PFM_SHADING, "Shading Style:", "%u", wShadingStyle);
871 DUMP(PFM_NUMBERINGSTART, "Numbering Start:", "%u", wNumberingStart);
872 DUMP(PFM_NUMBERINGSTYLE, "Numbering Style:", "0x%x", wNumberingStyle);
873 DUMP(PFM_NUMBERINGTAB, "Numbering Tab:", "%u", wNumberingStyle);
874 DUMP(PFM_BORDER, "Border Space:", "%u", wBorderSpace);
875 DUMP(PFM_BORDER, "Border Width:", "%u", wBorderWidth);
876 DUMP(PFM_BORDER, "Borders:", "%u", wBorders);
877
878#undef DUMP
879#undef DUMP_EFFECT
880}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define DUMP(mask, name, fmt, field)
#define DUMP_EFFECT(mask, name)
#define PFM_SPACEBEFORE
Definition: richedit.h:847
#define PFM_OFFSETINDENT
Definition: richedit.h:844
#define PFM_NUMBERING
Definition: richedit.h:843
#define PFM_NOLINENUMBER
Definition: richedit.h:860
#define PFM_KEEPNEXT
Definition: richedit.h:858
#define PFM_NUMBERINGSTYLE
Definition: richedit.h:853
#define PFM_DONOTHYPHEN
Definition: richedit.h:862
#define PFM_LINESPACING
Definition: richedit.h:849
#define PFM_OFFSET
Definition: richedit.h:840
#define PFM_SHADING
Definition: richedit.h:852
#define PFM_RIGHTINDENT
Definition: richedit.h:839
#define PFM_NOWIDOWCONTROL
Definition: richedit.h:861
#define PFM_PAGEBREAKBEFORE
Definition: richedit.h:859
#define PFM_BORDER
Definition: richedit.h:851
#define PFM_SIDEBYSIDE
Definition: richedit.h:863
#define PFA_JUSTIFY
Definition: richedit.h:924
#define PFM_TABSTOPS
Definition: richedit.h:842
#define PFM_STYLE
Definition: richedit.h:850
#define PFM_KEEP
Definition: richedit.h:857
#define PFM_RTLPARA
Definition: richedit.h:856
#define PFM_SPACEAFTER
Definition: richedit.h:848
#define PFM_STARTINDENT
Definition: richedit.h:838
#define PFM_NUMBERINGSTART
Definition: richedit.h:855
#define PFM_NUMBERINGTAB
Definition: richedit.h:854
LONG rgxTabs[MAX_TAB_STOPS]
Definition: richedit.h:675

◆ ME_DumpStyle()

void ME_DumpStyle ( ME_Style s)

Definition at line 243 of file style.c.

244{
245 char buf[2048];
246 ME_DumpStyleToBuf(&s->fmt, buf);
247 TRACE_(richedit_style)("%s\n", buf);
248}
void ME_DumpStyleToBuf(CHARFORMAT2W *pFmt, char buf[2048])
Definition: style.c:250

◆ ME_DumpStyleToBuf()

void ME_DumpStyleToBuf ( CHARFORMAT2W pFmt,
char  buf[2048] 
)

Definition at line 250 of file style.c.

251{
252 /* FIXME only CHARFORMAT styles implemented */
253 /* this function sucks, doesn't check for buffer overruns but it's "good enough" as for debug code */
254 char *p;
255 p = buf;
256 p += sprintf(p, "Font face: ");
257 if (pFmt->dwMask & CFM_FACE) {
258 WCHAR *q = pFmt->szFaceName;
259 while(*q) {
260 *p++ = (*q > 255) ? '?' : *q;
261 q++;
262 }
263 } else
264 p += sprintf(p, "N/A");
265
266 if (pFmt->dwMask & CFM_SIZE)
267 p += sprintf(p, "\nFont size: %d\n", pFmt->yHeight);
268 else
269 p += sprintf(p, "\nFont size: N/A\n");
270
271 if (pFmt->dwMask & CFM_OFFSET)
272 p += sprintf(p, "Char offset: %d\n", pFmt->yOffset);
273 else
274 p += sprintf(p, "Char offset: N/A\n");
275
276 if (pFmt->dwMask & CFM_CHARSET)
277 p += sprintf(p, "Font charset: %d\n", (int)pFmt->bCharSet);
278 else
279 p += sprintf(p, "Font charset: N/A\n");
280
281 /* I'm assuming CFM_xxx and CFE_xxx are the same values, fortunately it IS true wrt used flags*/
282 ME_DumpStyleEffect(&p, "Font bold:", pFmt, CFM_BOLD);
283 ME_DumpStyleEffect(&p, "Font italic:", pFmt, CFM_ITALIC);
284 ME_DumpStyleEffect(&p, "Font underline:", pFmt, CFM_UNDERLINE);
285 ME_DumpStyleEffect(&p, "Font strikeout:", pFmt, CFM_STRIKEOUT);
286 ME_DumpStyleEffect(&p, "Hidden text:", pFmt, CFM_HIDDEN);
287 p += sprintf(p, "Text color: ");
288 if (pFmt->dwMask & CFM_COLOR)
289 {
290 if (pFmt->dwEffects & CFE_AUTOCOLOR)
291 p += sprintf(p, "auto\n");
292 else
293 p += sprintf(p, "%06x\n", (int)pFmt->crTextColor);
294 }
295 else
296 p += sprintf(p, "N/A\n");
297 ME_DumpStyleEffect(&p, "Text protected:", pFmt, CFM_PROTECTED);
298}
static void ME_DumpStyleEffect(char **p, const char *name, const CHARFORMAT2W *fmt, int mask)
Definition: style.c:238
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
#define CFM_PROTECTED
Definition: richedit.h:336
BYTE bCharSet
Definition: richedit.h:311
DWORD dwMask
Definition: richedit.h:306
LONG yOffset
Definition: richedit.h:309
DWORD dwEffects
Definition: richedit.h:307
LONG yHeight
Definition: richedit.h:308
COLORREF crTextColor
Definition: richedit.h:310

Referenced by ME_DumpStyle(), and ME_KeyDown().

◆ ME_EmptyUndoStack()

void ME_EmptyUndoStack ( ME_TextEditor editor)

Definition at line 53 of file undo.c.

54{
55 struct undo_item *cursor, *cursor2;
56 if (editor->nUndoMode == umIgnore)
57 return;
58
59 TRACE("Emptying undo stack\n");
60
61 editor->nUndoStackSize = 0;
62
63 LIST_FOR_EACH_ENTRY_SAFE( cursor, cursor2, &editor->undo_stack, struct undo_item, entry )
64 {
65 list_remove( &cursor->entry );
67 }
68
69 empty_redo_stack( editor );
70}
static void empty_redo_stack(ME_TextEditor *editor)
Definition: undo.c:43

Referenced by add_undo_insert_run(), fnTextSrv_TxSetText(), ME_DestroyEditor(), ME_HandleMessage(), ME_ReplaceSel(), and ME_StreamIn().

◆ ME_EndToUnicode()

void ME_EndToUnicode ( LONG  codepage,
LPVOID  psz 
)

Definition at line 248 of file string.c.

249{
250 if (codepage != CP_UNICODE)
251 heap_free( psz );
252}
#define CP_UNICODE
Definition: stg_prop.c:74
int codepage
Definition: win_iconv.c:156

Referenced by ME_HandleMessage(), and ME_SetText().

◆ ME_EnsureVisible()

void ME_EnsureVisible ( ME_TextEditor editor,
ME_Cursor pCursor 
)

Definition at line 1275 of file paint.c.

1276{
1277 ME_Run *pRun = &pCursor->pRun->member.run;
1278 ME_DisplayItem *pRow = ME_FindItemBack(pCursor->pRun, diStartRow);
1279 ME_DisplayItem *pPara = pCursor->pPara;
1280 int x, y, yheight;
1281
1282#ifdef __REACTOS__
1283 if (!pRow || !pPara)
1284 return;
1285#else
1286 assert(pRow);
1287 assert(pPara);
1288#endif
1289
1290 if (editor->styleFlags & ES_AUTOHSCROLL)
1291 {
1292 x = pRun->pt.x + ME_PointFromChar(editor, pRun, pCursor->nOffset, TRUE);
1293 if (x > editor->horz_si.nPos + editor->sizeWindow.cx)
1294 x = x + 1 - editor->sizeWindow.cx;
1295 else if (x > editor->horz_si.nPos)
1296 x = editor->horz_si.nPos;
1297
1298 if (~editor->styleFlags & ES_AUTOVSCROLL)
1299 {
1300 ME_HScrollAbs(editor, x);
1301 return;
1302 }
1303 } else {
1304 if (~editor->styleFlags & ES_AUTOVSCROLL)
1305 return;
1306 x = editor->horz_si.nPos;
1307 }
1308
1309 y = pPara->member.para.pt.y + pRow->member.row.pt.y;
1310 yheight = pRow->member.row.nHeight;
1311
1312 if (y < editor->vert_si.nPos)
1313 ME_ScrollAbs(editor, x, y);
1314 else if (y + yheight > editor->vert_si.nPos + editor->sizeWindow.cy)
1315 ME_ScrollAbs(editor, x, y + yheight - editor->sizeWindow.cy);
1316 else if (x != editor->horz_si.nPos)
1317 ME_ScrollAbs(editor, x, editor->vert_si.nPos);
1318}
void ME_ScrollAbs(ME_TextEditor *editor, int x, int y)
Definition: paint.c:1043
void ME_HScrollAbs(ME_TextEditor *editor, int x)
Definition: paint.c:1106
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN
Definition: run.c:598
#define ES_AUTOVSCROLL
Definition: pedump.c:671
#define ES_AUTOHSCROLL
Definition: pedump.c:672
POINT pt
Definition: editstr.h:239
int nHeight
Definition: editstr.h:234
POINT pt
Definition: editstr.h:167
DWORD styleFlags
Definition: editstr.h:388
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48

Referenced by ME_ArrowKey(), ME_HandleMessage(), ME_MouseMove(), and ME_UpdateRepaint().

◆ ME_FindItemBack()

◆ ME_FindItemBackOrHere()

ME_DisplayItem * ME_FindItemBackOrHere ( ME_DisplayItem di,
ME_DIType  nTypeOrClass 
)

Definition at line 124 of file list.c.

125{
126 while(di!=NULL) {
127 if (ME_DITypesEqual(di->type, nTypeOrClass))
128 return di;
129 di = di->prev;
130 }
131 return NULL;
132}

Referenced by ME_GetParagraph(), and ME_RowStart().

◆ ME_FindItemFwd()

◆ ME_FindNonWhitespaceV()

int ME_FindNonWhitespaceV ( const ME_String s,
int  nVChar 
)

◆ ME_FindRowWithNumber()

ME_DisplayItem * ME_FindRowWithNumber ( ME_TextEditor editor,
int  nRow 
)

Definition at line 44 of file row.c.

45{
47 int nCount = 0;
48
49 while (item->type == diParagraph &&
50 nCount + item->member.para.nRows <= nRow)
51 {
52 nCount += item->member.para.nRows;
53 item = item->member.para.next_para;
54 }
55 if (item->type != diParagraph)
56 return NULL;
57 for (item = ME_FindItemFwd(item, diStartRow); item && nCount < nRow; nCount++)
59 return item;
60}

Referenced by ME_HandleMessage().

◆ ME_GetCharFormat()

void ME_GetCharFormat ( ME_TextEditor editor,
const ME_Cursor from,
const ME_Cursor to,
CHARFORMAT2W pFmt 
)

Definition at line 819 of file run.c.

821{
822 ME_DisplayItem *run, *run_end;
823 CHARFORMAT2W tmp;
824
825 run = from->pRun;
826 /* special case - if selection is empty, take previous char's formatting */
827 if (from->pRun == to->pRun && from->nOffset == to->nOffset)
828 {
829 if (!from->nOffset)
830 {
832 if (tmp_run->type == diRun) {
833 ME_GetRunCharFormat(editor, tmp_run, pFmt);
834 return;
835 }
836 }
837 ME_GetRunCharFormat(editor, run, pFmt);
838 return;
839 }
840
841 run_end = to->pRun;
842 if (!to->nOffset)
843 run_end = ME_FindItemBack(run_end, diRun);
844
845 ME_GetRunCharFormat(editor, run, pFmt);
846
847 if (run == run_end) return;
848
849 do {
850 /* FIXME add more style feature comparisons */
853
854 run = ME_FindItemFwd(run, diRun);
855
856 ZeroMemory(&tmp, sizeof(tmp));
857 tmp.cbSize = sizeof(tmp);
858 ME_GetRunCharFormat(editor, run, &tmp);
859
860 assert((tmp.dwMask & dwAttribs) == dwAttribs);
861 /* reset flags that differ */
862
863 if (pFmt->yHeight != tmp.yHeight)
864 pFmt->dwMask &= ~CFM_SIZE;
865 if (pFmt->dwMask & CFM_FACE)
866 {
867 if (!(tmp.dwMask & CFM_FACE))
868 pFmt->dwMask &= ~CFM_FACE;
869 else if (wcscmp(pFmt->szFaceName, tmp.szFaceName) ||
870 pFmt->bPitchAndFamily != tmp.bPitchAndFamily)
871 pFmt->dwMask &= ~CFM_FACE;
872 }
873 if (pFmt->yHeight != tmp.yHeight)
874 pFmt->dwMask &= ~CFM_SIZE;
875 if (pFmt->bUnderlineType != tmp.bUnderlineType)
876 pFmt->dwMask &= ~CFM_UNDERLINETYPE;
877 if (pFmt->dwMask & CFM_COLOR)
878 {
879 if (!((pFmt->dwEffects&CFE_AUTOCOLOR) & (tmp.dwEffects&CFE_AUTOCOLOR)))
880 {
881 if (pFmt->crTextColor != tmp.crTextColor)
882 pFmt->dwMask &= ~CFM_COLOR;
883 }
884 }
885
886 pFmt->dwMask &= ~((pFmt->dwEffects ^ tmp.dwEffects) & dwEffects);
887 pFmt->dwEffects = tmp.dwEffects;
888
889 } while(run != run_end);
890}
static void ME_GetRunCharFormat(ME_TextEditor *editor, ME_DisplayItem *run, CHARFORMAT2W *pFmt)
Definition: run.c:779
@ diRunOrParagraph
Definition: editstr.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CFM_LINK
Definition: richedit.h:337
#define CFM_SUPERSCRIPT
Definition: richedit.h:349
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BYTE bUnderlineType
Definition: richedit.h:321
BYTE bPitchAndFamily
Definition: richedit.h:312

Referenced by get_textfont_prop_for_pos(), ME_GetSelectionCharFormat(), ME_StreamIn(), and ME_UpdateLinkAttribute().

◆ ME_GetCursorCoordinates()

void ME_GetCursorCoordinates ( ME_TextEditor editor,
ME_Cursor pCursor,
int x,
int y,
int height 
)

Definition at line 221 of file caret.c.

223{
225 ME_DisplayItem *run = pCursor->pRun;
226 ME_DisplayItem *para = pCursor->pPara;
227 ME_DisplayItem *pSizeRun = run;
229 int run_x;
230
231 assert(height && x && y);
233 assert(run && run->type == diRun);
234 assert(para && para->type == diParagraph);
235
237 assert(row && row->type == diStartRow);
238
239 ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
240
241 if (!pCursor->nOffset)
242 {
244 assert(prev);
245 if (prev->type == diRun)
246 pSizeRun = prev;
247 }
248 if (editor->bCaretAtEnd && !pCursor->nOffset &&
249 run == ME_FindItemFwd(row, diRun))
250 {
252 assert(tmp);
253 if (tmp->type == diRun)
254 {
256 pSizeRun = run = tmp;
257 assert(run);
258 assert(run->type == diRun);
259 }
260 }
261 run_x = ME_PointFromCharContext( &c, &run->member.run, pCursor->nOffset, TRUE );
262
263 *height = pSizeRun->member.run.nAscent + pSizeRun->member.run.nDescent;
264 *x = c.rcView.left + run->member.run.pt.x + run_x - editor->horz_si.nPos;
265 *y = c.rcView.top + para->member.para.pt.y + row->member.row.nBaseline
266 + run->member.run.pt.y - pSizeRun->member.run.nAscent
267 - editor->vert_si.nPos;
269 return;
270}
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visual_order) DECLSPEC_HIDDEN
Definition: run.c:557
@ diStartRowOrParagraph
Definition: editstr.h:92
int nAscent
Definition: editstr.h:166
int nDescent
Definition: editstr.h:166
BOOL bCaretAtEnd
Definition: editstr.h:399

Referenced by create_caret(), ITextRange_fnScrollIntoView(), and update_caret().

◆ ME_GetCursorOfs()

◆ ME_GetDataObject()

HRESULT ME_GetDataObject ( ME_TextEditor editor,
const ME_Cursor start,
int  nChars,
LPDATAOBJECT lplpdataobj 
)

◆ ME_GetDefaultCharFormat()

void ME_GetDefaultCharFormat ( ME_TextEditor editor,
CHARFORMAT2W pFmt 
)

Definition at line 790 of file run.c.

791{
792 ME_CopyCharFormat(pFmt, &editor->pBuffer->pDefaultStyle->fmt);
793}
void ME_CopyCharFormat(CHARFORMAT2W *pDest, const CHARFORMAT2W *pSrc) DECLSPEC_HIDDEN
Definition: style.c:230

Referenced by ME_HandleMessage().

◆ ME_GetInsertStyle()

ME_Style * ME_GetInsertStyle ( ME_TextEditor editor,
int  nCursor 
)

Definition at line 476 of file style.c.

477{
478 if (ME_IsSelection(editor))
479 {
480 ME_Cursor *from, *to;
481
482 ME_GetSelection(editor, &from, &to);
483 ME_AddRefStyle(from->pRun->member.run.style);
484 return from->pRun->member.run.style;
485 }
486 if (editor->pBuffer->pCharStyle) {
488 return editor->pBuffer->pCharStyle;
489 }
490 else
491 {
492 ME_Cursor *pCursor = &editor->pCursors[nCursor];
493 ME_DisplayItem *pRunItem = pCursor->pRun;
494 ME_DisplayItem *pPrevItem = NULL;
495 if (pCursor->nOffset) {
496 ME_Run *pRun = &pRunItem->member.run;
497 ME_AddRefStyle(pRun->style);
498 return pRun->style;
499 }
500 pPrevItem = ME_FindItemBack(pRunItem, diRunOrParagraph);
501 if (pPrevItem->type == diRun)
502 {
503 ME_AddRefStyle(pPrevItem->member.run.style);
504 return pPrevItem->member.run.style;
505 }
506 else
507 {
508 ME_AddRefStyle(pRunItem->member.run.style);
509 return pRunItem->member.run.style;
510 }
511 }
512}
BOOL ME_IsSelection(ME_TextEditor *editor)
Definition: caret.c:1578
int ME_GetSelection(ME_TextEditor *editor, ME_Cursor **from, ME_Cursor **to)
Definition: caret.c:57

Referenced by handle_enter(), ITextRange_fnSetText(), ME_Char(), ME_GetSelectionInsertStyle(), ME_HandleMessage(), ME_InsertEndParaFromCursor(), ME_InsertEndRowFromCursor(), ME_InsertOLEFromCursor(), and ME_SetSelectionCharFormat().

◆ ME_GetOLEObjectSize()

void ME_GetOLEObjectSize ( const ME_Context c,
ME_Run run,
SIZE pSize 
)

Definition at line 5727 of file richole.c.

5728{
5729 IDataObject* ido;
5730 FORMATETC fmt;
5731 STGMEDIUM stgm;
5732 DIBSECTION dibsect;
5733 ENHMETAHEADER emh;
5734
5735 assert(run->nFlags & MERF_GRAPHICS);
5736 assert(run->reobj);
5737
5738 if (run->reobj->obj.sizel.cx != 0 || run->reobj->obj.sizel.cy != 0)
5739 {
5740 convert_sizel(c, &run->reobj->obj.sizel, pSize);
5741 if (c->editor->nZoomNumerator != 0)
5742 {
5743 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5744 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5745 }
5746 return;
5747 }
5748
5749 if (!run->reobj->obj.poleobj)
5750 {
5751 pSize->cx = pSize->cy = 0;
5752 return;
5753 }
5754
5755 if (IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
5756 {
5757 FIXME("Query Interface IID_IDataObject failed!\n");
5758 pSize->cx = pSize->cy = 0;
5759 return;
5760 }
5761 fmt.cfFormat = CF_BITMAP;
5762 fmt.ptd = NULL;
5763 fmt.dwAspect = DVASPECT_CONTENT;
5764 fmt.lindex = -1;
5765 fmt.tymed = TYMED_GDI;
5766 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
5767 {
5768 fmt.cfFormat = CF_ENHMETAFILE;
5769 fmt.tymed = TYMED_ENHMF;
5770 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
5771 {
5772 FIXME("unsupported format\n");
5773 pSize->cx = pSize->cy = 0;
5774 IDataObject_Release(ido);
5775 return;
5776 }
5777 }
5778 IDataObject_Release(ido);
5779
5780 switch (stgm.tymed)
5781 {
5782 case TYMED_GDI:
5783 GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
5784 pSize->cx = dibsect.dsBm.bmWidth;
5785 pSize->cy = dibsect.dsBm.bmHeight;
5786 break;
5787 case TYMED_ENHMF:
5788 GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
5789 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
5790 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
5791 break;
5792 default:
5793 FIXME("Unsupported tymed %d\n", stgm.tymed);
5794 break;
5795 }
5796 ReleaseStgMedium(&stgm);
5797 if (c->editor->nZoomNumerator != 0)
5798 {
5799 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5800 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5801 }
5802}

Referenced by ME_CharFromPointContext(), ME_GetRunSizeCommon(), and ME_PointFromCharContext().

◆ ME_GetOuterParagraph()

ME_DisplayItem * ME_GetOuterParagraph ( ME_DisplayItem para)

Definition at line 172 of file table.c.

173{
174 if (para->member.para.nFlags & MEPF_ROWEND)
175 para = para->member.para.prev_para;
176 while (para->member.para.pCell)
177 {
178 para = ME_GetTableRowStart(para);
179 if (!para->member.para.pCell)
180 break;
182 }
183 return para;
184}

Referenced by ME_InvalidateParagraphRange().

◆ ME_GetParaBorderWidth()

int ME_GetParaBorderWidth ( const ME_Context c,
int  flags 
)

Definition at line 529 of file paint.c.

530{
531 int idx = (flags >> 8) & 0xF;
532 int width;
533
535 {
536 FIXME("Unsupported border value %d\n", idx);
537 return 0;
538 }
540 if (border_details[idx].dble) width = width * 2 + 1;
541 return width;
542}
unsigned int idx
Definition: utils.c:41
static int ME_GetBorderPenWidth(const ME_Context *c, int idx)
Definition: paint.c:516
static const struct @538 border_details[]
unsigned width
Definition: paint.c:490
unsigned dble
Definition: paint.c:490
GLint GLint GLsizei width
Definition: gl.h:1546

Referenced by ME_DrawParaDecoration(), and ME_WrapTextParagraph().

◆ ME_GetParagraph()

ME_DisplayItem * ME_GetParagraph ( ME_DisplayItem run)

◆ ME_GetRunSizeCommon()

SIZE ME_GetRunSizeCommon ( ME_Context c,
const ME_Paragraph para,
ME_Run run,
int  nLen,
int  startx,
int pAscent,
int pDescent 
)

Definition at line 616 of file run.c.

618{
619 static const WCHAR spaceW[] = {' ',0};
620 SIZE size;
621
622 nLen = min( nLen, run->len );
623
624 if (run->nFlags & MERF_ENDPARA)
625 {
626 nLen = min( nLen, 1 );
627 ME_GetTextExtent(c, spaceW, nLen, run->style, &size);
628 }
629 else if (para->nFlags & MEPF_COMPLEX)
630 {
631 size.cx = run->nWidth;
632 }
633 else if (c->editor->cPasswordMask)
634 {
635 ME_String *szMasked = ME_MakeStringR(c->editor->cPasswordMask,nLen);
636 ME_GetTextExtent(c, szMasked->szData, nLen,run->style, &size);
637 ME_DestroyString(szMasked);
638 }
639 else
640 {
641 ME_GetTextExtent(c, get_text( run, 0 ), nLen, run->style, &size);
642 }
643 *pAscent = run->style->tm.tmAscent;
644 *pDescent = run->style->tm.tmDescent;
645 size.cy = *pAscent + *pDescent;
646
647 if (run->nFlags & MERF_TAB)
648 {
649 int pos = 0, i = 0, ppos, shift = 0;
650 const PARAFORMAT2 *pFmt = &para->fmt;
651
652 if (c->editor->bEmulateVersion10 && /* v1.0 - 3.0 */
653 pFmt->dwMask & PFM_TABLE && pFmt->wEffects & PFE_TABLE)
654 /* The horizontal gap shifts the tab positions to leave the gap. */
655 shift = pFmt->dxOffset * 2;
656 do {
657 if (i < pFmt->cTabCount)
658 {
659 /* Only one side of the horizontal gap is needed at the end of
660 * the table row. */
661 if (i == pFmt->cTabCount -1)
662 shift = shift >> 1;
663 pos = shift + (pFmt->rgxTabs[i]&0x00FFFFFF);
664 i++;
665 }
666 else
667 {
669 }
670 ppos = ME_twips2pointsX(c, pos);
671 if (ppos > startx + run->pt.x) {
672 size.cx = ppos - startx - run->pt.x;
673 break;
674 }
675 } while(1);
676 size.cy = *pAscent + *pDescent;
677 return size;
678 }
679 if (run->nFlags & MERF_GRAPHICS)
680 {
681 ME_GetOLEObjectSize(c, run, &size);
682 if (size.cy > *pAscent)
683 *pAscent = size.cy;
684 /* descent is unchanged */
685 return size;
686 }
687 return size;
688}
static void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style *s, SIZE *size)
Definition: run.c:537
int ME_twips2pointsX(const ME_Context *c, int x) DECLSPEC_HIDDEN
Definition: paint.c:153
#define MERF_ENDPARA
Definition: editstr.h:122
GLsizeiptr size
Definition: glext.h:5919
#define shift
Definition: input.c:1755
static const WCHAR spaceW[]
Definition: mxwriter.c:44
#define lDefaultTab
Definition: richedit.h:215
LONG dxOffset
Definition: richedit.h:672
TEXTMETRICW tm
Definition: editstr.h:76
LONG tmAscent
Definition: wingdi.h:2384
LONG tmDescent
Definition: wingdi.h:2385

Referenced by calc_run_extent().

◆ ME_GetSelection()

int ME_GetSelection ( ME_TextEditor editor,
ME_Cursor **  from,
ME_Cursor **  to 
)

Definition at line 57 of file caret.c.

58{
59 int from_ofs = ME_GetCursorOfs( &editor->pCursors[0] );
60 int to_ofs = ME_GetCursorOfs( &editor->pCursors[1] );
61 BOOL swap = (from_ofs > to_ofs);
62
63 if (from_ofs == to_ofs)
64 {
65 /* If cursor[0] is at the beginning of a run and cursor[1] at the end
66 of the prev run then we need to swap. */
67 if (editor->pCursors[0].nOffset < editor->pCursors[1].nOffset)
68 swap = TRUE;
69 }
70
71 if (!swap)
72 {
73 *from = &editor->pCursors[0];
74 *to = &editor->pCursors[1];
75 return 0;
76 } else {
77 *from = &editor->pCursors[1];
78 *to = &editor->pCursors[0];
79 return 1;
80 }
81}
int ME_GetCursorOfs(const ME_Cursor *cursor)
Definition: caret.c:957
#define swap(a, b)
Definition: qsort.c:63

Referenced by IRichEditOle_fnGetObject(), ITextSelection_fnGetChar(), ITextSelection_fnGetText(), ME_GetInsertStyle(), ME_GetSelectionCharFormat(), ME_SetSelectionCharFormat(), ME_StreamIn(), and ME_UpdateSelectionLinkAttribute().

◆ ME_GetSelectionCharFormat()

void ME_GetSelectionCharFormat ( ME_TextEditor editor,
CHARFORMAT2W pFmt 
)

Definition at line 801 of file run.c.

802{
803 ME_Cursor *from, *to;
804 if (!ME_IsSelection(editor) && editor->pBuffer->pCharStyle)
805 {
806 ME_CopyCharFormat(pFmt, &editor->pBuffer->pCharStyle->fmt);
807 return;
808 }
809 ME_GetSelection(editor, &from, &to);
810 ME_GetCharFormat(editor, from, to, pFmt);
811}
void ME_GetCharFormat(ME_TextEditor *editor, const ME_Cursor *from, const ME_Cursor *to, CHARFORMAT2W *pFmt)
Definition: run.c:819

Referenced by ME_HandleMessage(), ME_KeyDown(), and update_caret().

◆ ME_GetSelectionInsertStyle()

ME_Style * ME_GetSelectionInsertStyle ( ME_TextEditor editor)

Definition at line 1593 of file caret.c.

1594{
1595 return ME_GetInsertStyle(editor, 0);
1596}
ME_Style * ME_GetInsertStyle(ME_TextEditor *editor, int nCursor) DECLSPEC_HIDDEN
Definition: style.c:476

Referenced by ME_HandleMessage(), ME_ReplaceSel(), and ME_StreamIn().

◆ ME_GetSelectionOfs()

◆ ME_GetSelectionParaFormat()

void ME_GetSelectionParaFormat ( ME_TextEditor editor,
PARAFORMAT2 pFmt 
)

Definition at line 937 of file para.c.

938{
939 ME_DisplayItem *para, *para_end;
940 PARAFORMAT2 *curFmt;
941
942 if (pFmt->cbSize < sizeof(PARAFORMAT)) {
943 pFmt->dwMask = 0;
944 return;
945 }
946
947 ME_GetSelectionParas(editor, &para, &para_end);
948
949 ME_GetParaFormat(editor, para, pFmt);
950
951 /* Invalidate values that change across the selected paragraphs. */
952 while (para != para_end)
953 {
954 para = para->member.para.next_para;
955 curFmt = &para->member.para.fmt;
956
957#define CHECK_FIELD(m, f) \
958 if (pFmt->f != curFmt->f) pFmt->dwMask &= ~(m);
959
960 CHECK_FIELD(PFM_NUMBERING, wNumbering);
961 CHECK_FIELD(PFM_STARTINDENT, dxStartIndent);
962 CHECK_FIELD(PFM_RIGHTINDENT, dxRightIndent);
963 CHECK_FIELD(PFM_OFFSET, dxOffset);
964 CHECK_FIELD(PFM_ALIGNMENT, wAlignment);
965 if (pFmt->dwMask & PFM_TABSTOPS) {
966 if (pFmt->cTabCount != para->member.para.fmt.cTabCount ||
967 memcmp(pFmt->rgxTabs, curFmt->rgxTabs, curFmt->cTabCount*sizeof(int)))
968 pFmt->dwMask &= ~PFM_TABSTOPS;
969 }
970
971 if (pFmt->dwMask >= sizeof(PARAFORMAT2))
972 {
973 pFmt->dwMask &= ~((pFmt->wEffects ^ curFmt->wEffects) << 16);
974 CHECK_FIELD(PFM_SPACEBEFORE, dySpaceBefore);
975 CHECK_FIELD(PFM_SPACEAFTER, dySpaceAfter);
976 CHECK_FIELD(PFM_LINESPACING, dyLineSpacing);
977 CHECK_FIELD(PFM_STYLE, sStyle);
978 CHECK_FIELD(PFM_SPACEAFTER, bLineSpacingRule);
979 CHECK_FIELD(PFM_SHADING, wShadingWeight);
980 CHECK_FIELD(PFM_SHADING, wShadingStyle);
981 CHECK_FIELD(PFM_NUMBERINGSTART, wNumberingStart);
982 CHECK_FIELD(PFM_NUMBERINGSTYLE, wNumberingStyle);
983 CHECK_FIELD(PFM_NUMBERINGTAB, wNumberingTab);
984 CHECK_FIELD(PFM_BORDER, wBorderSpace);
985 CHECK_FIELD(PFM_BORDER, wBorderWidth);
986 CHECK_FIELD(PFM_BORDER, wBorders);
987 }
988#undef CHECK_FIELD
989 }
990}
#define CHECK_FIELD(m, f)
void ME_GetSelectionParas(ME_TextEditor *editor, ME_DisplayItem **para, ME_DisplayItem **para_end)
Definition: para.c:883
static void ME_GetParaFormat(ME_TextEditor *editor, const ME_DisplayItem *para, PARAFORMAT2 *pFmt)
Definition: para.c:923

Referenced by ME_HandleMessage(), and ME_RTFParAttrHook().

◆ ME_GetSelectionParas()

void ME_GetSelectionParas ( ME_TextEditor editor,
ME_DisplayItem **  para,
ME_DisplayItem **  para_end 
)

Definition at line 883 of file para.c.

884{
885 ME_Cursor *pEndCursor = &editor->pCursors[1];
886
887 *para = editor->pCursors[0].pPara;
888 *para_end = editor->pCursors[1].pPara;
889 if (*para == *para_end)
890 return;
891
892 if ((*para_end)->member.para.nCharOfs < (*para)->member.para.nCharOfs) {
893 ME_DisplayItem *tmp = *para;
894
895 *para = *para_end;
896 *para_end = tmp;
897 pEndCursor = &editor->pCursors[0];
898 }
899
900 /* The paragraph at the end of a non-empty selection isn't included
901 * if the selection ends at the start of the paragraph. */
902 if (!pEndCursor->pRun->member.run.nCharOfs && !pEndCursor->nOffset)
903 *para_end = (*para_end)->member.para.prev_para;
904}

Referenced by ME_GetSelectionParaFormat(), ME_InvalidateSelection(), and ME_SetSelectionParaFormat().

◆ ME_GetTableRowEnd()

ME_DisplayItem * ME_GetTableRowEnd ( ME_DisplayItem para)

Definition at line 136 of file table.c.

137{
138 ME_DisplayItem *cell;
139 assert(para);
140 if (para->member.para.nFlags & MEPF_ROWEND)
141 return para;
142 if (para->member.para.nFlags & MEPF_ROWSTART)
143 para = para->member.para.next_para;
144 cell = para->member.para.pCell;
145 assert(cell && cell->type == diCell);
146 while (cell->member.cell.next_cell)
147 cell = cell->member.cell.next_cell;
148
149 para = ME_FindItemFwd(cell, diParagraph);
150 assert(para && para->member.para.nFlags & MEPF_ROWEND);
151 return para;
152}

Referenced by ME_AppendTableRow(), ME_BeginRow(), ME_DrawTableBorders(), ME_FindPixelPos(), ME_MoveCursorLines(), ME_ProtectPartialTableDeletion(), ME_SelectOrInsertNextCell(), ME_StreamOutRTFTableProps(), and ME_WrapTextParagraph().

◆ ME_GetTableRowStart()

ME_DisplayItem * ME_GetTableRowStart ( ME_DisplayItem para)

Definition at line 154 of file table.c.

155{
156 ME_DisplayItem *cell;
157 assert(para);
158 if (para->member.para.nFlags & MEPF_ROWSTART)
159 return para;
160 if (para->member.para.nFlags & MEPF_ROWEND)
161 para = para->member.para.prev_para;
162 cell = para->member.para.pCell;
163 assert(cell && cell->type == diCell);
164 while (cell->member.cell.prev_cell)
165 cell = cell->member.cell.prev_cell;
166
167 para = ME_FindItemBack(cell, diParagraph);
168 assert(para && para->member.para.nFlags & MEPF_ROWSTART);
169 return para;
170}

Referenced by ME_AppendTableRow(), ME_GetOuterParagraph(), ME_MoveCursorLines(), ME_SelectOrInsertNextCell(), and ME_StreamOutRTFTableProps().

◆ ME_GetTextLength()

◆ ME_GetTextLengthEx()

int ME_GetTextLengthEx ( ME_TextEditor editor,
const GETTEXTLENGTHEX how 
)

Definition at line 91 of file caret.c.

92{
93 int length;
94
95 if (how->flags & GTL_PRECISE && how->flags & GTL_CLOSE)
96 return E_INVALIDARG;
97 if (how->flags & GTL_NUMCHARS && how->flags & GTL_NUMBYTES)
98 return E_INVALIDARG;
99
100 length = ME_GetTextLength(editor);
101
102 if ((editor->styleFlags & ES_MULTILINE)
103 && (how->flags & GTL_USECRLF)
104 && !editor->bEmulateVersion10) /* Ignore GTL_USECRLF flag in 1.0 emulation */
105 length += editor->nParagraphs - 1;
106
107 if (how->flags & GTL_NUMBYTES ||
108 (how->flags & GTL_PRECISE && /* GTL_PRECISE seems to imply GTL_NUMBYTES */
109 !(how->flags & GTL_NUMCHARS))) /* unless GTL_NUMCHARS is given */
110 {
111 CPINFO cpinfo;
112
113 if (how->codepage == 1200)
114 return length * 2;
115 if (how->flags & GTL_PRECISE)
116 FIXME("GTL_PRECISE flag unsupported. Using GTL_CLOSE\n");
117 if (GetCPInfo(how->codepage, &cpinfo))
118 return length * cpinfo.MaxCharSize;
119 ERR("Invalid codepage %u\n", how->codepage);
120 return E_INVALIDARG;
121 }
122 return length;
123}
#define ERR(fmt,...)
Definition: debug.h:110
#define E_INVALIDARG
Definition: ddrawi.h:101
BOOL WINAPI GetCPInfo(UINT CodePage, LPCPINFO CodePageInfo)
Definition: nls.c:2039
int ME_GetTextLength(ME_TextEditor *editor)
Definition: caret.c:83
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define ES_MULTILINE
Definition: pedump.c:667
#define GTL_CLOSE
Definition: richedit.h:1057
#define GTL_NUMCHARS
Definition: richedit.h:1058
#define GTL_PRECISE
Definition: richedit.h:1056
#define GTL_NUMBYTES
Definition: richedit.h:1059
#define GTL_USECRLF
Definition: richedit.h:1055
UINT MaxCharSize
Definition: winnls.h:581

Referenced by ME_HandleMessage().

◆ ME_GetTextW()

int ME_GetTextW ( ME_TextEditor editor,
WCHAR buffer,
int  buflen,
const ME_Cursor start,
int  srcChars,
BOOL  bCRLF,
BOOL  bEOP 
)

Definition at line 5192 of file editor.c.

5195{
5196 ME_DisplayItem *pRun, *pNextRun;
5197 const WCHAR *pStart = buffer;
5198 const WCHAR cr_lf[] = {'\r', '\n', 0};
5199 const WCHAR *str;
5200 int nLen;
5201
5202 /* bCRLF flag is only honored in 2.0 and up. 1.0 must always return text verbatim */
5203 if (editor->bEmulateVersion10) bCRLF = FALSE;
5204
5205 pRun = start->pRun;
5206 assert(pRun);
5207 pNextRun = ME_FindItemFwd(pRun, diRun);
5208
5209 nLen = pRun->member.run.len - start->nOffset;
5210 str = get_text( &pRun->member.run, start->nOffset );
5211
5212 while (srcChars && buflen && pNextRun)
5213 {
5214 int nFlags = pRun->member.run.nFlags;
5215
5216 if (bCRLF && nFlags & MERF_ENDPARA && ~nFlags & MERF_ENDCELL)
5217 {
5218 if (buflen == 1) break;
5219 /* FIXME: native fails to reduce srcChars here for WM_GETTEXT or
5220 * EM_GETTEXTEX, however, this is done for copying text which
5221 * also uses this function. */
5222 srcChars -= min(nLen, srcChars);
5223 nLen = 2;
5224 str = cr_lf;
5225 } else {
5226 nLen = min(nLen, srcChars);
5227 srcChars -= nLen;
5228 }
5229
5230 nLen = min(nLen, buflen);
5231 buflen -= nLen;
5232
5233 CopyMemory(buffer, str, sizeof(WCHAR) * nLen);
5234
5235 buffer += nLen;
5236
5237 pRun = pNextRun;
5238 pNextRun = ME_FindItemFwd(pRun, diRun);
5239
5240 nLen = pRun->member.run.len;
5241 str = get_text( &pRun->member.run, 0 );
5242 }
5243 /* append '\r' to the last paragraph. */
5244 if (pRun->next->type == diTextEnd && bEOP)
5245 {
5246 *buffer = '\r';
5247 buffer ++;
5248 }
5249 *buffer = 0;
5250 return buffer - pStart;
5251}
static const WCHAR cr_lf[]
Definition: table.c:59

Referenced by fnTextSrv_TxGetText(), get_unicode_text(), ITextRange_fnGetText(), ITextSelection_fnGetText(), ME_GetTextEx(), ME_GetTextRange(), ME_IsCandidateAnURL(), ME_StreamIn(), and range_GetChar().

◆ ME_HandleMessage()

LRESULT ME_HandleMessage ( ME_TextEditor editor,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  unicode,
HRESULT phresult 
)

Definition at line 3604 of file editor.c.

3606{
3607 *phresult = S_OK;
3608
3609 switch(msg) {
3610
3633
3634/* Messages specific to Richedit controls */
3635
3636 case EM_STREAMIN:
3637 return ME_StreamIn(editor, wParam, (EDITSTREAM*)lParam, TRUE);
3638 case EM_STREAMOUT:
3639 return ME_StreamOut(editor, wParam, (EDITSTREAM *)lParam);
3640 case WM_GETDLGCODE:
3641 {
3643
3644 if (lParam)
3645 editor->bDialogMode = TRUE;
3646 if (editor->styleFlags & ES_MULTILINE)
3648 if (!(editor->styleFlags & ES_SAVESEL))
3650 return code;
3651 }
3652 case EM_EMPTYUNDOBUFFER:
3653 ME_EmptyUndoStack(editor);
3654 return 0;
3655 case EM_GETSEL:
3656 {
3657 /* Note: wParam/lParam can be NULL */
3658 UINT from, to;
3659 PUINT pfrom = wParam ? (PUINT)wParam : &from;
3660 PUINT pto = lParam ? (PUINT)lParam : &to;
3661 ME_GetSelectionOfs(editor, (int *)pfrom, (int *)pto);
3662 if ((*pfrom|*pto) & 0xFFFF0000)
3663 return -1;
3664 return MAKELONG(*pfrom,*pto);
3665 }
3666 case EM_EXGETSEL:
3667 {
3668 CHARRANGE *pRange = (CHARRANGE *)lParam;
3669 ME_GetSelectionOfs(editor, &pRange->cpMin, &pRange->cpMax);
3670 TRACE("EM_EXGETSEL = (%d,%d)\n", pRange->cpMin, pRange->cpMax);
3671 return 0;
3672 }
3673 case EM_SETUNDOLIMIT:
3674 {
3675 if ((int)wParam < 0)
3677 else
3678 editor->nUndoLimit = min(wParam, STACK_SIZE_MAX);
3679 /* Setting a max stack size keeps wine from getting killed
3680 for hogging memory. Windows allocates all this memory at once, so
3681 no program would realistically set a value above our maximum. */
3682 return editor->nUndoLimit;
3683 }
3684 case EM_CANUNDO:
3685 return !list_empty( &editor->undo_stack );
3686 case EM_CANREDO:
3687 return !list_empty( &editor->redo_stack );
3688 case WM_UNDO: /* FIXME: actually not the same */
3689 case EM_UNDO:
3690 return ME_Undo(editor);
3691 case EM_REDO:
3692 return ME_Redo(editor);
3693 case EM_GETOPTIONS:
3694 {
3695 /* these flags are equivalent to the ES_* counterparts */
3698 DWORD settings = editor->styleFlags & mask;
3699
3700 return settings;
3701 }
3702 case EM_SETFONTSIZE:
3703 {
3705 LONG tmp_size, size;
3706 BOOL is_increase = ((LONG)wParam > 0);
3707
3708 if (editor->mode & TM_PLAINTEXT)
3709 return FALSE;
3710
3711 cf.cbSize = sizeof(cf);
3712 cf.dwMask = CFM_SIZE;
3713 ME_GetSelectionCharFormat(editor, &cf);
3714 tmp_size = (cf.yHeight / 20) + wParam;
3715
3716 if (tmp_size <= 1)
3717 size = 1;
3718 else if (tmp_size > 12 && tmp_size < 28 && tmp_size % 2)
3719 size = tmp_size + (is_increase ? 1 : -1);
3720 else if (tmp_size > 28 && tmp_size < 36)
3721 size = is_increase ? 36 : 28;
3722 else if (tmp_size > 36 && tmp_size < 48)
3723 size = is_increase ? 48 : 36;
3724 else if (tmp_size > 48 && tmp_size < 72)
3725 size = is_increase ? 72 : 48;
3726 else if (tmp_size > 72 && tmp_size < 80)
3727 size = is_increase ? 80 : 72;
3728 else if (tmp_size > 80 && tmp_size < 1638)
3729 size = 10 * (is_increase ? (tmp_size / 10 + 1) : (tmp_size / 10));
3730 else if (tmp_size >= 1638)
3731 size = 1638;
3732 else
3733 size = tmp_size;
3734
3735 cf.yHeight = size * 20; /* convert twips to points */
3736 ME_SetSelectionCharFormat(editor, &cf);
3737 ME_CommitUndo(editor);
3739 ME_UpdateScrollBar(editor);
3740
3741 return TRUE;
3742 }
3743 case EM_SETOPTIONS:
3744 {
3745 /* these flags are equivalent to ES_* counterparts, except for
3746 * ECO_AUTOWORDSELECTION that doesn't have an ES_* counterpart,
3747 * but is still stored in editor->styleFlags. */
3751 DWORD settings = mask & editor->styleFlags;
3752 DWORD oldSettings = settings;
3753 DWORD changedSettings;
3754
3755 switch(wParam)
3756 {
3757 case ECOOP_SET:
3758 settings = lParam;
3759 break;
3760 case ECOOP_OR:
3761 settings |= lParam;
3762 break;
3763 case ECOOP_AND:
3764 settings &= lParam;
3765 break;
3766 case ECOOP_XOR:
3767 settings ^= lParam;
3768 }
3769 changedSettings = oldSettings ^ settings;
3770
3771 if (changedSettings) {
3772 editor->styleFlags = (editor->styleFlags & ~mask) | (settings & mask);
3773
3774 if (changedSettings & ECO_SELECTIONBAR)
3775 {
3777 if (settings & ECO_SELECTIONBAR) {
3778 assert(!editor->selofs);
3779 editor->selofs = SELECTIONBAR_WIDTH;
3780 editor->rcFormat.left += editor->selofs;
3781 } else {
3782 editor->rcFormat.left -= editor->selofs;
3783 editor->selofs = 0;
3784 }
3785 ME_RewrapRepaint(editor);
3786 }
3787
3788 if ((changedSettings & settings & ES_NOHIDESEL) && !editor->bHaveFocus)
3789 ME_InvalidateSelection( editor );
3790
3791 if (changedSettings & settings & ECO_VERTICAL)
3792 FIXME("ECO_VERTICAL not implemented yet!\n");
3793 if (changedSettings & settings & ECO_AUTOHSCROLL)
3794 FIXME("ECO_AUTOHSCROLL not implemented yet!\n");
3795 if (changedSettings & settings & ECO_AUTOVSCROLL)
3796 FIXME("ECO_AUTOVSCROLL not implemented yet!\n");
3797 if (changedSettings & settings & ECO_WANTRETURN)
3798 FIXME("ECO_WANTRETURN not implemented yet!\n");
3799 if (changedSettings & settings & ECO_AUTOWORDSELECTION)
3800 FIXME("ECO_AUTOWORDSELECTION not implemented yet!\n");
3801 }
3802
3803 return settings;
3804 }
3805 case EM_SETSEL:
3806 {
3807 return set_selection( editor, wParam, lParam );
3808 }
3809 case EM_SETSCROLLPOS:
3810 {
3811 POINT *point = (POINT *)lParam;
3812 ME_ScrollAbs(editor, point->x, point->y);
3813 return 0;
3814 }
3815 case EM_AUTOURLDETECT:
3816 {
3817 if (wParam==1 || wParam ==0)
3818 {
3820 return 0;
3821 }
3822 return E_INVALIDARG;
3823 }
3825 {
3826 return editor->AutoURLDetect_bEnable;
3827 }
3828 case EM_EXSETSEL:
3829 {
3831
3832 return set_selection( editor, range.cpMin, range.cpMax );
3833 }
3834 case EM_SHOWSCROLLBAR:
3835 {
3836 DWORD flags;
3837
3838 switch (wParam)
3839 {
3840 case SB_HORZ:
3841 flags = WS_HSCROLL;
3842 break;
3843 case SB_VERT:
3844 flags = WS_VSCROLL;
3845 break;
3846 case SB_BOTH:
3848 break;
3849 default:
3850 return 0;
3851 }
3852
3853 if (lParam) {
3854 editor->styleFlags |= flags;
3855 if (flags & WS_HSCROLL)
3857 editor->nTotalWidth > editor->sizeWindow.cx);
3858 if (flags & WS_VSCROLL)
3860 editor->nTotalLength > editor->sizeWindow.cy);
3861 } else {
3862 editor->styleFlags &= ~flags;
3864 }
3865 return 0;
3866 }
3867 case EM_SETTEXTEX:
3868 {
3869 LPWSTR wszText;
3870 SETTEXTEX *pStruct = (SETTEXTEX *)wParam;
3871 int from, to, len;
3872 ME_Style *style;
3873 BOOL bRtf, bUnicode, bSelection, bUTF8;
3874 int oldModify = editor->nModifyStep;
3875 static const char utf8_bom[] = {0xef, 0xbb, 0xbf};
3876
3877 if (!pStruct) return 0;
3878
3879 /* If we detect ascii rtf at the start of the string,
3880 * we know it isn't unicode. */
3881 bRtf = (lParam && (!strncmp((char *)lParam, "{\\rtf", 5) ||
3882 !strncmp((char *)lParam, "{\\urtf", 6)));
3883 bUnicode = !bRtf && pStruct->codepage == CP_UNICODE;
3884 bUTF8 = (lParam && (!strncmp((char *)lParam, utf8_bom, 3)));
3885
3886 TRACE("EM_SETTEXTEX - %s, flags %d, cp %d\n",
3888 pStruct->flags, pStruct->codepage);
3889
3890 bSelection = (pStruct->flags & ST_SELECTION) != 0;
3891 if (bSelection) {
3892 int nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
3894 ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to - from, FALSE);
3895 } else {
3897 ME_SetCursorToStart(editor, &start);
3899 style = editor->pBuffer->pDefaultStyle;
3900 }
3901
3902 if (bRtf) {
3903 ME_StreamInRTFString(editor, bSelection, (char *)lParam);
3904 if (bSelection) {
3905 /* FIXME: The length returned doesn't include the rtf control
3906 * characters, only the actual text. */
3907 len = lParam ? strlen((char *)lParam) : 0;
3908 }
3909 } else {
3910 if (bUTF8 && !bUnicode) {
3911 wszText = ME_ToUnicode(CP_UTF8, (void *)(lParam+3), &len);
3912 ME_InsertTextFromCursor(editor, 0, wszText, len, style);
3913 ME_EndToUnicode(CP_UTF8, wszText);
3914 } else {
3915 wszText = ME_ToUnicode(pStruct->codepage, (void *)lParam, &len);
3916 ME_InsertTextFromCursor(editor, 0, wszText, len, style);
3917 ME_EndToUnicode(pStruct->codepage, wszText);
3918 }
3919 }
3920
3921 if (bSelection) {
3924 } else {
3926 len = 1;
3927 ME_SetCursorToStart(editor, &cursor);
3929 }
3930 ME_CommitUndo(editor);
3931 if (!(pStruct->flags & ST_KEEPUNDO))
3932 {
3933 editor->nModifyStep = oldModify;
3934 ME_EmptyUndoStack(editor);
3935 }
3936 ME_UpdateRepaint(editor, FALSE);
3937 return len;
3938 }
3939 case EM_SELECTIONTYPE:
3940 return ME_GetSelectionType(editor);
3941 case EM_SETBKGNDCOLOR:
3942 {
3943 LRESULT lColor;
3944 if (editor->rgbBackColor != -1) {
3945 DeleteObject(editor->hbrBackground);
3946 lColor = editor->rgbBackColor;
3947 }
3948 else lColor = ITextHost_TxGetSysColor(editor->texthost, COLOR_WINDOW);
3949
3950 if (wParam)
3951 {
3952 editor->rgbBackColor = -1;
3954 }
3955 else
3956 {
3957 editor->rgbBackColor = lParam;
3958 editor->hbrBackground = CreateSolidBrush(editor->rgbBackColor);
3959 }
3961 return lColor;
3962 }
3963 case EM_GETMODIFY:
3964 return editor->nModifyStep == 0 ? 0 : -1;
3965 case EM_SETMODIFY:
3966 {
3967 if (wParam)
3968 editor->nModifyStep = 1;
3969 else
3970 editor->nModifyStep = 0;
3971
3972 return 0;
3973 }
3974 case EM_SETREADONLY:
3975 {
3976 if (wParam)
3977 editor->styleFlags |= ES_READONLY;
3978 else
3979 editor->styleFlags &= ~ES_READONLY;
3980 return 1;
3981 }
3982 case EM_SETEVENTMASK:
3983 {
3984 DWORD nOldMask = editor->nEventMask;
3985
3986 editor->nEventMask = lParam;
3987 return nOldMask;
3988 }
3989 case EM_GETEVENTMASK:
3990 return editor->nEventMask;
3991 case EM_SETCHARFORMAT:
3992 return handle_EM_SETCHARFORMAT( editor, wParam, (CHARFORMAT2W *)lParam );
3993 case EM_GETCHARFORMAT:
3994 {
3996 if (dst->cbSize != sizeof(CHARFORMATA) &&
3997 dst->cbSize != sizeof(CHARFORMATW) &&
3998 dst->cbSize != sizeof(CHARFORMAT2A) &&
3999 dst->cbSize != sizeof(CHARFORMAT2W))
4000 return 0;
4001 tmp.cbSize = sizeof(tmp);
4002 if (!wParam)
4003 ME_GetDefaultCharFormat(editor, &tmp);
4004 else
4005 ME_GetSelectionCharFormat(editor, &tmp);
4006 cf2w_to_cfany(dst, &tmp);
4007 return tmp.dwMask;
4008 }
4009 case EM_SETPARAFORMAT:
4010 {
4013 ME_UpdateScrollBar(editor);
4014 ME_CommitUndo(editor);
4015 return result;
4016 }
4017 case EM_GETPARAFORMAT:
4019 return ((PARAFORMAT2 *)lParam)->dwMask;
4021 {
4022 ME_DisplayItem *p = editor->pBuffer->pFirst;
4023 int y = editor->vert_si.nPos;
4024 int ypara = 0;
4025 int count = 0;
4026 int ystart, yend;
4027 while(p) {
4029 if (p->type == diTextEnd)
4030 break;
4031 if (p->type == diParagraph) {
4032 ypara = p->member.para.pt.y;
4033 continue;
4034 }
4035 ystart = ypara + p->member.row.pt.y;
4036 yend = ystart + p->member.row.nHeight;
4037 if (y < yend) {
4038 break;
4039 }
4040 count++;
4041 }
4042 return count;
4043 }
4044 case EM_HIDESELECTION:
4045 {
4046 editor->bHideSelection = (wParam != 0);
4047 ME_InvalidateSelection(editor);
4048 return 0;
4049 }
4050 case EM_LINESCROLL:
4051 {
4052 if (!(editor->styleFlags & ES_MULTILINE))
4053 return FALSE;
4054 ME_ScrollDown( editor, lParam * get_default_line_height( editor ) );
4055 return TRUE;
4056 }
4057 case WM_CLEAR:
4058 {
4059 int from, to;
4060 int nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
4061 ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to-from, FALSE);
4062 ME_CommitUndo(editor);
4063 ME_UpdateRepaint(editor, TRUE);
4064 return 0;
4065 }
4066 case EM_REPLACESEL:
4067 {
4068 int len = 0;
4069 LONG codepage = unicode ? CP_UNICODE : CP_ACP;
4070 LPWSTR wszText = ME_ToUnicode(codepage, (void *)lParam, &len);
4071
4072 TRACE("EM_REPLACESEL - %s\n", debugstr_w(wszText));
4073
4074 ME_ReplaceSel(editor, !!wParam, wszText, len);
4075 ME_EndToUnicode(codepage, wszText);
4076 return len;
4077 }
4078 case EM_SCROLLCARET:
4079 ME_EnsureVisible(editor, &editor->pCursors[0]);
4080 return 0;
4081 case WM_SETFONT:
4082 {
4083 LOGFONTW lf;
4085 HDC hDC;
4086 BOOL bRepaint = LOWORD(lParam);
4087
4088 if (!wParam)
4090
4091 if (!GetObjectW((HGDIOBJ)wParam, sizeof(LOGFONTW), &lf))
4092 return 0;
4093
4094 hDC = ITextHost_TxGetDC(editor->texthost);
4097 if (editor->mode & TM_RICHTEXT) {
4099 ME_SetCursorToStart(editor, &start);
4100 ME_SetCharFormat(editor, &start, NULL, &fmt);
4101 }
4102 ME_SetDefaultCharFormat(editor, &fmt);
4103
4104 ME_CommitUndo(editor);
4105 ME_MarkAllForWrapping(editor);
4107 ME_UpdateScrollBar(editor);
4108 if (bRepaint)
4109 ME_Repaint(editor);
4110#ifdef __REACTOS__
4112 {
4113 HIMC hIMC = ImmGetContext(editor->hWnd);
4114 ImmSetCompositionFontW(hIMC, &lf);
4115 ImmReleaseContext(editor->hWnd, hIMC);
4116 }
4117#endif
4118 return 0;
4119 }
4120 case WM_SETTEXT:
4121 {
4123 ME_SetCursorToStart(editor, &cursor);
4125 if (lParam)
4126 {
4127 TRACE("WM_SETTEXT lParam==%lx\n",lParam);
4128 if (!strncmp((char *)lParam, "{\\rtf", 5) ||
4129 !strncmp((char *)lParam, "{\\urtf", 6))
4130 {
4131 /* Undocumented: WM_SETTEXT supports RTF text */
4132 ME_StreamInRTFString(editor, 0, (char *)lParam);
4133 }
4134 else
4135 ME_SetText(editor, (void*)lParam, unicode);
4136 }
4137 else
4138 TRACE("WM_SETTEXT - NULL\n");
4139 ME_SetCursorToStart(editor, &cursor);
4141 set_selection_cursors(editor, 0, 0);
4142 editor->nModifyStep = 0;
4143 ME_CommitUndo(editor);
4144 ME_EmptyUndoStack(editor);
4145 ME_UpdateRepaint(editor, FALSE);
4146 return 1;
4147 }
4148 case EM_CANPASTE:
4149 return paste_special( editor, 0, NULL, TRUE );
4150 case WM_PASTE:
4151 case WM_MBUTTONDOWN:
4152 wParam = 0;
4153 lParam = 0;
4154 /* fall through */
4155 case EM_PASTESPECIAL:
4157 return 0;
4158 case WM_CUT:
4159 case WM_COPY:
4160 copy_or_cut(editor, msg == WM_CUT);
4161 return 0;
4162 case WM_GETTEXTLENGTH:
4163 {
4164 GETTEXTLENGTHEX how;
4165
4166 /* CR/LF conversion required in 2.0 mode, verbatim in 1.0 mode */
4167 how.flags = GTL_CLOSE | (editor->bEmulateVersion10 ? 0 : GTL_USECRLF) | GTL_NUMCHARS;
4168 how.codepage = unicode ? CP_UNICODE : CP_ACP;
4169 return ME_GetTextLengthEx(editor, &how);
4170 }
4171 case EM_GETTEXTLENGTHEX:
4172 return ME_GetTextLengthEx(editor, (GETTEXTLENGTHEX *)wParam);
4173 case WM_GETTEXT:
4174 {
4175 GETTEXTEX ex;
4176 ex.cb = wParam * (unicode ? sizeof(WCHAR) : sizeof(CHAR));
4177 ex.flags = GT_USECRLF;
4178 ex.codepage = unicode ? CP_UNICODE : CP_ACP;
4179 ex.lpDefaultChar = NULL;
4180 ex.lpUsedDefChar = NULL;
4181 return ME_GetTextEx(editor, &ex, lParam);
4182 }
4183 case EM_GETTEXTEX:
4184 return ME_GetTextEx(editor, (GETTEXTEX*)wParam, lParam);
4185 case EM_GETSELTEXT:
4186 {
4187 int nFrom, nTo, nStartCur = ME_GetSelectionOfs(editor, &nFrom, &nTo);
4188 ME_Cursor *from = &editor->pCursors[nStartCur];
4189 return ME_GetTextRange(editor, (WCHAR *)lParam, from,
4190 nTo - nFrom, unicode);
4191 }
4192 case EM_GETSCROLLPOS:
4193 {
4194 POINT *point = (POINT *)lParam;
4195 point->x = editor->horz_si.nPos;
4196 point->y = editor->vert_si.nPos;
4197 /* 16-bit scaled value is returned as stored in scrollinfo */
4198 if (editor->horz_si.nMax > 0xffff)
4199 point->x = MulDiv(point->x, 0xffff, editor->horz_si.nMax);
4200 if (editor->vert_si.nMax > 0xffff)
4201 point->y = MulDiv(point->y, 0xffff, editor->vert_si.nMax);
4202 return 1;
4203 }
4204 case EM_GETTEXTRANGE:
4205 {
4206 TEXTRANGEW *rng = (TEXTRANGEW *)lParam;
4208 int nStart = rng->chrg.cpMin;
4209 int nEnd = rng->chrg.cpMax;
4210 int textlength = ME_GetTextLength(editor);
4211
4212 TRACE("EM_GETTEXTRANGE min=%d max=%d unicode=%d textlength=%d\n",
4213 rng->chrg.cpMin, rng->chrg.cpMax, unicode, textlength);
4214 if (nStart < 0) return 0;
4215 if ((nStart == 0 && nEnd == -1) || nEnd > textlength)
4216 nEnd = textlength;
4217 if (nStart >= nEnd) return 0;
4218
4219 ME_CursorFromCharOfs(editor, nStart, &start);
4220 return ME_GetTextRange(editor, rng->lpstrText, &start, nEnd - nStart, unicode);
4221 }
4222 case EM_GETLINE:
4223 {
4224 ME_DisplayItem *run;
4225 const unsigned int nMaxChars = *(WORD *) lParam;
4226 unsigned int nCharsLeft = nMaxChars;
4227 char *dest = (char *) lParam;
4228 BOOL wroteNull = FALSE;
4229
4230 TRACE("EM_GETLINE: row=%d, nMaxChars=%d (%s)\n", (int) wParam, nMaxChars,
4231 unicode ? "Unicode" : "Ansi");
4232
4233 run = ME_FindRowWithNumber(editor, wParam);
4234 if (run == NULL)
4235 return 0;
4236
4237 while (nCharsLeft && (run = ME_FindItemFwd(run, diRunOrStartRow))
4238 && run->type == diRun)
4239 {
4240 WCHAR *str = get_text( &run->member.run, 0 );
4241 unsigned int nCopy;
4242
4243 nCopy = min(nCharsLeft, run->member.run.len);
4244
4245 if (unicode)
4246 memcpy(dest, str, nCopy * sizeof(WCHAR));
4247 else
4248 nCopy = WideCharToMultiByte(CP_ACP, 0, str, nCopy, dest,
4249 nCharsLeft, NULL, NULL);
4250 dest += nCopy * (unicode ? sizeof(WCHAR) : 1);
4251 nCharsLeft -= nCopy;
4252 }
4253
4254 /* append line termination, space allowing */
4255 if (nCharsLeft > 0)
4256 {
4257 if (unicode)
4258 *((WCHAR *)dest) = '\0';
4259 else
4260 *dest = '\0';
4261 nCharsLeft--;
4262 wroteNull = TRUE;
4263 }
4264
4265 TRACE("EM_GETLINE: got %u characters\n", nMaxChars - nCharsLeft);
4266 return nMaxChars - nCharsLeft - (wroteNull ? 1 : 0);
4267 }
4268 case EM_GETLINECOUNT:
4269 {
4270 ME_DisplayItem *item = editor->pBuffer->pLast;
4271 int nRows = editor->total_rows;
4272 ME_DisplayItem *prev_para = NULL, *last_para = NULL;
4273
4274 last_para = ME_FindItemBack(item, diRun);
4275 prev_para = ME_FindItemBack(last_para, diRun);
4276 assert(last_para);
4277 assert(last_para->member.run.nFlags & MERF_ENDPARA);
4278 if (editor->bEmulateVersion10 && prev_para &&
4279 last_para->member.run.nCharOfs == 0 &&
4280 prev_para->member.run.len == 1 &&
4281 *get_text( &prev_para->member.run, 0 ) == '\r')
4282 {
4283 /* In 1.0 emulation, the last solitary \r at the very end of the text
4284 (if one exists) is NOT a line break.
4285 FIXME: this is an ugly hack. This should have a more regular model. */
4286 nRows--;
4287 }
4288
4289 TRACE("EM_GETLINECOUNT: nRows==%d\n", nRows);
4290 return max(1, nRows);
4291 }
4292 case EM_LINEFROMCHAR:
4293 {
4294 if (wParam == -1)
4295 return ME_RowNumberFromCharOfs(editor, ME_GetCursorOfs(&editor->pCursors[1]));
4296 else
4297 return ME_RowNumberFromCharOfs(editor, wParam);
4298 }
4299 case EM_EXLINEFROMCHAR:
4300 {
4301 if (lParam == -1)
4302 return ME_RowNumberFromCharOfs(editor, ME_GetCursorOfs(&editor->pCursors[1]));
4303 else
4304 return ME_RowNumberFromCharOfs(editor, lParam);
4305 }
4306 case EM_LINEINDEX:
4307 {
4308 ME_DisplayItem *item, *para;
4309 int nCharOfs;
4310
4311 if (wParam == -1)
4313 else
4314 item = ME_FindRowWithNumber(editor, wParam);
4315 if (!item)
4316 return -1;
4317 para = ME_GetParagraph(item);
4319 nCharOfs = para->member.para.nCharOfs + item->member.run.nCharOfs;
4320 TRACE("EM_LINEINDEX: nCharOfs==%d\n", nCharOfs);
4321 return nCharOfs;
4322 }
4323 case EM_LINELENGTH:
4324 {
4325 ME_DisplayItem *item, *item_end;
4326 int nChars = 0, nThisLineOfs = 0, nNextLineOfs = 0;
4327 ME_DisplayItem *para, *run;
4328
4329 if (wParam > ME_GetTextLength(editor))
4330 return 0;
4331 if (wParam == -1)
4332 {
4333 FIXME("EM_LINELENGTH: returning number of unselected characters on lines with selection unsupported.\n");
4334 return 0;
4335 }
4336 ME_RunOfsFromCharOfs(editor, wParam, &para, &run, NULL);
4337 item = ME_RowStart(run);
4338 nThisLineOfs = ME_CharOfsFromRunOfs(editor, para, ME_FindItemFwd(item, diRun), 0);
4340 if (item_end->type == diStartRow) {
4341 nNextLineOfs = ME_CharOfsFromRunOfs(editor, para, ME_FindItemFwd(item_end, diRun), 0);
4342 } else {
4343 ME_DisplayItem *endRun = ME_FindItemBack(item_end, diRun);
4344 assert(endRun && endRun->member.run.nFlags & MERF_ENDPARA);
4345 nNextLineOfs = item_end->member.para.nCharOfs - endRun->member.run.len;
4346 }
4347 nChars = nNextLineOfs - nThisLineOfs;
4348 TRACE("EM_LINELENGTH(%ld)==%d\n",wParam, nChars);
4349 return nChars;
4350 }
4351 case EM_EXLIMITTEXT:
4352 {
4353 if ((int)lParam < 0)
4354 return 0;
4355 if (lParam == 0)
4356 editor->nTextLimit = 65536;
4357 else
4358 editor->nTextLimit = (int) lParam;
4359 return 0;
4360 }
4361 case EM_LIMITTEXT:
4362 {
4363 if (wParam == 0)
4364 editor->nTextLimit = 65536;
4365 else
4366 editor->nTextLimit = (int) wParam;
4367 return 0;
4368 }
4369 case EM_GETLIMITTEXT:
4370 {
4371 return editor->nTextLimit;
4372 }
4373 case EM_FINDTEXT:
4374 {
4375 LRESULT r;
4376 if(!unicode){
4377 FINDTEXTA *ft = (FINDTEXTA *)lParam;
4378 int nChars = MultiByteToWideChar(CP_ACP, 0, ft->lpstrText, -1, NULL, 0);
4379 WCHAR *tmp;
4380
4381 if ((tmp = heap_alloc(nChars * sizeof(*tmp))) != NULL)
4382 MultiByteToWideChar(CP_ACP, 0, ft->lpstrText, -1, tmp, nChars);
4383 r = ME_FindText(editor, wParam, &ft->chrg, tmp, NULL);
4384 heap_free(tmp);
4385 }else{
4386 FINDTEXTW *ft = (FINDTEXTW *)lParam;
4387 r = ME_FindText(editor, wParam, &ft->chrg, ft->lpstrText, NULL);
4388 }
4389 return r;
4390 }
4391 case EM_FINDTEXTEX:
4392 {
4393 LRESULT r;
4394 if(!unicode){
4396 int nChars = MultiByteToWideChar(CP_ACP, 0, ex->lpstrText, -1, NULL, 0);
4397 WCHAR *tmp;
4398
4399 if ((tmp = heap_alloc(nChars * sizeof(*tmp))) != NULL)
4400 MultiByteToWideChar(CP_ACP, 0, ex->lpstrText, -1, tmp, nChars);
4401 r = ME_FindText(editor, wParam, &ex->chrg, tmp, &ex->chrgText);
4402 heap_free(tmp);
4403 }else{
4405 r = ME_FindText(editor, wParam, &ex->chrg, ex->lpstrText, &ex->chrgText);
4406 }
4407 return r;
4408 }
4409 case EM_FINDTEXTW:
4410 {
4411 FINDTEXTW *ft = (FINDTEXTW *)lParam;
4412 return ME_FindText(editor, wParam, &ft->chrg, ft->lpstrText, NULL);
4413 }
4414 case EM_FINDTEXTEXW:
4415 {
4417 return ME_FindText(editor, wParam, &ex->chrg, ex->lpstrText, &ex->chrgText);
4418 }
4419 case EM_GETZOOM:
4420 if (!wParam || !lParam)
4421 return FALSE;
4422 *(int *)wParam = editor->nZoomNumerator;
4423 *(int *)lParam = editor->nZoomDenominator;
4424 return TRUE;
4425 case EM_SETZOOM:
4426 return ME_SetZoom(editor, wParam, lParam);
4427 case EM_CHARFROMPOS:
4428 {
4430 if (ME_CharFromPos(editor, ((POINTL *)lParam)->x, ((POINTL *)lParam)->y,
4431 &cursor, NULL))
4432 return ME_GetCursorOfs(&cursor);
4433 else
4434 return -1;
4435 }
4436 case EM_POSFROMCHAR:
4437 {
4438 ME_DisplayItem *pPara, *pRun;
4439 int nCharOfs, nOffset, nLength;
4440 POINTL pt = {0,0};
4441
4442 nCharOfs = wParam;
4443 /* detect which API version we're dealing with */
4444 if (wParam >= 0x40000)
4445 nCharOfs = lParam;
4446 nLength = ME_GetTextLength(editor);
4447 nCharOfs = min(nCharOfs, nLength);
4448 nCharOfs = max(nCharOfs, 0);
4449
4450 ME_RunOfsFromCharOfs(editor, nCharOfs, &pPara, &pRun, &nOffset);
4451 assert(pRun->type == diRun);
4452 pt.y = pRun->member.run.pt.y;
4453 pt.x = pRun->member.run.pt.x + ME_PointFromChar(editor, &pRun->member.run, nOffset, TRUE);
4454 pt.y += pPara->member.para.pt.y + editor->rcFormat.top;
4455 pt.x += editor->rcFormat.left;
4456
4457 pt.x -= editor->horz_si.nPos;
4458 pt.y -= editor->vert_si.nPos;
4459
4460 if (wParam >= 0x40000) {
4461 *(POINTL *)wParam = pt;
4462 }
4463 return (wParam >= 0x40000) ? 0 : MAKELONG( pt.x, pt.y );
4464 }
4465 case WM_CREATE:
4466 return ME_WmCreate(editor, lParam, unicode);
4467 case WM_DESTROY:
4468 ME_DestroyEditor(editor);
4469 return 0;
4470 case WM_SETCURSOR:
4471 {
4472 POINT cursor_pos;
4473 if (wParam == (WPARAM)editor->hWnd && GetCursorPos(&cursor_pos) &&
4474 ScreenToClient(editor->hWnd, &cursor_pos))
4475 ME_LinkNotify(editor, msg, 0, MAKELPARAM(cursor_pos.x, cursor_pos.y));
4476 return ME_SetCursor(editor);
4477 }
4478 case WM_LBUTTONDBLCLK:
4479 case WM_LBUTTONDOWN:
4480 {
4481 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4482 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4483 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4484 return 0;
4486 ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam),
4489 editor->bMouseCaptured = TRUE;
4490 ME_LinkNotify(editor, msg, wParam, lParam);
4491 if (!ME_SetCursor(editor)) goto do_default;
4492 break;
4493 }
4494 case WM_MOUSEMOVE:
4495 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4496 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4497 return 0;
4498 if (editor->bMouseCaptured)
4499 ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
4500 else
4501 ME_LinkNotify(editor, msg, wParam, lParam);
4502 /* Set cursor if mouse is captured, since WM_SETCURSOR won't be received. */
4503 if (editor->bMouseCaptured)
4504 ME_SetCursor(editor);
4505 break;
4506 case WM_LBUTTONUP:
4507 if (editor->bMouseCaptured) {
4509 editor->bMouseCaptured = FALSE;
4510 }
4511 if (editor->nSelectionType == stDocument)
4512 editor->nSelectionType = stPosition;
4513 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4514 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4515 return 0;
4516 else
4517 {
4518 ME_SetCursor(editor);
4519 ME_LinkNotify(editor, msg, wParam, lParam);
4520 }
4521 break;
4522 case WM_RBUTTONUP:
4523 case WM_RBUTTONDOWN:
4524 case WM_RBUTTONDBLCLK:
4525 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4526 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4527 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4528 return 0;
4529 ME_LinkNotify(editor, msg, wParam, lParam);
4530 goto do_default;
4531 case WM_CONTEXTMENU:
4532 if (!ME_ShowContextMenu(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)))
4533 goto do_default;
4534 break;
4535 case WM_SETFOCUS:
4536 editor->bHaveFocus = TRUE;
4537 create_caret(editor);
4538 update_caret(editor);
4540 if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL))
4541 ME_InvalidateSelection( editor );
4542 return 0;
4543 case WM_KILLFOCUS:
4544 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4545 editor->bHaveFocus = FALSE;
4546 editor->wheel_remain = 0;
4547 hide_caret(editor);
4548 DestroyCaret();
4550 if (!editor->bHideSelection && !(editor->styleFlags & ES_NOHIDESEL))
4551 ME_InvalidateSelection( editor );
4552 return 0;
4553 case WM_COMMAND:
4554 TRACE("editor wnd command = %d\n", LOWORD(wParam));
4555 return 0;
4556 case WM_KEYUP:
4557 if ((editor->nEventMask & ENM_KEYEVENTS) &&
4558 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4559 return 0;
4560 goto do_default;
4561 case WM_KEYDOWN:
4562 if ((editor->nEventMask & ENM_KEYEVENTS) &&
4563 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4564 return 0;
4565 if (ME_KeyDown(editor, LOWORD(wParam)))
4566 return 0;
4567 goto do_default;
4568 case WM_CHAR:
4569 if ((editor->nEventMask & ENM_KEYEVENTS) &&
4570 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4571 return 0;
4572 return ME_Char(editor, wParam, lParam, unicode);
4573 case WM_UNICHAR:
4574 if (unicode)
4575 {
4576 if(wParam == UNICODE_NOCHAR) return TRUE;
4577 if(wParam <= 0x000fffff)
4578 {
4579 if(wParam > 0xffff) /* convert to surrogates */
4580 {
4581 wParam -= 0x10000;
4582 ME_Char(editor, (wParam >> 10) + 0xd800, 0, TRUE);
4583 ME_Char(editor, (wParam & 0x03ff) + 0xdc00, 0, TRUE);
4584 } else {
4585 ME_Char(editor, wParam, 0, TRUE);
4586 }
4587 }
4588 return 0;
4589 }
4590 break;
4591 case EM_STOPGROUPTYPING:
4592 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4593 return 0;
4594 case WM_HSCROLL:
4595 {
4596 const int scrollUnit = 7;
4597
4598 switch(LOWORD(wParam))
4599 {
4600 case SB_LEFT:
4601 ME_ScrollAbs(editor, 0, 0);
4602 break;
4603 case SB_RIGHT:
4604 ME_ScrollAbs(editor,
4605 editor->horz_si.nMax - (int)editor->horz_si.nPage,
4606 editor->vert_si.nMax - (int)editor->vert_si.nPage);
4607 break;
4608 case SB_LINELEFT:
4609 ME_ScrollLeft(editor, scrollUnit);
4610 break;
4611 case SB_LINERIGHT:
4612 ME_ScrollRight(editor, scrollUnit);
4613 break;
4614 case SB_PAGELEFT:
4615 ME_ScrollLeft(editor, editor->sizeWindow.cx);
4616 break;
4617 case SB_PAGERIGHT:
4618 ME_ScrollRight(editor, editor->sizeWindow.cx);
4619 break;
4620 case SB_THUMBTRACK:
4621 case SB_THUMBPOSITION:
4622 {
4623 int pos = HIWORD(wParam);
4624 if (editor->horz_si.nMax > 0xffff)
4625 pos = MulDiv(pos, editor->horz_si.nMax, 0xffff);
4626 ME_HScrollAbs(editor, pos);
4627 break;
4628 }
4629 }
4630 break;
4631 }
4632 case EM_SCROLL: /* fall through */
4633 case WM_VSCROLL:
4634 {
4635 int origNPos;
4636 int lineHeight = get_default_line_height( editor );
4637
4638 origNPos = editor->vert_si.nPos;
4639
4640 switch(LOWORD(wParam))
4641 {
4642 case SB_TOP:
4643 ME_ScrollAbs(editor, 0, 0);
4644 break;
4645 case SB_BOTTOM:
4646 ME_ScrollAbs(editor,
4647 editor->horz_si.nMax - (int)editor->horz_si.nPage,
4648 editor->vert_si.nMax - (int)editor->vert_si.nPage);
4649 break;
4650 case SB_LINEUP:
4651 ME_ScrollUp(editor,lineHeight);
4652 break;
4653 case SB_LINEDOWN:
4654 ME_ScrollDown(editor,lineHeight);
4655 break;
4656 case SB_PAGEUP:
4657 ME_ScrollUp(editor,editor->sizeWindow.cy);
4658 break;
4659 case SB_PAGEDOWN:
4660 ME_ScrollDown(editor,editor->sizeWindow.cy);
4661 break;
4662 case SB_THUMBTRACK:
4663 case SB_THUMBPOSITION:
4664 {
4665 int pos = HIWORD(wParam);
4666 if (editor->vert_si.nMax > 0xffff)
4667 pos = MulDiv(pos, editor->vert_si.nMax, 0xffff);
4668 ME_VScrollAbs(editor, pos);
4669 break;
4670 }
4671 }
4672 if (msg == EM_SCROLL)
4673 return 0x00010000 | (((editor->vert_si.nPos - origNPos)/lineHeight) & 0xffff);
4674 break;
4675 }
4676 case WM_MOUSEWHEEL:
4677 {
4678 int delta;
4679 BOOL ctrl_is_down;
4680
4681 if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
4682 !ME_FilterEvent(editor, msg, &wParam, &lParam))
4683 return 0;
4684
4685 ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
4686
4687 delta = GET_WHEEL_DELTA_WPARAM(wParam);
4688
4689 /* if scrolling changes direction, ignore left overs */
4690 if ((delta < 0 && editor->wheel_remain < 0) ||
4691 (delta > 0 && editor->wheel_remain > 0))
4692 editor->wheel_remain += delta;
4693 else
4694 editor->wheel_remain = delta;
4695
4696 if (editor->wheel_remain)
4697 {
4698 if (ctrl_is_down) {
4699 int numerator;
4700 if (!editor->nZoomNumerator || !editor->nZoomDenominator)
4701 {
4702 numerator = 100;
4703 } else {
4704 numerator = editor->nZoomNumerator * 100 / editor->nZoomDenominator;
4705 }
4706 numerator += calc_wheel_change( &editor->wheel_remain, 10 );
4707 if (numerator >= 10 && numerator <= 500)
4708 ME_SetZoom(editor, numerator, 100);
4709 } else {
4710 UINT max_lines = 3;
4711 int lines = 0;
4712
4713 SystemParametersInfoW( SPI_GETWHEELSCROLLLINES, 0, &max_lines, 0 );
4714 if (max_lines)
4715 lines = calc_wheel_change( &editor->wheel_remain, (int)max_lines );
4716 if (lines)
4717 ME_ScrollDown( editor, -lines * get_default_line_height( editor ) );
4718 }
4719 }
4720 break;
4721 }
4722 case EM_GETRECT:
4723 {
4724 *((RECT *)lParam) = editor->rcFormat;
4725 if (editor->bDefaultFormatRect)
4726 ((RECT *)lParam)->left -= editor->selofs;
4727 return 0;
4728 }
4729 case EM_SETRECT:
4730 case EM_SETRECTNP:
4731 {
4732 if (lParam)
4733 {
4734 int border = 0;
4735 RECT clientRect;
4736 RECT *rc = (RECT *)lParam;
4737
4738 border = editor->exStyleFlags & WS_EX_CLIENTEDGE ? 1 : 0;
4739 ITextHost_TxGetClientRect(editor->texthost, &clientRect);
4740 if (wParam == 0)
4741 {
4742 editor->rcFormat.top = max(0, rc->top - border);
4743 editor->rcFormat.left = max(0, rc->left - border);
4744 editor->rcFormat.bottom = min(clientRect.bottom, rc->bottom);
4745 editor->rcFormat.right = min(clientRect.right, rc->right + border);
4746 } else if (wParam == 1) {
4747 /* MSDN incorrectly says a wParam value of 1 causes the
4748 * lParam rect to be used as a relative offset,
4749 * however, the tests show it just prevents min/max bound
4750 * checking. */
4751 editor->rcFormat.top = rc->top - border;
4752 editor->rcFormat.left = rc->left - border;
4753 editor->rcFormat.bottom = rc->bottom;
4754 editor->rcFormat.right = rc->right + border;
4755 } else {
4756 return 0;
4757 }
4758 editor->bDefaultFormatRect = FALSE;
4759 }
4760 else
4761 {
4763 editor->bDefaultFormatRect = TRUE;
4764 }
4765 ME_MarkAllForWrapping(editor);
4767 ME_UpdateScrollBar(editor);
4768 if (msg != EM_SETRECTNP)
4769 ME_Repaint(editor);
4770 return 0;
4771 }
4772 case EM_REQUESTRESIZE:
4773 ME_SendRequestResize(editor, TRUE);
4774 return 0;
4775 case WM_SETREDRAW:
4776 goto do_default;
4778 {
4779 RECT clientRect;
4780 WINDOWPOS *winpos = (WINDOWPOS *)lParam;
4781
4782 if (winpos->flags & SWP_NOCLIENTSIZE) goto do_default;
4783 ITextHost_TxGetClientRect(editor->texthost, &clientRect);
4784 if (editor->bDefaultFormatRect) {
4786 } else {
4787 editor->rcFormat.right += clientRect.right - editor->prevClientRect.right;
4788 editor->rcFormat.bottom += clientRect.bottom - editor->prevClientRect.bottom;
4789 }
4790 editor->prevClientRect = clientRect;
4791 ME_RewrapRepaint(editor);
4792 goto do_default;
4793 }
4794#ifndef __REACTOS__
4795 /* IME messages to make richedit controls IME aware */
4796#endif
4797 case WM_IME_SETCONTEXT:
4798#ifdef __REACTOS__
4799 {
4800 if (FALSE) /* FIXME: Condition */
4801 lParam &= ~ISC_SHOWUICOMPOSITIONWINDOW;
4802
4803 if (wParam)
4804 {
4805 HIMC hIMC = ImmGetContext(editor->hWnd);
4807 if (pIC)
4808 {
4809 pIC->dwUIFlags &= ~0x40000;
4810 ImmUnlockIMC(hIMC);
4811 }
4812 if (FALSE) /* FIXME: Condition */
4814 ImmReleaseContext(editor->hWnd, hIMC);
4815 }
4816
4817 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4818 }
4819#endif
4820 case WM_IME_CONTROL:
4821#ifdef __REACTOS__
4822 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4823#endif
4824 case WM_IME_SELECT:
4825#ifdef __REACTOS__
4826 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4827#endif
4829 return 0;
4830 case WM_IME_STARTCOMPOSITION:
4831 {
4832#ifdef __REACTOS__
4833 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4834#else
4835 editor->imeStartIndex=ME_GetCursorOfs(&editor->pCursors[0]);
4836 ME_DeleteSelection(editor);
4837 ME_CommitUndo(editor);
4838 ME_UpdateRepaint(editor, FALSE);
4839#endif
4840 return 0;
4841 }
4842 case WM_IME_COMPOSITION:
4843 {
4844 HIMC hIMC;
4845
4846 ME_Style *style = ME_GetInsertStyle(editor, 0);
4847 hIMC = ITextHost_TxImmGetContext(editor->texthost);
4848 ME_DeleteSelection(editor);
4849 ME_SaveTempStyle(editor, style);
4851 {
4852 LPWSTR lpCompStr = NULL;
4854 DWORD dwIndex = lParam & GCS_RESULTSTR;
4855 if (!dwIndex)
4856 dwIndex = GCS_COMPSTR;
4857
4858 dwBufLen = ImmGetCompositionStringW(hIMC, dwIndex, NULL, 0);
4859 lpCompStr = HeapAlloc(GetProcessHeap(),0,dwBufLen + sizeof(WCHAR));
4860 ImmGetCompositionStringW(hIMC, dwIndex, lpCompStr, dwBufLen);
4861 lpCompStr[dwBufLen/sizeof(WCHAR)] = 0;
4862#ifndef __REACTOS__
4863 ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style);
4864#endif
4865 HeapFree(GetProcessHeap(), 0, lpCompStr);
4866
4867#ifndef __REACTOS__
4868 if (dwIndex == GCS_COMPSTR)
4869 set_selection_cursors(editor,editor->imeStartIndex,
4870 editor->imeStartIndex + dwBufLen/sizeof(WCHAR));
4871#endif
4872 }
4874 ME_CommitUndo(editor);
4875 ME_UpdateRepaint(editor, FALSE);
4876#ifdef __REACTOS__
4877 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4878#else
4879 return 0;
4880#endif
4881 }
4882 case WM_IME_ENDCOMPOSITION:
4883 {
4884#ifdef __REACTOS__
4885 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4886#else
4887 ME_DeleteSelection(editor);
4888 editor->imeStartIndex=-1;
4889 return 0;
4890#endif
4891 }
4892 case EM_GETOLEINTERFACE:
4893 {
4894 if (!editor->reOle)
4895 if (!CreateIRichEditOle(NULL, editor, (LPVOID *)&editor->reOle))
4896 return 0;
4897 if (IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (LPVOID *)lParam) == S_OK)
4898 return 1;
4899 return 0;
4900 }
4901 case EM_GETPASSWORDCHAR:
4902 {
4903 return editor->cPasswordMask;
4904 }
4905 case EM_SETOLECALLBACK:
4906 if(editor->lpOleCallback)
4907 IRichEditOleCallback_Release(editor->lpOleCallback);
4909 if(editor->lpOleCallback)
4910 IRichEditOleCallback_AddRef(editor->lpOleCallback);
4911 return TRUE;
4913 return (LRESULT)editor->pfnWordBreak;
4915 {
4916 EDITWORDBREAKPROCW pfnOld = editor->pfnWordBreak;
4917
4919 return (LRESULT)pfnOld;
4920 }
4921 case EM_GETTEXTMODE:
4922 return editor->mode;
4923 case EM_SETTEXTMODE:
4924 {
4925 int mask = 0;
4926 int changes = 0;
4927
4928 if (ME_GetTextLength(editor) ||
4929 !list_empty( &editor->undo_stack ) || !list_empty( &editor->redo_stack ))
4930 return E_UNEXPECTED;
4931
4932 /* Check for mutually exclusive flags in adjacent bits of wParam */
4935 return E_INVALIDARG;
4936
4938 {
4941 if (wParam & TM_PLAINTEXT) {
4942 /* Clear selection since it should be possible to select the
4943 * end of text run for rich text */
4944 ME_InvalidateSelection(editor);
4945 ME_SetCursorToStart(editor, &editor->pCursors[0]);
4946 editor->pCursors[1] = editor->pCursors[0];
4947 /* plain text can only have the default style. */
4948 ME_ClearTempStyle(editor);
4951 editor->pCursors[0].pRun->member.run.style = editor->pBuffer->pDefaultStyle;
4952 }
4953 }
4954 /* FIXME: Currently no support for undo level and code page options */
4955 editor->mode = (editor->mode & ~mask) | changes;
4956 return 0;
4957 }
4958 case EM_SETPASSWORDCHAR:
4959 {
4960 editor->cPasswordMask = wParam;
4961 ME_RewrapRepaint(editor);
4962 return 0;
4963 }
4964 case EM_SETTARGETDEVICE:
4965 if (wParam == 0)
4966 {
4967 BOOL new = (lParam == 0 && (editor->styleFlags & ES_MULTILINE));
4968 if (editor->nAvailWidth || editor->bWordWrap != new)
4969 {
4970 editor->bWordWrap = new;
4971 editor->nAvailWidth = 0; /* wrap to client area */
4972 ME_RewrapRepaint(editor);
4973 }
4974 } else {
4975 int width = max(0, lParam);
4976 if ((editor->styleFlags & ES_MULTILINE) &&
4977 (!editor->bWordWrap || editor->nAvailWidth != width))
4978 {
4979 editor->nAvailWidth = width;
4980 editor->bWordWrap = TRUE;
4981 ME_RewrapRepaint(editor);
4982 }
4983 FIXME("EM_SETTARGETDEVICE doesn't use non-NULL target devices\n");
4984 }
4985 return TRUE;
4986 default:
4987 do_default:
4988 *phresult = S_FALSE;
4989 break;
4990 }
4991 return 0L;
4992}
struct mke2fs_defaults settings[]
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
int nRows
Definition: appswitch.c:56
#define msg(x)
Definition: auth_time.c:54
static int list_empty(struct list_entry *head)
Definition: list.h:58
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define SWP_NOCLIENTSIZE
Definition: msg.h:29
LONG WINAPI ImmGetCompositionStringW(HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen)
Definition: compstr.c:899
DWORD HIMC
Definition: dimm.idl:75
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI ImmSetCompositionFontW(HIMC hIMC, LPLOGFONTW lplf)
Definition: ime.c:1744
BOOL WINAPI ImmIsIME(HKL hKL)
Definition: ime.c:880
BOOL WINAPI ImmNotifyIME(HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD_PTR dwValue)
Definition: ime.c:907
BOOL WINAPI ImmUnlockIMC(HIMC hIMC)
Definition: imm.c:1066
HIMC WINAPI ImmGetContext(HWND hWnd)
Definition: imm.c:1044
BOOL WINAPI ImmReleaseContext(HWND hWnd, HIMC hIMC)
Definition: imm.c:1085
LPINPUTCONTEXT WINAPI ImmLockIMC(HIMC hIMC)
Definition: imm.c:1057
void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: caret.c:27
void ME_DeleteSelection(ME_TextEditor *editor)
Definition: caret.c:1584
void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum)
Definition: caret.c:1204
int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how)
Definition: caret.c:91
void ME_MouseMove(ME_TextEditor *editor, int x, int y)
Definition: caret.c:1266
BOOL ME_CharFromPos(ME_TextEditor *editor, int x, int y, ME_Cursor *cursor, BOOL *isExact)
Definition: caret.c:1122
int set_selection_cursors(ME_TextEditor *editor, int from, int to)
Definition: caret.c:132
void create_caret(ME_TextEditor *editor)
Definition: caret.c:272
ME_Style * ME_GetSelectionInsertStyle(ME_TextEditor *editor)
Definition: caret.c:1593
static void ME_StreamInRTFString(ME_TextEditor *editor, BOOL selection, char *string)
Definition: editor.c:1841
static BOOL paste_special(ME_TextEditor *editor, UINT cf, REPASTESPECIAL *ps, BOOL check_only)
Definition: editor.c:2292
#define UNSUPPORTED_MSG(e)
Definition: editor.c:3593
static int ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCHAR *text, CHARRANGE *chrgText)
Definition: editor.c:1856
static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stream, BOOL stripLastCR)
Definition: editor.c:1585
static void ME_SetText(ME_TextEditor *editor, void *text, BOOL unicode)
Definition: editor.c:3487
void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len)
Definition: editor.c:3463
static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor)
Definition: editor.c:2410
static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode, LPARAM flags, BOOL unicode)
Definition: editor.c:2745
static BOOL ME_SetCursor(ME_TextEditor *editor)
Definition: editor.c:2897
static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y)
Definition: editor.c:3038
#define STACK_SIZE_MAX
Definition: editor.c:247
static void ME_SetDefaultFormatRect(ME_TextEditor *editor)
Definition: editor.c:2989
static int ME_GetTextRange(ME_TextEditor *editor, WCHAR *strText, const ME_Cursor *start, int nLen, BOOL unicode)
Definition: editor.c:2140
void ME_SendOldNotify(ME_TextEditor *editor, int nCode)
Definition: editor.c:5175
static LRESULT handle_EM_SETCHARFORMAT(ME_TextEditor *editor, WPARAM flags, const CHARFORMAT2W *fmt_in)
Definition: editor.c:3543
static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText)
Definition: editor.c:2088
static int calc_wheel_change(int *remain, int amount_per_click)
Definition: editor.c:3280
static BOOL ME_FilterEvent(ME_TextEditor *editor, UINT msg, WPARAM *wParam, LPARAM *lParam)
Definition: editor.c:2390
#define STACK_SIZE_DEFAULT
Definition: editor.c:246
static BOOL copy_or_cut(ME_TextEditor *editor, BOOL cut)
Definition: editor.c:2364
static int get_default_line_height(ME_TextEditor *editor)
Definition: editor.c:3269
static LONG ME_GetSelectionType(ME_TextEditor *editor)
Definition: editor.c:2997
static LRESULT ME_WmCreate(ME_TextEditor *editor, LPARAM lParam, BOOL unicode)
Definition: editor.c:3497
static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: editor.c:3423
static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int nChars)
Definition: editor.c:5533
void ME_DestroyEditor(ME_TextEditor *editor)
Definition: editor.c:3194
static BOOL ME_KeyDown(ME_TextEditor *editor, WORD nKey)
Definition: editor.c:2614
static int ME_CalculateClickCount(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: editor.c:2842
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define pt(x, y)
Definition: drawing.c:79
#define ITextHost_TxShowScrollBar(This, a, b)
Definition: editor.h:289
#define ITextHost_TxSetFocus(This)
Definition: editor.h:302
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: wrap.c:1093
void ME_ScrollRight(ME_TextEditor *editor, int cx) DECLSPEC_HIDDEN
Definition: paint.c:1131
#define ITextHost_TxInvalidateRect(This, a, b)
Definition: editor.h:293
void ME_CursorFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_Cursor *pCursor) DECLSPEC_HIDDEN
Definition: run.c:171
void ME_ScrollAbs(ME_TextEditor *editor, int x, int y) DECLSPEC_HIDDEN
Definition: paint.c:1043
void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style) DECLSPEC_HIDDEN
Definition: style.c:514
BOOL ME_SetZoom(ME_TextEditor *editor, int numerator, int denominator) DECLSPEC_HIDDEN
Definition: paint.c:1373
void ME_SendRequestResize(ME_TextEditor *editor, BOOL force) DECLSPEC_HIDDEN
Definition: wrap.c:1198
BOOL ME_Redo(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: undo.c:453
void ME_RunOfsFromCharOfs(ME_TextEditor *editor, int nCharOfs, ME_DisplayItem **ppPara, ME_DisplayItem **ppRun, int *pOfs) DECLSPEC_HIDDEN
Definition: run.c:184
void ME_UpdateScrollBar(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: paint.c:1148
void ME_GetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
Definition: run.c:790
#define ITextHost_TxSetCapture(This, a)
Definition: editor.h:301
#define ITextHost_TxGetSysColor(This, a)
Definition: editor.h:312
void ME_CharFormatFromLogFont(HDC hDC, const LOGFONTW *lf, CHARFORMAT2W *fmt) DECLSPEC_HIDDEN
Definition: style.c:331
void ME_EndToUnicode(LONG codepage, LPVOID psz) DECLSPEC_HIDDEN
Definition: string.c:248
void ME_ScrollLeft(ME_TextEditor *editor, int cx) DECLSPEC_HIDDEN
Definition: paint.c:1126
ME_DisplayItem * ME_GetParagraph(ME_DisplayItem *run) DECLSPEC_HIDDEN
Definition: para.c:815
void ME_VScrollAbs(ME_TextEditor *editor, int y) DECLSPEC_HIDDEN
Definition: paint.c:1111
void ME_ScrollUp(ME_TextEditor *editor, int cy) DECLSPEC_HIDDEN
Definition: paint.c:1116
void ME_CommitUndo(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: undo.c:227
int ME_RowNumberFromCharOfs(ME_TextEditor *editor, int nOfs) DECLSPEC_HIDDEN
Definition: row.c:64
void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now) DECLSPEC_HIDDEN
Definition: paint.c:116
void ME_HScrollAbs(ME_TextEditor *editor, int x) DECLSPEC_HIDDEN
Definition: paint.c:1106
int ME_CharOfsFromRunOfs(ME_TextEditor *editor, const ME_DisplayItem *pPara, const ME_DisplayItem *pRun, int nOfs) DECLSPEC_HIDDEN
Definition: run.c:156
void ME_GetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
Definition: run.c:801
LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *ppvObj) DECLSPEC_HIDDEN
Definition: richole.c:5688
void ME_RewrapRepaint(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: paint.c:142
void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod) DECLSPEC_HIDDEN
Definition: style.c:540
BOOL ME_SetSelectionParaFormat(ME_TextEditor *editor, const PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
Definition: para.c:907
ME_DisplayItem * ME_FindRowWithNumber(ME_TextEditor *editor, int nRow) DECLSPEC_HIDDEN
Definition: row.c:44
void ME_SetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
Definition: run.c:696
#define ITextHost_TxImmGetContext(This)
Definition: editor.h:323
ME_DisplayItem * ME_RowStart(ME_DisplayItem *item) DECLSPEC_HIDDEN
Definition: row.c:31
void ME_ScrollDown(ME_TextEditor *editor, int cy) DECLSPEC_HIDDEN
Definition: paint.c:1121
void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
Definition: para.c:937
BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from) DECLSPEC_HIDDEN
Definition: style.c:79
void ME_MarkAllForWrapping(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: para.c:236
LPWSTR ME_ToUnicode(LONG codepage, LPVOID psz, INT *len) DECLSPEC_HIDDEN
Definition: string.c:226
LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream) DECLSPEC_HIDDEN
Definition: writer.c:1179
void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
Definition: run.c:725
BOOL ME_Undo(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: undo.c:414
@ diStartRowOrParagraphOrEnd
Definition: editstr.h:93
@ diRunOrStartRow
Definition: editstr.h:95
#define SELECTIONBAR_WIDTH
Definition: editstr.h:100
@ stPosition
Definition: editstr.h:357
@ stDocument
Definition: editstr.h:361
POINTL point
Definition: edittest.c:50
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum GLint GLuint mask
Definition: glext.h:6028
GLenum GLint * range
Definition: glext.h:7539
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
#define CPS_CANCEL
Definition: imm.h:181
#define GCS_RESULTSTR
Definition: imm.h:234
#define GCS_COMPSTR
Definition: imm.h:227
#define NI_COMPOSITIONSTR
Definition: immdev.h:403
#define INT_MAX
Definition: limits.h:40
JSAMPARRAY JDIMENSION max_lines
Definition: jpeglib.h:1058
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
static char * dest
Definition: rtl.c:135
#define set_selection(hctl, start, end)
unsigned int * PUINT
Definition: ndis.h:50
unsigned int UINT
Definition: ndis.h:50
#define BOOL
Definition: nt_native.h:43
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define ES_READONLY
Definition: pedump.c:675
#define ES_NOHIDESEL
Definition: pedump.c:673
#define WS_VSCROLL
Definition: pedump.c:627
long LONG
Definition: pedump.c:60
#define WS_HSCROLL
Definition: pedump.c:628
#define TM_RICHTEXT
Definition: richedit.h:1029
#define ECO_NOHIDESEL
Definition: richedit.h:459
#define TM_MULTILEVELUNDO
Definition: richedit.h:1031
#define EM_GETAUTOURLDETECT
Definition: richedit.h:126
#define EM_CANREDO
Definition: richedit.h:118
#define EM_SCROLLCARET
Definition: richedit.h:81
#define ECO_WANTRETURN
Definition: richedit.h:461
#define EM_SETPALETTE
Definition: richedit.h:127
#define EM_SETOLECALLBACK
Definition: richedit.h:103
#define EM_GETREDONAME
Definition: richedit.h:120
#define EM_GETEVENTMASK
Definition: richedit.h:92
#define EM_REDO
Definition: richedit.h:117
#define EM_REQUESTRESIZE
Definition: richedit.h:98
#define EM_GETSELTEXT
Definition: richedit.h:95
#define EM_SETBIDIOPTIONS
Definition: richedit.h:154
#define EM_AUTOURLDETECT
Definition: richedit.h:125
#define EM_FORMATRANGE
Definition: richedit.h:90
#define EM_SETZOOM
Definition: richedit.h:170
#define EM_STREAMIN
Definition: richedit.h:106
#define EM_SETSCROLLPOS
Definition: richedit.h:166
#define ECO_AUTOWORDSELECTION
Definition: richedit.h:456
#define ST_SELECTION
Definition: richedit.h:1072
#define EM_SETEVENTMASK
Definition: richedit.h:102
#define EM_SETOPTIONS
Definition: richedit.h:110
#define EM_CANPASTE
Definition: richedit.h:83
#define WM_UNICHAR
Definition: richedit.h:67
#define ECO_VERTICAL
Definition: richedit.h:464
#define ST_KEEPUNDO
Definition: richedit.h:1071
#define EM_GETUNDONAME
Definition: richedit.h:119
#define EM_GETTEXTMODE
Definition: richedit.h:124
#define EM_GETWORDBREAKPROCEX
Definition: richedit.h:113
#define EM_GETBIDIOPTIONS
Definition: richedit.h:155
#define EM_SETBKGNDCOLOR
Definition: richedit.h:100
#define EM_SETTEXTEX
Definition: richedit.h:131
#define EM_HIDESELECTION
Definition: richedit.h:96
#define EM_POSFROMCHAR
Definition: richedit.h:77
#define EM_GETCHARFORMAT
Definition: richedit.h:91
#define TM_SINGLECODEPAGE
Definition: richedit.h:1032
struct _charformatw CHARFORMATW
#define EM_SETCHARFORMAT
Definition: richedit.h:101
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define EM_SETFONTSIZE
Definition: richedit.h:168
#define EM_GETLANGOPTIONS
Definition: richedit.h:144
#define EM_GETPARAFORMAT
Definition: richedit.h:94
#define EM_SHOWSCROLLBAR
Definition: richedit.h:130
#define ENM_KEYEVENTS
Definition: richedit.h:475
#define EM_SETWORDBREAKPROCEX
Definition: richedit.h:114
#define EM_GETOPTIONS
Definition: richedit.h:111
#define EM_DISPLAYBAND
Definition: richedit.h:84
#define EM_SETLANGOPTIONS
Definition: richedit.h:143
#define ECO_AUTOHSCROLL
Definition: richedit.h:458
#define EM_CHARFROMPOS
Definition: richedit.h:78
#define EM_GETEDITSTYLE
Definition: richedit.h:161
#define EM_GETTEXTRANGE
Definition: richedit.h:108
#define EM_SETTEXTMODE
Definition: richedit.h:123
#define EM_FINDTEXTW
Definition: richedit.h:147
#define EM_GETZOOM
Definition: richedit.h:169
#define EM_EXSETSEL
Definition: richedit.h:88
#define ECOOP_XOR
Definition: richedit.h:453
#define EM_GETSCROLLPOS
Definition: richedit.h:165
#define EM_EXLIMITTEXT
Definition: richedit.h:86
#define EM_PASTESPECIAL
Definition: richedit.h:97
#define EM_SELECTIONTYPE
Definition: richedit.h:99
#define EM_FINDTEXT
Definition: richedit.h:89
#define TM_PLAINTEXT
Definition: richedit.h:1028
#define EM_STOPGROUPTYPING
Definition: richedit.h:121
#define ES_SAVESEL
Definition: richedit.h:226
#define ECO_READONLY
Definition: richedit.h:460
#define ECOOP_OR
Definition: richedit.h:451
#define EM_SETTYPOGRAPHYOPTIONS
Definition: richedit.h:157
#define EM_GETTEXTLENGTHEX
Definition: richedit.h:129
#define ECOOP_SET
Definition: richedit.h:450
#define EM_SETTARGETDEVICE
Definition: richedit.h:105
#define EM_GETLIMITTEXT
Definition: richedit.h:74
#define EM_EXLINEFROMCHAR
Definition: richedit.h:87
#define GT_USECRLF
Definition: richedit.h:1037
#define EM_GETIMECOMPMODE
Definition: richedit.h:145
#define EM_GETOLEINTERFACE
Definition: richedit.h:93
#define ECO_AUTOVSCROLL
Definition: richedit.h:457
#define EM_GETTEXTEX
Definition: richedit.h:128
#define EM_SETPARAFORMAT
Definition: richedit.h:104
#define EM_FINDTEXTEXW
Definition: richedit.h:148
#define TM_SINGLELEVELUNDO
Definition: richedit.h:1030
#define EM_EXGETSEL
Definition: richedit.h:85
#define EM_GETTYPOGRAPHYOPTIONS
Definition: richedit.h:158
#define EM_FINDTEXTEX
Definition: richedit.h:112
#define ENM_MOUSEEVENTS
Definition: richedit.h:476
#define EM_SETUNDOLIMIT
Definition: richedit.h:116
#define EM_FINDWORDBREAK
Definition: richedit.h:109
#define TM_MULTICODEPAGE
Definition: richedit.h:1033
#define ECO_SELECTIONBAR
Definition: richedit.h:463
#define EM_SETEDITSTYLE
Definition: richedit.h:160
#define ECOOP_AND
Definition: richedit.h:452
#define EM_STREAMOUT
Definition: richedit.h:107
#define CP_UTF8
Definition: nls.h:20
static char utf8_bom[3]
Definition: file.c:108
static CHANGE * changes
Definition: io.c:49
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
UINT flags
Definition: winuser.h:3594
LONG cpMax
Definition: richedit.h:501
LONG cpMin
Definition: richedit.h:500
CHARRANGE chrg
Definition: richedit.h:581
LPCSTR lpstrText
Definition: richedit.h:582
CHARRANGE chrg
Definition: richedit.h:586
LPCWSTR lpstrText
Definition: richedit.h:587
UINT codepage
Definition: richedit.h:1066
DWORD flags
Definition: richedit.h:1065
CHARRANGE chrg
Definition: richedit.h:514
LPWSTR lpstrText
Definition: richedit.h:515
Definition: comerr.c:44
WCHAR cPasswordMask
Definition: editstr.h:426
struct list redo_stack
Definition: editstr.h:403
int nZoomNumerator
Definition: editstr.h:411
BOOL bDefaultFormatRect
Definition: editstr.h:414
BOOL bDialogMode
Definition: editstr.h:428
RECT prevClientRect
Definition: editstr.h:412
ME_SelectionType nSelectionType
Definition: editstr.h:434
BOOL AutoURLDetect_bEnable
Definition: editstr.h:425
int nZoomDenominator
Definition: editstr.h:411
BOOL bMouseCaptured
Definition: editstr.h:445
DWORD exStyleFlags
Definition: editstr.h:389
BOOL bHideSelection
Definition: editstr.h:424
#define WM_MOUSEWHEEL
Definition: treelist.c:96
eMaj lines
Definition: tritemp.h:206
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
_In_ DWORD nLength
Definition: wincon.h:473
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_ DWORD _In_ DWORD dwBufLen
Definition: wincrypt.h:4246
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define S_FALSE
Definition: winerror.h:2357
#define E_UNEXPECTED
Definition: winerror.h:2456
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define SYSTEM_FONT
Definition: wingdi.h:911
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define EM_SETREADONLY
Definition: winuser.h:2015
#define EM_GETIMESTATUS
Definition: winuser.h:1987
#define WM_GETTEXTLENGTH
Definition: winuser.h:1619
#define EM_GETRECT
Definition: winuser.h:1996
HKL WINAPI GetKeyboardLayout(_In_ DWORD)
#define EM_LIMITTEXT
Definition: winuser.h:2000
#define SB_THUMBTRACK
Definition: winuser.h:573
#define EM_LINEFROMCHAR
Definition: winuser.h:2001
#define SB_LINEUP
Definition: winuser.h:564
#define WM_HSCROLL
Definition: winuser.h:1743
#define WM_PASTE
Definition: winuser.h:1863
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
#define WM_KEYUP
Definition: winuser.h:1716
#define EN_KILLFOCUS
Definition: winuser.h:2025
#define EM_GETWORDBREAKPROC
Definition: winuser.h:1999
#define COLOR_WINDOW
Definition: winuser.h:918
#define EM_FMTLINES
Definition: winuser.h:1986
#define EM_GETPASSWORDCHAR
Definition: winuser.h:1995
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_VSCROLL
Definition: winuser.h:1744
#define WM_CREATE
Definition: winuser.h:1608
#define DLGC_WANTCHARS
Definition: winuser.h:2618
#define DLGC_WANTTAB
Definition: winuser.h:2611
#define EM_SETIMESTATUS
Definition: winuser.h:2010
#define EM_GETSEL
Definition: winuser.h:1997
#define EN_SETFOCUS
Definition: winuser.h:2027
#define EM_SETPASSWORDCHAR
Definition: winuser.h:2014
#define EM_GETMODIFY
Definition: winuser.h:1994
#define SB_PAGERIGHT
Definition: winuser.h:571
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define SB_VERT
Definition: winuser.h:553
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:1985
#define SB_LEFT
Definition: winuser.h:575
#define SB_BOTTOM
Definition: winuser.h:577
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1778
#define WM_COMMAND
Definition: winuser.h:1740
#define EM_REPLACESEL
Definition: winuser.h:2006
#define VK_CONTROL
Definition: winuser.h:2203
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2670
#define EM_SETRECT
Definition: winuser.h:2016
#define WM_RBUTTONUP
Definition: winuser.h:1780
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1781
#define WM_SETFOCUS
Definition: winuser.h:1613
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define WM_GETTEXT
Definition: winuser.h:1618
#define WM_CUT
Definition: winuser.h:1861
#define SB_LINERIGHT
Definition: winuser.h:567
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
#define EM_LINEINDEX
Definition: winuser.h:2002
#define EM_LINESCROLL
Definition: winuser.h:2004
#define EM_GETFIRSTVISIBLELINE
Definition: winuser.h:1988
#define WM_UNDO
Definition: winuser.h:1865
#define WM_IME_SETCONTEXT
Definition: winuser.h:1829
#define WM_RBUTTONDOWN
Definition: winuser.h:1779
#define WM_SETTEXT
Definition: winuser.h:1617
#define EM_CANUNDO
Definition: winuser.h:1983
#define EM_LINELENGTH
Definition: winuser.h:2003
#define EM_GETLINE
Definition: winuser.h:1991
#define EM_SETRECTNP
Definition: winuser.h:2017
#define SB_LINELEFT
Definition: winuser.h:566
#define WM_SETFONT
Definition: winuser.h:1650
#define EM_UNDO
Definition: winuser.h:2021
#define DLGC_WANTARROWS
Definition: winuser.h:2610
#define EM_SCROLL
Definition: winuser.h:2007
#define SB_PAGEDOWN
Definition: winuser.h:569
#define EM_SETWORDBREAKPROC
Definition: winuser.h:2020
#define SB_BOTH
Definition: winuser.h:555
#define SB_LINEDOWN
Definition: winuser.h:565
#define EM_SETSEL
Definition: winuser.h:2018
int(CALLBACK * EDITWORDBREAKPROCW)(LPWSTR, int, int, int)
Definition: winuser.h:2905
#define WM_LBUTTONUP
Definition: winuser.h:1777
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define WM_IME_COMPOSITIONFULL
Definition: winuser.h:1832
#define WM_CHAR
Definition: winuser.h:1717
#define SB_TOP
Definition: winuser.h:578
#define WM_COPY
Definition: winuser.h:1862
#define WM_SETCURSOR
Definition: winuser.h:1636
#define WM_IME_CONTROL
Definition: winuser.h:1831
#define EM_SETTABSTOPS
Definition: winuser.h:2019
#define DLGC_WANTMESSAGE
Definition: winuser.h:2613
#define WM_IME_SELECT
Definition: winuser.h:1833
#define WM_DESTROY
Definition: winuser.h:1609
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WM_CLEAR
Definition: winuser.h:1864
#define WM_KEYDOWN
Definition: winuser.h:1715
#define EM_GETLINECOUNT
Definition: winuser.h:1992
#define SB_RIGHT
Definition: winuser.h:576
BOOL WINAPI DestroyCaret(void)
Definition: caret.c:35
#define EM_SETMARGINS
Definition: winuser.h:2012
#define WM_WINDOWPOSCHANGED
Definition: winuser.h:1662
#define DLGC_HASSETSEL
Definition: winuser.h:2614
#define WM_KILLFOCUS
Definition: winuser.h:1614
#define SB_PAGEUP
Definition: winuser.h:568
#define WM_GETDLGCODE
Definition: winuser.h:1689
#define WM_MBUTTONDOWN
Definition: winuser.h:1782
#define EM_SETMODIFY
Definition: winuser.h:2013
#define SB_HORZ
Definition: winuser.h:552
SHORT WINAPI GetKeyState(_In_ int)
#define SB_PAGELEFT
Definition: winuser.h:570
#define WM_SETREDRAW
Definition: winuser.h:1616
#define SB_THUMBPOSITION
Definition: winuser.h:572
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
const char * LPCSTR
Definition: xmlstorage.h:183
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
char CHAR
Definition: xmlstorage.h:175

Referenced by fnTextSrv_TxSendMessage(), and RichEditWndProc_common().

◆ ME_HScrollAbs()

void ME_HScrollAbs ( ME_TextEditor editor,
int  x 
)

Definition at line 1106 of file paint.c.

1107{
1108 ME_ScrollAbs(editor, x, editor->vert_si.nPos);
1109}

Referenced by ME_EnsureVisible(), ME_HandleMessage(), ME_ScrollLeft(), ME_ScrollRight(), and ME_UpdateScrollBar().

◆ ME_InitCharFormat2W()

void ME_InitCharFormat2W ( CHARFORMAT2W pFmt)

Definition at line 150 of file style.c.

151{
152 ZeroMemory(pFmt, sizeof(CHARFORMAT2W));
153 pFmt->cbSize = sizeof(CHARFORMAT2W);
154}

Referenced by ME_CharFormatFromLogFont(), and ME_JoinParagraphs().

◆ ME_InitContext()

void ME_InitContext ( ME_Context c,
ME_TextEditor editor,
HDC  hDC 
)

Definition at line 23 of file context.c.

24{
25 c->hDC = hDC;
26 c->editor = editor;
27 c->pt.x = 0;
28 c->pt.y = 0;
29 c->rcView = editor->rcFormat;
30 c->current_style = NULL;
31 c->orig_font = NULL;
32 if (hDC) {
33 c->dpi.cx = GetDeviceCaps(hDC, LOGPIXELSX);
34 c->dpi.cy = GetDeviceCaps(hDC, LOGPIXELSY);
35 } else {
36 c->dpi.cx = c->dpi.cy = 96;
37 }
38 if (editor->nAvailWidth)
39 c->nAvailWidth = ME_twips2pointsX(c, editor->nAvailWidth);
40 else
41 c->nAvailWidth = c->rcView.right - c->rcView.left;
42}
#define LOGPIXELSX
Definition: wingdi.h:718

Referenced by ME_CharFromPoint(), ME_GetCursorCoordinates(), ME_InvalidateParagraphRange(), ME_MakeFirstParagraph(), ME_PaintContent(), ME_PointFromChar(), ME_WrapMarkedParagraphs(), and stream_out_graphics().

◆ ME_InitTableDef()

void ME_InitTableDef ( ME_TextEditor editor,
struct RTFTable tableDef 
)

Definition at line 646 of file table.c.

647{
648 ZeroMemory(tableDef->cells, sizeof(tableDef->cells));
649 ZeroMemory(tableDef->border, sizeof(tableDef->border));
650 tableDef->numCellsDefined = 0;
651 tableDef->leftEdge = 0;
652 if (!editor->bEmulateVersion10) /* v4.1 */
653 tableDef->gapH = 10;
654 else /* v1.0 - 3.0 */
655 tableDef->gapH = 0;
656}
RTFCell cells[MAX_TABLE_CELLS]
Definition: rtf.h:1027
int numCellsDefined
Definition: rtf.h:1028
int gapH
Definition: rtf.h:1030
RTFBorder border[6]
Definition: rtf.h:1032
int leftEdge
Definition: rtf.h:1030

Referenced by ME_RTFTblAttrHook().

◆ ME_InsertBefore()

void ME_InsertBefore ( ME_DisplayItem diWhere,
ME_DisplayItem diWhat 
)

Definition at line 26 of file list.c.

27{
28 diWhat->next = diWhere;
29 diWhat->prev = diWhere->prev;
30
31 diWhere->prev->next = diWhat;
32 diWhat->next->prev = diWhat;
33}

Referenced by ME_InsertRowStart(), ME_InsertRunAtCursor(), ME_MakeFirstParagraph(), ME_SplitParagraph(), and ME_SplitRunSimple().

◆ ME_InsertEndRowFromCursor()

void ME_InsertEndRowFromCursor ( ME_TextEditor editor,
int  nCursor 
)

Definition at line 580 of file caret.c.

581{
582 ME_Style *pStyle = ME_GetInsertStyle(editor, nCursor);
583 WCHAR space = ' ';
584
585 /* FIXME no no no */
586 if (ME_IsSelection(editor))
587 ME_DeleteSelection(editor);
588
589 ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, pStyle,
591 ME_ReleaseStyle(pStyle);
592}
static ME_DisplayItem * ME_InternalInsertTextFromCursor(ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style, int flags)
Definition: caret.c:520
#define MERF_ENDROW
Definition: editstr.h:124

Referenced by handle_enter(), and SpecialChar().

◆ ME_InsertOLEFromCursor()

void ME_InsertOLEFromCursor ( ME_TextEditor editor,
const REOBJECT reo,
int  nCursor 
)

Definition at line 546 of file caret.c.

547{
548 ME_Style *pStyle = ME_GetInsertStyle(editor, nCursor);
549 ME_DisplayItem *di;
550 WCHAR space = ' ';
551 ME_DisplayItem *di_prev = NULL;
552 struct re_object *reobj_prev = NULL;
553
554 /* FIXME no no no */
555 if (ME_IsSelection(editor))
556 ME_DeleteSelection(editor);
557
558 di = ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, pStyle,
560 di->member.run.reobj = create_re_object(reo);
561
562 di_prev = di;
563 while (ME_PrevRun(NULL, &di_prev, TRUE))
564 {
565 if (di_prev->member.run.reobj)
566 {
567 reobj_prev = di_prev->member.run.reobj;
568 break;
569 }
570 }
571 if (reobj_prev)
572 list_add_after(&reobj_prev->entry, &di->member.run.reobj->entry);
573 else
574 list_add_head(&editor->reobj_list, &di->member.run.reobj->entry);
575
576 ME_ReleaseStyle(pStyle);
577}
static struct re_object * create_re_object(const REOBJECT *reo)
Definition: caret.c:533
BOOL ME_PrevRun(ME_DisplayItem **para, ME_DisplayItem **run, BOOL all_para) DECLSPEC_HIDDEN
Definition: list.c:93
__WINE_SERVER_LIST_INLINE void list_add_after(struct list *elem, struct list *to_add)
Definition: list.h:78
struct list entry
Definition: editstr.h:154
struct list reobj_list
Definition: editstr.h:448

Referenced by insert_static_object(), and IRichEditOle_fnInsertObject().

◆ ME_InsertRunAtCursor()

ME_DisplayItem * ME_InsertRunAtCursor ( ME_TextEditor editor,
ME_Cursor cursor,
ME_Style style,
const WCHAR str,
int  len,
int  flags 
)

Definition at line 325 of file run.c.

327{
328 ME_DisplayItem *pDI, *insert_before = cursor->pRun, *prev;
329
330 if (cursor->nOffset)
331 {
332 if (cursor->nOffset == cursor->pRun->member.run.len)
333 {
334 insert_before = ME_FindItemFwd( cursor->pRun, diRun );
335 if (!insert_before) insert_before = cursor->pRun; /* Always insert before the final eop run */
336 }
337 else
338 {
339 ME_SplitRunSimple( editor, cursor );
340 insert_before = cursor->pRun;
341 }
342 }
343
344 add_undo_delete_run( editor, insert_before->member.run.para->nCharOfs +
345 insert_before->member.run.nCharOfs, len );
346
347 pDI = ME_MakeRun(style, flags);
348 pDI->member.run.nCharOfs = insert_before->member.run.nCharOfs;
349 pDI->member.run.len = len;
350 pDI->member.run.para = insert_before->member.run.para;
351 ME_InsertString( pDI->member.run.para->text, pDI->member.run.nCharOfs, str, len );
352 ME_InsertBefore( insert_before, pDI );
353 TRACE("Shift length:%d\n", len);
354 ME_PropagateCharOffset( insert_before, len );
355 mark_para_rewrap(editor, get_di_from_para(insert_before->member.run.para));
356
357 /* Move any cursors that were at the end of the previous run to the end of the inserted run */
358 prev = ME_FindItemBack( pDI, diRun );
359 if (prev)
360 {
361 int i;
362
363 for (i = 0; i < editor->nCursors; i++)
364 {
365 if (editor->pCursors[i].pRun == prev &&
366 editor->pCursors[i].nOffset == prev->member.run.len)
367 {
368 editor->pCursors[i].pRun = pDI;
369 editor->pCursors[i].nOffset = len;
370 }
371 }
372 }
373
374 return pDI;
375}
ME_DisplayItem * ME_SplitRunSimple(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: run.c:258
void ME_PropagateCharOffset(ME_DisplayItem *p, int shift)
Definition: run.c:59
ME_DisplayItem * ME_MakeRun(ME_Style *s, int nFlags)
Definition: run.c:296
void mark_para_rewrap(ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN
Definition: para.c:26
BOOL add_undo_delete_run(ME_TextEditor *, int pos, int len) DECLSPEC_HIDDEN
Definition: undo.c:204
ME_DisplayItem * get_di_from_para(ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: para.c:32
void ME_InsertBefore(ME_DisplayItem *diWhere, ME_DisplayItem *diWhat) DECLSPEC_HIDDEN
Definition: list.c:26
BOOL ME_InsertString(ME_String *s, int ofs, const WCHAR *insert, int len) DECLSPEC_HIDDEN
Definition: string.c:103

Referenced by ME_InternalInsertTextFromCursor(), and ME_PlayUndoItem().

◆ ME_InsertString()

BOOL ME_InsertString ( ME_String s,
int  ofs,
const WCHAR insert,
int  len 
)

Definition at line 103 of file string.c.

104{
105 DWORD new_len = s->nLen + len + 1;
106 WCHAR *new;
107
108 assert( s->nBuffer ); /* Not a const string */
109 assert( ofs <= s->nLen );
110
111 if( new_len > s->nBuffer )
112 {
113 s->nBuffer = ME_GetOptimalBuffer( new_len );
114 new = heap_realloc( s->szData, s->nBuffer * sizeof(WCHAR) );
115 if (!new) return FALSE;
116 s->szData = new;
117 }
118
119 memmove( s->szData + ofs + len, s->szData + ofs, (s->nLen - ofs + 1) * sizeof(WCHAR) );
120 memcpy( s->szData + ofs, insert, len * sizeof(WCHAR) );
121 s->nLen += len;
122
123 return TRUE;
124}
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
static int ME_GetOptimalBuffer(int nLen)
Definition: string.c:25
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static int insert
Definition: xmllint.c:138

Referenced by ME_AppendString(), and ME_InsertRunAtCursor().

◆ ME_InsertTableCellFromCursor()

ME_DisplayItem * ME_InsertTableCellFromCursor ( ME_TextEditor editor)

Definition at line 121 of file table.c.

122{
123 ME_DisplayItem *para;
124 WCHAR tab = '\t';
125 para = ME_InsertEndParaFromCursor(editor, 0, &tab, 1, MEPF_CELL);
126 return para;
127}
static ME_DisplayItem * ME_InsertEndParaFromCursor(ME_TextEditor *editor, int nCursor, const WCHAR *eol_str, int eol_len, int paraFlags)
Definition: table.c:61

Referenced by ME_AppendTableRow(), and ME_RTFSpecialCharHook().

◆ ME_InsertTableRowEndFromCursor()

ME_DisplayItem * ME_InsertTableRowEndFromCursor ( ME_TextEditor editor)

Definition at line 129 of file table.c.

130{
131 ME_DisplayItem *para;
132 para = ME_InsertEndParaFromCursor(editor, 0, cr_lf, 2, MEPF_ROWEND);
133 return para->member.para.prev_para;
134}

Referenced by ME_AppendTableRow(), and ME_RTFSpecialCharHook().

◆ ME_InsertTableRowStartAtParagraph()

ME_DisplayItem * ME_InsertTableRowStartAtParagraph ( ME_TextEditor editor,
ME_DisplayItem para 
)

Definition at line 86 of file table.c.

88{
89 ME_DisplayItem *prev_para, *end_para;
90 ME_Cursor savedCursor = editor->pCursors[0];
91 ME_DisplayItem *startRowPara;
92 editor->pCursors[0].pPara = para;
93 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
94 editor->pCursors[0].nOffset = 0;
95 editor->pCursors[1] = editor->pCursors[0];
96 startRowPara = ME_InsertTableRowStartFromCursor(editor);
97 savedCursor.pPara = ME_GetParagraph(savedCursor.pRun);
98 editor->pCursors[0] = savedCursor;
99 editor->pCursors[1] = editor->pCursors[0];
100
101 end_para = editor->pCursors[0].pPara->member.para.next_para;
102 prev_para = startRowPara->member.para.next_para;
103 para = prev_para->member.para.next_para;
104 while (para != end_para)
105 {
106 para->member.para.pCell = prev_para->member.para.pCell;
107 para->member.para.nFlags |= MEPF_CELL;
111 para->member.para.fmt.wEffects &= ~PFE_TABLEROWDELIMITER;
112 prev_para = para;
113 para = para->member.para.next_para;
114 }
115 return startRowPara;
116}

Referenced by ME_RTFParAttrHook(), and ME_RTFSpecialCharHook().

◆ ME_InsertTableRowStartFromCursor()

ME_DisplayItem * ME_InsertTableRowStartFromCursor ( ME_TextEditor editor)

Definition at line 79 of file table.c.

80{
81 ME_DisplayItem *para;
82 para = ME_InsertEndParaFromCursor(editor, 0, cr_lf, 2, MEPF_ROWSTART);
83 return para->member.para.prev_para;
84}

Referenced by ME_AppendTableRow(), ME_InsertTableRowStartAtParagraph(), and ME_RTFParAttrHook().

◆ ME_InsertTextFromCursor()

void ME_InsertTextFromCursor ( ME_TextEditor editor,
int  nCursor,
const WCHAR str,
int  len,
ME_Style style 
)

Definition at line 595 of file caret.c.

597{
598 const WCHAR *pos;
599 ME_Cursor *p = NULL;
600 int oldLen;
601
602 /* FIXME really HERE ? */
603 if (ME_IsSelection(editor))
604 ME_DeleteSelection(editor);
605
606 /* FIXME: is this too slow? */
607 /* Didn't affect performance for WM_SETTEXT (around 50sec/30K) */
608 oldLen = ME_GetTextLength(editor);
609
610 /* text operations set modified state */
611 editor->nModifyStep = 1;
612
613 assert(style);
614
615 assert(nCursor>=0 && nCursor<editor->nCursors);
616 if (len == -1)
617 len = lstrlenW(str);
618
619 /* grow the text limit to fit our text */
620 if(editor->nTextLimit < oldLen +len)
621 editor->nTextLimit = oldLen + len;
622
623 pos = str;
624
625 while (len)
626 {
627 /* FIXME this sucks - no respect for unicode (what else can be a line separator in unicode?) */
628 while(pos - str < len && *pos != '\r' && *pos != '\n' && *pos != '\t')
629 pos++;
630
631 if (pos != str) { /* handle text */
632 ME_InternalInsertTextFromCursor(editor, nCursor, str, pos-str, style, 0);
633 } else if (*pos == '\t') { /* handle tabs */
634 WCHAR tab = '\t';
635 ME_InternalInsertTextFromCursor(editor, nCursor, &tab, 1, style, MERF_TAB);
636 pos++;
637 } else { /* handle EOLs */
638 ME_DisplayItem *tp, *end_run, *run, *prev;
639 int eol_len = 0;
640
641 /* Check if new line is allowed for this control */
642 if (!(editor->styleFlags & ES_MULTILINE))
643 break;
644
645 /* Find number of CR and LF in end of paragraph run */
646 if (*pos =='\r')
647 {
648 if (len > 1 && pos[1] == '\n')
649 eol_len = 2;
650 else if (len > 2 && pos[1] == '\r' && pos[2] == '\n')
651 eol_len = 3;
652 else
653 eol_len = 1;
654 } else {
655 assert(*pos == '\n');
656 eol_len = 1;
657 }
658 pos += eol_len;
659
660 if (!editor->bEmulateVersion10 && eol_len == 3)
661 {
662 /* handle special \r\r\n sequence (richedit 2.x and higher only) */
663 WCHAR space = ' ';
664 ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, style, 0);
665 } else {
666 const WCHAR cr = '\r', *eol_str = str;
667
668 if (!editor->bEmulateVersion10)
669 {
670 eol_str = &cr;
671 eol_len = 1;
672 }
673
674 p = &editor->pCursors[nCursor];
675
676 if (p->nOffset == p->pRun->member.run.len)
677 {
678 run = ME_FindItemFwd( p->pRun, diRun );
679 if (!run) run = p->pRun;
680 }
681 else
682 {
683 if (p->nOffset) ME_SplitRunSimple(editor, p);
684 run = p->pRun;
685 }
686
687 tp = ME_SplitParagraph(editor, run, style, eol_str, eol_len, 0);
688
689 end_run = ME_FindItemBack(tp, diRun);
690
691 /* Move any cursors that were at the end of the previous run to the beginning of the new para */
692 prev = ME_FindItemBack( end_run, diRun );
693 if (prev)
694 {
695 int i;
696 for (i = 0; i < editor->nCursors; i++)
697 {
698 if (editor->pCursors[i].pRun == prev &&
699 editor->pCursors[i].nOffset == prev->member.run.len)
700 {
701 editor->pCursors[i].pPara = tp;
702 editor->pCursors[i].pRun = run;
703 editor->pCursors[i].nOffset = 0;
704 }
705 }
706 }
707
708 }
709 }
710 len -= pos - str;
711 str = pos;
712 }
713}
#define lstrlenW
Definition: compat.h:750
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
ME_DisplayItem * ME_SplitRunSimple(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN
Definition: run.c:258
ME_DisplayItem * ME_SplitParagraph(ME_TextEditor *editor, ME_DisplayItem *rp, ME_Style *style, const WCHAR *eol_str, int eol_len, int paraFlags) DECLSPEC_HIDDEN
Definition: para.c:545

Referenced by fnTextSrv_TxSetText(), handle_enter(), ITextRange_fnSetText(), ME_AppendTableRow(), ME_Char(), ME_HandleMessage(), ME_ReplaceSel(), ME_RTFParAttrHook(), ME_RTFSpecialCharHook(), ME_SetText(), ME_StreamInText(), and RTFFlushUnicodeOutputBuffer().

◆ ME_InternalDeleteText()

BOOL ME_InternalDeleteText ( ME_TextEditor editor,
ME_Cursor start,
int  nChars,
BOOL  bForce 
)

Definition at line 360 of file caret.c.

362{
363 ME_Cursor c = *start;
364 int nOfs = ME_GetCursorOfs(start), text_len = ME_GetTextLength( editor );
365 int shift = 0;
366 int totalChars = nChars;
367 ME_DisplayItem *start_para;
368 BOOL delete_all = FALSE;
369
370 /* Prevent deletion past last end of paragraph run. */
371 nChars = min(nChars, text_len - nOfs);
372 if (nChars == text_len) delete_all = TRUE;
373 start_para = c.pPara;
374
375 if (!bForce)
376 {
377 ME_ProtectPartialTableDeletion(editor, &c, &nChars);
378 if (nChars == 0)
379 return FALSE;
380 }
381
382 while(nChars > 0)
383 {
384 ME_Run *run;
385 ME_CursorFromCharOfs(editor, nOfs+nChars, &c);
386 if (!c.nOffset &&
387 nOfs+nChars == (c.pRun->member.run.nCharOfs
388 + c.pPara->member.para.nCharOfs))
389 {
390 /* We aren't deleting anything in this run, so we will go back to the
391 * last run we are deleting text in. */
392 ME_PrevRun(&c.pPara, &c.pRun, TRUE);
393 c.nOffset = c.pRun->member.run.len;
394 }
395 run = &c.pRun->member.run;
396 if (run->nFlags & MERF_ENDPARA) {
397 int eollen = c.pRun->member.run.len;
398 BOOL keepFirstParaFormat;
399
400 if (!ME_FindItemFwd(c.pRun, diParagraph))
401 {
402 return TRUE;
403 }
404 keepFirstParaFormat = (totalChars == nChars && nChars <= eollen &&
405 run->nCharOfs);
406 if (!editor->bEmulateVersion10) /* v4.1 */
407 {
409 ME_DisplayItem *this_para = next_para->member.para.prev_para;
410
411 /* The end of paragraph before a table row is only deleted if there
412 * is nothing else on the line before it. */
413 if (this_para == start_para &&
414 next_para->member.para.nFlags & MEPF_ROWSTART)
415 {
416 /* If the paragraph will be empty, then it should be deleted, however
417 * it still might have text right now which would inherit the
418 * MEPF_STARTROW property if we joined it right now.
419 * Instead we will delete it after the preceding text is deleted. */
420 if (nOfs > this_para->member.para.nCharOfs) {
421 /* Skip this end of line. */
422 nChars -= (eollen < nChars) ? eollen : nChars;
423 continue;
424 }
425 keepFirstParaFormat = TRUE;
426 }
427 }
428 ME_JoinParagraphs(editor, c.pPara, keepFirstParaFormat);
429 /* ME_SkipAndPropagateCharOffset(p->pRun, shift); */
430 ME_CheckCharOffsets(editor);
431 nChars -= (eollen < nChars) ? eollen : nChars;
432 continue;
433 }
434 else
435 {
437 int nCharsToDelete = min(nChars, c.nOffset);
438 int i;
439
440 c.nOffset -= nCharsToDelete;
441
443
444 cursor = c;
445 /* nChars is the number of characters that should be deleted from the
446 PRECEDING runs (these BEFORE cursor.pRun)
447 nCharsToDelete is a number of chars to delete from THIS run */
448 nChars -= nCharsToDelete;
449 shift -= nCharsToDelete;
450 TRACE("Deleting %d (remaining %d) chars at %d in %s (%d)\n",
451 nCharsToDelete, nChars, c.nOffset,
452 debugstr_run( run ), run->len);
453
454 /* nOfs is a character offset (from the start of the document
455 to the current (deleted) run */
456 add_undo_insert_run( editor, nOfs + nChars, get_text( run, c.nOffset ), nCharsToDelete, run->nFlags, run->style );
457
458 ME_StrDeleteV(run->para->text, run->nCharOfs + c.nOffset, nCharsToDelete);
459 run->len -= nCharsToDelete;
460 TRACE("Post deletion string: %s (%d)\n", debugstr_run( run ), run->len);
461 TRACE("Shift value: %d\n", shift);
462
463 /* update cursors (including c) */
464 for (i=-1; i<editor->nCursors; i++) {
465 ME_Cursor *pThisCur = editor->pCursors + i;
466 if (i == -1) pThisCur = &c;
467 if (pThisCur->pRun == cursor.pRun) {
468 if (pThisCur->nOffset > cursor.nOffset) {
469 if (pThisCur->nOffset-cursor.nOffset < nCharsToDelete)
470 pThisCur->nOffset = cursor.nOffset;
471 else
472 pThisCur->nOffset -= nCharsToDelete;
473 assert(pThisCur->nOffset >= 0);
474 assert(pThisCur->nOffset <= run->len);
475 }
476 if (pThisCur->nOffset == run->len)
477 {
478 pThisCur->pRun = ME_FindItemFwd(pThisCur->pRun, diRunOrParagraphOrEnd);
479 assert(pThisCur->pRun->type == diRun);
480 pThisCur->nOffset = 0;
481 }
482 }
483 }
484
485 /* c = updated data now */
486
487 if (c.pRun == cursor.pRun)
489 else
491
492 if (!cursor.pRun->member.run.len)
493 {
494 TRACE("Removing empty run\n");
495 ME_Remove(cursor.pRun);
497 }
498
499 shift = 0;
500 /*
501 ME_CheckCharOffsets(editor);
502 */
503 continue;
504 }
505 }
506 if (delete_all) ME_SetDefaultParaFormat( editor, &start_para->member.para.fmt );
507 return TRUE;
508}
BOOL add_undo_insert_run(ME_TextEditor *, int pos, const WCHAR *str, int len, int flags, ME_Style *style) DECLSPEC_HIDDEN
Definition: undo.c:131
void ME_PropagateCharOffset(ME_DisplayItem *p, int shift) DECLSPEC_HIDDEN
Definition: run.c:59
void ME_ProtectPartialTableDeletion(ME_TextEditor *editor, ME_Cursor *c, int *nChars) DECLSPEC_HIDDEN
Definition: table.c:287
void ME_SetDefaultParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) DECLSPEC_HIDDEN
Definition: para.c:992
ME_DisplayItem * ME_JoinParagraphs(ME_TextEditor *editor, ME_DisplayItem *tp, BOOL keepFirstParaFormat) DECLSPEC_HIDDEN
Definition: para.c:687
void ME_Remove(ME_DisplayItem *diWhere) DECLSPEC_HIDDEN
Definition: list.c:35
void ME_SkipAndPropagateCharOffset(ME_DisplayItem *p, int shift) DECLSPEC_HIDDEN
Definition: run.c:46
void ME_StrDeleteV(ME_String *s, int nVChar, int nChars) DECLSPEC_HIDDEN
Definition: string.c:147
@ diParagraphOrEnd
Definition: editstr.h:96

Referenced by copy_or_cut(), fnTextSrv_TxSetText(), ITextRange_fnSetText(), ME_DeleteTextAtCursor(), ME_HandleMessage(), ME_PlayUndoItem(), ME_ReplaceSel(), ME_RTFSpecialCharHook(), and ME_StreamIn().

◆ ME_InvalidateParagraphRange()

void ME_InvalidateParagraphRange ( ME_TextEditor editor,
ME_DisplayItem start_para,
ME_DisplayItem last_para 
)

Definition at line 1168 of file wrap.c.

1171{
1172 ME_Context c;
1173 RECT rc;
1174 int ofs;
1175
1176 ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
1177 rc = c.rcView;
1178 ofs = editor->vert_si.nPos;
1179
1180 if (start_para) {
1181 start_para = ME_GetOuterParagraph(start_para);
1182 last_para = ME_GetOuterParagraph(last_para);
1183 rc.top = c.rcView.top + start_para->member.para.pt.y - ofs;
1184 } else {
1185 rc.top = c.rcView.top + editor->nTotalLength - ofs;
1186 }
1187 if (editor->nTotalLength < editor->nLastTotalLength)
1188 rc.bottom = c.rcView.top + editor->nLastTotalLength - ofs;
1189 else
1190 rc.bottom = c.rcView.top + last_para->member.para.pt.y + last_para->member.para.nHeight - ofs;
1192
1194}
ME_DisplayItem * ME_GetOuterParagraph(ME_DisplayItem *para) DECLSPEC_HIDDEN
Definition: table.c:172
int nLastTotalLength
Definition: editstr.h:392

Referenced by ME_InvalidateSelection(), and ME_WrapMarkedParagraphs().

◆ ME_InvalidateSelection()

void ME_InvalidateSelection ( ME_TextEditor editor)

Definition at line 1322 of file paint.c.

1323{
1324 ME_DisplayItem *sel_start, *sel_end;
1325 ME_DisplayItem *repaint_start = NULL, *repaint_end = NULL;
1326 int nStart, nEnd;
1327 int len = ME_GetTextLength(editor);
1328
1329 ME_GetSelectionOfs(editor, &nStart, &nEnd);
1330 /* if both old and new selection are 0-char (= caret only), then
1331 there's no (inverted) area to be repainted, neither old nor new */
1332 if (nStart == nEnd && editor->nLastSelStart == editor->nLastSelEnd)
1333 return;
1335 ME_GetSelectionParas(editor, &sel_start, &sel_end);
1336 assert(sel_start->type == diParagraph);
1337 assert(sel_end->type == diParagraph);
1338 /* last selection markers aren't always updated, which means
1339 * they can point past the end of the document */
1340 if (editor->nLastSelStart > len || editor->nLastSelEnd > len) {
1341 repaint_start = ME_FindItemFwd(editor->pBuffer->pFirst, diParagraph);
1342 repaint_end = editor->pBuffer->pLast->member.para.prev_para;
1343 } else {
1344 /* if the start part of selection is being expanded or contracted... */
1345 if (nStart < editor->nLastSelStart) {
1346 repaint_start = sel_start;
1347 repaint_end = editor->pLastSelStartPara;
1348 } else if (nStart > editor->nLastSelStart) {
1349 repaint_start = editor->pLastSelStartPara;
1350 repaint_end = sel_start;
1351 }
1352
1353 /* if the end part of selection is being contracted or expanded... */
1354 if (nEnd < editor->nLastSelEnd) {
1355 if (!repaint_start) repaint_start = sel_end;
1356 repaint_end = editor->pLastSelEndPara;
1357 } else if (nEnd > editor->nLastSelEnd) {
1358 if (!repaint_start) repaint_start = editor->pLastSelEndPara;
1359 repaint_end = sel_end;
1360 }
1361 }
1362
1363 if (repaint_start)
1364 ME_InvalidateParagraphRange(editor, repaint_start, repaint_end);
1365 /* remember the last invalidated position */
1366 ME_GetSelectionOfs(editor, &editor->nLastSelStart, &editor->nLastSelEnd);
1367 ME_GetSelectionParas(editor, &editor->pLastSelStartPara, &editor->pLastSelEndPara);
1370}
void ME_GetSelectionParas(ME_TextEditor *editor, ME_DisplayItem **para, ME_DisplayItem **para_end) DECLSPEC_HIDDEN
Definition: para.c:883
void ME_InvalidateParagraphRange(ME_TextEditor *editor, ME_DisplayItem *start_para, ME_DisplayItem *last_para) DECLSPEC_HIDDEN
Definition: wrap.c:1168
ME_DisplayItem * pLastSelEndPara
Definition: editstr.h:409
ME_DisplayItem * pLastSelStartPara
Definition: editstr.h:409

Referenced by ME_ArrowKey(), ME_HandleMessage(), ME_LButtonDown(), ME_MouseMove(), ME_TabPressedInTable(), and set_selection().

◆ ME_IsInTable()

BOOL ME_IsInTable ( ME_DisplayItem pItem)

Definition at line 273 of file table.c.

274{
275 PARAFORMAT2 *pFmt;
276 if (!pItem)
277 return FALSE;
278 if (pItem->type == diRun)
279 pItem = ME_GetParagraph(pItem);
280 if (pItem->type != diParagraph)
281 return FALSE;
282 pFmt = &pItem->member.para.fmt;
283 return pFmt->dwMask & PFM_TABLE && pFmt->wEffects & PFE_TABLE;
284}

Referenced by handle_enter(), ME_Char(), ME_SelectOrInsertNextCell(), ME_StreamIn(), and ME_TabPressedInTable().

◆ ME_IsSelection()

◆ ME_IsWSpace()

static int ME_IsWSpace ( WCHAR  ch)
inlinestatic

Definition at line 101 of file editor.h.

102{
103 return ch > '\0' && ch <= ' ';
104}

Referenced by find_non_whitespace(), ME_UpdateRunFlags(), ME_WordBreakProc(), reverse_find_non_whitespace(), reverse_find_whitespace(), run_is_entirely_ws(), and run_is_splittable().

◆ ME_JoinParagraphs()

ME_DisplayItem * ME_JoinParagraphs ( ME_TextEditor editor,
ME_DisplayItem tp,
BOOL  keepFirstParaFormat 
)

Definition at line 687 of file para.c.

689{
690 ME_DisplayItem *pNext, *pFirstRunInNext, *pRun, *pTmp, *pCell = NULL;
691 int i, shift;
692 int end_len;
694 ME_Cursor startCur, endCur;
695 ME_String *eol_str;
696
697 assert(tp->type == diParagraph);
698 assert(tp->member.para.next_para);
699 assert(tp->member.para.next_para->type == diParagraph);
700
701 /* Clear any cached para numbering following this paragraph */
702 if (tp->member.para.fmt.wNumbering)
703 para_num_clear_list( editor, &tp->member.para, &tp->member.para.fmt );
704
705 pNext = tp->member.para.next_para;
706
707 /* Need to locate end-of-paragraph run here, in order to know end_len */
708 pRun = ME_FindItemBack(pNext, diRunOrParagraph);
709
710 assert(pRun);
711 assert(pRun->type == diRun);
713
714 end_len = pRun->member.run.len;
715 eol_str = ME_VSplitString( tp->member.para.text, pRun->member.run.nCharOfs );
716 ME_AppendString( tp->member.para.text, pNext->member.para.text->szData, pNext->member.para.text->nLen );
717
718 /* null char format operation to store the original char format for the ENDPARA run */
720 endCur.pPara = pNext;
721 endCur.pRun = ME_FindItemFwd(pNext, diRun);
722 endCur.nOffset = 0;
723 startCur = endCur;
724 ME_PrevRun(&startCur.pPara, &startCur.pRun, TRUE);
725 ME_SetCharFormat(editor, &startCur, &endCur, &fmt);
726
727 if (!editor->bEmulateVersion10) { /* v4.1 */
728 /* Table cell/row properties are always moved over from the removed para. */
729 tp->member.para.nFlags = pNext->member.para.nFlags;
730 tp->member.para.pCell = pNext->member.para.pCell;
731
732 /* Remove cell boundary if it is between the end paragraph run and the next
733 * paragraph display item. */
734 for (pTmp = pRun->next; pTmp != pNext; pTmp = pTmp->next)
735 {
736 if (pTmp->type == diCell)
737 {
738 pCell = pTmp;
739 break;
740 }
741 }
742 }
743
744 add_undo_split_para( editor, &pNext->member.para, eol_str, pCell ? &pCell->member.cell : NULL );
745
746 if (pCell)
747 {
748 ME_Remove( pCell );
749 if (pCell->member.cell.prev_cell)
750 pCell->member.cell.prev_cell->member.cell.next_cell = pCell->member.cell.next_cell;
751 if (pCell->member.cell.next_cell)
752 pCell->member.cell.next_cell->member.cell.prev_cell = pCell->member.cell.prev_cell;
753 ME_DestroyDisplayItem( pCell );
754 }
755
756 if (!keepFirstParaFormat)
757 {
758 add_undo_set_para_fmt( editor, &tp->member.para );
759 tp->member.para.fmt = pNext->member.para.fmt;
760 tp->member.para.border = pNext->member.para.border;
761 }
762
763 shift = pNext->member.para.nCharOfs - tp->member.para.nCharOfs - end_len;
764
765 pFirstRunInNext = ME_FindItemFwd(pNext, diRunOrParagraph);
766
767 assert(pFirstRunInNext->type == diRun);
768
769 /* Update selection cursors so they don't point to the removed end
770 * paragraph run, and point to the correct paragraph. */
771 for (i=0; i < editor->nCursors; i++) {
772 if (editor->pCursors[i].pRun == pRun) {
773 editor->pCursors[i].pRun = pFirstRunInNext;
774 editor->pCursors[i].nOffset = 0;
775 } else if (editor->pCursors[i].pPara == pNext) {
776 editor->pCursors[i].pPara = tp;
777 }
778 }
779
780 pTmp = pNext;
781 do {
783 if (pTmp->type != diRun)
784 break;
785 TRACE("shifting %s by %d (previous %d)\n", debugstr_run( &pTmp->member.run ), shift, pTmp->member.run.nCharOfs);
786 pTmp->member.run.nCharOfs += shift;
787 pTmp->member.run.para = &tp->member.para;
788 } while(1);
789
790 /* Fix up the para's eop_run ptr */
791 tp->member.para.eop_run = pNext->member.para.eop_run;
792
793 ME_Remove(pRun);
795
796 if (editor->pLastSelStartPara == pNext)
797 editor->pLastSelStartPara = tp;
798 if (editor->pLastSelEndPara == pNext)
799 editor->pLastSelEndPara = tp;
800
801 tp->member.para.next_para = pNext->member.para.next_para;
802 pNext->member.para.next_para->member.para.prev_para = tp;
803 ME_Remove(pNext);
804 destroy_para(editor, pNext);
805
806 ME_PropagateCharOffset(tp->member.para.next_para, -end_len);
807
808 ME_CheckCharOffsets(editor);
809
810 editor->nParagraphs--;
811 mark_para_rewrap(editor, tp);
812 return tp;
813}
void ME_InitCharFormat2W(CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN
Definition: style.c:150
BOOL ME_AppendString(ME_String *s, const WCHAR *append, int len) DECLSPEC_HIDDEN
Definition: string.c:126
BOOL add_undo_set_para_fmt(ME_TextEditor *, const ME_Paragraph *para) DECLSPEC_HIDDEN
Definition: undo.c:152
BOOL add_undo_split_para(ME_TextEditor *, const ME_Paragraph *para, ME_String *eol_str, const ME_Cell *cell) DECLSPEC_HIDDEN
Definition: undo.c:185
ME_String * ME_VSplitString(ME_String *orig, int nVPos) DECLSPEC_HIDDEN
Definition: string.c:131
void destroy_para(ME_TextEditor *editor, ME_DisplayItem *item)
Definition: para.c:48
void mark_para_rewrap(ME_TextEditor *editor, ME_DisplayItem *para)
Definition: para.c:26
static void para_num_clear_list(ME_TextEditor *editor, ME_Paragraph *para, const PARAFORMAT2 *orig_fmt)
Definition: para.c:453
ME_String * text
Definition: editstr.h:205
ME_Run * eop_run
Definition: editstr.h:216

Referenced by ME_InternalDeleteText(), and ME_PlayUndoItem().

◆ ME_JoinRuns()

void ME_JoinRuns ( ME_TextEditor editor,
ME_DisplayItem p 
)

Definition at line 229 of file run.c.

230{
231 ME_DisplayItem *pNext = p->next;
232 int i;
233 assert(p->type == diRun && pNext->type == diRun);
234 assert(p->member.run.nCharOfs != -1);
236
237 /* Update all cursors so that they don't contain the soon deleted run */
238 for (i=0; i<editor->nCursors; i++) {
239 if (editor->pCursors[i].pRun == pNext) {
240 editor->pCursors[i].pRun = p;
241 editor->pCursors[i].nOffset += p->member.run.len;
242 }
243 }
244
245 p->member.run.len += pNext->member.run.len;
246 ME_Remove(pNext);
248 ME_UpdateRunFlags(editor, &p->member.run);
249 ME_CheckCharOffsets(editor);
250}
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
Definition: run.c:413
void ME_CheckCharOffsets(ME_TextEditor *editor)
Definition: run.c:101

Referenced by ME_PrepareParagraphForWrapping().

◆ ME_LButtonDown()

void ME_LButtonDown ( ME_TextEditor editor,
int  x,
int  y,
int  clickNum 
)

Definition at line 1204 of file caret.c.

1205{
1206 ME_Cursor tmp_cursor;
1207 BOOL is_selection = FALSE, is_shift;
1208
1209 editor->nUDArrowX = -1;
1210
1211 x += editor->horz_si.nPos;
1212 y += editor->vert_si.nPos;
1213
1214 tmp_cursor = editor->pCursors[0];
1215 is_selection = ME_IsSelection(editor);
1216 is_shift = GetKeyState(VK_SHIFT) < 0;
1217
1218 ME_FindPixelPos(editor, x, y, &editor->pCursors[0], &editor->bCaretAtEnd, FALSE);
1219
1220 if (x >= editor->rcFormat.left || is_shift)
1221 {
1222 if (clickNum > 1)
1223 {
1224 editor->pCursors[1] = editor->pCursors[0];
1225 if (is_shift) {
1226 if (x >= editor->rcFormat.left)
1227 ME_SelectByType(editor, stWord);
1228 else
1230 } else if (clickNum % 2 == 0) {
1231 ME_SelectByType(editor, stWord);
1232 } else {
1234 }
1235 }
1236 else if (!is_shift)
1237 {
1238 editor->nSelectionType = stPosition;
1239 editor->pCursors[1] = editor->pCursors[0];
1240 }
1241 else if (!is_selection)
1242 {
1243 editor->nSelectionType = stPosition;
1244 editor->pCursors[1] = tmp_cursor;
1245 }
1246 else if (editor->nSelectionType != stPosition)
1247 {
1249 }
1250 }
1251 else
1252 {
1253 if (clickNum < 2) {
1254 ME_SelectByType(editor, stLine);
1255 } else if (clickNum % 2 == 0 || is_shift) {
1257 } else {
1258 ME_SelectByType(editor, stDocument);
1259 }
1260 }
1261 ME_InvalidateSelection(editor);
1262 update_caret(editor);
1263 ME_SendSelChange(editor);
1264}
static void ME_ExtendAnchorSelection(ME_TextEditor *editor)
Definition: caret.c:1152
static void ME_SelectByType(ME_TextEditor *editor, ME_SelectionType selectionType)
Definition: caret.c:899
@ stWord
Definition: editstr.h:358
@ stParagraph
Definition: editstr.h:360
@ stLine
Definition: editstr.h:359
#define VK_SHIFT
Definition: winuser.h:2202

Referenced by ME_HandleMessage().

◆ ME_MakeDI()

ME_DisplayItem * ME_MakeDI ( ME_DIType  type)

Definition at line 178 of file list.c.

179{
180 ME_DisplayItem *item = heap_alloc_zero(sizeof(*item));
181
182 item->type = type;
183 item->prev = item->next = NULL;
184 return item;
185}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by make_para(), ME_MakeRow(), ME_MakeRun(), ME_MakeText(), and ME_SplitParagraph().

◆ ME_MakeEditor()

ME_TextEditor * ME_MakeEditor ( ITextHost *  texthost,
BOOL  bEmulateVersion10 
)

Definition at line 3056 of file editor.c.

3057{
3058 ME_TextEditor *ed = heap_alloc(sizeof(*ed));
3059 int i;
3060 DWORD props;
3061 LONG selbarwidth;
3062
3063 ed->hWnd = NULL;
3064 ed->hwndParent = NULL;
3065 ed->sizeWindow.cx = ed->sizeWindow.cy = 0;
3066 ed->texthost = texthost;
3067 ed->reOle = NULL;
3068 ed->bEmulateVersion10 = bEmulateVersion10;
3069 ed->styleFlags = 0;
3070 ed->exStyleFlags = 0;
3071 ed->first_marked_para = NULL;
3072 ed->total_rows = 0;
3079 &props);
3080 ITextHost_TxGetScrollBars(texthost, &ed->styleFlags);
3083 ed->pBuffer = ME_MakeText();
3084 ed->nZoomNumerator = ed->nZoomDenominator = 0;
3085 ed->nAvailWidth = 0; /* wrap to client area */
3086 list_init( &ed->style_list );
3088 /* The four cursors are for:
3089 * 0 - The position where the caret is shown
3090 * 1 - The anchored end of the selection (for normal selection)
3091 * 2 & 3 - The anchored start and end respectively for word, line,
3092 * or paragraph selection.
3093 */
3094 ed->nCursors = 4;
3095 ed->pCursors = heap_alloc(ed->nCursors * sizeof(*ed->pCursors));
3096 ME_SetCursorToStart(ed, &ed->pCursors[0]);
3097 ed->pCursors[1] = ed->pCursors[0];
3098 ed->pCursors[2] = ed->pCursors[0];
3099 ed->pCursors[3] = ed->pCursors[1];
3100 ed->nLastTotalLength = ed->nTotalLength = 0;
3101 ed->nLastTotalWidth = ed->nTotalWidth = 0;
3102 ed->nUDArrowX = -1;
3103 ed->rgbBackColor = -1;
3105 ed->bCaretAtEnd = FALSE;
3106 ed->nEventMask = 0;
3107 ed->nModifyStep = 0;
3109 list_init( &ed->undo_stack );
3110 list_init( &ed->redo_stack );
3111 ed->nUndoStackSize = 0;
3113 ed->nUndoMode = umAddToUndo;
3114 ed->nParagraphs = 1;
3115 ed->nLastSelStart = ed->nLastSelEnd = 0;
3117 ed->bHideSelection = FALSE;
3118 ed->pfnWordBreak = NULL;
3119 ed->lpOleCallback = NULL;
3123 ed->bHaveFocus = FALSE;
3124 ed->bDialogMode = FALSE;
3125 ed->bMouseCaptured = FALSE;
3126 ed->caret_hidden = FALSE;
3127 ed->caret_height = 0;
3128 for (i=0; i<HFONT_CACHE_SIZE; i++)
3129 {
3130 ed->pFontCache[i].nRefs = 0;
3131 ed->pFontCache[i].nAge = 0;
3132 ed->pFontCache[i].hFont = NULL;
3133 }
3134
3136 SetRectEmpty(&ed->rcFormat);
3138 ITextHost_TxGetSelectionBarWidth(ed->texthost, &selbarwidth);
3139 if (selbarwidth) {
3140 /* FIXME: Convert selbarwidth from HIMETRIC to pixels */
3143 } else {
3144 ed->selofs = 0;
3145 }
3147
3148 ed->cPasswordMask = 0;
3151
3154 if (props & TXTBIT_MULTILINE) {
3155 ed->styleFlags |= ES_MULTILINE;
3156 ed->bWordWrap = (props & TXTBIT_WORDWRAP) != 0;
3157 } else {
3158 ed->bWordWrap = FALSE;
3159 }
3160 if (props & TXTBIT_READONLY)
3161 ed->styleFlags |= ES_READONLY;
3162 if (!(props & TXTBIT_HIDESELECTION))
3163 ed->styleFlags |= ES_NOHIDESEL;
3165 ed->styleFlags |= ES_SAVESEL;
3166 if (props & TXTBIT_VERTICAL)
3167 ed->styleFlags |= ES_VERTICAL;
3170
3171 ed->notified_cr.cpMin = ed->notified_cr.cpMax = 0;
3172
3173 /* Default scrollbar information */
3174 ed->vert_si.cbSize = sizeof(SCROLLINFO);
3175 ed->vert_si.nMin = 0;
3176 ed->vert_si.nMax = 0;
3177 ed->vert_si.nPage = 0;
3178 ed->vert_si.nPos = 0;
3179
3180 ed->horz_si.cbSize = sizeof(SCROLLINFO);
3181 ed->horz_si.nMin = 0;
3182 ed->horz_si.nMax = 0;
3183 ed->horz_si.nPage = 0;
3184 ed->horz_si.nPos = 0;
3185
3186 ed->wheel_remain = 0;
3187
3188 list_init( &ed->reobj_list );
3190
3191 return ed;
3192}
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:169
static ME_TextBuffer * ME_MakeText(void)
Definition: editor.c:271
#define TEXT_LIMIT_DEFAULT
Definition: editor.c:249
#define ITextHost_TxGetPropertyBits(This, a, b)
Definition: editor.h:321
void ME_MakeFirstParagraph(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: para.c:151
#define ITextHost_TxGetScrollBars(This, a)
Definition: editor.h:315
#define ITextHost_TxGetSelectionBarWidth(This, a)
Definition: editor.h:325
#define ITextHost_TxGetPasswordChar(This, a)
Definition: editor.h:316
if(dx< 0)
Definition: linetemp.h:194
#define ES_NOOLEDRAGDROP
Definition: richedit.h:223
#define ES_DISABLENOSCROLL
Definition: richedit.h:224
#define ES_SELECTIONBAR
Definition: richedit.h:230
#define ES_VERTICAL
Definition: richedit.h:229
int nLastTotalWidth
Definition: editstr.h:393
CHARRANGE notified_cr
Definition: editstr.h:438
BOOL caret_hidden
Definition: editstr.h:444
#define TXTBIT_AUTOWORDSEL
Definition: textserv.h:193
#define TXTBIT_WORDWRAP
Definition: textserv.h:196
#define TXTBIT_MULTILINE
Definition: textserv.h:187
#define TXTBIT_VERTICAL
Definition: textserv.h:194
#define TXTBIT_SAVESELECTION
Definition: textserv.h:192
#define TXTBIT_READONLY
Definition: textserv.h:188
#define TXTBIT_RICHTEXT
Definition: textserv.h:186
#define TXTBIT_USEPASSWORD
Definition: textserv.h:190
#define TXTBIT_HIDESELECTION
Definition: textserv.h:191
#define TXTBIT_DISABLEDRAG
Definition: textserv.h:198
static const WCHAR props[]
Definition: wbemdisp.c:288
struct tagSCROLLINFO SCROLLINFO
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)

Referenced by create_windowed_editor(), and CreateTextServices().

◆ ME_MakeFirstParagraph()

void ME_MakeFirstParagraph ( ME_TextEditor editor)

Definition at line 151 of file para.c.

152{
153 static const WCHAR cr_lf[] = {'\r','\n',0};
156 const CHARFORMATW *host_cf;
157 LOGFONTW lf;
158 HFONT hf;
159 ME_TextBuffer *text = editor->pBuffer;
160 ME_DisplayItem *para = make_para(editor);
161 ME_DisplayItem *run;
163 int eol_len;
164
165 ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
166
168 assert(hf);
169 GetObjectW(hf, sizeof(LOGFONTW), &lf);
170 ZeroMemory(&cf, sizeof(cf));
171 cf.cbSize = sizeof(cf);
178
179 cf.dwEffects = CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR;
180 lstrcpyW(cf.szFaceName, lf.lfFaceName);
181 /* Convert system font height from logical units to twips for cf.yHeight */
182 cf.yHeight = (lf.lfHeight * 72 * 1440) / (c.dpi.cy * c.dpi.cy);
183 if (lf.lfWeight > FW_NORMAL) cf.dwEffects |= CFE_BOLD;
184 cf.wWeight = lf.lfWeight;
185 if (lf.lfItalic) cf.dwEffects |= CFE_ITALIC;
186 if (lf.lfUnderline) cf.dwEffects |= CFE_UNDERLINE;
187 cf.bUnderlineType = CFU_UNDERLINE;
188 if (lf.lfStrikeOut) cf.dwEffects |= CFE_STRIKEOUT;
189 cf.bPitchAndFamily = lf.lfPitchAndFamily;
190 cf.bCharSet = lf.lfCharSet;
191 cf.lcid = GetSystemDefaultLCID();
192
194 text->pDefaultStyle = style;
195
196 if (ITextHost_TxGetCharFormat(editor->texthost, &host_cf) == S_OK)
197 {
198 ZeroMemory(&cf, sizeof(cf));
199 cf.cbSize = sizeof(cf);
200 cfany_to_cf2w(&cf, (CHARFORMAT2W *)host_cf);
201 ME_SetDefaultCharFormat(editor, &cf);
202 }
203
204 eol_len = editor->bEmulateVersion10 ? 2 : 1;
205 para->member.para.text = ME_MakeStringN( cr_lf, eol_len );
206
208 run->member.run.nCharOfs = 0;
209 run->member.run.len = eol_len;
210 run->member.run.para = &para->member.para;
211
212 para->member.para.eop_run = &run->member.run;
213
214 ME_InsertBefore(text->pLast, para);
215 ME_InsertBefore(text->pLast, run);
216 para->member.para.prev_para = text->pFirst;
217 para->member.para.next_para = text->pLast;
218 text->pFirst->member.para.next_para = para;
219 text->pLast->member.para.prev_para = para;
220
221 text->pLast->member.para.nCharOfs = editor->bEmulateVersion10 ? 2 : 1;
222
223 add_marked_para(editor, para);
225}
const WCHAR * text
Definition: package.c:1799
BOOL cfany_to_cf2w(CHARFORMAT2W *to, const CHARFORMAT2W *from) DECLSPEC_HIDDEN
Definition: style.c:36
ME_DisplayItem * ME_MakeRun(ME_Style *s, int nFlags) DECLSPEC_HIDDEN
Definition: run.c:296
ME_Style * ME_MakeStyle(CHARFORMAT2W *style) DECLSPEC_HIDDEN
Definition: style.c:121
ME_String * ME_MakeStringN(LPCWSTR szText, int nMaxChars) DECLSPEC_HIDDEN
Definition: string.c:75
#define ITextHost_TxGetCharFormat(This, a)
Definition: editor.h:310
LCID WINAPI GetSystemDefaultLCID(void)
Definition: lang.c:797
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static ME_DisplayItem * make_para(ME_TextEditor *editor)
Definition: para.c:37
#define CFM_SMALLCAPS
Definition: richedit.h:338
#define CFE_STRIKEOUT
Definition: richedit.h:409
#define CFM_SHADOW
Definition: richedit.h:342
#define CFM_IMPRINT
Definition: richedit.h:344
#define CFE_ITALIC
Definition: richedit.h:407
#define CFM_OUTLINE
Definition: richedit.h:341
#define CFM_EMBOSS
Definition: richedit.h:343
#define CFM_SUBSCRIPT
Definition: richedit.h:348
#define CFM_DISABLED
Definition: richedit.h:345
#define CFM_REVISED
Definition: richedit.h:346
#define CFE_AUTOBACKCOLOR
Definition: richedit.h:425
#define CFM_ALLCAPS
Definition: richedit.h:339

Referenced by ME_MakeEditor().

◆ ME_MakeRun()

ME_DisplayItem * ME_MakeRun ( ME_Style s,
int  nFlags 
)

Definition at line 296 of file run.c.

297{
299 item->member.run.style = s;
300 item->member.run.reobj = NULL;
301 item->member.run.nFlags = nFlags;
302 item->member.run.nCharOfs = -1;
303 item->member.run.len = 0;
304 item->member.run.para = NULL;
305 item->member.run.num_glyphs = 0;
306 item->member.run.max_glyphs = 0;
307 item->member.run.glyphs = NULL;
308 item->member.run.vis_attrs = NULL;
309 item->member.run.advances = NULL;
310 item->member.run.offsets = NULL;
311 item->member.run.max_clusters = 0;
312 item->member.run.clusters = NULL;
314 return item;
315}
ME_DisplayItem * ME_MakeDI(ME_DIType type) DECLSPEC_HIDDEN
Definition: list.c:178

Referenced by ME_InsertRunAtCursor(), ME_MakeFirstParagraph(), ME_SplitParagraph(), and ME_SplitRunSimple().

◆ ME_MakeStringConst()

ME_String * ME_MakeStringConst ( const WCHAR str,
int  len 
)

Definition at line 41 of file string.c.

42{
44 if (!s) return NULL;
45
46 s->szData = (WCHAR *)str;
47 s->nLen = len;
48 s->nBuffer = 0;
49 return s;
50}
static ME_String * make_string(void(*free)(ME_String *))
Definition: string.c:30

Referenced by para_num_init().

◆ ME_MakeStringEmpty()

ME_String * ME_MakeStringEmpty ( int  len)

Definition at line 58 of file string.c.

59{
61
62 if (!s) return NULL;
63 s->nLen = nMaxChars;
64 s->nBuffer = ME_GetOptimalBuffer(s->nLen + 1);
65 s->szData = heap_alloc( s->nBuffer * sizeof(WCHAR) );
66 if (!s->szData)
67 {
68 heap_free( s );
69 return NULL;
70 }
71 s->szData[s->nLen] = 0;
72 return s;
73}
static void heap_string_free(ME_String *s)
Definition: string.c:52

Referenced by ME_MakeStringN(), ME_MakeStringR(), and para_num_get_str().

◆ ME_MakeStringN()

ME_String * ME_MakeStringN ( LPCWSTR  szText,
int  nMaxChars 
)

Definition at line 75 of file string.c.

76{
77 ME_String *s = ME_MakeStringEmpty(nMaxChars);
78
79 if (!s) return NULL;
80 memcpy(s->szData, szText, s->nLen * sizeof(WCHAR));
81 return s;
82}
ME_String * ME_MakeStringEmpty(int nMaxChars)
Definition: string.c:58

Referenced by ME_MakeFirstParagraph(), and ME_VSplitString().

◆ ME_MakeStringR()

ME_String * ME_MakeStringR ( WCHAR  cRepeat,
int  nMaxChars 
)

Definition at line 85 of file string.c.

86{
87 int i;
88 ME_String *s = ME_MakeStringEmpty(nMaxChars);
89
90 if (!s) return NULL;
91 for (i = 0; i < nMaxChars; i++)
92 s->szData[i] = cRepeat;
93 return s;
94}

Referenced by draw_text(), ME_CharFromPointContext(), ME_GetRunSizeCommon(), and ME_PointFromCharContext().

◆ ME_MakeStyle()

ME_Style * ME_MakeStyle ( CHARFORMAT2W style)

Definition at line 121 of file style.c.

122{
123 ME_Style *s = heap_alloc(sizeof(*s));
124
125 assert(style->cbSize == sizeof(CHARFORMAT2W));
126 s->fmt = *style;
127 s->nRefs = 1;
128 s->font_cache = NULL;
129 memset(&s->tm, 0, sizeof(s->tm));
130 s->tm.tmAscent = -1;
131 s->script_cache = NULL;
132 list_init(&s->entry);
133 all_refs++;
134 TRACE_(richedit_style)("ME_MakeStyle %p, total refs=%d\n", s, all_refs);
135 return s;
136}

Referenced by ME_ApplyStyle(), and ME_MakeFirstParagraph().

◆ ME_MakeTableDef()

struct RTFTable * ME_MakeTableDef ( ME_TextEditor editor)

Definition at line 637 of file table.c.

638{
639 RTFTable *tableDef = heap_alloc_zero(sizeof(*tableDef));
640
641 if (!editor->bEmulateVersion10) /* v4.1 */
642 tableDef->gapH = 10;
643 return tableDef;
644}
Definition: rtf.h:1026

Referenced by ME_RTFTblAttrHook().

◆ ME_MarkAllForWrapping()

void ME_MarkAllForWrapping ( ME_TextEditor editor)

Definition at line 236 of file para.c.

237{
238 ME_MarkForWrapping(editor, editor->pBuffer->pFirst->member.para.next_para, editor->pBuffer->pLast);
239}
static void ME_MarkForWrapping(ME_TextEditor *editor, ME_DisplayItem *first, const ME_DisplayItem *last)
Definition: para.c:227

Referenced by ME_HandleMessage(), ME_RewrapRepaint(), and ME_SetDefaultCharFormat().

◆ ME_MouseMove()

void ME_MouseMove ( ME_TextEditor editor,
int  x,
int  y 
)

Definition at line 1266 of file caret.c.

1267{
1268 ME_Cursor tmp_cursor;
1269
1270 if (editor->nSelectionType == stDocument)
1271 return;
1272 x += editor->horz_si.nPos;
1273 y += editor->vert_si.nPos;
1274
1275 tmp_cursor = editor->pCursors[0];
1276 /* FIXME: do something with the return value of ME_FindPixelPos */
1277 ME_FindPixelPos(editor, x, y, &tmp_cursor, &editor->bCaretAtEnd, TRUE);
1278
1279 ME_InvalidateSelection(editor);
1280 editor->pCursors[0] = tmp_cursor;
1282
1283 if (editor->nSelectionType != stPosition &&
1284 memcmp(&editor->pCursors[1], &editor->pCursors[3], sizeof(ME_Cursor)))
1285 {
1286 /* The scroll the cursor towards the other end, since it was the one
1287 * extended by ME_ExtendAnchorSelection */
1288 ME_EnsureVisible(editor, &editor->pCursors[1]);
1289 } else {
1290 ME_EnsureVisible(editor, &editor->pCursors[0]);
1291 }
1292
1293 ME_InvalidateSelection(editor);
1294 update_caret(editor);
1295 ME_SendSelChange(editor);
1296}

Referenced by ME_HandleMessage().

◆ ME_MoveCursorChars()

int ME_MoveCursorChars ( ME_TextEditor editor,
ME_Cursor cursor,
int  nRelOfs,
BOOL  final_eop 
)

Definition at line 720 of file caret.c.

721{
722 cursor->nOffset += nRelOfs;
723 if (cursor->nOffset < 0)
724 {
725 cursor->nOffset += cursor->pRun->member.run.nCharOfs;
726 if (cursor->nOffset >= 0)
727 {
728 /* new offset in the same paragraph */
729 do {
730 cursor->pRun = ME_FindItemBack(cursor->pRun, diRun);
731 } while (cursor->nOffset < cursor->pRun->member.run.nCharOfs);
732 cursor->nOffset -= cursor->pRun->member.run.nCharOfs;
733 return nRelOfs;
734 }
735
736 cursor->nOffset += cursor->pPara->member.para.nCharOfs;
737 if (cursor->nOffset <= 0)
738 {
739 /* moved to the start of the text */
740 nRelOfs -= cursor->nOffset;
742 return nRelOfs;
743 }
744
745 /* new offset in a previous paragraph */
746 do {
747 cursor->pPara = cursor->pPara->member.para.prev_para;
748 } while (cursor->nOffset < cursor->pPara->member.para.nCharOfs);
749 cursor->nOffset -= cursor->pPara->member.para.nCharOfs;
750
751 cursor->pRun = ME_FindItemBack(cursor->pPara->member.para.next_para, diRun);
752 while (cursor->nOffset < cursor->pRun->member.run.nCharOfs) {
753 cursor->pRun = ME_FindItemBack(cursor->pRun, diRun);
754 }
755 cursor->nOffset -= cursor->pRun->member.run.nCharOfs;
756 } else if (cursor->nOffset >= cursor->pRun->member.run.len) {
757 ME_DisplayItem *next_para;
758 int new_offset;
759
760 new_offset = ME_GetCursorOfs(cursor);
761 next_para = cursor->pPara->member.para.next_para;
762 if (new_offset < next_para->member.para.nCharOfs)
763 {
764 /* new offset in the same paragraph */
765 do {
766 cursor->nOffset -= cursor->pRun->member.run.len;
767 cursor->pRun = ME_FindItemFwd(cursor->pRun, diRun);
768 } while (cursor->nOffset >= cursor->pRun->member.run.len);
769 return nRelOfs;
770 }
771
772 if (new_offset >= ME_GetTextLength(editor) + (final_eop ? 1 : 0))
773 {
774 /* new offset at the end of the text */
775 ME_SetCursorToEnd(editor, cursor, final_eop);
776 nRelOfs -= new_offset - (ME_GetTextLength(editor) + (final_eop ? 1 : 0));
777 return nRelOfs;
778 }
779
780 /* new offset in a following paragraph */
781 do {
782 cursor->pPara = next_para;
783 next_para = next_para->member.para.next_para;
784 } while (new_offset >= next_para->member.para.nCharOfs);
785
786 cursor->nOffset = new_offset - cursor->pPara->member.para.nCharOfs;
787 cursor->pRun = ME_FindItemFwd(cursor->pPara, diRun);
788 while (cursor->nOffset >= cursor->pRun->member.run.len)
789 {
790 cursor->nOffset -= cursor->pRun->member.run.len;
791 cursor->pRun = ME_FindItemFwd(cursor->pRun, diRun);
792 }
793 } /* else new offset is in the same run */
794 return nRelOfs;
795}

Referenced by get_textfont_prop_for_pos(), ME_ArrowKey(), ME_FindText(), ME_PlayUndoItem(), ME_ProtectPartialTableDeletion(), ME_StreamIn(), ME_StreamOutRTF(), and set_selection_cursors().

◆ ME_MoveCursorFromTableRowStartParagraph()

void ME_MoveCursorFromTableRowStartParagraph ( ME_TextEditor editor)

Definition at line 622 of file table.c.

623{
624 ME_DisplayItem *para = editor->pCursors[0].pPara;
625 if (para == editor->pCursors[1].pPara &&
627 /* The cursors should not be at the hidden start row paragraph without
628 * a selection, so the cursor is moved into the first cell. */
629 para = para->member.para.next_para;
630 editor->pCursors[0].pPara = para;
631 editor->pCursors[0].pRun = ME_FindItemFwd(para, diRun);
632 editor->pCursors[0].nOffset = 0;
633 editor->pCursors[1] = editor->pCursors[0];
634 }
635}

Referenced by ME_KeyDown(), ME_Redo(), and ME_Undo().

◆ ME_MoveCursorWords()

BOOL ME_MoveCursorWords ( ME_TextEditor editor,
ME_Cursor cursor,
int  nRelOfs 
)

Definition at line 799 of file caret.c.

800{
801 ME_DisplayItem *pRun = cursor->pRun, *pOtherRun;
802 ME_DisplayItem *pPara = cursor->pPara;
803 int nOffset = cursor->nOffset;
804
805 if (nRelOfs == -1)
806 {
807 /* Backward movement */
808 while (TRUE)
809 {
810 nOffset = ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
811 pRun->member.run.len, nOffset, WB_MOVEWORDLEFT);
812 if (nOffset)
813 break;
814 pOtherRun = ME_FindItemBack(pRun, diRunOrParagraph);
815 if (pOtherRun->type == diRun)
816 {
817 if (ME_CallWordBreakProc(editor, get_text( &pOtherRun->member.run, 0 ),
818 pOtherRun->member.run.len,
819 pOtherRun->member.run.len - 1,
821 && !(pRun->member.run.nFlags & MERF_ENDPARA)
822 && !(cursor->pRun == pRun && cursor->nOffset == 0)
823 && !ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
824 pRun->member.run.len, 0,
826 break;
827 pRun = pOtherRun;
828 nOffset = pOtherRun->member.run.len;
829 }
830 else if (pOtherRun->type == diParagraph)
831 {
832 if (cursor->pRun == pRun && cursor->nOffset == 0)
833 {
834 pPara = pOtherRun;
835 /* Skip empty start of table row paragraph */
836 if (pPara->member.para.prev_para->member.para.nFlags & MEPF_ROWSTART)
837 pPara = pPara->member.para.prev_para;
838 /* Paragraph breaks are treated as separate words */
839 if (pPara->member.para.prev_para->type == diTextStart)
840 return FALSE;
841
842 pRun = ME_FindItemBack(pPara, diRun);
843 pPara = pPara->member.para.prev_para;
844 }
845 break;
846 }
847 }
848 }
849 else
850 {
851 /* Forward movement */
852 BOOL last_delim = FALSE;
853
854 while (TRUE)
855 {
856 if (last_delim && !ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
857 pRun->member.run.len, nOffset, WB_ISDELIMITER))
858 break;
859 nOffset = ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
860 pRun->member.run.len, nOffset, WB_MOVEWORDRIGHT);
861 if (nOffset < pRun->member.run.len)
862 break;
863 pOtherRun = ME_FindItemFwd(pRun, diRunOrParagraphOrEnd);
864 if (pOtherRun->type == diRun)
865 {
866 last_delim = ME_CallWordBreakProc(editor, get_text( &pRun->member.run, 0 ),
867 pRun->member.run.len, nOffset - 1, WB_ISDELIMITER);
868 pRun = pOtherRun;
869 nOffset = 0;
870 }
871 else if (pOtherRun->type == diParagraph)
872 {
873 if (pOtherRun->member.para.nFlags & MEPF_ROWSTART)
874 pOtherRun = pOtherRun->member.para.next_para;
875 if (cursor->pRun == pRun) {
876 pPara = pOtherRun;
877 pRun = ME_FindItemFwd(pPara, diRun);
878 }
879 nOffset = 0;
880 break;
881 }
882 else /* diTextEnd */
883 {
884 if (cursor->pRun == pRun)
885 return FALSE;
886 nOffset = 0;
887 break;
888 }
889 }
890 }
891 cursor->pPara = pPara;
892 cursor->pRun = pRun;
893 cursor->nOffset = nOffset;
894 return TRUE;
895}
int ME_CallWordBreakProc(ME_TextEditor *editor, WCHAR *str, INT len, INT start, INT code) DECLSPEC_HIDDEN
Definition: string.c:204
#define WB_MOVEWORDRIGHT
Definition: richedit.h:1002
#define WB_MOVEWORDLEFT
Definition: richedit.h:1000
#define WB_ISDELIMITER
Definition: winuser.h:549

Referenced by handle_EM_SETCHARFORMAT(), ME_ArrowKey(), ME_ExtendAnchorSelection(), and ME_SelectByType().

◆ ME_NextRun()

BOOL ME_NextRun ( ME_DisplayItem **  para,
ME_DisplayItem **  run,
BOOL  all_para 
)

Definition at line 71 of file list.c.

72{
73 ME_DisplayItem *p = (*run)->next;
74 while (p->type != diTextEnd)
75 {
76 if (p->type == diParagraph) {
77 if (!all_para) return FALSE;
78 *para = p;
79 } else if (p->type == diRun) {
80 *run = p;
81 return TRUE;
82 }
83 p = p->next;
84 }
85 return FALSE;
86}

Referenced by ME_FindNextURLCandidate(), ME_FindText(), ME_LinkNotify(), and ME_StreamOutRTF().

◆ ME_PaintContent()

void ME_PaintContent ( ME_TextEditor editor,
HDC  hDC,
const RECT rcUpdate 
)

Definition at line 28 of file paint.c.

29{
32 int ys, ye;
33 HRGN oldRgn;
34
35 oldRgn = CreateRectRgn(0, 0, 0, 0);
36 if (!GetClipRgn(hDC, oldRgn))
37 {
38 DeleteObject(oldRgn);
39 oldRgn = NULL;
40 }
41 IntersectClipRect(hDC, rcUpdate->left, rcUpdate->top,
42 rcUpdate->right, rcUpdate->bottom);
43
44 ME_InitContext(&c, editor, hDC);
46
47 item = editor->pBuffer->pFirst->next;
48 /* This context point is an offset for the paragraph positions stored
49 * during wrapping. It shouldn't be modified during painting. */
50 c.pt.x = c.rcView.left - editor->horz_si.nPos;
51 c.pt.y = c.rcView.top - editor->vert_si.nPos;
52 while(item != editor->pBuffer->pLast)
53 {
54 assert(item->type == diParagraph);
55
56 ys = c.pt.y + item->member.para.pt.y;
57 if (item->member.para.pCell
58 != item->member.para.next_para->member.para.pCell)
59 {
60 ME_Cell *cell = NULL;
61 cell = &ME_FindItemBack(item->member.para.next_para, diCell)->member.cell;
62 ye = c.pt.y + cell->pt.y + cell->nHeight;
63 } else {
64 ye = ys + item->member.para.nHeight;
65 }
66 if (item->member.para.pCell && !(item->member.para.nFlags & MEPF_ROWEND) &&
67 item->member.para.pCell != item->member.para.prev_para->member.para.pCell)
68 {
69 /* the border shifts the text down */
70 ys -= item->member.para.pCell->member.cell.yTextOffset;
71 }
72
73 /* Draw the paragraph if any of the paragraph is in the update region. */
74 if (ys < rcUpdate->bottom && ye > rcUpdate->top)
76 item = item->member.para.next_para;
77 }
78 if (c.pt.y + editor->nTotalLength < c.rcView.bottom)
79 {
80 /* Fill space after the end of the text. */
81 RECT rc;
82 rc.top = c.pt.y + editor->nTotalLength;
83 rc.left = c.rcView.left;
84 rc.bottom = c.rcView.bottom;
85 rc.right = c.rcView.right;
86
87 IntersectRect(&rc, &rc, rcUpdate);
88
89 if (!IsRectEmpty(&rc))
90 PatBlt(hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
91 }
92 if (editor->nTotalLength != editor->nLastTotalLength ||
93 editor->nTotalWidth != editor->nLastTotalWidth)
95 editor->nLastTotalLength = editor->nTotalLength;
96 editor->nLastTotalWidth = editor->nTotalWidth;
97
98 SelectClipRgn(hDC, oldRgn);
99 if (oldRgn)
100 DeleteObject(oldRgn);
101
102 c.hDC = NULL;
104}
static void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph)
Definition: paint.c:915
GLint GLint bottom
Definition: glext.h:7726
POINT pt
Definition: editstr.h:226
int nHeight
Definition: editstr.h:227
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
#define TRANSPARENT
Definition: wingdi.h:950
#define PATCOPY
Definition: wingdi.h:335
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)

Referenced by RichEditWndProc_common().

◆ ME_PointFromChar()

int ME_PointFromChar ( ME_TextEditor editor,
ME_Run pRun,
int  nOffset,
BOOL  visual_order 
)

Definition at line 598 of file run.c.

599{
601 int ret;
602
603 ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
604 ret = ME_PointFromCharContext( &c, pRun, nOffset, visual_order );
606
607 return ret;
608}
int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visual_order)
Definition: run.c:557

Referenced by ME_EnsureVisible(), ME_GetXForArrow(), and ME_HandleMessage().

◆ ME_PointFromCharContext()

int ME_PointFromCharContext ( ME_Context c,
ME_Run pRun,
int  nOffset,
BOOL  visual_order 
)

Definition at line 557 of file run.c.

558{
559 SIZE size;
560 ME_String *mask_text = NULL;
561 WCHAR *str;
562
563 if (pRun->nFlags & MERF_GRAPHICS)
564 {
565 if (nOffset)
566 ME_GetOLEObjectSize(c, pRun, &size);
567 return nOffset != 0;
568 } else if (pRun->nFlags & MERF_ENDPARA) {
569 nOffset = 0;
570 }
571
572 if (pRun->para->nFlags & MEPF_COMPLEX)
573 {
574 int x;
575 ScriptCPtoX( nOffset, FALSE, pRun->len, pRun->num_glyphs, pRun->clusters,
576 pRun->vis_attrs, pRun->advances, &pRun->script_analysis, &x );
577 if (visual_order && pRun->script_analysis.fRTL) x = pRun->nWidth - x - 1;
578 return x;
579 }
580 if (c->editor->cPasswordMask)
581 {
582 mask_text = ME_MakeStringR(c->editor->cPasswordMask, pRun->len);
583 str = mask_text->szData;
584 }
585 else
586 str = get_text( pRun, 0 );
587
588 ME_GetTextExtent(c, str, nOffset, pRun->style, &size);
589 ME_DestroyString( mask_text );
590 return size.cx;
591}
HRESULT WINAPI ScriptCPtoX(int iCP, BOOL fTrailing, int cChars, int cGlyphs, const WORD *pwLogClust, const SCRIPT_VISATTR *psva, const int *piAdvance, const SCRIPT_ANALYSIS *psa, int *piX)
Definition: usp10.c:2650

Referenced by get_selection_rect(), ME_GetCursorCoordinates(), ME_InsertRowStart(), and ME_PointFromChar().

◆ ME_PrevRun()

BOOL ME_PrevRun ( ME_DisplayItem **  para,
ME_DisplayItem **  run,
BOOL  all_para 
)

Definition at line 93 of file list.c.

94{
95 ME_DisplayItem *p = (*run)->prev;
96 while (p->type != diTextStart)
97 {
98 if (p->type == diParagraph) {
99 if (!all_para) return FALSE;
100 if (para && p->member.para.prev_para->type == diParagraph)
101 *para = p->member.para.prev_para;
102 } else if (p->type == diRun) {
103 *run = p;
104 return TRUE;
105 }
106 p = p->prev;
107 }
108 return FALSE;
109}

Referenced by ME_FindText(), ME_InsertOLEFromCursor(), ME_InternalDeleteText(), ME_JoinParagraphs(), ME_LinkNotify(), and ME_MoveCursorLines().

◆ ME_PropagateCharOffset()

void ME_PropagateCharOffset ( ME_DisplayItem p,
int  shift 
)

Definition at line 59 of file run.c.

60{
61 /* Runs in one paragraph contain character offset relative to their owning
62 * paragraph. If we start the shifting from the run, we need to shift
63 * all the relative offsets until the end of the paragraph
64 */
65 if (p->type == diRun) /* propagate in all runs in this para */
66 {
67 TRACE("PropagateCharOffset(%s, %d)\n", debugstr_run( &p->member.run ), shift);
68 do {
69 p->member.run.nCharOfs += shift;
70 assert(p->member.run.nCharOfs >= 0);
72 } while(p->type == diRun);
73 }
74 /* Runs in next paragraphs don't need their offsets updated, because they,
75 * again, those offsets are relative to their respective paragraphs.
76 * Instead of that, we're updating paragraphs' character offsets.
77 */
78 if (p->type == diParagraph) /* propagate in all next paras */
79 {
80 do {
81 p->member.para.nCharOfs += shift;
82 assert(p->member.para.nCharOfs >= 0);
83 p = p->member.para.next_para;
84 } while(p->type == diParagraph);
85 }
86 /* diTextEnd also has character offset in it, which makes finding text length
87 * easier. But it needs to be up to date first.
88 */
89 if (p->type == diTextEnd)
90 {
91 p->member.para.nCharOfs += shift;
92 assert(p->member.para.nCharOfs >= 0);
93 }
94}

Referenced by ME_InsertRunAtCursor(), ME_InternalDeleteText(), ME_JoinParagraphs(), ME_SkipAndPropagateCharOffset(), and ME_SplitParagraph().

◆ ME_ProtectPartialTableDeletion()

void ME_ProtectPartialTableDeletion ( ME_TextEditor editor,
ME_Cursor c,
int nChars 
)

Definition at line 287 of file table.c.

288{
289 int nOfs = ME_GetCursorOfs(c);
290 ME_Cursor c2 = *c;
291 ME_DisplayItem *this_para = c->pPara;
292 ME_DisplayItem *end_para;
293
294 ME_MoveCursorChars(editor, &c2, *nChars, FALSE);
295 end_para = c2.pPara;
296 if (c2.pRun->member.run.nFlags & MERF_ENDPARA) {
297 /* End offset might be in the middle of the end paragraph run.
298 * If this is the case, then we need to use the next paragraph as the last
299 * paragraphs.
300 */
301 int remaining = nOfs + *nChars - c2.pRun->member.run.nCharOfs
302 - end_para->member.para.nCharOfs;
303 if (remaining)
304 {
305 assert(remaining < c2.pRun->member.run.len);
306 end_para = end_para->member.para.next_para;
307 }
308 }
309 if (!editor->bEmulateVersion10) { /* v4.1 */
310 if (this_para->member.para.pCell != end_para->member.para.pCell ||
311 ((this_para->member.para.nFlags|end_para->member.para.nFlags)
313 {
314 while (this_para != end_para)
315 {
316 ME_DisplayItem *next_para = this_para->member.para.next_para;
317 BOOL bTruancateDeletion = FALSE;
318 if (this_para->member.para.nFlags & MEPF_ROWSTART) {
319 /* The following while loop assumes that next_para is MEPF_ROWSTART,
320 * so moving back one paragraph let's it be processed as the start
321 * of the row. */
322 next_para = this_para;
323 this_para = this_para->member.para.prev_para;
324 } else if (next_para->member.para.pCell != this_para->member.para.pCell
325 || this_para->member.para.nFlags & MEPF_ROWEND)
326 {
327 /* Start of the deletion from after the start of the table row. */
328 bTruancateDeletion = TRUE;
329 }
330 while (!bTruancateDeletion &&
331 next_para->member.para.nFlags & MEPF_ROWSTART)
332 {
333 next_para = ME_GetTableRowEnd(next_para)->member.para.next_para;
334 if (next_para->member.para.nCharOfs > nOfs + *nChars)
335 {
336 /* End of deletion is not past the end of the table row. */
337 next_para = this_para->member.para.next_para;
338 /* Delete the end paragraph preceding the table row if the
339 * preceding table row will be empty. */
340 if (this_para->member.para.nCharOfs >= nOfs)
341 {
342 next_para = next_para->member.para.next_para;
343 }
344 bTruancateDeletion = TRUE;
345 } else {
346 this_para = next_para->member.para.prev_para;
347 }
348 }
349 if (bTruancateDeletion)
350 {
351 ME_Run *end_run = &ME_FindItemBack(next_para, diRun)->member.run;
352 int nCharsNew = (next_para->member.para.nCharOfs - nOfs
353 - end_run->len);
354 nCharsNew = max(nCharsNew, 0);
355 assert(nCharsNew <= *nChars);
356 *nChars = nCharsNew;
357 break;
358 }
359 this_para = next_para;
360 }
361 }
362 } else { /* v1.0 - 3.0 */
363 ME_DisplayItem *pRun;
364 int nCharsToBoundary;
365
366 if ((this_para->member.para.nCharOfs != nOfs || this_para == end_para) &&
367 this_para->member.para.fmt.dwMask & PFM_TABLE &&
368 this_para->member.para.fmt.wEffects & PFE_TABLE)
369 {
370 pRun = c->pRun;
371 /* Find the next tab or end paragraph to use as a delete boundary */
372 while (!(pRun->member.run.nFlags & (MERF_TAB|MERF_ENDPARA)))
373 pRun = ME_FindItemFwd(pRun, diRun);
374 nCharsToBoundary = pRun->member.run.nCharOfs
375 - c->pRun->member.run.nCharOfs
376 - c->nOffset;
377 *nChars = min(*nChars, nCharsToBoundary);
378 } else if (end_para->member.para.fmt.dwMask & PFM_TABLE &&
379 end_para->member.para.fmt.wEffects & PFE_TABLE)
380 {
381 /* The deletion starts from before the row, so don't join it with
382 * previous non-empty paragraphs. */
383 ME_DisplayItem *curPara;
384 pRun = NULL;
385 if (nOfs > this_para->member.para.nCharOfs) {
386 pRun = ME_FindItemBack(end_para, diRun);
387 curPara = end_para->member.para.prev_para;
388 }
389 if (!pRun) {
390 pRun = ME_FindItemFwd(end_para, diRun);
391 curPara = end_para;
392 }
393 if (pRun)
394 {
395 nCharsToBoundary = curPara->member.para.nCharOfs
396 + pRun->member.run.nCharOfs
397 - nOfs;
398 if (nCharsToBoundary >= 0)
399 *nChars = min(*nChars, nCharsToBoundary);
400 }
401 }
402 if (*nChars < 0)
403 *nChars = 0;
404 }
405}

Referenced by ME_InternalDeleteText().

◆ ME_Redo()

BOOL ME_Redo ( ME_TextEditor editor)

Definition at line 453 of file undo.c.

454{
455 ME_UndoMode nMode = editor->nUndoMode;
456 struct list *head;
457 struct undo_item *undo, *cursor2;
458
459 assert(nMode == umAddToUndo || nMode == umIgnore);
460
461 if (editor->nUndoMode == umIgnore) return FALSE;
462
463 head = list_head( &editor->redo_stack );
464 if (!head) return FALSE;
465
466 /* watch out for uncommitted transactions ! */
467 undo = LIST_ENTRY( head, struct undo_item, entry );
468 assert( undo->type == undo_end_transaction );
469
470 editor->nUndoMode = umAddBackToUndo;
471 list_remove( &undo->entry );
472 destroy_undo_item( undo );
473
474 LIST_FOR_EACH_ENTRY_SAFE( undo, cursor2, &editor->redo_stack, struct undo_item, entry )
475 {
476 if (undo->type == undo_end_transaction) break;
477 ME_PlayUndoItem( editor, undo );
478 list_remove( &undo->entry );
479 destroy_undo_item( undo );
480 }
484 editor->nUndoMode = nMode;
485 ME_UpdateRepaint(editor, FALSE);
486 return TRUE;
487}
void ME_MoveCursorFromTableRowStartParagraph(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: table.c:622
void ME_CheckTablesForCorruption(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: table.c:192
ME_UndoMode
Definition: editstr.h:280
@ umAddBackToUndo
Definition: editstr.h:284
struct list entry
Definition: editstr.h:343
enum undo_type type
Definition: editstr.h:344
static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
Definition: undo.c:323

Referenced by ME_HandleMessage(), and ME_KeyDown().

◆ ME_ReleaseStyle()

void ME_ReleaseStyle ( ME_Style item)

Definition at line 462 of file style.c.

463{
464 s->nRefs--;
465 all_refs--;
466 if (s->nRefs==0)
467 TRACE_(richedit_style)("destroy style %p, total refs=%d\n", s, all_refs);
468 else
469 TRACE_(richedit_style)("release style %p, new refs=%d, total refs=%d\n", s, s->nRefs, all_refs);
470 if (!all_refs) TRACE("all style references freed (good!)\n");
471 assert(s->nRefs>=0);
472 if (!s->nRefs)
474}
void ME_DestroyStyle(ME_Style *s)
Definition: style.c:442

Referenced by destroy_undo_item(), handle_enter(), ITextRange_fnSetText(), ME_Char(), ME_ClearTempStyle(), ME_DestroyDisplayItem(), ME_DestroyEditor(), ME_HandleMessage(), ME_InsertEndParaFromCursor(), ME_InsertEndRowFromCursor(), ME_InsertOLEFromCursor(), ME_ReplaceSel(), ME_RTFCharAttrHook(), ME_RTFReadHook(), ME_SaveTempStyle(), ME_SetCharFormat(), ME_SetDefaultCharFormat(), ME_SetSelectionCharFormat(), ME_StreamIn(), and para_num_clear().

◆ ME_Remove()

void ME_Remove ( ME_DisplayItem diWhere)

Definition at line 35 of file list.c.

36{
37 ME_DisplayItem *diNext = diWhere->next;
38 ME_DisplayItem *diPrev = diWhere->prev;
39 assert(diNext);
40 assert(diPrev);
41 diPrev->next = diNext;
42 diNext->prev = diPrev;
43}

Referenced by ME_InternalDeleteText(), ME_JoinParagraphs(), ME_JoinRuns(), and ME_PrepareParagraphForWrapping().

◆ ME_Repaint()

void ME_Repaint ( ME_TextEditor editor)

Definition at line 106 of file paint.c.

107{
108 if (ME_WrapMarkedParagraphs(editor))
109 {
110 ME_UpdateScrollBar(editor);
111 FIXME("ME_Repaint had to call ME_WrapMarkedParagraphs\n");
112 }
114}
void ME_UpdateScrollBar(ME_TextEditor *editor)
Definition: paint.c:1148
#define ITextHost_TxViewChange(This, a)
Definition: editor.h:294

Referenced by ME_ArrowKey(), ME_HandleMessage(), ME_RewrapRepaint(), ME_ScrollAbs(), and ME_TabPressedInTable().

◆ ME_ReplaceSel()

void ME_ReplaceSel ( ME_TextEditor editor,
BOOL  can_undo,
const WCHAR str,
int  len 
)

Definition at line 3463 of file editor.c.

3464{
3465 int from, to, nStartCursor;
3466 ME_Style *style;
3467
3468 nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
3470 ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to-from, FALSE);
3471 ME_InsertTextFromCursor(editor, 0, str, len, style);
3473 /* drop temporary style if line end */
3474 /*
3475 * FIXME question: does abc\n mean: put abc,
3476 * clear temp style, put \n? (would require a change)
3477 */
3478 if (len>0 && str[len-1] == '\n')
3479 ME_ClearTempStyle(editor);
3480 ME_CommitUndo(editor);
3482 if (!can_undo)
3483 ME_EmptyUndoStack(editor);
3484 ME_UpdateRepaint(editor, FALSE);
3485}

Referenced by ITextSelection_fnSetText(), and ME_HandleMessage().

◆ ME_ReverseFindNonWhitespaceV()

int ME_ReverseFindNonWhitespaceV ( const ME_String s,
int  nVChar 
)

◆ ME_ReverseFindWhitespaceV()

int ME_ReverseFindWhitespaceV ( const ME_String s,
int  nVChar 
)

◆ ME_RewrapRepaint()

void ME_RewrapRepaint ( ME_TextEditor editor)

Definition at line 142 of file paint.c.

143{
144 /* RewrapRepaint should be called whenever the control has changed in
145 * looks, but not content. Like resizing. */
146
147 ME_MarkAllForWrapping(editor);
149 ME_UpdateScrollBar(editor);
150 ME_Repaint(editor);
151}
void ME_Repaint(ME_TextEditor *editor)
Definition: paint.c:106

Referenced by ME_HandleMessage(), and ME_SetZoom().

◆ ME_RowNumberFromCharOfs()

int ME_RowNumberFromCharOfs ( ME_TextEditor editor,
int  nOfs 
)

Definition at line 64 of file row.c.

65{
67 int nRow = 0;
68
69 while (item->type == diParagraph &&
70 item->member.para.next_para->member.para.nCharOfs <= nOfs)
71 {
72 nRow += item->member.para.nRows;
73 item = item->member.para.next_para;
74 }
75 if (item->type == diParagraph)
76 {
77 ME_DisplayItem *next_para = item->member.para.next_para;
78
79 nOfs -= item->member.para.nCharOfs;
82 {
83 if (item == next_para)
84 break;
86 if (item->member.run.nCharOfs > nOfs)
87 break;
88 nRow++;
89 }
90 }
91 return nRow;
92}

Referenced by ME_HandleMessage().

◆ ME_RowStart()

ME_DisplayItem * ME_RowStart ( ME_DisplayItem item)

Definition at line 31 of file row.c.

31 {
33}

Referenced by ME_HandleMessage().

◆ ME_RTFCharAttrHook()

void ME_RTFCharAttrHook ( struct _RTF_Info info)

Definition at line 425 of file editor.c.

426{
428 fmt.cbSize = sizeof(fmt);
429 fmt.dwMask = 0;
430 fmt.dwEffects = 0;
431
432 switch(info->rtfMinor)
433 {
434 case rtfPlain:
435 /* FIXME add more flags once they're implemented */
438 fmt.dwEffects = CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR;
439 fmt.yHeight = 12*20; /* 12pt */
440 fmt.wWeight = FW_NORMAL;
441 fmt.bUnderlineType = CFU_UNDERLINE;
442 break;
443 case rtfBold:
444 fmt.dwMask = CFM_BOLD | CFM_WEIGHT;
445 fmt.dwEffects = info->rtfParam ? CFE_BOLD : 0;
446 fmt.wWeight = info->rtfParam ? FW_BOLD : FW_NORMAL;
447 break;
448 case rtfItalic:
449 fmt.dwMask = CFM_ITALIC;
450 fmt.dwEffects = info->rtfParam ? fmt.dwMask : 0;
451 break;
452 case rtfUnderline:
454 fmt.bUnderlineType = CFU_UNDERLINE;
455 fmt.dwEffects = info->rtfParam ? CFE_UNDERLINE : 0;
456 break;
457 case rtfDotUnderline:
459 fmt.bUnderlineType = CFU_UNDERLINEDOTTED;
460 fmt.dwEffects = info->rtfParam ? CFE_UNDERLINE : 0;
461 break;
462 case rtfDbUnderline:
464 fmt.bUnderlineType = CFU_UNDERLINEDOUBLE;
465 fmt.dwEffects = info->rtfParam ? CFE_UNDERLINE : 0;
466 break;
467 case rtfWordUnderline:
469 fmt.bUnderlineType = CFU_UNDERLINEWORD;
470 fmt.dwEffects = info->rtfParam ? CFE_UNDERLINE : 0;
471 break;
472 case rtfNoUnderline:
473 fmt.dwMask = CFM_UNDERLINE;
474 fmt.dwEffects = 0;
475 break;
476 case rtfStrikeThru:
477 fmt.dwMask = CFM_STRIKEOUT;
478 fmt.dwEffects = info->rtfParam ? fmt.dwMask : 0;
479 break;
480 case rtfSubScript:
481 case rtfSuperScript:
482 case rtfSubScrShrink:
484 case rtfNoSuperSub:
486 if (info->rtfMinor == rtfSubScrShrink) fmt.dwEffects = CFE_SUBSCRIPT;
487 if (info->rtfMinor == rtfSuperScrShrink) fmt.dwEffects = CFE_SUPERSCRIPT;
488 if (info->rtfMinor == rtfNoSuperSub) fmt.dwEffects = 0;
489 break;
490 case rtfInvisible:
491 fmt.dwMask = CFM_HIDDEN;
492 fmt.dwEffects = info->rtfParam ? fmt.dwMask : 0;
493 break;
494 case rtfBackColor:
495 fmt.dwMask = CFM_BACKCOLOR;
496 fmt.dwEffects = 0;
497 if (info->rtfParam == 0)
498 fmt.dwEffects = CFE_AUTOBACKCOLOR;
499 else if (info->rtfParam != rtfNoParam)
500 {
501 RTFColor *c = RTFGetColor(info, info->rtfParam);
502 if (c && c->rtfCBlue >= 0)
503 fmt.crBackColor = (c->rtfCBlue<<16)|(c->rtfCGreen<<8)|(c->rtfCRed);
504 else
505 fmt.dwEffects = CFE_AUTOBACKCOLOR;
506 }
507 break;
508 case rtfForeColor:
509 fmt.dwMask = CFM_COLOR;
510 fmt.dwEffects = 0;
511 if (info->rtfParam == 0)
512 fmt.dwEffects = CFE_AUTOCOLOR;
513 else if (info->rtfParam != rtfNoParam)
514 {
515 RTFColor *c = RTFGetColor(info, info->rtfParam);
516 if (c && c->rtfCBlue >= 0)
517 fmt.crTextColor = (c->rtfCBlue<<16)|(c->rtfCGreen<<8)|(c->rtfCRed);
518 else {
519 fmt.dwEffects = CFE_AUTOCOLOR;
520 }
521 }
522 break;
523 case rtfFontNum:
524 if (info->rtfParam != rtfNoParam)
525 {
526 RTFFont *f = RTFGetFont(info, info->rtfParam);
527 if (f)
528 {
529 MultiByteToWideChar(CP_ACP, 0, f->rtfFName, -1, fmt.szFaceName, ARRAY_SIZE(fmt.szFaceName));
530 fmt.szFaceName[ARRAY_SIZE(fmt.szFaceName)-1] = '\0';
531 fmt.bCharSet = f->rtfFCharSet;
532 fmt.dwMask = CFM_FACE | CFM_CHARSET;
533 fmt.bPitchAndFamily = f->rtfFPitch | (f->rtfFFamily << 4);
534 }
535 }
536 break;
537 case rtfFontSize:
538 fmt.dwMask = CFM_SIZE;
539 if (info->rtfParam != rtfNoParam)
540 fmt.yHeight = info->rtfParam*10;
541 break;
542 }
543 if (fmt.dwMask) {
544 ME_Style *style2;
546 /* FIXME too slow ? how come ? */
547 style2 = ME_ApplyStyle(info->editor, info->style, &fmt);
548 ME_ReleaseStyle(info->style);
549 info->style = style2;
550 info->styleChanged = TRUE;
551 }
552}
RTFFont * RTFGetFont(const RTF_Info *info, int num)
Definition: reader.c:1222
void RTFFlushOutputBuffer(RTF_Info *info)
Definition: reader.c:2626
RTFColor * RTFGetColor(const RTF_Info *info, int num)
Definition: reader.c:1237
ME_Style * ME_ApplyStyle(ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style) DECLSPEC_HIDDEN
Definition: style.c:156
#define CFU_UNDERLINEDOUBLE
Definition: richedit.h:430
#define CFU_UNDERLINEWORD
Definition: richedit.h:429
#define CFE_SUPERSCRIPT
Definition: richedit.h:413
#define CFE_SUBSCRIPT
Definition: richedit.h:412
#define CFU_UNDERLINEDOTTED
Definition: richedit.h:431
#define rtfUnderline
Definition: rtf.h:583
#define rtfSuperScrShrink
Definition: rtf.h:589
#define rtfWordUnderline
Definition: rtf.h:587
#define rtfDbUnderline
Definition: rtf.h:585
#define rtfSubScrShrink
Definition: rtf.h:568
#define rtfSuperScript
Definition: rtf.h:588
#define rtfNoUnderline
Definition: rtf.h:586
#define rtfStrikeThru
Definition: rtf.h:582
#define rtfItalic
Definition: rtf.h:575
#define rtfPlain
Definition: rtf.h:563
#define rtfForeColor
Definition: rtf.h:591
#define rtfSubScript
Definition: rtf.h:567
#define rtfNoParam
Definition: rtf.h:62
#define rtfBold
Definition: rtf.h:564
#define rtfFontSize
Definition: rtf.h:574
#define rtfBackColor
Definition: rtf.h:592
#define rtfNoSuperSub
Definition: rtf.h:569
#define rtfInvisible
Definition: rtf.h:590
#define rtfFontNum
Definition: rtf.h:573
#define rtfDotUnderline
Definition: rtf.h:584
Definition: rtf.h:979
Definition: rtf.h:960

Referenced by ControlClass().

◆ ME_RTFParAttrHook()

void ME_RTFParAttrHook ( struct _RTF_Info info)

Definition at line 556 of file editor.c.

557{
558 switch(info->rtfMinor)
559 {
560 case rtfParDef: /* restores default paragraph attributes */
561 if (!info->editor->bEmulateVersion10) /* v4.1 */
562 info->borderType = RTFBorderParaLeft;
563 else /* v1.0 - 3.0 */
564 info->borderType = RTFBorderParaTop;
569 /* TODO: shading */
570 info->fmt.wAlignment = PFA_LEFT;
571 info->fmt.cTabCount = 0;
572 info->fmt.dxOffset = info->fmt.dxStartIndent = info->fmt.dxRightIndent = 0;
573 info->fmt.wBorderWidth = info->fmt.wBorders = 0;
574 info->fmt.wBorderSpace = 0;
575 info->fmt.bLineSpacingRule = 0;
576 info->fmt.dySpaceBefore = info->fmt.dySpaceAfter = 0;
577 info->fmt.dyLineSpacing = 0;
578 info->fmt.wEffects &= ~PFE_RTLPARA;
579 info->fmt.wNumbering = 0;
580 info->fmt.wNumberingStart = 0;
581 info->fmt.wNumberingStyle = 0;
582 info->fmt.wNumberingTab = 0;
583
584 if (!info->editor->bEmulateVersion10) /* v4.1 */
585 {
586 if (info->tableDef && info->tableDef->tableRowStart &&
587 info->tableDef->tableRowStart->member.para.nFlags & MEPF_ROWEND)
588 {
590 ME_DisplayItem *para;
591 /* We are just after a table row. */
593 cursor = info->editor->pCursors[0];
594 para = cursor.pPara;
595 if (para == info->tableDef->tableRowStart->member.para.next_para
596 && !cursor.nOffset && !cursor.pRun->member.run.nCharOfs)
597 {
598 /* Since the table row end, no text has been inserted, and the \intbl
599 * control word has not be used. We can confirm that we are not in a
600 * table anymore.
601 */
602 info->tableDef->tableRowStart = NULL;
603 info->canInheritInTbl = FALSE;
604 }
605 }
606 } else { /* v1.0 - v3.0 */
607 info->fmt.dwMask |= PFM_TABLE;
608 info->fmt.wEffects &= ~PFE_TABLE;
609 }
610 break;
611 case rtfNestLevel:
612 if (!info->editor->bEmulateVersion10) /* v4.1 */
613 {
614 while (info->rtfParam > info->nestingLevel) {
615 RTFTable *tableDef = heap_alloc_zero(sizeof(*tableDef));
616 tableDef->parent = info->tableDef;
617 info->tableDef = tableDef;
618
620 if (tableDef->tableRowStart &&
622 {
623 ME_DisplayItem *para = tableDef->tableRowStart;
624 para = para->member.para.next_para;
625 para = ME_InsertTableRowStartAtParagraph(info->editor, para);
626 tableDef->tableRowStart = para;
627 } else {
629 WCHAR endl = '\r';
630 cursor = info->editor->pCursors[0];
631 if (cursor.nOffset || cursor.pRun->member.run.nCharOfs)
632 ME_InsertTextFromCursor(info->editor, 0, &endl, 1, info->style);
634 }
635
636 info->nestingLevel++;
637 }
638 info->canInheritInTbl = FALSE;
639 }
640 break;
641 case rtfInTable:
642 {
643 if (!info->editor->bEmulateVersion10) /* v4.1 */
644 {
645 if (info->nestingLevel < 1)
646 {
647 RTFTable *tableDef;
648 if (!info->tableDef)
649 info->tableDef = heap_alloc_zero(sizeof(*info->tableDef));
650 tableDef = info->tableDef;
652 if (tableDef->tableRowStart &&
654 {
655 ME_DisplayItem *para = tableDef->tableRowStart;
656 para = para->member.para.next_para;
657 para = ME_InsertTableRowStartAtParagraph(info->editor, para);
658 tableDef->tableRowStart = para;
659 } else {
661 WCHAR endl = '\r';
662 cursor = info->editor->pCursors[0];
663 if (cursor.nOffset || cursor.pRun->member.run.nCharOfs)
664 ME_InsertTextFromCursor(info->editor, 0, &endl, 1, info->style);
666 }
667 info->nestingLevel = 1;
668 info->canInheritInTbl = TRUE;
669 }
670 return;
671 } else { /* v1.0 - v3.0 */
672 info->fmt.dwMask |= PFM_TABLE;
673 info->fmt.wEffects |= PFE_TABLE;
674 }
675 break;
676 }
677 case rtfFirstIndent:
678 case rtfLeftIndent:
679 if ((info->fmt.dwMask & (PFM_STARTINDENT | PFM_OFFSET)) != (PFM_STARTINDENT | PFM_OFFSET))
680 {
682 fmt.cbSize = sizeof(fmt);
684 info->fmt.dwMask |= PFM_STARTINDENT | PFM_OFFSET;
685 info->fmt.dxStartIndent = fmt.dxStartIndent;
686 info->fmt.dxOffset = fmt.dxOffset;
687 }
688 if (info->rtfMinor == rtfFirstIndent)
689 {
690 info->fmt.dxStartIndent += info->fmt.dxOffset + info->rtfParam;
691 info->fmt.dxOffset = -info->rtfParam;
692 }
693 else
694 info->fmt.dxStartIndent = info->rtfParam - info->fmt.dxOffset;
695 break;
696 case rtfRightIndent:
697 info->fmt.dwMask |= PFM_RIGHTINDENT;
698 info->fmt.dxRightIndent = info->rtfParam;
699 break;
700 case rtfQuadLeft:
701 case rtfQuadJust:
702 info->fmt.dwMask |= PFM_ALIGNMENT;
703 info->fmt.wAlignment = PFA_LEFT;
704 break;
705 case rtfQuadRight:
706 info->fmt.dwMask |= PFM_ALIGNMENT;
707 info->fmt.wAlignment = PFA_RIGHT;
708 break;
709 case rtfQuadCenter:
710 info->fmt.dwMask |= PFM_ALIGNMENT;
711 info->fmt.wAlignment = PFA_CENTER;
712 break;
713 case rtfTabPos:
714 if (!(info->fmt.dwMask & PFM_TABSTOPS))
715 {
717 fmt.cbSize = sizeof(fmt);
719 memcpy(info->fmt.rgxTabs, fmt.rgxTabs,
720 fmt.cTabCount * sizeof(fmt.rgxTabs[0]));
721 info->fmt.cTabCount = fmt.cTabCount;
722 info->fmt.dwMask |= PFM_TABSTOPS;
723 }
724 if (info->fmt.cTabCount < MAX_TAB_STOPS && info->rtfParam < 0x1000000)
725 info->fmt.rgxTabs[info->fmt.cTabCount++] = info->rtfParam;
726 break;
727 case rtfKeep:
728 info->fmt.dwMask |= PFM_KEEP;
729 info->fmt.wEffects |= PFE_KEEP;
730 break;
732 info->fmt.dwMask |= PFM_NOWIDOWCONTROL;
733 info->fmt.wEffects |= PFE_NOWIDOWCONTROL;
734 break;
735 case rtfKeepNext:
736 info->fmt.dwMask |= PFM_KEEPNEXT;
737 info->fmt.wEffects |= PFE_KEEPNEXT;
738 break;
739 case rtfSpaceAfter:
740 info->fmt.dwMask |= PFM_SPACEAFTER;
741 info->fmt.dySpaceAfter = info->rtfParam;
742 break;
743 case rtfSpaceBefore:
744 info->fmt.dwMask |= PFM_SPACEBEFORE;
745 info->fmt.dySpaceBefore = info->rtfParam;
746 break;
747 case rtfSpaceBetween:
748 info->fmt.dwMask |= PFM_LINESPACING;
749 if ((int)info->rtfParam > 0)
750 {
751 info->fmt.dyLineSpacing = info->rtfParam;
752 info->fmt.bLineSpacingRule = 3;
753 }
754 else
755 {
756 info->fmt.dyLineSpacing = info->rtfParam;
757 info->fmt.bLineSpacingRule = 4;
758 }
759 break;
760 case rtfSpaceMultiply:
761 info->fmt.dwMask |= PFM_LINESPACING;
762 info->fmt.dyLineSpacing = info->rtfParam * 20;
763 info->fmt.bLineSpacingRule = 5;
764 break;
765 case rtfParBullet:
766 info->fmt.dwMask |= PFM_NUMBERING;
767 info->fmt.wNumbering = PFN_BULLET;
768 break;
769 case rtfParSimple:
770 info->fmt.dwMask |= PFM_NUMBERING;
771 info->fmt.wNumbering = 2; /* FIXME: MSDN says it's not used ?? */
772 break;
773 case rtfBorderLeft:
774 info->borderType = RTFBorderParaLeft;
775 info->fmt.wBorders |= 1;
776 info->fmt.dwMask |= PFM_BORDER;
777 break;
778 case rtfBorderRight:
779 info->borderType = RTFBorderParaRight;
780 info->fmt.wBorders |= 2;
781 info->fmt.dwMask |= PFM_BORDER;
782 break;
783 case rtfBorderTop:
784 info->borderType = RTFBorderParaTop;
785 info->fmt.wBorders |= 4;
786 info->fmt.dwMask |= PFM_BORDER;
787 break;
788 case rtfBorderBottom:
789 info->borderType = RTFBorderParaBottom;
790 info->fmt.wBorders |= 8;
791 info->fmt.dwMask |= PFM_BORDER;
792 break;
793 case rtfBorderSingle:
794 info->fmt.wBorders &= ~0x700;
795 info->fmt.wBorders |= 1 << 8;
796 info->fmt.dwMask |= PFM_BORDER;
797 break;
798 case rtfBorderThick:
799 info->fmt.wBorders &= ~0x700;
800 info->fmt.wBorders |= 2 << 8;
801 info->fmt.dwMask |= PFM_BORDER;
802 break;
803 case rtfBorderShadow:
804 info->fmt.wBorders &= ~0x700;
805 info->fmt.wBorders |= 10 << 8;
806 info->fmt.dwMask |= PFM_BORDER;
807 break;
808 case rtfBorderDouble:
809 info->fmt.wBorders &= ~0x700;
810 info->fmt.wBorders |= 7 << 8;
811 info->fmt.dwMask |= PFM_BORDER;
812 break;
813 case rtfBorderDot:
814 info->fmt.wBorders &= ~0x700;
815 info->fmt.wBorders |= 11 << 8;
816 info->fmt.dwMask |= PFM_BORDER;
817 break;
818 case rtfBorderWidth:
819 {
820 int borderSide = info->borderType & RTFBorderSideMask;
821 RTFTable *tableDef = info->tableDef;
822 if ((info->borderType & RTFBorderTypeMask) == RTFBorderTypeCell)
823 {
825 if (!tableDef || tableDef->numCellsDefined >= MAX_TABLE_CELLS)
826 break;
827 border = &tableDef->cells[tableDef->numCellsDefined].border[borderSide];
828 border->width = info->rtfParam;
829 break;
830 }
831 info->fmt.wBorderWidth = info->rtfParam;
832 info->fmt.dwMask |= PFM_BORDER;
833 break;
834 }
835 case rtfBorderSpace:
836 info->fmt.wBorderSpace = info->rtfParam;
837 info->fmt.dwMask |= PFM_BORDER;
838 break;
839 case rtfBorderColor:
840 {
841 RTFTable *tableDef = info->tableDef;
842 int borderSide = info->borderType & RTFBorderSideMask;
843 int borderType = info->borderType & RTFBorderTypeMask;
844 switch(borderType)
845 {
847 if (!info->editor->bEmulateVersion10) /* v4.1 */
848 break;
849 /* v1.0 - 3.0 treat paragraph and row borders the same. */
850 case RTFBorderTypeRow:
851 if (tableDef) {
852 tableDef->border[borderSide].color = info->rtfParam;
853 }
854 break;
856 if (tableDef && tableDef->numCellsDefined < MAX_TABLE_CELLS) {
857 tableDef->cells[tableDef->numCellsDefined].border[borderSide].color = info->rtfParam;
858 }
859 break;
860 }
861 break;
862 }
863 case rtfRTLPar:
864 info->fmt.dwMask |= PFM_RTLPARA;
865 info->fmt.wEffects |= PFE_RTLPARA;
866 break;
867 case rtfLTRPar:
868 info->fmt.dwMask |= PFM_RTLPARA;
869 info->fmt.wEffects &= ~PFE_RTLPARA;
870 break;
871 }
872}
ME_DisplayItem * ME_InsertTableRowStartFromCursor(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: table.c:79
ME_DisplayItem * ME_InsertTableRowStartAtParagraph(ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN
Definition: table.c:86
#define MAX_TAB_STOPS
Definition: richedit.h:218
#define PFE_RTLPARA
Definition: richedit.h:932
#define PFE_KEEP
Definition: richedit.h:933
#define MAX_TABLE_CELLS
Definition: richedit.h:220
#define PFE_NOWIDOWCONTROL
Definition: richedit.h:937
#define PFN_BULLET
Definition: richedit.h:905
#define PFE_KEEPNEXT
Definition: richedit.h:934
#define rtfBorderWidth
Definition: rtf.h:542
#define rtfBorderDouble
Definition: rtf.h:538
#define rtfKeepNext
Definition: rtf.h:462
#define rtfQuadLeft
Definition: rtf.h:467
#define rtfQuadRight
Definition: rtf.h:468
#define RTFBorderTypeMask
Definition: rtf.h:1052
#define rtfBorderRight
Definition: rtf.h:531
#define rtfNoWidowControl
Definition: rtf.h:461
#define rtfLTRPar
Definition: rtf.h:480
#define rtfBorderShadow
Definition: rtf.h:537
#define rtfParBullet
Definition: rtf.h:493
#define rtfKeep
Definition: rtf.h:460
#define RTFBorderParaRight
Definition: rtf.h:1069
#define rtfBorderSingle
Definition: rtf.h:535
#define rtfQuadCenter
Definition: rtf.h:470
#define rtfBorderBottom
Definition: rtf.h:529
#define rtfBorderLeft
Definition: rtf.h:530
#define rtfQuadJust
Definition: rtf.h:469
#define rtfParDef
Definition: rtf.h:456
#define rtfBorderColor
Definition: rtf.h:543
#define rtfSpaceMultiply
Definition: rtf.h:477
#define RTFBorderSideMask
Definition: rtf.h:1063
#define RTFBorderParaTop
Definition: rtf.h:1066
#define rtfParSimple
Definition: rtf.h:494
#define rtfNestLevel
Definition: rtf.h:560
#define rtfRightIndent
Definition: rtf.h:473
#define rtfRTLPar
Definition: rtf.h:479
#define rtfSpaceBetween
Definition: rtf.h:476
#define RTFBorderParaBottom
Definition: rtf.h:1068
#define rtfSpaceBefore
Definition: rtf.h:474
#define rtfBorderTop
Definition: rtf.h:528
#define rtfInTable
Definition: rtf.h:459
#define RTFBorderTypePara
Definition: rtf.h:1049
#define RTFBorderTypeRow
Definition: rtf.h:1050
#define rtfBorderThick
Definition: rtf.h:536
#define RTFBorderTypeCell
Definition: rtf.h:1051
#define rtfFirstIndent
Definition: rtf.h:471
#define rtfBorderDot
Definition: rtf.h:539
#define rtfTabPos
Definition: rtf.h:481
#define rtfSpaceAfter
Definition: rtf.h:475
#define RTFBorderParaLeft
Definition: rtf.h:1067
#define rtfBorderSpace
Definition: rtf.h:544
#define rtfLeftIndent
Definition: rtf.h:472
int color
Definition: rtf.h:1015
int width
Definition: rtf.h:1014
RTFBorder border[4]
Definition: rtf.h:1021
ME_DisplayItem * tableRowStart
Definition: rtf.h:1041
RTFTable * parent
Definition: rtf.h:1044

Referenced by ControlClass().

◆ ME_RTFSpecialCharHook()

void ME_RTFSpecialCharHook ( struct _RTF_Info info)

Definition at line 948 of file editor.c.

949{
950 RTFTable *tableDef = info->tableDef;
951 switch (info->rtfMinor)
952 {
953 case rtfNestCell:
954 if (info->editor->bEmulateVersion10) /* v1.0 - v3.0 */
955 break;
956 /* else fall through since v4.1 treats rtfNestCell and rtfCell the same */
957 case rtfCell:
958 if (!tableDef)
959 break;
961 if (!info->editor->bEmulateVersion10) { /* v4.1 */
962 if (tableDef->tableRowStart)
963 {
964 if (!info->nestingLevel &&
966 {
967 ME_DisplayItem *para = tableDef->tableRowStart;
968 para = para->member.para.next_para;
969 para = ME_InsertTableRowStartAtParagraph(info->editor, para);
970 tableDef->tableRowStart = para;
971 info->nestingLevel = 1;
972 }
974 }
975 } else { /* v1.0 - v3.0 */
976 ME_DisplayItem *para = info->editor->pCursors[0].pPara;
977 PARAFORMAT2 *pFmt = &para->member.para.fmt;
978 if (pFmt->dwMask & PFM_TABLE && pFmt->wEffects & PFE_TABLE &&
979 tableDef->numCellsInserted < tableDef->numCellsDefined)
980 {
981 WCHAR tab = '\t';
982 ME_InsertTextFromCursor(info->editor, 0, &tab, 1, info->style);
983 tableDef->numCellsInserted++;
984 }
985 }
986 break;
987 case rtfNestRow:
988 if (info->editor->bEmulateVersion10) /* v1.0 - v3.0 */
989 break;
990 /* else fall through since v4.1 treats rtfNestRow and rtfRow the same */
991 case rtfRow:
992 {
993 ME_DisplayItem *para, *cell, *run;
994 int i;
995
996 if (!tableDef)
997 break;
999 if (!info->editor->bEmulateVersion10) { /* v4.1 */
1000 if (!tableDef->tableRowStart)
1001 break;
1002 if (!info->nestingLevel &&
1004 {
1005 para = tableDef->tableRowStart;
1006 para = para->member.para.next_para;
1007 para = ME_InsertTableRowStartAtParagraph(info->editor, para);
1008 tableDef->tableRowStart = para;
1009 info->nestingLevel++;
1010 }
1011 para = tableDef->tableRowStart;
1012 cell = ME_FindItemFwd(para, diCell);
1013 assert(cell && !cell->member.cell.prev_cell);
1014 if (tableDef->numCellsDefined < 1)
1015 {
1016 /* 2000 twips appears to be the cell size that native richedit uses
1017 * when no cell sizes are specified. */
1018 const int defaultCellSize = 2000;
1019 int nRightBoundary = defaultCellSize;
1020 cell->member.cell.nRightBoundary = nRightBoundary;
1021 while (cell->member.cell.next_cell) {
1022 cell = cell->member.cell.next_cell;
1023 nRightBoundary += defaultCellSize;
1024 cell->member.cell.nRightBoundary = nRightBoundary;
1025 }
1026 para = ME_InsertTableCellFromCursor(info->editor);
1027 cell = para->member.para.pCell;
1028 cell->member.cell.nRightBoundary = nRightBoundary;
1029 } else {
1030 for (i = 0; i < tableDef->numCellsDefined; i++)
1031 {
1032 RTFCell *cellDef = &tableDef->cells[i];
1033 cell->member.cell.nRightBoundary = cellDef->rightBoundary;
1035 cellDef->border);
1036 cell = cell->member.cell.next_cell;
1037 if (!cell)
1038 {
1039 para = ME_InsertTableCellFromCursor(info->editor);
1040 cell = para->member.para.pCell;
1041 }
1042 }
1043 /* Cell for table row delimiter is empty */
1044 cell->member.cell.nRightBoundary = tableDef->cells[i-1].rightBoundary;
1045 }
1046
1047 run = ME_FindItemFwd(cell, diRun);
1048 if (info->editor->pCursors[0].pRun != run ||
1049 info->editor->pCursors[0].nOffset)
1050 {
1051 int nOfs, nChars;
1052 /* Delete inserted cells that aren't defined. */
1053 info->editor->pCursors[1].pRun = run;
1054 info->editor->pCursors[1].pPara = ME_GetParagraph(run);
1055 info->editor->pCursors[1].nOffset = 0;
1056 nOfs = ME_GetCursorOfs(&info->editor->pCursors[1]);
1057 nChars = ME_GetCursorOfs(&info->editor->pCursors[0]) - nOfs;
1058 ME_InternalDeleteText(info->editor, &info->editor->pCursors[1],
1059 nChars, TRUE);
1060 }
1061
1062 para = ME_InsertTableRowEndFromCursor(info->editor);
1063 para->member.para.fmt.dxOffset = abs(info->tableDef->gapH);
1064 para->member.para.fmt.dxStartIndent = info->tableDef->leftEdge;
1066 tableDef->border);
1067 info->nestingLevel--;
1068 if (!info->nestingLevel)
1069 {
1070 if (info->canInheritInTbl) {
1071 tableDef->tableRowStart = para;
1072 } else {
1073 while (info->tableDef) {
1074 tableDef = info->tableDef;
1075 info->tableDef = tableDef->parent;
1076 heap_free(tableDef);
1077 }
1078 }
1079 } else {
1080 info->tableDef = tableDef->parent;
1081 heap_free(tableDef);
1082 }
1083 } else { /* v1.0 - v3.0 */
1084 WCHAR endl = '\r';
1085 ME_DisplayItem *para = info->editor->pCursors[0].pPara;
1086 PARAFORMAT2 *pFmt = &para->member.para.fmt;
1087 pFmt->dxOffset = info->tableDef->gapH;
1088 pFmt->dxStartIndent = info->tableDef->leftEdge;
1089
1091 tableDef->border);
1092 while (tableDef->numCellsInserted < tableDef->numCellsDefined)
1093 {
1094 WCHAR tab = '\t';
1095 ME_InsertTextFromCursor(info->editor, 0, &tab, 1, info->style);
1096 tableDef->numCellsInserted++;
1097 }
1098 pFmt->cTabCount = min(tableDef->numCellsDefined, MAX_TAB_STOPS);
1099 if (!tableDef->numCellsDefined)
1100 pFmt->wEffects &= ~PFE_TABLE;
1101 ME_InsertTextFromCursor(info->editor, 0, &endl, 1, info->style);
1102 tableDef->numCellsInserted = 0;
1103 }
1104 break;
1105 }
1106 case rtfTab:
1107 case rtfPar:
1108 if (info->editor->bEmulateVersion10) { /* v1.0 - 3.0 */
1109 ME_DisplayItem *para;
1110 PARAFORMAT2 *pFmt;
1112 para = info->editor->pCursors[0].pPara;
1113 pFmt = &para->member.para.fmt;
1114 if (pFmt->dwMask & PFM_TABLE && pFmt->wEffects & PFE_TABLE)
1115 {
1116 /* rtfPar is treated like a space within a table. */
1117 info->rtfClass = rtfText;
1118 info->rtfMajor = ' ';
1119 }
1120 else if (info->rtfMinor == rtfPar && tableDef)
1121 tableDef->numCellsInserted = 0;
1122 }
1123 break;
1124 }
1125}
static void ME_ApplyBorderProperties(RTF_Info *info, ME_BorderRect *borderRect, RTFBorder *borderDef)
Definition: editor.c:399
ME_DisplayItem * ME_InsertTableRowEndFromCursor(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: table.c:129
ME_DisplayItem * ME_InsertTableCellFromCursor(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: table.c:121
#define abs(i)
Definition: fconv.c:206
#define rtfPar
Definition: rtf.h:237
#define rtfCell
Definition: rtf.h:235
#define rtfText
Definition: rtf.h:80
#define rtfRow
Definition: rtf.h:236
#define rtfTab
Definition: rtf.h:246
#define rtfNestRow
Definition: rtf.h:269
#define rtfNestCell
Definition: rtf.h:268
Definition: rtf.h:1019
int rightBoundary
Definition: rtf.h:1020
int numCellsInserted
Definition: rtf.h:1035
LONG dxStartIndent
Definition: richedit.h:670

Referenced by ControlClass(), and ME_StreamIn().

◆ ME_RTFTblAttrHook()

void ME_RTFTblAttrHook ( struct _RTF_Info info)

Definition at line 874 of file editor.c.

875{
876 switch (info->rtfMinor)
877 {
878 case rtfRowDef:
879 {
880 if (!info->editor->bEmulateVersion10) /* v4.1 */
881 info->borderType = 0; /* Not sure */
882 else /* v1.0 - 3.0 */
883 info->borderType = RTFBorderRowTop;
884 if (!info->tableDef) {
885 info->tableDef = ME_MakeTableDef(info->editor);
886 } else {
887 ME_InitTableDef(info->editor, info->tableDef);
888 }
889 break;
890 }
891 case rtfCellPos:
892 {
893 int cellNum;
894 if (!info->tableDef)
895 {
896 info->tableDef = ME_MakeTableDef(info->editor);
897 }
898 cellNum = info->tableDef->numCellsDefined;
899 if (cellNum >= MAX_TABLE_CELLS)
900 break;
901 info->tableDef->cells[cellNum].rightBoundary = info->rtfParam;
902 if (cellNum < MAX_TAB_STOPS) {
903 /* Tab stops were used to store cell positions before v4.1 but v4.1
904 * still seems to set the tabstops without using them. */
905 ME_DisplayItem *para = info->editor->pCursors[0].pPara;
906 PARAFORMAT2 *pFmt = &para->member.para.fmt;
907 pFmt->rgxTabs[cellNum] &= ~0x00FFFFFF;
908 pFmt->rgxTabs[cellNum] |= 0x00FFFFFF & info->rtfParam;
909 }
910 info->tableDef->numCellsDefined++;
911 break;
912 }
913 case rtfRowBordTop:
914 info->borderType = RTFBorderRowTop;
915 break;
916 case rtfRowBordLeft:
917 info->borderType = RTFBorderRowLeft;
918 break;
919 case rtfRowBordBottom:
920 info->borderType = RTFBorderRowBottom;
921 break;
922 case rtfRowBordRight:
923 info->borderType = RTFBorderRowRight;
924 break;
925 case rtfCellBordTop:
926 info->borderType = RTFBorderCellTop;
927 break;
928 case rtfCellBordLeft:
929 info->borderType = RTFBorderCellLeft;
930 break;
932 info->borderType = RTFBorderCellBottom;
933 break;
934 case rtfCellBordRight:
935 info->borderType = RTFBorderCellRight;
936 break;
937 case rtfRowGapH:
938 if (info->tableDef)
939 info->tableDef->gapH = info->rtfParam;
940 break;
941 case rtfRowLeftEdge:
942 if (info->tableDef)
943 info->tableDef->leftEdge = info->rtfParam;
944 break;
945 }
946}
void ME_InitTableDef(ME_TextEditor *editor, struct RTFTable *tableDef) DECLSPEC_HIDDEN
Definition: table.c:646
struct RTFTable * ME_MakeTableDef(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: table.c:637
#define rtfRowGapH
Definition: rtf.h:416
#define RTFBorderRowTop
Definition: rtf.h:1070
#define rtfRowBordLeft
Definition: rtf.h:430
#define rtfRowBordTop
Definition: rtf.h:429
#define rtfCellBordBottom
Definition: rtf.h:435
#define RTFBorderCellTop
Definition: rtf.h:1076
#define rtfRowBordBottom
Definition: rtf.h:431
#define rtfRowDef
Definition: rtf.h:415
#define RTFBorderCellRight
Definition: rtf.h:1079
#define rtfRowLeftEdge
Definition: rtf.h:423
#define rtfCellBordRight
Definition: rtf.h:438
#define rtfCellBordLeft
Definition: rtf.h:437
#define RTFBorderCellLeft
Definition: rtf.h:1077
#define rtfCellPos
Definition: rtf.h:417
#define RTFBorderRowBottom
Definition: rtf.h:1072
#define RTFBorderRowLeft
Definition: rtf.h:1071
#define rtfCellBordTop
Definition: rtf.h:436
#define RTFBorderRowRight
Definition: rtf.h:1073
#define rtfRowBordRight
Definition: rtf.h:432
#define RTFBorderCellBottom
Definition: rtf.h:1078

Referenced by ControlClass().

◆ ME_RunOfsFromCharOfs()

void ME_RunOfsFromCharOfs ( ME_TextEditor editor,
int  nCharOfs,
ME_DisplayItem **  ppPara,
ME_DisplayItem **  ppRun,
int pOfs 
)

Definition at line 184 of file run.c.

189{
190 ME_DisplayItem *item, *next_item;
191 int endOfs = nCharOfs, len = ME_GetTextLength(editor);
192
193 nCharOfs = max(nCharOfs, 0);
194 nCharOfs = min(nCharOfs, len);
195
196 /* Find the paragraph at the offset. */
197 next_item = editor->pBuffer->pFirst->member.para.next_para;
198 do {
199 item = next_item;
200 next_item = item->member.para.next_para;
201 } while (next_item->member.para.nCharOfs <= nCharOfs);
202 assert(item->type == diParagraph);
203 nCharOfs -= item->member.para.nCharOfs;
204 if (ppPara) *ppPara = item;
205
206 /* Find the run at the offset. */
207 next_item = ME_FindItemFwd(item, diRun);
208 do {
209 item = next_item;
211 } while (next_item->type == diRun &&
212 next_item->member.run.nCharOfs <= nCharOfs);
213 assert(item->type == diRun);
214 nCharOfs -= item->member.run.nCharOfs;
215
216 if (ppRun) *ppRun = item;
217 if (pOfs) {
218 if (((*ppRun)->member.run.nFlags & MERF_ENDPARA) && endOfs > len)
219 *pOfs = (*ppRun)->member.run.len;
220 else *pOfs = nCharOfs;
221 }
222}

Referenced by ME_CursorFromCharOfs(), and ME_HandleMessage().

◆ ME_SaveTempStyle()

void ME_SaveTempStyle ( ME_TextEditor editor,
ME_Style style 
)

Definition at line 514 of file style.c.

515{
516 ME_Style *old_style = editor->pBuffer->pCharStyle;
517
518 if (style) ME_AddRefStyle( style );
519 editor->pBuffer->pCharStyle = style;
520 if (old_style) ME_ReleaseStyle( old_style );
521}

Referenced by handle_enter(), and ME_HandleMessage().

◆ ME_ScrollAbs()

void ME_ScrollAbs ( ME_TextEditor editor,
int  x,
int  y 
)

Definition at line 1043 of file paint.c.

1044{
1045 BOOL bScrollBarIsVisible, bScrollBarWillBeVisible;
1046 int scrollX = 0, scrollY = 0;
1047
1048 if (editor->horz_si.nPos != x) {
1049 x = min(x, editor->horz_si.nMax);
1050 x = max(x, editor->horz_si.nMin);
1051 scrollX = editor->horz_si.nPos - x;
1052 editor->horz_si.nPos = x;
1053 if (editor->horz_si.nMax > 0xFFFF) /* scale to 16-bit value */
1054 x = MulDiv(x, 0xFFFF, editor->horz_si.nMax);
1056 }
1057
1058 if (editor->vert_si.nPos != y) {
1059 y = min(y, editor->vert_si.nMax - (int)editor->vert_si.nPage);
1060 y = max(y, editor->vert_si.nMin);
1061 scrollY = editor->vert_si.nPos - y;
1062 editor->vert_si.nPos = y;
1063 if (editor->vert_si.nMax > 0xFFFF) /* scale to 16-bit value */
1064 y = MulDiv(y, 0xFFFF, editor->vert_si.nMax);
1066 }
1067
1068 if (abs(scrollX) > editor->sizeWindow.cx ||
1069 abs(scrollY) > editor->sizeWindow.cy)
1071 else
1072 ITextHost_TxScrollWindowEx(editor->texthost, scrollX, scrollY,
1073 &editor->rcFormat, &editor->rcFormat,
1075 ME_Repaint(editor);
1076
1077 if (editor->hWnd)
1078 {
1079 LONG winStyle = GetWindowLongW(editor->hWnd, GWL_STYLE);
1080 if (editor->styleFlags & WS_HSCROLL)
1081 {
1082 bScrollBarIsVisible = (winStyle & WS_HSCROLL) != 0;
1083 bScrollBarWillBeVisible = (editor->nTotalWidth > editor->sizeWindow.cx
1084 && (editor->styleFlags & WS_HSCROLL))
1085 || (editor->styleFlags & ES_DISABLENOSCROLL);
1086 if (bScrollBarIsVisible != bScrollBarWillBeVisible)
1088 bScrollBarWillBeVisible);
1089 }
1090
1091 if (editor->styleFlags & WS_VSCROLL)
1092 {
1093 bScrollBarIsVisible = (winStyle & WS_VSCROLL) != 0;
1094 bScrollBarWillBeVisible = (editor->nTotalLength > editor->sizeWindow.cy
1095 && (editor->styleFlags & WS_VSCROLL)
1096 && (editor->styleFlags & ES_MULTILINE))
1097 || (editor->styleFlags & ES_DISABLENOSCROLL);
1098 if (bScrollBarIsVisible != bScrollBarWillBeVisible)
1100 bScrollBarWillBeVisible);
1101 }
1102 }
1103 ME_UpdateScrollBar(editor);
1104}
#define ITextHost_TxSetScrollPos(This, a, b, c)
Definition: editor.h:292
#define ITextHost_TxScrollWindowEx(This, a, b, c, d, e, f, g)
Definition: editor.h:300
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define SW_INVALIDATE
Definition: winuser.h:2579
#define GWL_STYLE
Definition: winuser.h:852

Referenced by ITextRange_fnScrollIntoView(), ME_EnsureVisible(), ME_HandleMessage(), ME_HScrollAbs(), and ME_VScrollAbs().

◆ ME_ScrollDown()

void ME_ScrollDown ( ME_TextEditor editor,
int  cy 
)

Definition at line 1121 of file paint.c.

1122{
1123 ME_VScrollAbs(editor, editor->vert_si.nPos + cy);
1124}
void ME_VScrollAbs(ME_TextEditor *editor, int y)
Definition: paint.c:1111
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586

Referenced by ME_ArrowPageDown(), and ME_HandleMessage().

◆ ME_ScrollLeft()

void ME_ScrollLeft ( ME_TextEditor editor,
int  cx 
)

Definition at line 1126 of file paint.c.

1127{
1128 ME_HScrollAbs(editor, editor->horz_si.nPos - cx);
1129}

Referenced by ME_HandleMessage().

◆ ME_ScrollRight()

void ME_ScrollRight ( ME_TextEditor editor,
int  cx 
)

Definition at line 1131 of file paint.c.

1132{
1133 ME_HScrollAbs(editor, editor->horz_si.nPos + cx);
1134}

Referenced by ME_HandleMessage().

◆ ME_ScrollUp()

void ME_ScrollUp ( ME_TextEditor editor,
int  cy 
)

Definition at line 1116 of file paint.c.

1117{
1118 ME_VScrollAbs(editor, editor->vert_si.nPos - cy);
1119}

Referenced by ME_ArrowPageUp(), and ME_HandleMessage().

◆ ME_SendOldNotify()

void ME_SendOldNotify ( ME_TextEditor editor,
int  nCode 
)

Definition at line 5175 of file editor.c.

5176{
5177 ITextHost_TxNotify(editor->texthost, nCode, NULL);
5178}
#define ITextHost_TxNotify(This, a, b)
Definition: editor.h:322

Referenced by ME_HandleMessage(), ME_UpdateRepaint(), and RichEditWndProc_common().

◆ ME_SendRequestResize()

void ME_SendRequestResize ( ME_TextEditor editor,
BOOL  force 
)

Definition at line 1198 of file wrap.c.

1199{
1200 if (editor->nEventMask & ENM_REQUESTRESIZE)
1201 {
1202 RECT rc;
1203
1204 ITextHost_TxGetClientRect(editor->texthost, &rc);
1205
1206 if (force || rc.bottom != editor->nTotalLength)
1207 {
1209
1210 info.nmhdr.hwndFrom = NULL;
1211 info.nmhdr.idFrom = 0;
1212 info.nmhdr.code = EN_REQUESTRESIZE;
1213 info.rc = rc;
1214 info.rc.right = editor->nTotalWidth;
1215 info.rc.bottom = editor->nTotalLength;
1216
1217 editor->nEventMask &= ~ENM_REQUESTRESIZE;
1218 ITextHost_TxNotify(editor->texthost, info.nmhdr.code, &info);
1219 editor->nEventMask |= ENM_REQUESTRESIZE;
1220 }
1221 }
1222}
#define EN_REQUESTRESIZE
Definition: richedit.h:192
#define ENM_REQUESTRESIZE
Definition: richedit.h:477

Referenced by ME_HandleMessage(), ME_KeyDown(), ME_PaintContent(), and ME_StreamIn().

◆ ME_SendSelChange()

void ME_SendSelChange ( ME_TextEditor editor)

Definition at line 1598 of file caret.c.

1599{
1600 SELCHANGE sc;
1601
1602 sc.nmhdr.hwndFrom = NULL;
1603 sc.nmhdr.idFrom = 0;
1604 sc.nmhdr.code = EN_SELCHANGE;
1605 ME_GetSelectionOfs(editor, &sc.chrg.cpMin, &sc.chrg.cpMax);
1606 sc.seltyp = SEL_EMPTY;
1607 if (sc.chrg.cpMin != sc.chrg.cpMax)
1608 sc.seltyp |= SEL_TEXT;
1609 if (sc.chrg.cpMin < sc.chrg.cpMax+1) /* what were RICHEDIT authors thinking ? */
1610 sc.seltyp |= SEL_MULTICHAR;
1611
1612 if (sc.chrg.cpMin != editor->notified_cr.cpMin || sc.chrg.cpMax != editor->notified_cr.cpMax)
1613 {
1614 ME_ClearTempStyle(editor);
1615
1616 editor->notified_cr = sc.chrg;
1617
1618 if (editor->nEventMask & ENM_SELCHANGE)
1619 {
1620 TRACE("cpMin=%d cpMax=%d seltyp=%d (%s %s)\n",
1621 sc.chrg.cpMin, sc.chrg.cpMax, sc.seltyp,
1622 (sc.seltyp & SEL_TEXT) ? "SEL_TEXT" : "",
1623 (sc.seltyp & SEL_MULTICHAR) ? "SEL_MULTICHAR" : "");
1624 ITextHost_TxNotify(editor->texthost, sc.nmhdr.code, &sc);
1625 }
1626 }
1627}
#define SEL_EMPTY
Definition: richedit.h:822
#define SEL_MULTICHAR
Definition: richedit.h:825
#define EN_SELCHANGE
Definition: richedit.h:193
#define SEL_TEXT
Definition: richedit.h:823
#define ENM_SELCHANGE
Definition: richedit.h:478
NMHDR nmhdr
Definition: richedit.h:685
WORD seltyp
Definition: richedit.h:687
CHARRANGE chrg
Definition: richedit.h:686
UINT_PTR idFrom
Definition: winuser.h:3158
UINT code
Definition: winuser.h:3159
HWND hwndFrom
Definition: winuser.h:3157

Referenced by ME_ArrowKey(), ME_LButtonDown(), ME_MouseMove(), ME_StreamIn(), ME_TabPressedInTable(), ME_UpdateRepaint(), and set_selection().

◆ ME_SetCharFormat()

void ME_SetCharFormat ( ME_TextEditor editor,
ME_Cursor start,
ME_Cursor end,
CHARFORMAT2W pFmt 
)

Definition at line 725 of file run.c.

726{
727 ME_DisplayItem *run, *start_run = start->pRun, *end_run = NULL;
728
729 if (end && start->pRun == end->pRun && start->nOffset == end->nOffset)
730 return;
731
732 if (start->nOffset == start->pRun->member.run.len)
733 start_run = ME_FindItemFwd( start->pRun, diRun );
734 else if (start->nOffset)
735 {
736 /* SplitRunSimple may or may not update the cursors, depending on whether they
737 * are selection cursors, but we need to make sure they are valid. */
738 int split_offset = start->nOffset;
739 ME_DisplayItem *split_run = ME_SplitRunSimple(editor, start);
740 start_run = start->pRun;
741 if (end && end->pRun == split_run)
742 {
743 end->pRun = start->pRun;
744 end->nOffset -= split_offset;
745 }
746 }
747
748 if (end)
749 {
750 if (end->nOffset == end->pRun->member.run.len)
751 end_run = ME_FindItemFwd( end->pRun, diRun );
752 else
753 {
754 if (end->nOffset) ME_SplitRunSimple(editor, end);
755 end_run = end->pRun;
756 }
757 }
758
759 for (run = start_run; run != end_run; run = ME_FindItemFwd( run, diRun ))
760 {
761 ME_Style *new_style = ME_ApplyStyle(editor, run->member.run.style, pFmt);
762 ME_Paragraph *para = run->member.run.para;
763
764 add_undo_set_char_fmt( editor, run->member.run.para->nCharOfs + run->member.run.nCharOfs,
765 run->member.run.len, &run->member.run.style->fmt );
767 run->member.run.style = new_style;
768
769 /* The para numbering style depends on the eop style */
770 if ((run->member.run.nFlags & MERF_ENDPARA) && para->para_num.style)
771 {
772 ME_ReleaseStyle(para->para_num.style);
773 para->para_num.style = NULL;
774 }
775 mark_para_rewrap(editor, get_di_from_para(para));
776 }
777}
BOOL add_undo_set_char_fmt(ME_TextEditor *, int pos, int len, const CHARFORMAT2W *fmt) DECLSPEC_HIDDEN
Definition: undo.c:164
GLuint GLuint end
Definition: gl.h:1545
struct para_num para_num
Definition: editstr.h:215

Referenced by handle_EM_SETCHARFORMAT(), ME_HandleMessage(), ME_JoinParagraphs(), ME_PlayUndoItem(), ME_SetSelectionCharFormat(), ME_UpdateLinkAttribute(), set_textfont_prop(), and textrange_set_font().

◆ ME_SetCursorToStart()

◆ ME_SetDefaultCharFormat()

void ME_SetDefaultCharFormat ( ME_TextEditor editor,
CHARFORMAT2W mod 
)

Definition at line 540 of file style.c.

541{
542 ME_Style *style, *def = editor->pBuffer->pDefaultStyle;
543
544 assert(mod->cbSize == sizeof(CHARFORMAT2W));
545 style = ME_ApplyStyle(editor, def, mod);
546 def->fmt = style->fmt;
547 def->tm = style->tm;
548 if (def->font_cache)
549 {
551 def->font_cache = NULL;
552 }
555 ME_MarkAllForWrapping( editor );
556}
ME_Style * ME_ApplyStyle(ME_TextEditor *editor, ME_Style *sSrc, CHARFORMAT2W *mod)
Definition: style.c:156
SCRIPT_CACHE script_cache
Definition: editstr.h:78
ME_FontCacheItem * font_cache
Definition: editstr.h:75

Referenced by handle_EM_SETCHARFORMAT(), ME_HandleMessage(), and ME_MakeFirstParagraph().

◆ ME_SetDefaultParaFormat()

void ME_SetDefaultParaFormat ( ME_TextEditor editor,
PARAFORMAT2 pFmt 
)

Definition at line 992 of file para.c.

993{
994 const PARAFORMAT2 *host_fmt;
995 HRESULT hr;
996
997 ZeroMemory(pFmt, sizeof(PARAFORMAT2));
998 pFmt->cbSize = sizeof(PARAFORMAT2);
999 pFmt->dwMask = PFM_ALL2;
1000 pFmt->wAlignment = PFA_LEFT;
1001 pFmt->sStyle = -1;
1002 pFmt->bOutlineLevel = TRUE;
1003
1004 hr = ITextHost_TxGetParaFormat( editor->texthost, (const PARAFORMAT **)&host_fmt );
1005 if (SUCCEEDED(hr))
1006 {
1007 /* Just use the alignment for now */
1008 if (host_fmt->dwMask & PFM_ALIGNMENT)
1009 pFmt->wAlignment = host_fmt->wAlignment;
1011 }
1012}
#define ITextHost_OnTxParaFormatChange(This, a)
Definition: editor.h:320
#define ITextHost_TxGetParaFormat(This, a)
Definition: editor.h:311
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define PFM_ALL2
Definition: richedit.h:892
struct _paraformat2 PARAFORMAT2
HRESULT hr
Definition: shlfolder.c:183
BYTE bOutlineLevel
Definition: richedit.h:678
SHORT sStyle
Definition: richedit.h:677

Referenced by handle_enter(), make_para(), ME_InternalDeleteText(), and ME_StreamIn().

◆ ME_SetSelectionCharFormat()

void ME_SetSelectionCharFormat ( ME_TextEditor editor,
CHARFORMAT2W pFmt 
)

Definition at line 696 of file run.c.

697{
698 if (!ME_IsSelection(editor))
699 {
700 ME_Style *s;
701 if (!editor->pBuffer->pCharStyle)
702 editor->pBuffer->pCharStyle = ME_GetInsertStyle(editor, 0);
703 s = ME_ApplyStyle(editor, editor->pBuffer->pCharStyle, pFmt);
705 editor->pBuffer->pCharStyle = s;
706 } else {
707 ME_Cursor *from, *to;
708 ME_GetSelection(editor, &from, &to);
709 ME_SetCharFormat(editor, from, to, pFmt);
710 }
711}
void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *pFmt)
Definition: run.c:725

Referenced by handle_EM_SETCHARFORMAT(), ME_HandleMessage(), and ME_StreamIn().

◆ ME_SetSelectionParaFormat()

BOOL ME_SetSelectionParaFormat ( ME_TextEditor editor,
const PARAFORMAT2 pFmt 
)

Definition at line 907 of file para.c.

908{
909 ME_DisplayItem *para, *para_end;
910
911 ME_GetSelectionParas(editor, &para, &para_end);
912
913 do {
914 ME_SetParaFormat(editor, &para->member.para, pFmt);
915 if (para == para_end)
916 break;
917 para = para->member.para.next_para;
918 } while(1);
919
920 return TRUE;
921}
static BOOL ME_SetParaFormat(ME_TextEditor *editor, ME_Paragraph *para, const PARAFORMAT2 *pFmt)
Definition: para.c:464

Referenced by ME_HandleMessage(), and SpecialChar().

◆ ME_SetZoom()

BOOL ME_SetZoom ( ME_TextEditor editor,
int  numerator,
int  denominator 
)

Definition at line 1373 of file paint.c.

1374{
1375 /* TODO: Zoom images and objects */
1376
1377 if (numerator == 0 && denominator == 0)
1378 {
1379 editor->nZoomNumerator = editor->nZoomDenominator = 0;
1380 return TRUE;
1381 }
1382 if (numerator <= 0 || denominator <= 0)
1383 return FALSE;
1384 if (numerator * 64 <= denominator || numerator / denominator >= 64)
1385 return FALSE;
1386
1387 editor->nZoomNumerator = numerator;
1388 editor->nZoomDenominator = denominator;
1389
1390 ME_RewrapRepaint(editor);
1391 return TRUE;
1392}
void ME_RewrapRepaint(ME_TextEditor *editor)
Definition: paint.c:142

Referenced by ME_HandleMessage().

◆ ME_SkipAndPropagateCharOffset()

void ME_SkipAndPropagateCharOffset ( ME_DisplayItem p,
int  shift 
)

Definition at line 46 of file run.c.

Referenced by ME_InternalDeleteText().

◆ ME_SplitParagraph()

ME_DisplayItem * ME_SplitParagraph ( ME_TextEditor editor,
ME_DisplayItem rp,
ME_Style style,
const WCHAR eol_str,
int  eol_len,
int  paraFlags 
)

Definition at line 545 of file para.c.

548{
549 ME_DisplayItem *next_para = NULL;
550 ME_DisplayItem *run_para = NULL;
551 ME_DisplayItem *new_para = make_para(editor);
552 ME_DisplayItem *end_run;
553 int ofs, i;
554 ME_DisplayItem *pp;
555 int run_flags = MERF_ENDPARA;
556
557 if (!editor->bEmulateVersion10) { /* v4.1 */
558 /* At most 1 of MEPF_CELL, MEPF_ROWSTART, or MEPF_ROWEND should be set. */
559 assert(!(paraFlags & ~(MEPF_CELL|MEPF_ROWSTART|MEPF_ROWEND)));
560 assert(!(paraFlags & (paraFlags-1)));
561 if (paraFlags == MEPF_CELL)
562 run_flags |= MERF_ENDCELL;
563 else if (paraFlags == MEPF_ROWSTART)
564 run_flags |= MERF_TABLESTART|MERF_HIDDEN;
565 } else { /* v1.0 - v3.0 */
566 assert(!(paraFlags & (MEPF_CELL|MEPF_ROWSTART|MEPF_ROWEND)));
567 }
568 assert(run->type == diRun);
569 run_para = ME_GetParagraph(run);
570 assert(run_para->member.para.fmt.cbSize == sizeof(PARAFORMAT2));
571
572 /* Clear any cached para numbering following this paragraph */
573 if (run_para->member.para.fmt.wNumbering)
574 para_num_clear_list( editor, &run_para->member.para, &run_para->member.para.fmt );
575
576 new_para->member.para.text = ME_VSplitString( run_para->member.para.text, run->member.run.nCharOfs );
577
578 end_run = ME_MakeRun(style, run_flags);
579 ofs = end_run->member.run.nCharOfs = run->member.run.nCharOfs;
580 end_run->member.run.len = eol_len;
581 end_run->member.run.para = run->member.run.para;
582 ME_AppendString( run_para->member.para.text, eol_str, eol_len );
583 next_para = run_para->member.para.next_para;
584 assert(next_para == ME_FindItemFwd(run_para, diParagraphOrEnd));
585
586 add_undo_join_paras( editor, run_para->member.para.nCharOfs + ofs );
587
588 /* Update selection cursors to point to the correct paragraph. */
589 for (i = 0; i < editor->nCursors; i++) {
590 if (editor->pCursors[i].pPara == run_para &&
591 run->member.run.nCharOfs <= editor->pCursors[i].pRun->member.run.nCharOfs)
592 {
593 editor->pCursors[i].pPara = new_para;
594 }
595 }
596
597 /* the new paragraph will have a different starting offset, so let's update its runs */
598 pp = run;
599 while(pp->type == diRun) {
600 pp->member.run.nCharOfs -= ofs;
601 pp->member.run.para = &new_para->member.para;
603 }
604 new_para->member.para.nCharOfs = run_para->member.para.nCharOfs + ofs;
605 new_para->member.para.nCharOfs += eol_len;
606 new_para->member.para.nFlags = 0;
607 mark_para_rewrap(editor, new_para);
608
609 /* FIXME initialize format style and call ME_SetParaFormat blah blah */
610 new_para->member.para.fmt = run_para->member.para.fmt;
611 new_para->member.para.border = run_para->member.para.border;
612
613 /* insert paragraph into paragraph double linked list */
614 new_para->member.para.prev_para = run_para;
615 new_para->member.para.next_para = next_para;
616 run_para->member.para.next_para = new_para;
617 next_para->member.para.prev_para = new_para;
618
619 /* insert end run of the old paragraph, and new paragraph, into DI double linked list */
620 ME_InsertBefore(run, new_para);
621 ME_InsertBefore(new_para, end_run);
622
623 /* Fix up the paras' eop_run ptrs */
624 new_para->member.para.eop_run = run_para->member.para.eop_run;
625 run_para->member.para.eop_run = &end_run->member.run;
626
627 if (!editor->bEmulateVersion10) { /* v4.1 */
628 if (paraFlags & (MEPF_ROWSTART|MEPF_CELL))
629 {
631 ME_InsertBefore(new_para, cell);
632 new_para->member.para.pCell = cell;
633 cell->member.cell.next_cell = NULL;
634 if (paraFlags & MEPF_ROWSTART)
635 {
636 run_para->member.para.nFlags |= MEPF_ROWSTART;
637 cell->member.cell.prev_cell = NULL;
638 cell->member.cell.parent_cell = run_para->member.para.pCell;
639 if (run_para->member.para.pCell)
640 cell->member.cell.nNestingLevel = run_para->member.para.pCell->member.cell.nNestingLevel + 1;
641 else
642 cell->member.cell.nNestingLevel = 1;
643 } else {
644 cell->member.cell.prev_cell = run_para->member.para.pCell;
646 cell->member.cell.prev_cell->member.cell.next_cell = cell;
647 assert(run_para->member.para.nFlags & MEPF_CELL);
648 assert(!(run_para->member.para.nFlags & MEPF_ROWSTART));
649 cell->member.cell.nNestingLevel = cell->member.cell.prev_cell->member.cell.nNestingLevel;
650 cell->member.cell.parent_cell = cell->member.cell.prev_cell->member.cell.parent_cell;
651 }
652 } else if (paraFlags & MEPF_ROWEND) {
653 run_para->member.para.nFlags |= MEPF_ROWEND;
654 run_para->member.para.pCell = run_para->member.para.pCell->member.cell.parent_cell;
655 new_para->member.para.pCell = run_para->member.para.pCell;
656 assert(run_para->member.para.prev_para->member.para.nFlags & MEPF_CELL);
657 assert(!(run_para->member.para.prev_para->member.para.nFlags & MEPF_ROWSTART));
658 if (new_para->member.para.pCell != new_para->member.para.next_para->member.para.pCell
659 && new_para->member.para.next_para->member.para.pCell
660 && !new_para->member.para.next_para->member.para.pCell->member.cell.prev_cell)
661 {
662 /* Row starts just after the row that was ended. */
663 new_para->member.para.nFlags |= MEPF_ROWSTART;
664 }
665 } else {
666 new_para->member.para.pCell = run_para->member.para.pCell;
667 }
668 ME_UpdateTableFlags(run_para);
669 ME_UpdateTableFlags(new_para);
670 }
671
672 /* force rewrap of the */
673 if (run_para->member.para.prev_para->type == diParagraph)
674 mark_para_rewrap(editor, run_para->member.para.prev_para);
675
676 mark_para_rewrap(editor, new_para->member.para.prev_para);
677
678 /* we've added the end run, so we need to modify nCharOfs in the next paragraphs */
679 ME_PropagateCharOffset(next_para, eol_len);
680 editor->nParagraphs++;
681
682 return new_para;
683}
BOOL add_undo_join_paras(ME_TextEditor *, int pos) DECLSPEC_HIDDEN
Definition: undo.c:176
#define MERF_HIDDEN
Definition: editstr.h:126
#define MERF_TABLESTART
Definition: editstr.h:128
static void ME_UpdateTableFlags(ME_DisplayItem *para)
Definition: para.c:241
ME_DisplayItem * ME_GetParagraph(ME_DisplayItem *item)
Definition: para.c:815
WORD wNumbering
Definition: richedit.h:668
struct tagME_DisplayItem * parent_cell
Definition: editstr.h:229

Referenced by ME_InsertEndParaFromCursor(), ME_InsertTextFromCursor(), and ME_PlayUndoItem().

◆ ME_SplitRunSimple()

ME_DisplayItem * ME_SplitRunSimple ( ME_TextEditor editor,
ME_Cursor cursor 
)

Definition at line 258 of file run.c.

259{
260 ME_DisplayItem *run = cursor->pRun;
261 ME_DisplayItem *new_run;
262 int i;
263 int nOffset = cursor->nOffset;
264
266
267 new_run = ME_MakeRun(run->member.run.style,
269 new_run->member.run.nCharOfs = run->member.run.nCharOfs + nOffset;
270 new_run->member.run.len = run->member.run.len - nOffset;
271 new_run->member.run.para = run->member.run.para;
272 run->member.run.len = nOffset;
273 cursor->pRun = new_run;
274 cursor->nOffset = 0;
275
276 ME_InsertBefore(run->next, new_run);
277
278 ME_UpdateRunFlags(editor, &run->member.run);
279 ME_UpdateRunFlags(editor, &new_run->member.run);
280 for (i = 0; i < editor->nCursors; i++) {
281 if (editor->pCursors[i].pRun == run &&
282 editor->pCursors[i].nOffset >= nOffset) {
283 editor->pCursors[i].pRun = new_run;
284 editor->pCursors[i].nOffset -= nOffset;
285 }
286 }
287 mark_para_rewrap(editor, cursor->pPara);
288 return run;
289}
#define MERF_NONTEXT
Definition: editstr.h:111
#define MERF_SPLITMASK
Definition: editstr.h:136

Referenced by itemize_para(), ME_InsertEndParaFromCursor(), ME_InsertRunAtCursor(), ME_InsertTextFromCursor(), ME_PlayUndoItem(), ME_SetCharFormat(), and split_run_extents().

◆ ME_StrDeleteV()

void ME_StrDeleteV ( ME_String s,
int  nVChar,
int  nChars 
)

Definition at line 147 of file string.c.

148{
149 int end_ofs = nVChar + nChars;
150
151 assert(s->nBuffer); /* Not a const string */
152 assert(nChars >= 0);
153 assert(nVChar >= 0);
154 assert(end_ofs <= s->nLen);
155
156 memmove(s->szData + nVChar, s->szData + end_ofs,
157 (s->nLen - end_ofs + 1) * sizeof(WCHAR));
158 s->nLen -= nChars;
159}

Referenced by ME_InternalDeleteText().

◆ ME_StreamInFill()

void ME_StreamInFill ( ME_InStream stream)

Definition at line 1576 of file editor.c.

1577{
1578 stream->editstream->dwError = stream->editstream->pfnCallback(stream->editstream->dwCookie,
1579 (BYTE *)stream->buffer,
1580 sizeof(stream->buffer),
1581 (LONG *)&stream->dwSize);
1582 stream->dwUsed = 0;
1583}
Definition: parse.h:23
unsigned char BYTE
Definition: xxhash.c:193

Referenced by _RTFGetChar(), ME_StreamIn(), and ME_StreamInText().

◆ ME_StreamOut()

LRESULT ME_StreamOut ( ME_TextEditor editor,
DWORD  dwFormat,
EDITSTREAM stream 
)

Definition at line 1179 of file writer.c.

1180{
1182 int nChars;
1183
1184 if (dwFormat & SFF_SELECTION) {
1185 int nStart, nTo;
1186 start = editor->pCursors[ME_GetSelectionOfs(editor, &nStart, &nTo)];
1187 nChars = nTo - nStart;
1188 } else {
1189 ME_SetCursorToStart(editor, &start);
1190 nChars = ME_GetTextLength(editor);
1191 /* Generate an end-of-paragraph at the end of SCF_ALL RTF output */
1192 if (dwFormat & SF_RTF)
1193 nChars++;
1194 }
1195 return ME_StreamOutRange(editor, dwFormat, &start, nChars, stream);
1196}
LRESULT ME_StreamOutRange(ME_TextEditor *editor, DWORD dwFormat, const ME_Cursor *start, int nChars, EDITSTREAM *stream)
Definition: writer.c:1163
#define SFF_SELECTION
Definition: richedit.h:979
#define SF_RTF
Definition: richedit.h:721

Referenced by ME_HandleMessage().

◆ ME_StreamOutRange()

LRESULT ME_StreamOutRange ( ME_TextEditor editor,
DWORD  dwFormat,
const ME_Cursor start,
int  nChars,
EDITSTREAM stream 
)

Definition at line 1163 of file writer.c.

1166{
1167 ME_OutStream *pStream = ME_StreamOutInit(editor, stream);
1168
1169 if (dwFormat & SF_RTF)
1170 ME_StreamOutRTF(editor, pStream, start, nChars, dwFormat);
1171 else if (dwFormat & SF_TEXT || dwFormat & SF_TEXTIZED)
1172 ME_StreamOutText(editor, pStream, start, nChars, dwFormat);
1173 if (!pStream->stream->dwError)
1174 ME_StreamOutFlush(pStream);
1175 return ME_StreamOutFree(pStream);
1176}
static LONG ME_StreamOutFree(ME_OutStream *pStream)
Definition: writer.c:92
static ME_OutStream * ME_StreamOutInit(ME_TextEditor *editor, EDITSTREAM *stream)
Definition: writer.c:55
static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream, const ME_Cursor *start, int nChars, DWORD dwFormat)
Definition: writer.c:1104
static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream, const ME_Cursor *start, int nChars, int dwFormat)
Definition: writer.c:998
static BOOL ME_StreamOutFlush(ME_OutStream *pStream)
Definition: writer.c:69
#define SF_TEXT
Definition: richedit.h:720
#define SF_TEXTIZED
Definition: richedit.h:723
DWORD dwError
Definition: richedit.h:523
EDITSTREAM * stream
Definition: writer.c:34

Referenced by get_rtf_text(), and ME_StreamOut().

◆ ME_TabPressedInTable()

void ME_TabPressedInTable ( ME_TextEditor editor,
BOOL  bSelectedRow 
)

Definition at line 562 of file table.c.

563{
564 /* FIXME: Shift tab should move to the previous cell. */
565 ME_Cursor fromCursor, toCursor;
567 {
568 int from, to;
569 from = ME_GetCursorOfs(&editor->pCursors[0]);
570 to = ME_GetCursorOfs(&editor->pCursors[1]);
571 if (from <= to)
572 {
573 fromCursor = editor->pCursors[0];
574 toCursor = editor->pCursors[1];
575 } else {
576 fromCursor = editor->pCursors[1];
577 toCursor = editor->pCursors[0];
578 }
579 }
580 if (!editor->bEmulateVersion10) /* v4.1 */
581 {
582 if (!ME_IsInTable(toCursor.pRun))
583 {
584 editor->pCursors[0] = toCursor;
585 editor->pCursors[1] = toCursor;
586 } else {
587 ME_SelectOrInsertNextCell(editor, toCursor.pRun);
588 }
589 } else { /* v1.0 - 3.0 */
590 if (!ME_IsInTable(fromCursor.pRun)) {
591 editor->pCursors[0] = fromCursor;
592 editor->pCursors[1] = fromCursor;
593 /* FIXME: For some reason the caret is shown at the start of the
594 * previous paragraph in v1.0 to v3.0, and bCaretAtEnd only works
595 * within the paragraph for wrapped lines. */
596 if (ME_FindItemBack(fromCursor.pRun, diRun))
597 editor->bCaretAtEnd = TRUE;
598 } else if ((bSelectedRow || !ME_IsInTable(toCursor.pRun))) {
599 ME_SelectOrInsertNextCell(editor, fromCursor.pRun);
600 } else {
601 if (ME_IsSelection(editor) && !toCursor.nOffset)
602 {
603 ME_DisplayItem *run;
605 if (run->type == diRun && run->member.run.nFlags & MERF_TAB)
606 ME_SelectOrInsertNextCell(editor, run);
607 else
608 ME_SelectOrInsertNextCell(editor, toCursor.pRun);
609 } else {
610 ME_SelectOrInsertNextCell(editor, toCursor.pRun);
611 }
612 }
613 }
615 ME_Repaint(editor);
616 update_caret(editor);
617 ME_SendSelChange(editor);
618}
static void ME_SelectOrInsertNextCell(ME_TextEditor *editor, ME_DisplayItem *run)
Definition: table.c:462
BOOL ME_IsInTable(ME_DisplayItem *pItem)
Definition: table.c:273

Referenced by ME_Char().

◆ ME_ToUnicode()

LPWSTR ME_ToUnicode ( LONG  codepage,
LPVOID  psz,
INT len 
)

Definition at line 226 of file string.c.

227{
228 *len = 0;
229 if (!psz) return NULL;
230
231 if (codepage == CP_UNICODE)
232 {
233 *len = lstrlenW(psz);
234 return psz;
235 }
236 else {
237 WCHAR *tmp;
238 int nChars = MultiByteToWideChar(codepage, 0, psz, -1, NULL, 0);
239
240 if(!nChars) return NULL;
241
242 if((tmp = heap_alloc( nChars * sizeof(WCHAR) )) != NULL)
243 *len = MultiByteToWideChar(codepage, 0, psz, -1, tmp, nChars) - 1;
244 return tmp;
245 }
246}

Referenced by ME_HandleMessage(), and ME_SetText().

◆ ME_twips2pointsX()

int ME_twips2pointsX ( const ME_Context c,
int  x 
)

Definition at line 153 of file paint.c.

154{
155 if (c->editor->nZoomNumerator == 0)
156 return x * c->dpi.cx / 1440;
157 else
158 return x * c->dpi.cx * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
159}

Referenced by adjust_para_y(), ME_BeginRow(), ME_DrawTableBorders(), ME_GetRunSizeCommon(), ME_InitContext(), and ME_WrapTextParagraph().

◆ ME_twips2pointsY()

int ME_twips2pointsY ( const ME_Context c,
int  y 
)

Definition at line 161 of file paint.c.

162{
163 if (c->editor->nZoomNumerator == 0)
164 return y * c->dpi.cy / 1440;
165 else
166 return y * c->dpi.cy * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
167}

Referenced by adjust_para_y(), calc_y_offset(), ME_DrawParaDecoration(), ME_DrawTableBorders(), ME_GetParaLineSpace(), ME_LogFontFromStyle(), and ME_WrapTextParagraph().

◆ ME_Undo()

BOOL ME_Undo ( ME_TextEditor editor)

Definition at line 414 of file undo.c.

415{
416 ME_UndoMode nMode = editor->nUndoMode;
417 struct list *head;
418 struct undo_item *undo, *cursor2;
419
420 if (editor->nUndoMode == umIgnore) return FALSE;
421 assert(nMode == umAddToUndo || nMode == umIgnore);
422
423 head = list_head( &editor->undo_stack );
424 if (!head) return FALSE;
425
426 /* watch out for uncommitted transactions ! */
427 undo = LIST_ENTRY( head, struct undo_item, entry );
430
431 editor->nUndoMode = umAddToRedo;
432
433 list_remove( &undo->entry );
434 destroy_undo_item( undo );
435
436 LIST_FOR_EACH_ENTRY_SAFE( undo, cursor2, &editor->undo_stack, struct undo_item, entry )
437 {
438 if (undo->type == undo_end_transaction) break;
439 ME_PlayUndoItem( editor, undo );
440 list_remove( &undo->entry );
441 destroy_undo_item( undo );
442 }
443
447 editor->nUndoStackSize--;
448 editor->nUndoMode = nMode;
449 ME_UpdateRepaint(editor, FALSE);
450 return TRUE;
451}
@ umAddToRedo
Definition: editstr.h:282

Referenced by ME_HandleMessage(), and ME_KeyDown().

◆ ME_UpdateRepaint()

void ME_UpdateRepaint ( ME_TextEditor editor,
BOOL  update_now 
)

Definition at line 116 of file paint.c.

117{
118 /* Should be called whenever the contents of the control have changed */
119 BOOL wrappedParagraphs;
120
121 wrappedParagraphs = ME_WrapMarkedParagraphs(editor);
122 if (wrappedParagraphs)
123 ME_UpdateScrollBar(editor);
124
125 /* Ensure that the cursor is visible */
126 ME_EnsureVisible(editor, &editor->pCursors[0]);
127
128 ITextHost_TxViewChange(editor->texthost, update_now);
129
130 ME_SendSelChange(editor);
131
132 /* send EN_CHANGE if the event mask asks for it */
133 if(editor->nEventMask & ENM_CHANGE)
134 {
135 editor->nEventMask &= ~ENM_CHANGE;
137 editor->nEventMask |= ENM_CHANGE;
138 }
139}
void ME_EnsureVisible(ME_TextEditor *editor, ME_Cursor *pCursor)
Definition: paint.c:1275
#define ENM_CHANGE
Definition: richedit.h:468
#define EN_CHANGE
Definition: winuser.h:2022

Referenced by copy_or_cut(), fnTextSrv_TxSetText(), handle_enter(), IRichEditOle_fnInsertObject(), ME_Char(), ME_HandleMessage(), ME_KeyDown(), ME_Redo(), ME_ReplaceSel(), ME_StreamIn(), ME_Undo(), and paste_emf().

◆ ME_UpdateRunFlags()

void ME_UpdateRunFlags ( ME_TextEditor editor,
ME_Run run 
)

Definition at line 413 of file run.c.

414{
415 assert(run->nCharOfs >= 0);
416
417 if (RUN_IS_HIDDEN(run) || run->nFlags & MERF_TABLESTART)
418 run->nFlags |= MERF_HIDDEN;
419 else
420 run->nFlags &= ~MERF_HIDDEN;
421
422 if (run_is_splittable( run ))
423 run->nFlags |= MERF_SPLITTABLE;
424 else
425 run->nFlags &= ~MERF_SPLITTABLE;
426
427 if (!(run->nFlags & MERF_NOTEXT))
428 {
429 if (run_is_entirely_ws( run ))
431 else
432 {
433 run->nFlags &= ~MERF_WHITESPACE;
434
435 if (ME_IsWSpace( *get_text( run, 0 ) ))
436 run->nFlags |= MERF_STARTWHITE;
437 else
438 run->nFlags &= ~MERF_STARTWHITE;
439
440 if (ME_IsWSpace( *get_text( run, run->len - 1 ) ))
441 run->nFlags |= MERF_ENDWHITE;
442 else
443 run->nFlags &= ~MERF_ENDWHITE;
444 }
445 }
446 else
448}
static BOOL run_is_splittable(const ME_Run *run)
Definition: run.c:377
static BOOL run_is_entirely_ws(const ME_Run *run)
Definition: run.c:395
static int ME_IsWSpace(WCHAR ch)
Definition: editor.h:101
#define RUN_IS_HIDDEN(run)
Definition: editor.h:29
#define MERF_STARTWHITE
Definition: editstr.h:116
#define MERF_NOTEXT
Definition: editstr.h:133
#define MERF_ENDWHITE
Definition: editstr.h:118
#define MERF_SPLITTABLE
Definition: editstr.h:114
#define MERF_WHITESPACE
Definition: editstr.h:120

Referenced by ME_JoinRuns(), ME_SplitByBacktracking(), ME_SplitRunSimple(), and ME_WrapSizeRun().

◆ ME_UpdateScrollBar()

void ME_UpdateScrollBar ( ME_TextEditor editor)

Definition at line 1148 of file paint.c.

1149{
1150 /* Note that this is the only function that should ever call
1151 * SetScrollInfo with SIF_PAGE or SIF_RANGE. */
1152
1153 SCROLLINFO si;
1154 BOOL bScrollBarWasVisible, bScrollBarWillBeVisible;
1155
1156 if (ME_WrapMarkedParagraphs(editor))
1157 FIXME("ME_UpdateScrollBar had to call ME_WrapMarkedParagraphs\n");
1158
1159 si.cbSize = sizeof(si);
1161 si.nMin = 0;
1162 if (editor->styleFlags & ES_DISABLENOSCROLL)
1164
1165 /* Update horizontal scrollbar */
1166 bScrollBarWasVisible = editor->horz_si.nMax > editor->horz_si.nPage;
1167 bScrollBarWillBeVisible = editor->nTotalWidth > editor->sizeWindow.cx;
1168 if (editor->horz_si.nPos && !bScrollBarWillBeVisible)
1169 {
1170 ME_HScrollAbs(editor, 0);
1171 /* ME_HScrollAbs will call this function,
1172 * so nothing else needs to be done here. */
1173 return;
1174 }
1175
1176 si.nMax = editor->nTotalWidth;
1177 si.nPos = editor->horz_si.nPos;
1178 si.nPage = editor->sizeWindow.cx;
1179
1180 if (si.nMax != editor->horz_si.nMax ||
1181 si.nPage != editor->horz_si.nPage)
1182 {
1183 TRACE("min=%d max=%d page=%d\n", si.nMin, si.nMax, si.nPage);
1184 editor->horz_si.nMax = si.nMax;
1185 editor->horz_si.nPage = si.nPage;
1186 if ((bScrollBarWillBeVisible || bScrollBarWasVisible) &&
1187 editor->styleFlags & WS_HSCROLL)
1188 {
1189 if (si.nMax > 0xFFFF)
1190 {
1191 /* Native scales the scrollbar info to 16-bit external values. */
1192 si.nPos = MulDiv(si.nPos, 0xFFFF, si.nMax);
1193 si.nMax = 0xFFFF;
1194 }
1195 if (editor->hWnd) {
1196 SetScrollInfo(editor->hWnd, SB_HORZ, &si, TRUE);
1197 } else {
1200 }
1201 /* SetScrollInfo or SetScrollRange change scrollbar visibility. */
1202 bScrollBarWasVisible = ME_PostSetScrollRangeVisibility(&si);
1203 }
1204 }
1205
1206 if (editor->styleFlags & WS_HSCROLL)
1207 {
1208 if (si.fMask & SIF_DISABLENOSCROLL) {
1209 bScrollBarWillBeVisible = TRUE;
1210 } else if (!(editor->styleFlags & WS_HSCROLL)) {
1211 bScrollBarWillBeVisible = FALSE;
1212 }
1213
1214 if (bScrollBarWasVisible != bScrollBarWillBeVisible)
1215 ITextHost_TxShowScrollBar(editor->texthost, SB_HORZ, bScrollBarWillBeVisible);
1216 }
1217
1218 /* Update vertical scrollbar */
1219 bScrollBarWasVisible = editor->vert_si.nMax > editor->vert_si.nPage;
1220 bScrollBarWillBeVisible = editor->nTotalLength > editor->sizeWindow.cy &&
1221 (editor->styleFlags & ES_MULTILINE);
1222
1223 if (editor->vert_si.nPos && !bScrollBarWillBeVisible)
1224 {
1225 ME_VScrollAbs(editor, 0);
1226 /* ME_VScrollAbs will call this function,
1227 * so nothing else needs to be done here. */
1228 return;
1229 }
1230
1231 si.nMax = editor->nTotalLength;
1232 si.nPos = editor->vert_si.nPos;
1233 si.nPage = editor->sizeWindow.cy;
1234
1235 if (si.nMax != editor->vert_si.nMax ||
1236 si.nPage != editor->vert_si.nPage)
1237 {
1238 TRACE("min=%d max=%d page=%d\n", si.nMin, si.nMax, si.nPage);
1239 editor->vert_si.nMax = si.nMax;
1240 editor->vert_si.nPage = si.nPage;
1241 if ((bScrollBarWillBeVisible || bScrollBarWasVisible) &&
1242 editor->styleFlags & WS_VSCROLL)
1243 {
1244 if (si.nMax > 0xFFFF)
1245 {
1246 /* Native scales the scrollbar info to 16-bit external values. */
1247 si.nPos = MulDiv(si.nPos, 0xFFFF, si.nMax);
1248 si.nMax = 0xFFFF;
1249 }
1250 if (editor->hWnd) {
1251 SetScrollInfo(editor->hWnd, SB_VERT, &si, TRUE);
1252 } else {
1255 }
1256 /* SetScrollInfo or SetScrollRange change scrollbar visibility. */
1257 bScrollBarWasVisible = ME_PostSetScrollRangeVisibility(&si);
1258 }
1259 }
1260
1261 if (editor->styleFlags & WS_VSCROLL)
1262 {
1263 if (si.fMask & SIF_DISABLENOSCROLL) {
1264 bScrollBarWillBeVisible = TRUE;
1265 } else if (!(editor->styleFlags & WS_VSCROLL)) {
1266 bScrollBarWillBeVisible = FALSE;
1267 }
1268
1269 if (bScrollBarWasVisible != bScrollBarWillBeVisible)
1271 bScrollBarWillBeVisible);
1272 }
1273}
static BOOL ME_PostSetScrollRangeVisibility(SCROLLINFO *si)
Definition: paint.c:1138
#define ITextHost_TxSetScrollRange(This, a, b, c, d)
Definition: editor.h:291
#define SIF_RANGE
Definition: winuser.h:1235
#define SIF_PAGE
Definition: winuser.h:1233
#define SIF_DISABLENOSCROLL
Definition: winuser.h:1236
#define SIF_POS
Definition: winuser.h:1234
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)

Referenced by handle_EM_SETCHARFORMAT(), ME_HandleMessage(), ME_Repaint(), ME_RewrapRepaint(), ME_ScrollAbs(), and ME_UpdateRepaint().

◆ ME_VScrollAbs()

void ME_VScrollAbs ( ME_TextEditor editor,
int  y 
)

Definition at line 1111 of file paint.c.

1112{
1113 ME_ScrollAbs(editor, editor->horz_si.nPos, y);
1114}

Referenced by ME_HandleMessage(), ME_ScrollDown(), ME_ScrollUp(), and ME_UpdateScrollBar().

◆ ME_VSplitString()

ME_String * ME_VSplitString ( ME_String orig,
int  nVPos 
)

Definition at line 131 of file string.c.

132{
133 ME_String *s;
134
135 assert(orig->nBuffer); /* Not a const string */
136 assert(charidx>=0);
137 assert(charidx<=orig->nLen);
138
139 s = ME_MakeStringN(orig->szData+charidx, orig->nLen-charidx);
140 if (!s) return NULL;
141
142 orig->nLen = charidx;
143 orig->szData[charidx] = '\0';
144 return s;
145}
ME_String * ME_MakeStringN(LPCWSTR szText, int nMaxChars)
Definition: string.c:75
int nBuffer
Definition: editstr.h:57

Referenced by ME_JoinParagraphs(), and ME_SplitParagraph().

◆ ME_WrapMarkedParagraphs()

BOOL ME_WrapMarkedParagraphs ( ME_TextEditor editor)

Definition at line 1093 of file wrap.c.

1094{
1096 ME_Context c;
1097 int totalWidth = editor->nTotalWidth, diff = 0, prev_width;
1098 ME_DisplayItem *repaint_start = NULL, *repaint_end = NULL;
1099 ME_Paragraph *para;
1100
1101 if (!editor->first_marked_para)
1102 return FALSE;
1103
1104 ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
1105
1106 item = editor->first_marked_para;
1107 c.pt = item->member.para.pt;
1108 while (item != editor->pBuffer->pLast)
1109 {
1110 assert(item->type == diParagraph);
1111
1112 prev_width = item->member.para.nWidth;
1113 ME_WrapTextParagraph(editor, &c, item);
1114 if (prev_width == totalWidth && item->member.para.nWidth < totalWidth)
1115 totalWidth = get_total_width(editor);
1116 else
1117 totalWidth = max(totalWidth, item->member.para.nWidth);
1118
1119 if (!item->member.para.nCharOfs)
1120 ME_MarkRepaintEnd(item->member.para.prev_para, &repaint_start, &repaint_end);
1121 ME_MarkRepaintEnd(item, &repaint_start, &repaint_end);
1122 adjust_para_y(item, &c, repaint_start, repaint_end);
1123
1124 if (item->member.para.next_para)
1125 {
1126 diff = c.pt.y - item->member.para.next_para->member.para.pt.y;
1127 if (diff)
1128 {
1129 para = &item->member.para;
1130 while (para->next_para && para != &item->member.para.next_marked->member.para &&
1131 para != &editor->pBuffer->pLast->member.para)
1132 {
1133 ME_MarkRepaintEnd(para->next_para, &repaint_start, &repaint_end);
1134 para->next_para->member.para.pt.y = c.pt.y;
1135 adjust_para_y(para->next_para, &c, repaint_start, repaint_end);
1136 para = &para->next_para->member.para;
1137 }
1138 }
1139 }
1140 if (item->member.para.next_marked)
1141 {
1142 ME_DisplayItem *rem = item;
1143 item = item->member.para.next_marked;
1144 remove_marked_para(editor, rem);
1145 }
1146 else
1147 {
1148 remove_marked_para(editor, item);
1149 item = editor->pBuffer->pLast;
1150 }
1151 c.pt.y = item->member.para.pt.y;
1152 }
1153 editor->sizeWindow.cx = c.rcView.right-c.rcView.left;
1154 editor->sizeWindow.cy = c.rcView.bottom-c.rcView.top;
1155
1156 editor->nTotalLength = c.pt.y;
1157 editor->nTotalWidth = totalWidth;
1158 editor->pBuffer->pLast->member.para.pt.x = 0;
1159 editor->pBuffer->pLast->member.para.pt.y = c.pt.y;
1160
1162
1163 if (repaint_start || editor->nTotalLength < editor->nLastTotalLength)
1164 ME_InvalidateParagraphRange(editor, repaint_start, repaint_end);
1165 return !!repaint_start;
1166}
int get_total_width(ME_TextEditor *editor) DECLSPEC_HIDDEN
Definition: para.c:64
void remove_marked_para(ME_TextEditor *editor, ME_DisplayItem *para) DECLSPEC_HIDDEN
Definition: para.c:82
static void adjust_para_y(ME_DisplayItem *item, ME_Context *c, ME_DisplayItem *repaint_start, ME_DisplayItem *repaint_end)
Definition: wrap.c:979
void ME_InvalidateParagraphRange(ME_TextEditor *editor, ME_DisplayItem *start_para, ME_DisplayItem *last_para)
Definition: wrap.c:1168
static void ME_MarkRepaintEnd(ME_DisplayItem *para, ME_DisplayItem **repaint_start, ME_DisplayItem **repaint_end)
Definition: wrap.c:970
static void ME_WrapTextParagraph(ME_TextEditor *editor, ME_Context *c, ME_DisplayItem *tp)
Definition: wrap.c:868

Referenced by handle_EM_SETCHARFORMAT(), ME_HandleMessage(), ME_InvalidateSelection(), ME_Repaint(), ME_RewrapRepaint(), ME_SelectOrInsertNextCell(), ME_UpdateRepaint(), ME_UpdateScrollBar(), and ME_WmCreate().

◆ para_num_clear()

void para_num_clear ( struct para_num pn)

Definition at line 442 of file para.c.

443{
444 if (pn->style)
445 {
446 ME_ReleaseStyle( pn->style );
447 pn->style = NULL;
448 }
449 ME_DestroyString( pn->text );
450 pn->text = NULL;
451}
static int pints_t pn[]
Definition: server.c:129

Referenced by destroy_para(), and para_num_clear_list().

◆ para_num_init()

void para_num_init ( ME_Context c,
ME_Paragraph para 
)

Definition at line 395 of file para.c.

396{
399 static const WCHAR bullet_font[] = {'S','y','m','b','o','l',0};
400 static const WCHAR bullet_str[] = {0xb7, 0};
401 static const WCHAR spaceW[] = {' ', 0};
402 SIZE sz;
403
404 if (!para->fmt.wNumbering) return;
405 if (para->para_num.style && para->para_num.text) return;
406
407 if (!para->para_num.style)
408 {
409 style = para->eop_run->style;
410
411 if (para->fmt.wNumbering == PFN_BULLET)
412 {
413 cf.cbSize = sizeof(cf);
414 cf.dwMask = CFM_FACE | CFM_CHARSET;
415 memcpy( cf.szFaceName, bullet_font, sizeof(bullet_font) );
416 cf.bCharSet = SYMBOL_CHARSET;
417 style = ME_ApplyStyle( c->editor, style, &cf );
418 }
419 else
420 {
422 }
423
424 para->para_num.style = style;
425 }
426
427 if (!para->para_num.text)
428 {
429 if (para->fmt.wNumbering != PFN_BULLET)
430 para->para_num.text = para_num_get_str( para, para_num_get_num( para ) );
431 else
432 para->para_num.text = ME_MakeStringConst( bullet_str, 1 );
433 }
434
435 select_style( c, para->para_num.style );
436 GetTextExtentPointW( c->hDC, para->para_num.text->szData, para->para_num.text->nLen, &sz );
437 para->para_num.width = sz.cx;
438 GetTextExtentPointW( c->hDC, spaceW, 1, &sz );
439 para->para_num.width += sz.cx;
440}
ME_String * ME_MakeStringConst(const WCHAR *str, int len) DECLSPEC_HIDDEN
Definition: string.c:41
static ME_String * para_num_get_str(ME_Paragraph *para, WORD num)
Definition: para.c:281
static int para_num_get_num(ME_Paragraph *para)
Definition: para.c:268
BOOL WINAPI GetTextExtentPointW(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)
#define SYMBOL_CHARSET
Definition: wingdi.h:385

Referenced by ME_WrapTextParagraph().

◆ release_typelib()

void release_typelib ( void  )

Definition at line 159 of file apps.c.

160{
161 unsigned i;
162
163 for (i = 0; i < ARRAY_SIZE(typeinfo); i++)
164 if (typeinfo[i])
165 ITypeInfo_Release(typeinfo[i]);
166
167 if (typelib)
168 ITypeLib_Release(typelib);
169}
static ITypeLib * typelib
Definition: apps.c:108

◆ remove_marked_para()

void remove_marked_para ( ME_TextEditor editor,
ME_DisplayItem para 
)

Definition at line 82 of file para.c.

83{
85
86 assert(di->type == diParagraph);
87 if (!di->member.para.next_marked && !di->member.para.prev_marked)
88 {
89 if (di == head)
90 editor->first_marked_para = NULL;
91 }
92 else if (di->member.para.next_marked && di->member.para.prev_marked)
93 {
94 di->member.para.prev_marked->member.para.next_marked = di->member.para.next_marked;
95 di->member.para.next_marked->member.para.prev_marked = di->member.para.prev_marked;
96 di->member.para.prev_marked = di->member.para.next_marked = NULL;
97 }
98 else if (di->member.para.next_marked)
99 {
100 assert(di == editor->first_marked_para);
102 di->member.para.next_marked->member.para.prev_marked = NULL;
103 di->member.para.next_marked = NULL;
104 }
105 else
106 {
107 di->member.para.prev_marked->member.para.next_marked = NULL;
108 di->member.para.prev_marked = NULL;
109 }
110}

Referenced by destroy_para(), and ME_WrapMarkedParagraphs().

◆ select_style()

void select_style ( ME_Context c,
ME_Style s 
)

Definition at line 369 of file style.c.

370{
371 HFONT old_font;
372 LOGFONTW lf;
373 int i, empty, age = 0x7FFFFFFF;
375
376 if (c->current_style == s) return;
377
378 if (s)
379 {
380 ME_LogFontFromStyle( c, &lf, s );
381
382 for (i = 0; i < HFONT_CACHE_SIZE; i++)
383 c->editor->pFontCache[i].nAge++;
384 for (i = 0, empty = -1, age = 0; i < HFONT_CACHE_SIZE; i++)
385 {
386 item = &c->editor->pFontCache[i];
387 if (!item->nRefs)
388 {
389 if (item->nAge > age)
390 {
391 empty = i;
392 age = item->nAge;
393 }
394 }
395
396 if (item->hFont && ME_IsFontEqual( &item->lfSpecs, &lf ))
397 break;
398 }
399
400 if (i < HFONT_CACHE_SIZE) /* found */
401 {
402 item = &c->editor->pFontCache[i];
403 TRACE_(richedit_style)( "font reused %d\n", i );
404 item->nRefs++;
405 }
406 else
407 {
408 assert(empty != -1);
409 item = &c->editor->pFontCache[empty];
410 if (item->hFont)
411 {
412 TRACE_(richedit_style)( "font deleted %d\n", empty );
413 DeleteObject(item->hFont);
414 item->hFont = NULL;
415 }
416 item->hFont = CreateFontIndirectW( &lf );
417 TRACE_(richedit_style)( "font created %d\n", empty );
418 item->nRefs = 1;
419 item->lfSpecs = lf;
420 }
421 s->font_cache = item;
422 old_font = SelectObject( c->hDC, item->hFont );
423 GetTextMetricsW( c->hDC, &s->tm );
424 if (!c->orig_font) c->orig_font = old_font;
425 }
426 else
427 {
428 SelectObject( c->hDC, c->orig_font );
429 c->orig_font = NULL;
430 }
431
432 if (c->current_style && c->current_style->font_cache)
433 {
434 release_font_cache( c->current_style->font_cache );
435 c->current_style->font_cache = NULL;
436 }
437 c->current_style = s;
438
439 return;
440}
static const WCHAR empty[]
Definition: main.c:47
static void ME_LogFontFromStyle(ME_Context *c, LOGFONTW *lf, const ME_Style *s)
Definition: style.c:302
static BOOL ME_IsFontEqual(const LOGFONTW *p1, const LOGFONTW *p2)
Definition: style.c:351
#define for
Definition: utility.h:88
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)

Referenced by draw_para_number(), draw_space(), ME_CharFromPointContext(), ME_DestroyContext(), ME_DrawTextWithStyle(), ME_GetTextExtent(), para_num_init(), and shape_run().

◆ set_selection()

int set_selection ( ME_TextEditor editor,
int  to,
int  from 
)

Definition at line 2158 of file editor.c.

2159{
2160 int end;
2161
2162 TRACE("%d - %d\n", to, from );
2163
2164 if (!editor->bHideSelection) ME_InvalidateSelection( editor );
2165 end = set_selection_cursors( editor, to, from );
2166 if (!editor->bHideSelection) ME_InvalidateSelection( editor );
2167 update_caret( editor );
2168 ME_SendSelChange( editor );
2169
2170 return end;
2171}

◆ set_selection_cursors()

int set_selection_cursors ( ME_TextEditor editor,
int  from,
int  to 
)

Definition at line 132 of file caret.c.

133{
134 int selectionEnd = 0;
135 const int len = ME_GetTextLength(editor);
136
137 /* all negative values are effectively the same */
138 if (from < 0)
139 from = -1;
140 if (to < 0)
141 to = -1;
142
143 /* select all */
144 if (from == 0 && to == -1)
145 {
146 ME_SetCursorToStart(editor, &editor->pCursors[1]);
147 ME_SetCursorToEnd(editor, &editor->pCursors[0], TRUE);
148 return len + 1;
149 }
150
151 /* if both values are equal and also out of bound, that means to */
152 /* put the selection at the end of the text */
153 if ((from == to) && (to < 0 || to > len))
154 {
155 selectionEnd = 1;
156 }
157 else
158 {
159 /* if from is negative and to is positive then selection is */
160 /* deselected and caret moved to end of the current selection */
161 if (from < 0)
162 {
163 int start, end;
164 ME_GetSelectionOfs(editor, &start, &end);
165 if (start != end)
166 {
167 if (end > len)
168 {
169 editor->pCursors[0].nOffset = 0;
170 end --;
171 }
172 editor->pCursors[1] = editor->pCursors[0];
173 }
174 return end;
175 }
176
177 /* adjust to if it's a negative value */
178 if (to < 0)
179 to = len + 1;
180
181 /* flip from and to if they are reversed */
182 if (from>to)
183 {
184 int tmp = from;
185 from = to;
186 to = tmp;
187 }
188
189 /* after fiddling with the values, we find from > len && to > len */
190 if (from > len)
191 selectionEnd = 1;
192 /* special case with to too big */
193 else if (to > len)
194 to = len + 1;
195 }
196
197 if (selectionEnd)
198 {
199 ME_SetCursorToEnd(editor, &editor->pCursors[0], FALSE);
200 editor->pCursors[1] = editor->pCursors[0];
201 return len;
202 }
203
204 ME_CursorFromCharOfs(editor, from, &editor->pCursors[1]);
205 editor->pCursors[0] = editor->pCursors[1];
206 ME_MoveCursorChars(editor, &editor->pCursors[0], to - from, FALSE);
207 /* Selection is not allowed in the middle of an end paragraph run. */
208 if (editor->pCursors[1].pRun->member.run.nFlags & MERF_ENDPARA)
209 editor->pCursors[1].nOffset = 0;
210 if (editor->pCursors[0].pRun->member.run.nFlags & MERF_ENDPARA)
211 {
212 if (to > len)
213 editor->pCursors[0].nOffset = editor->pCursors[0].pRun->member.run.len;
214 else
215 editor->pCursors[0].nOffset = 0;
216 }
217 return to;
218}

Referenced by fnTextSrv_TxSetText(), ME_HandleMessage(), ME_StreamIn(), and set_selection().

◆ show_caret()

void show_caret ( ME_TextEditor ed)

Definition at line 282 of file caret.c.

283{
284 ITextHost_TxShowCaret(editor->texthost, TRUE);
285 editor->caret_hidden = FALSE;
286}

Referenced by update_caret().

◆ update_caret()

void update_caret ( ME_TextEditor ed)

Definition at line 298 of file caret.c.

299{
300 int x, y, height;
301
302 if (!editor->bHaveFocus) return;
303 if (!ME_IsSelection(editor))
304 {
305 ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y, &height);
306 if (height != editor->caret_height) create_caret(editor);
307 x = min(x, editor->rcFormat.right-1);
308 ITextHost_TxSetCaretPos(editor->texthost, x, y);
309 show_caret(editor);
310 }
311 else
312 hide_caret(editor);
313#ifdef __REACTOS__
315 {
316 HIMC hIMC = ImmGetContext(editor->hWnd);
317 if (hIMC)
318 {
320 LOGFONTW lf;
321 COMPOSITIONFORM CompForm;
322 POINT pt = { x, y };
323
324 CompForm.ptCurrentPos = pt;
325 if (editor->styleFlags & ES_MULTILINE)
326 {
327 CompForm.dwStyle = CFS_RECT;
328 CompForm.rcArea = editor->rcFormat;
329 }
330 else
331 {
332 CompForm.dwStyle = CFS_POINT;
333 SetRectEmpty(&CompForm.rcArea);
334 }
335 ImmSetCompositionWindow(hIMC, &CompForm);
336
337 fmt.cbSize = sizeof(fmt);
339
340 ZeroMemory(&lf, sizeof(lf));
342 if (fmt.dwMask & CFM_SIZE)
343 {
345 lf.lfHeight = -MulDiv(fmt.yHeight, GetDeviceCaps(hdc, LOGPIXELSY), 1440);
346 DeleteDC(hdc);
347 }
348 if (fmt.dwMask & CFM_CHARSET)
349 lf.lfCharSet = fmt.bCharSet;
350 if (fmt.dwMask & CFM_FACE)
351 lstrcpynW(lf.lfFaceName, fmt.szFaceName, ARRAY_SIZE(lf.lfFaceName));
352 ImmSetCompositionFontW(hIMC, &lf);
353
354 ImmReleaseContext(editor->hWnd, hIMC);
355 }
356 }
357#endif
358}
#define lstrcpynW
Definition: compat.h:738
BOOL WINAPI ImmSetCompositionWindow(HIMC hIMC, LPCOMPOSITIONFORM lpCompForm)
Definition: ime.c:1583
void show_caret(ME_TextEditor *editor)
Definition: caret.c:282
#define ITextHost_TxSetCaretPos(This, a, b)
Definition: editor.h:297
#define CFS_RECT
Definition: imm.h:324
#define CFS_POINT
Definition: imm.h:325
HDC hdc
Definition: main.c:9
RECT rcArea
Definition: dimm.idl:88
DWORD dwStyle
Definition: dimm.idl:86
POINT ptCurrentPos
Definition: dimm.idl:87
#define DEFAULT_CHARSET
Definition: wingdi.h:384

Referenced by ME_ArrowKey(), ME_HandleMessage(), ME_LButtonDown(), ME_MouseMove(), ME_StreamIn(), ME_TabPressedInTable(), ME_WmCreate(), RichEditWndProc_common(), and set_selection().

Variable Documentation

◆ DECLSPEC_HIDDEN

BOOL me_debug DECLSPEC_HIDDEN
extern

Definition at line 257 of file editor.h.