1 /***********************************************************************\
2 *                               richedit.d                              *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                                                                       *
8 *                       Placed into public domain                       *
9 \***********************************************************************/
10 module windows.richedit;
11 nothrow:
12 private import windows.windef, windows.winuser;
13 private import windows.wingdi; // for LF_FACESIZE
14 
15 align(4):
16 
17 version(Unicode) {
18 	const wchar[] RICHEDIT_CLASS = "RichEdit20W";
19 } else {
20 	const char[] RICHEDIT_CLASS  = "RichEdit20A";
21 }
22 
23 const RICHEDIT_CLASS10A = "RICHEDIT";
24 
25 const TCHAR[]
26 	CF_RTF       = "Rich Text Format",
27 	CF_RTFNOOBJS = "Rich Text Format Without Objects",
28 	CF_RETEXTOBJ = "RichEdit Text and Objects";
29 
30 const DWORD
31 	CFM_BOLD        = 1,
32 	CFM_ITALIC      = 2,
33 	CFM_UNDERLINE   = 4,
34 	CFM_STRIKEOUT   = 8,
35 	CFM_PROTECTED   = 16,
36 	CFM_LINK        = 32,
37 	CFM_SIZE        = 0x80000000,
38 	CFM_COLOR       = 0x40000000,
39 	CFM_FACE        = 0x20000000,
40 	CFM_OFFSET      = 0x10000000,
41 	CFM_CHARSET     = 0x08000000,
42 	CFM_SUBSCRIPT   = 0x00030000,
43 	CFM_SUPERSCRIPT = 0x00030000;
44 
45 const DWORD
46 	CFE_BOLD        = 1,
47 	CFE_ITALIC      = 2,
48 	CFE_UNDERLINE   = 4,
49 	CFE_STRIKEOUT   = 8,
50 	CFE_PROTECTED   = 16,
51 	CFE_SUBSCRIPT   = 0x00010000,
52 	CFE_SUPERSCRIPT = 0x00020000,
53 	CFE_AUTOCOLOR   = 0x40000000;
54 
55 const CFM_EFFECTS = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_COLOR
56   | CFM_STRIKEOUT | CFE_PROTECTED | CFM_LINK;
57 
58 // flags for EM_SETIMEOPTIONS
59 const LPARAM
60 	IMF_FORCENONE         = 1,
61 	IMF_FORCEENABLE       = 2,
62 	IMF_FORCEDISABLE      = 4,
63 	IMF_CLOSESTATUSWINDOW = 8,
64 	IMF_VERTICAL          = 32,
65 	IMF_FORCEACTIVE       = 64,
66 	IMF_FORCEINACTIVE     = 128,
67 	IMF_FORCEREMEMBER     = 256;
68 
69 const SEL_EMPTY=0;
70 const SEL_TEXT=1;
71 const SEL_OBJECT=2;
72 const SEL_MULTICHAR=4;
73 const SEL_MULTIOBJECT=8;
74 
75 const MAX_TAB_STOPS=32;
76 
77 const PFM_ALIGNMENT=8;
78 const PFM_NUMBERING=32;
79 const PFM_OFFSET=4;
80 const PFM_OFFSETINDENT=0x80000000;
81 const PFM_RIGHTINDENT=2;
82 const PFM_STARTINDENT=1;
83 const PFM_TABSTOPS=16;
84 const PFM_BORDER=2048;
85 const PFM_LINESPACING=256;
86 const PFM_NUMBERINGSTART=32768;
87 const PFM_NUMBERINGSTYLE=8192;
88 const PFM_NUMBERINGTAB=16384;
89 const PFM_SHADING=4096;
90 const PFM_SPACEAFTER=128;
91 const PFM_SPACEBEFORE=64;
92 const PFM_STYLE=1024;
93 const PFM_DONOTHYPHEN=4194304;
94 const PFM_KEEP=131072;
95 const PFM_KEEPNEXT=262144;
96 const PFM_NOLINENUMBER=1048576;
97 const PFM_NOWIDOWCONTROL=2097152;
98 const PFM_PAGEBREAKBEFORE=524288;
99 const PFM_RTLPARA=65536;
100 const PFM_SIDEBYSIDE=8388608;
101 const PFM_TABLE=1073741824;
102 const PFN_BULLET=1;
103 
104 const PFE_DONOTHYPHEN=64;
105 const PFE_KEEP=2;
106 const PFE_KEEPNEXT=4;
107 const PFE_NOLINENUMBER=16;
108 const PFE_NOWIDOWCONTROL=32;
109 const PFE_PAGEBREAKBEFORE=8;
110 const PFE_RTLPARA=1;
111 const PFE_SIDEBYSIDE=128;
112 const PFE_TABLE=16384;
113 const PFA_LEFT=1;
114 const PFA_RIGHT=2;
115 const PFA_CENTER=3;
116 const PFA_JUSTIFY=4;
117 const PFA_FULL_INTERWORD=4;
118 
119 const SF_TEXT=1;
120 const SF_RTF=2;
121 const SF_RTFNOOBJS=3;
122 const SF_TEXTIZED=4;
123 const SF_UNICODE=16;
124 const SF_USECODEPAGE=32;
125 const SF_NCRFORNONASCII=64;
126 const SF_RTFVAL=0x0700;
127 
128 const SFF_PWD=0x0800;
129 const SFF_KEEPDOCINFO=0x1000;
130 const SFF_PERSISTVIEWSCALE=0x2000;
131 const SFF_PLAINRTF=0x4000;
132 const SFF_SELECTION=0x8000;
133 
134 const WB_CLASSIFY      = 3;
135 const WB_MOVEWORDLEFT  = 4;
136 const WB_MOVEWORDRIGHT = 5;
137 const WB_LEFTBREAK     = 6;
138 const WB_RIGHTBREAK    = 7;
139 const WB_MOVEWORDPREV  = 4;
140 const WB_MOVEWORDNEXT  = 5;
141 const WB_PREVBREAK     = 6;
142 const WB_NEXTBREAK     = 7;
143 
144 const WBF_WORDWRAP  = 16;
145 const WBF_WORDBREAK = 32;
146 const WBF_OVERFLOW  = 64;
147 const WBF_LEVEL1    = 128;
148 const WBF_LEVEL2    = 256;
149 const WBF_CUSTOM    = 512;
150 
151 const ES_DISABLENOSCROLL  = 8192;
152 const ES_SUNKEN           = 16384;
153 const ES_SAVESEL          = 32768;
154 const ES_EX_NOCALLOLEINIT = 16777216;
155 const ES_NOIME            = 524288;
156 const ES_NOOLEDRAGDROP    = 8;
157 const ES_SELECTIONBAR     = 16777216;
158 const ES_SELFIME          = 262144;
159 const ES_VERTICAL         = 4194304;
160 
161 const EM_CANPASTE = WM_USER+50;
162 const EM_DISPLAYBAND = WM_USER+51;
163 const EM_EXGETSEL = WM_USER+52;
164 const EM_EXLIMITTEXT = WM_USER+53;
165 const EM_EXLINEFROMCHAR = WM_USER+54;
166 const EM_EXSETSEL = WM_USER+55;
167 const EM_FINDTEXT = WM_USER+56;
168 const EM_FORMATRANGE = WM_USER+57;
169 const EM_GETCHARFORMAT = WM_USER+58;
170 const EM_GETEVENTMASK = WM_USER+59;
171 const EM_GETOLEINTERFACE = WM_USER+60;
172 const EM_GETPARAFORMAT = WM_USER+61;
173 const EM_GETSELTEXT = WM_USER+62;
174 const EM_HIDESELECTION = WM_USER+63;
175 const EM_PASTESPECIAL = WM_USER+64;
176 const EM_REQUESTRESIZE = WM_USER+65;
177 const EM_SELECTIONTYPE = WM_USER+66;
178 const EM_SETBKGNDCOLOR = WM_USER+67;
179 const EM_SETCHARFORMAT = WM_USER+68;
180 const EM_SETEVENTMASK = WM_USER+69;
181 const EM_SETOLECALLBACK = WM_USER+70;
182 const EM_SETPARAFORMAT = WM_USER+71;
183 const EM_SETTARGETDEVICE = WM_USER+72;
184 const EM_STREAMIN = WM_USER+73;
185 const EM_STREAMOUT = WM_USER+74;
186 const EM_GETTEXTRANGE = WM_USER+75;
187 const EM_FINDWORDBREAK = WM_USER+76;
188 const EM_SETOPTIONS = WM_USER+77;
189 const EM_GETOPTIONS = WM_USER+78;
190 const EM_FINDTEXTEX = WM_USER+79;
191 const EM_GETWORDBREAKPROCEX = WM_USER+80;
192 const EM_SETWORDBREAKPROCEX = WM_USER+81;
193 /* RichEdit 2.0 messages */
194 const EM_SETUNDOLIMIT = WM_USER+82;
195 const EM_REDO = WM_USER+84;
196 const EM_CANREDO = WM_USER+85;
197 const EM_GETUNDONAME = WM_USER+86;
198 const EM_GETREDONAME = WM_USER+87;
199 const EM_STOPGROUPTYPING = WM_USER+88;
200 const EM_SETTEXTMODE = WM_USER+89;
201 const EM_GETTEXTMODE = WM_USER+90;
202 const EM_AUTOURLDETECT = WM_USER+91;
203 const EM_GETAUTOURLDETECT = WM_USER + 92;
204 const EM_SETPALETTE = WM_USER + 93;
205 const EM_GETTEXTEX = WM_USER+94;
206 const EM_GETTEXTLENGTHEX = WM_USER+95;
207 const EM_SHOWSCROLLBAR = WM_USER+96;
208 const EM_SETTEXTEX = WM_USER + 97;
209 const EM_SETPUNCTUATION = WM_USER + 100;
210 const EM_GETPUNCTUATION = WM_USER + 101;
211 const EM_SETWORDWRAPMODE = WM_USER + 102;
212 const EM_GETWORDWRAPMODE = WM_USER + 103;
213 const EM_SETIMECOLOR = WM_USER + 104;
214 const EM_GETIMECOLOR = WM_USER + 105;
215 const EM_SETIMEOPTIONS = WM_USER + 106;
216 const EM_GETIMEOPTIONS = WM_USER + 107;
217 const EM_SETLANGOPTIONS = WM_USER+120;
218 const EM_GETLANGOPTIONS = WM_USER+121;
219 const EM_GETIMECOMPMODE = WM_USER+122;
220 const EM_FINDTEXTW = WM_USER + 123;
221 const EM_FINDTEXTEXW = WM_USER + 124;
222 const EM_RECONVERSION = WM_USER + 125;
223 const EM_SETBIDIOPTIONS = WM_USER + 200;
224 const EM_GETBIDIOPTIONS = WM_USER + 201;
225 const EM_SETTYPOGRAPHYOPTIONS = WM_USER+202;
226 const EM_GETTYPOGRAPHYOPTIONS = WM_USER+203;
227 const EM_SETEDITSTYLE = WM_USER + 204;
228 const EM_GETEDITSTYLE = WM_USER + 205;
229 const EM_GETSCROLLPOS = WM_USER+221;
230 const EM_SETSCROLLPOS = WM_USER+222;
231 const EM_SETFONTSIZE = WM_USER+223;
232 const EM_GETZOOM = WM_USER+224;
233 const EM_SETZOOM = WM_USER+225;
234 
235 const EN_MSGFILTER     = 1792;
236 const EN_REQUESTRESIZE = 1793;
237 const EN_SELCHANGE     = 1794;
238 const EN_DROPFILES     = 1795;
239 const EN_PROTECTED     = 1796;
240 const EN_CORRECTTEXT   = 1797;
241 const EN_STOPNOUNDO    = 1798;
242 const EN_IMECHANGE     = 1799;
243 const EN_SAVECLIPBOARD = 1800;
244 const EN_OLEOPFAILED   = 1801;
245 const EN_LINK          = 1803;
246 
247 const ENM_NONE            = 0;
248 const ENM_CHANGE          = 1;
249 const ENM_UPDATE          = 2;
250 const ENM_SCROLL          = 4;
251 const ENM_SCROLLEVENTS    = 8;
252 const ENM_DRAGDROPDONE    = 16;
253 const ENM_KEYEVENTS       = 65536;
254 const ENM_MOUSEEVENTS     = 131072;
255 const ENM_REQUESTRESIZE   = 262144;
256 const ENM_SELCHANGE       = 524288;
257 const ENM_DROPFILES       = 1048576;
258 const ENM_PROTECTED       = 2097152;
259 const ENM_CORRECTTEXT     = 4194304;
260 const ENM_IMECHANGE       = 8388608;
261 const ENM_LANGCHANGE      = 16777216;
262 const ENM_OBJECTPOSITIONS = 33554432;
263 const ENM_LINK            = 67108864;
264 
265 const ECO_AUTOWORDSELECTION=1;
266 const ECO_AUTOVSCROLL=64;
267 const ECO_AUTOHSCROLL=128;
268 const ECO_NOHIDESEL=256;
269 const ECO_READONLY=2048;
270 const ECO_WANTRETURN=4096;
271 const ECO_SAVESEL=0x8000;
272 const ECO_SELECTIONBAR=0x1000000;
273 const ECO_VERTICAL=0x400000;
274 
275 enum {
276 	ECOOP_SET = 1,
277 	ECOOP_OR,
278 	ECOOP_AND,
279 	ECOOP_XOR
280 }
281 
282 const SCF_DEFAULT    = 0;
283 const SCF_SELECTION  = 1;
284 const SCF_WORD       = 2;
285 const SCF_ALL        = 4;
286 const SCF_USEUIRULES = 8;
287 
288 alias DWORD TEXTMODE;
289 const TM_PLAINTEXT=1;
290 const TM_RICHTEXT=2;
291 const TM_SINGLELEVELUNDO=4;
292 const TM_MULTILEVELUNDO=8;
293 const TM_SINGLECODEPAGE=16;
294 const TM_MULTICODEPAGE=32;
295 
296 const GT_DEFAULT=0;
297 const GT_USECRLF=1;
298 
299 const yHeightCharPtsMost=1638;
300 const lDefaultTab=720;
301 
302 alias DWORD UNDONAMEID;
303 const UID_UNKNOWN    = 0;
304 const UID_TYPING     = 1;
305 const UID_DELETE     = 2;
306 const UID_DRAGDROP   = 3;
307 const UID_CUT        = 4;
308 const UID_PASTE      = 5;
309 
310 struct CHARFORMATA {
311 	UINT cbSize = this.sizeof;
312 	DWORD dwMask;
313 	DWORD dwEffects;
314 	LONG yHeight;
315 	LONG yOffset;
316 	COLORREF crTextColor;
317 	BYTE bCharSet;
318 	BYTE bPitchAndFamily;
319 	char[LF_FACESIZE] szFaceName;
320 }
321 struct CHARFORMATW {
322 	UINT cbSize = this.sizeof;
323 	DWORD dwMask;
324 	DWORD dwEffects;
325 	LONG yHeight;
326 	LONG yOffset;
327 	COLORREF crTextColor;
328 	BYTE bCharSet;
329 	BYTE bPitchAndFamily;
330 	WCHAR[LF_FACESIZE] szFaceName;
331 }
332 
333 struct CHARFORMAT2A {
334 	UINT cbSize = this.sizeof;
335 	DWORD dwMask;
336 	DWORD dwEffects;
337 	LONG yHeight;
338 	LONG yOffset;
339 	COLORREF crTextColor;
340 	BYTE bCharSet;
341 	BYTE bPitchAndFamily;
342 	char[LF_FACESIZE] szFaceName;
343 	WORD wWeight;
344 	SHORT sSpacing;
345 	COLORREF crBackColor;
346 	LCID lcid;
347 	DWORD dwReserved;
348 	SHORT sStyle;
349 	WORD wKerning;
350 	BYTE bUnderlineType;
351 	BYTE bAnimation;
352 	BYTE bRevAuthor;
353 }
354 
355 struct CHARFORMAT2W {
356 	UINT cbSize = this.sizeof;
357 	DWORD dwMask;
358 	DWORD dwEffects;
359 	LONG yHeight;
360 	LONG yOffset;
361 	COLORREF crTextColor;
362 	BYTE bCharSet;
363 	BYTE bPitchAndFamily;
364 	WCHAR[LF_FACESIZE] szFaceName;
365 	WORD wWeight;
366 	SHORT sSpacing;
367 	COLORREF crBackColor;
368 	LCID lcid;
369 	DWORD dwReserved;
370 	SHORT sStyle;
371 	WORD wKerning;
372 	BYTE bUnderlineType;
373 	BYTE bAnimation;
374 	BYTE bRevAuthor;
375 }
376 
377 struct CHARRANGE {
378 	LONG cpMin;
379 	LONG cpMax;
380 }
381 
382 struct COMPCOLOR {
383 	COLORREF crText;
384 	COLORREF crBackground;
385 	DWORD dwEffects;
386 }
387 
388 extern (Windows) {
389 	alias DWORD function(DWORD,PBYTE,LONG,LONG*) EDITSTREAMCALLBACK;
390 }
391 
392 struct EDITSTREAM {
393 	DWORD dwCookie;
394 	DWORD dwError;
395 	EDITSTREAMCALLBACK pfnCallback;
396 }
397 
398 struct ENCORRECTTEXT {
399 	NMHDR nmhdr;
400 	CHARRANGE chrg;
401 	WORD seltyp;
402 }
403 
404 struct ENDROPFILES {
405 	NMHDR nmhdr;
406 	HANDLE hDrop;
407 	LONG cp;
408 	BOOL fProtected;
409 }
410 
411 struct ENLINK {
412 	NMHDR nmhdr;
413 	UINT msg;
414 	WPARAM wParam;
415 	LPARAM lParam;
416 	CHARRANGE chrg;
417 }
418 
419 struct ENOLEOPFAILED {
420 	NMHDR nmhdr;
421 	LONG iob;
422 	LONG lOper;
423 	HRESULT hr;
424 }
425 
426 struct ENPROTECTED {
427 	NMHDR nmhdr;
428 	UINT msg;
429 	WPARAM wParam;
430 	LPARAM lParam;
431 	CHARRANGE chrg;
432 }
433 alias ENPROTECTED* LPENPROTECTED;
434 
435 struct ENSAVECLIPBOARD {
436 	NMHDR nmhdr;
437 	LONG cObjectCount;
438 	LONG cch;
439 }
440 
441 struct FINDTEXTA {
442 	CHARRANGE chrg;
443 	LPSTR lpstrText;
444 }
445 
446 struct FINDTEXTW {
447 	CHARRANGE chrg;
448 	LPWSTR lpstrText;
449 }
450 
451 struct FINDTEXTEXA {
452 	CHARRANGE chrg;
453 	LPSTR lpstrText;
454 	CHARRANGE chrgText;
455 }
456 
457 struct FINDTEXTEXW {
458 	CHARRANGE chrg;
459 	LPWSTR lpstrText;
460 	CHARRANGE chrgText;
461 }
462 
463 struct FORMATRANGE {
464 	HDC hdc;
465 	HDC hdcTarget;
466 	RECT rc;
467 	RECT rcPage;
468 	CHARRANGE chrg;
469 }
470 
471 struct MSGFILTER {
472 	NMHDR nmhdr;
473 	UINT msg;
474 	WPARAM wParam;
475 	LPARAM lParam;
476 }
477 
478 struct PARAFORMAT {
479 	UINT cbSize = this.sizeof;
480 	DWORD dwMask;
481 	WORD wNumbering;
482 	WORD wReserved;
483 	LONG dxStartIndent;
484 	LONG dxRightIndent;
485 	LONG dxOffset;
486 	WORD wAlignment;
487 	SHORT cTabCount;
488 	LONG[MAX_TAB_STOPS] rgxTabs;
489 }
490 
491 struct PARAFORMAT2 {
492 	UINT cbSize = this.sizeof;
493 	DWORD dwMask;
494 	WORD wNumbering;
495 	WORD wEffects;
496 	LONG dxStartIndent;
497 	LONG dxRightIndent;
498 	LONG dxOffset;
499 	WORD wAlignment;
500 	SHORT cTabCount;
501 	LONG[MAX_TAB_STOPS] rgxTabs;
502 	LONG dySpaceBefore;
503 	LONG dySpaceAfter;
504 	LONG dyLineSpacing;
505 	SHORT sStype;
506 	BYTE bLineSpacingRule;
507 	BYTE bOutlineLevel;
508 	WORD wShadingWeight;
509 	WORD wShadingStyle;
510 	WORD wNumberingStart;
511 	WORD wNumberingStyle;
512 	WORD wNumberingTab;
513 	WORD wBorderSpace;
514 	WORD wBorderWidth;
515 	WORD wBorders;
516 }
517 
518 struct SELCHANGE {
519 	NMHDR nmhdr;
520 	CHARRANGE chrg;
521 	WORD seltyp;
522 }
523 
524 struct TEXTRANGEA {
525 	CHARRANGE chrg;
526 	LPSTR lpstrText;
527 }
528 
529 struct TEXTRANGEW {
530 	CHARRANGE chrg;
531 	LPWSTR lpstrText;
532 }
533 
534 struct REQRESIZE {
535 	NMHDR nmhdr;
536 	RECT rc;
537 }
538 
539 struct REPASTESPECIAL {
540 	DWORD dwAspect;
541 	DWORD dwParam;
542 }
543 
544 struct PUNCTUATION {
545 	UINT iSize;
546 	LPSTR szPunctuation;
547 }
548 
549 struct GETTEXTEX {
550 	DWORD cb;
551 	DWORD flags;
552 	UINT codepage;
553 	LPCSTR lpDefaultChar;
554 	LPBOOL lpUsedDefChar;
555 }
556 
557 extern (Windows) {
558 alias LONG function(char*,LONG,BYTE,INT) EDITWORDBREAKPROCEX;
559 }
560 
561 /* Defines for EM_SETTYPOGRAPHYOPTIONS */
562 const TO_ADVANCEDTYPOGRAPHY = 1;
563 const TO_SIMPLELINEBREAK    = 2;
564 
565 /* Defines for GETTEXTLENGTHEX */
566 const GTL_DEFAULT  = 0;
567 const GTL_USECRLF  = 1;
568 const GTL_PRECISE  = 2;
569 const GTL_CLOSE    = 4;
570 const GTL_NUMCHARS = 8;
571 const GTL_NUMBYTES = 16;
572 
573 struct GETTEXTLENGTHEX {
574 	DWORD flags;
575 	UINT codepage;
576 }
577 
578 version(Unicode) {
579 	alias CHARFORMATW CHARFORMAT;
580 	alias CHARFORMAT2W CHARFORMAT2;
581 	alias FINDTEXTW FINDTEXT;
582 	alias FINDTEXTEXW FINDTEXTEX;
583 	alias TEXTRANGEW TEXTRANGE;
584 } else {
585 	alias CHARFORMATA CHARFORMAT;
586 	alias CHARFORMAT2A CHARFORMAT2;
587 	alias FINDTEXTA FINDTEXT;
588 	alias FINDTEXTEXA FINDTEXTEX;
589 	alias TEXTRANGEA TEXTRANGE;
590 }