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