1 | /**************************************************************************/
|
---|
2 | /* MLE text editor/viewer source code */
|
---|
3 | /* copyright (c) 1993 by M. Kimes */
|
---|
4 | /* All rights reserved */
|
---|
5 | /**************************************************************************/
|
---|
6 |
|
---|
7 | /* MLE support macros */
|
---|
8 |
|
---|
9 | /* return number of lines in file */
|
---|
10 | #define MLEnumlines(h) (LONG)WinSendMsg((h),MLM_QUERYLINECOUNT,\
|
---|
11 | MPVOID,MPVOID)
|
---|
12 |
|
---|
13 | /* return line # from position i */
|
---|
14 | #define MLElinefrompos(h,i) (LONG)WinSendMsg((h),MLM_LINEFROMCHAR,\
|
---|
15 | MPFROMLONG((LONG)(i)),MPVOID)
|
---|
16 |
|
---|
17 | /* return current position of cursor */
|
---|
18 | #define MLEcurpos(h) (IPT)WinSendMsg((h),MLM_QUERYSEL,\
|
---|
19 | MPFROM2SHORT(MLFQS_CURSORSEL,0),MPVOID)
|
---|
20 |
|
---|
21 | /* return current position of anchor */
|
---|
22 | #define MLEancpos(h) (IPT)WinSendMsg((h),MLM_QUERYSEL,\
|
---|
23 | MPFROM2SHORT(MLFQS_ANCHORSEL,0),MPVOID)
|
---|
24 |
|
---|
25 | /* return current line # cursor is on */
|
---|
26 | #define MLEcurline(h) (LONG)WinSendMsg((h),MLM_LINEFROMCHAR,\
|
---|
27 | MPFROMLONG(WinSendMsg((h),MLM_QUERYSEL,\
|
---|
28 | MPFROM2SHORT(MLFQS_CURSORSEL,0),MPVOID)),MPVOID)
|
---|
29 |
|
---|
30 | /* return current line # anchor is on */
|
---|
31 | #define MLEancline(h) (LONG)WinSendMsg((h),MLM_LINEFROMCHAR,\
|
---|
32 | MPFROMLONG(WinSendMsg((h),MLM_QUERYSEL,\
|
---|
33 | MPFROM2SHORT(MLFQS_CURSORSEL,0),MPVOID)),MPVOID)
|
---|
34 |
|
---|
35 | /* return len of remainder of line at cursor position */
|
---|
36 | #define MLEcurlenleft(h) (LONG)WinSendMsg((h),MLM_QUERYFORMATLINELENGTH,\
|
---|
37 | MPFROMLONG(-1L),MPVOID)
|
---|
38 |
|
---|
39 | /* return len of remainder of line at position i */
|
---|
40 | #define MLElinelenleft(h,i) (LONG)WinSendMsg((h),MLM_QUERYFORMATLINELENGTH,\
|
---|
41 | MPFROMLONG((LONG)i),MPVOID)
|
---|
42 |
|
---|
43 | /* return total len of current line */
|
---|
44 | #define MLEcurlinelen(h) (LONG)WinSendMsg((h),MLM_QUERYFORMATLINELENGTH,\
|
---|
45 | MPFROMLONG(WinSendMsg((h),MLM_CHARFROMLINE,\
|
---|
46 | MPFROMLONG(-1L),MPVOID)),MPVOID)
|
---|
47 |
|
---|
48 | /* return total len of line # l */
|
---|
49 | #define MLElinelen(h,l) (LONG)WinSendMsg((h),MLM_QUERYFORMATLINELENGTH,\
|
---|
50 | MPFROMLONG(WinSendMsg((h),MLM_CHARFROMLINE,\
|
---|
51 | MPFROMLONG((l)),MPVOID)),MPVOID)
|
---|
52 |
|
---|
53 | /* return start pos of current line cursor is on */
|
---|
54 | #define MLEstartofcurline(h) (IPT)WinSendMsg((h),MLM_CHARFROMLINE,\
|
---|
55 | MPFROMLONG(-1L),MPVOID)
|
---|
56 |
|
---|
57 | /* return start pos of line l */
|
---|
58 | #define MLEstartofline(h,l) (IPT)WinSendMsg((h),MLM_CHARFROMLINE,\
|
---|
59 | MPFROMLONG((l)),MPVOID)
|
---|
60 |
|
---|
61 | /* copy selected text into buffer b, return len of text copied */
|
---|
62 | #define MLEgetseltext(h,b) (LONG)WinSendMsg((h),MLM_QUERYSELTEXT,\
|
---|
63 | MPFROMP((b)),MPVOID)
|
---|
64 |
|
---|
65 | /* insert text s into selection */
|
---|
66 | #define MLEinsert(h,s) WinSendMsg((h),MLM_INSERT,MPFROMP((s)),MPVOID)
|
---|
67 |
|
---|
68 | /* delete text from pos f to pos t */
|
---|
69 | #define MLEdelete(h,f,t) (LONG)WinSendMsg(h,MLM_DELETE,\
|
---|
70 | MPFROMLONG((IPT)(f)),\
|
---|
71 | MPFROMLONG((LONG)(t)))
|
---|
72 |
|
---|
73 | /* set current cursor (and anchor) position to i */
|
---|
74 | #define MLEsetcurpos(h,i) WinSendMsg((h),MLM_SETSEL,\
|
---|
75 | MPFROMLONG((LONG)(i)),MPFROMLONG((LONG)(i)))
|
---|
76 |
|
---|
77 | /* set current cursor position to i, don't move anchor */
|
---|
78 | #define MLEsetcurposc(h,i) WinSendMsg((h),MLM_SETSEL,\
|
---|
79 | MPFROMLONG((LONG)(i)),MPFROMLONG(-1L))
|
---|
80 |
|
---|
81 | /* set current anchor position to i, don't move cursor */
|
---|
82 | #define MLEsetcurposa(h,i) WinSendMsg((h),MLM_SETSEL,\
|
---|
83 | MPFROMLONG(-1L),MPFROMLONG((LONG)(i)))
|
---|
84 |
|
---|
85 | /* set first line in window to line # l */
|
---|
86 | #define MLEsettopline(h,l) WinSendMsg((h),MLM_SETFIRSTCHAR,(MPARAM)\
|
---|
87 | WinSendMsg((h),MLM_CHARFROMLINE,\
|
---|
88 | WinSendMsg((h),MLM_LINEFROMCHAR,\
|
---|
89 | MPFROMLONG((LONG)(l)),MPVOID),\
|
---|
90 | MPVOID),MPVOID)
|
---|
91 |
|
---|
92 | /* set changed flag to boolean state b */
|
---|
93 | #define MLEsetchanged(h,b) WinSendMsg((h),MLM_SETCHANGED,\
|
---|
94 | MPFROM2SHORT((b),0),MPVOID)
|
---|
95 |
|
---|
96 | /* get changed flag */
|
---|
97 | #define MLEgetchanged(h) (BOOL)WinSendMsg((h),MLM_QUERYCHANGED,MPVOID,MPVOID)
|
---|
98 |
|
---|
99 | /* set MLE wrap to boolean state b */
|
---|
100 | #define MLEsetwrap(h,b) WinSendMsg((h),MLM_SETWRAP,MPFROM2SHORT((b),0),\
|
---|
101 | MPVOID)
|
---|
102 |
|
---|
103 | /* return MLE wrap boolean state */
|
---|
104 | #define MLEgetwrap(h) (BOOL)WinSendMsg((h),MLM_QUERYWRAP,MPVOID,MPVOID)
|
---|
105 |
|
---|
106 | /* set MLE readonly to boolean state b */
|
---|
107 | #define MLEsetreadonly(h,b) WinSendMsg((h),MLM_SETREADONLY,\
|
---|
108 | MPFROM2SHORT((b),0),MPVOID)
|
---|
109 |
|
---|
110 | /* return MLE readonly boolean state */
|
---|
111 | #define MLEgetreadonly(h) (BOOL)WinSendMsg((h),MLM_QUERYREADONLY,MPVOID,MPVOID)
|
---|
112 |
|
---|
113 | /* set text limit to l */
|
---|
114 | #define MLEsetlimit(h,l) WinSendMsg((h),MLM_SETTEXTLIMIT,\
|
---|
115 | MPFROMLONG((LONG)(l)),MPVOID)
|
---|
116 |
|
---|
117 | /* return text limit */
|
---|
118 | #define MLEgetlimit(h) (LONG)WinSendMsg((h),MLM_QUERYFORMATTEXTLIMIT,MPVOID,MPVOID)
|
---|
119 |
|
---|
120 | /* set format to format f */
|
---|
121 | #define MLEsetformat(h,f) WinSendMsg((h),MLM_FORMAT,\
|
---|
122 | MPFROM2SHORT((f),0), MPVOID)
|
---|
123 |
|
---|
124 | /* disable MLE refresh */
|
---|
125 | #define MLEdisable(h) WinSendMsg((h),MLM_DISABLEREFRESH,MPVOID,MPVOID)
|
---|
126 |
|
---|
127 | /* enable MLE refresh */
|
---|
128 | #define MLEenable(h) WinSendMsg((h),MLM_ENABLEREFRESH,MPVOID,MPVOID)
|
---|
129 |
|
---|
130 | /* clear (cut and discard) current selection */
|
---|
131 | #define MLEclear(h) WinSendMsg((h),MLM_CLEAR,MPVOID,MPVOID)
|
---|
132 |
|
---|
133 | /* cut current selection to clipboard */
|
---|
134 | #define MLEcut(h) WinSendMsg((h),MLM_CUT,MPVOID,MPVOID)
|
---|
135 |
|
---|
136 | /* copy current selection to clipboard */
|
---|
137 | #define MLEcopy(h) WinSendMsg((h),MLM_COPY,MPVOID,MPVOID)
|
---|
138 |
|
---|
139 | /* paste clipboard into current selection */
|
---|
140 | #define MLEpaste(h) WinSendMsg((h),MLM_PASTE,MPVOID,MPVOID)
|
---|
141 |
|
---|
142 | /* undo last MLE operation */
|
---|
143 | #define MLEundo(h) WinSendMsg((h),MLM_UNDO,MPVOID,MPVOID)
|
---|
144 |
|
---|
145 | /* return length of text in MLE */
|
---|
146 | #define MLEgetlen(h) (LONG)WinSendMsg((h),MLM_QUERYFORMATTEXTLENGTH,\
|
---|
147 | MPFROMLONG(0),MPFROMLONG((LONG)WinSendMsg((h),\
|
---|
148 | MLM_QUERYTEXTLENGTH,MPVOID,MPVOID)))
|
---|
149 |
|
---|
150 | /* select all text in MLE */
|
---|
151 | #define MLEselectall(h) WinSendMsg((h),MLM_SETSEL,MPFROMLONG(0L),\
|
---|
152 | (MPARAM)WinSendMsg((h),MLM_QUERYFORMATTEXTLENGTH,\
|
---|
153 | MPFROMLONG(0),MPFROMLONG(0xfffffffe)))
|
---|
154 |
|
---|
155 | /* select all text in MLE from cursor to end of file */
|
---|
156 | #define MLEselecttoeof(h) WinSendMsg((h),MLM_SETSEL,\
|
---|
157 | (IPT)WinSendMsg((h),MLM_QUERYSEL,\
|
---|
158 | MPFROM2SHORT(MLFQS_CURSORSEL,0),MPVOID),\
|
---|
159 | (MPARAM)WinSendMsg((h),MLM_QUERYFORMATTEXTLENGTH,\
|
---|
160 | MPFROMLONG(0),MPFROMLONG(0xfffffffe)))
|
---|
161 |
|
---|
162 | /* set anchor point equal to cursor point (no text will be selected) */
|
---|
163 | #define MLEanctocur(h) WinSendMsg((h),MLM_SETSEL,\
|
---|
164 | MPFROMLONG((LONG)WinSendMsg((h),MLM_QUERYSEL,\
|
---|
165 | MPFROM2SHORT(MLFQS_CURSORSEL,0),MPVOID)),\
|
---|
166 | MPFROMLONG(-1L))
|
---|
167 |
|
---|
168 | /* set cursor point equal to anchor point (no text will be selected) */
|
---|
169 | #define MLEcurtoanc(h) WinSendMsg((h),MLM_SETSEL,MPFROMLONG(-1L),\
|
---|
170 | MPFROMLONG((LONG)WinSendMsg((h),MLM_QUERYSEL,\
|
---|
171 | MPFROM2SHORT(MLFQS_ANCHORSEL,0),MPVOID)))
|
---|
172 |
|
---|
173 | /* swap cursor point with anchor point */
|
---|
174 | #define MLEswappoints(h) WinSendMsg((h),MLM_SETSEL,\
|
---|
175 | MPFROMLONG((LONG)WinSendMsg((h),MLM_QUERYSEL,\
|
---|
176 | MPFROM2SHORT(MLFQS_ANCHORSEL,0),MPVOID)),\
|
---|
177 | MPFROMLONG((LONG)WinSendMsg((h),MLM_QUERYSEL,\
|
---|
178 | MPFROM2SHORT(MLFQS_CURSORSEL,0),MPVOID)))
|
---|
179 |
|
---|
180 | /* declarations of functions in mle.c */
|
---|
181 | LONG MLEgetlinetext (HWND h,LONG l,CHAR *buf,INT maxlen);
|
---|
182 | LONG MLEdeleteline (HWND h,LONG l);
|
---|
183 | LONG MLEdeletecurline (HWND h);
|
---|
184 | LONG MLEdeletetoeol (HWND h);
|
---|
185 | VOID MLEclearall (HWND h);
|
---|
186 | LONG MLEtextatcursor (HWND h,CHAR *buffer,INT buflen);
|
---|
187 | LONG MLEtextatpos (HWND h,IPT i,CHAR *buffer,INT buflen);
|
---|
188 | LONG MLEsizeofsel (HWND h);
|
---|
189 | BOOL MLEdoblock (HWND h,INT action,CHAR *filename);
|
---|
190 | BOOL MLEquotepara (HWND h,CHAR *initials,BOOL fQuoteOld);
|
---|
191 | BOOL MLEinsertfile (HWND h,CHAR *filename);
|
---|
192 | BOOL MLEHexLoad (HWND h,CHAR *filename);
|
---|
193 | BOOL MLEloadfile (HWND h,CHAR *filename);
|
---|
194 | INT MLEbackgroundload(HWND hwndReport,ULONG msg,HWND h,CHAR *filename,
|
---|
195 | INT hex);
|
---|
196 | BOOL MLEexportfile (HWND h,CHAR *filename,INT tabspaces,BOOL striptraillines,
|
---|
197 | BOOL striptrailspaces);
|
---|
198 | typedef struct {
|
---|
199 | USHORT size;
|
---|
200 | BOOL fInsensitive;
|
---|
201 | BOOL sandr;
|
---|
202 | BOOL rall;
|
---|
203 | HWND hwndmle;
|
---|
204 | MLE_SEARCHDATA se;
|
---|
205 | CHAR search[258];
|
---|
206 | CHAR replace[258];
|
---|
207 | } SRCHPTR;
|
---|
208 | MRESULT EXPENTRY SandRDlgProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2);
|
---|
209 | BOOL MLEfindfirst (HWND hwnd,SRCHPTR *vw);
|
---|
210 | INT MLEfindnext (HWND hwnd,SRCHPTR *vw);
|
---|
211 | VOID MLEinternet (HWND h,BOOL ftp);
|
---|
212 |
|
---|
213 | /* declarations of functions in mlefont.c */
|
---|
214 | FATTRS * SetMLEFont (HWND hwndMLE, FATTRS *fattrs, ULONG flags);
|
---|
215 |
|
---|
216 | /* struct used by MLE editor/viewer, saved in window pointer */
|
---|
217 |
|
---|
218 | typedef struct {
|
---|
219 | USHORT size;
|
---|
220 | USHORT hex;
|
---|
221 | HAB hab;
|
---|
222 | BOOL fWrap;
|
---|
223 | SRCHPTR srch;
|
---|
224 | HWND hwndMenu;
|
---|
225 | HWND hwndPopupMenu;
|
---|
226 | HACCEL accel;
|
---|
227 | BOOL ch;
|
---|
228 | BOOL fStripTrail;
|
---|
229 | BOOL fStripTrailLines;
|
---|
230 | INT ExpandTabs;
|
---|
231 | INT TabStops;
|
---|
232 | CHAR exportfilename[1027];
|
---|
233 | CHAR importfilename[1027];
|
---|
234 | FATTRS fattrs;
|
---|
235 | ULONG cp;
|
---|
236 | INT busy;
|
---|
237 | ULONG lastpos;
|
---|
238 | BOOL killme;
|
---|
239 | BOOL dontclose;
|
---|
240 | HWND hwndRestore,hwndFrame,hwndParent;
|
---|
241 | } XMLEWNDPTR;
|
---|
242 |
|
---|
243 | /* declarations of functions in mlemain.c */
|
---|
244 | HWND StartMLEEditor (HWND hwnd,INT flags,CHAR *filename,HWND hwndRestore);
|
---|
245 | MRESULT EXPENTRY MLEEditorProc (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2);
|
---|
246 |
|
---|
247 | /* MLEdoblock() actions */
|
---|
248 |
|
---|
249 | #define UPPERCASE 1
|
---|
250 | #define LOWERCASE 2
|
---|
251 | #define TOGGLECASE 3
|
---|
252 | #define ROT13 4
|
---|
253 | #define FORMAT 5
|
---|
254 | #define XOR 6
|
---|
255 | #define WRITE 7
|
---|
256 | #define APPENDCLIP 8
|
---|
257 |
|
---|
258 | #define ParentOf(hwnd) WinQueryWindow((hwnd),QW_PARENT)
|
---|
259 | #define GrandparentOf(hwnd) WinQueryWindow(WinQueryWindow(hwnd,QW_PARENT),QW_PARENT)
|
---|
260 |
|
---|