ReactOS 0.4.16-dev-1276-g70732b0
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)
 
#define ITextHost2_TxIsDoubleClickPending(This)   TXTHOST_VTABLE(This)->TxIsDoubleClickPending(This)
 
#define ITextHost2_TxGetWindow(This, a)   TXTHOST_VTABLE(This)->TxGetWindow(This,a)
 
#define ITextHost2_TxSetForegroundWindow(This)   TXTHOST_VTABLE(This)->TxSetForegroundWindow(This)
 
#define ITextHost2_TxGetPalette(This)   TXTHOST_VTABLE(This)->TxGetPalette(This)
 
#define ITextHost2_TxGetEastAsianFlags(This, a)   TXTHOST_VTABLE(This)->TxGetEastAsianFlags(This,a)
 
#define ITextHost2_TxSetCursor2(This, a, b)   TXTHOST_VTABLE(This)->TxSetCursor2(This,a,b)
 
#define ITextHost2_TxFreeTextServicesNotification(This)   TXTHOST_VTABLE(This)->TxFreeTextServicesNotification(This)
 
#define ITextHost2_TxGetEditStyle(This, a, b)   TXTHOST_VTABLE(This)->TxGetEditStyle(This,a,b)
 
#define ITextHost2_TxGetWindowStyles(This, a, b)   TXTHOST_VTABLE(This)->TxGetWindowStyles(This,a,b)
 
#define ITextHost2_TxShowDropCaret(This, a, b, c)   TXTHOST_VTABLE(This)->TxShowDropCaret(This,a,b,c)
 
#define ITextHost2_TxDestroyCaret(This)   TXTHOST_VTABLE(This)->TxDestroyCaret(This)
 
#define ITextHost2_TxGetHorzExtent(This, a)   TXTHOST_VTABLE(This)->TxGetHorzExtent(This,a)
 
#define TXTSERV_VTABLE(This)   (This)->lpVtbl
 
#define ITextServices_TxSendMessage(This, a, b, c, d)   TXTSERV_VTABLE(This)->TxSendMessage(This,a,b,c,d)
 
#define ITextServices_TxDraw(This, a, b, c, d, e, f, g, h, i, j, k, l)   TXTSERV_VTABLE(This)->TxDraw(This,a,b,c,d,e,f,g,h,i,j,k,l)
 
#define ITextServices_TxGetHScroll(This, a, b, c, d, e)   TXTSERV_VTABLE(This)->TxGetHScroll(This,a,b,c,d,e)
 
#define ITextServices_TxGetVScroll(This, a, b, c, d, e)   TXTSERV_VTABLE(This)->TxGetVScroll(This,a,b,c,d,e)
 
#define ITextServices_OnTxSetCursor(This, a, b, c, d, e, f, g, h, i)   TXTSERV_VTABLE(This)->OnTxSetCursor(This,a,b,c,d,e,f,g,h,i)
 
#define ITextServices_TxQueryHitPoint(This, a, b, c, d, e, f, g, h, i, j)   TXTSERV_VTABLE(This)->TxQueryHitPoint(This,a,b,c,d,e,f,g,h,i,j)
 
#define ITextServices_OnTxInPlaceActivate(This, a)   TXTSERV_VTABLE(This)->OnTxInPlaceActivate(This,a)
 
#define ITextServices_OnTxInPlaceDeactivate(This)   TXTSERV_VTABLE(This)->OnTxInPlaceDeactivate(This)
 
#define ITextServices_OnTxUIActivate(This)   TXTSERV_VTABLE(This)->OnTxUIActivate(This)
 
#define ITextServices_OnTxUIDeactivate(This)   TXTSERV_VTABLE(This)->OnTxUIDeactivate(This)
 
#define ITextServices_TxGetText(This, a)   TXTSERV_VTABLE(This)->TxGetText(This,a)
 
#define ITextServices_TxSetText(This, a)   TXTSERV_VTABLE(This)->TxSetText(This,a)
 
#define ITextServices_TxGetCurTargetX(This, a)   TXTSERV_VTABLE(This)->TxGetCurTargetX(This,a)
 
#define ITextServices_TxGetBaseLinePos(This, a)   TXTSERV_VTABLE(This)->TxGetBaseLinePos(This,a)
 
#define ITextServices_TxGetNaturalSize(This, a, b, c, d, e, f, g, h)   TXTSERV_VTABLE(This)->TxGetNaturalSize(This,a,b,c,d,e,f,g,h)
 
#define ITextServices_TxGetDropTarget(This, a)   TXTSERV_VTABLE(This)->TxGetDropTarget(This,a)
 
#define ITextServices_OnTxPropertyBitsChange(This, a, b)   TXTSERV_VTABLE(This)->OnTxPropertyBitsChange(This,a,b)
 
#define ITextServices_TxGetCachedSize(This, a, b)   TXTSERV_VTABLE(This)->TxGetCachedSize(This,a,b)
 

Functions

static WCHARget_text (const ME_Run *run, int offset)
 
static const chardebugstr_run (const ME_Run *run)
 
ME_Stylestyle_get_insert_style (ME_TextEditor *editor, ME_Cursor *cursor)
 
ME_StyleME_MakeStyle (CHARFORMAT2W *style)
 
void ME_AddRefStyle (ME_Style *item)
 
void ME_DestroyStyle (ME_Style *item)
 
void ME_ReleaseStyle (ME_Style *item)
 
ME_StyleME_ApplyStyle (ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style)
 
void select_style (ME_Context *c, ME_Style *s)
 
void ME_InitCharFormat2W (CHARFORMAT2W *pFmt)
 
void ME_SaveTempStyle (ME_TextEditor *editor, ME_Style *style)
 
void ME_ClearTempStyle (ME_TextEditor *editor)
 
void ME_DumpStyleToBuf (CHARFORMAT2W *pFmt, char buf[2048])
 
void ME_DumpStyle (ME_Style *s)
 
BOOL cfany_to_cf2w (CHARFORMAT2W *to, const CHARFORMAT2W *from)
 
BOOL cf2w_to_cfany (CHARFORMAT2W *to, const CHARFORMAT2W *from)
 
void ME_CopyCharFormat (CHARFORMAT2W *pDest, const CHARFORMAT2W *pSrc)
 
void ME_CharFormatFromLogFont (HDC hDC, const LOGFONTW *lf, CHARFORMAT2W *fmt)
 
void ME_InsertBefore (ME_DisplayItem *diWhere, ME_DisplayItem *diWhat)
 
void ME_Remove (ME_DisplayItem *diWhere)
 
ME_DisplayItemME_FindItemBack (ME_DisplayItem *di, ME_DIType nTypeOrClass)
 
ME_DisplayItemME_FindItemFwd (ME_DisplayItem *di, ME_DIType nTypeOrClass)
 
ME_DisplayItemME_FindItemBackOrHere (ME_DisplayItem *di, ME_DIType nTypeOrClass)
 
ME_DisplayItemME_MakeDI (ME_DIType type)
 
void ME_DestroyDisplayItem (ME_DisplayItem *item)
 
void ME_DumpDocument (ME_TextBuffer *buffer)
 
ME_StringME_MakeStringN (LPCWSTR szText, int nMaxChars)
 
ME_StringME_MakeStringR (WCHAR cRepeat, int nMaxChars)
 
ME_StringME_MakeStringConst (const WCHAR *str, int len)
 
ME_StringME_MakeStringEmpty (int len)
 
void ME_DestroyString (ME_String *s)
 
BOOL ME_AppendString (ME_String *s, const WCHAR *append, int len)
 
ME_StringME_VSplitString (ME_String *orig, int nVPos)
 
int ME_FindNonWhitespaceV (const ME_String *s, int nVChar)
 
int ME_CallWordBreakProc (ME_TextEditor *editor, WCHAR *str, INT len, INT start, INT code)
 
void ME_StrDeleteV (ME_String *s, int nVChar, int nChars)
 
BOOL ME_InsertString (ME_String *s, int ofs, const WCHAR *insert, int len)
 
LPWSTR ME_ToUnicode (LONG codepage, LPVOID psz, INT *len)
 
void ME_EndToUnicode (LONG codepage, LPVOID psz)
 
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)
 
int ME_ReverseFindWhitespaceV (const ME_String *s, int nVChar)
 
void row_end_cursor (ME_Row *row, ME_Cursor *cursor, BOOL include_eop)
 
void row_first_cursor (ME_Row *row, ME_Cursor *cursor)
 
ME_Runrow_first_run (ME_Row *row)
 
ME_Rowrow_from_cursor (ME_Cursor *cursor)
 
ME_Rowrow_from_row_number (ME_TextEditor *editor, int row_num)
 
ME_Rowrow_next (ME_Row *row)
 
ME_Rowrow_next_all_paras (ME_Row *row)
 
ME_Runrow_next_run (ME_Row *row, ME_Run *run)
 
int row_number_from_char_ofs (ME_TextEditor *editor, int ofs)
 
ME_Paragraphrow_para (ME_Row *row)
 
ME_Rowrow_prev_all_paras (ME_Row *row)
 
static ME_DisplayItemrow_get_di (ME_Row *row)
 
void cursor_from_char_ofs (ME_TextEditor *editor, int char_ofs, ME_Cursor *cursor)
 
BOOL cursor_next_run (ME_Cursor *cursor, BOOL all_para)
 
BOOL cursor_prev_run (ME_Cursor *cursor, BOOL all_para)
 
void editor_propagate_char_ofs (ME_TextEditor *editor, ME_Paragraph *para, ME_Run *run, int shift)
 
int run_char_ofs (ME_Run *run, int ofs)
 
ME_Runrun_create (ME_Style *s, int nFlags)
 
ME_Runrun_insert (ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style, const WCHAR *str, int len, int flags)
 
void ME_CheckCharOffsets (ME_TextEditor *editor)
 
int ME_CharFromPointContext (ME_Context *c, int cx, ME_Run *run, BOOL closest, BOOL visual_order)
 
int ME_CharFromPoint (ME_TextEditor *editor, int cx, ME_Run *run, BOOL closest, BOOL visual_order)
 
int ME_PointFromCharContext (ME_Context *c, ME_Run *pRun, int nOffset, BOOL visual_order)
 
int ME_PointFromChar (ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order)
 
BOOL ME_CanJoinRuns (const ME_Run *run1, const ME_Run *run2)
 
void run_join (ME_TextEditor *editor, ME_Run *run)
 
ME_Runrun_next (ME_Run *run)
 
ME_Runrun_next_all_paras (ME_Run *run)
 
ME_Runrun_prev (ME_Run *run)
 
ME_Runrun_prev_all_paras (ME_Run *run)
 
ME_Runrun_split (ME_TextEditor *editor, ME_Cursor *cursor)
 
void ME_UpdateRunFlags (ME_TextEditor *editor, ME_Run *run)
 
SIZE ME_GetRunSizeCommon (ME_Context *c, const ME_Paragraph *para, ME_Run *run, int nLen, int startx, int *pAscent, int *pDescent)
 
void ME_SetCharFormat (ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *pFmt)
 
void ME_SetSelectionCharFormat (ME_TextEditor *editor, CHARFORMAT2W *pFmt)
 
void ME_GetCharFormat (ME_TextEditor *editor, const ME_Cursor *from, const ME_Cursor *to, CHARFORMAT2W *pFmt)
 
void ME_GetSelectionCharFormat (ME_TextEditor *editor, CHARFORMAT2W *pFmt)
 
void ME_GetDefaultCharFormat (ME_TextEditor *editor, CHARFORMAT2W *pFmt)
 
void ME_SetDefaultCharFormat (ME_TextEditor *editor, CHARFORMAT2W *mod)
 
static ME_DisplayItemrun_get_di (ME_Run *run)
 
void cursor_coords (ME_TextEditor *editor, ME_Cursor *cursor, int *x, int *y, int *height)
 
BOOL cursor_from_coords (ME_TextEditor *editor, int x, int y, ME_Cursor *cursor)
 
void ME_SetCursorToStart (ME_TextEditor *editor, ME_Cursor *cursor)
 
int set_selection_cursors (ME_TextEditor *editor, int from, int to)
 
BOOL ME_MoveCursorWords (ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
 
void hide_caret (ME_TextEditor *ed)
 
void show_caret (ME_TextEditor *ed)
 
void update_caret (ME_TextEditor *ed)
 
void create_caret (ME_TextEditor *ed)
 
void ME_LButtonDown (ME_TextEditor *editor, int x, int y, int clickNum)
 
void ME_MouseMove (ME_TextEditor *editor, int x, int y)
 
BOOL ME_DeleteTextAtCursor (ME_TextEditor *editor, int nCursor, int nChars)
 
void ME_InsertTextFromCursor (ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style)
 
void ME_InsertEndRowFromCursor (ME_TextEditor *editor, int nCursor)
 
int ME_MoveCursorChars (ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BOOL final_eop)
 
BOOL ME_ArrowKey (ME_TextEditor *ed, int nVKey, BOOL extend, BOOL ctrl)
 
int ME_GetCursorOfs (const ME_Cursor *cursor)
 
int ME_GetSelectionOfs (ME_TextEditor *editor, LONG *from, LONG *to)
 
int ME_GetSelection (ME_TextEditor *editor, ME_Cursor **from, ME_Cursor **to)
 
BOOL ME_IsSelection (ME_TextEditor *editor)
 
void ME_DeleteSelection (ME_TextEditor *editor)
 
void ME_SendSelChange (ME_TextEditor *editor)
 
HRESULT editor_insert_oleobj (ME_TextEditor *editor, const REOBJECT *reo)
 
BOOL ME_InternalDeleteText (ME_TextEditor *editor, ME_Cursor *start, int nChars, BOOL bForce)
 
int ME_GetTextLength (ME_TextEditor *editor)
 
int ME_GetTextLengthEx (ME_TextEditor *editor, const GETTEXTLENGTHEX *how)
 
ME_StyleME_GetSelectionInsertStyle (ME_TextEditor *editor)
 
void ME_InitContext (ME_Context *c, ME_TextEditor *editor, HDC hDC)
 
void ME_DestroyContext (ME_Context *c)
 
BOOL ME_WrapMarkedParagraphs (ME_TextEditor *editor)
 
void para_range_invalidate (ME_TextEditor *editor, ME_Paragraph *start_para, ME_Paragraph *last_para)
 
void ME_SendRequestResize (ME_TextEditor *editor, BOOL force)
 
BOOL wrap_marked_paras_dc (ME_TextEditor *editor, HDC hdc, BOOL invalidate)
 
void editor_get_selection_paras (ME_TextEditor *editor, ME_Paragraph **para, ME_Paragraph **para_end)
 
void editor_get_selection_para_fmt (ME_TextEditor *editor, PARAFORMAT2 *fmt)
 
void editor_mark_rewrap_all (ME_TextEditor *editor)
 
void editor_set_default_para_fmt (ME_TextEditor *editor, PARAFORMAT2 *pFmt)
 
BOOL editor_set_selection_para_fmt (ME_TextEditor *editor, const PARAFORMAT2 *fmt)
 
void ME_MakeFirstParagraph (ME_TextEditor *editor, HDC hdc)
 
void ME_DumpParaStyle (ME_Paragraph *s)
 
void ME_DumpParaStyleToBuf (const PARAFORMAT2 *pFmt, char buf[2048])
 
int get_total_width (ME_TextEditor *editor)
 
ME_Cellpara_cell (ME_Paragraph *para)
 
void para_destroy (ME_TextEditor *editor, ME_Paragraph *item)
 
ME_Rowpara_end_row (ME_Paragraph *para)
 
ME_Runpara_end_run (ME_Paragraph *para)
 
ME_Rowpara_first_row (ME_Paragraph *para)
 
ME_Runpara_first_run (ME_Paragraph *para)
 
BOOL para_in_table (ME_Paragraph *para)
 
ME_Paragraphpara_join (ME_TextEditor *editor, ME_Paragraph *para, BOOL use_first_fmt)
 
void para_mark_add (ME_TextEditor *editor, ME_Paragraph *para)
 
void para_mark_remove (ME_TextEditor *editor, ME_Paragraph *para)
 
void para_mark_rewrap (ME_TextEditor *editor, ME_Paragraph *para)
 
ME_Paragraphpara_next (ME_Paragraph *para)
 
void para_num_clear (struct para_num *pn)
 
void para_num_init (ME_Context *c, ME_Paragraph *para)
 
ME_Paragraphpara_prev (ME_Paragraph *para)
 
ME_Paragraphpara_split (ME_TextEditor *editor, ME_Run *run, ME_Style *style, const WCHAR *eol_str, int eol_len, int paraFlags)
 
static ME_DisplayItempara_get_di (ME_Paragraph *para)
 
void editor_draw (ME_TextEditor *editor, HDC hDC, const RECT *update)
 
void ME_Repaint (ME_TextEditor *editor)
 
void ME_RewrapRepaint (ME_TextEditor *editor)
 
void ME_UpdateRepaint (ME_TextEditor *editor, BOOL update_now)
 
void editor_ensure_visible (ME_TextEditor *editor, ME_Cursor *cursor)
 
void ME_InvalidateSelection (ME_TextEditor *editor)
 
BOOL ME_SetZoom (ME_TextEditor *editor, int numerator, int denominator)
 
int ME_twips2pointsX (const ME_Context *c, int x)
 
int ME_twips2pointsY (const ME_Context *c, int y)
 
void scroll_abs (ME_TextEditor *editor, int x, int y, BOOL notify)
 
void scroll_h_abs (ME_TextEditor *editor, int x, BOOL notify)
 
void scroll_v_abs (ME_TextEditor *editor, int y, BOOL notify)
 
void ME_ScrollUp (ME_TextEditor *editor, int cy)
 
void ME_ScrollDown (ME_TextEditor *editor, int cy)
 
void ME_ScrollLeft (ME_TextEditor *editor, int cx)
 
void ME_ScrollRight (ME_TextEditor *editor, int cx)
 
void ME_UpdateScrollBar (ME_TextEditor *editor)
 
int ME_GetParaBorderWidth (const ME_Context *c, int flags)
 
void draw_ole (ME_Context *c, int x, int y, ME_Run *run, BOOL selected)
 
void ME_GetOLEObjectSize (const ME_Context *c, ME_Run *run, SIZE *pSize)
 
void ME_CopyReObject (REOBJECT *dst, const REOBJECT *src, DWORD flags)
 
void ME_DeleteReObject (struct re_object *re_object)
 
void richole_release_children (struct text_services *services)
 
ME_TextEditorME_MakeEditor (ITextHost *texthost, BOOL bEmulateVersion10)
 
void ME_DestroyEditor (ME_TextEditor *editor)
 
LRESULT editor_handle_message (ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam, HRESULT *phresult)
 
int ME_GetTextW (ME_TextEditor *editor, WCHAR *buffer, int buflen, const ME_Cursor *start, int srcChars, BOOL bCRLF, BOOL bEOP)
 
void ME_RTFCharAttrHook (struct _RTF_Info *info)
 
void ME_RTFParAttrHook (struct _RTF_Info *info)
 
void ME_RTFTblAttrHook (struct _RTF_Info *info)
 
void ME_RTFSpecialCharHook (struct _RTF_Info *info)
 
void ME_StreamInFill (ME_InStream *stream)
 
void ME_ReplaceSel (ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len)
 
int set_selection (ME_TextEditor *editor, int to, int from)
 
HRESULT editor_copy_or_cut (ME_TextEditor *editor, BOOL cut, ME_Cursor *start, int count, IDataObject **data_out)
 
ME_Paragrapheditor_end_para (ME_TextEditor *editor)
 
ME_Paragrapheditor_first_para (ME_TextEditor *editor)
 
void editor_set_cursor (ME_TextEditor *editor, int x, int y)
 
void link_notify (ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
 
ME_Cellcell_create (void)
 
ME_Paragraphcell_end_para (ME_Cell *cell)
 
ME_Paragraphcell_first_para (ME_Cell *cell)
 
ME_Cellcell_next (ME_Cell *cell)
 
ME_Cellcell_prev (ME_Cell *cell)
 
ME_Paragraphtable_append_row (ME_TextEditor *editor, ME_Paragraph *table_row)
 
void table_handle_tab (ME_TextEditor *editor, BOOL selected_row)
 
ME_Paragraphtable_insert_cell (ME_TextEditor *editor, ME_Cursor *cursor)
 
ME_Paragraphtable_insert_row_end (ME_TextEditor *editor, ME_Cursor *cursor)
 
ME_Paragraphtable_insert_row_start (ME_TextEditor *editor, ME_Cursor *cursor)
 
ME_Paragraphtable_insert_row_start_at_para (ME_TextEditor *editor, ME_Paragraph *para)
 
void table_move_from_row_start (ME_TextEditor *editor)
 
ME_Paragraphtable_outer_para (ME_Paragraph *para)
 
void table_protect_partial_deletion (ME_TextEditor *editor, ME_Cursor *c, int *num_chars)
 
ME_Paragraphtable_row_end (ME_Paragraph *para)
 
ME_Celltable_row_end_cell (ME_Paragraph *para)
 
ME_Celltable_row_first_cell (ME_Paragraph *para)
 
ME_Paragraphtable_row_start (ME_Paragraph *para)
 
struct RTFTableME_MakeTableDef (ME_TextEditor *editor)
 
void ME_InitTableDef (ME_TextEditor *editor, struct RTFTable *tableDef)
 
static ME_DisplayItemcell_get_di (ME_Cell *cell)
 
BOOL add_undo_insert_run (ME_TextEditor *, int pos, const WCHAR *str, int len, int flags, ME_Style *style)
 
BOOL add_undo_delete_run (ME_TextEditor *, int pos, int len)
 
BOOL add_undo_set_para_fmt (ME_TextEditor *, const ME_Paragraph *para)
 
BOOL add_undo_set_char_fmt (ME_TextEditor *, int pos, int len, const CHARFORMAT2W *fmt)
 
BOOL add_undo_join_paras (ME_TextEditor *, int pos)
 
BOOL add_undo_split_para (ME_TextEditor *, const ME_Paragraph *para, ME_String *eol_str, const ME_Cell *cell)
 
void ME_CommitUndo (ME_TextEditor *editor)
 
void ME_ContinueCoalescingTransaction (ME_TextEditor *editor)
 
void ME_CommitCoalescingUndo (ME_TextEditor *editor)
 
BOOL ME_Undo (ME_TextEditor *editor)
 
BOOL ME_Redo (ME_TextEditor *editor)
 
void ME_EmptyUndoStack (ME_TextEditor *editor)
 
void editor_disable_undo (ME_TextEditor *editor)
 
void editor_enable_undo (ME_TextEditor *editor)
 
static BOOL editor_undo_ignored (ME_TextEditor *editor)
 
HRESULT create_text_services (IUnknown *outer, ITextHost *text_host, IUnknown **unk, BOOL emulate_10)
 
LRESULT ME_StreamOutRange (ME_TextEditor *editor, DWORD dwFormat, const ME_Cursor *start, int nChars, EDITSTREAM *stream)
 
LRESULT ME_StreamOut (ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream)
 
HRESULT ME_GetDataObject (ME_TextEditor *editor, const ME_Cursor *start, int nChars, LPDATAOBJECT *lplpdataobj)
 
void release_typelib (void)
 

Variables

HINSTANCE dll_instance
 
const IRichEditOleVtbl re_ole_vtbl
 
const ITextDocument2OldVtbl text_doc2old_vtbl
 
BOOL me_debug
 

Macro Definition Documentation

◆ CP_UNICODE

#define CP_UNICODE   1200

Definition at line 92 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;\
};
_In_ size_t const _In_ int _In_ bool const _In_ unsigned const _In_ __acrt_rounding_mode const _Inout_ __crt_cached_ptd_host & ptd
Definition: cvt.cpp:355
#define NULL
Definition: types.h:112
static DWORD tymed
Definition: url.c:174

Definition at line 32 of file editor.h.

◆ ITextHost2_TxDestroyCaret

#define ITextHost2_TxDestroyCaret (   This)    TXTHOST_VTABLE(This)->TxDestroyCaret(This)

Definition at line 382 of file editor.h.

◆ ITextHost2_TxFreeTextServicesNotification

#define ITextHost2_TxFreeTextServicesNotification (   This)    TXTHOST_VTABLE(This)->TxFreeTextServicesNotification(This)

Definition at line 378 of file editor.h.

◆ ITextHost2_TxGetEastAsianFlags

#define ITextHost2_TxGetEastAsianFlags (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetEastAsianFlags(This,a)

Definition at line 376 of file editor.h.

◆ ITextHost2_TxGetEditStyle

#define ITextHost2_TxGetEditStyle (   This,
  a,
  b 
)    TXTHOST_VTABLE(This)->TxGetEditStyle(This,a,b)

Definition at line 379 of file editor.h.

◆ ITextHost2_TxGetHorzExtent

#define ITextHost2_TxGetHorzExtent (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetHorzExtent(This,a)

Definition at line 383 of file editor.h.

◆ ITextHost2_TxGetPalette

#define ITextHost2_TxGetPalette (   This)    TXTHOST_VTABLE(This)->TxGetPalette(This)

Definition at line 375 of file editor.h.

◆ ITextHost2_TxGetWindow

#define ITextHost2_TxGetWindow (   This,
  a 
)    TXTHOST_VTABLE(This)->TxGetWindow(This,a)

Definition at line 373 of file editor.h.

◆ ITextHost2_TxGetWindowStyles

#define ITextHost2_TxGetWindowStyles (   This,
  a,
  b 
)    TXTHOST_VTABLE(This)->TxGetWindowStyles(This,a,b)

Definition at line 380 of file editor.h.

◆ ITextHost2_TxIsDoubleClickPending

#define ITextHost2_TxIsDoubleClickPending (   This)    TXTHOST_VTABLE(This)->TxIsDoubleClickPending(This)

Definition at line 372 of file editor.h.

◆ ITextHost2_TxSetCursor2

#define ITextHost2_TxSetCursor2 (   This,
  a,
  b 
)    TXTHOST_VTABLE(This)->TxSetCursor2(This,a,b)

Definition at line 377 of file editor.h.

◆ ITextHost2_TxSetForegroundWindow

#define ITextHost2_TxSetForegroundWindow (   This)    TXTHOST_VTABLE(This)->TxSetForegroundWindow(This)

Definition at line 374 of file editor.h.

◆ ITextHost2_TxShowDropCaret

#define ITextHost2_TxShowDropCaret (   This,
  a,
  b,
  c 
)    TXTHOST_VTABLE(This)->TxShowDropCaret(This,a,b,c)

Definition at line 381 of file editor.h.

◆ ITextHost_OnTxCharFormatChange

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

Definition at line 364 of file editor.h.

◆ ITextHost_OnTxParaFormatChange

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

Definition at line 365 of file editor.h.

◆ ITextHost_TxActivate

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

Definition at line 351 of file editor.h.

◆ ITextHost_TxClientToScreen

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

Definition at line 350 of file editor.h.

◆ ITextHost_TxCreateCaret

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

Definition at line 340 of file editor.h.

◆ ITextHost_TxDeactivate

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

Definition at line 352 of file editor.h.

◆ ITextHost_TxEnableScrollBar

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

Definition at line 335 of file editor.h.

◆ ITextHost_TxGetAcceleratorPos

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

Definition at line 362 of file editor.h.

◆ ITextHost_TxGetBackStyle

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

Definition at line 358 of file editor.h.

◆ ITextHost_TxGetCharFormat

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

Definition at line 355 of file editor.h.

◆ ITextHost_TxGetClientRect

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

Definition at line 353 of file editor.h.

◆ ITextHost_TxGetDC

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

Definition at line 332 of file editor.h.

◆ ITextHost_TxGetExtent

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

Definition at line 363 of file editor.h.

◆ ITextHost_TxGetMaxLength

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

Definition at line 359 of file editor.h.

◆ ITextHost_TxGetParaFormat

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

Definition at line 356 of file editor.h.

◆ ITextHost_TxGetPasswordChar

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

Definition at line 361 of file editor.h.

◆ ITextHost_TxGetPropertyBits

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

Definition at line 366 of file editor.h.

◆ ITextHost_TxGetScrollBars

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

Definition at line 360 of file editor.h.

◆ ITextHost_TxGetSelectionBarWidth

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

Definition at line 370 of file editor.h.

◆ ITextHost_TxGetSysColor

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

Definition at line 357 of file editor.h.

◆ ITextHost_TxGetViewInset

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

Definition at line 354 of file editor.h.

◆ ITextHost_TxImmGetContext

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

Definition at line 368 of file editor.h.

◆ ITextHost_TxImmReleaseContext

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

Definition at line 369 of file editor.h.

◆ ITextHost_TxInvalidateRect

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

Definition at line 338 of file editor.h.

◆ ITextHost_TxKillTimer

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

Definition at line 344 of file editor.h.

◆ ITextHost_TxNotify

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

Definition at line 367 of file editor.h.

◆ ITextHost_TxReleaseDC

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

Definition at line 333 of file editor.h.

◆ ITextHost_TxScreenToClient

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

Definition at line 349 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 345 of file editor.h.

◆ ITextHost_TxSetCapture

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

Definition at line 346 of file editor.h.

◆ ITextHost_TxSetCaretPos

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

Definition at line 342 of file editor.h.

◆ ITextHost_TxSetCursor

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

Definition at line 348 of file editor.h.

◆ ITextHost_TxSetFocus

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

Definition at line 347 of file editor.h.

◆ ITextHost_TxSetScrollPos

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

Definition at line 337 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 336 of file editor.h.

◆ ITextHost_TxSetTimer

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

Definition at line 343 of file editor.h.

◆ ITextHost_TxShowCaret

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

Definition at line 341 of file editor.h.

◆ ITextHost_TxShowScrollBar

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

Definition at line 334 of file editor.h.

◆ ITextHost_TxViewChange

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

Definition at line 339 of file editor.h.

◆ ITextServices_OnTxInPlaceActivate

#define ITextServices_OnTxInPlaceActivate (   This,
  a 
)    TXTSERV_VTABLE(This)->OnTxInPlaceActivate(This,a)

Definition at line 420 of file editor.h.

◆ ITextServices_OnTxInPlaceDeactivate

#define ITextServices_OnTxInPlaceDeactivate (   This)    TXTSERV_VTABLE(This)->OnTxInPlaceDeactivate(This)

Definition at line 421 of file editor.h.

◆ ITextServices_OnTxPropertyBitsChange

#define ITextServices_OnTxPropertyBitsChange (   This,
  a,
  b 
)    TXTSERV_VTABLE(This)->OnTxPropertyBitsChange(This,a,b)

Definition at line 430 of file editor.h.

◆ ITextServices_OnTxSetCursor

#define ITextServices_OnTxSetCursor (   This,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i 
)    TXTSERV_VTABLE(This)->OnTxSetCursor(This,a,b,c,d,e,f,g,h,i)

Definition at line 418 of file editor.h.

◆ ITextServices_OnTxUIActivate

#define ITextServices_OnTxUIActivate (   This)    TXTSERV_VTABLE(This)->OnTxUIActivate(This)

Definition at line 422 of file editor.h.

◆ ITextServices_OnTxUIDeactivate

#define ITextServices_OnTxUIDeactivate (   This)    TXTSERV_VTABLE(This)->OnTxUIDeactivate(This)

Definition at line 423 of file editor.h.

◆ ITextServices_TxDraw

#define ITextServices_TxDraw (   This,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j,
  k,
  l 
)    TXTSERV_VTABLE(This)->TxDraw(This,a,b,c,d,e,f,g,h,i,j,k,l)

Definition at line 415 of file editor.h.

◆ ITextServices_TxGetBaseLinePos

#define ITextServices_TxGetBaseLinePos (   This,
  a 
)    TXTSERV_VTABLE(This)->TxGetBaseLinePos(This,a)

Definition at line 427 of file editor.h.

◆ ITextServices_TxGetCachedSize

#define ITextServices_TxGetCachedSize (   This,
  a,
  b 
)    TXTSERV_VTABLE(This)->TxGetCachedSize(This,a,b)

Definition at line 431 of file editor.h.

◆ ITextServices_TxGetCurTargetX

#define ITextServices_TxGetCurTargetX (   This,
  a 
)    TXTSERV_VTABLE(This)->TxGetCurTargetX(This,a)

Definition at line 426 of file editor.h.

◆ ITextServices_TxGetDropTarget

#define ITextServices_TxGetDropTarget (   This,
  a 
)    TXTSERV_VTABLE(This)->TxGetDropTarget(This,a)

Definition at line 429 of file editor.h.

◆ ITextServices_TxGetHScroll

#define ITextServices_TxGetHScroll (   This,
  a,
  b,
  c,
  d,
  e 
)    TXTSERV_VTABLE(This)->TxGetHScroll(This,a,b,c,d,e)

Definition at line 416 of file editor.h.

◆ ITextServices_TxGetNaturalSize

#define ITextServices_TxGetNaturalSize (   This,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h 
)    TXTSERV_VTABLE(This)->TxGetNaturalSize(This,a,b,c,d,e,f,g,h)

Definition at line 428 of file editor.h.

◆ ITextServices_TxGetText

#define ITextServices_TxGetText (   This,
  a 
)    TXTSERV_VTABLE(This)->TxGetText(This,a)

Definition at line 424 of file editor.h.

◆ ITextServices_TxGetVScroll

#define ITextServices_TxGetVScroll (   This,
  a,
  b,
  c,
  d,
  e 
)    TXTSERV_VTABLE(This)->TxGetVScroll(This,a,b,c,d,e)

Definition at line 417 of file editor.h.

◆ ITextServices_TxQueryHitPoint

#define ITextServices_TxQueryHitPoint (   This,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
  j 
)    TXTSERV_VTABLE(This)->TxQueryHitPoint(This,a,b,c,d,e,f,g,h,i,j)

Definition at line 419 of file editor.h.

◆ ITextServices_TxSendMessage

#define ITextServices_TxSendMessage (   This,
  a,
  b,
  c,
  d 
)    TXTSERV_VTABLE(This)->TxSendMessage(This,a,b,c,d)

Definition at line 414 of file editor.h.

◆ ITextServices_TxSetText

#define ITextServices_TxSetText (   This,
  a 
)    TXTSERV_VTABLE(This)->TxSetText(This,a)

Definition at line 425 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 329 of file editor.h.

◆ TXTSERV_VTABLE

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

Definition at line 412 of file editor.h.

Function Documentation

◆ 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:296
GLenum GLsizei len
Definition: glext.h:6722
struct delete_run_item delete_run
Definition: editstr.h:354
union undo_item::@596 u
static struct undo_item * add_undo(ME_TextEditor *editor, enum undo_type type)
Definition: undo.c:72

Referenced by run_insert().

◆ 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 = malloc( (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}
#define malloc
Definition: debug_ros.c:4
void ME_AddRefStyle(ME_Style *item)
Definition: style.c:454
@ undo_insert_run
Definition: editstr.h:295
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:353
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:297
struct join_paras_item join_paras
Definition: editstr.h:355

Referenced by para_split().

◆ 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:300
Definition: dsound.c:943
struct set_char_fmt_item set_char_fmt
Definition: editstr.h:358

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:299
ME_BorderRect border
Definition: editstr.h:208
PARAFORMAT2 fmt
Definition: editstr.h:204
struct set_para_fmt_item set_para_fmt
Definition: editstr.h:357

Referenced by ME_PlayUndoItem(), para_join(), and para_set_fmt().

◆ 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:298
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:55
struct split_para_item split_para
Definition: editstr.h:356

Referenced by para_join().

◆ cell_create()

ME_Cell * cell_create ( void  )

Definition at line 186 of file table.c.

187{
189 return &item->member.cell;
190}
ME_DisplayItem * ME_MakeDI(ME_DIType type)
Definition: list.c:133
@ diCell
Definition: editstr.h:84
static ATOM item
Definition: dde.c:856

Referenced by para_split().

◆ cell_end_para()

ME_Paragraph * cell_end_para ( ME_Cell cell)

Definition at line 207 of file table.c.

208{
209 ME_Cell *next = cell_next( cell );
210
211 if (!next) return cell_first_para( cell ); /* End of row */
212
214}
ME_Paragraph * cell_first_para(ME_Cell *cell)
Definition: table.c:202
ME_Cell * cell_next(ME_Cell *cell)
Definition: table.c:192
ME_DisplayItem * ME_FindItemBack(ME_DisplayItem *di, ME_DIType nTypeOrClass)
Definition: list.c:66
static ME_DisplayItem * cell_get_di(ME_Cell *cell)
Definition: editor.h:318
@ diParagraph
Definition: editstr.h:83
static unsigned __int64 next
Definition: rand_nt.c:6
union tagME_DisplayItem::@595 member
ME_Paragraph para
Definition: editstr.h:262

Referenced by adjust_para_y(), cursor_move_line(), draw_table_borders(), editor_draw(), and table_select_next_cell_or_append().

◆ cell_first_para()

ME_Paragraph * cell_first_para ( ME_Cell cell)

Definition at line 202 of file table.c.

203{
204 return &ME_FindItemFwd( cell_get_di( cell ), diParagraph )->member.para;
205}
ME_DisplayItem * ME_FindItemFwd(ME_DisplayItem *di, ME_DIType nTypeOrClass)
Definition: list.c:89

Referenced by cell_end_para(), cursor_move_line(), draw_table_borders(), editor_draw(), ME_RTFSpecialCharHook(), pixel_pos_in_table_row(), and table_select_next_cell_or_append().

◆ cell_get_di()

static ME_DisplayItem * cell_get_di ( ME_Cell cell)
inlinestatic

Definition at line 318 of file editor.h.

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

Referenced by cell_end_para(), cell_first_para(), para_join(), para_split(), table_outer_para(), table_row_end(), and table_row_start().

◆ cell_next()

◆ cell_prev()

ME_Cell * cell_prev ( ME_Cell cell)

Definition at line 197 of file table.c.

198{
199 return cell->prev_cell;
200}
struct tagME_Cell * prev_cell
Definition: editstr.h:229

Referenced by adjust_para_y(), cursor_move_line(), ME_BeginRow(), ME_RTFSpecialCharHook(), para_join(), para_split(), and table_row_start().

◆ 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:1751

Referenced by editor_handle_message().

◆ 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:20
#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:1753

Referenced by handle_EM_SETCHARFORMAT(), and ME_MakeFirstParagraph().

◆ create_caret()

void create_caret ( ME_TextEditor ed)

Definition at line 251 of file caret.c.

252{
253 int x, y, height;
254
255 cursor_coords( editor, &editor->pCursors[0], &x, &y, &height );
256 ITextHost_TxCreateCaret(editor->texthost, NULL, 0, height);
257 editor->caret_height = height;
258 editor->caret_hidden = TRUE;
259}
void cursor_coords(ME_TextEditor *editor, ME_Cursor *cursor, int *x, int *y, int *height)
Definition: caret.c:221
#define ITextHost_TxCreateCaret(This, a, b, c)
Definition: editor.h:340
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 editor_handle_message(), and update_caret().

◆ create_text_services()

HRESULT create_text_services ( IUnknown outer,
ITextHost *  text_host,
IUnknown **  unk,
BOOL  emulate_10 
)

Definition at line 579 of file txtsrv.c.

580{
581 struct text_services *services;
582
583 TRACE( "%p %p --> %p\n", outer, text_host, unk );
584 if (text_host == NULL) return E_POINTER;
585
586 services = malloc( sizeof(*services) );
587 if (services == NULL) return E_OUTOFMEMORY;
588 services->ref = 1;
589 services->IUnknown_inner.lpVtbl = &textservices_inner_vtbl;
590 services->ITextServices_iface.lpVtbl = &textservices_vtbl;
591 services->IRichEditOle_iface.lpVtbl = &re_ole_vtbl;
592 services->ITextDocument2Old_iface.lpVtbl = &text_doc2old_vtbl;
593 services->editor = ME_MakeEditor( text_host, emulate_10 );
594 services->editor->richole = &services->IRichEditOle_iface;
595
596 if (outer) services->outer_unk = outer;
597 else services->outer_unk = &services->IUnknown_inner;
598
599 services->text_selection = NULL;
600 list_init( &services->rangelist );
601 list_init( &services->clientsites );
602
603 *unk = &services->IUnknown_inner;
604 return S_OK;
605}
static void list_init(struct list_entry *head)
Definition: list.h:51
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
ME_TextEditor * ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
Definition: editor.c:2936
static const IUnknownVtbl textservices_inner_vtbl
Definition: txtsrv.c:90
static const ITextServicesVtbl textservices_vtbl
Definition: txtsrv.c:554
const IRichEditOleVtbl re_ole_vtbl
Definition: richole.c:1419
const ITextDocument2OldVtbl text_doc2old_vtbl
Definition: richole.c:4527
#define S_OK
Definition: intsafe.h:52
#define TRACE(s)
Definition: solgame.cpp:4
#define E_POINTER
Definition: winerror.h:2365

Referenced by create_windowed_editor(), and CreateTextServices().

◆ cursor_coords()

void cursor_coords ( ME_TextEditor editor,
ME_Cursor cursor,
int x,
int y,
int height 
)

Definition at line 221 of file caret.c.

223{
224 ME_Row *row;
225 ME_Run *run = cursor->run;
226 ME_Paragraph *para = cursor->para;
227 ME_Run *size_run = run, *prev;
229 int run_x;
230 HDC hdc = ITextHost_TxGetDC( editor->texthost );
231
232 assert(~para->nFlags & MEPF_REWRAP);
233
235
236 ME_InitContext( &c, editor, hdc );
237
238 if (!cursor->nOffset && (prev = run_prev( run ))) size_run = prev;
239
240 run_x = ME_PointFromCharContext( &c, run, cursor->nOffset, TRUE );
241
242 *height = size_run->nAscent + size_run->nDescent;
243 *x = c.rcView.left + run->pt.x + run_x - editor->horz_si.nPos;
244 *y = c.rcView.top + para->pt.y + row->nBaseline
245 + run->pt.y - size_run->nAscent - editor->vert_si.nPos;
248 return;
249}
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
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)
Definition: run.c:613
ME_Row * row_from_cursor(ME_Cursor *cursor)
Definition: row.c:74
ME_Run * run_prev(ME_Run *run)
Definition: run.c:82
#define ITextHost_TxGetDC(This)
Definition: editor.h:332
#define ITextHost_TxReleaseDC(This, a)
Definition: editor.h:333
#define MEPF_REWRAP
Definition: editstr.h:139
const GLubyte * c
Definition: glext.h:8905
const char cursor[]
Definition: icontest.c:13
#define c
Definition: ke_i.h:80
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
int nAscent
Definition: editstr.h:166
POINT pt
Definition: editstr.h:167
int nDescent
Definition: editstr.h:166
SCROLLINFO vert_si
Definition: editstr.h:449
ITextHost2 * texthost
Definition: editstr.h:391
SCROLLINFO horz_si
Definition: editstr.h:449
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48

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

◆ cursor_from_char_ofs()

void cursor_from_char_ofs ( ME_TextEditor editor,
int  char_ofs,
ME_Cursor cursor 
)

Definition at line 245 of file run.c.

246{
247 ME_Paragraph *para;
248 ME_Run *run;
249
250 char_ofs = min( max( char_ofs, 0 ), ME_GetTextLength( editor ) );
251
252 /* Find the paragraph at the offset. */
253 for (para = editor_first_para( editor );
254 para_next( para )->nCharOfs <= char_ofs;
255 para = para_next( para ))
256 ;
257
258 char_ofs -= para->nCharOfs;
259
260 /* Find the run at the offset. */
261 for (run = para_first_run( para );
262 run_next( run ) && run_next( run )->nCharOfs <= char_ofs;
263 run = run_next( run ))
264 ;
265
266 char_ofs -= run->nCharOfs;
267
268 cursor->para = para;
269 cursor->run = run;
270 cursor->nOffset = char_ofs;
271}
int ME_GetTextLength(ME_TextEditor *editor)
Definition: caret.c:83
ME_Paragraph * editor_first_para(ME_TextEditor *editor)
Definition: editor.c:276
ME_Run * run_next(ME_Run *run)
Definition: run.c:68
ME_Run * para_first_run(ME_Paragraph *para)
Definition: para.c:104
ME_Paragraph * para_next(ME_Paragraph *para)
Definition: para.c:57
#define min(a, b)
Definition: monoChain.cc:55
int nCharOfs
Definition: editstr.h:162
#define max(a, b)
Definition: svc.c:63

Referenced by editor_handle_message(), editor_insert_oleobj(), fnTextSrv_TxGetText(), get_textfont_prop_for_pos(), IRichEditOle_fnGetClipboardData(), IRichEditOle_fnGetObject(), ITextRange_fnGetChar(), ITextRange_fnGetText(), ITextRange_fnScrollIntoView(), ITextRange_fnSetText(), ME_FindText(), ME_GetSelectionType(), ME_InternalDeleteText(), ME_PlayUndoItem(), ME_StreamIn(), set_selection_cursors(), set_textfont_prop(), textrange_copy_or_cut(), textrange_endof(), textrange_move(), textrange_moveend(), textrange_movestart(), and textrange_set_font().

◆ cursor_from_coords()

BOOL cursor_from_coords ( ME_TextEditor editor,
int  x,
int  y,
ME_Cursor cursor 
)

Definition at line 1070 of file caret.c.

1071{
1072 x += editor->horz_si.nPos;
1073 y += editor->vert_si.nPos;
1074 return cursor_from_virtual_coords( editor, x, y, cursor, FALSE );
1075}
static BOOL cursor_from_virtual_coords(ME_TextEditor *editor, int x, int y, ME_Cursor *result, BOOL final_eop)
Definition: caret.c:1012

Referenced by editor_handle_message(), editor_set_cursor(), and link_notify().

◆ cursor_next_run()

BOOL cursor_next_run ( ME_Cursor cursor,
BOOL  all_para 
)

Definition at line 30 of file run.c.

31{
33
34 while (p->type != diTextEnd)
35 {
36 if (p->type == diParagraph && !all_para) return FALSE;
37 else if (p->type == diRun)
38 {
39 cursor->run = &p->member.run;
40 cursor->para = cursor->run->para;
41 cursor->nOffset = 0;
42 return TRUE;
43 }
44 p = p->next;
45 }
46 return FALSE;
47}
static ME_DisplayItem * run_get_di(ME_Run *run)
Definition: editor.h:162
@ diTextEnd
Definition: editstr.h:87
@ diRun
Definition: editstr.h:85
GLfloat GLfloat p
Definition: glext.h:8902
struct define * next
Definition: compiler.c:65
struct tagME_DisplayItem * next
Definition: editstr.h:257

Referenced by ME_FindNextURLCandidate(), ME_StreamOutRTF(), run_next(), and run_next_all_paras().

◆ cursor_prev_run()

BOOL cursor_prev_run ( ME_Cursor cursor,
BOOL  all_para 
)

Definition at line 49 of file run.c.

50{
52
53 while (p->type != diTextStart)
54 {
55 if (p->type == diParagraph && !all_para) return FALSE;
56 else if (p->type == diRun)
57 {
58 cursor->run = &p->member.run;
59 cursor->para = cursor->run->para;
60 cursor->nOffset = 0;
61 return TRUE;
62 }
63 p = p->prev;
64 }
65 return FALSE;
66}
@ diTextStart
Definition: editstr.h:82
struct tagME_DisplayItem * prev
Definition: editstr.h:257

Referenced by run_prev(), and run_prev_all_paras().

◆ 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_MaximizeSplit(), ME_SplitByBacktracking(), and split_run_extents().

◆ draw_ole()

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

Definition at line 5785 of file richole.c.

5786{
5787 IDataObject* ido;
5788 IViewObject* ivo;
5789 FORMATETC fmt;
5790 STGMEDIUM stgm;
5791 DIBSECTION dibsect;
5792 ENHMETAHEADER emh;
5793 HDC hMemDC;
5794 SIZE sz;
5795 BOOL has_size;
5796 HBITMAP old_bm;
5797 RECT rc;
5798
5799 assert(run->nFlags & MERF_GRAPHICS);
5800 assert(run->reobj);
5801
5802 if (!run->reobj->obj.poleobj) return;
5803
5804 if (SUCCEEDED(IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IViewObject, (void**)&ivo)))
5805 {
5806 HRESULT hr;
5807 RECTL bounds;
5808
5809 convert_sizel(c, &run->reobj->obj.sizel, &sz);
5810 if (c->editor->nZoomNumerator != 0)
5811 {
5812 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5813 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5814 }
5815
5816 bounds.left = x;
5817 bounds.top = y - sz.cy;
5818 bounds.right = x + sz.cx;
5819 bounds.bottom = y;
5820
5821 hr = IViewObject_Draw(ivo, DVASPECT_CONTENT, -1, 0, 0, 0, c->hDC, &bounds, NULL, NULL, 0);
5822 if (FAILED(hr))
5823 {
5824 WARN("failed to draw object: %#08lx\n", hr);
5825 }
5826
5827 IViewObject_Release(ivo);
5828 return;
5829 }
5830
5831 if (IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
5832 {
5833 FIXME("Couldn't get interface\n");
5834 return;
5835 }
5836 has_size = run->reobj->obj.sizel.cx != 0 || run->reobj->obj.sizel.cy != 0;
5837 fmt.cfFormat = CF_BITMAP;
5838 fmt.ptd = NULL;
5839 fmt.dwAspect = DVASPECT_CONTENT;
5840 fmt.lindex = -1;
5841 fmt.tymed = TYMED_GDI;
5842 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
5843 {
5844 fmt.cfFormat = CF_ENHMETAFILE;
5845 fmt.tymed = TYMED_ENHMF;
5846 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
5847 {
5848 FIXME("Couldn't get storage medium\n");
5849 IDataObject_Release(ido);
5850 return;
5851 }
5852 }
5853 IDataObject_Release(ido);
5854
5855 switch (stgm.tymed)
5856 {
5857 case TYMED_GDI:
5858 GetObjectW(stgm.hBitmap, sizeof(dibsect), &dibsect);
5859 hMemDC = CreateCompatibleDC(c->hDC);
5860 old_bm = SelectObject(hMemDC, stgm.hBitmap);
5861 if (has_size)
5862 {
5863 convert_sizel(c, &run->reobj->obj.sizel, &sz);
5864 } else {
5865 sz.cx = dibsect.dsBm.bmWidth;
5866 sz.cy = dibsect.dsBm.bmHeight;
5867 }
5868 if (c->editor->nZoomNumerator != 0)
5869 {
5870 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5871 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5872 }
5873 StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
5874 hMemDC, 0, 0, dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight, SRCCOPY);
5875
5876 SelectObject(hMemDC, old_bm);
5877 DeleteDC(hMemDC);
5878 break;
5879 case TYMED_ENHMF:
5880 GetEnhMetaFileHeader(stgm.hEnhMetaFile, sizeof(emh), &emh);
5881 if (has_size)
5882 {
5883 convert_sizel(c, &run->reobj->obj.sizel, &sz);
5884 } else {
5885 sz.cx = emh.rclBounds.right - emh.rclBounds.left;
5886 sz.cy = emh.rclBounds.bottom - emh.rclBounds.top;
5887 }
5888 if (c->editor->nZoomNumerator != 0)
5889 {
5890 sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5891 sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5892 }
5893
5894 rc.left = x;
5895 rc.top = y - sz.cy;
5896 rc.right = x + sz.cx;
5897 rc.bottom = y;
5898 PlayEnhMetaFile(c->hDC, stgm.hEnhMetaFile, &rc);
5899 break;
5900 default:
5901 FIXME("Unsupported tymed %ld\n", stgm.tymed);
5902 selected = FALSE;
5903 break;
5904 }
5905 ReleaseStgMedium(&stgm);
5906
5907 if (selected && !c->editor->bHideSelection)
5908 PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
5909}
#define CF_BITMAP
Definition: constants.h:397
#define CF_ENHMETAFILE
Definition: constants.h:409
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
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:5696
#define MERF_GRAPHICS
Definition: editstr.h:103
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
static HBITMAP
Definition: button.c:44
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
const GUID IID_IViewObject
const GUID IID_IDataObject
HRESULT hr
Definition: shlfolder.c:183
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 cx
Definition: kdterminal.h:27
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
int nFlags
Definition: editstr.h:165
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
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:1546
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 draw_run().

◆ editor_copy_or_cut()

HRESULT editor_copy_or_cut ( ME_TextEditor editor,
BOOL  cut,
ME_Cursor start,
int  count,
IDataObject **  data_out 
)

Definition at line 2362 of file editor.c.

2364{
2365 HRESULT hr;
2366
2367 if (cut && (editor->props & TXTBIT_READONLY))
2368 {
2369 return E_ACCESSDENIED;
2370 }
2371
2372 hr = editor_copy( editor, start, count, data_out );
2373 if (SUCCEEDED(hr) && cut)
2374 {
2376 ME_CommitUndo( editor );
2377 ME_UpdateRepaint( editor, TRUE );
2378 }
2379 return hr;
2380}
BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start, int nChars, BOOL bForce)
Definition: caret.c:339
static HRESULT editor_copy(ME_TextEditor *editor, ME_Cursor *start, int chars, IDataObject **data_out)
Definition: editor.c:2332
void ME_CommitUndo(ME_TextEditor *editor)
Definition: undo.c:227
void ME_UpdateRepaint(ME_TextEditor *editor, BOOL update_now)
Definition: paint.c:132
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define TXTBIT_READONLY
Definition: textserv.h:187
#define E_ACCESSDENIED
Definition: winerror.h:2849

Referenced by copy_or_cut(), and textrange_copy_or_cut().

◆ editor_disable_undo()

void editor_disable_undo ( ME_TextEditor editor)

Definition at line 483 of file undo.c.

484{
485 ME_EmptyUndoStack(editor);
487}
@ undoDisabled
Definition: editstr.h:290
ME_UndoControlState undo_ctl_state
Definition: editstr.h:416

Referenced by ITextDocument2Old_fnUndo().

◆ editor_draw()

void editor_draw ( ME_TextEditor editor,
HDC  hDC,
const RECT update 
)

Definition at line 33 of file paint.c.

34{
35 ME_Paragraph *para;
37 ME_Cell *cell;
38 int ys, ye;
39 HRGN oldRgn;
40 RECT rc, client;
42
43 ME_InitContext( &c, editor, hDC );
44 if (!update)
45 {
46 client = c.rcView;
47 client.left -= editor->selofs;
48 update = &client;
49 }
50
51 oldRgn = CreateRectRgn(0, 0, 0, 0);
52 if (!GetClipRgn(hDC, oldRgn))
53 {
54 DeleteObject(oldRgn);
55 oldRgn = NULL;
56 }
57 IntersectClipRect( hDC, update->left, update->top, update->right, update->bottom );
58
59 brush = SelectObject( hDC, brush );
61
62 para = editor_first_para( editor );
63 /* This context point is an offset for the paragraph positions stored
64 * during wrapping. It shouldn't be modified during painting. */
65 c.pt.x = c.rcView.left - editor->horz_si.nPos;
66 c.pt.y = c.rcView.top - editor->vert_si.nPos;
67 while (para_next( para ))
68 {
69 ys = c.pt.y + para->pt.y;
70 cell = para_cell( para );
71 if (cell && para == cell_end_para( cell ))
72 ye = c.pt.y + cell->pt.y + cell->nHeight;
73 else ye = ys + para->nHeight;
74
75 if (cell && !(para->nFlags & MEPF_ROWEND) && para == cell_first_para( cell ))
76 {
77 /* the border shifts the text down */
78 ys -= para_cell( para )->yTextOffset;
79 }
80
81 /* Draw the paragraph if any of the paragraph is in the update region. */
82 if (ys < update->bottom && ye > update->top)
83 draw_paragraph( &c, para );
84 para = para_next( para );
85 }
86 if (editor_opaque( editor ))
87 {
88 if (c.pt.y + editor->nTotalLength < c.rcView.bottom)
89 { /* space after the end of the text */
90 rc.top = c.pt.y + editor->nTotalLength;
91 rc.left = c.rcView.left;
92 rc.bottom = c.rcView.bottom;
93 rc.right = c.rcView.right;
94 if (IntersectRect( &rc, &rc, update ))
95 PatBlt(hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
96 }
97 if (editor->selofs)
98 { /* selection bar */
99 rc.left = c.rcView.left - editor->selofs;
100 rc.top = c.rcView.top;
101 rc.right = c.rcView.left;
102 rc.bottom = c.rcView.bottom;
103 if (IntersectRect( &rc, &rc, update ))
104 PatBlt( hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY );
105 }
106 }
107
108 DeleteObject( SelectObject( hDC, brush ) );
109 SelectClipRgn( hDC, oldRgn );
110 if (oldRgn) DeleteObject( oldRgn );
112
113 if (editor->in_place_active) {
114 if (editor->nTotalLength != editor->nLastTotalLength || editor->nTotalWidth != editor->nLastTotalWidth)
116 editor->nLastTotalLength = editor->nTotalLength;
117 editor->nLastTotalWidth = editor->nTotalWidth;
118 }
119}
static HDC hDC
Definition: 3dtext.c:33
static void draw_paragraph(ME_Context *c, ME_Paragraph *para)
Definition: paint.c:935
static BOOL editor_opaque(ME_TextEditor *editor)
Definition: paint.c:28
ME_Paragraph * cell_first_para(ME_Cell *cell)
Definition: table.c:202
#define ITextHost_TxGetSysColor(This, a)
Definition: editor.h:357
void ME_SendRequestResize(ME_TextEditor *editor, BOOL force)
Definition: wrap.c:1137
ME_Cell * para_cell(ME_Paragraph *para)
Definition: para.c:127
ME_Paragraph * cell_end_para(ME_Cell *cell)
Definition: table.c:207
#define MEPF_ROWEND
Definition: editstr.h:143
pKey DeleteObject()
GLint GLint bottom
Definition: glext.h:7726
static FILE * client
Definition: client.c:41
POINT pt
Definition: editstr.h:226
int nHeight
Definition: editstr.h:227
int yTextOffset
Definition: editstr.h:228
int nLastTotalWidth
Definition: editstr.h:405
unsigned int in_place_active
Definition: editstr.h:393
int nLastTotalLength
Definition: editstr.h:404
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
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define COLOR_WINDOW
Definition: winuser.h:929
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)

Referenced by fnTextSrv_TxDraw().

◆ editor_enable_undo()

void editor_enable_undo ( ME_TextEditor editor)

Definition at line 489 of file undo.c.

490{
491 if (editor->undo_ctl_state == undoDisabled)
492 {
493 editor->undo_ctl_state = undoActive;
494 }
495}
@ undoActive
Definition: editstr.h:288

Referenced by editor_handle_message(), and ITextDocument2Old_fnUndo().

◆ editor_end_para()

ME_Paragraph * editor_end_para ( ME_TextEditor editor)

Definition at line 282 of file editor.c.

283{
284 return &editor->pBuffer->pLast->member.para;
285}
ME_DisplayItem * pLast
Definition: editstr.h:268
ME_TextBuffer * pBuffer
Definition: editstr.h:395

Referenced by editor_handle_message(), editor_mark_rewrap_all(), ME_ArrowPageDown(), ME_GetTextW(), ME_InvalidateSelection(), and ME_SetCursorToEnd().

◆ editor_ensure_visible()

void editor_ensure_visible ( ME_TextEditor editor,
ME_Cursor cursor 
)

Definition at line 1210 of file paint.c.

1211{
1212 ME_Run *run = cursor->run;
1214 ME_Paragraph *para = cursor->para;
1215 int x, y, yheight;
1216
1217 if (!editor->in_place_active)
1218 return;
1219
1220 if (editor->scrollbars & ES_AUTOHSCROLL)
1221 {
1222 x = run->pt.x + ME_PointFromChar( editor, run, cursor->nOffset, TRUE );
1223 if (x > editor->horz_si.nPos + editor->sizeWindow.cx)
1224 x = x + 1 - editor->sizeWindow.cx;
1225 else if (x > editor->horz_si.nPos)
1226 x = editor->horz_si.nPos;
1227
1228 if (~editor->scrollbars & ES_AUTOVSCROLL)
1229 {
1230 scroll_h_abs( editor, x, TRUE );
1231 return;
1232 }
1233 }
1234 else
1235 {
1236 if (~editor->scrollbars & ES_AUTOVSCROLL) return;
1237 x = editor->horz_si.nPos;
1238 }
1239
1240 y = para->pt.y + row->pt.y;
1241 yheight = row->nHeight;
1242
1243 if (y < editor->vert_si.nPos)
1244 scroll_abs( editor, x, y, TRUE );
1245 else if (y + yheight > editor->vert_si.nPos + editor->sizeWindow.cy)
1246 scroll_abs( editor, x, y + yheight - editor->sizeWindow.cy, TRUE );
1247 else if (x != editor->horz_si.nPos)
1248 scroll_abs( editor, x, editor->vert_si.nPos, TRUE );
1249}
void scroll_h_abs(ME_TextEditor *editor, int x, BOOL notify)
Definition: paint.c:1121
void scroll_abs(ME_TextEditor *editor, int x, int y, BOOL notify)
Definition: paint.c:1091
int ME_PointFromChar(ME_TextEditor *editor, ME_Run *pRun, int nOffset, BOOL visual_order)
Definition: run.c:654
#define ES_AUTOVSCROLL
Definition: pedump.c:671
#define ES_AUTOHSCROLL
Definition: pedump.c:672
DWORD scrollbars
Definition: editstr.h:401

Referenced by editor_handle_message(), ME_ArrowKey(), ME_MouseMove(), ME_UpdateRepaint(), and set_selection().

◆ editor_first_para()

◆ editor_get_selection_para_fmt()

void editor_get_selection_para_fmt ( ME_TextEditor editor,
PARAFORMAT2 fmt 
)

Definition at line 903 of file para.c.

904{
905 ME_Paragraph *para, *para_end;
906
907 if (fmt->cbSize < sizeof(PARAFORMAT))
908 {
909 fmt->dwMask = 0;
910 return;
911 }
912
913 editor_get_selection_paras( editor, &para, &para_end );
914
915 para_copy_fmt( para, fmt );
916
917 /* Invalidate values that change across the selected paragraphs. */
918 while (para != para_end)
919 {
920 para = para_next( para );
921
922#define CHECK_FIELD(m, f) \
923 if (fmt->f != para->fmt.f) fmt->dwMask &= ~(m);
924
925 CHECK_FIELD(PFM_NUMBERING, wNumbering);
926 CHECK_FIELD(PFM_STARTINDENT, dxStartIndent);
927 CHECK_FIELD(PFM_RIGHTINDENT, dxRightIndent);
928 CHECK_FIELD(PFM_OFFSET, dxOffset);
929 CHECK_FIELD(PFM_ALIGNMENT, wAlignment);
930 if (fmt->dwMask & PFM_TABSTOPS)
931 {
932 if (fmt->cTabCount != para->fmt.cTabCount ||
933 memcmp(fmt->rgxTabs, para->fmt.rgxTabs, para->fmt.cTabCount * sizeof(int) ))
934 fmt->dwMask &= ~PFM_TABSTOPS;
935 }
936
937 if (fmt->cbSize >= sizeof(PARAFORMAT2))
938 {
939 fmt->dwMask &= ~((fmt->wEffects ^ para->fmt.wEffects) << 16);
940 CHECK_FIELD(PFM_SPACEBEFORE, dySpaceBefore);
941 CHECK_FIELD(PFM_SPACEAFTER, dySpaceAfter);
942 CHECK_FIELD(PFM_LINESPACING, dyLineSpacing);
943 CHECK_FIELD(PFM_STYLE, sStyle);
944 CHECK_FIELD(PFM_SPACEAFTER, bLineSpacingRule);
945 CHECK_FIELD(PFM_SHADING, wShadingWeight);
946 CHECK_FIELD(PFM_SHADING, wShadingStyle);
947 CHECK_FIELD(PFM_NUMBERINGSTART, wNumberingStart);
948 CHECK_FIELD(PFM_NUMBERINGSTYLE, wNumberingStyle);
949 CHECK_FIELD(PFM_NUMBERINGTAB, wNumberingTab);
950 CHECK_FIELD(PFM_BORDER, wBorderSpace);
951 CHECK_FIELD(PFM_BORDER, wBorderWidth);
952 CHECK_FIELD(PFM_BORDER, wBorders);
953 }
954#undef CHECK_FIELD
955 }
956}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define CHECK_FIELD(m, f)
void editor_get_selection_paras(ME_TextEditor *editor, ME_Paragraph **para, ME_Paragraph **para_end)
Definition: para.c:848
ME_Paragraph * para_next(ME_Paragraph *para)
Definition: para.c:57
static void para_copy_fmt(const ME_Paragraph *para, PARAFORMAT2 *fmt)
Definition: para.c:889
#define PFM_SPACEBEFORE
Definition: richedit.h:847
#define PFM_NUMBERING
Definition: richedit.h:843
#define PFM_NUMBERINGSTYLE
Definition: richedit.h:853
#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_BORDER
Definition: richedit.h:851
#define PFM_ALIGNMENT
Definition: richedit.h:841
#define PFM_TABSTOPS
Definition: richedit.h:842
#define PFM_STYLE
Definition: richedit.h:850
#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
SHORT cTabCount
Definition: richedit.h:674
WORD wEffects
Definition: richedit.h:669

Referenced by editor_handle_message(), and ME_RTFParAttrHook().

◆ editor_get_selection_paras()

void editor_get_selection_paras ( ME_TextEditor editor,
ME_Paragraph **  para,
ME_Paragraph **  para_end 
)

Definition at line 848 of file para.c.

849{
850 ME_Cursor *pEndCursor = &editor->pCursors[1];
851
852 *para = editor->pCursors[0].para;
853 *para_end = editor->pCursors[1].para;
854 if (*para == *para_end)
855 return;
856
857 if ((*para_end)->nCharOfs < (*para)->nCharOfs)
858 {
859 ME_Paragraph *tmp = *para;
860
861 *para = *para_end;
862 *para_end = tmp;
863 pEndCursor = &editor->pCursors[0];
864 }
865
866 /* The paragraph at the end of a non-empty selection isn't included
867 * if the selection ends at the start of the paragraph. */
868 if (!pEndCursor->run->nCharOfs && !pEndCursor->nOffset)
869 *para_end = para_prev( *para_end );
870}
ME_Paragraph * para_prev(ME_Paragraph *para)
Definition: para.c:63
ME_Paragraph * para
Definition: editstr.h:275
int nOffset
Definition: editstr.h:277
ME_Run * run
Definition: editstr.h:276
ME_Cursor * pCursors
Definition: editstr.h:396

Referenced by editor_get_selection_para_fmt(), editor_set_selection_para_fmt(), and ME_InvalidateSelection().

◆ editor_handle_message()

LRESULT editor_handle_message ( ME_TextEditor editor,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam,
HRESULT phresult 
)

Definition at line 3266 of file editor.c.

3268{
3269 *phresult = S_OK;
3270
3271 switch(msg) {
3272
3295
3296/* Messages specific to Richedit controls */
3297
3298 case EM_STREAMIN:
3299 return ME_StreamIn(editor, wParam, (EDITSTREAM*)lParam, TRUE);
3300 case EM_STREAMOUT:
3301 return ME_StreamOut(editor, wParam, (EDITSTREAM *)lParam);
3302 case EM_EMPTYUNDOBUFFER:
3303 ME_EmptyUndoStack(editor);
3304 return 0;
3305 case EM_GETSEL:
3306 {
3307 /* Note: wParam/lParam can be NULL */
3308 LONG from, to;
3309 LONG *pfrom = wParam ? (LONG *)wParam : &from;
3310 LONG *pto = lParam ? (LONG *)lParam : &to;
3311 ME_GetSelectionOfs(editor, pfrom, pto);
3312 if ((*pfrom|*pto) & 0xFFFF0000)
3313 return -1;
3314 return MAKELONG(*pfrom,*pto);
3315 }
3316 case EM_EXGETSEL:
3317 {
3318 CHARRANGE *pRange = (CHARRANGE *)lParam;
3319 ME_GetSelectionOfs(editor, &pRange->cpMin, &pRange->cpMax);
3320 TRACE("EM_EXGETSEL = (%ld,%ld)\n", pRange->cpMin, pRange->cpMax);
3321 return 0;
3322 }
3323 case EM_SETUNDOLIMIT:
3324 {
3325 editor_enable_undo(editor);
3326 if ((int)wParam < 0)
3328 else
3329 editor->nUndoLimit = min(wParam, STACK_SIZE_MAX);
3330 /* Setting a max stack size keeps wine from getting killed
3331 for hogging memory. Windows allocates all this memory at once, so
3332 no program would realistically set a value above our maximum. */
3333 return editor->nUndoLimit;
3334 }
3335 case EM_CANUNDO:
3336 return !list_empty( &editor->undo_stack );
3337 case EM_CANREDO:
3338 return !list_empty( &editor->redo_stack );
3339 case WM_UNDO: /* FIXME: actually not the same */
3340 case EM_UNDO:
3341 return ME_Undo(editor);
3342 case EM_REDO:
3343 return ME_Redo(editor);
3344 case EM_SETFONTSIZE:
3345 {
3347 LONG tmp_size, size;
3348 BOOL is_increase = ((LONG)wParam > 0);
3349
3350 if (editor->mode & TM_PLAINTEXT)
3351 return FALSE;
3352
3353 cf.cbSize = sizeof(cf);
3354 cf.dwMask = CFM_SIZE;
3355 ME_GetSelectionCharFormat(editor, &cf);
3356 tmp_size = (cf.yHeight / 20) + wParam;
3357
3358 if (tmp_size <= 1)
3359 size = 1;
3360 else if (tmp_size > 12 && tmp_size < 28 && tmp_size % 2)
3361 size = tmp_size + (is_increase ? 1 : -1);
3362 else if (tmp_size > 28 && tmp_size < 36)
3363 size = is_increase ? 36 : 28;
3364 else if (tmp_size > 36 && tmp_size < 48)
3365 size = is_increase ? 48 : 36;
3366 else if (tmp_size > 48 && tmp_size < 72)
3367 size = is_increase ? 72 : 48;
3368 else if (tmp_size > 72 && tmp_size < 80)
3369 size = is_increase ? 80 : 72;
3370 else if (tmp_size > 80 && tmp_size < 1638)
3371 size = 10 * (is_increase ? (tmp_size / 10 + 1) : (tmp_size / 10));
3372 else if (tmp_size >= 1638)
3373 size = 1638;
3374 else
3375 size = tmp_size;
3376
3377 cf.yHeight = size * 20; /* convert twips to points */
3378 ME_SetSelectionCharFormat(editor, &cf);
3379 ME_CommitUndo(editor);
3381 ME_UpdateScrollBar(editor);
3382
3383 return TRUE;
3384 }
3385 case EM_SETSEL:
3386 {
3387 return set_selection( editor, wParam, lParam );
3388 }
3389 case EM_SETSCROLLPOS:
3390 {
3391 POINT *point = (POINT *)lParam;
3392 scroll_abs( editor, point->x, point->y, TRUE );
3393 return 0;
3394 }
3395 case EM_AUTOURLDETECT:
3396 {
3397 if (wParam==1 || wParam ==0)
3398 {
3400 return 0;
3401 }
3402 return E_INVALIDARG;
3403 }
3405 {
3406 return editor->AutoURLDetect_bEnable;
3407 }
3408 case EM_EXSETSEL:
3409 {
3411
3412 return set_selection( editor, range.cpMin, range.cpMax );
3413 }
3414 case EM_SETTEXTEX:
3415 {
3416 LPWSTR wszText;
3417 SETTEXTEX *pStruct = (SETTEXTEX *)wParam;
3418 LONG from, to;
3419 int len;
3420 ME_Style *style;
3421 BOOL bRtf, bUnicode, bSelection, bUTF8;
3422 int oldModify = editor->nModifyStep;
3423 static const char utf8_bom[] = {0xef, 0xbb, 0xbf};
3424
3425 if (!pStruct) return 0;
3426
3427 /* If we detect ascii rtf at the start of the string,
3428 * we know it isn't unicode. */
3429 bRtf = (lParam && (!strncmp((char *)lParam, "{\\rtf", 5) ||
3430 !strncmp((char *)lParam, "{\\urtf", 6)));
3431 bUnicode = !bRtf && pStruct->codepage == CP_UNICODE;
3432 bUTF8 = (lParam && (!strncmp((char *)lParam, utf8_bom, 3)));
3433
3434 TRACE("EM_SETTEXTEX - %s, flags %ld, cp %d\n",
3436 pStruct->flags, pStruct->codepage);
3437
3438 bSelection = (pStruct->flags & ST_SELECTION) != 0;
3439 if (bSelection) {
3440 int nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
3442 ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to - from, FALSE);
3443 } else {
3445 ME_SetCursorToStart(editor, &start);
3447 style = editor->pBuffer->pDefaultStyle;
3448 }
3449
3450 if (bRtf) {
3451 ME_StreamInRTFString(editor, bSelection, (char *)lParam);
3452 if (bSelection) {
3453 /* FIXME: The length returned doesn't include the rtf control
3454 * characters, only the actual text. */
3455 len = lParam ? strlen((char *)lParam) : 0;
3456 }
3457 } else {
3458 if (bUTF8 && !bUnicode) {
3459 wszText = ME_ToUnicode(CP_UTF8, (void *)(lParam+3), &len);
3460 ME_InsertTextFromCursor(editor, 0, wszText, len, style);
3461 ME_EndToUnicode(CP_UTF8, wszText);
3462 } else {
3463 wszText = ME_ToUnicode(pStruct->codepage, (void *)lParam, &len);
3464 ME_InsertTextFromCursor(editor, 0, wszText, len, style);
3465 ME_EndToUnicode(pStruct->codepage, wszText);
3466 }
3467 }
3468
3469 if (bSelection) {
3472 } else {
3474 len = 1;
3475 ME_SetCursorToStart(editor, &cursor);
3477 }
3478 ME_CommitUndo(editor);
3479 if (!(pStruct->flags & ST_KEEPUNDO))
3480 {
3481 editor->nModifyStep = oldModify;
3482 ME_EmptyUndoStack(editor);
3483 }
3484 ME_UpdateRepaint(editor, FALSE);
3485 return len;
3486 }
3487 case EM_SELECTIONTYPE:
3488 return ME_GetSelectionType(editor);
3489 case EM_GETMODIFY:
3490 return editor->nModifyStep == 0 ? 0 : -1;
3491 case EM_SETMODIFY:
3492 {
3493 if (wParam)
3494 editor->nModifyStep = 1;
3495 else
3496 editor->nModifyStep = 0;
3497
3498 return 0;
3499 }
3500 case EM_SETEVENTMASK:
3501 {
3502 DWORD nOldMask = editor->nEventMask;
3503
3504 editor->nEventMask = lParam;
3505 return nOldMask;
3506 }
3507 case EM_GETEVENTMASK:
3508 return editor->nEventMask;
3509 case EM_SETCHARFORMAT:
3510 return handle_EM_SETCHARFORMAT( editor, wParam, (CHARFORMAT2W *)lParam );
3511 case EM_GETCHARFORMAT:
3512 {
3514 if (dst->cbSize != sizeof(CHARFORMATA) &&
3515 dst->cbSize != sizeof(CHARFORMATW) &&
3516 dst->cbSize != sizeof(CHARFORMAT2A) &&
3517 dst->cbSize != sizeof(CHARFORMAT2W))
3518 return 0;
3519 tmp.cbSize = sizeof(tmp);
3520 if (!wParam)
3521 ME_GetDefaultCharFormat(editor, &tmp);
3522 else
3523 ME_GetSelectionCharFormat(editor, &tmp);
3524 cf2w_to_cfany(dst, &tmp);
3525 return tmp.dwMask;
3526 }
3527 case EM_SETPARAFORMAT:
3528 {
3531 ME_UpdateScrollBar(editor);
3532 ME_CommitUndo(editor);
3533 return result;
3534 }
3535 case EM_GETPARAFORMAT:
3537 return ((PARAFORMAT2 *)lParam)->dwMask;
3539 {
3540 ME_Paragraph *para = editor_first_para( editor );
3541 ME_Row *row;
3542 int y = editor->vert_si.nPos;
3543 int count = 0;
3544
3545 while (para_next( para ))
3546 {
3547 if (y < para->pt.y + para->nHeight) break;
3548 count += para->nRows;
3549 para = para_next( para );
3550 }
3551
3552 row = para_first_row( para );
3553 while (row)
3554 {
3555 if (y < para->pt.y + row->pt.y + row->nHeight) break;
3556 count++;
3557 row = row_next( row );
3558 }
3559 return count;
3560 }
3561 case EM_HIDESELECTION:
3562 {
3563 editor->bHideSelection = (wParam != 0);
3564 ME_InvalidateSelection(editor);
3565 return 0;
3566 }
3567 case EM_LINESCROLL:
3568 {
3569 if (!(editor->props & TXTBIT_MULTILINE))
3570 return FALSE;
3571 ME_ScrollDown( editor, lParam * get_default_line_height( editor ) );
3572 return TRUE;
3573 }
3574 case WM_CLEAR:
3575 {
3576 LONG from, to;
3577 int nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
3578 ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to-from, FALSE);
3579 ME_CommitUndo(editor);
3580 ME_UpdateRepaint(editor, TRUE);
3581 return 0;
3582 }
3583 case EM_REPLACESEL:
3584 {
3585 WCHAR *text = (WCHAR *)lParam;
3586 int len = text ? lstrlenW( text ) : 0;
3587
3588 TRACE( "EM_REPLACESEL - %s\n", debugstr_w( text ) );
3589 ME_ReplaceSel( editor, !!wParam, text, len );
3590 return len;
3591 }
3592 case EM_SCROLLCARET:
3593 editor_ensure_visible( editor, &editor->pCursors[0] );
3594 return 0;
3595 case WM_SETFONT:
3596 {
3597 LOGFONTW lf;
3599 HDC hDC;
3600 BOOL bRepaint = LOWORD(lParam);
3601
3602 if (!wParam)
3604
3605 if (!GetObjectW((HGDIOBJ)wParam, sizeof(LOGFONTW), &lf))
3606 return 0;
3607
3608 hDC = ITextHost_TxGetDC(editor->texthost);
3611 if (editor->mode & TM_RICHTEXT) {
3613 ME_SetCursorToStart(editor, &start);
3614 ME_SetCharFormat(editor, &start, NULL, &fmt);
3615 }
3616 ME_SetDefaultCharFormat(editor, &fmt);
3617
3618 ME_CommitUndo(editor);
3619 editor_mark_rewrap_all( editor );
3621 ME_UpdateScrollBar(editor);
3622 if (bRepaint)
3623 ME_Repaint(editor);
3624#ifdef __REACTOS__
3626 {
3627 HIMC hIMC = ImmGetContext(editor->hWnd);
3628 ImmSetCompositionFontW(hIMC, &lf);
3629 ImmReleaseContext(editor->hWnd, hIMC);
3630 }
3631#endif
3632 return 0;
3633 }
3634 case WM_SETTEXT:
3635 {
3637 ME_SetCursorToStart(editor, &cursor);
3639 if (lParam)
3640 {
3641 TRACE("WM_SETTEXT lParam==%Ix\n",lParam);
3642 if (!strncmp((char *)lParam, "{\\rtf", 5) ||
3643 !strncmp((char *)lParam, "{\\urtf", 6))
3644 {
3645 /* Undocumented: WM_SETTEXT supports RTF text */
3646 ME_StreamInRTFString(editor, 0, (char *)lParam);
3647 }
3648 else
3649 ME_SetText( editor, (void*)lParam, TRUE );
3650 }
3651 else
3652 TRACE("WM_SETTEXT - NULL\n");
3653 ME_SetCursorToStart(editor, &cursor);
3655 set_selection_cursors(editor, 0, 0);
3656 editor->nModifyStep = 0;
3657 ME_CommitUndo(editor);
3658 ME_EmptyUndoStack(editor);
3659 ME_UpdateRepaint(editor, FALSE);
3660 return 1;
3661 }
3662 case EM_CANPASTE:
3663 return paste_special( editor, 0, NULL, TRUE );
3664 case WM_PASTE:
3665 case WM_MBUTTONDOWN:
3666 wParam = 0;
3667 lParam = 0;
3668 /* fall through */
3669 case EM_PASTESPECIAL:
3671 return 0;
3672 case WM_CUT:
3673 case WM_COPY:
3674 copy_or_cut(editor, msg == WM_CUT);
3675 return 0;
3676 case WM_GETTEXTLENGTH:
3677 {
3678 GETTEXTLENGTHEX how;
3679 how.flags = GTL_CLOSE | (editor->bEmulateVersion10 ? 0 : GTL_USECRLF) | GTL_NUMCHARS;
3680 how.codepage = CP_UNICODE;
3681 return ME_GetTextLengthEx(editor, &how);
3682 }
3683 case EM_GETTEXTLENGTHEX:
3684 return ME_GetTextLengthEx(editor, (GETTEXTLENGTHEX *)wParam);
3685 case WM_GETTEXT:
3686 {
3687 GETTEXTEX ex;
3688 ex.cb = wParam * sizeof(WCHAR);
3689 ex.flags = GT_USECRLF;
3690 ex.codepage = CP_UNICODE;
3691 ex.lpDefaultChar = NULL;
3692 ex.lpUsedDefChar = NULL;
3693 return ME_GetTextEx(editor, &ex, lParam);
3694 }
3695 case EM_GETTEXTEX:
3696 return ME_GetTextEx(editor, (GETTEXTEX*)wParam, lParam);
3697 case EM_GETSELTEXT:
3698 {
3699 LONG nFrom, nTo;
3700 int nStartCur = ME_GetSelectionOfs(editor, &nFrom, &nTo);
3701 ME_Cursor *from = &editor->pCursors[nStartCur];
3702 return get_text_range( editor, (WCHAR *)lParam, from, nTo - nFrom );
3703 }
3704 case EM_GETSCROLLPOS:
3705 {
3706 POINT *point = (POINT *)lParam;
3707 point->x = editor->horz_si.nPos;
3708 point->y = editor->vert_si.nPos;
3709 /* 16-bit scaled value is returned as stored in scrollinfo */
3710 if (editor->horz_si.nMax > 0xffff)
3711 point->x = MulDiv(point->x, 0xffff, editor->horz_si.nMax);
3712 if (editor->vert_si.nMax > 0xffff)
3713 point->y = MulDiv(point->y, 0xffff, editor->vert_si.nMax);
3714 return 1;
3715 }
3716 case EM_GETTEXTRANGE:
3717 {
3718 TEXTRANGEW *rng = (TEXTRANGEW *)lParam;
3720 int nStart = rng->chrg.cpMin;
3721 int nEnd = rng->chrg.cpMax;
3722 int textlength = ME_GetTextLength(editor);
3723
3724 TRACE( "EM_GETTEXTRANGE min = %ld max = %ld textlength = %d\n", rng->chrg.cpMin, rng->chrg.cpMax, textlength );
3725 if (nStart < 0) return 0;
3726 if ((nStart == 0 && nEnd == -1) || nEnd > textlength)
3727 nEnd = textlength;
3728 if (nStart >= nEnd) return 0;
3729
3730 cursor_from_char_ofs( editor, nStart, &start );
3731 return get_text_range( editor, rng->lpstrText, &start, nEnd - nStart );
3732 }
3733 case EM_GETLINE:
3734 {
3735 ME_Row *row;
3736 ME_Run *run;
3737 const unsigned int nMaxChars = *(WORD *) lParam;
3738 unsigned int nCharsLeft = nMaxChars;
3739 char *dest = (char *) lParam;
3741
3742 TRACE( "EM_GETLINE: row=%d, nMaxChars=%d\n", (int)wParam, nMaxChars );
3743
3744 row = row_from_row_number( editor, wParam );
3745 if (row == NULL) return 0;
3746
3748 row_end_cursor( row, &end, TRUE );
3749 run = start.run;
3750 while (nCharsLeft)
3751 {
3752 WCHAR *str;
3753 unsigned int nCopy;
3754 int ofs = (run == start.run) ? start.nOffset : 0;
3755 int len = (run == end.run) ? end.nOffset : run->len;
3756
3757 str = get_text( run, ofs );
3758 nCopy = min( nCharsLeft, len );
3759
3760 memcpy(dest, str, nCopy * sizeof(WCHAR));
3761 dest += nCopy * sizeof(WCHAR);
3762 nCharsLeft -= nCopy;
3763 if (run == end.run) break;
3764 run = row_next_run( row, run );
3765 }
3766
3767 /* append line termination, space allowing */
3768 if (nCharsLeft > 0) *((WCHAR *)dest) = '\0';
3769
3770 TRACE("EM_GETLINE: got %u characters\n", nMaxChars - nCharsLeft);
3771 return nMaxChars - nCharsLeft;
3772 }
3773 case EM_GETLINECOUNT:
3774 {
3775 int count = editor->total_rows;
3776 ME_Run *prev_run, *last_run;
3777
3778 last_run = para_end_run( para_prev( editor_end_para( editor ) ) );
3779 prev_run = run_prev_all_paras( last_run );
3780
3781 if (editor->bEmulateVersion10 && prev_run && last_run->nCharOfs == 0 &&
3782 prev_run->len == 1 && *get_text( prev_run, 0 ) == '\r')
3783 {
3784 /* In 1.0 emulation, the last solitary \r at the very end of the text
3785 (if one exists) is NOT a line break.
3786 FIXME: this is an ugly hack. This should have a more regular model. */
3787 count--;
3788 }
3789
3790 count = max(1, count);
3791 TRACE("EM_GETLINECOUNT: count==%d\n", count);
3792 return count;
3793 }
3794 case EM_LINEFROMCHAR:
3795 {
3796 if (wParam == -1) wParam = ME_GetCursorOfs( editor->pCursors + 1 );
3797 return row_number_from_char_ofs( editor, wParam );
3798 }
3799 case EM_EXLINEFROMCHAR:
3800 {
3801 if (lParam == -1) lParam = ME_GetCursorOfs( editor->pCursors + 1 );
3802 return row_number_from_char_ofs( editor, lParam );
3803 }
3804 case EM_LINEINDEX:
3805 {
3806 ME_Row *row;
3808 int ofs;
3809
3810 if (wParam == -1) row = row_from_cursor( editor->pCursors );
3811 else row = row_from_row_number( editor, wParam );
3812 if (!row) return -1;
3813
3815 ofs = ME_GetCursorOfs( &cursor );
3816 TRACE( "EM_LINEINDEX: nCharOfs==%d\n", ofs );
3817 return ofs;
3818 }
3819 case EM_LINELENGTH:
3820 {
3821 ME_Row *row;
3822 int start_ofs, end_ofs;
3824
3825 if (wParam > ME_GetTextLength(editor))
3826 return 0;
3827 if (wParam == -1)
3828 {
3829 FIXME("EM_LINELENGTH: returning number of unselected characters on lines with selection unsupported.\n");
3830 return 0;
3831 }
3832 cursor_from_char_ofs( editor, wParam, &cursor );
3835 start_ofs = ME_GetCursorOfs( &cursor );
3837 end_ofs = ME_GetCursorOfs( &cursor );
3838 TRACE( "EM_LINELENGTH(%Id)==%d\n", wParam, end_ofs - start_ofs );
3839 return end_ofs - start_ofs;
3840 }
3841 case EM_EXLIMITTEXT:
3842 {
3843 if ((int)lParam < 0)
3844 return 0;
3845 if (lParam == 0)
3846 editor->nTextLimit = 65536;
3847 else
3848 editor->nTextLimit = (int) lParam;
3849 return 0;
3850 }
3851 case EM_LIMITTEXT:
3852 {
3853 if (wParam == 0)
3854 editor->nTextLimit = 65536;
3855 else
3856 editor->nTextLimit = (int) wParam;
3857 return 0;
3858 }
3859 case EM_GETLIMITTEXT:
3860 {
3861 return editor->nTextLimit;
3862 }
3863 case EM_FINDTEXT:
3864 case EM_FINDTEXTW:
3865 {
3866 FINDTEXTW *ft = (FINDTEXTW *)lParam;
3867 return ME_FindText(editor, wParam, &ft->chrg, ft->lpstrText, NULL);
3868 }
3869 case EM_FINDTEXTEX:
3870 case EM_FINDTEXTEXW:
3871 {
3873 return ME_FindText(editor, wParam, &ex->chrg, ex->lpstrText, &ex->chrgText);
3874 }
3875 case EM_GETZOOM:
3876 if (!wParam || !lParam)
3877 return FALSE;
3878 *(int *)wParam = editor->nZoomNumerator;
3879 *(int *)lParam = editor->nZoomDenominator;
3880 return TRUE;
3881 case EM_SETZOOM:
3882 return ME_SetZoom(editor, wParam, lParam);
3883 case EM_CHARFROMPOS:
3884 {
3886 POINTL *pt = (POINTL *)lParam;
3887
3888 cursor_from_coords(editor, pt->x, pt->y, &cursor);
3889 return ME_GetCursorOfs(&cursor);
3890 }
3891 case EM_POSFROMCHAR:
3892 {
3894 int nCharOfs, nLength;
3895 POINTL pt = {0,0};
3896
3897 nCharOfs = wParam;
3898 /* detect which API version we're dealing with */
3899 if (wParam >= 0x40000)
3900 nCharOfs = lParam;
3901 nLength = ME_GetTextLength(editor);
3902 nCharOfs = min(nCharOfs, nLength);
3903 nCharOfs = max(nCharOfs, 0);
3904
3905 cursor_from_char_ofs( editor, nCharOfs, &cursor );
3906 pt.y = cursor.run->pt.y;
3907 pt.x = cursor.run->pt.x +
3908 ME_PointFromChar( editor, cursor.run, cursor.nOffset, TRUE );
3909 pt.y += cursor.para->pt.y + editor->rcFormat.top;
3910 pt.x += editor->rcFormat.left;
3911
3912 pt.x -= editor->horz_si.nPos;
3913 pt.y -= editor->vert_si.nPos;
3914
3915 if (wParam >= 0x40000) *(POINTL *)wParam = pt;
3916
3917 return (wParam >= 0x40000) ? 0 : MAKELONG( pt.x, pt.y );
3918 }
3919 case WM_LBUTTONDBLCLK:
3920 case WM_LBUTTONDOWN:
3921 {
3922 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
3924 ME_LButtonDown(editor, (short)LOWORD(lParam), (short)HIWORD(lParam),
3927 editor->bMouseCaptured = TRUE;
3928 link_notify( editor, msg, wParam, lParam );
3929 break;
3930 }
3931 case WM_MOUSEMOVE:
3932 if (editor->bMouseCaptured)
3933 ME_MouseMove(editor, (short)LOWORD(lParam), (short)HIWORD(lParam));
3934 else
3935 link_notify( editor, msg, wParam, lParam );
3936 break;
3937 case WM_LBUTTONUP:
3938 if (editor->bMouseCaptured) {
3940 editor->bMouseCaptured = FALSE;
3941 }
3942 if (editor->nSelectionType == stDocument)
3943 editor->nSelectionType = stPosition;
3944 else
3945 {
3946 link_notify( editor, msg, wParam, lParam );
3947 }
3948 break;
3949 case WM_RBUTTONUP:
3950 case WM_RBUTTONDOWN:
3951 case WM_RBUTTONDBLCLK:
3952 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
3953 link_notify( editor, msg, wParam, lParam );
3954 goto do_default;
3955 case WM_CONTEXTMENU:
3956 if (!ME_ShowContextMenu(editor, (short)LOWORD(lParam), (short)HIWORD(lParam)))
3957 goto do_default;
3958 break;
3959 case WM_SETFOCUS:
3960 editor->bHaveFocus = TRUE;
3961 create_caret(editor);
3962 update_caret(editor);
3964 if (!editor->bHideSelection && (editor->props & TXTBIT_HIDESELECTION))
3965 ME_InvalidateSelection( editor );
3966 return 0;
3967 case WM_KILLFOCUS:
3968 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
3969 editor->bHaveFocus = FALSE;
3970 editor->wheel_remain = 0;
3971 hide_caret(editor);
3972 DestroyCaret();
3974 if (!editor->bHideSelection && (editor->props & TXTBIT_HIDESELECTION))
3975 ME_InvalidateSelection( editor );
3976 return 0;
3977 case WM_COMMAND:
3978 TRACE("editor wnd command = %d\n", LOWORD(wParam));
3979 return 0;
3980 case WM_KEYDOWN:
3981 if (ME_KeyDown(editor, LOWORD(wParam)))
3982 return 0;
3983 goto do_default;
3984 case WM_CHAR:
3985 return handle_wm_char( editor, wParam, lParam );
3986 case WM_UNICHAR:
3987 if (wParam == UNICODE_NOCHAR) return TRUE;
3988 if (wParam <= 0x000fffff)
3989 {
3990 if (wParam > 0xffff) /* convert to surrogates */
3991 {
3992 wParam -= 0x10000;
3993 handle_wm_char( editor, (wParam >> 10) + 0xd800, 0 );
3994 handle_wm_char( editor, (wParam & 0x03ff) + 0xdc00, 0 );
3995 }
3996 else
3997 handle_wm_char( editor, wParam, 0 );
3998 }
3999 return 0;
4000 case EM_STOPGROUPTYPING:
4001 ME_CommitUndo(editor); /* End coalesced undos for typed characters */
4002 return 0;
4003 case WM_HSCROLL:
4004 {
4005 const int scrollUnit = 7;
4006
4007 switch(LOWORD(wParam))
4008 {
4009 case SB_LEFT:
4010 scroll_abs( editor, 0, 0, TRUE );
4011 break;
4012 case SB_RIGHT:
4013 scroll_abs( editor, editor->horz_si.nMax - (int)editor->horz_si.nPage,
4014 editor->vert_si.nMax - (int)editor->vert_si.nPage, TRUE );
4015 break;
4016 case SB_LINELEFT:
4017 ME_ScrollLeft(editor, scrollUnit);
4018 break;
4019 case SB_LINERIGHT:
4020 ME_ScrollRight(editor, scrollUnit);
4021 break;
4022 case SB_PAGELEFT:
4023 ME_ScrollLeft(editor, editor->sizeWindow.cx);
4024 break;
4025 case SB_PAGERIGHT:
4026 ME_ScrollRight(editor, editor->sizeWindow.cx);
4027 break;
4028 case SB_THUMBTRACK:
4029 case SB_THUMBPOSITION:
4030 {
4031 int pos = HIWORD(wParam);
4032 if (editor->horz_si.nMax > 0xffff)
4033 pos = MulDiv(pos, editor->horz_si.nMax, 0xffff);
4034 scroll_h_abs( editor, pos, FALSE );
4035 break;
4036 }
4037 }
4038 break;
4039 }
4040 case EM_SCROLL: /* fall through */
4041 case WM_VSCROLL:
4042 {
4043 int origNPos;
4044 int lineHeight = get_default_line_height( editor );
4045
4046 origNPos = editor->vert_si.nPos;
4047
4048 switch(LOWORD(wParam))
4049 {
4050 case SB_TOP:
4051 scroll_abs( editor, 0, 0, TRUE );
4052 break;
4053 case SB_BOTTOM:
4054 scroll_abs( editor, editor->horz_si.nMax - (int)editor->horz_si.nPage,
4055 editor->vert_si.nMax - (int)editor->vert_si.nPage, TRUE );
4056 break;
4057 case SB_LINEUP:
4058 ME_ScrollUp(editor,lineHeight);
4059 break;
4060 case SB_LINEDOWN:
4061 ME_ScrollDown(editor,lineHeight);
4062 break;
4063 case SB_PAGEUP:
4064 ME_ScrollUp(editor,editor->sizeWindow.cy);
4065 break;
4066 case SB_PAGEDOWN:
4067 ME_ScrollDown(editor,editor->sizeWindow.cy);
4068 break;
4069 case SB_THUMBTRACK:
4070 case SB_THUMBPOSITION:
4071 {
4072 int pos = HIWORD(wParam);
4073 if (editor->vert_si.nMax > 0xffff)
4074 pos = MulDiv(pos, editor->vert_si.nMax, 0xffff);
4075 scroll_v_abs( editor, pos, FALSE );
4076 break;
4077 }
4078 }
4079 if (msg == EM_SCROLL)
4080 return 0x00010000 | (((editor->vert_si.nPos - origNPos)/lineHeight) & 0xffff);
4081 break;
4082 }
4083 case WM_MOUSEWHEEL:
4084 {
4085 int delta = GET_WHEEL_DELTA_WPARAM( wParam );
4086 BOOL ctrl_is_down = GetKeyState( VK_CONTROL ) & 0x8000;
4087
4088 /* if scrolling changes direction, ignore left overs */
4089 if ((delta < 0 && editor->wheel_remain < 0) ||
4090 (delta > 0 && editor->wheel_remain > 0))
4091 editor->wheel_remain += delta;
4092 else
4093 editor->wheel_remain = delta;
4094
4095 if (editor->wheel_remain)
4096 {
4097 if (ctrl_is_down) {
4098 int numerator;
4099 if (!editor->nZoomNumerator || !editor->nZoomDenominator)
4100 {
4101 numerator = 100;
4102 } else {
4103 numerator = editor->nZoomNumerator * 100 / editor->nZoomDenominator;
4104 }
4105 numerator += calc_wheel_change( &editor->wheel_remain, 10 );
4106 if (numerator >= 10 && numerator <= 500)
4107 ME_SetZoom(editor, numerator, 100);
4108 } else {
4109 UINT max_lines = 3;
4110 int lines = 0;
4111
4112 SystemParametersInfoW( SPI_GETWHEELSCROLLLINES, 0, &max_lines, 0 );
4113 if (max_lines)
4114 lines = calc_wheel_change( &editor->wheel_remain, (int)max_lines );
4115 if (lines)
4116 ME_ScrollDown( editor, -lines * get_default_line_height( editor ) );
4117 }
4118 }
4119 break;
4120 }
4121 case EM_REQUESTRESIZE:
4122 ME_SendRequestResize(editor, TRUE);
4123 return 0;
4124#ifndef __REACTOS__
4125 /* IME messages to make richedit controls IME aware */
4126#endif
4127 case WM_IME_SETCONTEXT:
4128#ifdef __REACTOS__
4129 {
4130 if (FALSE) /* FIXME: Condition */
4131 lParam &= ~ISC_SHOWUICOMPOSITIONWINDOW;
4132
4133 if (wParam)
4134 {
4135 HIMC hIMC = ImmGetContext(editor->hWnd);
4137 if (pIC)
4138 {
4139 pIC->dwUIFlags &= ~0x40000;
4140 ImmUnlockIMC(hIMC);
4141 }
4142 if (FALSE) /* FIXME: Condition */
4144 ImmReleaseContext(editor->hWnd, hIMC);
4145 }
4146
4147 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4148 }
4149#endif
4150 case WM_IME_CONTROL:
4151#ifdef __REACTOS__
4152 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4153#endif
4154 case WM_IME_SELECT:
4155#ifdef __REACTOS__
4156 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4157#endif
4159 return 0;
4160 case WM_IME_STARTCOMPOSITION:
4161 {
4162#ifdef __REACTOS__
4163 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4164#else
4165 editor->imeStartIndex=ME_GetCursorOfs(&editor->pCursors[0]);
4166 ME_DeleteSelection(editor);
4167 ME_CommitUndo(editor);
4168 ME_UpdateRepaint(editor, FALSE);
4169#endif
4170 return 0;
4171 }
4172 case WM_IME_COMPOSITION:
4173 {
4174 HIMC hIMC;
4175
4176 ME_Style *style = style_get_insert_style( editor, editor->pCursors );
4177 hIMC = ITextHost_TxImmGetContext(editor->texthost);
4178 ME_DeleteSelection(editor);
4179 ME_SaveTempStyle(editor, style);
4181 {
4182 LPWSTR lpCompStr = NULL;
4184 DWORD dwIndex = lParam & GCS_RESULTSTR;
4185 if (!dwIndex)
4186 dwIndex = GCS_COMPSTR;
4187
4188 dwBufLen = ImmGetCompositionStringW(hIMC, dwIndex, NULL, 0);
4189 lpCompStr = malloc(dwBufLen + sizeof(WCHAR));
4190 ImmGetCompositionStringW(hIMC, dwIndex, lpCompStr, dwBufLen);
4191 lpCompStr[dwBufLen/sizeof(WCHAR)] = 0;
4192#ifndef __REACTOS__
4193 ME_InsertTextFromCursor(editor,0,lpCompStr,dwBufLen/sizeof(WCHAR),style);
4194#endif
4195 free(lpCompStr);
4196
4197#ifndef __REACTOS__
4198 if (dwIndex == GCS_COMPSTR)
4199 set_selection_cursors(editor,editor->imeStartIndex,
4200 editor->imeStartIndex + dwBufLen/sizeof(WCHAR));
4201 else
4202 editor->imeStartIndex = ME_GetCursorOfs(&editor->pCursors[0]);
4203#endif
4204 }
4207 ME_CommitUndo(editor);
4208 ME_UpdateRepaint(editor, FALSE);
4209#ifdef __REACTOS__
4210 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4211#else
4212 return 0;
4213#endif
4214 }
4215 case WM_IME_ENDCOMPOSITION:
4216 {
4217#ifdef __REACTOS__
4218 return DefWindowProcW(editor->hWnd, msg, wParam, lParam);
4219#else
4220 ME_DeleteSelection(editor);
4221 editor->imeStartIndex=-1;
4222 return 0;
4223#endif
4224 }
4225 case EM_GETOLEINTERFACE:
4226 IRichEditOle_AddRef( editor->richole );
4227 *(IRichEditOle **)lParam = editor->richole;
4228 return 1;
4229
4230 case EM_SETOLECALLBACK:
4231 if(editor->lpOleCallback)
4232 IRichEditOleCallback_Release(editor->lpOleCallback);
4234 if(editor->lpOleCallback)
4235 IRichEditOleCallback_AddRef(editor->lpOleCallback);
4236 return TRUE;
4238 return (LRESULT)editor->pfnWordBreak;
4240 {
4241 EDITWORDBREAKPROCW pfnOld = editor->pfnWordBreak;
4242
4244 return (LRESULT)pfnOld;
4245 }
4246 case EM_GETTEXTMODE:
4247 return editor->mode;
4248 case EM_SETTEXTMODE:
4249 {
4250 int mask = 0;
4251 int changes = 0;
4252
4253 if (ME_GetTextLength(editor) ||
4254 !list_empty( &editor->undo_stack ) || !list_empty( &editor->redo_stack ))
4255 return E_UNEXPECTED;
4256
4257 /* Check for mutually exclusive flags in adjacent bits of wParam */
4260 return E_INVALIDARG;
4261
4263 {
4266 if (wParam & TM_PLAINTEXT) {
4267 /* Clear selection since it should be possible to select the
4268 * end of text run for rich text */
4269 ME_InvalidateSelection(editor);
4270 ME_SetCursorToStart(editor, &editor->pCursors[0]);
4271 editor->pCursors[1] = editor->pCursors[0];
4272 /* plain text can only have the default style. */
4273 ME_ClearTempStyle(editor);
4275 ME_ReleaseStyle( editor->pCursors[0].run->style );
4276 editor->pCursors[0].run->style = editor->pBuffer->pDefaultStyle;
4277 }
4278 }
4279 /* FIXME: Currently no support for undo level and code page options */
4280 editor->mode = (editor->mode & ~mask) | changes;
4281 return 0;
4282 }
4283 case EM_SETTARGETDEVICE:
4284 if (wParam == 0)
4285 {
4286 BOOL new = (lParam == 0 && (editor->props & TXTBIT_MULTILINE));
4287 if (editor->nAvailWidth || editor->bWordWrap != new)
4288 {
4289 editor->bWordWrap = new;
4290 editor->nAvailWidth = 0; /* wrap to client area */
4291 ME_RewrapRepaint(editor);
4292 }
4293 } else {
4294 int width = max(0, lParam);
4295 if ((editor->props & TXTBIT_MULTILINE) &&
4296 (!editor->bWordWrap || editor->nAvailWidth != width))
4297 {
4298 editor->nAvailWidth = width;
4299 editor->bWordWrap = TRUE;
4300 ME_RewrapRepaint(editor);
4301 }
4302 FIXME("EM_SETTARGETDEVICE doesn't use non-NULL target devices\n");
4303 }
4304 return TRUE;
4305 default:
4306 do_default:
4307 *phresult = S_FALSE;
4308 break;
4309 }
4310 return 0L;
4311}
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
#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 E_INVALIDARG
Definition: ddrawi.h:101
#define free
Definition: debug_ros.c:5
DWORD HIMC
Definition: dimm.idl:75
#define lstrlenW
Definition: compat.h:750
const WCHAR * text
Definition: package.c:1794
#define CP_UNICODE
Definition: stg_prop.c:74
void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: caret.c:27
void ME_DeleteSelection(ME_TextEditor *editor)
Definition: caret.c:1425
int ME_GetCursorOfs(const ME_Cursor *cursor)
Definition: caret.c:923
void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor, const WCHAR *str, int len, ME_Style *style)
Definition: caret.c:584
void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum)
Definition: caret.c:1156
int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how)
Definition: caret.c:91
BOOL cursor_from_coords(ME_TextEditor *editor, int x, int y, ME_Cursor *cursor)
Definition: caret.c:1070
void hide_caret(ME_TextEditor *editor)
Definition: caret.c:267
void ME_MouseMove(ME_TextEditor *editor, int x, int y)
Definition: caret.c:1218
int set_selection_cursors(ME_TextEditor *editor, int from, int to)
Definition: caret.c:132
int ME_GetSelectionOfs(ME_TextEditor *editor, LONG *from, LONG *to)
Definition: caret.c:42
void create_caret(ME_TextEditor *editor)
Definition: caret.c:251
void update_caret(ME_TextEditor *editor)
Definition: caret.c:277
ME_Style * ME_GetSelectionInsertStyle(ME_TextEditor *editor)
Definition: caret.c:1434
static void ME_StreamInRTFString(ME_TextEditor *editor, BOOL selection, char *string)
Definition: editor.c:1834
static BOOL paste_special(ME_TextEditor *editor, UINT cf, REPASTESPECIAL *ps, BOOL check_only)
Definition: editor.c:2285
#define UNSUPPORTED_MSG(e)
Definition: editor.c:3255
static int ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCHAR *text, CHARRANGE *chrgText)
Definition: editor.c:1849
static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stream, BOOL stripLastCR)
Definition: editor.c:1571
static void ME_SetText(ME_TextEditor *editor, void *text, BOOL unicode)
Definition: editor.c:3195
void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len)
Definition: editor.c:3170
static void ME_UpdateSelectionLinkAttribute(ME_TextEditor *editor)
Definition: editor.c:2398
static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y)
Definition: editor.c:2914
#define STACK_SIZE_MAX
Definition: editor.c:245
static LRESULT handle_EM_SETCHARFORMAT(ME_TextEditor *editor, WPARAM flags, const CHARFORMAT2W *fmt_in)
Definition: editor.c:3205
static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText)
Definition: editor.c:2092
static int calc_wheel_change(int *remain, int amount_per_click)
Definition: editor.c:3126
static int get_text_range(ME_TextEditor *editor, WCHAR *buffer, const ME_Cursor *start, int len)
Definition: editor.c:2144
#define STACK_SIZE_DEFAULT
Definition: editor.c:244
static BOOL copy_or_cut(ME_TextEditor *editor, BOOL cut)
Definition: editor.c:2382
static int get_default_line_height(ME_TextEditor *editor)
Definition: editor.c:3115
static LONG ME_GetSelectionType(ME_TextEditor *editor)
Definition: editor.c:2875
static BOOL ME_UpdateLinkAttribute(ME_TextEditor *editor, ME_Cursor *start, int nChars)
Definition: editor.c:4562
static LRESULT handle_wm_char(ME_TextEditor *editor, WCHAR wstr, LPARAM flags)
Definition: editor.c:2690
static BOOL ME_KeyDown(ME_TextEditor *editor, WORD nKey)
Definition: editor.c:2567
void link_notify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: editor.c:3133
ME_Paragraph * editor_end_para(ME_TextEditor *editor)
Definition: editor.c:282
static int ME_CalculateClickCount(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: editor.c:2776
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define pt(x, y)
Definition: drawing.c:79
void ME_InvalidateSelection(ME_TextEditor *editor)
Definition: paint.c:1253
void ME_RewrapRepaint(ME_TextEditor *editor)
Definition: paint.c:160
ME_Row * para_first_row(ME_Paragraph *para)
Definition: para.c:132
#define ITextHost_TxSetFocus(This)
Definition: editor.h:347
void ME_ScrollRight(ME_TextEditor *editor, int cx)
Definition: paint.c:1146
void editor_get_selection_para_fmt(ME_TextEditor *editor, PARAFORMAT2 *fmt)
Definition: para.c:903
void ME_ScrollLeft(ME_TextEditor *editor, int cx)
Definition: paint.c:1141
ME_Style * style_get_insert_style(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: style.c:476
void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *pFmt)
Definition: run.c:782
void ME_ReleaseStyle(ME_Style *item)
Definition: style.c:462
#define ITextHost_TxImmReleaseContext(This, a)
Definition: editor.h:369
BOOL ME_SetZoom(ME_TextEditor *editor, int numerator, int denominator)
Definition: paint.c:1310
void ME_UpdateScrollBar(ME_TextEditor *editor)
Definition: paint.c:1151
int row_number_from_char_ofs(ME_TextEditor *editor, int ofs)
Definition: row.c:131
void ME_EndToUnicode(LONG codepage, LPVOID psz)
Definition: string.c:248
void ME_Repaint(ME_TextEditor *editor)
Definition: paint.c:121
void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style)
Definition: style.c:498
void scroll_h_abs(ME_TextEditor *editor, int x, BOOL notify)
Definition: paint.c:1121
BOOL ME_Undo(ME_TextEditor *editor)
Definition: undo.c:410
BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
Definition: wrap.c:1103
#define ITextHost_TxSetCapture(This, a)
Definition: editor.h:346
void row_first_cursor(ME_Row *row, ME_Cursor *cursor)
Definition: row.c:82
#define ITextHost_TxNotify(This, a, b)
Definition: editor.h:367
ME_Run * para_end_run(ME_Paragraph *para)
Definition: para.c:117
void ME_ScrollDown(ME_TextEditor *editor, int cy)
Definition: paint.c:1136
void editor_enable_undo(ME_TextEditor *editor)
Definition: undo.c:489
BOOL editor_set_selection_para_fmt(ME_TextEditor *editor, const PARAFORMAT2 *fmt)
Definition: para.c:873
BOOL ME_Redo(ME_TextEditor *editor)
Definition: undo.c:448
ME_Run * run_prev_all_paras(ME_Run *run)
Definition: run.c:110
void ME_CharFormatFromLogFont(HDC hDC, const LOGFONTW *lf, CHARFORMAT2W *fmt)
Definition: style.c:331
void scroll_v_abs(ME_TextEditor *editor, int y, BOOL notify)
Definition: paint.c:1126
BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from)
Definition: style.c:79
void row_end_cursor(ME_Row *row, ME_Cursor *cursor, BOOL include_eop)
Definition: row.c:92
ME_Run * row_next_run(ME_Row *row, ME_Run *run)
Definition: row.c:63
LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream)
Definition: writer.c:1193
void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *mod)
Definition: style.c:524
void editor_mark_rewrap_all(ME_TextEditor *editor)
Definition: para.c:235
#define ITextHost_TxImmGetContext(This)
Definition: editor.h:368
void cursor_from_char_ofs(ME_TextEditor *editor, int char_ofs, ME_Cursor *cursor)
Definition: run.c:245
void ME_SetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt)
Definition: run.c:753
ME_Paragraph * para_prev(ME_Paragraph *para)
Definition: para.c:63
void ME_ClearTempStyle(ME_TextEditor *editor)
Definition: style.c:507
ME_Row * row_next(ME_Row *row)
Definition: row.c:27
void ME_ScrollUp(ME_TextEditor *editor, int cy)
Definition: paint.c:1131
void ME_EmptyUndoStack(ME_TextEditor *editor)
Definition: undo.c:53
void ME_GetSelectionCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt)
Definition: run.c:858
void scroll_abs(ME_TextEditor *editor, int x, int y, BOOL notify)
Definition: paint.c:1091
ME_Row * row_from_row_number(ME_TextEditor *editor, int row_num)
Definition: row.c:111
LPWSTR ME_ToUnicode(LONG codepage, LPVOID psz, INT *len)
Definition: string.c:226
void editor_ensure_visible(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: paint.c:1210
void ME_GetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt)
Definition: run.c:847
@ stPosition
Definition: editstr.h:363
@ stDocument
Definition: editstr.h:367
POINTL point
Definition: edittest.c:50
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLuint end
Definition: gl.h:1545
GLint GLint GLsizei width
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
GLenum GLint GLuint mask
Definition: glext.h:6028
GLenum GLint * range
Definition: glext.h:7539
GLenum GLenum dst
Definition: glext.h:6340
GLuint64EXT * result
Definition: glext.h:11304
BOOL WINAPI ImmSetCompositionFontW(_In_ HIMC hIMC, _In_ LPLOGFONTW lplf)
Definition: ime.c:1322
struct INPUTCONTEXTDX * LPINPUTCONTEXTDX
#define CPS_CANCEL
Definition: imm.h:181
#define GCS_RESULTSTR
Definition: imm.h:234
HIMC WINAPI ImmGetContext(_In_ HWND hWnd)
Definition: imm.c:1065
BOOL WINAPI ImmReleaseContext(_In_ HWND hWnd, _In_ HIMC hIMC)
Definition: imm.c:1109
#define GCS_COMPSTR
Definition: imm.h:227
LONG WINAPI ImmGetCompositionStringW(_In_ HIMC hIMC, _In_ DWORD dwIndex, _Out_writes_bytes_opt_(dwBufLen) LPVOID lpBuf, _In_ DWORD dwBufLen)
Definition: compstr.c:908
BOOL WINAPI ImmIsIME(_In_ HKL hKL)
Definition: ime.c:429
BOOL WINAPI ImmNotifyIME(_In_ HIMC hIMC, _In_ DWORD dwAction, _In_ DWORD dwIndex, _In_ DWORD_PTR dwValue)
Definition: ime.c:458
LPINPUTCONTEXT WINAPI ImmLockIMC(_In_ HIMC hIMC)
Definition: imm.c:1079
#define NI_COMPOSITIONSTR
Definition: immdev.h:381
BOOL WINAPI ImmUnlockIMC(_In_ HIMC hIMC)
Definition: imm.c:1089
#define INT_MAX
Definition: intsafe.h:150
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 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
long LONG
Definition: pedump.c:60
#define TM_RICHTEXT
Definition: richedit.h:1029
#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 EM_SETPALETTE
Definition: richedit.h:127
#define EM_SETOLECALLBACK
Definition: richedit.h:103
#define EM_GETREDONAME
Definition: richedit.h:120
#define GTL_CLOSE
Definition: richedit.h:1057
#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 ST_SELECTION
Definition: richedit.h:1072
#define EM_SETEVENTMASK
Definition: richedit.h:102
#define EM_CANPASTE
Definition: richedit.h:83
#define WM_UNICHAR
Definition: richedit.h:67
#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_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 GTL_NUMCHARS
Definition: richedit.h:1058
#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_SETWORDBREAKPROCEX
Definition: richedit.h:114
#define EM_DISPLAYBAND
Definition: richedit.h:84
#define EM_SETLANGOPTIONS
Definition: richedit.h:143
#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 CFM_SIZE
Definition: richedit.h:362
#define EM_FINDTEXTW
Definition: richedit.h:147
#define EM_GETZOOM
Definition: richedit.h:169
#define EM_EXSETSEL
Definition: richedit.h:88
#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 EM_SETTYPOGRAPHYOPTIONS
Definition: richedit.h:157
#define EM_GETTEXTLENGTHEX
Definition: richedit.h:129
#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 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 EM_SETUNDOLIMIT
Definition: richedit.h:116
#define GTL_USECRLF
Definition: richedit.h:1055
#define EM_FINDWORDBREAK
Definition: richedit.h:109
#define TM_MULTICODEPAGE
Definition: richedit.h:1033
#define EM_SETEDITSTYLE
Definition: richedit.h:160
#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
DWORD dwMask
Definition: richedit.h:306
LONG cpMax
Definition: richedit.h:501
LONG cpMin
Definition: richedit.h:500
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
ME_Style * style
Definition: editstr.h:160
ME_Style * pDefaultStyle
Definition: editstr.h:270
EDITWORDBREAKPROCW pfnWordBreak
Definition: editstr.h:425
struct list redo_stack
Definition: editstr.h:412
int nZoomNumerator
Definition: editstr.h:421
ME_SelectionType nSelectionType
Definition: editstr.h:443
BOOL AutoURLDetect_bEnable
Definition: editstr.h:434
LPRICHEDITOLECALLBACK lpOleCallback
Definition: editstr.h:427
int nZoomDenominator
Definition: editstr.h:421
IRichEditOle * richole
Definition: editstr.h:426
BOOL bMouseCaptured
Definition: editstr.h:455
unsigned int bEmulateVersion10
Definition: editstr.h:392
struct list undo_stack
Definition: editstr.h:411
BOOL bHideSelection
Definition: editstr.h:433
#define TXTBIT_MULTILINE
Definition: textserv.h:186
#define TXTBIT_HIDESELECTION
Definition: textserv.h:190
#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
WINBASEAPI _In_ DWORD nLength
Definition: wincon.h:682
_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
#define EM_GETIMESTATUS
Definition: winuser.h:2006
#define WM_GETTEXTLENGTH
Definition: winuser.h:1638
HKL WINAPI GetKeyboardLayout(_In_ DWORD)
#define EM_LIMITTEXT
Definition: winuser.h:2019
#define SB_THUMBTRACK
Definition: winuser.h:573
#define EM_LINEFROMCHAR
Definition: winuser.h:2020
#define SB_LINEUP
Definition: winuser.h:564
#define WM_HSCROLL
Definition: winuser.h:1762
#define WM_PASTE
Definition: winuser.h:1882
#define EN_KILLFOCUS
Definition: winuser.h:2044
#define EM_GETWORDBREAKPROC
Definition: winuser.h:2018
#define EM_FMTLINES
Definition: winuser.h:2005
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_VSCROLL
Definition: winuser.h:1763
#define EM_SETIMESTATUS
Definition: winuser.h:2029
#define EM_GETSEL
Definition: winuser.h:2016
#define EN_SETFOCUS
Definition: winuser.h:2046
#define EM_GETMODIFY
Definition: winuser.h:2013
#define SB_PAGERIGHT
Definition: winuser.h:571
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:2004
#define SB_LEFT
Definition: winuser.h:575
#define SB_BOTTOM
Definition: winuser.h:577
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1797
#define WM_COMMAND
Definition: winuser.h:1759
#define EM_REPLACESEL
Definition: winuser.h:2025
#define VK_CONTROL
Definition: winuser.h:2222
#define WM_RBUTTONUP
Definition: winuser.h:1799
#define WM_RBUTTONDBLCLK
Definition: winuser.h:1800
#define WM_SETFOCUS
Definition: winuser.h:1632
#define WM_MOUSEMOVE
Definition: winuser.h:1794
#define WM_GETTEXT
Definition: winuser.h:1637
#define WM_CUT
Definition: winuser.h:1880
#define SB_LINERIGHT
Definition: winuser.h:567
#define WM_LBUTTONDOWN
Definition: winuser.h:1795
#define EM_LINEINDEX
Definition: winuser.h:2021
#define EM_LINESCROLL
Definition: winuser.h:2023
#define EM_GETFIRSTVISIBLELINE
Definition: winuser.h:2007
#define WM_UNDO
Definition: winuser.h:1884
#define WM_IME_SETCONTEXT
Definition: winuser.h:1848
#define WM_RBUTTONDOWN
Definition: winuser.h:1798
#define WM_SETTEXT
Definition: winuser.h:1636
#define EM_CANUNDO
Definition: winuser.h:2002
#define EM_LINELENGTH
Definition: winuser.h:2022
#define EM_GETLINE
Definition: winuser.h:2010
#define SB_LINELEFT
Definition: winuser.h:566
#define WM_SETFONT
Definition: winuser.h:1669
#define EM_UNDO
Definition: winuser.h:2040
#define EM_SCROLL
Definition: winuser.h:2026
#define SB_PAGEDOWN
Definition: winuser.h:569
#define EM_SETWORDBREAKPROC
Definition: winuser.h:2039
#define SB_LINEDOWN
Definition: winuser.h:565
#define EM_SETSEL
Definition: winuser.h:2037
int(CALLBACK * EDITWORDBREAKPROCW)(LPWSTR, int, int, int)
Definition: winuser.h:2981
#define WM_LBUTTONUP
Definition: winuser.h:1796
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define WM_IME_COMPOSITIONFULL
Definition: winuser.h:1851
#define WM_CHAR
Definition: winuser.h:1736
#define SB_TOP
Definition: winuser.h:578
#define WM_COPY
Definition: winuser.h:1881
#define WM_IME_CONTROL
Definition: winuser.h:1850
#define EM_SETTABSTOPS
Definition: winuser.h:2038
#define WM_IME_SELECT
Definition: winuser.h:1852
#define WM_CLEAR
Definition: winuser.h:1883
#define WM_KEYDOWN
Definition: winuser.h:1734
#define EM_GETLINECOUNT
Definition: winuser.h:2011
#define SB_RIGHT
Definition: winuser.h:576
BOOL WINAPI DestroyCaret(void)
Definition: caret.c:35
#define EM_SETMARGINS
Definition: winuser.h:2031
#define WM_KILLFOCUS
Definition: winuser.h:1633
#define SB_PAGEUP
Definition: winuser.h:568
#define WM_MBUTTONDOWN
Definition: winuser.h:1801
#define EM_SETMODIFY
Definition: winuser.h:2032
SHORT WINAPI GetKeyState(_In_ int)
#define SB_PAGELEFT
Definition: winuser.h:570
#define SB_THUMBPOSITION
Definition: winuser.h:572
const char * LPCSTR
Definition: xmlstorage.h:183
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by fnTextSrv_TxSendMessage().

◆ editor_insert_oleobj()

HRESULT editor_insert_oleobj ( ME_TextEditor editor,
const REOBJECT reo 
)

Definition at line 504 of file caret.c.

505{
506 ME_Run *run, *prev;
507 const WCHAR space = ' ';
508 struct re_object *reobj_prev = NULL;
509 ME_Cursor *cursor, cursor_from_ofs;
511 HRESULT hr;
513
514 if (editor->lpOleCallback)
515 {
516 hr = IRichEditOleCallback_QueryInsertObject(editor->lpOleCallback, (LPCLSID)&reo->clsid, reo->pstg, REO_CP_SELECTION);
517 if (hr != S_OK)
518 return hr;
519 }
520
521 extent = reo->sizel;
522 if (!extent.cx && !extent.cy && reo->poleobj)
523 {
524 hr = IOleObject_GetExtent( reo->poleobj, DVASPECT_CONTENT, &extent );
525 if (FAILED(hr))
526 {
527 extent.cx = 0;
528 extent.cy = 0;
529 }
530 }
531
532 if (reo->cp == REO_CP_SELECTION)
533 cursor = editor->pCursors;
534 else
535 {
536 cursor_from_char_ofs( editor, reo->cp, &cursor_from_ofs );
537 cursor = &cursor_from_ofs;
538 }
540
541 if (ME_IsSelection(editor))
542 ME_DeleteSelection(editor);
543
544 run = run_insert( editor, cursor, style, &space, 1, MERF_GRAPHICS );
545
546 run->reobj = create_re_object( reo, run );
547 run->reobj->obj.sizel = extent;
548
549 prev = run;
550 while ((prev = run_prev_all_paras( prev )))
551 {
552 if (prev->reobj)
553 {
554 reobj_prev = prev->reobj;
555 break;
556 }
557 }
558 if (reobj_prev)
559 list_add_after(&reobj_prev->entry, &run->reobj->entry);
560 else
561 list_add_head(&editor->reobj_list, &run->reobj->entry);
562
564 return S_OK;
565}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
BOOL ME_IsSelection(ME_TextEditor *editor)
Definition: caret.c:1419
static struct re_object * create_re_object(const REOBJECT *reo, ME_Run *run)
Definition: caret.c:490
ME_Run * run_insert(ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style, const WCHAR *str, int len, int flags)
Definition: run.c:380
__WINE_SERVER_LIST_INLINE void list_add_after(struct list *elem, struct list *to_add)
Definition: list.h:78
CLSID clsid
Definition: richole.idl:60
LPSTORAGE pstg
Definition: richole.idl:62
LPOLEOBJECT poleobj
Definition: richole.idl:61
LONG cp
Definition: richole.idl:59
SIZEL sizel
Definition: richole.idl:64
struct list entry
Definition: editstr.h:153
struct tagME_Run * run
Definition: editstr.h:155
struct list reobj_list
Definition: editstr.h:459

Referenced by insert_static_object(), and IRichEditOle_fnInsertObject().

◆ editor_mark_rewrap_all()

void editor_mark_rewrap_all ( ME_TextEditor editor)

Definition at line 235 of file para.c.

236{
237 para_mark_rewrap_paras( editor, editor_first_para( editor ), editor_end_para( editor ) );
238}
static void para_mark_rewrap_paras(ME_TextEditor *editor, ME_Paragraph *first, const ME_Paragraph *end)
Definition: para.c:226

Referenced by editor_handle_message(), fnTextSrv_TxDraw(), fnTextSrv_TxGetNaturalSize(), ME_RewrapRepaint(), and ME_SetDefaultCharFormat().

◆ editor_propagate_char_ofs()

void editor_propagate_char_ofs ( ME_TextEditor editor,
ME_Paragraph para,
ME_Run run,
int  shift 
)

Definition at line 147 of file run.c.

148{
149 assert( !para ^ !run );
150
151 if (run)
152 {
153 para = para_next( run->para );
154 do
155 {
156 run->nCharOfs += shift;
157 run = run_next( run );
158 } while (run);
159 }
160
161 do
162 {
163 /* update position in marked tree, if added */
164 if (para->nFlags & MEPF_REWRAP)
165 para_mark_remove( editor, para );
166 para->nCharOfs += shift;
167 if (para->nFlags & MEPF_REWRAP)
168 para_mark_add( editor, para );
169 para = para_next( para );
170 } while (para);
171}
void para_mark_remove(ME_TextEditor *editor, ME_Paragraph *para)
Definition: para.c:94
void para_mark_add(ME_TextEditor *editor, ME_Paragraph *para)
Definition: para.c:99
#define shift
Definition: input.c:1755
struct tagME_Paragraph * para
Definition: editstr.h:161

Referenced by ME_InternalDeleteText(), para_join(), para_split(), and run_insert().

◆ editor_set_cursor()

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

Definition at line 2831 of file editor.c.

2832{
2833 ME_Cursor pos;
2834 static HCURSOR cursor_arrow, cursor_hand, cursor_ibeam, cursor_reverse;
2836
2837 if (!cursor_arrow)
2838 {
2839 cursor_arrow = LoadCursorW( NULL, MAKEINTRESOURCEW( IDC_ARROW ) );
2840 cursor_hand = LoadCursorW( NULL, MAKEINTRESOURCEW( IDC_HAND ) );
2841 cursor_ibeam = LoadCursorW( NULL, MAKEINTRESOURCEW( IDC_IBEAM ) );
2842 cursor_reverse = LoadCursorW( dll_instance, MAKEINTRESOURCEW( OCR_REVERSE ) );
2843 }
2844
2845 cursor = cursor_ibeam;
2846
2847 if ((editor->nSelectionType == stLine && editor->bMouseCaptured) ||
2848 (!editor->bEmulateVersion10 && y < editor->rcFormat.top && x < editor->rcFormat.left))
2849 cursor = cursor_reverse;
2850 else if (y < editor->rcFormat.top || y > editor->rcFormat.bottom)
2851 {
2852 if (editor->bEmulateVersion10) cursor = cursor_arrow;
2853 else cursor = cursor_ibeam;
2854 }
2855 else if (x < editor->rcFormat.left) cursor = cursor_reverse;
2856 else if (cursor_from_coords( editor, x, y, &pos ))
2857 {
2858 ME_Run *run = pos.run;
2859
2860 if (is_link( run )) cursor = cursor_hand;
2861
2862 else if (ME_IsSelection( editor ))
2863 {
2864 LONG start, end;
2865 int offset = ME_GetCursorOfs( &pos );
2866
2867 ME_GetSelectionOfs( editor, &start, &end );
2868 if (start <= offset && end >= offset) cursor = cursor_arrow;
2869 }
2870 }
2871
2872 ITextHost_TxSetCursor( editor->texthost, cursor, cursor == cursor_ibeam );
2873}
HINSTANCE dll_instance
Definition: editor.c:253
static BOOL is_link(ME_Run *run)
Definition: editor.c:2826
#define ITextHost_TxSetCursor(This, a, b)
Definition: editor.h:348
@ stLine
Definition: editstr.h:365
GLintptr offset
Definition: glext.h:5920
#define OCR_REVERSE
Definition: res.h:23
HICON HCURSOR
Definition: windef.h:299
#define IDC_ARROW
Definition: winuser.h:695
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2442
#define IDC_IBEAM
Definition: winuser.h:696
#define IDC_HAND
Definition: winuser.h:706
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by fnTextSrv_OnTxSetCursor().

◆ editor_set_default_para_fmt()

void editor_set_default_para_fmt ( ME_TextEditor editor,
PARAFORMAT2 pFmt 
)

Definition at line 958 of file para.c.

959{
960 const PARAFORMAT2 *host_fmt;
961 HRESULT hr;
962
963 ZeroMemory(pFmt, sizeof(PARAFORMAT2));
964 pFmt->cbSize = sizeof(PARAFORMAT2);
965 pFmt->dwMask = PFM_ALL2;
966 pFmt->wAlignment = PFA_LEFT;
967 pFmt->sStyle = -1;
968 pFmt->bOutlineLevel = TRUE;
969
970 hr = ITextHost_TxGetParaFormat( editor->texthost, (const PARAFORMAT **)&host_fmt );
971 if (SUCCEEDED(hr))
972 {
973 /* Just use the alignment for now */
974 if (host_fmt->dwMask & PFM_ALIGNMENT)
975 pFmt->wAlignment = host_fmt->wAlignment;
977 }
978}
#define ITextHost_OnTxParaFormatChange(This, a)
Definition: editor.h:365
#define ITextHost_TxGetParaFormat(This, a)
Definition: editor.h:356
#define PFA_LEFT
Definition: richedit.h:921
#define PFM_ALL2
Definition: richedit.h:892
struct _paraformat2 PARAFORMAT2
BYTE bOutlineLevel
Definition: richedit.h:678
WORD wAlignment
Definition: richedit.h:673
DWORD dwMask
Definition: richedit.h:667
SHORT sStyle
Definition: richedit.h:677
UINT cbSize
Definition: richedit.h:666

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

◆ editor_set_selection_para_fmt()

BOOL editor_set_selection_para_fmt ( ME_TextEditor editor,
const PARAFORMAT2 fmt 
)

Definition at line 873 of file para.c.

874{
875 ME_Paragraph *para, *para_end;
876
877 editor_get_selection_paras( editor, &para, &para_end );
878
879 do
880 {
881 para_set_fmt( editor, para, fmt );
882 if (para == para_end) break;
883 para = para_next( para );
884 } while(1);
885
886 return TRUE;
887}
static BOOL para_set_fmt(ME_TextEditor *editor, ME_Paragraph *para, const PARAFORMAT2 *pFmt)
Definition: para.c:456

Referenced by editor_handle_message(), and SpecialChar().

◆ editor_undo_ignored()

static BOOL editor_undo_ignored ( ME_TextEditor editor)
inlinestatic

Definition at line 401 of file editor.h.

402{
403 return editor->undo_ctl_state != undoActive || editor->nUndoMode == umIgnore;
404}
@ umIgnore
Definition: editstr.h:283
ME_UndoMode nUndoMode
Definition: editstr.h:415

Referenced by add_undo(), ME_CommitCoalescingUndo(), ME_CommitUndo(), ME_ContinueCoalescingTransaction(), ME_PlayUndoItem(), ME_Redo(), and ME_Undo().

◆ get_text()

◆ get_total_width()

int get_total_width ( ME_TextEditor editor)

Definition at line 69 of file para.c.

70{
71 ME_Paragraph *para;
72 int total_width = 0;
73
74 if (editor->pBuffer->pFirst && editor->pBuffer->pLast)
75 {
76 para = &editor->pBuffer->pFirst->next->member.para;
77 while (para != &editor->pBuffer->pLast->member.para && para->next_para)
78 {
79 total_width = max(total_width, para->nWidth);
80 para = &para->next_para->member.para;
81 }
82 }
83
84 return total_width;
85}
struct tagME_DisplayItem * next_para
Definition: editstr.h:217

Referenced by para_destroy(), and wrap_marked_paras_dc().

◆ hide_caret()

void hide_caret ( ME_TextEditor ed)

Definition at line 267 of file caret.c.

268{
269 /* calls to HideCaret are cumulative; do so only once */
270 if (!editor->caret_hidden)
271 {
272 ITextHost_TxShowCaret(editor->texthost, FALSE);
273 editor->caret_hidden = TRUE;
274 }
275}
#define ITextHost_TxShowCaret(This, a)
Definition: editor.h:341

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

◆ link_notify()

void link_notify ( ME_TextEditor editor,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 3133 of file editor.c.

3134{
3135 int x,y;
3136 ME_Cursor cursor; /* The start of the clicked text. */
3137 ME_Run *run;
3138 ENLINK info;
3139
3140 x = (short)LOWORD(lParam);
3141 y = (short)HIWORD(lParam);
3142 if (!cursor_from_coords( editor, x, y, &cursor )) return;
3143
3144 if (is_link( cursor.run ))
3145 { /* The clicked run has CFE_LINK set */
3146 info.nmhdr.hwndFrom = NULL;
3147 info.nmhdr.idFrom = 0;
3148 info.nmhdr.code = EN_LINK;
3149 info.msg = msg;
3150 info.wParam = wParam;
3151 info.lParam = lParam;
3152 cursor.nOffset = 0;
3153
3154 /* find the first contiguous run with CFE_LINK set */
3155 info.chrg.cpMin = ME_GetCursorOfs(&cursor);
3156 run = cursor.run;
3157 while ((run = run_prev( run )) && is_link( run ))
3158 info.chrg.cpMin -= run->len;
3159
3160 /* find the last contiguous run with CFE_LINK set */
3161 info.chrg.cpMax = ME_GetCursorOfs(&cursor) + cursor.run->len;
3162 run = cursor.run;
3163 while ((run = run_next( run )) && is_link( run ))
3164 info.chrg.cpMax += run->len;
3165
3166 ITextHost_TxNotify(editor->texthost, info.nmhdr.code, &info);
3167 }
3168}
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
ME_Run * run_next(ME_Run *run)
Definition: run.c:68
#define EN_LINK
Definition: richedit.h:202

Referenced by editor_handle_message(), and fnTextSrv_OnTxSetCursor().

◆ 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(), editor_handle_message(), ME_ApplyStyle(), ME_RTFReadHook(), ME_SaveTempStyle(), ME_StreamIn(), para_num_init(), RTFUngetToken(), run_create(), and style_get_insert_style().

◆ 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 para_join(), and para_split().

◆ 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}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:66
int yOffset
Definition: appswitch.c:58
LCID lcid
Definition: locale.c:5656
#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
uint32_t entry
Definition: isohybrid.c:63
#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_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:71
#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 1471 of file caret.c.

1472{
1473 int nCursor = 0;
1474 ME_Cursor *p = &editor->pCursors[nCursor];
1475 ME_Cursor tmp_curs = *p;
1476 BOOL success = FALSE;
1477
1478 ME_CheckCharOffsets(editor);
1479 switch(nVKey) {
1480 case VK_LEFT:
1481 if (ctrl)
1482 success = ME_MoveCursorWords(editor, &tmp_curs, -1);
1483 else
1484 success = ME_MoveCursorChars(editor, &tmp_curs, -1, extend);
1485 break;
1486 case VK_RIGHT:
1487 if (ctrl)
1488 success = ME_MoveCursorWords(editor, &tmp_curs, +1);
1489 else
1490 success = ME_MoveCursorChars(editor, &tmp_curs, +1, extend);
1491 break;
1492 case VK_UP:
1493 cursor_move_line( editor, &tmp_curs, TRUE, extend );
1494 break;
1495 case VK_DOWN:
1496 cursor_move_line( editor, &tmp_curs, FALSE, extend );
1497 break;
1498 case VK_PRIOR:
1499 ME_ArrowPageUp(editor, &tmp_curs);
1500 break;
1501 case VK_NEXT:
1502 ME_ArrowPageDown(editor, &tmp_curs);
1503 break;
1504 case VK_HOME: {
1505 if (ctrl)
1506 ME_ArrowCtrlHome(editor, &tmp_curs);
1507 else
1508 ME_ArrowHome(editor, &tmp_curs);
1509 break;
1510 }
1511 case VK_END:
1512 if (ctrl)
1513 ME_ArrowCtrlEnd(editor, &tmp_curs);
1514 else
1515 ME_ArrowEnd(editor, &tmp_curs);
1516 break;
1517 }
1518
1519 if (!extend)
1520 editor->pCursors[1] = tmp_curs;
1521 *p = tmp_curs;
1522
1523 ME_InvalidateSelection(editor);
1524 ME_Repaint(editor);
1525 hide_caret(editor);
1526 editor_ensure_visible( editor, &tmp_curs );
1527 update_caret(editor);
1528 ME_SendSelChange(editor);
1529 return success;
1530}
static void cursor_move_line(ME_TextEditor *editor, ME_Cursor *cursor, BOOL up, BOOL extend)
Definition: caret.c:1265
static void ME_ArrowHome(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: caret.c:1395
int ME_MoveCursorChars(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs, BOOL final_eop)
Definition: caret.c:709
BOOL ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
Definition: caret.c:789
static void ME_ArrowCtrlEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
Definition: caret.c:1414
void ME_SendSelChange(ME_TextEditor *editor)
Definition: caret.c:1439
static void ME_ArrowPageUp(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: caret.c:1331
static void ME_ArrowPageDown(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: caret.c:1364
static void ME_ArrowCtrlHome(ME_TextEditor *editor, ME_Cursor *pCursor)
Definition: caret.c:1402
static void ME_ArrowEnd(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: caret.c:1407
void ME_CheckCharOffsets(ME_TextEditor *editor)
Definition: run.c:178
#define ctrl
Definition: input.c:1756
#define success(from, fromstr, to, tostr)
#define VK_UP
Definition: winuser.h:2244
#define VK_NEXT
Definition: winuser.h:2240
#define VK_END
Definition: winuser.h:2241
#define VK_HOME
Definition: winuser.h:2242
#define VK_LEFT
Definition: winuser.h:2243
#define VK_RIGHT
Definition: winuser.h:2245
#define VK_DOWN
Definition: winuser.h:2246
#define VK_PRIOR
Definition: winuser.h:2239

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);
216 char *buffer = malloc(buffer_size);
217 if (!buffer) return 0;
221 free(buffer);
222 return result;
223 }
224}
static int ME_WordBreakProc(LPWSTR s, INT start, INT len, INT code)
Definition: string.c:162
GLuint buffer
Definition: glext.h:5915
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
Definition: inflate.c:139

Referenced by ME_MoveCursorWords().

◆ ME_CanJoinRuns()

BOOL ME_CanJoinRuns ( const ME_Run run1,
const ME_Run run2 
)

Definition at line 129 of file run.c.

130{
131 if ((run1->nFlags | run2->nFlags) & MERF_NOJOIN)
132 return FALSE;
133 if (run1->style != run2->style)
134 return FALSE;
135 if ((run1->nFlags & MERF_STYLEFLAGS) != (run2->nFlags & MERF_STYLEFLAGS))
136 return FALSE;
137 return TRUE;
138}
#define MERF_STYLEFLAGS
Definition: editstr.h:101
#define MERF_NOJOIN
Definition: editstr.h:129

Referenced by ME_PrepareParagraphForWrapping().

◆ ME_CharCompare()

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

Definition at line 103 of file editor.h.

104{
105 return caseSensitive ? (a == b) : (towupper(a) == towupper(b));
106}
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}
#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 editor_handle_message().

◆ ME_CharFromPoint()

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

Definition at line 575 of file run.c.

576{
578 int ret;
579 HDC hdc = ITextHost_TxGetDC( editor->texthost );
580
581 ME_InitContext( &c, editor, hdc );
582 ret = ME_CharFromPointContext( &c, cx, run, closest, visual_order );
585 return ret;
586}
int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL closest, BOOL visual_order)
Definition: run.c:516
_Out_opt_ int * cx
Definition: commctrl.h:585
int ret

Referenced by row_cursor().

◆ ME_CharFromPointContext()

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

Definition at line 516 of file run.c.

517{
518 ME_String *mask_text = NULL;
519 WCHAR *str;
520 int fit = 0;
521 SIZE sz, sz2, sz3;
522 if (!run->len || cx <= 0)
523 return 0;
524
525 if (run->nFlags & (MERF_TAB | MERF_ENDCELL))
526 {
527 if (!closest || cx < run->nWidth / 2) return 0;
528 return 1;
529 }
530
531 if (run->nFlags & MERF_GRAPHICS)
532 {
533 SIZE sz;
534 ME_GetOLEObjectSize(c, run, &sz);
535 if (!closest || cx < sz.cx / 2) return 0;
536 return 1;
537 }
538
539 if (run->para->nFlags & MEPF_COMPLEX)
540 {
541 int cp, trailing;
542 if (visual_order && run->script_analysis.fRTL) cx = run->nWidth - cx - 1;
543
544 ScriptXtoCP( cx, run->len, run->num_glyphs, run->clusters, run->vis_attrs, run->advances, &run->script_analysis,
545 &cp, &trailing );
546 TRACE("x %d cp %d trailing %d (run width %d) rtl %d log order %d\n", cx, cp, trailing, run->nWidth,
548 return closest ? cp + trailing : cp;
549 }
550
551 if (c->editor->password_char)
552 {
553 mask_text = ME_MakeStringR( c->editor->password_char, run->len );
554 str = mask_text->szData;
555 }
556 else
557 str = get_text( run, 0 );
558
559 select_style(c, run->style);
560 GetTextExtentExPointW(c->hDC, str, run->len,
561 cx, &fit, NULL, &sz);
562 if (closest && fit != run->len)
563 {
564 GetTextExtentPoint32W(c->hDC, str, fit, &sz2);
565 GetTextExtentPoint32W(c->hDC, str, fit + 1, &sz3);
566 if (cx >= (sz2.cx+sz3.cx)/2)
567 fit = fit + 1;
568 }
569
570 ME_DestroyString( mask_text );
571
572 return fit;
573}
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:2875
void ME_DestroyString(ME_String *s)
Definition: string.c:96
void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
Definition: richole.c:5708
void select_style(ME_Context *c, ME_Style *s)
Definition: style.c:369
ME_String * ME_MakeStringR(WCHAR cRepeat, int nMaxChars)
Definition: string.c:85
#define MERF_TAB
Definition: editstr.h:105
#define MERF_ENDCELL
Definition: editstr.h:107
#define MEPF_COMPLEX
Definition: editstr.h:144
POINT cp
Definition: magnifier.c:59
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:54
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_CheckCharOffsets()

void ME_CheckCharOffsets ( ME_TextEditor editor)

Definition at line 178 of file run.c.

179{
180 ME_DisplayItem *p = editor->pBuffer->pFirst;
181 int ofs = 0, ofsp = 0;
182
183 if (!TRACE_ON(richedit_check))
184 return;
185
186 TRACE_(richedit_check)("Checking begin\n");
187 if(TRACE_ON(richedit_lists))
188 {
189 TRACE_(richedit_lists)("---\n");
190 ME_DumpDocument(editor->pBuffer);
191 }
192 do {
194 switch(p->type) {
195 case diTextEnd:
196 TRACE_(richedit_check)("tend, real ofsp = %d, counted = %d\n", p->member.para.nCharOfs, ofsp+ofs);
197 assert(ofsp+ofs == p->member.para.nCharOfs);
198 TRACE_(richedit_check)("Checking finished\n");
199 return;
200 case diParagraph:
201 TRACE_(richedit_check)("para, real ofsp = %d, counted = %d\n", p->member.para.nCharOfs, ofsp+ofs);
202 assert(ofsp+ofs == p->member.para.nCharOfs);
203 ofsp = p->member.para.nCharOfs;
204 ofs = 0;
205 break;
206 case diRun:
207 TRACE_(richedit_check)("run, real ofs = %d (+ofsp = %d), counted = %d, len = %d, txt = %s, flags=%08x, fx&mask = %08lx\n",
208 p->member.run.nCharOfs, p->member.run.nCharOfs+ofsp, ofsp+ofs,
209 p->member.run.len, debugstr_run( &p->member.run ),
210 p->member.run.nFlags,
211 p->member.run.style->fmt.dwMask & p->member.run.style->fmt.dwEffects);
212 assert(ofs == p->member.run.nCharOfs);
213 assert(p->member.run.len);
214 ofs += p->member.run.len;
215 break;
216 case diCell:
217 TRACE_(richedit_check)("cell\n");
218 break;
219 default:
220 assert(0);
221 }
222 } while(1);
223 TRACE_(richedit_check)("Checking finished\n");
224}
#define TRACE_ON(x)
Definition: compat.h:75
void ME_DumpDocument(ME_TextBuffer *buffer)
Definition: list.c:142
static const char * debugstr_run(const ME_Run *run)
Definition: editor.h:46
@ diRunOrParagraphOrEnd
Definition: editstr.h:95

Referenced by ME_ArrowKey(), ME_InternalDeleteText(), ME_KeyDown(), ME_MakeEditor(), para_join(), run_join(), and split_run_extents().

◆ ME_ClearTempStyle()

void ME_ClearTempStyle ( ME_TextEditor editor)

Definition at line 507 of file style.c.

508{
509 if (!editor->pBuffer->pCharStyle) return;
511 editor->pBuffer->pCharStyle = NULL;
512}
void ME_ReleaseStyle(ME_Style *s)
Definition: style.c:462
ME_Style * pCharStyle
Definition: editstr.h:269

Referenced by editor_handle_message(), ME_DestroyEditor(), 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_undo_ignored(editor))
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
static BOOL editor_undo_ignored(ME_TextEditor *editor)
Definition: editor.h:401
@ umAddToUndo
Definition: editstr.h:281
@ undo_end_transaction
Definition: editstr.h:301
@ undo_potential_end_transaction
Definition: editstr.h:302
Definition: list.h:15
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by handle_enter(), handle_wm_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_undo_ignored(editor))
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 editor_copy_or_cut(), editor_handle_message(), handle_EM_SETCHARFORMAT(), handle_enter(), handle_wm_char(), IRichEditOle_fnInsertObject(), ME_KeyDown(), ME_ReplaceSel(), ME_StreamIn(), paste_emf(), set_textfont_prop(), and textrange_set_font().

◆ 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_undo_ignored(editor))
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:413
static void destroy_undo_item(struct undo_item *undo)
Definition: undo.c:25

Referenced by handle_enter(), handle_wm_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_GetSelectionCharFormat(), and run_copy_char_fmt().

◆ ME_CopyReObject()

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

Definition at line 5919 of file richole.c.

5920{
5921 *dst = *src;
5922 dst->poleobj = NULL;
5923 dst->pstg = NULL;
5924 dst->polesite = NULL;
5925
5926 if ((flags & REO_GETOBJ_POLEOBJ) && src->poleobj)
5927 {
5928 dst->poleobj = src->poleobj;
5929 IOleObject_AddRef(dst->poleobj);
5930 }
5931 if ((flags & REO_GETOBJ_PSTG) && src->pstg)
5932 {
5933 dst->pstg = src->pstg;
5934 IStorage_AddRef(dst->pstg);
5935 }
5936 if ((flags & REO_GETOBJ_POLESITE) && src->polesite)
5937 {
5938 dst->polesite = src->polesite;
5939 IOleClientSite_AddRef(dst->polesite);
5940 }
5941}
GLenum src
Definition: glext.h:6340

Referenced by create_re_object(), and IRichEditOle_fnGetObject().

◆ ME_DeleteReObject()

void ME_DeleteReObject ( struct re_object re_object)

Definition at line 5911 of file richole.c.

5912{
5913 if (reobj->obj.poleobj) IOleObject_Release(reobj->obj.poleobj);
5914 if (reobj->obj.pstg) IStorage_Release(reobj->obj.pstg);
5915 if (reobj->obj.polesite) IOleClientSite_Release(reobj->obj.polesite);
5916 free(reobj);
5917}

Referenced by ME_DestroyDisplayItem().

◆ ME_DeleteSelection()

void ME_DeleteSelection ( ME_TextEditor editor)

Definition at line 1425 of file caret.c.

1426{
1427 LONG from, to;
1428 int nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
1429 int nEndCursor = nStartCursor ^ 1;
1430 ME_DeleteTextAtCursor(editor, nStartCursor, to - from);
1431 editor->pCursors[nEndCursor] = editor->pCursors[nStartCursor];
1432}
BOOL ME_DeleteTextAtCursor(ME_TextEditor *editor, int nCursor, int nChars)
Definition: caret.c:481

Referenced by editor_handle_message(), editor_insert_oleobj(), ME_InsertEndRowFromCursor(), ME_InsertTextFromCursor(), and ME_KeyDown().

◆ ME_DeleteTextAtCursor()

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

Definition at line 481 of file caret.c.

482{
483 assert(nCursor>=0 && nCursor<editor->nCursors);
484 /* text operations set modified state */
485 editor->nModifyStep = 1;
486 return ME_InternalDeleteText(editor, &editor->pCursors[nCursor],
487 nChars, FALSE);
488}

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}

Referenced by cursor_coords(), editor_draw(), ME_CharFromPoint(), ME_MakeFirstParagraph(), ME_PointFromChar(), stream_out_graphics(), and wrap_marked_paras_dc().

◆ ME_DestroyDisplayItem()

void ME_DestroyDisplayItem ( ME_DisplayItem item)

Definition at line 115 of file list.c.

116{
117 if (0)
118 TRACE("type=%s\n", ME_GetDITypeName(item->type));
119 if (item->type==diRun)
120 {
121 if (item->member.run.reobj)
122 {
123 list_remove(&item->member.run.reobj->entry);
124 ME_DeleteReObject(item->member.run.reobj);
125 }
126 free(item->member.run.glyphs);
127 free(item->member.run.clusters);
128 ME_ReleaseStyle(item->member.run.style);
129 }
130 free(item);
131}
static const char * ME_GetDITypeName(ME_DIType type)
Definition: list.c:101
void ME_DeleteReObject(struct re_object *re_object)
Definition: richole.c:5911

Referenced by ME_DestroyEditor(), ME_InternalDeleteText(), ME_PrepareParagraphForWrapping(), para_destroy(), para_join(), and run_join().

◆ ME_DestroyEditor()

void ME_DestroyEditor ( ME_TextEditor editor)

Definition at line 3077 of file editor.c.

3078{
3079 ME_DisplayItem *p = editor->pBuffer->pFirst, *pNext = NULL;
3080 ME_Style *s, *cursor2;
3081 int i;
3082
3083 ME_ClearTempStyle(editor);
3084 ME_EmptyUndoStack(editor);
3085 editor->pBuffer->pFirst = NULL;
3086 while(p)
3087 {
3088 pNext = p->next;
3089 if (p->type == diParagraph)
3090 para_destroy( editor, &p->member.para );
3091 else
3093 p = pNext;
3094 }
3095
3096 LIST_FOR_EACH_ENTRY_SAFE( s, cursor2, &editor->style_list, ME_Style, entry )
3097 ME_DestroyStyle( s );
3098
3100 for (i=0; i<HFONT_CACHE_SIZE; i++)
3101 {
3102 if (editor->pFontCache[i].hFont)
3103 DeleteObject(editor->pFontCache[i].hFont);
3104 }
3105 if(editor->lpOleCallback)
3106 IRichEditOleCallback_Release(editor->lpOleCallback);
3107
3109
3110 free(editor->pBuffer);
3111 free(editor->pCursors);
3112 free(editor);
3113}
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:230
void para_destroy(ME_TextEditor *editor, ME_Paragraph *item)
Definition: para.c:42
void ME_DestroyDisplayItem(ME_DisplayItem *item)
Definition: list.c:115
void ME_DestroyStyle(ME_Style *item)
Definition: style.c:442
#define HFONT_CACHE_SIZE
Definition: editstr.h:67
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 LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
ME_FontCacheItem pFontCache[HFONT_CACHE_SIZE]
Definition: editstr.h:420
struct list style_list
Definition: editstr.h:458

Referenced by ITextServicesImpl_Release().

◆ 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 free( s );
101}

Referenced by destroy_undo_item(), draw_text(), ME_CharFromPointContext(), ME_GetRunSizeCommon(), ME_PointFromCharContext(), para_destroy(), 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 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_DumpDocument()

void ME_DumpDocument ( ME_TextBuffer buffer)

Definition at line 142 of file list.c.

143{
144 /* FIXME this is useless, */
145 ME_DisplayItem *pItem = buffer->pFirst;
146 TRACE("DOCUMENT DUMP START\n");
147 while(pItem) {
148 switch(pItem->type)
149 {
150 case diTextStart:
151 TRACE("Start\n");
152 break;
153 case diCell:
154 TRACE("Cell(level=%d%s)\n", pItem->member.cell.nNestingLevel,
155 !pItem->member.cell.next_cell ? ", END" :
156 (!pItem->member.cell.prev_cell ? ", START" :""));
157 break;
158 case diParagraph:
159 TRACE("Paragraph(ofs=%d)\n", pItem->member.para.nCharOfs);
160 if (pItem->member.para.nFlags & MEPF_ROWSTART)
161 TRACE(" - (Table Row Start)\n");
162 if (pItem->member.para.nFlags & MEPF_ROWEND)
163 TRACE(" - (Table Row End)\n");
164 break;
165 case diStartRow:
166 TRACE(" - StartRow\n");
167 break;
168 case diRun:
169 TRACE(" - Run(%s, %d, flags=%x)\n", debugstr_run( &pItem->member.run ),
170 pItem->member.run.nCharOfs, pItem->member.run.nFlags);
171 break;
172 case diTextEnd:
173 TRACE("End(ofs=%d)\n", pItem->member.para.nCharOfs);
174 break;
175 default:
176 break;
177 }
178 pItem = pItem->next;
179 }
180 TRACE("DOCUMENT DUMP END\n");
181}
#define MEPF_ROWSTART
Definition: editstr.h:142
@ diStartRow
Definition: editstr.h:86
int nNestingLevel
Definition: editstr.h:223
ME_DIType type
Definition: editstr.h:256
ME_Cell cell
Definition: editstr.h:261

Referenced by ME_CheckCharOffsets().

◆ ME_DumpParaStyle()

void ME_DumpParaStyle ( ME_Paragraph s)

◆ ME_DumpParaStyleToBuf()

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

Definition at line 785 of file para.c.

786{
787 char *p;
788 p = buf;
789
790#define DUMP(mask, name, fmt, field) \
791 if (pFmt->dwMask & (mask)) p += sprintf(p, "%-22s" fmt "\n", name, pFmt->field); \
792 else p += sprintf(p, "%-22sN/A\n", name);
793
794/* we take for granted that PFE_xxx is the hiword of the corresponding PFM_xxx */
795#define DUMP_EFFECT(mask, name) \
796 p += sprintf(p, "%-22s%s\n", name, (pFmt->dwMask & (mask)) ? ((pFmt->wEffects & ((mask) >> 16)) ? "yes" : "no") : "N/A");
797
798 DUMP(PFM_NUMBERING, "Numbering:", "%u", wNumbering);
799 DUMP_EFFECT(PFM_DONOTHYPHEN, "Disable auto-hyphen:");
800 DUMP_EFFECT(PFM_KEEP, "No page break in para:");
801 DUMP_EFFECT(PFM_KEEPNEXT, "No page break in para & next:");
802 DUMP_EFFECT(PFM_NOLINENUMBER, "No line number:");
803 DUMP_EFFECT(PFM_NOWIDOWCONTROL, "No widow & orphan:");
804 DUMP_EFFECT(PFM_PAGEBREAKBEFORE, "Page break before:");
805 DUMP_EFFECT(PFM_RTLPARA, "RTL para:");
806 DUMP_EFFECT(PFM_SIDEBYSIDE, "Side by side:");
807 DUMP_EFFECT(PFM_TABLE, "Table:");
808 DUMP(PFM_OFFSETINDENT, "Offset indent:", "%ld", dxStartIndent);
809 DUMP(PFM_STARTINDENT, "Start indent:", "%ld", dxStartIndent);
810 DUMP(PFM_RIGHTINDENT, "Right indent:", "%ld", dxRightIndent);
811 DUMP(PFM_OFFSET, "Offset:", "%ld", dxOffset);
812 if (pFmt->dwMask & PFM_ALIGNMENT) {
813 switch (pFmt->wAlignment) {
814 case PFA_LEFT : p += sprintf(p, "Alignment: left\n"); break;
815 case PFA_RIGHT : p += sprintf(p, "Alignment: right\n"); break;
816 case PFA_CENTER : p += sprintf(p, "Alignment: center\n"); break;
817 case PFA_JUSTIFY: p += sprintf(p, "Alignment: justify\n"); break;
818 default : p += sprintf(p, "Alignment: incorrect %d\n", pFmt->wAlignment); break;
819 }
820 }
821 else p += sprintf(p, "Alignment: N/A\n");
822 DUMP(PFM_TABSTOPS, "Tab Stops:", "%d", cTabCount);
823 if (pFmt->dwMask & PFM_TABSTOPS) {
824 int i;
825 p += sprintf(p, "\t");
826 for (i = 0; i < pFmt->cTabCount; i++) p += sprintf(p, "%lx ", pFmt->rgxTabs[i]);
827 p += sprintf(p, "\n");
828 }
829 DUMP(PFM_SPACEBEFORE, "Space Before:", "%ld", dySpaceBefore);
830 DUMP(PFM_SPACEAFTER, "Space After:", "%ld", dySpaceAfter);
831 DUMP(PFM_LINESPACING, "Line spacing:", "%ld", dyLineSpacing);
832 DUMP(PFM_STYLE, "Text style:", "%d", sStyle);
833 DUMP(PFM_LINESPACING, "Line spacing rule:", "%u", bLineSpacingRule);
834 /* bOutlineLevel should be 0 */
835 DUMP(PFM_SHADING, "Shading Weight:", "%u", wShadingWeight);
836 DUMP(PFM_SHADING, "Shading Style:", "%u", wShadingStyle);
837 DUMP(PFM_NUMBERINGSTART, "Numbering Start:", "%u", wNumberingStart);
838 DUMP(PFM_NUMBERINGSTYLE, "Numbering Style:", "0x%x", wNumberingStyle);
839 DUMP(PFM_NUMBERINGTAB, "Numbering Tab:", "%u", wNumberingStyle);
840 DUMP(PFM_BORDER, "Border Space:", "%u", wBorderSpace);
841 DUMP(PFM_BORDER, "Border Width:", "%u", wBorderWidth);
842 DUMP(PFM_BORDER, "Borders:", "%u", wBorders);
843
844#undef DUMP
845#undef DUMP_EFFECT
846}
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 PFA_RIGHT
Definition: richedit.h:922
#define PFA_CENTER
Definition: richedit.h:923
#define PFM_OFFSETINDENT
Definition: richedit.h:844
#define PFM_NOLINENUMBER
Definition: richedit.h:860
#define PFM_KEEPNEXT
Definition: richedit.h:858
#define PFM_DONOTHYPHEN
Definition: richedit.h:862
#define PFM_TABLE
Definition: richedit.h:870
#define PFM_NOWIDOWCONTROL
Definition: richedit.h:861
#define PFM_PAGEBREAKBEFORE
Definition: richedit.h:859
#define PFM_SIDEBYSIDE
Definition: richedit.h:863
#define PFA_JUSTIFY
Definition: richedit.h:924
#define PFM_KEEP
Definition: richedit.h:857
#define PFM_RTLPARA
Definition: richedit.h:856

◆ 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: %ld\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: %ld\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
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) /* NOTE don't use editor_undo_ignored() here! */
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(), editor_disable_undo(), editor_handle_message(), fnTextSrv_TxSetText(), ME_DestroyEditor(), 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 free(psz);
252}
int codepage
Definition: win_iconv.c:156

Referenced by editor_handle_message(), ME_SetText(), and RichEditWndProc_common().

◆ ME_FindItemBack()

ME_DisplayItem * ME_FindItemBack ( ME_DisplayItem di,
ME_DIType  nTypeOrClass 
)

Definition at line 66 of file list.c.

67{
68 if (!di)
69 return NULL;
70 di = di->prev;
71 while(di!=NULL) {
72 if (ME_DITypesEqual(di->type, nTypeOrClass))
73 return di;
74 di = di->prev;
75 }
76 return NULL;
77}
static BOOL ME_DITypesEqual(ME_DIType type, ME_DIType nTypeOrClass)
Definition: list.c:45

Referenced by cell_end_para(), para_end_row(), row_end_cursor(), row_from_cursor(), row_next_run(), row_prev_all_paras(), table_outer_para(), and table_row_start().

◆ ME_FindItemBackOrHere()

ME_DisplayItem * ME_FindItemBackOrHere ( ME_DisplayItem di,
ME_DIType  nTypeOrClass 
)

Definition at line 79 of file list.c.

80{
81 while(di!=NULL) {
82 if (ME_DITypesEqual(di->type, nTypeOrClass))
83 return di;
84 di = di->prev;
85 }
86 return NULL;
87}

◆ ME_FindItemFwd()

ME_DisplayItem * ME_FindItemFwd ( ME_DisplayItem di,
ME_DIType  nTypeOrClass 
)

Definition at line 89 of file list.c.

90{
91 if (!di) return NULL;
92 di = di->next;
93 while(di!=NULL) {
94 if (ME_DITypesEqual(di->type, nTypeOrClass))
95 return di;
96 di = di->next;
97 }
98 return NULL;
99}

Referenced by cell_first_para(), ME_CheckCharOffsets(), para_first_row(), row_end_cursor(), row_first_cursor(), row_first_run(), row_next(), row_next_all_paras(), row_next_run(), and table_row_end().

◆ ME_FindNonWhitespaceV()

int ME_FindNonWhitespaceV ( const ME_String s,
int  nVChar 
)

◆ ME_GetCharFormat()

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

Definition at line 876 of file run.c.

878{
879 ME_Run *run, *run_end, *prev_run;
880 CHARFORMAT2W tmp;
881
882 run = from->run;
883 /* special case - if selection is empty, take previous char's formatting */
884 if (from->run == to->run && from->nOffset == to->nOffset)
885 {
886 if (!from->nOffset && (prev_run = run_prev( run ))) run = prev_run;
887 run_copy_char_fmt( run, fmt );
888 return;
889 }
890
891 run_end = to->run;
892 if (!to->nOffset) run_end = run_prev_all_paras( run_end );
893
894 run_copy_char_fmt( run, fmt );
895
896 if (run == run_end) return;
897
898 do {
899 /* FIXME add more style feature comparisons */
902
903 run = run_next_all_paras( run );
904
905 memset( &tmp, 0, sizeof(tmp) );
906 tmp.cbSize = sizeof(tmp);
907 run_copy_char_fmt( run, &tmp );
908
909 assert((tmp.dwMask & dwAttribs) == dwAttribs);
910
911 /* reset flags that differ */
912 if (fmt->dwMask & CFM_FACE)
913 {
914 if (!(tmp.dwMask & CFM_FACE))
915 fmt->dwMask &= ~CFM_FACE;
916 else if (wcscmp( fmt->szFaceName, tmp.szFaceName ) ||
917 fmt->bPitchAndFamily != tmp.bPitchAndFamily)
918 fmt->dwMask &= ~CFM_FACE;
919 }
920 if (fmt->yHeight != tmp.yHeight) fmt->dwMask &= ~CFM_SIZE;
921 if (fmt->bUnderlineType != tmp.bUnderlineType) fmt->dwMask &= ~CFM_UNDERLINETYPE;
922 if (fmt->dwMask & CFM_COLOR)
923 {
924 if (!((fmt->dwEffects&CFE_AUTOCOLOR) & (tmp.dwEffects&CFE_AUTOCOLOR)))
925 {
926 if (fmt->crTextColor != tmp.crTextColor)
927 fmt->dwMask &= ~CFM_COLOR;
928 }
929 }
930
931 fmt->dwMask &= ~((fmt->dwEffects ^ tmp.dwEffects) & dwEffects);
932 fmt->dwEffects = tmp.dwEffects;
933
934 } while(run != run_end);
935}
ME_Run * run_prev(ME_Run *run)
Definition: run.c:82
static void run_copy_char_fmt(ME_Run *run, CHARFORMAT2W *fmt)
Definition: run.c:836
ME_Run * run_prev_all_paras(ME_Run *run)
Definition: run.c:110
ME_Run * run_next_all_paras(ME_Run *run)
Definition: run.c:96
#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)
#define memset(x, y, z)
Definition: compat.h:39
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_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 847 of file run.c.

848{
849 ME_CopyCharFormat(pFmt, &editor->pBuffer->pDefaultStyle->fmt);
850}
void ME_CopyCharFormat(CHARFORMAT2W *pDest, const CHARFORMAT2W *pSrc)
Definition: style.c:230

Referenced by editor_handle_message().

◆ ME_GetOLEObjectSize()

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

Definition at line 5708 of file richole.c.

5709{
5710 IDataObject* ido;
5711 FORMATETC fmt;
5712 STGMEDIUM stgm;
5713 DIBSECTION dibsect;
5714 ENHMETAHEADER emh;
5715
5716 assert(run->nFlags & MERF_GRAPHICS);
5717 assert(run->reobj);
5718
5719 if (run->reobj->obj.sizel.cx != 0 || run->reobj->obj.sizel.cy != 0)
5720 {
5721 convert_sizel(c, &run->reobj->obj.sizel, pSize);
5722 if (c->editor->nZoomNumerator != 0)
5723 {
5724 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5725 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5726 }
5727 return;
5728 }
5729
5730 if (!run->reobj->obj.poleobj)
5731 {
5732 pSize->cx = pSize->cy = 0;
5733 return;
5734 }
5735
5736 if (IOleObject_QueryInterface(run->reobj->obj.poleobj, &IID_IDataObject, (void**)&ido) != S_OK)
5737 {
5738 FIXME("Query Interface IID_IDataObject failed!\n");
5739 pSize->cx = pSize->cy = 0;
5740 return;
5741 }
5742 fmt.cfFormat = CF_BITMAP;
5743 fmt.ptd = NULL;
5744 fmt.dwAspect = DVASPECT_CONTENT;
5745 fmt.lindex = -1;
5746 fmt.tymed = TYMED_GDI;
5747 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
5748 {
5749 fmt.cfFormat = CF_ENHMETAFILE;
5750 fmt.tymed = TYMED_ENHMF;
5751 if (IDataObject_GetData(ido, &fmt, &stgm) != S_OK)
5752 {
5753 FIXME("unsupported format\n");
5754 pSize->cx = pSize->cy = 0;
5755 IDataObject_Release(ido);
5756 return;
5757 }
5758 }
5759 IDataObject_Release(ido);
5760
5761 switch (stgm.tymed)
5762 {
5763 case TYMED_GDI:
5764 GetObjectW(stgm.hBitmap, sizeof(dibsect), &dibsect);
5765 pSize->cx = dibsect.dsBm.bmWidth;
5766 pSize->cy = dibsect.dsBm.bmHeight;
5767 break;
5768 case TYMED_ENHMF:
5769 GetEnhMetaFileHeader(stgm.hEnhMetaFile, sizeof(emh), &emh);
5770 pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
5771 pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
5772 break;
5773 default:
5774 FIXME("Unsupported tymed %ld\n", stgm.tymed);
5775 break;
5776 }
5777 ReleaseStgMedium(&stgm);
5778 if (c->editor->nZoomNumerator != 0)
5779 {
5780 pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5781 pSize->cy = MulDiv(pSize->cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
5782 }
5783}

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

◆ ME_GetParaBorderWidth()

int ME_GetParaBorderWidth ( const ME_Context c,
int  flags 
)

Definition at line 541 of file paint.c.

542{
543 int idx = (flags >> 8) & 0xF;
544 int width;
545
547 {
548 FIXME("Unsupported border value %d\n", idx);
549 return 0;
550 }
552 if (border_details[idx].dble) width = width * 2 + 1;
553 return width;
554}
unsigned int idx
Definition: utils.c:41
static int ME_GetBorderPenWidth(const ME_Context *c, int idx)
Definition: paint.c:528
static const struct @597 border_details[]
unsigned width
Definition: paint.c:502
unsigned dble
Definition: paint.c:502

Referenced by ME_DrawParaDecoration(), and ME_WrapTextParagraph().

◆ 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 674 of file run.c.

676{
677 SIZE size;
678
679 nLen = min( nLen, run->len );
680
681 if (run->nFlags & MERF_ENDPARA)
682 {
683 nLen = min( nLen, 1 );
684 ME_GetTextExtent( c, L" ", nLen, run->style, &size );
685 }
686 else if (para->nFlags & MEPF_COMPLEX)
687 {
688 size.cx = run->nWidth;
689 }
690 else if (c->editor->password_char)
691 {
692 ME_String *szMasked = ME_MakeStringR( c->editor->password_char, nLen );
693 ME_GetTextExtent(c, szMasked->szData, nLen,run->style, &size);
694 ME_DestroyString(szMasked);
695 }
696 else
697 {
698 ME_GetTextExtent(c, get_text( run, 0 ), nLen, run->style, &size);
699 }
700 *pAscent = run->style->tm.tmAscent;
701 *pDescent = run->style->tm.tmDescent;
702 size.cy = *pAscent + *pDescent;
703
704 if (run->nFlags & MERF_TAB)
705 {
706 int pos = 0, i = 0, ppos, shift = 0;
707 const PARAFORMAT2 *pFmt = &para->fmt;
708
709 if (c->editor->bEmulateVersion10 && /* v1.0 - 3.0 */
710 pFmt->dwMask & PFM_TABLE && pFmt->wEffects & PFE_TABLE)
711 /* The horizontal gap shifts the tab positions to leave the gap. */
712 shift = pFmt->dxOffset * 2;
713 do {
714 if (i < pFmt->cTabCount)
715 {
716 /* Only one side of the horizontal gap is needed at the end of
717 * the table row. */
718 if (i == pFmt->cTabCount -1)
719 shift = shift >> 1;
720 pos = shift + (pFmt->rgxTabs[i]&0x00FFFFFF);
721 i++;
722 }
723 else
724 {
726 }
727 ppos = ME_twips2pointsX(c, pos);
728 if (ppos > startx + run->pt.x) {
729 size.cx = ppos - startx - run->pt.x;
730 break;
731 }
732 } while(1);
733 size.cy = *pAscent + *pDescent;
734 return size;
735 }
736 if (run->nFlags & MERF_GRAPHICS)
737 {
738 ME_GetOLEObjectSize(c, run, &size);
739 if (size.cy > *pAscent)
740 *pAscent = size.cy;
741 /* descent is unchanged */
742 return size;
743 }
744 return size;
745}
static void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style *s, SIZE *size)
Definition: run.c:593
int ME_twips2pointsX(const ME_Context *c, int x)
Definition: paint.c:171
#define MERF_ENDPARA
Definition: editstr.h:120
#define lDefaultTab
Definition: richedit.h:215
#define PFE_TABLE
Definition: richedit.h:944
LONG dxOffset
Definition: richedit.h:672
TEXTMETRICW tm
Definition: editstr.h:74
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}
#define swap(a, b)
Definition: qsort.c:63

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

◆ ME_GetSelectionCharFormat()

void ME_GetSelectionCharFormat ( ME_TextEditor editor,
CHARFORMAT2W pFmt 
)

Definition at line 858 of file run.c.

859{
860 ME_Cursor *from, *to;
861 if (!ME_IsSelection(editor) && editor->pBuffer->pCharStyle)
862 {
863 ME_CopyCharFormat(pFmt, &editor->pBuffer->pCharStyle->fmt);
864 return;
865 }
866 ME_GetSelection(editor, &from, &to);
867 ME_GetCharFormat(editor, from, to, pFmt);
868}
int ME_GetSelection(ME_TextEditor *editor, ME_Cursor **from, ME_Cursor **to)
Definition: caret.c:57
void ME_GetCharFormat(ME_TextEditor *editor, const ME_Cursor *from, const ME_Cursor *to, CHARFORMAT2W *fmt)
Definition: run.c:876

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

◆ ME_GetSelectionInsertStyle()

ME_Style * ME_GetSelectionInsertStyle ( ME_TextEditor editor)

Definition at line 1434 of file caret.c.

1435{
1436 return style_get_insert_style( editor, editor->pCursors );
1437}

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

◆ ME_GetSelectionOfs()

◆ 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->props & TXTBIT_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: precomp.h:57
BOOL WINAPI GetCPInfo(UINT codepage, LPCPINFO cpinfo)
Definition: locale.c:2144
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define GTL_PRECISE
Definition: richedit.h:1056
#define GTL_NUMBYTES
Definition: richedit.h:1059
UINT MaxCharSize
Definition: winnls.h:601

Referenced by editor_handle_message().

◆ 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 4325 of file editor.c.

4328{
4329 ME_Run *run, *next_run;
4330 const WCHAR *pStart = buffer;
4331 const WCHAR *str;
4332 int nLen;
4333
4334 /* bCRLF flag is only honored in 2.0 and up. 1.0 must always return text verbatim */
4335 if (editor->bEmulateVersion10) bCRLF = FALSE;
4336
4337 run = start->run;
4338 next_run = run_next_all_paras( run );
4339
4340 nLen = run->len - start->nOffset;
4341 str = get_text( run, start->nOffset );
4342
4343 while (srcChars && buflen && next_run)
4344 {
4345 if (bCRLF && run->nFlags & MERF_ENDPARA && ~run->nFlags & MERF_ENDCELL)
4346 {
4347 if (buflen == 1) break;
4348 /* FIXME: native fails to reduce srcChars here for WM_GETTEXT or
4349 * EM_GETTEXTEX, however, this is done for copying text which
4350 * also uses this function. */
4351 srcChars -= min(nLen, srcChars);
4352 nLen = 2;
4353 str = L"\r\n";
4354 }
4355 else
4356 {
4357 nLen = min(nLen, srcChars);
4358 srcChars -= nLen;
4359 }
4360
4361 nLen = min(nLen, buflen);
4362 buflen -= nLen;
4363
4364 CopyMemory(buffer, str, sizeof(WCHAR) * nLen);
4365
4366 buffer += nLen;
4367
4368 run = next_run;
4369 next_run = run_next_all_paras( run );
4370
4371 nLen = run->len;
4372 str = get_text( run, 0 );
4373 }
4374 /* append '\r' to the last paragraph. */
4375 if (run == para_end_run( para_prev( editor_end_para( editor ) ) ) && bEOP && buflen)
4376 {
4377 *buffer = '\r';
4378 buffer ++;
4379 }
4380 *buffer = 0;
4381 return buffer - pStart;
4382}
ME_Run * run_next_all_paras(ME_Run *run)
Definition: run.c:96

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

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

◆ 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 cursor_coords(), editor_draw(), ME_CharFromPoint(), ME_MakeFirstParagraph(), ME_PointFromChar(), stream_out_graphics(), and wrap_marked_paras_dc().

◆ ME_InitTableDef()

void ME_InitTableDef ( ME_TextEditor editor,
struct RTFTable tableDef 
)

Definition at line 556 of file table.c.

557{
558 ZeroMemory(tableDef->cells, sizeof(tableDef->cells));
559 ZeroMemory(tableDef->border, sizeof(tableDef->border));
560 tableDef->numCellsDefined = 0;
561 tableDef->leftEdge = 0;
562 if (!editor->bEmulateVersion10) /* v4.1 */
563 tableDef->gapH = 10;
564 else /* v1.0 - 3.0 */
565 tableDef->gapH = 0;
566}
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_MakeFirstParagraph(), para_split(), run_insert(), and run_split().

◆ ME_InsertEndRowFromCursor()

void ME_InsertEndRowFromCursor ( ME_TextEditor editor,
int  nCursor 
)

Definition at line 568 of file caret.c.

569{
570 const WCHAR space = ' ';
571 ME_Cursor *cursor = editor->pCursors + nCursor;
573
574 /* FIXME no no no */
575 if (ME_IsSelection(editor))
576 ME_DeleteSelection(editor);
577
578 run_insert( editor, cursor, style, &space, 1, MERF_ENDROW );
579
581}
#define MERF_ENDROW
Definition: editstr.h:122

Referenced by handle_enter(), and SpecialChar().

◆ 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 = 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}
#define realloc
Definition: debug_ros.c:6
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 run_insert().

◆ ME_InsertTextFromCursor()

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

Definition at line 584 of file caret.c.

586{
587 const WCHAR *pos;
588 ME_Cursor *cursor = editor->pCursors + nCursor;
589 int oldLen;
590
591 /* FIXME really HERE ? */
592 if (ME_IsSelection(editor))
593 ME_DeleteSelection(editor);
594
595 oldLen = ME_GetTextLength(editor);
596
597 /* text operations set modified state */
598 editor->nModifyStep = 1;
599
600 assert(style);
601
602 if (len == -1) len = lstrlenW( str );
603
604 /* grow the text limit to fit our text */
605 if (editor->nTextLimit < oldLen + len) editor->nTextLimit = oldLen + len;
606
607 pos = str;
608
609 while (len)
610 {
611 /* FIXME this sucks - no respect for unicode (what else can be a line separator in unicode?) */
612 while (pos - str < len && *pos != '\r' && *pos != '\n' && *pos != '\t')
613 pos++;
614
615 if (pos != str) /* handle text */
616 run_insert( editor, cursor, style, str, pos - str, 0 );
617 else if (*pos == '\t') /* handle tabs */
618 {
619 const WCHAR tab = '\t';
620 run_insert( editor, cursor, style, &tab, 1, MERF_TAB );
621 pos++;
622 }
623 else /* handle EOLs */
624 {
625 ME_Run *end_run, *run, *prev;
626 ME_Paragraph *new_para;
627 int eol_len = 0;
628
629 /* Check if new line is allowed for this control */
630 if (!(editor->props & TXTBIT_MULTILINE))
631 break;
632
633 /* Find number of CR and LF in end of paragraph run */
634 if (*pos =='\r')
635 {
636 if (len > 1 && pos[1] == '\n')
637 eol_len = 2;
638 else if (len > 2 && pos[1] == '\r' && pos[2] == '\n')
639 eol_len = 3;
640 else
641 eol_len = 1;
642 }
643 else
644 {
645 assert(*pos == '\n');
646 eol_len = 1;
647 }
648 pos += eol_len;
649
650 if (!editor->bEmulateVersion10 && eol_len == 3)
651 {
652 /* handle special \r\r\n sequence (richedit 2.x and higher only) */
653 const WCHAR space = ' ';
654 run_insert( editor, cursor, style, &space, 1, 0 );
655 }
656 else
657 {
658 const WCHAR cr = '\r', *eol_str = str;
659
660 if (!editor->bEmulateVersion10)
661 {
662 eol_str = &cr;
663 eol_len = 1;
664 }
665
666 if (cursor->nOffset == cursor->run->len)
667 {
668 run = run_next( cursor->run );
669 if (!run) run = cursor->run;
670 }
671 else
672 {
673 if (cursor->nOffset) run_split( editor, cursor );
674 run = cursor->run;
675 }
676
677 new_para = para_split( editor, run, style, eol_str, eol_len, 0 );
678 end_run = para_end_run( para_prev( new_para ) );
679
680 /* Move any cursors that were at the end of the previous run to the beginning of the new para */
681 prev = run_prev( end_run );
682 if (prev)
683 {
684 int i;
685 for (i = 0; i < editor->nCursors; i++)
686 {
687 if (editor->pCursors[i].run == prev &&
688 editor->pCursors[i].nOffset == prev->len)
689 {
690 editor->pCursors[i].para = new_para;
691 editor->pCursors[i].run = run;
692 editor->pCursors[i].nOffset = 0;
693 }
694 }
695 }
696
697 }
698 }
699 len -= pos - str;
700 str = pos;
701 }
702}
ME_Paragraph * para_split(ME_TextEditor *editor, ME_Run *run, ME_Style *style, const WCHAR *eol_str, int eol_len, int paraFlags)
Definition: para.c:538
ME_Run * run_split(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: run.c:310
static struct wctab tab[]

Referenced by editor_handle_message(), fnTextSrv_TxSetText(), handle_enter(), handle_wm_char(), ITextRange_fnSetText(), ME_ReplaceSel(), ME_RTFParAttrHook(), ME_RTFSpecialCharHook(), ME_SetText(), ME_StreamInText(), RTFFlushUnicodeOutputBuffer(), and table_append_row().

◆ ME_InternalDeleteText()

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

Definition at line 339 of file caret.c.

341{
342 ME_Cursor c = *start;
343 int nOfs = ME_GetCursorOfs(start), text_len = ME_GetTextLength( editor );
344 int shift = 0;
345 int totalChars = nChars;
346 ME_Paragraph *start_para;
347 BOOL delete_all = FALSE;
348
349 /* Prevent deletion past last end of paragraph run. */
350 nChars = min(nChars, text_len - nOfs);
351 if (nChars == text_len) delete_all = TRUE;
352 start_para = c.para;
353
354 if (!bForce)
355 {
356 table_protect_partial_deletion( editor, &c, &nChars );
357 if (nChars == 0) return FALSE;
358 }
359
360 while (nChars > 0)
361 {
362 ME_Run *run;
363 cursor_from_char_ofs( editor, nOfs + nChars, &c );
364 if (!c.nOffset)
365 {
366 /* We aren't deleting anything in this run, so we will go back to the
367 * last run we are deleting text in. */
368 c.run = run_prev_all_paras( c.run );
369 c.para = c.run->para;
370 c.nOffset = c.run->len;
371 }
372 run = c.run;
373 if (run->nFlags & MERF_ENDPARA)
374 {
375 int eollen = c.run->len;
376 BOOL keepFirstParaFormat;
377
378 if (!para_next( para_next( c.para ) )) return TRUE;
379
380 keepFirstParaFormat = (totalChars == nChars && nChars <= eollen &&
381 run->nCharOfs);
382 if (!editor->bEmulateVersion10) /* v4.1 */
383 {
384 ME_Paragraph *this_para = run->para;
385 ME_Paragraph *next_para = para_next( this_para );
386
387 /* The end of paragraph before a table row is only deleted if there
388 * is nothing else on the line before it. */
389 if (this_para == start_para && next_para->nFlags & MEPF_ROWSTART)
390 {
391 /* If the paragraph will be empty, then it should be deleted, however
392 * it still might have text right now which would inherit the
393 * MEPF_STARTROW property if we joined it right now.
394 * Instead we will delete it after the preceding text is deleted. */
395 if (nOfs > this_para->nCharOfs)
396 {
397 /* Skip this end of line. */
398 nChars -= (eollen < nChars) ? eollen : nChars;
399 continue;
400 }
401 keepFirstParaFormat = TRUE;
402 }
403 }
404 para_join( editor, c.para, keepFirstParaFormat );
405 /* ME_SkipAndPropagateCharOffset(p->pRun, shift); */
406 ME_CheckCharOffsets(editor);
407 nChars -= (eollen < nChars) ? eollen : nChars;
408 continue;
409 }
410 else
411 {
413 int nCharsToDelete = min(nChars, c.nOffset);
414 int i;
415
416 c.nOffset -= nCharsToDelete;
417
418 para_mark_rewrap( editor, c.run->para );
419
420 cursor = c;
421 /* nChars is the number of characters that should be deleted from the
422 PRECEDING runs (these BEFORE cursor.pRun)
423 nCharsToDelete is a number of chars to delete from THIS run */
424 nChars -= nCharsToDelete;
425 shift -= nCharsToDelete;
426 TRACE("Deleting %d (remaining %d) chars at %d in %s (%d)\n",
427 nCharsToDelete, nChars, c.nOffset,
428 debugstr_run( run ), run->len);
429
430 /* nOfs is a character offset (from the start of the document
431 to the current (deleted) run */
432 add_undo_insert_run( editor, nOfs + nChars, get_text( run, c.nOffset ), nCharsToDelete, run->nFlags, run->style );
433
434 ME_StrDeleteV(run->para->text, run->nCharOfs + c.nOffset, nCharsToDelete);
435 run->len -= nCharsToDelete;
436 TRACE("Post deletion string: %s (%d)\n", debugstr_run( run ), run->len);
437 TRACE("Shift value: %d\n", shift);
438
439 /* update cursors (including c) */
440 for (i=-1; i<editor->nCursors; i++) {
441 ME_Cursor *pThisCur = editor->pCursors + i;
442 if (i == -1) pThisCur = &c;
443 if (pThisCur->run == cursor.run) {
444 if (pThisCur->nOffset > cursor.nOffset) {
445 if (pThisCur->nOffset-cursor.nOffset < nCharsToDelete)
446 pThisCur->nOffset = cursor.nOffset;
447 else
448 pThisCur->nOffset -= nCharsToDelete;
449 assert(pThisCur->nOffset >= 0);
450 assert(pThisCur->nOffset <= run->len);
451 }
452 if (pThisCur->nOffset == run->len)
453 {
454 pThisCur->run = run_next( pThisCur->run );
455 assert( pThisCur->run );
456 pThisCur->nOffset = 0;
457 }
458 }
459 }
460
461 /* c = updated data now */
462
463 if (c.run == cursor.run) c.run->nCharOfs -= shift;
464 editor_propagate_char_ofs( editor, NULL, c.run, shift );
465
466 if (!cursor.run->len)
467 {
468 TRACE("Removing empty run\n");
469 ME_Remove( run_get_di( cursor.run ));
471 }
472
473 shift = 0;
474 continue;
475 }
476 }
477 if (delete_all) editor_set_default_para_fmt( editor, &start_para->fmt );
478 return TRUE;
479}
void editor_set_default_para_fmt(ME_TextEditor *editor, PARAFORMAT2 *pFmt)
Definition: para.c:958
void ME_Remove(ME_DisplayItem *diWhere)
Definition: list.c:35
void editor_propagate_char_ofs(ME_TextEditor *editor, ME_Paragraph *para, ME_Run *run, int shift)
Definition: run.c:147
ME_Paragraph * para_join(ME_TextEditor *editor, ME_Paragraph *para, BOOL use_first_fmt)
Definition: para.c:681
void table_protect_partial_deletion(ME_TextEditor *editor, ME_Cursor *c, int *num_chars)
Definition: table.c:217
void ME_StrDeleteV(ME_String *s, int nVChar, int nChars)
Definition: string.c:147
void para_mark_rewrap(ME_TextEditor *editor, ME_Paragraph *para)
Definition: para.c:26
BOOL add_undo_insert_run(ME_TextEditor *, int pos, const WCHAR *str, int len, int flags, ME_Style *style)
Definition: undo.c:131

Referenced by editor_copy_or_cut(), editor_handle_message(), fnTextSrv_TxSetText(), ITextRange_fnSetText(), ME_DeleteTextAtCursor(), ME_PlayUndoItem(), ME_ReplaceSel(), ME_RTFSpecialCharHook(), and ME_StreamIn().

◆ ME_InvalidateSelection()

void ME_InvalidateSelection ( ME_TextEditor editor)

Definition at line 1253 of file paint.c.

1254{
1255 ME_Paragraph *sel_start, *sel_end;
1256 ME_Paragraph *repaint_start = NULL, *repaint_end = NULL;
1257 LONG nStart, nEnd;
1258 int len = ME_GetTextLength(editor);
1259
1260 ME_GetSelectionOfs(editor, &nStart, &nEnd);
1261 /* if both old and new selection are 0-char (= caret only), then
1262 there's no (inverted) area to be repainted, neither old nor new */
1263 if (nStart == nEnd && editor->nLastSelStart == editor->nLastSelEnd)
1264 return;
1266 editor_get_selection_paras( editor, &sel_start, &sel_end );
1267
1268 /* last selection markers aren't always updated, which means
1269 * they can point past the end of the document */
1270 if (editor->nLastSelStart > len || editor->nLastSelEnd > len)
1271 {
1272 repaint_start = editor_first_para( editor );
1273 repaint_end = para_prev( editor_end_para( editor ) );
1274 }
1275 else
1276 {
1277 /* if the start part of selection is being expanded or contracted... */
1278 if (nStart < editor->nLastSelStart)
1279 {
1280 repaint_start = sel_start;
1281 repaint_end = editor->last_sel_start_para;
1282 }
1283 else if (nStart > editor->nLastSelStart)
1284 {
1285 repaint_start = editor->last_sel_start_para;
1286 repaint_end = sel_start;
1287 }
1288
1289 /* if the end part of selection is being contracted or expanded... */
1290 if (nEnd < editor->nLastSelEnd)
1291 {
1292 if (!repaint_start) repaint_start = sel_end;
1293 repaint_end = editor->last_sel_end_para;
1294 }
1295 else if (nEnd > editor->nLastSelEnd)
1296 {
1297 if (!repaint_start) repaint_start = editor->last_sel_end_para;
1298 repaint_end = sel_end;
1299 }
1300 }
1301
1302 if (repaint_start)
1303 para_range_invalidate( editor, repaint_start, repaint_end );
1304 /* remember the last invalidated position */
1305 ME_GetSelectionOfs(editor, &editor->nLastSelStart, &editor->nLastSelEnd);
1307}
void editor_get_selection_paras(ME_TextEditor *editor, ME_Paragraph **para, ME_Paragraph **para_end)
Definition: para.c:848
void para_range_invalidate(ME_TextEditor *editor, ME_Paragraph *start_para, ME_Paragraph *last_para)
Definition: wrap.c:1111
ME_Paragraph * last_sel_end_para
Definition: editstr.h:419
ME_Paragraph * last_sel_start_para
Definition: editstr.h:419
LONG nLastSelEnd
Definition: editstr.h:418
LONG nLastSelStart
Definition: editstr.h:418

Referenced by editor_handle_message(), fnTextSrv_OnTxPropertyBitsChange(), ME_ArrowKey(), ME_LButtonDown(), ME_MouseMove(), set_selection(), and table_handle_tab().

◆ ME_IsSelection()

◆ ME_IsWSpace()

static int ME_IsWSpace ( WCHAR  ch)
inlinestatic

◆ ME_LButtonDown()

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

Definition at line 1156 of file caret.c.

1157{
1158 ME_Cursor tmp_cursor;
1159 BOOL is_selection = FALSE, is_shift;
1160
1161 editor->nUDArrowX = -1;
1162
1163 x += editor->horz_si.nPos;
1164 y += editor->vert_si.nPos;
1165
1166 tmp_cursor = editor->pCursors[0];
1167 is_selection = ME_IsSelection(editor);
1168 is_shift = GetKeyState(VK_SHIFT) < 0;
1169
1170 cursor_from_virtual_coords( editor, x, y, &editor->pCursors[0], FALSE );
1171
1172 if (x >= editor->rcFormat.left || is_shift)
1173 {
1174 if (clickNum > 1)
1175 {
1176 editor->pCursors[1] = editor->pCursors[0];
1177 if (is_shift) {
1178 if (x >= editor->rcFormat.left)
1179 ME_SelectByType(editor, stWord);
1180 else
1182 } else if (clickNum % 2 == 0) {
1183 ME_SelectByType(editor, stWord);
1184 } else {
1186 }
1187 }
1188 else if (!is_shift)
1189 {
1190 editor->nSelectionType = stPosition;
1191 editor->pCursors[1] = editor->pCursors[0];
1192 }
1193 else if (!is_selection)
1194 {
1195 editor->nSelectionType = stPosition;
1196 editor->pCursors[1] = tmp_cursor;
1197 }
1198 else if (editor->nSelectionType != stPosition)
1199 {
1201 }
1202 }
1203 else
1204 {
1205 if (clickNum < 2) {
1206 ME_SelectByType(editor, stLine);
1207 } else if (clickNum % 2 == 0 || is_shift) {
1209 } else {
1210 ME_SelectByType(editor, stDocument);
1211 }
1212 }
1213 ME_InvalidateSelection(editor);
1214 update_caret(editor);
1215 ME_SendSelChange(editor);
1216}
static void ME_ExtendAnchorSelection(ME_TextEditor *editor)
Definition: caret.c:1088
static void ME_SelectByType(ME_TextEditor *editor, ME_SelectionType selectionType)
Definition: caret.c:875
@ stWord
Definition: editstr.h:364
@ stParagraph
Definition: editstr.h:366
#define VK_SHIFT
Definition: winuser.h:2221

Referenced by editor_handle_message().

◆ ME_MakeDI()

ME_DisplayItem * ME_MakeDI ( ME_DIType  type)

Definition at line 133 of file list.c.

134{
135 ME_DisplayItem *item = calloc(1, sizeof(*item));
136
137 item->type = type;
138 item->prev = item->next = NULL;
139 return item;
140}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define calloc
Definition: rosglue.h:14

Referenced by cell_create(), ME_MakeText(), para_create(), row_create(), and run_create().

◆ ME_MakeEditor()

ME_TextEditor * ME_MakeEditor ( ITextHost *  texthost,
BOOL  bEmulateVersion10 
)

Definition at line 2936 of file editor.c.

2937{
2938 ME_TextEditor *ed = malloc( sizeof(*ed) );
2939 int i;
2940 LONG selbarwidth;
2941 HRESULT hr;
2942 HDC hdc;
2943
2944 ed->sizeWindow.cx = ed->sizeWindow.cy = 0;
2945 if (ITextHost_QueryInterface( texthost, &IID_ITextHost2, (void **)&ed->texthost ) == S_OK)
2946 {
2947 ITextHost_Release( texthost );
2948 ed->have_texthost2 = TRUE;
2949 }
2950 else
2951 {
2952 ed->texthost = (ITextHost2 *)texthost;
2953 ed->have_texthost2 = FALSE;
2954 }
2955
2956 ed->bEmulateVersion10 = bEmulateVersion10;
2957 ed->in_place_active = FALSE;
2958 ed->total_rows = 0;
2963 &ed->props );
2965 ed->pBuffer = ME_MakeText();
2966 ed->nZoomNumerator = ed->nZoomDenominator = 0;
2967 ed->nAvailWidth = 0; /* wrap to client area */
2968 list_init( &ed->style_list );
2969
2972 /* The four cursors are for:
2973 * 0 - The position where the caret is shown
2974 * 1 - The anchored end of the selection (for normal selection)
2975 * 2 & 3 - The anchored start and end respectively for word, line,
2976 * or paragraph selection.
2977 */
2978 ed->nCursors = 4;
2979 ed->pCursors = malloc( ed->nCursors * sizeof(*ed->pCursors) );
2980 ME_SetCursorToStart(ed, &ed->pCursors[0]);
2981 ed->pCursors[1] = ed->pCursors[0];
2982 ed->pCursors[2] = ed->pCursors[0];
2983 ed->pCursors[3] = ed->pCursors[1];
2984 ed->nLastTotalLength = ed->nTotalLength = 0;
2985 ed->nLastTotalWidth = ed->nTotalWidth = 0;
2986 ed->nUDArrowX = -1;
2987 ed->nEventMask = 0;
2988 ed->nModifyStep = 0;
2990 list_init( &ed->undo_stack );
2991 list_init( &ed->redo_stack );
2992 ed->nUndoStackSize = 0;
2994 ed->nUndoMode = umAddToUndo;
2996 ed->nParagraphs = 1;
2997 ed->nLastSelStart = ed->nLastSelEnd = 0;
2999 ed->bHideSelection = FALSE;
3000 ed->pfnWordBreak = NULL;
3001 ed->richole = NULL;
3002 ed->lpOleCallback = NULL;
3006 ed->bHaveFocus = FALSE;
3007 ed->freeze_count = 0;
3008 ed->bMouseCaptured = FALSE;
3009 ed->caret_hidden = FALSE;
3010 ed->caret_height = 0;
3011 for (i=0; i<HFONT_CACHE_SIZE; i++)
3012 {
3013 ed->pFontCache[i].nRefs = 0;
3014 ed->pFontCache[i].nAge = 0;
3015 ed->pFontCache[i].hFont = NULL;
3016 }
3017
3019 SetRectEmpty(&ed->rcFormat);
3020 hr = ITextHost_TxGetSelectionBarWidth( ed->texthost, &selbarwidth );
3021 /* FIXME: Convert selbarwidth from HIMETRIC to pixels */
3022 if (hr == S_OK && selbarwidth) ed->selofs = SELECTIONBAR_WIDTH;
3023 else ed->selofs = 0;
3025
3026 ed->password_char = 0;
3027 if (ed->props & TXTBIT_USEPASSWORD)
3029
3030 ed->bWordWrap = (ed->props & TXTBIT_WORDWRAP) && (ed->props & TXTBIT_MULTILINE);
3031
3032 ed->notified_cr.cpMin = ed->notified_cr.cpMax = 0;
3033
3034 /* Default scrollbar information */
3035 ed->vert_si.cbSize = sizeof(SCROLLINFO);
3036 ed->vert_si.nMin = 0;
3037 ed->vert_si.nMax = 0;
3038 ed->vert_si.nPage = 0;
3039 ed->vert_si.nPos = 0;
3040 ed->vert_sb_enabled = 0;
3041
3042 ed->horz_si.cbSize = sizeof(SCROLLINFO);
3043 ed->horz_si.nMin = 0;
3044 ed->horz_si.nMax = 0;
3045 ed->horz_si.nPage = 0;
3046 ed->horz_si.nPos = 0;
3047 ed->horz_sb_enabled = 0;
3048
3050 {
3051 if (ed->scrollbars & WS_VSCROLL)
3052 {
3055 }
3056 if (ed->scrollbars & WS_HSCROLL)
3057 {
3060 }
3061 }
3062
3063 ed->wheel_remain = 0;
3064
3067
3068 list_init( &ed->reobj_list );
3070
3073
3074 return ed;
3075}
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:169
static ME_TextBuffer * ME_MakeText(void)
Definition: editor.c:256
#define TEXT_LIMIT_DEFAULT
Definition: editor.c:247
#define ITextHost_TxSetScrollRange(This, a, b, c, d)
Definition: editor.h:336
#define ITextHost_TxGetPropertyBits(This, a, b)
Definition: editor.h:366
#define ITextHost_TxGetBackStyle(This, a)
Definition: editor.h:358
BOOL wrap_marked_paras_dc(ME_TextEditor *editor, HDC hdc, BOOL invalidate)
Definition: wrap.c:1032
#define ITextHost_TxGetScrollBars(This, a)
Definition: editor.h:360
#define ITextHost_TxGetSelectionBarWidth(This, a)
Definition: editor.h:370
#define ITextHost_TxGetPasswordChar(This, a)
Definition: editor.h:361
void ME_MakeFirstParagraph(ME_TextEditor *editor, HDC hdc)
Definition: para.c:151
#define ITextHost_TxEnableScrollBar(This, a, b)
Definition: editor.h:335
#define SELECTIONBAR_WIDTH
Definition: editstr.h:98
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
#define ES_DISABLENOSCROLL
Definition: richedit.h:224
unsigned int horz_sb_enabled
Definition: editstr.h:451
unsigned int have_texthost2
Definition: editstr.h:394
unsigned int vert_sb_enabled
Definition: editstr.h:450
TXTBACKSTYLE back_style
Definition: editstr.h:457
DWORD freeze_count
Definition: editstr.h:437
WCHAR password_char
Definition: editstr.h:435
CHARRANGE notified_cr
Definition: editstr.h:446
BOOL caret_hidden
Definition: editstr.h:454
#define TXTBIT_AUTOWORDSEL
Definition: textserv.h:192
#define TXTBIT_WORDWRAP
Definition: textserv.h:195
#define TXTBIT_VERTICAL
Definition: textserv.h:193
#define TXTBIT_ALLOWBEEP
Definition: textserv.h:196
#define TXTBIT_SAVESELECTION
Definition: textserv.h:191
@ TXTBACK_OPAQUE
Definition: textserv.h:165
#define TXTBIT_RICHTEXT
Definition: textserv.h:185
#define TXTBIT_USEPASSWORD
Definition: textserv.h:189
EXTERN_C const IID IID_ITextHost2
Definition: textserv.h:38
#define TXTBIT_DISABLEDRAG
Definition: textserv.h:197
struct tagSCROLLINFO SCROLLINFO
#define SB_VERT
Definition: winuser.h:553
#define ESB_DISABLE_BOTH
Definition: winuser.h:556
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define SB_HORZ
Definition: winuser.h:552

Referenced by create_text_services().

◆ ME_MakeFirstParagraph()

void ME_MakeFirstParagraph ( ME_TextEditor editor,
HDC  hdc 
)

Definition at line 151 of file para.c.

152{
155 const CHARFORMATW *host_cf;
156 LOGFONTW lf;
157 HFONT hf;
158 ME_TextBuffer *text = editor->pBuffer;
159 ME_Paragraph *para = para_create( editor );
160 ME_Run *run;
162 int eol_len;
163
164 ME_InitContext( &c, editor, hdc );
165
167 assert(hf);
168 GetObjectW(hf, sizeof(LOGFONTW), &lf);
169 ZeroMemory(&cf, sizeof(cf));
170 cf.cbSize = sizeof(cf);
177
178 cf.dwEffects = CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR;
179 lstrcpyW(cf.szFaceName, lf.lfFaceName);
180 /* Convert system font height from logical units to twips for cf.yHeight */
181 cf.yHeight = (lf.lfHeight * 72 * 1440) / (c.dpi.cy * c.dpi.cy);
182 if (lf.lfWeight > FW_NORMAL) cf.dwEffects |= CFE_BOLD;
183 cf.wWeight = lf.lfWeight;
184 if (lf.lfItalic) cf.dwEffects |= CFE_ITALIC;
185 if (lf.lfUnderline) cf.dwEffects |= CFE_UNDERLINE;
186 cf.bUnderlineType = CFU_UNDERLINE;
187 if (lf.lfStrikeOut) cf.dwEffects |= CFE_STRIKEOUT;
188 cf.bPitchAndFamily = lf.lfPitchAndFamily;
189 cf.bCharSet = lf.lfCharSet;
190 cf.lcid = GetSystemDefaultLCID();
191
193 text->pDefaultStyle = style;
194
195 if (ITextHost_TxGetCharFormat(editor->texthost, &host_cf) == S_OK)
196 {
197 ZeroMemory(&cf, sizeof(cf));
198 cf.cbSize = sizeof(cf);
199 cfany_to_cf2w(&cf, (CHARFORMAT2W *)host_cf);
200 ME_SetDefaultCharFormat(editor, &cf);
201 }
202
203 eol_len = editor->bEmulateVersion10 ? 2 : 1;
204 para->text = ME_MakeStringN( L"\r\n", eol_len );
205
206 run = run_create( style, MERF_ENDPARA );
207 run->nCharOfs = 0;
208 run->len = eol_len;
209 run->para = para;
210 para->eop_run = run;
211
212 ME_InsertBefore( text->pLast, para_get_di( para) );
213 ME_InsertBefore( text->pLast, run_get_di( run ) );
214 para->prev_para = text->pFirst;
215 para->next_para = text->pLast;
216 text->pFirst->member.para.next_para = para_get_di( para );
217 text->pLast->member.para.prev_para = para_get_di( para );
218
219 text->pLast->member.para.nCharOfs = editor->bEmulateVersion10 ? 2 : 1;
220
222 para_mark_add( editor, para );
224}
LCID WINAPI GetSystemDefaultLCID(void)
Definition: locale.c:1230
static ME_DisplayItem * para_get_di(ME_Paragraph *para)
Definition: editor.h:236
ME_Run * run_create(ME_Style *s, int nFlags)
Definition: run.c:348
BOOL cfany_to_cf2w(CHARFORMAT2W *to, const CHARFORMAT2W *from)
Definition: style.c:36
ME_String * ME_MakeStringN(LPCWSTR szText, int nMaxChars)
Definition: string.c:75
ME_Style * ME_MakeStyle(CHARFORMAT2W *style)
Definition: style.c:121
void ME_InsertBefore(ME_DisplayItem *diWhere, ME_DisplayItem *diWhat)
Definition: list.c:26
#define ITextHost_TxGetCharFormat(This, a)
Definition: editor.h:355
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static ME_Paragraph * para_create(ME_TextEditor *editor)
Definition: para.c:32
void para_mark_add(ME_TextEditor *editor, ME_Paragraph *para)
Definition: para.c:99
static int para_mark_compare(const void *key, const struct wine_rb_entry *entry)
Definition: para.c:87
#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
#define wine_rb_init
Definition: rbtree.h:406
ME_String * text
Definition: editstr.h:205
ME_Run * eop_run
Definition: editstr.h:216
struct wine_rb_tree marked_paras
Definition: editstr.h:460

Referenced by ME_MakeEditor().

◆ 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 = malloc( s->nBuffer * sizeof(WCHAR) );
66 if (!s->szData)
67 {
68 free( s );
69 return NULL;
70 }
71 s->szData[s->nLen] = 0;
72 return s;
73}
static void 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 = malloc(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 547 of file table.c.

548{
549 RTFTable *tableDef = calloc(1, sizeof(*tableDef));
550
551 if (!editor->bEmulateVersion10) /* v4.1 */
552 tableDef->gapH = 10;
553 return tableDef;
554}
Definition: rtf.h:1026

Referenced by ME_RTFTblAttrHook().

◆ ME_MouseMove()

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

Definition at line 1218 of file caret.c.

1219{
1220 ME_Cursor tmp_cursor;
1221
1222 if (editor->nSelectionType == stDocument)
1223 return;
1224 x += editor->horz_si.nPos;
1225 y += editor->vert_si.nPos;
1226
1227 tmp_cursor = editor->pCursors[0];
1228 /* FIXME: do something with the return value of cursor_from_virtual_coords */
1229 cursor_from_virtual_coords( editor, x, y, &tmp_cursor, TRUE );
1230
1231 ME_InvalidateSelection(editor);
1232 editor->pCursors[0] = tmp_cursor;
1234
1235 if (editor->nSelectionType != stPosition &&
1236 memcmp(&editor->pCursors[1], &editor->pCursors[3], sizeof(ME_Cursor)))
1237 /* The scroll the cursor towards the other end, since it was the one
1238 * extended by ME_ExtendAnchorSelection */
1239 editor_ensure_visible( editor, &editor->pCursors[1] );
1240 else
1241 editor_ensure_visible( editor, &editor->pCursors[0] );
1242
1243 ME_InvalidateSelection(editor);
1244 update_caret(editor);
1245 ME_SendSelChange(editor);
1246}

Referenced by editor_handle_message().

◆ ME_MoveCursorChars()

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

Definition at line 709 of file caret.c.

710{
711 cursor->nOffset += nRelOfs;
712 if (cursor->nOffset < 0)
713 {
714 cursor->nOffset += cursor->run->nCharOfs;
715 if (cursor->nOffset >= 0)
716 {
717 /* new offset in the same paragraph */
718 do {
719 cursor->run = run_prev( cursor->run );
720 } while (cursor->nOffset < cursor->run->nCharOfs);
721 cursor->nOffset -= cursor->run->nCharOfs;
722 return nRelOfs;
723 }
724
725 cursor->nOffset += cursor->para->nCharOfs;
726 if (cursor->nOffset <= 0)
727 {
728 /* moved to the start of the text */
729 nRelOfs -= cursor->nOffset;
731 return nRelOfs;
732 }
733
734 /* new offset in a previous paragraph */
735 do {
736 cursor->para = para_prev( cursor->para );
737 } while (cursor->nOffset < cursor->para->nCharOfs);
738 cursor->nOffset -= cursor->para->nCharOfs;
739
740 cursor->run = para_end_run( cursor->para );
741 while (cursor->nOffset < cursor->run->nCharOfs)
742 cursor->run = run_prev( cursor->run );
743 cursor->nOffset -= cursor->run->nCharOfs;
744 }
745 else if (cursor->nOffset >= cursor->run->len)
746 {
747 ME_Paragraph *next_para;
748 int new_offset;
749
750 new_offset = ME_GetCursorOfs(cursor);
751 next_para = para_next( cursor->para );
752 if (new_offset < next_para->nCharOfs)
753 {
754 /* new offset in the same paragraph */
755 do {
756 cursor->nOffset -= cursor->run->len;
757 cursor->run = run_next( cursor->run );
758 } while (cursor->nOffset >= cursor->run->len);
759 return nRelOfs;
760 }
761
762 if (new_offset >= ME_GetTextLength(editor) + (final_eop ? 1 : 0))
763 {
764 /* new offset at the end of the text */
765 ME_SetCursorToEnd(editor, cursor, final_eop);
766 nRelOfs -= new_offset - (ME_GetTextLength(editor) + (final_eop ? 1 : 0));
767 return nRelOfs;
768 }
769
770 /* new offset in a following paragraph */
771 do {
772 cursor->para = next_para;
773 next_para = para_next( next_para );
774 } while (new_offset >= next_para->nCharOfs);
775
776 cursor->nOffset = new_offset - cursor->para->nCharOfs;
777 cursor->run = para_first_run( cursor->para );
778 while (cursor->nOffset >= cursor->run->len)
779 {
780 cursor->nOffset -= cursor->run->len;
781 cursor->run = run_next( cursor->run );
782 }
783 } /* else new offset is in the same run */
784 return nRelOfs;
785}

Referenced by get_textfont_prop_for_pos(), ME_ArrowKey(), ME_FindText(), ME_PlayUndoItem(), ME_StreamIn(), ME_StreamOutRTF(), set_selection_cursors(), table_protect_partial_deletion(), textrange_endof(), textrange_move(), textrange_moveend(), and textrange_movestart().

◆ ME_MoveCursorWords()

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

Definition at line 789 of file caret.c.

790{
791 ME_Run *run = cursor->run, *other_run;
792 ME_Paragraph *para = cursor->para;
793 int nOffset = cursor->nOffset;
794
795 if (nRelOfs == -1)
796 {
797 /* Backward movement */
798 while (TRUE)
799 {
800 nOffset = ME_CallWordBreakProc( editor, get_text( run, 0 ), run->len, nOffset, WB_MOVEWORDLEFT );
801 if (nOffset) break;
802 other_run = run_prev( run );
803 if (other_run)
804 {
805 if (ME_CallWordBreakProc( editor, get_text( other_run, 0 ), other_run->len, other_run->len - 1, WB_ISDELIMITER )
806 && !(run->nFlags & MERF_ENDPARA)
807 && !(cursor->run == run && cursor->nOffset == 0)
808 && !ME_CallWordBreakProc( editor, get_text( run, 0 ), run->len, 0, WB_ISDELIMITER ))
809 break;
810 run = other_run;
811 nOffset = other_run->len;
812 }
813 else
814 {
815 if (cursor->run == run && cursor->nOffset == 0)
816 {
817 para = run->para;
818 /* Skip empty start of table row paragraph */
819 if (para_prev( para ) && para_prev( para )->nFlags & MEPF_ROWSTART)
820 para = para_prev( para );
821 /* Paragraph breaks are treated as separate words */
822 if (!para_prev( para )) return FALSE;
823 para = para_prev( para );
824 run = para_end_run( para );
825 }
826 break;
827 }
828 }
829 }
830 else
831 {
832 /* Forward movement */
833 BOOL last_delim = FALSE;
834
835 while (TRUE)
836 {
837 if (last_delim && !ME_CallWordBreakProc( editor, get_text( run, 0 ), run->len, nOffset, WB_ISDELIMITER ))
838 break;
839 nOffset = ME_CallWordBreakProc( editor, get_text( run, 0 ), run->len, nOffset, WB_MOVEWORDRIGHT );
840 if (nOffset < run->len) break;
841 other_run = run_next( run );
842 if (other_run)
843 {
844 last_delim = ME_CallWordBreakProc( editor, get_text( run, 0 ), run->len, nOffset - 1, WB_ISDELIMITER );
845 run = other_run;
846 nOffset = 0;
847 }
848 else
849 {
850 ME_Paragraph *other_para = para_next( para );
851 if (!para_next( other_para ))
852 {
853 if (cursor->run == run) return FALSE;
854 nOffset = 0;
855 break;
856 }
857 if (other_para->nFlags & MEPF_ROWSTART) other_para = para_next( other_para );
858 if (cursor->run == run) {
859 para = other_para;
860 run = para_first_run( para );
861 }
862 nOffset = 0;
863 break;
864 }
865 }
866 }
867 cursor->para = para;
868 cursor->run = run;
869 cursor->nOffset = nOffset;
870 return TRUE;
871}
int ME_CallWordBreakProc(ME_TextEditor *editor, WCHAR *str, INT len, INT start, INT code)
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_PointFromChar()

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

Definition at line 654 of file run.c.

655{
657 int ret;
658 HDC hdc = ITextHost_TxGetDC( editor->texthost );
659
660 ME_InitContext( &c, editor, hdc );
661 ret = ME_PointFromCharContext( &c, pRun, nOffset, visual_order );
664
665 return ret;
666}
int ME_PointFromCharContext(ME_Context *c, ME_Run *pRun, int nOffset, BOOL visual_order)
Definition: run.c:613

Referenced by editor_ensure_visible(), editor_handle_message(), and ME_GetXForArrow().

◆ ME_PointFromCharContext()

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

Definition at line 613 of file run.c.

614{
615 SIZE size;
616 ME_String *mask_text = NULL;
617 WCHAR *str;
618
619 if (pRun->nFlags & MERF_GRAPHICS)
620 {
621 if (nOffset)
622 ME_GetOLEObjectSize(c, pRun, &size);
623 return nOffset != 0;
624 } else if (pRun->nFlags & MERF_ENDPARA) {
625 nOffset = 0;
626 }
627
628 if (pRun->para->nFlags & MEPF_COMPLEX)
629 {
630 int x;
631 ScriptCPtoX( nOffset, FALSE, pRun->len, pRun->num_glyphs, pRun->clusters,
632 pRun->vis_attrs, pRun->advances, &pRun->script_analysis, &x );
633 if (visual_order && pRun->script_analysis.fRTL) x = pRun->nWidth - x - 1;
634 return x;
635 }
636 if (c->editor->password_char)
637 {
638 mask_text = ME_MakeStringR( c->editor->password_char, pRun->len );
639 str = mask_text->szData;
640 }
641 else
642 str = get_text( pRun, 0 );
643
644 ME_GetTextExtent(c, str, nOffset, pRun->style, &size);
645 ME_DestroyString( mask_text );
646 return size.cx;
647}
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:2671

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

◆ ME_Redo()

BOOL ME_Redo ( ME_TextEditor editor)

Definition at line 448 of file undo.c.

449{
450 ME_UndoMode nMode = editor->nUndoMode;
451 struct list *head;
452 struct undo_item *undo, *cursor2;
453
454 assert(nMode == umAddToUndo || nMode == umIgnore);
455
456 if (editor_undo_ignored(editor)) return FALSE;
457
458 head = list_head( &editor->redo_stack );
459 if (!head) return FALSE;
460
461 /* watch out for uncommitted transactions ! */
462 undo = LIST_ENTRY( head, struct undo_item, entry );
463 assert( undo->type == undo_end_transaction );
464
465 editor->nUndoMode = umAddBackToUndo;
466 list_remove( &undo->entry );
467 destroy_undo_item( undo );
468
469 LIST_FOR_EACH_ENTRY_SAFE( undo, cursor2, &editor->redo_stack, struct undo_item, entry )
470 {
471 if (undo->type == undo_end_transaction) break;
472 ME_PlayUndoItem( editor, undo );
473 list_remove( &undo->entry );
474 destroy_undo_item( undo );
475 }
478 editor->nUndoMode = nMode;
479 ME_UpdateRepaint(editor, FALSE);
480 return TRUE;
481}
void table_move_from_row_start(ME_TextEditor *editor)
Definition: table.c:531
ME_UndoMode
Definition: editstr.h:280
@ umAddBackToUndo
Definition: editstr.h:284
struct list entry
Definition: editstr.h:349
enum undo_type type
Definition: editstr.h:350
static void ME_PlayUndoItem(ME_TextEditor *editor, struct undo_item *undo)
Definition: undo.c:323

Referenced by editor_handle_message(), ITextDocument2Old_fnRedo(), 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(), editor_handle_message(), editor_insert_oleobj(), handle_enter(), handle_wm_char(), ITextRange_fnSetText(), ME_ClearTempStyle(), ME_DestroyDisplayItem(), ME_DestroyEditor(), ME_InsertEndRowFromCursor(), ME_ReplaceSel(), ME_RTFCharAttrHook(), ME_RTFReadHook(), ME_SaveTempStyle(), ME_SetCharFormat(), ME_SetDefaultCharFormat(), ME_SetSelectionCharFormat(), ME_StreamIn(), para_num_clear(), and table_insert_end_para().

◆ 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_PrepareParagraphForWrapping(), para_join(), and run_join().

◆ ME_Repaint()

void ME_Repaint ( ME_TextEditor editor)

Definition at line 121 of file paint.c.

122{
123 if (ME_WrapMarkedParagraphs(editor))
124 {
125 ME_UpdateScrollBar(editor);
126 FIXME("ME_Repaint had to call ME_WrapMarkedParagraphs\n");
127 }
128 if (!editor->freeze_count)
130}
void ME_UpdateScrollBar(ME_TextEditor *editor)
Definition: paint.c:1151
#define ITextHost_TxViewChange(This, a)
Definition: editor.h:339

Referenced by editor_handle_message(), ME_ArrowKey(), ME_RewrapRepaint(), scroll_abs(), set_selection(), and table_handle_tab().

◆ ME_ReplaceSel()

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

Definition at line 3170 of file editor.c.

3171{
3172 LONG from, to;
3173 int nStartCursor;
3174 ME_Style *style;
3175
3176 nStartCursor = ME_GetSelectionOfs(editor, &from, &to);
3178 ME_InternalDeleteText(editor, &editor->pCursors[nStartCursor], to-from, FALSE);
3179 ME_InsertTextFromCursor(editor, 0, str, len, style);
3181 /* drop temporary style if line end */
3182 /*
3183 * FIXME question: does abc\n mean: put abc,
3184 * clear temp style, put \n? (would require a change)
3185 */
3186 if (len>0 && str[len-1] == '\n')
3187 ME_ClearTempStyle(editor);
3188 ME_CommitUndo(editor);
3190 if (!can_undo)
3191 ME_EmptyUndoStack(editor);
3192 ME_UpdateRepaint(editor, FALSE);
3193}

Referenced by editor_handle_message(), and ITextSelection_fnSetText().

◆ 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 160 of file paint.c.

161{
162 /* RewrapRepaint should be called whenever the control has changed in
163 * looks, but not content. Like resizing. */
164
165 editor_mark_rewrap_all( editor );
167 ME_UpdateScrollBar(editor);
168 ME_Repaint(editor);
169}
void ME_Repaint(ME_TextEditor *editor)
Definition: paint.c:121

Referenced by editor_handle_message(), fnTextSrv_OnTxInPlaceActivate(), fnTextSrv_OnTxPropertyBitsChange(), ITextDocument2Old_fnUnfreeze(), and ME_SetZoom().

◆ 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:1205
void RTFFlushOutputBuffer(RTF_Info *info)
Definition: reader.c:2606
RTFColor * RTFGetColor(const RTF_Info *info, int num)
Definition: reader.c:1220
ME_Style * ME_ApplyStyle(ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style)
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->row_start &&
587 info->tableDef->row_start->nFlags & MEPF_ROWEND)
588 {
590 ME_Paragraph *para;
591 /* We are just after a table row. */
593 cursor = info->editor->pCursors[0];
594 para = cursor.para;
595 if (para == para_next( info->tableDef->row_start )
596 && !cursor.nOffset && !cursor.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->row_start = NULL;
603 info->canInheritInTbl = FALSE;
604 }
605 }
606 }
607 else /* v1.0 - v3.0 */
608 {
609 info->fmt.dwMask |= PFM_TABLE;
610 info->fmt.wEffects &= ~PFE_TABLE;
611 }
612 break;
613 case rtfNestLevel:
614 if (!info->editor->bEmulateVersion10) /* v4.1 */
615 {
616 while (info->rtfParam > info->nestingLevel)
617 {
618 RTFTable *tableDef = calloc(1, sizeof(*tableDef));
619 tableDef->parent = info->tableDef;
620 info->tableDef = tableDef;
621
623 if (tableDef->row_start && tableDef->row_start->nFlags & MEPF_ROWEND)
624 {
625 ME_Paragraph *para = para_next( tableDef->row_start );
626 tableDef->row_start = table_insert_row_start_at_para( info->editor, para );
627 }
628 else
629 {
631 cursor = info->editor->pCursors[0];
632 if (cursor.nOffset || cursor.run->nCharOfs)
633 ME_InsertTextFromCursor(info->editor, 0, L"\r", 1, info->style);
634 tableDef->row_start = table_insert_row_start( info->editor, info->editor->pCursors );
635 }
636
637 info->nestingLevel++;
638 }
639 info->canInheritInTbl = FALSE;
640 }
641 break;
642 case rtfInTable:
643 {
644 if (!info->editor->bEmulateVersion10) /* v4.1 */
645 {
646 if (info->nestingLevel < 1)
647 {
648 RTFTable *tableDef;
649 ME_Paragraph *para;
650
651 if (!info->tableDef)
652 info->tableDef = calloc(1, sizeof(*info->tableDef));
653 tableDef = info->tableDef;
655 if (tableDef->row_start && tableDef->row_start->nFlags & MEPF_ROWEND)
656 para = para_next( tableDef->row_start );
657 else
658 para = info->editor->pCursors[0].para;
659
660 tableDef->row_start = table_insert_row_start_at_para( info->editor, para );
661
662 info->nestingLevel = 1;
663 info->canInheritInTbl = TRUE;
664 }
665 return;
666 } else { /* v1.0 - v3.0 */
667 info->fmt.dwMask |= PFM_TABLE;
668 info->fmt.wEffects |= PFE_TABLE;
669 }
670 break;
671 }
672 case rtfFirstIndent:
673 case rtfLeftIndent:
674 if ((info->fmt.dwMask & (PFM_STARTINDENT | PFM_OFFSET)) != (PFM_STARTINDENT | PFM_OFFSET))
675 {
677 fmt.cbSize = sizeof(fmt);
679 info->fmt.dwMask |= PFM_STARTINDENT | PFM_OFFSET;
680 info->fmt.dxStartIndent = fmt.dxStartIndent;
681 info->fmt.dxOffset = fmt.dxOffset;
682 }
683 if (info->rtfMinor == rtfFirstIndent)
684 {
685 info->fmt.dxStartIndent += info->fmt.dxOffset + info->rtfParam;
686 info->fmt.dxOffset = -info->rtfParam;
687 }
688 else
689 info->fmt.dxStartIndent = info->rtfParam - info->fmt.dxOffset;
690 break;
691 case rtfRightIndent:
692 info->fmt.dwMask |= PFM_RIGHTINDENT;
693 info->fmt.dxRightIndent = info->rtfParam;
694 break;
695 case rtfQuadLeft:
696 case rtfQuadJust:
697 info->fmt.dwMask |= PFM_ALIGNMENT;
698 info->fmt.wAlignment = PFA_LEFT;
699 break;
700 case rtfQuadRight:
701 info->fmt.dwMask |= PFM_ALIGNMENT;
702 info->fmt.wAlignment = PFA_RIGHT;
703 break;
704 case rtfQuadCenter:
705 info->fmt.dwMask |= PFM_ALIGNMENT;
706 info->fmt.wAlignment = PFA_CENTER;
707 break;
708 case rtfTabPos:
709 if (!(info->fmt.dwMask & PFM_TABSTOPS))
710 {
712 fmt.cbSize = sizeof(fmt);
714 memcpy(info->fmt.rgxTabs, fmt.rgxTabs,
715 fmt.cTabCount * sizeof(fmt.rgxTabs[0]));
716 info->fmt.cTabCount = fmt.cTabCount;
717 info->fmt.dwMask |= PFM_TABSTOPS;
718 }
719 if (info->fmt.cTabCount < MAX_TAB_STOPS && info->rtfParam < 0x1000000)
720 info->fmt.rgxTabs[info->fmt.cTabCount++] = info->rtfParam;
721 break;
722 case rtfKeep:
723 info->fmt.dwMask |= PFM_KEEP;
724 info->fmt.wEffects |= PFE_KEEP;
725 break;
727 info->fmt.dwMask |= PFM_NOWIDOWCONTROL;
728 info->fmt.wEffects |= PFE_NOWIDOWCONTROL;
729 break;
730 case rtfKeepNext:
731 info->fmt.dwMask |= PFM_KEEPNEXT;
732 info->fmt.wEffects |= PFE_KEEPNEXT;
733 break;
734 case rtfSpaceAfter:
735 info->fmt.dwMask |= PFM_SPACEAFTER;
736 info->fmt.dySpaceAfter = info->rtfParam;
737 break;
738 case rtfSpaceBefore:
739 info->fmt.dwMask |= PFM_SPACEBEFORE;
740 info->fmt.dySpaceBefore = info->rtfParam;
741 break;
742 case rtfSpaceBetween:
743 info->fmt.dwMask |= PFM_LINESPACING;
744 if ((int)info->rtfParam > 0)
745 {
746 info->fmt.dyLineSpacing = info->rtfParam;
747 info->fmt.bLineSpacingRule = 3;
748 }
749 else
750 {
751 info->fmt.dyLineSpacing = info->rtfParam;
752 info->fmt.bLineSpacingRule = 4;
753 }
754 break;
755 case rtfSpaceMultiply:
756 info->fmt.dwMask |= PFM_LINESPACING;
757 info->fmt.dyLineSpacing = info->rtfParam * 20;
758 info->fmt.bLineSpacingRule = 5;
759 break;
760 case rtfParBullet:
761 info->fmt.dwMask |= PFM_NUMBERING;
762 info->fmt.wNumbering = PFN_BULLET;
763 break;
764 case rtfParSimple:
765 info->fmt.dwMask |= PFM_NUMBERING;
766 info->fmt.wNumbering = 2; /* FIXME: MSDN says it's not used ?? */
767 break;
768 case rtfBorderLeft:
769 info->borderType = RTFBorderParaLeft;
770 info->fmt.wBorders |= 1;
771 info->fmt.dwMask |= PFM_BORDER;
772 break;
773 case rtfBorderRight:
774 info->borderType = RTFBorderParaRight;
775 info->fmt.wBorders |= 2;
776 info->fmt.dwMask |= PFM_BORDER;
777 break;
778 case rtfBorderTop:
779 info->borderType = RTFBorderParaTop;
780 info->fmt.wBorders |= 4;
781 info->fmt.dwMask |= PFM_BORDER;
782 break;
783 case rtfBorderBottom:
784 info->borderType = RTFBorderParaBottom;
785 info->fmt.wBorders |= 8;
786 info->fmt.dwMask |= PFM_BORDER;
787 break;
788 case rtfBorderSingle:
789 info->fmt.wBorders &= ~0x700;
790 info->fmt.wBorders |= 1 << 8;
791 info->fmt.dwMask |= PFM_BORDER;
792 break;
793 case rtfBorderThick:
794 info->fmt.wBorders &= ~0x700;
795 info->fmt.wBorders |= 2 << 8;
796 info->fmt.dwMask |= PFM_BORDER;
797 break;
798 case rtfBorderShadow:
799 info->fmt.wBorders &= ~0x700;
800 info->fmt.wBorders |= 10 << 8;
801 info->fmt.dwMask |= PFM_BORDER;
802 break;
803 case rtfBorderDouble:
804 info->fmt.wBorders &= ~0x700;
805 info->fmt.wBorders |= 7 << 8;
806 info->fmt.dwMask |= PFM_BORDER;
807 break;
808 case rtfBorderDot:
809 info->fmt.wBorders &= ~0x700;
810 info->fmt.wBorders |= 11 << 8;
811 info->fmt.dwMask |= PFM_BORDER;
812 break;
813 case rtfBorderWidth:
814 {
815 int borderSide = info->borderType & RTFBorderSideMask;
816 RTFTable *tableDef = info->tableDef;
817 if ((info->borderType & RTFBorderTypeMask) == RTFBorderTypeCell)
818 {
820 if (!tableDef || tableDef->numCellsDefined >= MAX_TABLE_CELLS)
821 break;
822 border = &tableDef->cells[tableDef->numCellsDefined].border[borderSide];
823 border->width = info->rtfParam;
824 break;
825 }
826 info->fmt.wBorderWidth = info->rtfParam;
827 info->fmt.dwMask |= PFM_BORDER;
828 break;
829 }
830 case rtfBorderSpace:
831 info->fmt.wBorderSpace = info->rtfParam;
832 info->fmt.dwMask |= PFM_BORDER;
833 break;
834 case rtfBorderColor:
835 {
836 RTFTable *tableDef = info->tableDef;
837 int borderSide = info->borderType & RTFBorderSideMask;
838 int borderType = info->borderType & RTFBorderTypeMask;
839 switch(borderType)
840 {
842 if (!info->editor->bEmulateVersion10) /* v4.1 */
843 break;
844 /* v1.0 - 3.0 treat paragraph and row borders the same. */
845 case RTFBorderTypeRow:
846 if (tableDef) {
847 tableDef->border[borderSide].color = info->rtfParam;
848 }
849 break;
851 if (tableDef && tableDef->numCellsDefined < MAX_TABLE_CELLS) {
852 tableDef->cells[tableDef->numCellsDefined].border[borderSide].color = info->rtfParam;
853 }
854 break;
855 }
856 break;
857 }
858 case rtfRTLPar:
859 info->fmt.dwMask |= PFM_RTLPARA;
860 info->fmt.wEffects |= PFE_RTLPARA;
861 break;
862 case rtfLTRPar:
863 info->fmt.dwMask |= PFM_RTLPARA;
864 info->fmt.wEffects &= ~PFE_RTLPARA;
865 break;
866 }
867}
ME_Paragraph * table_insert_row_start(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: table.c:72
ME_Paragraph * table_insert_row_start_at_para(ME_TextEditor *editor, ME_Paragraph *para)
Definition: table.c:80
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
#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_Paragraph * row_start
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 943 of file editor.c.

944{
945 RTFTable *tableDef = info->tableDef;
946 switch (info->rtfMinor)
947 {
948 case rtfNestCell:
949 if (info->editor->bEmulateVersion10) /* v1.0 - v3.0 */
950 break;
951 /* else fall through since v4.1 treats rtfNestCell and rtfCell the same */
952 case rtfCell:
953 if (!tableDef)
954 break;
956 if (!info->editor->bEmulateVersion10) /* v4.1 */
957 {
958 if (tableDef->row_start)
959 {
960 if (!info->nestingLevel && tableDef->row_start->nFlags & MEPF_ROWEND)
961 {
962 ME_Paragraph *para = para_next( tableDef->row_start );
963 tableDef->row_start = table_insert_row_start_at_para( info->editor, para );
964 info->nestingLevel = 1;
965 }
966 table_insert_cell( info->editor, info->editor->pCursors );
967 }
968 }
969 else /* v1.0 - v3.0 */
970 {
971 ME_Paragraph *para = info->editor->pCursors[0].para;
972
973 if (para_in_table( para ) && tableDef->numCellsInserted < tableDef->numCellsDefined)
974 {
975 WCHAR tab = '\t';
976 ME_InsertTextFromCursor(info->editor, 0, &tab, 1, info->style);
977 tableDef->numCellsInserted++;
978 }
979 }
980 break;
981 case rtfNestRow:
982 if (info->editor->bEmulateVersion10) /* v1.0 - v3.0 */
983 break;
984 /* else fall through since v4.1 treats rtfNestRow and rtfRow the same */
985 case rtfRow:
986 {
987 ME_Run *run;
988 ME_Paragraph *para;
989 ME_Cell *cell;
990 int i;
991
992 if (!tableDef)
993 break;
995 if (!info->editor->bEmulateVersion10) /* v4.1 */
996 {
997 if (!tableDef->row_start) break;
998 if (!info->nestingLevel && tableDef->row_start->nFlags & MEPF_ROWEND)
999 {
1000 para = para_next( tableDef->row_start );
1001 tableDef->row_start = table_insert_row_start_at_para( info->editor, para );
1002 info->nestingLevel++;
1003 }
1004 para = tableDef->row_start;
1005 cell = table_row_first_cell( para );
1006 assert( cell && !cell_prev( cell ) );
1007 if (tableDef->numCellsDefined < 1)
1008 {
1009 /* 2000 twips appears to be the cell size that native richedit uses
1010 * when no cell sizes are specified. */
1011 const int default_size = 2000;
1012 int right_boundary = default_size;
1013 cell->nRightBoundary = right_boundary;
1014 while (cell_next( cell ))
1015 {
1016 cell = cell_next( cell );
1017 right_boundary += default_size;
1018 cell->nRightBoundary = right_boundary;
1019 }
1020 para = table_insert_cell( info->editor, info->editor->pCursors );
1021 cell = para_cell( para );
1022 cell->nRightBoundary = right_boundary;
1023 }
1024 else
1025 {
1026 for (i = 0; i < tableDef->numCellsDefined; i++)
1027 {
1028 RTFCell *cellDef = &tableDef->cells[i];
1029 cell->nRightBoundary = cellDef->rightBoundary;
1030 ME_ApplyBorderProperties( info, &cell->border, cellDef->border );
1031 cell = cell_next( cell );
1032 if (!cell)
1033 {
1034 para = table_insert_cell( info->editor, info->editor->pCursors );
1035 cell = para_cell( para );
1036 }
1037 }
1038 /* Cell for table row delimiter is empty */
1039 cell->nRightBoundary = tableDef->cells[i - 1].rightBoundary;
1040 }
1041
1042 run = para_first_run( cell_first_para( cell ) );
1043 if (info->editor->pCursors[0].run != run || info->editor->pCursors[0].nOffset)
1044 {
1045 int nOfs, nChars;
1046 /* Delete inserted cells that aren't defined. */
1047 info->editor->pCursors[1].run = run;
1048 info->editor->pCursors[1].para = run->para;
1049 info->editor->pCursors[1].nOffset = 0;
1050 nOfs = ME_GetCursorOfs(&info->editor->pCursors[1]);
1051 nChars = ME_GetCursorOfs(&info->editor->pCursors[0]) - nOfs;
1052 ME_InternalDeleteText(info->editor, &info->editor->pCursors[1],
1053 nChars, TRUE);
1054 }
1055
1056 para = table_insert_row_end( info->editor, info->editor->pCursors );
1057 para->fmt.dxOffset = abs(info->tableDef->gapH);
1058 para->fmt.dxStartIndent = info->tableDef->leftEdge;
1059 ME_ApplyBorderProperties( info, &para->border, tableDef->border );
1060 info->nestingLevel--;
1061 if (!info->nestingLevel)
1062 {
1063 if (info->canInheritInTbl) tableDef->row_start = para;
1064 else
1065 {
1066 while (info->tableDef)
1067 {
1068 tableDef = info->tableDef;
1069 info->tableDef = tableDef->parent;
1070 free(tableDef);
1071 }
1072 }
1073 }
1074 else
1075 {
1076 info->tableDef = tableDef->parent;
1077 free(tableDef);
1078 }
1079 }
1080 else /* v1.0 - v3.0 */
1081 {
1082 para = info->editor->pCursors[0].para;
1083 para->fmt.dxOffset = info->tableDef->gapH;
1084 para->fmt.dxStartIndent = info->tableDef->leftEdge;
1085
1086 ME_ApplyBorderProperties( info, &para->border, tableDef->border );
1087 while (tableDef->numCellsInserted < tableDef->numCellsDefined)
1088 {
1089 WCHAR tab = '\t';
1090 ME_InsertTextFromCursor(info->editor, 0, &tab, 1, info->style);
1091 tableDef->numCellsInserted++;
1092 }
1093 para->fmt.cTabCount = min(tableDef->numCellsDefined, MAX_TAB_STOPS);
1094 if (!tableDef->numCellsDefined) para->fmt.wEffects &= ~PFE_TABLE;
1095 ME_InsertTextFromCursor(info->editor, 0, L"\r", 1, info->style);
1096 tableDef->numCellsInserted = 0;
1097 }
1098 break;
1099 }
1100 case rtfTab:
1101 case rtfPar:
1102 if (info->editor->bEmulateVersion10) /* v1.0 - 3.0 */
1103 {
1104 ME_Paragraph *para;
1105
1107 para = info->editor->pCursors[0].para;
1108 if (para_in_table( para ))
1109 {
1110 /* rtfPar is treated like a space within a table. */
1111 info->rtfClass = rtfText;
1112 info->rtfMajor = ' ';
1113 }
1114 else if (info->rtfMinor == rtfPar && tableDef)
1115 tableDef->numCellsInserted = 0;
1116 }
1117 break;
1118 }
1119}
static void ME_ApplyBorderProperties(RTF_Info *info, ME_BorderRect *borderRect, RTFBorder *borderDef)
Definition: editor.c:399
ME_Cell * cell_next(ME_Cell *cell)
Definition: table.c:192
ME_Cell * cell_prev(ME_Cell *cell)
Definition: table.c:197
ME_Paragraph * table_insert_row_end(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: table.c:119
ME_Cell * table_row_first_cell(ME_Paragraph *para)
Definition: table.c:170
ME_Paragraph * table_insert_cell(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: table.c:112
BOOL para_in_table(ME_Paragraph *para)
Definition: para.c:122
#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 869 of file editor.c.

870{
871 switch (info->rtfMinor)
872 {
873 case rtfRowDef:
874 {
875 if (!info->editor->bEmulateVersion10) /* v4.1 */
876 info->borderType = 0; /* Not sure */
877 else /* v1.0 - 3.0 */
878 info->borderType = RTFBorderRowTop;
879 if (!info->tableDef) {
880 info->tableDef = ME_MakeTableDef(info->editor);
881 } else {
882 ME_InitTableDef(info->editor, info->tableDef);
883 }
884 break;
885 }
886 case rtfCellPos:
887 {
888 int cellNum;
889 if (!info->tableDef)
890 {
891 info->tableDef = ME_MakeTableDef(info->editor);
892 }
893 cellNum = info->tableDef->numCellsDefined;
894 if (cellNum >= MAX_TABLE_CELLS)
895 break;
896 info->tableDef->cells[cellNum].rightBoundary = info->rtfParam;
897 if (cellNum < MAX_TAB_STOPS)
898 {
899 /* Tab stops were used to store cell positions before v4.1 but v4.1
900 * still seems to set the tabstops without using them. */
901 PARAFORMAT2 *fmt = &info->editor->pCursors[0].para->fmt;
902 fmt->rgxTabs[cellNum] &= ~0x00FFFFFF;
903 fmt->rgxTabs[cellNum] |= 0x00FFFFFF & info->rtfParam;
904 }
905 info->tableDef->numCellsDefined++;
906 break;
907 }
908 case rtfRowBordTop:
909 info->borderType = RTFBorderRowTop;
910 break;
911 case rtfRowBordLeft:
912 info->borderType = RTFBorderRowLeft;
913 break;
914 case rtfRowBordBottom:
915 info->borderType = RTFBorderRowBottom;
916 break;
917 case rtfRowBordRight:
918 info->borderType = RTFBorderRowRight;
919 break;
920 case rtfCellBordTop:
921 info->borderType = RTFBorderCellTop;
922 break;
923 case rtfCellBordLeft:
924 info->borderType = RTFBorderCellLeft;
925 break;
927 info->borderType = RTFBorderCellBottom;
928 break;
929 case rtfCellBordRight:
930 info->borderType = RTFBorderCellRight;
931 break;
932 case rtfRowGapH:
933 if (info->tableDef)
934 info->tableDef->gapH = info->rtfParam;
935 break;
936 case rtfRowLeftEdge:
937 if (info->tableDef)
938 info->tableDef->leftEdge = info->rtfParam;
939 break;
940 }
941}
struct RTFTable * ME_MakeTableDef(ME_TextEditor *editor)
Definition: table.c:547
void ME_InitTableDef(ME_TextEditor *editor, struct RTFTable *tableDef)
Definition: table.c:556
#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_SaveTempStyle()

void ME_SaveTempStyle ( ME_TextEditor editor,
ME_Style style 
)

Definition at line 498 of file style.c.

499{
500 ME_Style *old_style = editor->pBuffer->pCharStyle;
501
502 if (style) ME_AddRefStyle( style );
503 editor->pBuffer->pCharStyle = style;
504 if (old_style) ME_ReleaseStyle( old_style );
505}

Referenced by editor_handle_message(), and handle_enter().

◆ ME_ScrollDown()

void ME_ScrollDown ( ME_TextEditor editor,
int  cy 
)

Definition at line 1136 of file paint.c.

1137{
1138 scroll_v_abs( editor, editor->vert_si.nPos + cy, TRUE );
1139}
void scroll_v_abs(ME_TextEditor *editor, int y, BOOL notify)
Definition: paint.c:1126
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586

Referenced by editor_handle_message(), and ME_ArrowPageDown().

◆ ME_ScrollLeft()

void ME_ScrollLeft ( ME_TextEditor editor,
int  cx 
)

Definition at line 1141 of file paint.c.

1142{
1143 scroll_h_abs( editor, editor->horz_si.nPos - cx, TRUE );
1144}

Referenced by editor_handle_message().

◆ ME_ScrollRight()

void ME_ScrollRight ( ME_TextEditor editor,
int  cx 
)

Definition at line 1146 of file paint.c.

1147{
1148 scroll_h_abs( editor, editor->horz_si.nPos + cx, TRUE );
1149}

Referenced by editor_handle_message().

◆ ME_ScrollUp()

void ME_ScrollUp ( ME_TextEditor editor,
int  cy 
)

Definition at line 1131 of file paint.c.

1132{
1133 scroll_v_abs( editor, editor->vert_si.nPos - cy, TRUE );
1134}

Referenced by editor_handle_message(), and ME_ArrowPageUp().

◆ ME_SendRequestResize()

void ME_SendRequestResize ( ME_TextEditor editor,
BOOL  force 
)

Definition at line 1137 of file wrap.c.

1138{
1139 if (editor->nEventMask & ENM_REQUESTRESIZE)
1140 {
1141 RECT rc;
1142
1143 ITextHost_TxGetClientRect(editor->texthost, &rc);
1144
1145 if (force || rc.bottom != editor->nTotalLength)
1146 {
1148
1149 info.nmhdr.hwndFrom = NULL;
1150 info.nmhdr.idFrom = 0;
1151 info.nmhdr.code = EN_REQUESTRESIZE;
1152 info.rc = rc;
1153 info.rc.right = editor->nTotalWidth;
1154 info.rc.bottom = editor->nTotalLength;
1155
1156 editor->nEventMask &= ~ENM_REQUESTRESIZE;
1157 ITextHost_TxNotify(editor->texthost, info.nmhdr.code, &info);
1158 editor->nEventMask |= ENM_REQUESTRESIZE;
1159 }
1160 }
1161}
#define ITextHost_TxGetClientRect(This, a)
Definition: editor.h:353
#define EN_REQUESTRESIZE
Definition: richedit.h:192
#define ENM_REQUESTRESIZE
Definition: richedit.h:477

Referenced by editor_draw(), editor_handle_message(), ME_KeyDown(), and ME_StreamIn().

◆ ME_SendSelChange()

void ME_SendSelChange ( ME_TextEditor editor)

Definition at line 1439 of file caret.c.

1440{
1441 SELCHANGE sc;
1442
1443 sc.nmhdr.hwndFrom = NULL;
1444 sc.nmhdr.idFrom = 0;
1445 sc.nmhdr.code = EN_SELCHANGE;
1446 ME_GetSelectionOfs(editor, &sc.chrg.cpMin, &sc.chrg.cpMax);
1447 sc.seltyp = SEL_EMPTY;
1448 if (sc.chrg.cpMin != sc.chrg.cpMax)
1449 sc.seltyp |= SEL_TEXT;
1450 if (sc.chrg.cpMin < sc.chrg.cpMax+1) /* what were RICHEDIT authors thinking ? */
1451 sc.seltyp |= SEL_MULTICHAR;
1452
1453 if (sc.chrg.cpMin != editor->notified_cr.cpMin || sc.chrg.cpMax != editor->notified_cr.cpMax)
1454 {
1455 ME_ClearTempStyle(editor);
1456
1457 editor->notified_cr = sc.chrg;
1458
1459 if (editor->nEventMask & ENM_SELCHANGE)
1460 {
1461 TRACE("cpMin=%ld cpMax=%ld seltyp=%d (%s %s)\n",
1462 sc.chrg.cpMin, sc.chrg.cpMax, sc.seltyp,
1463 (sc.seltyp & SEL_TEXT) ? "SEL_TEXT" : "",
1464 (sc.seltyp & SEL_MULTICHAR) ? "SEL_MULTICHAR" : "");
1465 ITextHost_TxNotify(editor->texthost, sc.nmhdr.code, &sc);
1466 }
1467 }
1468}
#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:3234
UINT code
Definition: winuser.h:3235
HWND hwndFrom
Definition: winuser.h:3233

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

◆ ME_SetCharFormat()

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

Definition at line 782 of file run.c.

783{
784 ME_Run *run, *start_run = start->run, *end_run = NULL;
785
786 if (end && start->run == end->run && start->nOffset == end->nOffset)
787 return;
788
789 if (start->nOffset == start->run->len)
790 start_run = run_next_all_paras( start->run );
791 else if (start->nOffset)
792 {
793 /* run_split() may or may not update the cursors, depending on whether they
794 * are selection cursors, but we need to make sure they are valid. */
795 int split_offset = start->nOffset;
796 ME_Run *split_run = run_split( editor, start );
797 start_run = start->run;
798 if (end && end->run == split_run)
799 {
800 end->run = start->run;
801 end->nOffset -= split_offset;
802 }
803 }
804
805 if (end)
806 {
807 if (end->nOffset == end->run->len)
808 end_run = run_next_all_paras( end->run );
809 else
810 {
811 if (end->nOffset) run_split( editor, end );
812 end_run = end->run;
813 }
814 }
815
816 for (run = start_run; run != end_run; run = run_next_all_paras( run ))
817 {
818 ME_Style *new_style = ME_ApplyStyle( editor, run->style, fmt );
819 ME_Paragraph *para = run->para;
820
821 add_undo_set_char_fmt( editor, para->nCharOfs + run->nCharOfs,
822 run->len, &run->style->fmt );
823 ME_ReleaseStyle( run->style );
824 run->style = new_style;
825
826 /* The para numbering style depends on the eop style */
827 if ((run->nFlags & MERF_ENDPARA) && para->para_num.style)
828 {
829 ME_ReleaseStyle(para->para_num.style);
830 para->para_num.style = NULL;
831 }
832 para_mark_rewrap( editor, para );
833 }
834}
ME_Run * run_split(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: run.c:310
BOOL add_undo_set_char_fmt(ME_TextEditor *, int pos, int len, const CHARFORMAT2W *fmt)
Definition: undo.c:164
struct para_num para_num
Definition: editstr.h:215

Referenced by editor_handle_message(), handle_EM_SETCHARFORMAT(), ME_PlayUndoItem(), ME_SetSelectionCharFormat(), ME_UpdateLinkAttribute(), para_join(), set_textfont_prop(), and textrange_set_font().

◆ ME_SetCursorToStart()

◆ ME_SetDefaultCharFormat()

void ME_SetDefaultCharFormat ( ME_TextEditor editor,
CHARFORMAT2W mod 
)

Definition at line 524 of file style.c.

525{
526 ME_Style *style, *def = editor->pBuffer->pDefaultStyle;
527
528 assert(mod->cbSize == sizeof(CHARFORMAT2W));
529 style = ME_ApplyStyle(editor, def, mod);
530 def->fmt = style->fmt;
531 def->tm = style->tm;
532 if (def->font_cache)
533 {
535 def->font_cache = NULL;
536 }
539 editor_mark_rewrap_all( editor );
540}
ME_Style * ME_ApplyStyle(ME_TextEditor *editor, ME_Style *sSrc, CHARFORMAT2W *mod)
Definition: style.c:156
SCRIPT_CACHE script_cache
Definition: editstr.h:76
ME_FontCacheItem * font_cache
Definition: editstr.h:73

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

◆ ME_SetSelectionCharFormat()

void ME_SetSelectionCharFormat ( ME_TextEditor editor,
CHARFORMAT2W pFmt 
)

Definition at line 753 of file run.c.

754{
755 if (!ME_IsSelection(editor))
756 {
757 ME_Style *s;
758 if (!editor->pBuffer->pCharStyle)
759 editor->pBuffer->pCharStyle = style_get_insert_style( editor, editor->pCursors );
760 s = ME_ApplyStyle(editor, editor->pBuffer->pCharStyle, pFmt);
762 editor->pBuffer->pCharStyle = s;
763 } else {
764 ME_Cursor *from, *to;
765 ME_GetSelection(editor, &from, &to);
766 ME_SetCharFormat(editor, from, to, pFmt);
767 }
768}
void ME_SetCharFormat(ME_TextEditor *editor, ME_Cursor *start, ME_Cursor *end, CHARFORMAT2W *fmt)
Definition: run.c:782

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

◆ ME_SetZoom()

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

Definition at line 1310 of file paint.c.

1311{
1312 /* TODO: Zoom images and objects */
1313
1314 if (numerator == 0 && denominator == 0)
1315 {
1316 editor->nZoomNumerator = editor->nZoomDenominator = 0;
1317 return TRUE;
1318 }
1319 if (numerator <= 0 || denominator <= 0)
1320 return FALSE;
1321 if (numerator * 64 <= denominator || numerator / denominator >= 64)
1322 return FALSE;
1323
1324 editor->nZoomNumerator = numerator;
1325 editor->nZoomDenominator = denominator;
1326
1327 ME_RewrapRepaint(editor);
1328 return TRUE;
1329}
void ME_RewrapRepaint(ME_TextEditor *editor)
Definition: paint.c:160

Referenced by editor_handle_message().

◆ 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 1562 of file editor.c.

1563{
1564 stream->editstream->dwError = stream->editstream->pfnCallback(stream->editstream->dwCookie,
1565 (BYTE *)stream->buffer,
1566 sizeof(stream->buffer),
1567 (LONG *)&stream->dwSize);
1568 stream->dwUsed = 0;
1569}
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 1193 of file writer.c.

1194{
1196 int nChars;
1197
1198 if (dwFormat & SFF_SELECTION) {
1199 LONG nStart, nTo;
1200 start = editor->pCursors[ME_GetSelectionOfs(editor, &nStart, &nTo)];
1201 nChars = nTo - nStart;
1202 } else {
1203 ME_SetCursorToStart(editor, &start);
1204 nChars = ME_GetTextLength(editor);
1205 /* Generate an end-of-paragraph at the end of SCF_ALL RTF output */
1206 if (dwFormat & SF_RTF)
1207 nChars++;
1208 }
1209 return ME_StreamOutRange(editor, dwFormat, &start, nChars, stream);
1210}
LRESULT ME_StreamOutRange(ME_TextEditor *editor, DWORD dwFormat, const ME_Cursor *start, int nChars, EDITSTREAM *stream)
Definition: writer.c:1177
#define SFF_SELECTION
Definition: richedit.h:979
#define SF_RTF
Definition: richedit.h:721

Referenced by editor_handle_message().

◆ ME_StreamOutRange()

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

Definition at line 1177 of file writer.c.

1180{
1181 ME_OutStream *pStream = ME_StreamOutInit(editor, stream);
1182
1183 if (dwFormat & SF_RTF)
1184 ME_StreamOutRTF(editor, pStream, start, nChars, dwFormat);
1185 else if (dwFormat & SF_TEXT || dwFormat & SF_TEXTIZED)
1186 ME_StreamOutText(editor, pStream, start, nChars, dwFormat);
1187 if (!pStream->stream->dwError)
1188 ME_StreamOutFlush(pStream);
1189 return ME_StreamOutFree(pStream);
1190}
static LONG ME_StreamOutFree(ME_OutStream *pStream)
Definition: writer.c:90
static ME_OutStream * ME_StreamOutInit(ME_TextEditor *editor, EDITSTREAM *stream)
Definition: writer.c:53
static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream, const ME_Cursor *start, int nChars, DWORD dwFormat)
Definition: writer.c:1119
static BOOL ME_StreamOutRTF(ME_TextEditor *editor, ME_OutStream *pStream, const ME_Cursor *start, int nChars, int dwFormat)
Definition: writer.c:995
static BOOL ME_StreamOutFlush(ME_OutStream *pStream)
Definition: writer.c:67
#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:32

Referenced by get_rtf_text(), and ME_StreamOut().

◆ 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 = malloc(nChars * sizeof(WCHAR))) != NULL)
243 *len = MultiByteToWideChar(codepage, 0, psz, -1, tmp, nChars) - 1;
244 return tmp;
245 }
246}

Referenced by editor_handle_message(), ME_SetText(), and RichEditWndProc_common().

◆ ME_twips2pointsX()

int ME_twips2pointsX ( const ME_Context c,
int  x 
)

Definition at line 171 of file paint.c.

172{
173 if (c->editor->nZoomNumerator == 0)
174 return x * c->dpi.cx / 1440;
175 else
176 return x * c->dpi.cx * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
177}

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

◆ ME_twips2pointsY()

int ME_twips2pointsY ( const ME_Context c,
int  y 
)

Definition at line 179 of file paint.c.

180{
181 if (c->editor->nZoomNumerator == 0)
182 return y * c->dpi.cy / 1440;
183 else
184 return y * c->dpi.cy * c->editor->nZoomNumerator / 1440 / c->editor->nZoomDenominator;
185}

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

◆ ME_Undo()

BOOL ME_Undo ( ME_TextEditor editor)

Definition at line 410 of file undo.c.

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

Referenced by editor_handle_message(), ITextDocument2Old_fnUndo(), and ME_KeyDown().

◆ ME_UpdateRepaint()

void ME_UpdateRepaint ( ME_TextEditor editor,
BOOL  update_now 
)

Definition at line 132 of file paint.c.

133{
134 /* Should be called whenever the contents of the control have changed */
135 BOOL wrappedParagraphs;
136
137 wrappedParagraphs = ME_WrapMarkedParagraphs(editor);
138 if (wrappedParagraphs)
139 ME_UpdateScrollBar(editor);
140
141 /* Ensure that the cursor is visible */
142 editor_ensure_visible( editor, &editor->pCursors[0] );
143
144 update_caret( editor );
145
146 if (!editor->freeze_count)
147 ITextHost_TxViewChange(editor->texthost, update_now);
148
149 ME_SendSelChange(editor);
150
151 if(editor->nEventMask & ENM_CHANGE)
152 {
153 editor->nEventMask &= ~ENM_CHANGE;
155 editor->nEventMask |= ENM_CHANGE;
156 }
157}
void editor_ensure_visible(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: paint.c:1210
#define ENM_CHANGE
Definition: richedit.h:468
#define EN_CHANGE
Definition: winuser.h:2041

Referenced by editor_copy_or_cut(), editor_handle_message(), fnTextSrv_TxSetText(), handle_enter(), handle_wm_char(), IRichEditOle_fnInsertObject(), 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 467 of file run.c.

468{
469 assert(run->nCharOfs >= 0);
470
471 if (RUN_IS_HIDDEN(run) || run->nFlags & MERF_TABLESTART)
472 run->nFlags |= MERF_HIDDEN;
473 else
474 run->nFlags &= ~MERF_HIDDEN;
475
476 if (run_is_splittable( run ))
477 run->nFlags |= MERF_SPLITTABLE;
478 else
479 run->nFlags &= ~MERF_SPLITTABLE;
480
481 if (!(run->nFlags & MERF_NOTEXT))
482 {
483 if (run_is_entirely_ws( run ))
485 else
486 {
487 run->nFlags &= ~MERF_WHITESPACE;
488
489 if (ME_IsWSpace( *get_text( run, 0 ) ))
490 run->nFlags |= MERF_STARTWHITE;
491 else
492 run->nFlags &= ~MERF_STARTWHITE;
493
494 if (ME_IsWSpace( *get_text( run, run->len - 1 ) ))
495 run->nFlags |= MERF_ENDWHITE;
496 else
497 run->nFlags &= ~MERF_ENDWHITE;
498 }
499 }
500 else
502}
static BOOL run_is_splittable(const ME_Run *run)
Definition: run.c:431
static BOOL run_is_entirely_ws(const ME_Run *run)
Definition: run.c:449
static int ME_IsWSpace(WCHAR ch)
Definition: editor.h:98
#define RUN_IS_HIDDEN(run)
Definition: editor.h:29
#define MERF_STARTWHITE
Definition: editstr.h:114
#define MERF_NOTEXT
Definition: editstr.h:131
#define MERF_ENDWHITE
Definition: editstr.h:116
#define MERF_HIDDEN
Definition: editstr.h:124
#define MERF_SPLITTABLE
Definition: editstr.h:112
#define MERF_TABLESTART
Definition: editstr.h:126
#define MERF_WHITESPACE
Definition: editstr.h:118

Referenced by ME_SplitByBacktracking(), ME_WrapSizeRun(), run_join(), and run_split().

◆ ME_UpdateScrollBar()

void ME_UpdateScrollBar ( ME_TextEditor editor)

Definition at line 1151 of file paint.c.

1152{
1153 /* Note that this is the only function that should ever call
1154 * SetScrollInfo with SIF_PAGE or SIF_RANGE. */
1155 BOOL enable;
1156
1157 if (ME_WrapMarkedParagraphs(editor))
1158 FIXME("ME_UpdateScrollBar had to call ME_WrapMarkedParagraphs\n");
1159
1160 /* Update horizontal scrollbar */
1161 enable = editor->nTotalWidth > editor->sizeWindow.cx;
1162 if (editor->horz_si.nPos && !enable)
1163 {
1164 scroll_h_abs( editor, 0, TRUE );
1165 /* ME_HScrollAbs will call this function, so nothing else needs to be done here. */
1166 return;
1167 }
1168
1169 if (editor->scrollbars & WS_HSCROLL && !enable ^ !editor->horz_sb_enabled)
1170 {
1171 editor->horz_sb_enabled = enable;
1173 }
1174
1175 if (editor->horz_si.nMax != editor->nTotalWidth || editor->horz_si.nPage != editor->sizeWindow.cx)
1176 {
1177 editor->horz_si.nMax = editor->nTotalWidth;
1178 editor->horz_si.nPage = editor->sizeWindow.cx;
1179 TRACE( "min = %d max = %d page = %d\n", editor->horz_si.nMin, editor->horz_si.nMax, editor->horz_si.nPage );
1180 if ((enable || editor->horz_sb_enabled) && editor->scrollbars & WS_HSCROLL)
1181 set_scroll_range_pos( editor, SB_HORZ, &editor->horz_si, TRUE, TRUE );
1182 }
1183
1184 /* Update vertical scrollbar */
1185 enable = editor->nTotalLength > editor->sizeWindow.cy && (editor->props & TXTBIT_MULTILINE);
1186
1187 if (editor->vert_si.nPos && !enable)
1188 {
1189 scroll_v_abs( editor, 0, TRUE );
1190 /* ME_VScrollAbs will call this function, so nothing else needs to be done here. */
1191 return;
1192 }
1193
1194 if (editor->scrollbars & WS_VSCROLL && !enable ^ !editor->vert_sb_enabled)
1195 {
1196 editor->vert_sb_enabled = enable;
1198 }
1199
1200 if (editor->vert_si.nMax != editor->nTotalLength || editor->vert_si.nPage != editor->sizeWindow.cy)
1201 {
1202 editor->vert_si.nMax = editor->nTotalLength;
1203 editor->vert_si.nPage = editor->sizeWindow.cy;
1204 TRACE( "min = %d max = %d page = %d\n", editor->vert_si.nMin, editor->vert_si.nMax, editor->vert_si.nPage );
1205 if ((enable || editor->vert_sb_enabled) && editor->scrollbars & WS_VSCROLL)
1206 set_scroll_range_pos( editor, SB_VERT, &editor->vert_si, TRUE, TRUE );
1207 }
1208}
static void enable_show_scrollbar(ME_TextEditor *editor, INT bar, BOOL enable)
Definition: paint.c:1066
static void set_scroll_range_pos(ME_TextEditor *editor, INT bar, SCROLLINFO *info, BOOL set_range, BOOL notify)
Definition: paint.c:1074
GLboolean enable
Definition: glext.h:11120

Referenced by editor_handle_message(), handle_EM_SETCHARFORMAT(), ME_Repaint(), ME_RewrapRepaint(), ME_UpdateRepaint(), scroll_abs(), set_textfont_prop(), and textrange_set_font().

◆ 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:55

Referenced by para_join(), and para_split().

◆ ME_WrapMarkedParagraphs()

BOOL ME_WrapMarkedParagraphs ( ME_TextEditor editor)

Definition at line 1103 of file wrap.c.

1104{
1105 HDC hdc = ITextHost_TxGetDC( editor->texthost );
1106 BOOL ret = wrap_marked_paras_dc( editor, hdc, TRUE );
1108 return ret;
1109}
BOOL wrap_marked_paras_dc(ME_TextEditor *editor, HDC hdc, BOOL invalidate)
Definition: wrap.c:1032

Referenced by editor_handle_message(), handle_EM_SETCHARFORMAT(), ME_InvalidateSelection(), ME_Repaint(), ME_RewrapRepaint(), ME_UpdateRepaint(), ME_UpdateScrollBar(), set_textfont_prop(), table_select_next_cell_or_append(), and textrange_set_font().

◆ para_cell()

◆ para_destroy()

void para_destroy ( ME_TextEditor editor,
ME_Paragraph item 
)

Definition at line 42 of file para.c.

43{
44 if (para->nWidth == editor->nTotalWidth)
45 {
46 para->nWidth = 0;
47 editor->nTotalWidth = get_total_width(editor);
48 }
49 editor->total_rows -= para->nRows;
50 ME_DestroyString( para->text );
51 para_num_clear( &para->para_num );
52 para_mark_remove( editor, para );
54}
void para_mark_remove(ME_TextEditor *editor, ME_Paragraph *para)
Definition: para.c:94
void para_num_clear(struct para_num *pn)
Definition: para.c:434
int get_total_width(ME_TextEditor *editor)
Definition: para.c:69

Referenced by ME_DestroyEditor(), and para_join().

◆ para_end_row()

ME_Row * para_end_row ( ME_Paragraph para)

Definition at line 141 of file para.c.

142{
144
145 para = para_next( para );
147 if (!item || item->type != diStartRow) return NULL;
148 return &item->member.row;
149}
@ diStartRowOrParagraph
Definition: editstr.h:90

Referenced by cursor_from_virtual_coords(), cursor_move_line(), and ME_ArrowPageDown().

◆ para_end_run()

◆ para_first_row()

ME_Row * para_first_row ( ME_Paragraph para)

◆ para_first_run()

◆ para_get_di()

◆ para_in_table()

◆ para_join()

ME_Paragraph * para_join ( ME_TextEditor editor,
ME_Paragraph para,
BOOL  use_first_fmt 
)

Definition at line 681 of file para.c.

682{
683 ME_Paragraph *next = para_next( para );
684 ME_Run *end_run, *next_first_run, *tmp_run;
685 ME_Cell *cell = NULL;
686 int i, end_len;
688 ME_Cursor startCur, endCur;
689 ME_String *eol_str;
690
691 assert( next && para_next( next ) );
692
693 /* Clear any cached para numbering following this paragraph */
694 if (para->fmt.wNumbering) para_num_clear_list( editor, para, &para->fmt );
695
696 end_run = para_end_run( para );
697 next_first_run = para_first_run( next );
698
699 end_len = end_run->len;
700 eol_str = ME_VSplitString( para->text, end_run->nCharOfs );
701 ME_AppendString( para->text, next->text->szData, next->text->nLen );
702
703 /* null char format operation to store the original char format for the ENDPARA run */
705 startCur.para = para;
706 startCur.run = end_run;
707 endCur.para = next;
708 endCur.run = next_first_run;
709 startCur.nOffset = endCur.nOffset = 0;
710
711 ME_SetCharFormat(editor, &startCur, &endCur, &fmt);
712
713 if (!editor->bEmulateVersion10) /* v4.1 */
714 {
715 /* Remove cell boundary if it is between the end paragraph run and the next
716 * paragraph display item. */
717 if (para->cell != next->cell) cell = next->cell;
718
719 /* Table cell/row properties are always moved over from the removed para. */
720 para->nFlags = next->nFlags;
721 para->cell = next->cell;
722 }
723
724 add_undo_split_para( editor, next, eol_str, cell );
725
726 if (cell)
727 {
728 ME_Remove( cell_get_di( cell ) );
729 if (cell_prev( cell )) cell_prev( cell )->next_cell = cell_next( cell );
730 if (cell_next( cell )) cell_next( cell )->prev_cell = cell_prev( cell );
732 }
733
734 if (!use_first_fmt)
735 {
736 add_undo_set_para_fmt( editor, para );
737 para->fmt = next->fmt;
738 para->border = next->border;
739 }
740
741 /* Update selection cursors so they don't point to the removed end
742 * paragraph run, and point to the correct paragraph. */
743 for (i = 0; i < editor->nCursors; i++)
744 {
745 if (editor->pCursors[i].run == end_run)
746 {
747 editor->pCursors[i].run = next_first_run;
748 editor->pCursors[i].nOffset = 0;
749 }
750 else if (editor->pCursors[i].para == next)
751 editor->pCursors[i].para = para;
752 }
753
754 for (tmp_run = next_first_run; tmp_run; tmp_run = run_next( tmp_run ))
755 {
756 tmp_run->nCharOfs += next->nCharOfs - para->nCharOfs - end_len;
757 tmp_run->para = para;
758 }
759
760 /* Fix up the para's eop_run ptr */
761 para->eop_run = next->eop_run;
762
763 ME_Remove( run_get_di( end_run ) );
765
766 if (editor->last_sel_start_para == next)
767 editor->last_sel_start_para = para;
768 if (editor->last_sel_end_para == next)
769 editor->last_sel_end_para = para;
770
771 para->next_para = next->next_para;
772 next->next_para->member.para.prev_para = para_get_di( para );
774 para_destroy( editor, next );
775
776 editor_propagate_char_ofs( editor, para_next( para ), NULL, -end_len );
777
778 ME_CheckCharOffsets(editor);
779
780 editor->nParagraphs--;
781 para_mark_rewrap( editor, para );
782 return para;
783}
BOOL ME_AppendString(ME_String *s, const WCHAR *append, int len)
Definition: string.c:126
ME_String * ME_VSplitString(ME_String *orig, int nVPos)
Definition: string.c:131
BOOL add_undo_set_para_fmt(ME_TextEditor *, const ME_Paragraph *para)
Definition: undo.c:152
void ME_InitCharFormat2W(CHARFORMAT2W *pFmt)
Definition: style.c:150
BOOL add_undo_split_para(ME_TextEditor *, const ME_Paragraph *para, ME_String *eol_str, const ME_Cell *cell)
Definition: undo.c:185
ME_Run * para_end_run(ME_Paragraph *para)
Definition: para.c:117
void para_mark_rewrap(ME_TextEditor *editor, ME_Paragraph *para)
Definition: para.c:26
ME_Run * para_first_run(ME_Paragraph *para)
Definition: para.c:104
void para_destroy(ME_TextEditor *editor, ME_Paragraph *para)
Definition: para.c:42
static void para_num_clear_list(ME_TextEditor *editor, ME_Paragraph *para, const PARAFORMAT2 *orig_fmt)
Definition: para.c:445
WORD wNumbering
Definition: richedit.h:668

Referenced by ME_InternalDeleteText(), and ME_PlayUndoItem().

◆ para_mark_add()

void para_mark_add ( ME_TextEditor editor,
ME_Paragraph para 
)

Definition at line 99 of file para.c.

100{
101 wine_rb_put( &editor->marked_paras, &para->nCharOfs, &para->marked_entry );
102}
#define wine_rb_put
Definition: rbtree.h:410
struct wine_rb_entry marked_entry
Definition: editstr.h:218

Referenced by editor_propagate_char_ofs(), ME_MakeFirstParagraph(), and para_mark_rewrap().

◆ para_mark_remove()

void para_mark_remove ( ME_TextEditor editor,
ME_Paragraph para 
)

Definition at line 94 of file para.c.

95{
96 wine_rb_remove_key( &editor->marked_paras, &para->nCharOfs );
97}
#define wine_rb_remove_key
Definition: rbtree.h:412

Referenced by editor_propagate_char_ofs(), and para_destroy().

◆ para_mark_rewrap()

◆ para_next()

◆ para_num_clear()

void para_num_clear ( struct para_num pn)

Definition at line 434 of file para.c.

435{
436 if (pn->style)
437 {
438 ME_ReleaseStyle( pn->style );
439 pn->style = NULL;
440 }
441 ME_DestroyString( pn->text );
442 pn->text = NULL;
443}
static int pints_t pn[]
Definition: server.c:129

Referenced by para_destroy(), and para_num_clear_list().

◆ para_num_init()

void para_num_init ( ME_Context c,
ME_Paragraph para 
)

Definition at line 390 of file para.c.

391{
394 SIZE sz;
395
396 if (!para->fmt.wNumbering) return;
397 if (para->para_num.style && para->para_num.text) return;
398
399 if (!para->para_num.style)
400 {
401 style = para->eop_run->style;
402
403 if (para->fmt.wNumbering == PFN_BULLET)
404 {
405 cf.cbSize = sizeof(cf);
406 cf.dwMask = CFM_FACE | CFM_CHARSET;
407 lstrcpyW( cf.szFaceName, L"Symbol" );
408 cf.bCharSet = SYMBOL_CHARSET;
409 style = ME_ApplyStyle( c->editor, style, &cf );
410 }
411 else
412 {
414 }
415
416 para->para_num.style = style;
417 }
418
419 if (!para->para_num.text)
420 {
421 if (para->fmt.wNumbering != PFN_BULLET)
422 para->para_num.text = para_num_get_str( para, para_num_get_num( para ) );
423 else
424 para->para_num.text = ME_MakeStringConst( L"\x00b7", 1 );
425 }
426
427 select_style( c, para->para_num.style );
428 GetTextExtentPointW( c->hDC, para->para_num.text->szData, para->para_num.text->nLen, &sz );
429 para->para_num.width = sz.cx;
430 GetTextExtentPointW( c->hDC, L" ", 1, &sz );
431 para->para_num.width += sz.cx;
432}
ME_String * ME_MakeStringConst(const WCHAR *str, int len)
Definition: string.c:41
static ME_String * para_num_get_str(ME_Paragraph *para, WORD num)
Definition: para.c:277
static int para_num_get_num(ME_Paragraph *para)
Definition: para.c:264
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().

◆ para_prev()

◆ para_range_invalidate()

void para_range_invalidate ( ME_TextEditor editor,
ME_Paragraph start_para,
ME_Paragraph last_para 
)

Definition at line 1111 of file wrap.c.

1113{
1114 RECT rc;
1115 int ofs;
1116
1117 rc = editor->rcFormat;
1118 ofs = editor->vert_si.nPos;
1119
1120 if (start_para)
1121 {
1122 start_para = table_outer_para( start_para );
1123 last_para = table_outer_para( last_para );
1124 rc.top += start_para->pt.y - ofs;
1125 } else {
1126 rc.top += editor->nTotalLength - ofs;
1127 }
1128 if (editor->nTotalLength < editor->nLastTotalLength)
1129 rc.bottom = editor->rcFormat.top + editor->nLastTotalLength - ofs;
1130 else
1131 rc.bottom = editor->rcFormat.top + last_para->pt.y + last_para->nHeight - ofs;
1133}
#define ITextHost_TxInvalidateRect(This, a, b)
Definition: editor.h:338
ME_Paragraph * table_outer_para(ME_Paragraph *para)
Definition: table.c:158

Referenced by ME_InvalidateSelection(), and wrap_marked_paras_dc().

◆ para_split()

ME_Paragraph * para_split ( ME_TextEditor editor,
ME_Run run,
ME_Style style,
const WCHAR eol_str,
int  eol_len,
int  paraFlags 
)

Definition at line 538 of file para.c.

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

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

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

◆ richole_release_children()

void richole_release_children ( struct text_services services)

Definition at line 5943 of file richole.c.

5944{
5947
5948 if (services->text_selection)
5949 {
5950 services->text_selection->services = NULL;
5951 ITextSelection_Release( &services->text_selection->ITextSelection_iface );
5952 }
5953
5954 LIST_FOR_EACH_ENTRY( range, &services->rangelist, ITextRangeImpl, child.entry )
5955 range->child.reole = NULL;
5956
5958 site->child.reole = NULL;
5959}
static IActiveScriptSite * site
Definition: script.c:149
static HWND child
Definition: cursoricon.c:298
IWbemServices * services
Definition: locator.c:1514

Referenced by ITextServicesImpl_Release().

◆ row_end_cursor()

void row_end_cursor ( ME_Row row,
ME_Cursor cursor,
BOOL  include_eop 
)

Definition at line 92 of file row.c.

93{
94 ME_DisplayItem *item, *run;
95
97 run = ME_FindItemBack( item, diRun );
98 cursor->run = &run->member.run;
99 cursor->para = cursor->run->para;
100 cursor->nOffset = (item->type == diStartRow || include_eop) ? cursor->run->len : 0;
101}
static ME_DisplayItem * row_get_di(ME_Row *row)
Definition: editor.h:125
@ diStartRowOrParagraphOrEnd
Definition: editstr.h:91

Referenced by editor_handle_message(), ME_ArrowEnd(), ME_ExtendAnchorSelection(), ME_SelectByType(), and row_number_from_char_ofs().

◆ row_first_cursor()

void row_first_cursor ( ME_Row row,
ME_Cursor cursor 
)

Definition at line 82 of file row.c.

83{
85
87 cursor->run = &item->member.run;
88 cursor->para = cursor->run->para;
89 cursor->nOffset = 0;
90}

Referenced by editor_handle_message(), ME_ArrowHome(), ME_ExtendAnchorSelection(), ME_SelectByType(), and row_para().

◆ row_first_run()

ME_Run * row_first_run ( ME_Row row)

Definition at line 54 of file row.c.

55{
57
59 assert( item->type == diRun );
60 return &item->member.run;
61}
@ diRunOrStartRow
Definition: editstr.h:93

Referenced by row_cursor().

◆ row_from_cursor()

◆ row_from_row_number()

ME_Row * row_from_row_number ( ME_TextEditor editor,
int  row_num 
)

Definition at line 111 of file row.c.

112{
113 ME_Paragraph *para = editor_first_para( editor );
114 ME_Row *row;
115 int count = 0;
116
117 while (para_next( para ) && count + para->nRows <= row_num)
118 {
119 count += para->nRows;
120 para = para_next( para );
121 }
122 if (!para_next( para )) return NULL;
123
124 for (row = para_first_row( para ); row && count < row_num; count++)
125 row = row_next( row );
126
127 return row;
128}
ME_Row * row_next(ME_Row *row)
Definition: row.c:27

Referenced by editor_handle_message().

◆ row_get_di()

static ME_DisplayItem * row_get_di ( ME_Row row)
inlinestatic

◆ row_next()

ME_Row * row_next ( ME_Row row)

Definition at line 27 of file row.c.

28{
30
32 if (!item || item->type != diStartRow) return NULL;
33 return &item->member.row;
34}

Referenced by cursor_from_virtual_coords(), editor_handle_message(), row_from_row_number(), and row_number_from_char_ofs().

◆ row_next_all_paras()

ME_Row * row_next_all_paras ( ME_Row row)

Definition at line 36 of file row.c.

37{
39
41 if (!item) return NULL;
42 return &item->member.row;
43}

Referenced by cursor_move_line(), and ME_ArrowPageDown().

◆ row_next_run()

ME_Run * row_next_run ( ME_Row row,
ME_Run run 
)

Definition at line 63 of file row.c.

64{
66
68
70 if (!item || item->type == diStartRow) return NULL;
71 return &item->member.run;
72}

Referenced by editor_handle_message(), and row_cursor().

◆ row_number_from_char_ofs()

int row_number_from_char_ofs ( ME_TextEditor editor,
int  ofs 
)

Definition at line 131 of file row.c.

132{
133 ME_Paragraph *para = editor_first_para( editor );
134 ME_Row *row;
136 int row_num = 0;
137
138 while (para_next( para ) && para_next( para )->nCharOfs <= ofs)
139 {
140 row_num += para->nRows;
141 para = para_next( para );
142 }
143
144 if (para_next( para ))
145 {
146 for (row = para_first_row( para ); row; row = row_next( row ))
147 {
149 if (ME_GetCursorOfs( &cursor ) > ofs ) break;
150 row_num++;
151 }
152 }
153
154 return row_num;
155}
void row_end_cursor(ME_Row *row, ME_Cursor *cursor, BOOL include_eop)
Definition: row.c:92

Referenced by editor_handle_message().

◆ row_para()

ME_Paragraph * row_para ( ME_Row row)

Definition at line 103 of file row.c.

104{
106
108 return cursor.para;
109}
void row_first_cursor(ME_Row *row, ME_Cursor *cursor)
Definition: row.c:82

Referenced by cursor_move_line(), ME_ArrowPageDown(), and ME_ArrowPageUp().

◆ row_prev_all_paras()

ME_Row * row_prev_all_paras ( ME_Row row)

Definition at line 45 of file row.c.

46{
48
50 if (!item) return NULL;
51 return &item->member.row;
52}

Referenced by cursor_move_line(), and ME_ArrowPageUp().

◆ run_char_ofs()

int run_char_ofs ( ME_Run run,
int  ofs 
)

Definition at line 233 of file run.c.

234{
235 return run->para->nCharOfs + run->nCharOfs + ofs;
236}

Referenced by draw_run(), and IRichEditOle_fnGetObject().

◆ run_create()

ME_Run * run_create ( ME_Style s,
int  nFlags 
)

Definition at line 348 of file run.c.

349{
351 ME_Run *run = &item->member.run;
352
353 if (!item) return NULL;
354
355 ME_AddRefStyle( s );
356 run->style = s;
357 run->reobj = NULL;
358 run->nFlags = flags;
359 run->nCharOfs = -1;
360 run->len = 0;
361 run->para = NULL;
362 run->num_glyphs = 0;
363 run->max_glyphs = 0;
364 run->glyphs = NULL;
365 run->vis_attrs = NULL;
366 run->advances = NULL;
367 run->offsets = NULL;
368 run->max_clusters = 0;
369 run->clusters = NULL;
370 return run;
371}
GOFFSET * offsets
Definition: editstr.h:175
int max_clusters
Definition: editstr.h:176
WORD * glyphs
Definition: editstr.h:172
int max_glyphs
Definition: editstr.h:171

Referenced by ME_MakeFirstParagraph(), para_split(), run_insert(), and run_split().

◆ run_get_di()

◆ run_insert()

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

Definition at line 380 of file run.c.

382{
383 ME_Run *insert_before = cursor->run, *run, *prev;
384
385 if (cursor->nOffset)
386 {
387 if (cursor->nOffset == insert_before->len)
388 {
389 insert_before = run_next_all_paras( insert_before );
390 if (!insert_before) insert_before = cursor->run; /* Always insert before the final eop run */
391 }
392 else
393 {
394 run_split( editor, cursor );
395 insert_before = cursor->run;
396 }
397 }
398
399 add_undo_delete_run( editor, insert_before->para->nCharOfs + insert_before->nCharOfs, len );
400
401 run = run_create( style, flags );
402 run->nCharOfs = insert_before->nCharOfs;
403 run->len = len;
404 run->para = insert_before->para;
405 ME_InsertString( run->para->text, run->nCharOfs, str, len );
406 ME_InsertBefore( run_get_di( insert_before ), run_get_di( run ) );
407 TRACE("Shift length:%d\n", len);
408 editor_propagate_char_ofs( editor, NULL, insert_before, len );
409 para_mark_rewrap( editor, insert_before->para );
410
411 /* Move any cursors that were at the end of the previous run to the end of the inserted run */
412 prev = run_prev_all_paras( run );
413 if (prev)
414 {
415 int i;
416
417 for (i = 0; i < editor->nCursors; i++)
418 {
419 if (editor->pCursors[i].run == prev &&
420 editor->pCursors[i].nOffset == prev->len)
421 {
422 editor->pCursors[i].run = run;
423 editor->pCursors[i].nOffset = len;
424 }
425 }
426 }
427
428 return run;
429}
void editor_propagate_char_ofs(ME_TextEditor *editor, ME_Paragraph *para, ME_Run *run, int shift)
Definition: run.c:147
ME_Run * run_create(ME_Style *s, int flags)
Definition: run.c:348
BOOL ME_InsertString(ME_String *s, int ofs, const WCHAR *insert, int len)
Definition: string.c:103
BOOL add_undo_delete_run(ME_TextEditor *, int pos, int len)
Definition: undo.c:204

Referenced by editor_insert_oleobj(), ME_InsertEndRowFromCursor(), ME_InsertTextFromCursor(), and ME_PlayUndoItem().

◆ run_join()

void run_join ( ME_TextEditor editor,
ME_Run run 
)

Definition at line 278 of file run.c.

279{
280 ME_Run *next = run_next( run );
281 int i;
282
283 assert( run );
284 assert( run->nCharOfs != -1 );
285 para_mark_rewrap( editor, run->para );
286
287 /* Update all cursors so that they don't contain the soon deleted run */
288 for (i = 0; i < editor->nCursors; i++)
289 {
290 if (editor->pCursors[i].run == next)
291 {
292 editor->pCursors[i].run = run;
293 editor->pCursors[i].nOffset += run->len;
294 }
295 }
296
297 run->len += next->len;
300 ME_UpdateRunFlags( editor, run );
301 ME_CheckCharOffsets( editor );
302}
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
Definition: run.c:467
void ME_CheckCharOffsets(ME_TextEditor *editor)
Definition: run.c:178

Referenced by ME_PrepareParagraphForWrapping().

◆ run_next()

◆ run_next_all_paras()

ME_Run * run_next_all_paras ( ME_Run run)

Definition at line 96 of file run.c.

97{
99
100 cursor.run = run;
101 cursor.para = run->para;
102 cursor.nOffset = 0;
103
104 if (cursor_next_run( &cursor, TRUE ))
105 return cursor.run;
106
107 return NULL;
108}

Referenced by ME_FindText(), ME_GetCharFormat(), ME_GetTextW(), ME_SetCharFormat(), ME_StreamOutText(), ME_UpdateLinkAttribute(), run_insert(), stream_out_font_and_colour_tbls(), and table_select_next_cell_or_append().

◆ run_prev()

ME_Run * run_prev ( ME_Run run)

Definition at line 82 of file run.c.

83{
85
86 cursor.run = run;
87 cursor.para = run->para;
88 cursor.nOffset = 0;
89
91 return cursor.run;
92
93 return NULL;
94}
BOOL cursor_prev_run(ME_Cursor *cursor, BOOL all_para)
Definition: run.c:49

Referenced by cursor_coords(), layout_row(), link_notify(), ME_GetCharFormat(), ME_InsertRowStart(), ME_InsertTextFromCursor(), ME_MaximizeSplit(), ME_MoveCursorChars(), ME_MoveCursorWords(), ME_WrapHandleRun(), style_get_insert_style(), and table_handle_tab().

◆ run_prev_all_paras()

ME_Run * run_prev_all_paras ( ME_Run run)

Definition at line 110 of file run.c.

111{
113
114 cursor.run = run;
115 cursor.para = run->para;
116 cursor.nOffset = 0;
117
118 if (cursor_prev_run( &cursor, TRUE ))
119 return cursor.run;
120
121 return NULL;
122}

Referenced by editor_handle_message(), editor_insert_oleobj(), ME_FindText(), ME_GetCharFormat(), ME_InternalDeleteText(), and run_insert().

◆ run_split()

ME_Run * run_split ( ME_TextEditor editor,
ME_Cursor cursor 
)

Definition at line 310 of file run.c.

311{
312 ME_Run *run = cursor->run, *new_run;
313 int i;
314 int nOffset = cursor->nOffset;
315
316 assert( !(run->nFlags & MERF_NONTEXT) );
317
318 new_run = run_create( run->style, run->nFlags & MERF_SPLITMASK );
319 new_run->nCharOfs = run->nCharOfs + nOffset;
320 new_run->len = run->len - nOffset;
321 new_run->para = run->para;
322 run->len = nOffset;
323 cursor->run = new_run;
324 cursor->nOffset = 0;
325
326 ME_InsertBefore( run_get_di( run )->next, run_get_di( new_run ) );
327
328 ME_UpdateRunFlags( editor, run );
329 ME_UpdateRunFlags( editor, new_run );
330 for (i = 0; i < editor->nCursors; i++)
331 {
332 if (editor->pCursors[i].run == run &&
333 editor->pCursors[i].nOffset >= nOffset)
334 {
335 editor->pCursors[i].run = new_run;
336 editor->pCursors[i].nOffset -= nOffset;
337 }
338 }
339 para_mark_rewrap( editor, run->para );
340 return run;
341}
#define MERF_NONTEXT
Definition: editstr.h:109
#define MERF_SPLITMASK
Definition: editstr.h:134

Referenced by itemize_para(), ME_InsertTextFromCursor(), ME_PlayUndoItem(), ME_SetCharFormat(), run_insert(), split_run_extents(), and table_insert_end_para().

◆ scroll_abs()

void scroll_abs ( ME_TextEditor editor,
int  x,
int  y,
BOOL  notify 
)

Definition at line 1091 of file paint.c.

1092{
1093 int scrollX = 0, scrollY = 0;
1094
1095 if (editor->horz_si.nPos != x) {
1096 x = min(x, editor->horz_si.nMax);
1097 x = max(x, editor->horz_si.nMin);
1098 scrollX = editor->horz_si.nPos - x;
1099 editor->horz_si.nPos = x;
1100 set_scroll_range_pos( editor, SB_HORZ, &editor->horz_si, FALSE, notify );
1101 }
1102
1103 if (editor->vert_si.nPos != y) {
1104 y = min(y, editor->vert_si.nMax - (int)editor->vert_si.nPage);
1105 y = max(y, editor->vert_si.nMin);
1106 scrollY = editor->vert_si.nPos - y;
1107 editor->vert_si.nPos = y;
1108 set_scroll_range_pos( editor, SB_VERT, &editor->vert_si, FALSE, notify );
1109 }
1110
1111 if (abs(scrollX) > editor->sizeWindow.cx || abs(scrollY) > editor->sizeWindow.cy)
1113 else
1114 ITextHost_TxScrollWindowEx(editor->texthost, scrollX, scrollY,
1115 &editor->rcFormat, &editor->rcFormat,
1117 ME_UpdateScrollBar(editor);
1118 ME_Repaint(editor);
1119}
#define ITextHost_TxScrollWindowEx(This, a, b, c, d, e, f, g)
Definition: editor.h:345
int notify
Definition: msacm.c:1366
#define SW_INVALIDATE
Definition: winuser.h:2598

Referenced by editor_ensure_visible(), editor_handle_message(), ITextRange_fnScrollIntoView(), scroll_h_abs(), and scroll_v_abs().

◆ scroll_h_abs()

void scroll_h_abs ( ME_TextEditor editor,
int  x,
BOOL  notify 
)

Definition at line 1121 of file paint.c.

1122{
1123 scroll_abs( editor, x, editor->vert_si.nPos, notify );
1124}

Referenced by editor_ensure_visible(), editor_handle_message(), ME_ScrollLeft(), ME_ScrollRight(), and ME_UpdateScrollBar().

◆ scroll_v_abs()

void scroll_v_abs ( ME_TextEditor editor,
int  y,
BOOL  notify 
)

Definition at line 1126 of file paint.c.

1127{
1128 scroll_abs( editor, editor->horz_si.nPos, y, notify );
1129}

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

◆ 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(), draw_text_with_style(), ME_CharFromPointContext(), ME_DestroyContext(), ME_GetTextExtent(), para_num_init(), and shape_run().

◆ set_selection()

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

Definition at line 2151 of file editor.c.

2152{
2153 int end;
2154
2155 TRACE("%d - %d\n", to, from );
2156
2157 if (!editor->bHideSelection) ME_InvalidateSelection( editor );
2158 end = set_selection_cursors( editor, to, from );
2159 editor_ensure_visible( editor, &editor->pCursors[0] );
2160 if (!editor->bHideSelection) ME_InvalidateSelection( editor );
2161 update_caret( editor );
2162 ME_Repaint( editor );
2163 ME_SendSelChange( editor );
2164
2165 return end;
2166}

◆ 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 LONG 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 cursor_from_char_ofs( 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].run->nFlags & MERF_ENDPARA)
209 editor->pCursors[1].nOffset = 0;
210 if (editor->pCursors[0].run->nFlags & MERF_ENDPARA)
211 {
212 if (to > len)
213 editor->pCursors[0].nOffset = editor->pCursors[0].run->len;
214 else
215 editor->pCursors[0].nOffset = 0;
216 }
217 return to;
218}

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

◆ show_caret()

void show_caret ( ME_TextEditor ed)

Definition at line 261 of file caret.c.

262{
263 ITextHost_TxShowCaret(editor->texthost, TRUE);
264 editor->caret_hidden = FALSE;
265}

Referenced by update_caret().

◆ style_get_insert_style()

ME_Style * style_get_insert_style ( ME_TextEditor editor,
ME_Cursor cursor 
)

Definition at line 476 of file style.c.

477{
479 ME_Cursor *from, *to;
480 ME_Run *prev;
481
482 if (ME_IsSelection( editor ))
483 {
484 ME_GetSelection( editor, &from, &to );
485 style = from->run->style;
486 }
487 else if (editor->pBuffer->pCharStyle)
488 style = editor->pBuffer->pCharStyle;
489 else if (!cursor->nOffset && (prev = run_prev( cursor->run )))
490 style = prev->style;
491 else
492 style = cursor->run->style;
493
495 return style;
496}

Referenced by editor_handle_message(), editor_insert_oleobj(), handle_enter(), handle_wm_char(), ITextRange_fnSetText(), ME_GetSelectionInsertStyle(), ME_InsertEndRowFromCursor(), ME_SetSelectionCharFormat(), and table_insert_end_para().

◆ table_append_row()

ME_Paragraph * table_append_row ( ME_TextEditor editor,
ME_Paragraph table_row 
)

Definition at line 327 of file table.c.

328{
329 WCHAR endl = '\r', tab = '\t';
330 ME_Run *run;
331 int i;
332
333 if (!editor->bEmulateVersion10) /* v4.1 */
334 {
335 ME_Cell *new_cell, *cell;
336 ME_Paragraph *para, *prev_table_end, *new_row_start;
337
338 cell = table_row_first_cell( table_row );
339 prev_table_end = table_row_end( table_row );
340 para = para_next( prev_table_end );
341 run = para_first_run( para );
342 editor->pCursors[0].para = para;
343 editor->pCursors[0].run = run;
344 editor->pCursors[0].nOffset = 0;
345 editor->pCursors[1] = editor->pCursors[0];
346 new_row_start = table_insert_row_start( editor, editor->pCursors );
347 new_cell = table_row_first_cell( new_row_start );
348 /* Copy cell properties */
349 new_cell->nRightBoundary = cell->nRightBoundary;
350 new_cell->border = cell->border;
351 while (cell_next( cell ))
352 {
353 cell = cell_next( cell );
354 para = table_insert_cell( editor, editor->pCursors );
355 new_cell = para_cell( para );
356 /* Copy cell properties */
357 new_cell->nRightBoundary = cell->nRightBoundary;
358 new_cell->border = cell->border;
359 };
360 para = table_insert_row_end( editor, editor->pCursors );
361 para->fmt = prev_table_end->fmt;
362 /* return the table row start for the inserted paragraph */
363 return new_row_start;
364 }
365 else /* v1.0 - 3.0 */
366 {
367 run = para_end_run( table_row );
368 assert( para_in_table( table_row ) );
369 editor->pCursors[0].para = table_row;
370 editor->pCursors[0].run = run;
371 editor->pCursors[0].nOffset = 0;
372 editor->pCursors[1] = editor->pCursors[0];
373 ME_InsertTextFromCursor( editor, 0, &endl, 1, run->style );
374 run = editor->pCursors[0].run;
375 for (i = 0; i < table_row->fmt.cTabCount; i++)
376 ME_InsertTextFromCursor( editor, 0, &tab, 1, run->style );
377
378 return para_next( table_row );
379 }
380}
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
ME_Paragraph * table_insert_row_end(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: table.c:119
ME_Cell * table_row_first_cell(ME_Paragraph *para)
Definition: table.c:170
ME_Paragraph * table_insert_row_start(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: table.c:72
ME_Paragraph * table_row_end(ME_Paragraph *para)
Definition: table.c:127
ME_Paragraph * table_insert_cell(ME_TextEditor *editor, ME_Cursor *cursor)
Definition: table.c:112

Referenced by handle_enter(), and table_select_next_cell_or_append().

◆ table_handle_tab()

void table_handle_tab ( ME_TextEditor editor,
BOOL  selected_row 
)

Definition at line 473 of file table.c.

474{
475 /* FIXME: Shift tab should move to the previous cell. */
476 ME_Cursor fromCursor, toCursor;
478 {
479 int from, to;
480 from = ME_GetCursorOfs(&editor->pCursors[0]);
481 to = ME_GetCursorOfs(&editor->pCursors[1]);
482 if (from <= to)
483 {
484 fromCursor = editor->pCursors[0];
485 toCursor = editor->pCursors[1];
486 }
487 else
488 {
489 fromCursor = editor->pCursors[1];
490 toCursor = editor->pCursors[0];
491 }
492 }
493 if (!editor->bEmulateVersion10) /* v4.1 */
494 {
495 if (!para_in_table( toCursor.para ))
496 {
497 editor->pCursors[0] = toCursor;
498 editor->pCursors[1] = toCursor;
499 }
500 else table_select_next_cell_or_append( editor, toCursor.run );
501 }
502 else /* v1.0 - 3.0 */
503 {
504 if (!para_in_table( fromCursor.para ))
505 {
506 editor->pCursors[0] = fromCursor;
507 editor->pCursors[1] = fromCursor;
508 /* FIXME: For some reason the caret is shown at the start of the
509 * previous paragraph in v1.0 to v3.0 */
510 }
511 else if ((selected_row || !para_in_table( toCursor.para )))
512 table_select_next_cell_or_append( editor, fromCursor.run );
513 else
514 {
515 ME_Run *run = run_prev( toCursor.run );
516
517 if (ME_IsSelection(editor) && !toCursor.nOffset && run && run->nFlags & MERF_TAB)
519 else
520 table_select_next_cell_or_append( editor, toCursor.run );
521 }
522 }
524 ME_Repaint(editor);
525 update_caret(editor);
526 ME_SendSelChange(editor);
527}
static void table_select_next_cell_or_append(ME_TextEditor *editor, ME_Run *run)
Definition: table.c:383

Referenced by handle_wm_char().

◆ table_insert_cell()

ME_Paragraph * table_insert_cell ( ME_TextEditor editor,
ME_Cursor cursor 
)

Definition at line 112 of file table.c.

113{
114 WCHAR tab = '\t';
115
116 return table_insert_end_para( editor, editor->pCursors, &tab, 1, MEPF_CELL );
117}
static ME_Paragraph * table_insert_end_para(ME_TextEditor *editor, ME_Cursor *cursor, const WCHAR *eol_str, int eol_len, int para_flags)
Definition: table.c:57

Referenced by ME_RTFSpecialCharHook(), and table_append_row().

◆ table_insert_row_end()

ME_Paragraph * table_insert_row_end ( ME_TextEditor editor,
ME_Cursor cursor 
)

Definition at line 119 of file table.c.

120{
121 ME_Paragraph *para;
122
123 para = table_insert_end_para( editor, cursor, L"\r\n", 2, MEPF_ROWEND );
124 return para_prev( para );
125}

Referenced by ME_RTFSpecialCharHook(), and table_append_row().

◆ table_insert_row_start()

ME_Paragraph * table_insert_row_start ( ME_TextEditor editor,
ME_Cursor cursor 
)

Definition at line 72 of file table.c.

73{
74 ME_Paragraph *para;
75
76 para = table_insert_end_para( editor, cursor, L"\r\n", 2, MEPF_ROWSTART );
77 return para_prev( para );
78}

Referenced by ME_RTFParAttrHook(), table_append_row(), and table_insert_row_start_at_para().

◆ table_insert_row_start_at_para()

ME_Paragraph * table_insert_row_start_at_para ( ME_TextEditor editor,
ME_Paragraph para 
)

Definition at line 80 of file table.c.

81{
82 ME_Paragraph *prev_para, *end_para, *start_row;
84
85 cursor.para = para;
86 cursor.run = para_first_run( para );
87 cursor.nOffset = 0;
88
89 start_row = table_insert_row_start( editor, &cursor );
90
91 end_para = para_next( editor->pCursors[0].para );
92 prev_para = para_next( start_row );
93 para = para_next( prev_para );
94
95 while (para != end_para)
96 {
97 para->cell = para_cell( prev_para );
98 para->nFlags |= MEPF_CELL;
99 para->nFlags &= ~(MEPF_ROWSTART | MEPF_ROWEND);
101 para->fmt.wEffects |= PFE_TABLE;
102 para->fmt.wEffects &= ~PFE_TABLEROWDELIMITER;
103 prev_para = para;
104 para = para_next( para );
105 }
106 return start_row;
107}
#define PFM_TABLEROWDELIMITER
Definition: richedit.h:868

Referenced by ME_RTFParAttrHook(), and ME_RTFSpecialCharHook().

◆ table_move_from_row_start()

void table_move_from_row_start ( ME_TextEditor editor)

Definition at line 531 of file table.c.

532{
533 ME_Paragraph *para = editor->pCursors[0].para;
534
535 if (para == editor->pCursors[1].para && para->nFlags & MEPF_ROWSTART)
536 {
537 /* The cursors should not be at the hidden start row paragraph without
538 * a selection, so the cursor is moved into the first cell. */
539 para = para_next( para );
540 editor->pCursors[0].para = para;
541 editor->pCursors[0].run = para_first_run( para );
542 editor->pCursors[0].nOffset = 0;
543 editor->pCursors[1] = editor->pCursors[0];
544 }
545}

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

◆ table_outer_para()

ME_Paragraph * table_outer_para ( ME_Paragraph para)

Definition at line 158 of file table.c.

159{
160 if (para->nFlags & MEPF_ROWEND) para = para_prev( para );
161 while (para_cell( para ))
162 {
163 para = table_row_start( para );
164 if (!para_cell( para )) break;
166 }
167 return para;
168}
ME_Paragraph * table_row_start(ME_Paragraph *para)
Definition: table.c:142

Referenced by para_range_invalidate(), and wrap_marked_paras_dc().

◆ table_protect_partial_deletion()

void table_protect_partial_deletion ( ME_TextEditor editor,
ME_Cursor c,
int num_chars 
)

Definition at line 217 of file table.c.

218{
219 int start_ofs = ME_GetCursorOfs( c );
220 ME_Cursor c2 = *c;
221 ME_Paragraph *this_para = c->para, *end_para;
222
223 ME_MoveCursorChars( editor, &c2, *num_chars, FALSE );
224 end_para = c2.para;
225 if (c2.run->nFlags & MERF_ENDPARA)
226 {
227 /* End offset might be in the middle of the end paragraph run.
228 * If this is the case, then we need to use the next paragraph as the last
229 * paragraphs.
230 */
231 int remaining = start_ofs + *num_chars - c2.run->nCharOfs - end_para->nCharOfs;
232 if (remaining)
233 {
234 assert( remaining < c2.run->len );
235 end_para = para_next( end_para );
236 }
237 }
238 if (!editor->bEmulateVersion10) /* v4.1 */
239 {
240 if (para_cell( this_para ) != para_cell( end_para ) ||
241 ((this_para->nFlags | end_para->nFlags) & (MEPF_ROWSTART | MEPF_ROWEND)))
242 {
243 while (this_para != end_para)
244 {
245 ME_Paragraph *next_para = para_next( this_para );
246 BOOL truancate_del = FALSE;
247 if (this_para->nFlags & MEPF_ROWSTART)
248 {
249 /* The following while loop assumes that next_para is MEPF_ROWSTART,
250 * so moving back one paragraph lets it be processed as the start
251 * of the row. */
252 next_para = this_para;
253 this_para = para_prev( this_para );
254 }
255 else if (para_cell( next_para) != para_cell( this_para ) || this_para->nFlags & MEPF_ROWEND)
256 {
257 /* Start of the deletion from after the start of the table row. */
258 truancate_del = TRUE;
259 }
260 while (!truancate_del && next_para->nFlags & MEPF_ROWSTART)
261 {
262 next_para = para_next( table_row_end( next_para ) );
263 if (next_para->nCharOfs > start_ofs + *num_chars)
264 {
265 /* End of deletion is not past the end of the table row. */
266 next_para = para_next( this_para );
267 /* Delete the end paragraph preceding the table row if the
268 * preceding table row will be empty. */
269 if (this_para->nCharOfs >= start_ofs) next_para = para_next( next_para );
270 truancate_del = TRUE;
271 }
272 else this_para = para_prev( next_para );
273 }
274 if (truancate_del)
275 {
276 ME_Run *end_run = para_end_run( para_prev( next_para ) );
277 int new_chars = next_para->nCharOfs - start_ofs - end_run->len;
278 new_chars = max( new_chars, 0 );
279 assert( new_chars <= *num_chars);
280 *num_chars = new_chars;
281 break;
282 }
283 this_para = next_para;
284 }
285 }
286 }
287 else /* v1.0 - 3.0 */
288 {
289 ME_Run *run;
290 int chars_to_boundary;
291
292 if ((this_para->nCharOfs != start_ofs || this_para == end_para) && para_in_table( this_para ))
293 {
294 run = c->run;
295 /* Find the next tab or end paragraph to use as a delete boundary */
296 while (!(run->nFlags & (MERF_TAB | MERF_ENDPARA)))
297 run = run_next( run );
298 chars_to_boundary = run->nCharOfs - c->run->nCharOfs - c->nOffset;
299 *num_chars = min( *num_chars, chars_to_boundary );
300 }
301 else if (para_in_table( end_para ))
302 {
303 /* The deletion starts from before the row, so don't join it with
304 * previous non-empty paragraphs. */
305 ME_Paragraph *cur_para;
306 run = NULL;
307 if (start_ofs > this_para->nCharOfs)
308 {
309 cur_para = para_prev( end_para );
310 run = para_end_run( cur_para );
311 }
312 if (!run)
313 {
314 cur_para = end_para;
315 run = para_first_run( end_para );
316 }
317 if (run)
318 {
319 chars_to_boundary = cur_para->nCharOfs + run->nCharOfs - start_ofs;
320 if (chars_to_boundary >= 0) *num_chars = min( *num_chars, chars_to_boundary );
321 }
322 }
323 if (*num_chars < 0) *num_chars = 0;
324 }
325}

Referenced by ME_InternalDeleteText().

◆ table_row_end()

ME_Paragraph * table_row_end ( ME_Paragraph para)

Definition at line 127 of file table.c.

128{
129 ME_Cell *cell;
130
131 if (para->nFlags & MEPF_ROWEND) return para;
132 if (para->nFlags & MEPF_ROWSTART) para = para_next( para );
133 cell = para_cell( para );
134 while (cell_next( cell ))
135 cell = cell_next( cell );
136
137 para = &ME_FindItemFwd( cell_get_di( cell ), diParagraph )->member.para;
138 assert( para && para->nFlags & MEPF_ROWEND );
139 return para;
140}

Referenced by adjust_para_y(), cursor_from_virtual_coords(), cursor_move_line(), draw_table_borders(), ME_BeginRow(), ME_WrapTextParagraph(), pixel_pos_in_table_row(), stream_out_table_props(), table_append_row(), table_protect_partial_deletion(), table_row_end_cell(), and table_select_next_cell_or_append().

◆ table_row_end_cell()

ME_Cell * table_row_end_cell ( ME_Paragraph para)

Definition at line 178 of file table.c.

179{
180 if (!para_in_table( para )) return NULL;
181
182 para = para_prev( table_row_end( para ));
183 return cell_next( para_cell( para ) );
184}

Referenced by adjust_para_y(), cursor_move_line(), draw_paragraph(), draw_table_borders(), and ME_BeginRow().

◆ table_row_first_cell()

ME_Cell * table_row_first_cell ( ME_Paragraph para)

Definition at line 170 of file table.c.

171{
172 if (!para_in_table( para )) return NULL;
173
174 para = para_next( table_row_start( para ) );
175 return para_cell( para );
176}

Referenced by adjust_para_y(), cursor_move_line(), draw_paragraph(), ME_RTFSpecialCharHook(), pixel_pos_in_table_row(), stream_out_table_props(), and table_append_row().

◆ table_row_start()

ME_Paragraph * table_row_start ( ME_Paragraph para)

Definition at line 142 of file table.c.

143{
144 ME_Cell *cell;
145
146 if (para->nFlags & MEPF_ROWSTART) return para;
147 if (para->nFlags & MEPF_ROWEND) para = para_prev( para );
148 cell = para_cell( para );
149
150 while (cell_prev( cell ))
151 cell = cell_prev( cell );
152
154 assert( para && para->nFlags & MEPF_ROWSTART );
155 return para;
156}
ME_Cell * cell_prev(ME_Cell *cell)
Definition: table.c:197

Referenced by adjust_para_y(), cursor_move_line(), table_outer_para(), table_row_first_cell(), and table_select_next_cell_or_append().

◆ update_caret()

void update_caret ( ME_TextEditor ed)

Definition at line 277 of file caret.c.

278{
279 int x, y, height;
280
281 if (!editor->bHaveFocus) return;
282 if (!ME_IsSelection(editor))
283 {
284 cursor_coords( editor, &editor->pCursors[0], &x, &y, &height );
285 if (height != editor->caret_height) create_caret(editor);
286 x = min(x, editor->rcFormat.right-1);
287 ITextHost_TxSetCaretPos(editor->texthost, x, y);
288 show_caret(editor);
289 }
290 else
291 hide_caret(editor);
292#ifdef __REACTOS__
294 {
295 HIMC hIMC = ImmGetContext(editor->hWnd);
296 if (hIMC)
297 {
299 LOGFONTW lf;
300 COMPOSITIONFORM CompForm;
301 POINT pt = { x, y };
302
303 CompForm.ptCurrentPos = pt;
304 if (editor->styleFlags & ES_MULTILINE)
305 {
306 CompForm.dwStyle = CFS_RECT;
307 CompForm.rcArea = editor->rcFormat;
308 }
309 else
310 {
311 CompForm.dwStyle = CFS_POINT;
312 SetRectEmpty(&CompForm.rcArea);
313 }
314 ImmSetCompositionWindow(hIMC, &CompForm);
315
316 fmt.cbSize = sizeof(fmt);
318
319 ZeroMemory(&lf, sizeof(lf));
321 if (fmt.dwMask & CFM_SIZE)
322 {
324 lf.lfHeight = -MulDiv(fmt.yHeight, GetDeviceCaps(hdc, LOGPIXELSY), 1440);
325 DeleteDC(hdc);
326 }
327 if (fmt.dwMask & CFM_CHARSET)
328 lf.lfCharSet = fmt.bCharSet;
329 if (fmt.dwMask & CFM_FACE)
330 lstrcpynW(lf.lfFaceName, fmt.szFaceName, ARRAY_SIZE(lf.lfFaceName));
331 ImmSetCompositionFontW(hIMC, &lf);
332
333 ImmReleaseContext(editor->hWnd, hIMC);
334 }
335 }
336#endif
337}
#define lstrcpynW
Definition: compat.h:738
void show_caret(ME_TextEditor *editor)
Definition: caret.c:261
#define ITextHost_TxSetCaretPos(This, a, b)
Definition: editor.h:342
#define CFS_RECT
Definition: imm.h:324
BOOL WINAPI ImmSetCompositionWindow(_In_ HIMC hIMC, _In_ LPCOMPOSITIONFORM lpCompForm)
Definition: ime.c:1149
#define CFS_POINT
Definition: imm.h:325
#define ES_MULTILINE
Definition: pedump.c:667
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 editor_handle_message(), ME_ArrowKey(), ME_LButtonDown(), ME_MouseMove(), ME_UpdateRepaint(), set_selection(), and table_handle_tab().

◆ wrap_marked_paras_dc()

BOOL wrap_marked_paras_dc ( ME_TextEditor editor,
HDC  hdc,
BOOL  invalidate 
)

Definition at line 1032 of file wrap.c.

1033{
1034 ME_Paragraph *para, *next;
1035 struct wine_rb_entry *entry, *next_entry = NULL;
1036 ME_Context c;
1037 int totalWidth = editor->nTotalWidth, prev_width;
1038 struct repaint_range repaint = { NULL, NULL };
1039
1040 if (!editor->marked_paras.root) return FALSE;
1041
1042 ME_InitContext( &c, editor, hdc );
1043
1044 entry = rb_head( editor->marked_paras.root );
1045 while (entry)
1046 {
1047 para = WINE_RB_ENTRY_VALUE( entry, ME_Paragraph, marked_entry );
1048
1049 /* If the first entry lies inside a table, go back to the start
1050 of the table to ensure cell heights are kept in sync. */
1051 if (!next_entry && para_in_table( para ) && para != table_outer_para( para ))
1052 {
1053 para = table_outer_para( para );
1054 next_entry = entry;
1055 }
1056 else
1057 next_entry = rb_next( entry );
1058
1059 c.pt = para->pt;
1060 prev_width = para->nWidth;
1061 ME_WrapTextParagraph( editor, &c, para );
1062 if (prev_width == totalWidth && para->nWidth < totalWidth)
1063 totalWidth = get_total_width(editor);
1064 else
1065 totalWidth = max(totalWidth, para->nWidth);
1066
1067 update_repaint( para, &repaint );
1068 adjust_para_y( para, &c, &repaint );
1069
1070 if (para_next( para ))
1071 {
1072 if (c.pt.x != para_next( para )->pt.x || c.pt.y != para_next( para )->pt.y ||
1073 para_in_table( para ))
1074 {
1075 next = para;
1076 while (para_next( next ) && &next->marked_entry != next_entry &&
1077 next != &editor->pBuffer->pLast->member.para)
1078 {
1079 update_repaint( para_next( next ), &repaint );
1080 para_next( next )->pt = c.pt;
1081 adjust_para_y( para_next( next ), &c, &repaint );
1082 next = para_next( next );
1083 }
1084 }
1085 }
1086 entry = next_entry;
1087 }
1088 wine_rb_destroy( &editor->marked_paras, NULL, NULL );
1089
1090 editor->sizeWindow.cx = c.rcView.right-c.rcView.left;
1091 editor->sizeWindow.cy = c.rcView.bottom-c.rcView.top;
1092
1093 editor->nTotalLength = editor->pBuffer->pLast->member.para.pt.y;
1094 editor->nTotalWidth = totalWidth;
1095
1097
1098 if (invalidate && (repaint.start || editor->nTotalLength < editor->nLastTotalLength))
1099 para_range_invalidate( editor, repaint.start, repaint.end);
1100 return !!repaint.start;
1101}
struct rb_node * rb_next(struct rb_node *)
Definition: rbtree.c:320
int get_total_width(ME_TextEditor *editor)
Definition: para.c:69
#define wine_rb_entry
Definition: rbtree.h:404
#define WINE_RB_ENTRY_VALUE
Definition: rbtree.h:414
static struct rb_entry * rb_head(struct rb_entry *iter)
Definition: rbtree.h:97
#define wine_rb_destroy
Definition: rbtree.h:408
ME_Paragraph * start
Definition: wrap.c:919
ME_Paragraph * end
Definition: wrap.c:919
static void invalidate()
static void ME_WrapTextParagraph(ME_TextEditor *editor, ME_Context *c, ME_Paragraph *para)
Definition: wrap.c:817
static void update_repaint(ME_Paragraph *para, struct repaint_range *repaint)
Definition: wrap.c:922
void para_range_invalidate(ME_TextEditor *editor, ME_Paragraph *start_para, ME_Paragraph *last_para)
Definition: wrap.c:1111
static void adjust_para_y(ME_Paragraph *para, ME_Context *c, struct repaint_range *repaint)
Definition: wrap.c:928

Referenced by fnTextSrv_TxDraw(), fnTextSrv_TxGetNaturalSize(), ME_MakeEditor(), and ME_WrapMarkedParagraphs().

Variable Documentation

◆ dll_instance

HINSTANCE dll_instance
extern

Definition at line 253 of file editor.c.

Referenced by DllMain(), and editor_set_cursor().

◆ me_debug

BOOL me_debug
extern

Definition at line 254 of file editor.c.

Referenced by draw_paragraph().

◆ re_ole_vtbl

const IRichEditOleVtbl re_ole_vtbl
extern

Definition at line 1419 of file richole.c.

Referenced by create_text_services().

◆ text_doc2old_vtbl

const ITextDocument2OldVtbl text_doc2old_vtbl
extern

Definition at line 4527 of file richole.c.

Referenced by create_text_services().