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 
12 private import win32.windef, win32.winuser;
13 private import win32.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 const TM_PLAINTEXT=1;
289 const TM_RICHTEXT=2;
290 const TM_SINGLELEVELUNDO=4;
291 const TM_MULTILEVELUNDO=8;
292 const TM_SINGLECODEPAGE=16;
293 const TM_MULTICODEPAGE=32;
294 
295 const GT_DEFAULT=0;
296 const GT_USECRLF=1;
297 
298 const yHeightCharPtsMost=1638;
299 const lDefaultTab=720;
300 
301 struct CHARFORMATA {
302 	UINT cbSize = this.sizeof;
303 	DWORD dwMask;
304 	DWORD dwEffects;
305 	LONG yHeight;
306 	LONG yOffset;
307 	COLORREF crTextColor;
308 	BYTE bCharSet;
309 	BYTE bPitchAndFamily;
310 	char szFaceName[LF_FACESIZE];
311 }
312 struct CHARFORMATW {
313 	UINT cbSize = this.sizeof;
314 	DWORD dwMask;
315 	DWORD dwEffects;
316 	LONG yHeight;
317 	LONG yOffset;
318 	COLORREF crTextColor;
319 	BYTE bCharSet;
320 	BYTE bPitchAndFamily;
321 	WCHAR szFaceName[LF_FACESIZE];
322 }
323 
324 struct CHARFORMAT2A {
325 	UINT cbSize = this.sizeof;
326 	DWORD dwMask;
327 	DWORD dwEffects;
328 	LONG yHeight;
329 	LONG yOffset;
330 	COLORREF crTextColor;
331 	BYTE bCharSet;
332 	BYTE bPitchAndFamily;
333 	char szFaceName[LF_FACESIZE];
334 	WORD wWeight;
335 	SHORT sSpacing;
336 	COLORREF crBackColor;
337 	LCID lcid;
338 	DWORD dwReserved;
339 	SHORT sStyle;
340 	WORD wKerning;
341 	BYTE bUnderlineType;
342 	BYTE bAnimation;
343 	BYTE bRevAuthor;
344 }
345 
346 struct CHARFORMAT2W {
347 	UINT cbSize = this.sizeof;
348 	DWORD dwMask;
349 	DWORD dwEffects;
350 	LONG yHeight;
351 	LONG yOffset;
352 	COLORREF crTextColor;
353 	BYTE bCharSet;
354 	BYTE bPitchAndFamily;
355 	WCHAR szFaceName[LF_FACESIZE];
356 	WORD wWeight;
357 	SHORT sSpacing;
358 	COLORREF crBackColor;
359 	LCID lcid;
360 	DWORD dwReserved;
361 	SHORT sStyle;
362 	WORD wKerning;
363 	BYTE bUnderlineType;
364 	BYTE bAnimation;
365 	BYTE bRevAuthor;
366 }
367 
368 struct CHARRANGE {
369 	LONG cpMin;
370 	LONG cpMax;
371 }
372 
373 struct COMPCOLOR {
374 	COLORREF crText;
375 	COLORREF crBackground;
376 	DWORD dwEffects;
377 }
378 
379 extern (Windows) {
380 	alias DWORD function(DWORD,PBYTE,LONG,LONG*) EDITSTREAMCALLBACK;
381 }
382 
383 struct EDITSTREAM {
384 	DWORD dwCookie;
385 	DWORD dwError;
386 	EDITSTREAMCALLBACK pfnCallback;
387 }
388 
389 struct ENCORRECTTEXT {
390 	NMHDR nmhdr;
391 	CHARRANGE chrg;
392 	WORD seltyp;
393 }
394 
395 struct ENDROPFILES {
396 	NMHDR nmhdr;
397 	HANDLE hDrop;
398 	LONG cp;
399 	BOOL fProtected;
400 }
401 
402 struct ENLINK {
403 	NMHDR nmhdr;
404 	UINT msg;
405 	WPARAM wParam;
406 	LPARAM lParam;
407 	CHARRANGE chrg;
408 }
409 
410 struct ENOLEOPFAILED {
411 	NMHDR nmhdr;
412 	LONG iob;
413 	LONG lOper;
414 	HRESULT hr;
415 }
416 
417 struct ENPROTECTED {
418 	NMHDR nmhdr;
419 	UINT msg;
420 	WPARAM wParam;
421 	LPARAM lParam;
422 	CHARRANGE chrg;
423 }
424 alias ENPROTECTED* LPENPROTECTED;
425 
426 struct ENSAVECLIPBOARD {
427 	NMHDR nmhdr;
428 	LONG cObjectCount;
429 	LONG cch;
430 }
431 
432 struct FINDTEXTA {
433 	CHARRANGE chrg;
434 	LPSTR lpstrText;
435 }
436 
437 struct FINDTEXTW {
438 	CHARRANGE chrg;
439 	LPWSTR lpstrText;
440 }
441 
442 struct FINDTEXTEXA {
443 	CHARRANGE chrg;
444 	LPSTR lpstrText;
445 	CHARRANGE chrgText;
446 }
447 
448 struct FINDTEXTEXW {
449 	CHARRANGE chrg;
450 	LPWSTR lpstrText;
451 	CHARRANGE chrgText;
452 }
453 
454 struct FORMATRANGE {
455 	HDC hdc;
456 	HDC hdcTarget;
457 	RECT rc;
458 	RECT rcPage;
459 	CHARRANGE chrg;
460 }
461 
462 struct MSGFILTER {
463 	NMHDR nmhdr;
464 	UINT msg;
465 	WPARAM wParam;
466 	LPARAM lParam;
467 }
468 
469 struct PARAFORMAT {
470 	UINT cbSize = this.sizeof;
471 	DWORD dwMask;
472 	WORD wNumbering;
473 	WORD wReserved;
474 	LONG dxStartIndent;
475 	LONG dxRightIndent;
476 	LONG dxOffset;
477 	WORD wAlignment;
478 	SHORT cTabCount;
479 	LONG rgxTabs[MAX_TAB_STOPS];
480 }
481 
482 struct PARAFORMAT2 {
483 	UINT cbSize = this.sizeof;
484 	DWORD dwMask;
485 	WORD wNumbering;
486 	WORD wEffects;
487 	LONG dxStartIndent;
488 	LONG dxRightIndent;
489 	LONG dxOffset;
490 	WORD wAlignment;
491 	SHORT cTabCount;
492 	LONG rgxTabs[MAX_TAB_STOPS];
493 	LONG dySpaceBefore;
494 	LONG dySpaceAfter;
495 	LONG dyLineSpacing;
496 	SHORT sStype;
497 	BYTE bLineSpacingRule;
498 	BYTE bOutlineLevel;
499 	WORD wShadingWeight;
500 	WORD wShadingStyle;
501 	WORD wNumberingStart;
502 	WORD wNumberingStyle;
503 	WORD wNumberingTab;
504 	WORD wBorderSpace;
505 	WORD wBorderWidth;
506 	WORD wBorders;
507 }
508 
509 struct SELCHANGE {
510 	NMHDR nmhdr;
511 	CHARRANGE chrg;
512 	WORD seltyp;
513 }
514 
515 struct TEXTRANGEA {
516 	CHARRANGE chrg;
517 	LPSTR lpstrText;
518 }
519 
520 struct TEXTRANGEW {
521 	CHARRANGE chrg;
522 	LPWSTR lpstrText;
523 }
524 
525 struct REQRESIZE {
526 	NMHDR nmhdr;
527 	RECT rc;
528 }
529 
530 struct REPASTESPECIAL {
531 	DWORD dwAspect;
532 	DWORD dwParam;
533 }
534 
535 struct PUNCTUATION {
536 	UINT iSize;
537 	LPSTR szPunctuation;
538 }
539 
540 struct GETTEXTEX {
541 	DWORD cb;
542 	DWORD flags;
543 	UINT codepage;
544 	LPCSTR lpDefaultChar;
545 	LPBOOL lpUsedDefaultChar;
546 }
547 
548 extern (Windows) {
549 alias LONG function(char*,LONG,BYTE,INT) EDITWORDBREAKPROCEX;
550 }
551 
552 /* Defines for EM_SETTYPOGRAPHYOPTIONS */
553 const TO_ADVANCEDTYPOGRAPHY = 1;
554 const TO_SIMPLELINEBREAK    = 2;
555 
556 /* Defines for GETTEXTLENGTHEX */
557 const GTL_DEFAULT  = 0;
558 const GTL_USECRLF  = 1;
559 const GTL_PRECISE  = 2;
560 const GTL_CLOSE    = 4;
561 const GTL_NUMCHARS = 8;
562 const GTL_NUMBYTES = 16;
563 
564 struct GETTEXTLENGTHEX {
565 	DWORD flags;
566 	UINT codepage;
567 }
568 
569 version(Unicode) {
570 	alias CHARFORMATW CHARFORMAT;
571 	alias CHARFORMAT2W CHARFORMAT2;
572 	alias FINDTEXTW FINDTEXT;
573 	alias FINDTEXTEXW FINDTEXTEX;
574 	alias TEXTRANGEW TEXTRANGE;
575 } else {
576 	alias CHARFORMATA CHARFORMAT;
577 	alias CHARFORMAT2A CHARFORMAT2;
578 	alias FINDTEXTA FINDTEXT;
579 	alias FINDTEXTEXA FINDTEXTEX;
580 	alias TEXTRANGEA TEXTRANGE;
581 }