1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: newview.c 1497 2010-01-08 04:39:40Z gyoung $
|
---|
5 |
|
---|
6 | New internal viewer
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2001, 2009 Steven H. Levine
|
---|
10 |
|
---|
11 | 01 Dec 03 SHL Comments
|
---|
12 | 02 Dec 03 SHL Correct WM_VSCROLL math
|
---|
13 | 23 May 05 SHL Use QWL_USER
|
---|
14 | 06 Jun 05 SHL Indent -i2
|
---|
15 | 06 Jun 05 SHL Correct reversed wrap logic
|
---|
16 | 17 Jul 06 SHL Use Runtime_Error
|
---|
17 | 26 Jul 06 SHL Use chop_at_crnl and convert_nl_to_nul
|
---|
18 | 03 Nov 06 SHL Renames
|
---|
19 | 03 Nov 06 SHL Count thread usage
|
---|
20 | 22 Mar 07 GKY Use QWL_USER
|
---|
21 | 30 Mar 07 GKY Remove GetPString for window class names
|
---|
22 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
---|
23 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
24 | 26 Aug 07 GKY Fixed fast viewer text load failure
|
---|
25 | 28 Aug 07 GKY Reversed horizontal scrollbar behavior to be present for unwrapped text and absent for wrapped text & hex.
|
---|
26 | 14 Sep 07 SHL Another attempt to correct the fast viewer text load failure
|
---|
27 | 10 Oct 07 SHL Correct ReLineThread typo
|
---|
28 | 17 Dec 07 GKY Make WPURLDEFAULTSETTINGS the fall back for ftp/httprun
|
---|
29 | 28 Dec 07 GKY Add mailrun to allow mailto by clicking on an email address in the viewer
|
---|
30 | 29 Dec 07 GKY Formated email address using "<mailto:"
|
---|
31 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
32 | 29 Feb 08 GKY Refactor global command line variables to notebook.h
|
---|
33 | 20 Jul 08 GKY Change ListToClipboardHab call to match changes made to function
|
---|
34 | 10 Dec 08 SHL Integrate exception handler support
|
---|
35 | 11 Jan 09 GKY Replace font names in the string file with global set at compile in init.c
|
---|
36 | 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
|
---|
37 | 07 Feb 09 GKY Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error
|
---|
38 | 08 Mar 09 GKY Renamed commafmt.h i18nutil.h
|
---|
39 | 08 Mar 09 GKY Additional strings move to PCSZs in init.c
|
---|
40 | 13 Jul 09 SHL Sync with renames
|
---|
41 |
|
---|
42 | ***********************************************************************/
|
---|
43 |
|
---|
44 | #include <stdlib.h>
|
---|
45 | #include <string.h>
|
---|
46 | // #include <process.h> // 10 Dec 08 SHL
|
---|
47 | #include <limits.h>
|
---|
48 | #include <share.h>
|
---|
49 |
|
---|
50 | #define INCL_DOS
|
---|
51 | #define INCL_WIN
|
---|
52 | #define INCL_GPI
|
---|
53 | #define INCL_LONGLONG
|
---|
54 |
|
---|
55 | #include "fm3dll.h"
|
---|
56 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
57 | #include "mainwnd2.h" // Data declaration(s)
|
---|
58 | #include "collect.h" // Data declaration(s)
|
---|
59 | #include "grep.h" // Data declaration(s)
|
---|
60 | #include "dircnrs.h" // Data declaration(s)
|
---|
61 | #include "init.h" // Data declaration(s)
|
---|
62 | #include "fm3dlg.h"
|
---|
63 | #include "fm3str.h"
|
---|
64 | #include "mle.h"
|
---|
65 | #include "makelist.h" // AddToList
|
---|
66 | #include "errutil.h" // Dos_Error...
|
---|
67 | #include "strutil.h" // GetPString
|
---|
68 | #include "notebook.h" // httprun etc
|
---|
69 | #include "colors.h" // ColorDlgProc
|
---|
70 | #include "defview.h" // DefaultView
|
---|
71 | #include "draglist.h" // DragOne
|
---|
72 | #include "mainwnd.h" // FillClient, MakeBubble
|
---|
73 | #include "valid.h" // IsBinary
|
---|
74 | #include "saveclip.h" // ListToClipboardHab
|
---|
75 | #include "codepage.h" // PickCodepage
|
---|
76 | #include "fonts.h" // SetPresParamFromFattrs
|
---|
77 | #include "newview.h"
|
---|
78 | #include "strips.h" // chop_at_crnl, convert_nl_to_nul
|
---|
79 | // remove_first_occurence_of_character
|
---|
80 | // strip_lead_char, strip_trail_char
|
---|
81 | #include "common.h" // CommonTextButton, CommonTextProc, DecrThreadUsage
|
---|
82 | // IncrThreadUsage
|
---|
83 | #include "systemf.h" // ExecOnList
|
---|
84 | #include "input.h" // InputDlgProc
|
---|
85 | #include "shadow.h" // OpenObject
|
---|
86 | #include "chklist.h" // PopupMenu
|
---|
87 | #include "viewer.h" // StartMLEEditor
|
---|
88 | #include "i18nutil.h" // commafmt
|
---|
89 | #include "getnames.h" // export_filename
|
---|
90 | #include "literal.h" // literal
|
---|
91 | #include "wrappers.h" // xrealloc
|
---|
92 | #include "stristr.h" // findstring
|
---|
93 | #include "misc.h" // PaintRecessedWindow
|
---|
94 | #include "fortify.h"
|
---|
95 | #include "excputil.h" // xbeginthread
|
---|
96 |
|
---|
97 | // Data definitions
|
---|
98 | #pragma data_seg(GLOBAL1)
|
---|
99 | HEV CompactSem;
|
---|
100 | BOOL fFtpRunWPSDefault;
|
---|
101 | BOOL fHttpRunWPSDefault;
|
---|
102 |
|
---|
103 | #pragma data_seg(GLOBAL2)
|
---|
104 | CHAR *httprun;
|
---|
105 | CHAR *mailrun;
|
---|
106 |
|
---|
107 | #pragma data_seg(GLOBAL3)
|
---|
108 | LONG standardcolors[16];
|
---|
109 |
|
---|
110 | #pragma data_seg(DATA2)
|
---|
111 | static PSZ pszSrcFile = __FILE__;
|
---|
112 |
|
---|
113 | #define VF_SELECTED 0x01
|
---|
114 | #define VF_FOUND 0x02
|
---|
115 | #define VF_HTTP 0x04
|
---|
116 | #define VF_FTP 0x08
|
---|
117 |
|
---|
118 | #define NEWVIEWMLE_FONT_LCID 5
|
---|
119 |
|
---|
120 | #define COLORS_MAX 14
|
---|
121 |
|
---|
122 | #define COLORS_CURSOREDNORMALBACK 0
|
---|
123 | #define COLORS_CURSOREDSELECTEDBACK 1
|
---|
124 | #define COLORS_NORMALBACK 2
|
---|
125 | #define COLORS_SELECTEDBACK 3
|
---|
126 | #define COLORS_NORMALFORE 4
|
---|
127 | #define COLORS_FOUNDFORE 5
|
---|
128 | #define COLORS_SELECTEDFORE 6
|
---|
129 | #define COLORS_SELECTEDFOUNDFORE 7
|
---|
130 | #define COLORS_HTTPBACK 8
|
---|
131 | #define COLORS_HTTPFORE 9
|
---|
132 | #define COLORS_FTPBACK 10
|
---|
133 | #define COLORS_FTPFORE 11
|
---|
134 | #define COLORS_MAILBACK 12
|
---|
135 | #define COLORS_MAILFORE 13
|
---|
136 |
|
---|
137 | static LONG Colors[COLORS_MAX] = {
|
---|
138 | COLR_WHITE, COLR_DARKGRAY,
|
---|
139 | COLR_PALEGRAY, COLR_BLACK,
|
---|
140 | COLR_BLACK, COLR_RED,
|
---|
141 | COLR_WHITE, COLR_YELLOW,
|
---|
142 | COLR_PALEGRAY, COLR_DARKBLUE,
|
---|
143 | COLR_PALEGRAY, COLR_DARKGREEN,
|
---|
144 | COLR_PALEGRAY, COLR_DARKRED
|
---|
145 | };
|
---|
146 |
|
---|
147 | #define SEARCHSTRINGLEN 1024
|
---|
148 |
|
---|
149 | typedef struct
|
---|
150 | {
|
---|
151 | FATTRS fattrs;
|
---|
152 | LONG colors[COLORS_MAX];
|
---|
153 | CHAR *text;
|
---|
154 | CHAR **lines, *markedlines;
|
---|
155 | CHAR searchtext[SEARCHSTRINGLEN], *lastpos, szFacename[FACESIZE];
|
---|
156 | ULONG textsize, numlines, topline, cursored, selected, numalloc, multiplier,
|
---|
157 | lastselected, found;
|
---|
158 | LONG oldwidth, lastdirection, lMaxAscender, lMaxDescender, lMaxHeight,
|
---|
159 | maxx, horzscroll;
|
---|
160 | HMTX ScanSem;
|
---|
161 | HWND hvscroll, hwndMenu, hwndStatus1, hwndStatus2, hwndStatus3, hwndRestore,
|
---|
162 | hwndPopup, hwndListbox, hwndFrame, hwndDrag, hwndParent, hhscroll;
|
---|
163 | HPS hps;
|
---|
164 | USHORT size;
|
---|
165 | USHORT flags;
|
---|
166 | USHORT cliptype;
|
---|
167 | CHAR filename[CCHMAXPATH];
|
---|
168 | CHAR stopflag, busy;
|
---|
169 | BOOL hex, mousecaptured, sensitive, dummy, literalsearch, clientfocused,
|
---|
170 | alsoselect, wrapon, relining, httpin, ftpin, mailin, ignorehttp, ignoreftp,
|
---|
171 | ignoremail, needrefreshing;
|
---|
172 | }
|
---|
173 | VIEWDATA;
|
---|
174 |
|
---|
175 | typedef struct
|
---|
176 | {
|
---|
177 | ULONG len;
|
---|
178 | CHAR *line;
|
---|
179 | USHORT size;
|
---|
180 | USHORT dummy;
|
---|
181 | CHAR url[SEARCHSTRINGLEN];
|
---|
182 | }
|
---|
183 | URLDATA;
|
---|
184 |
|
---|
185 | static BOOL Sensitive = FALSE;
|
---|
186 | static USHORT Codepage = 0;
|
---|
187 | static BOOL Firsttime = TRUE;
|
---|
188 | static BOOL LiteralSearch = FALSE;
|
---|
189 | static BOOL AlsoSelect = FALSE;
|
---|
190 | static BOOL WrapOn = FALSE;
|
---|
191 | static BOOL IgnoreFTP = FALSE;
|
---|
192 | static BOOL IgnoreHTTP = FALSE;
|
---|
193 | static BOOL IgnoreMail = FALSE;
|
---|
194 | static FATTRS Fattrs;
|
---|
195 |
|
---|
196 | // mailstr checks for a designated character in a string then cuts the string
|
---|
197 | //to the first word that contains the character then prepends <mailto: and appends >
|
---|
198 |
|
---|
199 | CHAR *mailstr(CHAR *pszSrc, CHAR *pszFindChar, LONG StrLens)
|
---|
200 | {
|
---|
201 | CHAR *pszCharCounter;
|
---|
202 | CHAR *pszTestStr = pszSrc;
|
---|
203 | CHAR szMailTo[1024] = "mailto:";
|
---|
204 | //CHAR szMailEnd[] = ">";
|
---|
205 |
|
---|
206 | if (!strnstr(pszTestStr, pszFindChar, StrLens))
|
---|
207 | return NULL;
|
---|
208 | bstripcr(pszSrc);
|
---|
209 | remove_first_occurence_of_character("\r", pszSrc);
|
---|
210 | remove_first_occurence_of_character("\n", pszSrc);
|
---|
211 | if (!strstr(pszSrc, " ")){
|
---|
212 | if (!stristr(pszSrc, "<mailto:") && !fNoMailtoMailRun) {
|
---|
213 | strip_lead_char("<", pszSrc);
|
---|
214 | strip_trail_char(">", pszSrc);
|
---|
215 | strcat(szMailTo, pszSrc);
|
---|
216 | // strcat(szMailTo, szMailEnd);
|
---|
217 | pszSrc = szMailTo;
|
---|
218 | return pszSrc;
|
---|
219 | }
|
---|
220 | else {
|
---|
221 | strip_lead_char("<", pszSrc);
|
---|
222 | strip_trail_char(">", pszSrc);
|
---|
223 | return pszSrc;
|
---|
224 | }
|
---|
225 | }
|
---|
226 | while (strchr(pszSrc, ' ') < strchr(pszSrc, *pszFindChar)){
|
---|
227 | pszCharCounter = pszSrc;
|
---|
228 | while (*pszCharCounter && *pszCharCounter != ' '){
|
---|
229 | *pszCharCounter = ' ';
|
---|
230 | pszCharCounter++;
|
---|
231 | }
|
---|
232 | lstrip(pszSrc);
|
---|
233 | }
|
---|
234 | pszCharCounter = pszSrc;
|
---|
235 | while (*pszCharCounter && *pszCharCounter != ' ' && *pszCharCounter != '\r' &&
|
---|
236 | *pszCharCounter != '\n' && *pszCharCounter != '\"')
|
---|
237 | pszCharCounter++;
|
---|
238 | *pszCharCounter = 0;
|
---|
239 | if (!stristr(pszSrc, "<mailto:") && !fNoMailtoMailRun) {
|
---|
240 | strip_lead_char("<", pszSrc);
|
---|
241 | strip_trail_char(">", pszSrc);
|
---|
242 | strcat(szMailTo, pszSrc);
|
---|
243 | //strcat(szMailTo, szMailEnd);
|
---|
244 | pszSrc = szMailTo;
|
---|
245 | return pszSrc;
|
---|
246 | }
|
---|
247 | else {
|
---|
248 | strip_lead_char("<", pszSrc);
|
---|
249 | strip_trail_char(">", pszSrc);
|
---|
250 | return pszSrc;
|
---|
251 | }
|
---|
252 | }
|
---|
253 |
|
---|
254 | MRESULT EXPENTRY UrlDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
255 | {
|
---|
256 | URLDATA *urld;
|
---|
257 |
|
---|
258 | switch (msg) {
|
---|
259 | case WM_INITDLG:
|
---|
260 | if (mp2) {
|
---|
261 | CHAR *p, *e, *pp;
|
---|
262 | SHORT count;
|
---|
263 |
|
---|
264 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
265 | urld = mp2;
|
---|
266 | e = urld->line + urld->len + 1;
|
---|
267 | p = urld->line;
|
---|
268 | do {
|
---|
269 | p = strnstr(p, "http://", e - p);
|
---|
270 | if (p) {
|
---|
271 | strncpy(urld->url, p, min(e - p, SEARCHSTRINGLEN - 1));
|
---|
272 | urld->url[min(e - p, SEARCHSTRINGLEN - 1)] = 0;
|
---|
273 | pp = urld->url;
|
---|
274 | while (*pp && *pp != ' ' && *pp != '\r' && *pp != '\n' &&
|
---|
275 | *pp != '\"')
|
---|
276 | pp++;
|
---|
277 | *pp = 0;
|
---|
278 | WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_INSERTITEM,
|
---|
279 | MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url));
|
---|
280 | p++;
|
---|
281 | }
|
---|
282 | }
|
---|
283 | while (p && *p && p < e);
|
---|
284 | p = urld->line;
|
---|
285 | do {
|
---|
286 | p = strnstr(p, "ftp://", e - p);
|
---|
287 | if (p) {
|
---|
288 | strncpy(urld->url, p, min(e - p, SEARCHSTRINGLEN - 1));
|
---|
289 | urld->url[min(e - p, SEARCHSTRINGLEN - 1)] = 0;
|
---|
290 | pp = urld->url;
|
---|
291 | while (*pp && *pp != ' ' && *pp != '\r' && *pp != '\n' &&
|
---|
292 | *pp != '\"')
|
---|
293 | pp++;
|
---|
294 | *pp = 0;
|
---|
295 | WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_INSERTITEM,
|
---|
296 | MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url));
|
---|
297 | p++;
|
---|
298 | }
|
---|
299 | }
|
---|
300 | while (p && *p && p < e);
|
---|
301 | p = urld->line;
|
---|
302 | if (mailstr(p, "@", e - p)) {
|
---|
303 | pp = mailstr(p, "@", e - p);
|
---|
304 | strcpy(urld->url, pp);
|
---|
305 | WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_INSERTITEM,
|
---|
306 | MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url));
|
---|
307 | }
|
---|
308 | *urld->url = 0;
|
---|
309 | count = (SHORT) WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_QUERYITEMCOUNT,
|
---|
310 | MPVOID, MPVOID);
|
---|
311 | if (count) {
|
---|
312 | WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_SELECTITEM,
|
---|
313 | MPFROMSHORT(0), MPFROMSHORT(TRUE));
|
---|
314 | if (count == 1)
|
---|
315 | WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
---|
316 | else
|
---|
317 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
318 | break;
|
---|
319 | }
|
---|
320 | }
|
---|
321 | WinDismissDlg(hwnd, 0);
|
---|
322 | break;
|
---|
323 |
|
---|
324 | case UM_SETUP:
|
---|
325 | WinShowWindow(hwnd, TRUE);
|
---|
326 | return 0;
|
---|
327 |
|
---|
328 | case WM_CONTROL:
|
---|
329 | switch (SHORT1FROMMP(mp1)) {
|
---|
330 | case URL_LISTBOX:
|
---|
331 | switch (SHORT2FROMMP(mp1)) {
|
---|
332 | case LN_ENTER:
|
---|
333 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
---|
334 | break;
|
---|
335 | }
|
---|
336 | break;
|
---|
337 | }
|
---|
338 | return 0;
|
---|
339 |
|
---|
340 | case WM_COMMAND:
|
---|
341 | switch (SHORT1FROMMP(mp1)) {
|
---|
342 | case URL_BOOKMARK:
|
---|
343 | WinDismissDlg(hwnd, 3);
|
---|
344 | break;
|
---|
345 |
|
---|
346 | case DID_OK:
|
---|
347 | {
|
---|
348 | SHORT select;
|
---|
349 |
|
---|
350 | urld = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
351 | if (urld) {
|
---|
352 | select = (SHORT) WinSendDlgItemMsg(hwnd, URL_LISTBOX,
|
---|
353 | LM_QUERYSELECTION,
|
---|
354 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
355 | if (select >= 0) {
|
---|
356 | *urld->url = 0;
|
---|
357 | WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_QUERYITEMTEXT,
|
---|
358 | MPFROM2SHORT(select, sizeof(urld->url)),
|
---|
359 | MPFROMP(urld->url));
|
---|
360 | if (*urld->url) {
|
---|
361 | if (!strncmp(urld->url, "http://", 7)) {
|
---|
362 | WinDismissDlg(hwnd, 1);
|
---|
363 | break;
|
---|
364 | }
|
---|
365 | else if (!strncmp(urld->url, "ftp://", 6)) {
|
---|
366 | memmove(urld->url, urld->url + 6, strlen(urld->url) + 1);
|
---|
367 | if (*urld->url) {
|
---|
368 | WinDismissDlg(hwnd, 2);
|
---|
369 | break;
|
---|
370 | }
|
---|
371 | }
|
---|
372 | else if (strchr(urld->url, '@')) {
|
---|
373 | WinDismissDlg(hwnd, 3);
|
---|
374 | break;
|
---|
375 | }
|
---|
376 | }
|
---|
377 | }
|
---|
378 | }
|
---|
379 | }
|
---|
380 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
381 | break;
|
---|
382 |
|
---|
383 | case DID_CANCEL:
|
---|
384 | WinDismissDlg(hwnd, 0);
|
---|
385 | break;
|
---|
386 |
|
---|
387 | case IDM_HELP:
|
---|
388 | break;
|
---|
389 | }
|
---|
390 | return 0;
|
---|
391 | }
|
---|
392 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
393 | }
|
---|
394 |
|
---|
395 | static ULONG NumLines(RECTL * rcl, VIEWDATA * ad)
|
---|
396 | {
|
---|
397 | ULONG numlines;
|
---|
398 |
|
---|
399 | numlines = (rcl->yTop - rcl->yBottom) / ad->lMaxHeight;
|
---|
400 | if (ad->lMaxDescender && numlines &&
|
---|
401 | ((rcl->yTop - rcl->yBottom) -
|
---|
402 | (numlines * ad->lMaxHeight) <= ad->lMaxDescender))
|
---|
403 | numlines--;
|
---|
404 | return numlines;
|
---|
405 | }
|
---|
406 |
|
---|
407 | static CHAR **BuildAList(HWND hwnd)
|
---|
408 | {
|
---|
409 | VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
410 | register ULONG x, y, z = 0;
|
---|
411 | ULONG width;
|
---|
412 | RECTL Rectl;
|
---|
413 | CHAR **list = NULL, s[SEARCHSTRINGLEN], a;
|
---|
414 | register CHAR *p, *e;
|
---|
415 | UINT numlines = 0, numalloc = 0;
|
---|
416 |
|
---|
417 | if (ad && ad->selected) {
|
---|
418 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
419 | width = (Rectl.xRight - Rectl.xLeft) / ad->fattrs.lAveCharWidth;
|
---|
420 | if (!width && !ad->hex)
|
---|
421 | return list;
|
---|
422 | for (x = 0; x < ad->numlines; x++) {
|
---|
423 | if (ad->stopflag)
|
---|
424 | break;
|
---|
425 | if (ad->markedlines[x] & VF_SELECTED) {
|
---|
426 | if (ad->hex) {
|
---|
427 | width = ad->textsize - (x * 16);
|
---|
428 | width = min(width, 16);
|
---|
429 | sprintf(s, "%08lx ", x * 16);
|
---|
430 | p = s + 9;
|
---|
431 | for (y = 0; y < width; y++) {
|
---|
432 | sprintf(p, " %02x", (UCHAR)ad->text[(x * 16) + y]);
|
---|
433 | p += 3;
|
---|
434 | }
|
---|
435 | *p = ' ';
|
---|
436 | p++;
|
---|
437 | *p = ' ';
|
---|
438 | p++;
|
---|
439 | for (y = 0; y < width; y++) {
|
---|
440 | a = ad->text[(x * 16) + y];
|
---|
441 | if (a && a != '\n' && a != '\r' && a != '\t' && a != '\x1a')
|
---|
442 | *p = ad->text[(x * 16) + y];
|
---|
443 | else
|
---|
444 | *p = '.';
|
---|
445 | p++;
|
---|
446 | }
|
---|
447 | *p = 0;
|
---|
448 | }
|
---|
449 | else {
|
---|
450 | if (!ad->wrapon) {
|
---|
451 | e = p = ad->lines[x];
|
---|
452 | while (*e != '\r' && *e != '\n' && e < ad->text + ad->textsize)
|
---|
453 | e++;
|
---|
454 | /* fixme to be gone?
|
---|
455 | if((*e == '\r' || *e == '\n') && e > p)
|
---|
456 | e--;
|
---|
457 | */
|
---|
458 | width = e - p;
|
---|
459 | }
|
---|
460 | else {
|
---|
461 | p = ad->lines[x];
|
---|
462 | e = p + (width - 1);
|
---|
463 | if (e - ad->text > ad->textsize)
|
---|
464 | e = ad->text + ad->textsize;
|
---|
465 | while (p < e) {
|
---|
466 | if (*p == '\r' || *p == '\n') {
|
---|
467 | e = p;
|
---|
468 | break;
|
---|
469 | }
|
---|
470 | p++;
|
---|
471 | }
|
---|
472 | }
|
---|
473 | strncpy(s, ad->lines[x], e - ad->lines[x]);
|
---|
474 | s[e - ad->lines[x]] = 0;
|
---|
475 | }
|
---|
476 | if (AddToList(s, &list, &numlines, &numalloc))
|
---|
477 | break;
|
---|
478 | z++;
|
---|
479 | if (z >= ad->selected)
|
---|
480 | break;
|
---|
481 | }
|
---|
482 | }
|
---|
483 | }
|
---|
484 | return list;
|
---|
485 | }
|
---|
486 |
|
---|
487 | static CHAR **BuildAList2(HWND hwnd)
|
---|
488 | {
|
---|
489 | VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
490 | CHAR **list = NULL, s[SEARCHSTRINGLEN];
|
---|
491 | SHORT x, z;
|
---|
492 | UINT numlines = 0, numalloc = 0;
|
---|
493 |
|
---|
494 | if (ad) {
|
---|
495 | z = (SHORT) WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
|
---|
496 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
497 | z = max(z, 0);
|
---|
498 | for (x = 0; x < z; x++) {
|
---|
499 | if (ad->stopflag)
|
---|
500 | break;
|
---|
501 | *s = 0;
|
---|
502 | WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX, LM_QUERYITEMTEXT,
|
---|
503 | MPFROM2SHORT(x, SEARCHSTRINGLEN), MPFROMP(s));
|
---|
504 | if (*s)
|
---|
505 | if (AddToList(s, &list, &numlines, &numalloc))
|
---|
506 | break;
|
---|
507 | }
|
---|
508 | }
|
---|
509 | return list;
|
---|
510 | }
|
---|
511 |
|
---|
512 | MRESULT EXPENTRY ViewStatusProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
513 | {
|
---|
514 | switch (msg) {
|
---|
515 | case WM_CREATE:
|
---|
516 | return CommonTextProc(hwnd, msg, mp1, mp2);
|
---|
517 |
|
---|
518 | case WM_MOUSEMOVE:
|
---|
519 | {
|
---|
520 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
521 |
|
---|
522 | if (fOtherHelp) {
|
---|
523 | if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
|
---|
524 | && !WinQueryCapture(HWND_DESKTOP)) {
|
---|
525 |
|
---|
526 | PCSZ s = NULL;
|
---|
527 |
|
---|
528 | switch (id) {
|
---|
529 | case NEWVIEW_STATUS2:
|
---|
530 | s = GetPString(IDS_NVSTATUS2HELPTEXT);
|
---|
531 | break;
|
---|
532 | case NEWVIEW_STATUS3:
|
---|
533 | s = GetPString(IDS_NVSTATUS3HELPTEXT);
|
---|
534 | break;
|
---|
535 | case NEWVIEW_DRAG:
|
---|
536 | s = GetPString(IDS_NVDRAGHELPTEXT);
|
---|
537 | break;
|
---|
538 | }
|
---|
539 | if (s && *s)
|
---|
540 | MakeBubble(hwnd, TRUE, s);
|
---|
541 | else if (hwndBubble)
|
---|
542 | WinDestroyWindow(hwndBubble);
|
---|
543 | }
|
---|
544 | }
|
---|
545 | switch (id) {
|
---|
546 | case NEWVIEW_STATUS1:
|
---|
547 | break;
|
---|
548 | default:
|
---|
549 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
---|
550 | }
|
---|
551 | }
|
---|
552 | break;
|
---|
553 |
|
---|
554 | case WM_BUTTON3UP:
|
---|
555 | case WM_BUTTON1UP:
|
---|
556 | case WM_BUTTON1DOWN:
|
---|
557 | case WM_BUTTON3DOWN:
|
---|
558 | {
|
---|
559 | USHORT id;
|
---|
560 |
|
---|
561 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
562 | switch (id) {
|
---|
563 | case NEWVIEW_STATUS1:
|
---|
564 | break;
|
---|
565 | default:
|
---|
566 | return CommonTextButton(hwnd, msg, mp1, mp2);
|
---|
567 | }
|
---|
568 | }
|
---|
569 | break;
|
---|
570 |
|
---|
571 | case UM_CLICKED:
|
---|
572 | case UM_CLICKED3:
|
---|
573 | {
|
---|
574 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID), cmd = 0;
|
---|
575 |
|
---|
576 | switch (id) {
|
---|
577 | case NEWVIEW_DRAG:
|
---|
578 | if (msg == UM_CLICKED)
|
---|
579 | cmd = (msg == UM_CLICKED) ? IDM_HEXMODE : IDM_DESELECTALL;
|
---|
580 | break;
|
---|
581 | case NEWVIEW_STATUS2:
|
---|
582 | cmd = (msg == UM_CLICKED) ? IDM_GOTOLINE : IDM_FINDFIRST;
|
---|
583 | break;
|
---|
584 | case NEWVIEW_STATUS3:
|
---|
585 | cmd = (msg == UM_CLICKED) ? IDM_GOTOOFFSET : IDM_FINDNEXT;
|
---|
586 | break;
|
---|
587 | default:
|
---|
588 | break;
|
---|
589 | }
|
---|
590 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
591 | FID_CLIENT),
|
---|
592 | WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
|
---|
593 | }
|
---|
594 | return 0;
|
---|
595 |
|
---|
596 | case WM_BEGINDRAG:
|
---|
597 | {
|
---|
598 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
599 |
|
---|
600 | switch (id) {
|
---|
601 | case NEWVIEW_STATUS1:
|
---|
602 | case NEWVIEW_DRAG:
|
---|
603 | {
|
---|
604 | VIEWDATA *ad =
|
---|
605 | WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
|
---|
606 | QW_PARENT),
|
---|
607 | FID_CLIENT), QWL_USER);
|
---|
608 |
|
---|
609 | if (ad)
|
---|
610 | DragOne(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
611 | FID_CLIENT), (HWND) 0, ad->filename,
|
---|
612 | FALSE);
|
---|
613 | }
|
---|
614 | break;
|
---|
615 | default:
|
---|
616 | break;
|
---|
617 | }
|
---|
618 | }
|
---|
619 | break;
|
---|
620 |
|
---|
621 | case WM_CONTEXTMENU:
|
---|
622 | PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
623 | FID_CLIENT), UM_CONTEXTMENU, MPVOID, MPVOID);
|
---|
624 | break;
|
---|
625 |
|
---|
626 | case WM_SETFOCUS:
|
---|
627 | if (mp2)
|
---|
628 | PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
|
---|
629 | break;
|
---|
630 |
|
---|
631 | case WM_PAINT:
|
---|
632 | {
|
---|
633 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
634 | ULONG color;
|
---|
635 | VIEWDATA *ad = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
|
---|
636 | QW_PARENT),
|
---|
637 | FID_CLIENT), QWL_USER);
|
---|
638 | SWP swp;
|
---|
639 | POINTL ptl;
|
---|
640 | HPS hps;
|
---|
641 |
|
---|
642 | switch (id) {
|
---|
643 | case NEWVIEW_STATUS1:
|
---|
644 | PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
|
---|
645 | break;
|
---|
646 | default:
|
---|
647 | PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
|
---|
648 | break;
|
---|
649 | }
|
---|
650 | hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
|
---|
651 | if (hps) {
|
---|
652 | WinQueryWindowPos(hwnd, &swp);
|
---|
653 | ptl.x = swp.x - 1;
|
---|
654 | ptl.y = swp.y + swp.cy + 2;
|
---|
655 | GpiMove(hps, &ptl);
|
---|
656 | switch (id) {
|
---|
657 | case NEWVIEW_STATUS1:
|
---|
658 | if (ad)
|
---|
659 | color =
|
---|
660 | (standardcolors[ad->colors[COLORS_NORMALBACK]] ==
|
---|
661 | CLR_WHITE) ? CLR_PALEGRAY : CLR_WHITE;
|
---|
662 | else
|
---|
663 | color = CLR_WHITE;
|
---|
664 | break;
|
---|
665 | default:
|
---|
666 | if (ad)
|
---|
667 | color =
|
---|
668 | (standardcolors[ad->colors[COLORS_NORMALBACK]] ==
|
---|
669 | CLR_PALEGRAY) ? CLR_DARKGRAY : CLR_PALEGRAY;
|
---|
670 | else
|
---|
671 | color = CLR_PALEGRAY;
|
---|
672 | break;
|
---|
673 | }
|
---|
674 | GpiSetColor(hps, color);
|
---|
675 | ptl.x = swp.x + swp.cx;
|
---|
676 | GpiLine(hps, &ptl);
|
---|
677 | WinReleasePS(hps);
|
---|
678 | }
|
---|
679 | }
|
---|
680 | break;
|
---|
681 |
|
---|
682 | case UM_FOCUSME:
|
---|
683 | WinSetFocus(HWND_DESKTOP,
|
---|
684 | WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT));
|
---|
685 | return 0;
|
---|
686 | }
|
---|
687 | return PFNWPStatic(hwnd, msg, mp1, mp2);
|
---|
688 | }
|
---|
689 |
|
---|
690 | static VOID FreeViewerMem(HWND hwnd)
|
---|
691 | {
|
---|
692 | VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
693 |
|
---|
694 | if (ad) {
|
---|
695 | ad->selected = ad->textsize = ad->numlines = ad->numalloc = 0;
|
---|
696 | xfree(ad->text, pszSrcFile, __LINE__);
|
---|
697 | xfree(ad->lines, pszSrcFile, __LINE__);
|
---|
698 | xfree(ad->markedlines, pszSrcFile, __LINE__);
|
---|
699 | ad->text = NULL;
|
---|
700 | ad->lines = NULL;
|
---|
701 | ad->markedlines = NULL;
|
---|
702 | DosPostEventSem(CompactSem);
|
---|
703 | }
|
---|
704 | }
|
---|
705 |
|
---|
706 | static HPS InitWindow(HWND hwnd)
|
---|
707 | {
|
---|
708 | VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
709 | HPS hps = (HPS) 0;
|
---|
710 | SIZEL sizel;
|
---|
711 | FONTMETRICS FontMetrics;
|
---|
712 |
|
---|
713 | if (ad) {
|
---|
714 | sizel.cx = sizel.cy = 0;
|
---|
715 | hps = GpiCreatePS(WinQueryAnchorBlock(hwnd), WinOpenWindowDC(hwnd),
|
---|
716 | (PSIZEL) & sizel, PU_PELS | GPIF_DEFAULT | GPIT_MICRO |
|
---|
717 | GPIA_ASSOC);
|
---|
718 | if (hps) {
|
---|
719 | GpiSetCp(hps, (ULONG) ad->fattrs.usCodePage);
|
---|
720 | GpiCreateLogFont(hps, NULL, NEWVIEWMLE_FONT_LCID, &ad->fattrs);
|
---|
721 | GpiSetCharSet(hps, NEWVIEWMLE_FONT_LCID);
|
---|
722 | GpiQueryFontMetrics(hps, (long)sizeof(FONTMETRICS), &FontMetrics);
|
---|
723 | ad->fattrs.lAveCharWidth = FontMetrics.lAveCharWidth;
|
---|
724 | ad->fattrs.lMaxBaselineExt = FontMetrics.lMaxBaselineExt;
|
---|
725 | ad->lMaxAscender = max(FontMetrics.lMaxAscender, 0);
|
---|
726 | ad->lMaxDescender = max(FontMetrics.lMaxDescender, 0);
|
---|
727 | ad->lMaxHeight = ad->lMaxAscender + ad->lMaxDescender;
|
---|
728 | if (ad->fattrs.usCodePage != FontMetrics.usCodePage) {
|
---|
729 | ad->fattrs.usCodePage = FontMetrics.usCodePage;
|
---|
730 | Codepage = ad->fattrs.usCodePage;
|
---|
731 | PrfWriteProfileData(fmprof,
|
---|
732 | appname,
|
---|
733 | "Viewer.Codepage",
|
---|
734 | &ad->fattrs.usCodePage, sizeof(USHORT));
|
---|
735 | }
|
---|
736 | else if (ad->fattrs.usCodePage) {
|
---|
737 |
|
---|
738 | HMQ hmq;
|
---|
739 | ULONG cps[50], len, x;
|
---|
740 |
|
---|
741 | if (!DosQueryCp(sizeof(cps), cps, &len)) {
|
---|
742 | for (x = 0; x < len / sizeof(ULONG); x++) {
|
---|
743 | if (cps[x] == (ULONG) ad->fattrs.usCodePage) {
|
---|
744 | hmq = WinQueryWindowULong(hwnd, QWL_HMQ);
|
---|
745 | WinSetCp(hmq, ad->fattrs.usCodePage);
|
---|
746 | break;
|
---|
747 | }
|
---|
748 | }
|
---|
749 | }
|
---|
750 | DosSetProcessCp((ULONG) ad->fattrs.usCodePage);
|
---|
751 | }
|
---|
752 | GpiSetBackMix(hps, BM_OVERPAINT);
|
---|
753 | SetPresParamFromFattrs(WinWindowFromID(ad->hwndFrame, NEWVIEW_LISTBOX),
|
---|
754 | &ad->fattrs, FontMetrics.sNominalPointSize,
|
---|
755 | MAKEFIXED(FontMetrics.sNominalPointSize / 10,
|
---|
756 | 0));
|
---|
757 | }
|
---|
758 | }
|
---|
759 | return (hps);
|
---|
760 | }
|
---|
761 |
|
---|
762 | static VOID PaintLine(HWND hwnd, HPS hps, ULONG whichline, ULONG topline,
|
---|
763 | RECTL * Rectl)
|
---|
764 | {
|
---|
765 | VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
766 | POINTL ptl;
|
---|
767 | ULONG width;
|
---|
768 | register CHAR *p, *e;
|
---|
769 | CHAR marker[] = " >";
|
---|
770 | RECTL rcl2;
|
---|
771 |
|
---|
772 | if (ad && (ad->hex || ad->lines)) {
|
---|
773 | ptl.y = (Rectl->yTop - (ad->lMaxHeight *
|
---|
774 | (((whichline + 1) - topline) + 1)));
|
---|
775 | ptl.x = 0;
|
---|
776 | GpiMove(hps, &ptl);
|
---|
777 | GpiSetBackMix(hps, BM_OVERPAINT);
|
---|
778 | if (ad->markedlines) {
|
---|
779 | if (ad->markedlines[whichline] & VF_SELECTED) {
|
---|
780 | GpiSetColor(hps, ((ad->markedlines[whichline] & VF_FOUND) != 0) ?
|
---|
781 | standardcolors[ad->colors[COLORS_SELECTEDFOUNDFORE]] :
|
---|
782 | standardcolors[ad->colors[COLORS_SELECTEDFORE]]);
|
---|
783 | GpiSetBackColor(hps, (whichline == ad->cursored - 1) ?
|
---|
784 | standardcolors[ad->
|
---|
785 | colors[COLORS_CURSOREDSELECTEDBACK]] :
|
---|
786 | standardcolors[ad->colors[COLORS_SELECTEDBACK]]);
|
---|
787 | }
|
---|
788 | else if (ad->markedlines[whichline] & VF_FOUND) {
|
---|
789 | GpiSetColor(hps, standardcolors[ad->colors[COLORS_FOUNDFORE]]);
|
---|
790 | GpiSetBackColor(hps, (whichline == ad->cursored - 1) ?
|
---|
791 | standardcolors[ad->
|
---|
792 | colors[COLORS_CURSOREDNORMALBACK]] :
|
---|
793 | standardcolors[ad->colors[COLORS_NORMALBACK]]);
|
---|
794 | }
|
---|
795 | else {
|
---|
796 | GpiSetColor(hps, standardcolors[ad->colors[COLORS_NORMALFORE]]);
|
---|
797 | GpiSetBackColor(hps, (whichline == ad->cursored - 1) ?
|
---|
798 | standardcolors[ad->
|
---|
799 | colors[COLORS_CURSOREDNORMALBACK]] :
|
---|
800 | standardcolors[ad->colors[COLORS_NORMALBACK]]);
|
---|
801 | }
|
---|
802 | }
|
---|
803 | else {
|
---|
804 | GpiSetColor(hps, standardcolors[ad->colors[COLORS_NORMALFORE]]);
|
---|
805 | GpiSetBackColor(hps, (whichline == ad->cursored - 1) ?
|
---|
806 | standardcolors[ad->colors[COLORS_CURSOREDNORMALBACK]] :
|
---|
807 | standardcolors[ad->colors[COLORS_NORMALBACK]]);
|
---|
808 | }
|
---|
809 | if (!ad->hex) {
|
---|
810 | if (ad->wrapon) {
|
---|
811 | width = (Rectl->xRight - Rectl->xLeft) / ad->fattrs.lAveCharWidth;
|
---|
812 | if (width) {
|
---|
813 | GpiCharString(hps, 1, marker + (whichline == ad->cursored - 1));
|
---|
814 | p = ad->lines[whichline];
|
---|
815 | e = p + (width - 1);
|
---|
816 | if (e - ad->text > ad->textsize)
|
---|
817 | e = ad->text + ad->textsize;
|
---|
818 | while (p < e) {
|
---|
819 | if (*p == '\r' || *p == '\n') {
|
---|
820 | e = p;
|
---|
821 | break;
|
---|
822 | }
|
---|
823 | p++;
|
---|
824 | }
|
---|
825 | if (ad->ftpin && whichline != ad->cursored - 1
|
---|
826 | && (!ad->markedlines
|
---|
827 | || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
|
---|
828 | && strnstr(ad->lines[whichline], "ftp://",
|
---|
829 | e - ad->lines[whichline])) {
|
---|
830 | GpiSetColor(hps, standardcolors[ad->colors[COLORS_FTPFORE]]);
|
---|
831 | GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_FTPBACK]]);
|
---|
832 | }
|
---|
833 | if (ad->httpin && whichline != ad->cursored - 1
|
---|
834 | && (!ad->markedlines
|
---|
835 | || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
|
---|
836 | && strnstr(ad->lines[whichline], "http://",
|
---|
837 | e - ad->lines[whichline])) {
|
---|
838 | GpiSetColor(hps, standardcolors[ad->colors[COLORS_HTTPFORE]]);
|
---|
839 | GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_HTTPBACK]]);
|
---|
840 | }
|
---|
841 |
|
---|
842 | if (ad->mailin && whichline != ad->cursored - 1
|
---|
843 | && (!ad->markedlines
|
---|
844 | || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
|
---|
845 | && strnstr(ad->lines[whichline], "@",e - ad->lines[whichline])) {
|
---|
846 | GpiSetColor(hps, standardcolors[ad->colors[COLORS_MAILFORE]]);
|
---|
847 | GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_MAILBACK]]);
|
---|
848 | }
|
---|
849 | rcl2 = *Rectl;
|
---|
850 | rcl2.yTop = ptl.y + ad->lMaxAscender;
|
---|
851 | rcl2.yBottom = ptl.y - ad->lMaxDescender;
|
---|
852 | GpiCharString(hps, e - ad->lines[whichline], ad->lines[whichline]);
|
---|
853 | GpiQueryCurrentPosition(hps, &ptl);
|
---|
854 | rcl2.xLeft = ptl.x;
|
---|
855 | WinFillRect(hps, &rcl2,
|
---|
856 | standardcolors[ad->colors[COLORS_NORMALBACK]]);
|
---|
857 | }
|
---|
858 | }
|
---|
859 | else {
|
---|
860 | width = (Rectl->xRight - Rectl->xLeft) / ad->fattrs.lAveCharWidth;
|
---|
861 | if (width) {
|
---|
862 | GpiCharString(hps, 1, marker + (whichline == ad->cursored - 1));
|
---|
863 | p = ad->lines[whichline];
|
---|
864 | e = p + (abs(ad->horzscroll) / ad->fattrs.lAveCharWidth);
|
---|
865 | if (e - ad->text > ad->textsize)
|
---|
866 | e = ad->text + ad->textsize;
|
---|
867 | while (p < e) {
|
---|
868 | if (*p == '\r' || *p == '\n')
|
---|
869 | break;
|
---|
870 | p++;
|
---|
871 | }
|
---|
872 | if (*p != '\r' && *p != '\n') {
|
---|
873 |
|
---|
874 | CHAR *pp;
|
---|
875 |
|
---|
876 | e = p + (width - 1);
|
---|
877 | if (e - ad->text > ad->textsize)
|
---|
878 | e = ad->text + ad->textsize;
|
---|
879 | pp = p;
|
---|
880 | while (pp < e) {
|
---|
881 | if (*pp == '\r' || *pp == '\n') {
|
---|
882 | e = pp;
|
---|
883 | break;
|
---|
884 | }
|
---|
885 | pp++;
|
---|
886 | }
|
---|
887 | }
|
---|
888 | else
|
---|
889 | e = p;
|
---|
890 | if (ad->ftpin && whichline != ad->cursored - 1
|
---|
891 | && (!ad->markedlines
|
---|
892 | || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
|
---|
893 | && strnstr(ad->lines[whichline], "ftp://",
|
---|
894 | e - ad->lines[whichline])) {
|
---|
895 | GpiSetColor(hps, standardcolors[ad->colors[COLORS_FTPFORE]]);
|
---|
896 | GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_FTPBACK]]);
|
---|
897 | }
|
---|
898 | if (ad->httpin && whichline != ad->cursored - 1
|
---|
899 | && (!ad->markedlines
|
---|
900 | || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
|
---|
901 | && strnstr(ad->lines[whichline], "http://",e - ad->lines[whichline])) {
|
---|
902 | GpiSetColor(hps, standardcolors[ad->colors[COLORS_HTTPFORE]]);
|
---|
903 | GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_HTTPBACK]]);
|
---|
904 | }
|
---|
905 |
|
---|
906 | if (ad->mailin && whichline != ad->cursored - 1
|
---|
907 | && (!ad->markedlines
|
---|
908 | || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
|
---|
909 | && strnstr(ad->lines[whichline], "@",e - ad->lines[whichline])) {
|
---|
910 | GpiSetColor(hps, standardcolors[ad->colors[COLORS_MAILFORE]]);
|
---|
911 | GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_MAILBACK]]);
|
---|
912 | }
|
---|
913 | rcl2 = *Rectl;
|
---|
914 | rcl2.yTop = ptl.y + ad->lMaxAscender;
|
---|
915 | rcl2.yBottom = ptl.y - ad->lMaxDescender;
|
---|
916 | GpiCharString(hps, e - p, p);
|
---|
917 | GpiQueryCurrentPosition(hps, &ptl);
|
---|
918 | rcl2.xLeft = ptl.x;
|
---|
919 | WinFillRect(hps, &rcl2,
|
---|
920 | standardcolors[ad->colors[COLORS_NORMALBACK]]);
|
---|
921 | }
|
---|
922 | }
|
---|
923 | }
|
---|
924 | else {
|
---|
925 |
|
---|
926 | CHAR s[80];
|
---|
927 | register ULONG x;
|
---|
928 |
|
---|
929 | rcl2 = *Rectl;
|
---|
930 | rcl2.yTop = ptl.y + ad->lMaxAscender;
|
---|
931 | rcl2.yBottom = ptl.y - ad->lMaxDescender;
|
---|
932 | GpiCharString(hps, 1, marker + (whichline == ad->cursored - 1));
|
---|
933 | width = ad->textsize - (whichline * 16);
|
---|
934 | width = min(width, 16);
|
---|
935 | sprintf(s, "%08lx ", whichline * 16);
|
---|
936 | p = s + 9;
|
---|
937 | for (x = 0; x < width; x++) {
|
---|
938 | sprintf(p, " %02x", (UCHAR)ad->text[(whichline * 16) + x]);
|
---|
939 | p += 3;
|
---|
940 | }
|
---|
941 | for (; x < 16; x++) {
|
---|
942 | *p = ' ';
|
---|
943 | p++;
|
---|
944 | *p = ' ';
|
---|
945 | p++;
|
---|
946 | *p = ' ';
|
---|
947 | p++;
|
---|
948 | }
|
---|
949 | *p = ' ';
|
---|
950 | p++;
|
---|
951 | *p = ' ';
|
---|
952 | p++;
|
---|
953 | for (x = 0; x < width; x++) {
|
---|
954 | *p = ad->text[(whichline * 16) + x];
|
---|
955 | p++;
|
---|
956 | }
|
---|
957 | *p = 0;
|
---|
958 | GpiCharString(hps, (p - s) - (abs(ad->horzscroll) /
|
---|
959 | ad->fattrs.lAveCharWidth),
|
---|
960 | s + (abs(ad->horzscroll) / ad->fattrs.lAveCharWidth));
|
---|
961 | GpiQueryCurrentPosition(hps, &ptl);
|
---|
962 | if (ptl.x + abs(ad->horzscroll) + ad->fattrs.lAveCharWidth + 1 >
|
---|
963 | ad->maxx) {
|
---|
964 | ad->maxx = ptl.x + abs(ad->horzscroll) + ad->fattrs.lAveCharWidth + 1;
|
---|
965 | WinSendMsg(ad->hhscroll, SBM_SETTHUMBSIZE,
|
---|
966 | MPFROM2SHORT((SHORT) Rectl->xRight, (SHORT) ad->maxx),
|
---|
967 | MPVOID);
|
---|
968 | }
|
---|
969 | rcl2.xLeft = ptl.x;
|
---|
970 | WinFillRect(hps, &rcl2, standardcolors[ad->colors[COLORS_NORMALBACK]]);
|
---|
971 | }
|
---|
972 | }
|
---|
973 | }
|
---|
974 |
|
---|
975 | static VOID SearchThread(VOID * args)
|
---|
976 | {
|
---|
977 | HWND hwnd = (HWND) args;
|
---|
978 | HAB hab2;
|
---|
979 | HMQ hmq2;
|
---|
980 | VIEWDATA *ad;
|
---|
981 | register CHAR *p;
|
---|
982 | RECTL Rectl;
|
---|
983 | ULONG width, numlines, lastline, whichline, firstline = ULONG_MAX;
|
---|
984 | register ULONG x;
|
---|
985 | CHAR s[SEARCHSTRINGLEN], s2[SEARCHSTRINGLEN], *t, *n, markwith;
|
---|
986 |
|
---|
987 | priority_normal();
|
---|
988 | # ifdef FORTIFY
|
---|
989 | Fortify_EnterScope();
|
---|
990 | # endif
|
---|
991 | hab2 = WinInitialize(0);
|
---|
992 | if (hab2) {
|
---|
993 | hmq2 = WinCreateMsgQueue(hab2, 0);
|
---|
994 | if (hmq2) {
|
---|
995 | WinCancelShutdown(hmq2, TRUE);
|
---|
996 | IncrThreadUsage();
|
---|
997 | ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
998 | if (ad) {
|
---|
999 | if (!DosRequestMutexSem(ad->ScanSem, SEM_INDEFINITE_WAIT)) {
|
---|
1000 | markwith = VF_FOUND | ((ad->alsoselect) ? VF_SELECTED : 0);
|
---|
1001 | strcpy(s, ad->searchtext);
|
---|
1002 | if (*s) {
|
---|
1003 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
1004 | width = (Rectl.xRight - Rectl.xLeft) / ad->fattrs.lAveCharWidth;
|
---|
1005 | numlines = NumLines(&Rectl, ad);
|
---|
1006 | WinSetWindowText(WinWindowFromID(ad->hwndFrame,
|
---|
1007 | NEWVIEW_STATUS1),
|
---|
1008 | GetPString(IDS_SEARCHINGTEXT));
|
---|
1009 | if (numlines && width && ad->markedlines && ad->numlines &&
|
---|
1010 | ad->text && ad->textsize) {
|
---|
1011 | for (x = 0; x < ad->numlines && !ad->stopflag; x++)
|
---|
1012 | ad->markedlines[x] &= (~VF_FOUND);
|
---|
1013 | ad->found = 0;
|
---|
1014 | t = s;
|
---|
1015 | while (t && !ad->stopflag) {
|
---|
1016 | lastline = 1;
|
---|
1017 | n = convert_nl_to_nul(t);
|
---|
1018 | if (*t) {
|
---|
1019 | strcpy(s2, t);
|
---|
1020 | if (ad->literalsearch)
|
---|
1021 | literal(s2);
|
---|
1022 | p = ad->text;
|
---|
1023 | while (p && !ad->stopflag) {
|
---|
1024 | p = findstring(s2, strlen(s2), p,
|
---|
1025 | ad->textsize - (p - ad->text),
|
---|
1026 | ad->sensitive);
|
---|
1027 | if (p) {
|
---|
1028 | if (ad->hex) {
|
---|
1029 | whichline = (p - ad->text) / 16;
|
---|
1030 | if (whichline < firstline)
|
---|
1031 | firstline = whichline;
|
---|
1032 | if (!(ad->markedlines[whichline] & VF_FOUND))
|
---|
1033 | ad->found++;
|
---|
1034 | if (markwith & VF_SELECTED) {
|
---|
1035 | if (!(ad->markedlines[whichline] & VF_SELECTED))
|
---|
1036 | ad->selected++;
|
---|
1037 | }
|
---|
1038 | ad->markedlines[whichline] |= markwith;
|
---|
1039 | if ((p - ad->text) + strlen(s2) >
|
---|
1040 | (whichline + 1) * 16) {
|
---|
1041 | whichline++;
|
---|
1042 | if (!(ad->markedlines[whichline] & VF_FOUND))
|
---|
1043 | ad->found++;
|
---|
1044 | if (markwith & VF_SELECTED) {
|
---|
1045 | if (!(ad->markedlines[whichline] & VF_SELECTED))
|
---|
1046 | ad->selected++;
|
---|
1047 | }
|
---|
1048 | ad->markedlines[whichline] |= markwith;
|
---|
1049 | }
|
---|
1050 | p = ad->text + ((whichline + 1) * 16);
|
---|
1051 | if (p >= ad->text + ad->textsize)
|
---|
1052 | break;
|
---|
1053 | }
|
---|
1054 | else {
|
---|
1055 | for (x = lastline; x < ad->numlines; x++) {
|
---|
1056 | if (ad->lines[x] > p) {
|
---|
1057 | if (x - 1 < firstline)
|
---|
1058 | firstline = x - 1;
|
---|
1059 | if (!(ad->markedlines[x - 1] & VF_FOUND))
|
---|
1060 | ad->found++;
|
---|
1061 | if (markwith & VF_SELECTED) {
|
---|
1062 | if (!(ad->markedlines[x - 1] & VF_SELECTED))
|
---|
1063 | ad->selected++;
|
---|
1064 | }
|
---|
1065 | ad->markedlines[x - 1] |= markwith;
|
---|
1066 | if (x + 1 < ad->numlines &&
|
---|
1067 | p + strlen(s2) > ad->lines[x]) {
|
---|
1068 | x++;
|
---|
1069 | if (!(ad->markedlines[x - 1] & VF_FOUND))
|
---|
1070 | ad->found++;
|
---|
1071 | if (markwith & VF_SELECTED) {
|
---|
1072 | if (!(ad->markedlines[x - 1] & VF_SELECTED))
|
---|
1073 | ad->selected++;
|
---|
1074 | }
|
---|
1075 | ad->markedlines[x - 1] |= markwith;
|
---|
1076 | }
|
---|
1077 | lastline = x;
|
---|
1078 | p = ad->lines[x];
|
---|
1079 | break;
|
---|
1080 | }
|
---|
1081 | }
|
---|
1082 | if (x >= ad->numlines) {
|
---|
1083 | if (markwith & VF_SELECTED) {
|
---|
1084 | if (!
|
---|
1085 | (ad->markedlines[numlines - 1] & VF_SELECTED))
|
---|
1086 | ad->selected++;
|
---|
1087 | if (!(ad->markedlines[numlines - 1] & VF_FOUND))
|
---|
1088 | ad->found++;
|
---|
1089 | }
|
---|
1090 | ad->markedlines[ad->numlines - 1] |= markwith;
|
---|
1091 | break;
|
---|
1092 | }
|
---|
1093 | }
|
---|
1094 | }
|
---|
1095 | }
|
---|
1096 | }
|
---|
1097 | t = n;
|
---|
1098 | }
|
---|
1099 | }
|
---|
1100 | DosReleaseMutexSem(ad->ScanSem);
|
---|
1101 | if (!ad->stopflag && firstline == ULONG_MAX) {
|
---|
1102 | if (!fAlertBeepOff)
|
---|
1103 | DosBeep(50, 50);
|
---|
1104 | WinSetWindowText(WinWindowFromID(ad->hwndFrame,
|
---|
1105 | NEWVIEW_STATUS1),
|
---|
1106 | GetPString(IDS_NOMATCHINGTEXT));
|
---|
1107 | DosSleep(150);//05 Aug 07 GKY 1500
|
---|
1108 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1109 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
1110 | }
|
---|
1111 | else if (!ad->stopflag) {
|
---|
1112 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1113 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
1114 | PostMsg(hwnd, UM_CONTAINER_FILLED,
|
---|
1115 | MPFROMLONG(firstline + 1), MPFROMLONG(firstline + 1));
|
---|
1116 | }
|
---|
1117 | }
|
---|
1118 | else
|
---|
1119 | DosReleaseMutexSem(ad->ScanSem);
|
---|
1120 | }
|
---|
1121 | }
|
---|
1122 | WinDestroyMsgQueue(hmq2);
|
---|
1123 | }
|
---|
1124 | DecrThreadUsage();
|
---|
1125 | WinTerminate(hab2);
|
---|
1126 | }
|
---|
1127 |
|
---|
1128 | # ifdef FORTIFY
|
---|
1129 | Fortify_LeaveScope();
|
---|
1130 | # endif
|
---|
1131 | DosPostEventSem(CompactSem);
|
---|
1132 | }
|
---|
1133 |
|
---|
1134 | static VOID ClipboardThread(VOID * args)
|
---|
1135 | {
|
---|
1136 | HWND hwnd = (HWND) args;
|
---|
1137 | HAB hab2;
|
---|
1138 | HMQ hmq2;
|
---|
1139 | VIEWDATA *ad;
|
---|
1140 | CHAR **list;
|
---|
1141 | USHORT cmd;
|
---|
1142 | register ULONG x;
|
---|
1143 | BOOL released = FALSE;
|
---|
1144 |
|
---|
1145 | priority_normal();
|
---|
1146 | # ifdef FORTIFY
|
---|
1147 | Fortify_EnterScope();
|
---|
1148 | # endif
|
---|
1149 | hab2 = WinInitialize(0);
|
---|
1150 | if (hab2) {
|
---|
1151 | hmq2 = WinCreateMsgQueue(hab2, 0);
|
---|
1152 | if (hmq2) {
|
---|
1153 | WinCancelShutdown(hmq2, TRUE);
|
---|
1154 | IncrThreadUsage();
|
---|
1155 | ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
1156 | if (ad) {
|
---|
1157 | if (!DosRequestMutexSem(ad->ScanSem, SEM_INDEFINITE_WAIT)) {
|
---|
1158 | cmd = ad->cliptype;
|
---|
1159 | if (ad->numlines && ad->text && ad->textsize && ad->markedlines &&
|
---|
1160 | !ad->stopflag) {
|
---|
1161 | WinSetWindowText(WinWindowFromID(ad->hwndFrame,
|
---|
1162 | NEWVIEW_STATUS1),
|
---|
1163 | GetPString(IDS_BUILDINGLINELISTTEXT));
|
---|
1164 | if (cmd == IDM_SAVETOCLIP || cmd == IDM_APPENDTOCLIP ||
|
---|
1165 | cmd == IDM_SAVETOLIST)
|
---|
1166 | list = BuildAList(hwnd);
|
---|
1167 | else
|
---|
1168 | list = BuildAList2(hwnd);
|
---|
1169 | if (list) {
|
---|
1170 | if (!ad->stopflag) {
|
---|
1171 | WinSetWindowText(WinWindowFromID(ad->hwndFrame,
|
---|
1172 | NEWVIEW_STATUS1),
|
---|
1173 | (cmd == IDM_SAVETOCLIP ||
|
---|
1174 | cmd == IDM_SAVETOCLIP2) ?
|
---|
1175 | GetPString(IDS_SAVETOCLIPTEXT) :
|
---|
1176 | (cmd == IDM_APPENDTOCLIP ||
|
---|
1177 | cmd == IDM_APPENDTOCLIP2) ?
|
---|
1178 | GetPString(IDS_APPENDTOCLIPTEXT) :
|
---|
1179 | GetPString(IDS_WRITETOFILETEXT));
|
---|
1180 | DosReleaseMutexSem(ad->ScanSem);
|
---|
1181 | released = TRUE;
|
---|
1182 | if (cmd == IDM_SAVETOCLIP || cmd == IDM_APPENDTOCLIP ||
|
---|
1183 | cmd == IDM_SAVETOCLIP2 || cmd == IDM_APPENDTOCLIP2)
|
---|
1184 | ListToClipboardHab(hab2, list, cmd);
|
---|
1185 | else {
|
---|
1186 |
|
---|
1187 | FILE *fp;
|
---|
1188 | CHAR filename[CCHMAXPATH];
|
---|
1189 |
|
---|
1190 | *filename = 0;
|
---|
1191 | if (export_filename(hwnd, filename, FALSE)) {
|
---|
1192 | fp = _fsopen(filename, "a+", SH_DENYWR);
|
---|
1193 | if (!fp) {
|
---|
1194 | saymsg(MB_CANCEL,
|
---|
1195 | hwnd,
|
---|
1196 | GetPString(IDS_ERRORTEXT),
|
---|
1197 | GetPString(IDS_CANTOPENFORWRITETEXT), filename);
|
---|
1198 | }
|
---|
1199 | else {
|
---|
1200 | fseek(fp, 0L, SEEK_END);
|
---|
1201 | for (x = 0; list[x]; x++)
|
---|
1202 | fprintf(fp, "%s\n", list[x]);
|
---|
1203 | fclose(fp);
|
---|
1204 | }
|
---|
1205 | }
|
---|
1206 | }
|
---|
1207 | }
|
---|
1208 | FreeList(list);
|
---|
1209 | }
|
---|
1210 | else {
|
---|
1211 | DosReleaseMutexSem(ad->ScanSem);
|
---|
1212 | released = TRUE;
|
---|
1213 | if (!fAlertBeepOff)
|
---|
1214 | DosBeep(50, 100);
|
---|
1215 | WinSetWindowText(WinWindowFromID(ad->hwndFrame,
|
---|
1216 | NEWVIEW_STATUS1),
|
---|
1217 | GetPString(IDS_NVNOLINESSELTEXT));
|
---|
1218 | DosSleep(150);//05 Aug 07 GKY 1500
|
---|
1219 | }
|
---|
1220 | }
|
---|
1221 | if (!released)
|
---|
1222 | DosReleaseMutexSem(ad->ScanSem);
|
---|
1223 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1224 | }
|
---|
1225 | }
|
---|
1226 | WinDestroyMsgQueue(hmq2);
|
---|
1227 | }
|
---|
1228 | DecrThreadUsage();
|
---|
1229 | WinTerminate(hab2);
|
---|
1230 | }
|
---|
1231 | # ifdef FORTIFY
|
---|
1232 | Fortify_LeaveScope();
|
---|
1233 | # endif
|
---|
1234 | DosPostEventSem(CompactSem);
|
---|
1235 | }
|
---|
1236 |
|
---|
1237 | static VOID ReLineThread(VOID * args)
|
---|
1238 | {
|
---|
1239 | HWND hwnd = (HWND) args;
|
---|
1240 | HAB hab2;
|
---|
1241 | HMQ hmq2;
|
---|
1242 | VIEWDATA *ad;
|
---|
1243 | CHAR *p, *pp, *e, *whereiam = NULL;
|
---|
1244 | RECTL Rectl;
|
---|
1245 | ULONG width, numlines, firstline = 1, cursored = 1;
|
---|
1246 |
|
---|
1247 | priority_normal();
|
---|
1248 | # ifdef FORTIFY
|
---|
1249 | Fortify_EnterScope();
|
---|
1250 | # endif
|
---|
1251 | hab2 = WinInitialize(0);
|
---|
1252 | if (hab2) {
|
---|
1253 | hmq2 = WinCreateMsgQueue(hab2, 0);
|
---|
1254 | if (hmq2) {
|
---|
1255 | WinCancelShutdown(hmq2, TRUE);
|
---|
1256 | IncrThreadUsage();
|
---|
1257 | ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
1258 | if (!ad)
|
---|
1259 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
1260 | else {
|
---|
1261 | if (!DosRequestMutexSem(ad->ScanSem, SEM_INDEFINITE_WAIT)) {
|
---|
1262 | ad->relining = TRUE;
|
---|
1263 | ad->busy++;
|
---|
1264 | ad->maxx = 0;
|
---|
1265 | if (ad->text && ad->textsize) {
|
---|
1266 | if (ad->hex) {
|
---|
1267 | firstline = ad->topline;
|
---|
1268 | cursored = ad->cursored;
|
---|
1269 | }
|
---|
1270 | else if (ad->lines)
|
---|
1271 | whereiam = ad->lines[ad->cursored - 1];
|
---|
1272 | ad->found = 0;
|
---|
1273 | ad->selected = ad->numlines = ad->numalloc = 0;
|
---|
1274 | xfree(ad->lines, pszSrcFile, __LINE__);
|
---|
1275 | xfree(ad->markedlines, pszSrcFile, __LINE__);
|
---|
1276 | ad->lines = NULL;
|
---|
1277 | ad->markedlines = NULL;
|
---|
1278 | WinSetWindowText(WinWindowFromID(ad->hwndFrame,
|
---|
1279 | NEWVIEW_STATUS1),
|
---|
1280 | GetPString(IDS_FORMATTINGTEXT));
|
---|
1281 | if (!ad->hex) {
|
---|
1282 | if (WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
|
---|
1283 | LM_QUERYITEMCOUNT, MPVOID, MPVOID)) {
|
---|
1284 | WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
|
---|
1285 | LM_DELETEALL, MPVOID, MPVOID);
|
---|
1286 | PostMsg(ad->hwndFrame, WM_UPDATEFRAME,
|
---|
1287 | MPFROMLONG(FCF_SIZEBORDER), MPVOID);
|
---|
1288 | }
|
---|
1289 | }
|
---|
1290 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
1291 | if (!ad->hex) {
|
---|
1292 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
1293 | width = (Rectl.xRight - Rectl.xLeft) / ad->fattrs.lAveCharWidth;
|
---|
1294 | numlines = NumLines(&Rectl, ad);
|
---|
1295 | ad->oldwidth = width;
|
---|
1296 | p = ad->text;
|
---|
1297 | if (width) {
|
---|
1298 | while (p - ad->text < ad->textsize && !ad->stopflag) {
|
---|
1299 | if (ad->wrapon) {
|
---|
1300 | e = p + (width - 1);
|
---|
1301 | if (e - ad->text > ad->textsize)
|
---|
1302 | e = ad->text + ad->textsize;
|
---|
1303 | pp = p;
|
---|
1304 | while (pp < e) {
|
---|
1305 | if (*pp == '\r' || *pp == '\n') {
|
---|
1306 | e = pp;
|
---|
1307 | break;
|
---|
1308 | }
|
---|
1309 | pp++;
|
---|
1310 | }
|
---|
1311 | }
|
---|
1312 | else {
|
---|
1313 | pp = p;
|
---|
1314 | while (pp - ad->text < ad->textsize &&
|
---|
1315 | *pp != '\r' && *pp != '\n')
|
---|
1316 | pp++;
|
---|
1317 | e = pp;
|
---|
1318 | if (ad->maxx <
|
---|
1319 | (((e - p) + 1) * ad->fattrs.lAveCharWidth) + 1)
|
---|
1320 | ad->maxx = (((e - p) + 1) *
|
---|
1321 | ad->fattrs.lAveCharWidth) + 1;
|
---|
1322 | }
|
---|
1323 | if (whereiam && p >= whereiam && e <= whereiam) {
|
---|
1324 | cursored = firstline = ad->numlines + 1;
|
---|
1325 | whereiam = NULL;
|
---|
1326 | }
|
---|
1327 | /* assign ad->lines[ad->numlines] */
|
---|
1328 | if (ad->numlines + 1 > ad->numalloc) {
|
---|
1329 |
|
---|
1330 | CHAR **temp;
|
---|
1331 |
|
---|
1332 | temp = xrealloc(ad->lines, sizeof(CHAR *) *
|
---|
1333 | (ad->numalloc + 256), pszSrcFile,
|
---|
1334 | __LINE__);
|
---|
1335 | if (!temp)
|
---|
1336 | break;
|
---|
1337 | ad->lines = temp;
|
---|
1338 | ad->numalloc += 256;
|
---|
1339 | }
|
---|
1340 | ad->lines[ad->numlines] = p;
|
---|
1341 | ad->numlines++;
|
---|
1342 | if (ad->numlines == numlines) {
|
---|
1343 | /* display first page */
|
---|
1344 | register INT x;
|
---|
1345 |
|
---|
1346 | for (x = 0; x < ad->numlines; x++) {
|
---|
1347 | if ((LONG) (Rectl.yTop -
|
---|
1348 | (ad->lMaxHeight * (((x + 1) -
|
---|
1349 | ad->topline) + 1))) < 0)
|
---|
1350 | break;
|
---|
1351 | PaintLine(hwnd, ad->hps, x, 1, &Rectl);
|
---|
1352 | }
|
---|
1353 | }
|
---|
1354 | p = e;
|
---|
1355 | if (p - ad->text < ad->textsize) {
|
---|
1356 | if (*p == '\r')
|
---|
1357 | p++;
|
---|
1358 | }
|
---|
1359 | if (p - ad->text < ad->textsize) {
|
---|
1360 | if (*p == '\n')
|
---|
1361 | p++;
|
---|
1362 | }
|
---|
1363 | }
|
---|
1364 | }
|
---|
1365 | if (ad->numalloc != ad->numlines) {
|
---|
1366 |
|
---|
1367 | CHAR **temp;
|
---|
1368 |
|
---|
1369 | temp =
|
---|
1370 | xrealloc(ad->lines, sizeof(CHAR *) * ad->numlines,
|
---|
1371 | pszSrcFile, __LINE__);
|
---|
1372 | if (temp) {
|
---|
1373 | ad->lines = temp;
|
---|
1374 | ad->numalloc = ad->numlines;
|
---|
1375 | }
|
---|
1376 | }
|
---|
1377 | }
|
---|
1378 | else {
|
---|
1379 | ad->numlines = ad->textsize / 16;
|
---|
1380 | if (ad->numlines * 16 < ad->textsize)
|
---|
1381 | ad->numlines++;
|
---|
1382 | }
|
---|
1383 | if (ad->numlines) {
|
---|
1384 | ad->markedlines = xmallocz(ad->numlines, pszSrcFile, __LINE__);
|
---|
1385 | if (ad->markedlines) {
|
---|
1386 | ad->selected = 0;
|
---|
1387 | }
|
---|
1388 | if ((*ftprun || fFtpRunWPSDefault) && !ad->ignoreftp &&
|
---|
1389 | strstr(ad->text, "ftp://"))
|
---|
1390 | ad->ftpin = TRUE;
|
---|
1391 | if ((*httprun || fHttpRunWPSDefault) && !ad->ignorehttp &&
|
---|
1392 | strstr(ad->text, "http://"))
|
---|
1393 | ad->httpin = TRUE;
|
---|
1394 | if (*mailrun && !ad->ignoremail && strstr(ad->text, "@"))
|
---|
1395 | ad->mailin = TRUE;
|
---|
1396 | }
|
---|
1397 | }
|
---|
1398 | DosReleaseMutexSem(ad->ScanSem);
|
---|
1399 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
1400 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
1401 | ad->busy--;
|
---|
1402 | } // if got sim
|
---|
1403 | } // if got VIEWDATA
|
---|
1404 | WinDestroyMsgQueue(hmq2);
|
---|
1405 | }
|
---|
1406 | DecrThreadUsage();
|
---|
1407 | WinTerminate(hab2);
|
---|
1408 | }
|
---|
1409 | # ifdef FORTIFY
|
---|
1410 | Fortify_LeaveScope();
|
---|
1411 | # endif
|
---|
1412 | DosPostEventSem(CompactSem);
|
---|
1413 | if (ad && !ad->stopflag) { //Fixme can't post message withou HAB GKY 7-10-08
|
---|
1414 | PostMsg(hwnd, UM_CONTAINER_FILLED, MPFROMLONG(firstline),
|
---|
1415 | MPFROMLONG(cursored));
|
---|
1416 | ad->relining = FALSE;
|
---|
1417 | }
|
---|
1418 | }
|
---|
1419 |
|
---|
1420 | static VOID LoadFileThread(VOID * args)
|
---|
1421 | {
|
---|
1422 | HWND hwnd = (HWND) args;
|
---|
1423 | HAB hab2;
|
---|
1424 | HMQ hmq2;
|
---|
1425 | VIEWDATA *ad;
|
---|
1426 | HFILE handle;
|
---|
1427 | ULONG action;
|
---|
1428 | ULONG len;
|
---|
1429 | APIRET rc;
|
---|
1430 | BOOL error = TRUE;
|
---|
1431 |
|
---|
1432 | # ifdef FORTIFY
|
---|
1433 | Fortify_EnterScope();
|
---|
1434 | # endif
|
---|
1435 | hab2 = WinInitialize(0);
|
---|
1436 | if (hab2) {
|
---|
1437 | hmq2 = WinCreateMsgQueue(hab2, 0);
|
---|
1438 | if (hmq2) {
|
---|
1439 | WinCancelShutdown(hmq2, TRUE);
|
---|
1440 | IncrThreadUsage();
|
---|
1441 | ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
1442 | if (ad) {
|
---|
1443 | if (!DosRequestMutexSem(ad->ScanSem, SEM_INDEFINITE_WAIT)) {
|
---|
1444 | ad->busy++;
|
---|
1445 | priority_normal();
|
---|
1446 | if (*ad->filename) {
|
---|
1447 | xfree(ad->text, pszSrcFile, __LINE__);
|
---|
1448 | xfree(ad->lines, pszSrcFile, __LINE__);
|
---|
1449 | xfree(ad->markedlines, pszSrcFile, __LINE__);
|
---|
1450 | ad->text = NULL;
|
---|
1451 | ad->lines = NULL;
|
---|
1452 | ad->markedlines = NULL;
|
---|
1453 | ad->ftpin = ad->httpin = ad->mailin = FALSE;
|
---|
1454 | ad->selected = ad->numlines = ad->textsize = ad->numalloc = 0;
|
---|
1455 | WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX, LM_DELETEALL,
|
---|
1456 | MPVOID, MPVOID);
|
---|
1457 | PostMsg(ad->hwndFrame, WM_UPDATEFRAME,
|
---|
1458 | MPFROMLONG(FCF_SIZEBORDER), MPVOID);
|
---|
1459 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
1460 | rc = DosOpen(ad->filename, &handle, &action, 0, 0,
|
---|
1461 | OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
|
---|
1462 | OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT |
|
---|
1463 | OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE |
|
---|
1464 | OPEN_ACCESS_READONLY, 0);
|
---|
1465 | if (rc) {
|
---|
1466 | Dos_Error(MB_CANCEL,
|
---|
1467 | rc,
|
---|
1468 | hwnd,
|
---|
1469 | pszSrcFile,
|
---|
1470 | __LINE__,
|
---|
1471 | GetPString(IDS_COMPCANTOPENTEXT), ad->filename);
|
---|
1472 | }
|
---|
1473 | else {
|
---|
1474 | DosChgFilePtr(handle, 0, FILE_END, &len);
|
---|
1475 | DosChgFilePtr(handle, 0, FILE_BEGIN, &action);
|
---|
1476 | if (!len) {
|
---|
1477 | saymsg(MB_CANCEL,
|
---|
1478 | hwnd,
|
---|
1479 | GetPString(IDS_ERRORTEXT),
|
---|
1480 | GetPString(IDS_ZEROLENGTHTEXT), ad->filename);
|
---|
1481 | }
|
---|
1482 | else {
|
---|
1483 | // 06 Oct 07 SHL Protect against 4096 NFTS driver small buffer defect
|
---|
1484 | ad->text = xmalloc(max(len + 2, 4096), // 05 Nov 07 SHL
|
---|
1485 | pszSrcFile,
|
---|
1486 | __LINE__);
|
---|
1487 | if (ad->text) {
|
---|
1488 | *ad->text = 0;
|
---|
1489 | ad->text[len] = 0;
|
---|
1490 | rc = DosRead(handle, ad->text, len, &ad->textsize);
|
---|
1491 | if (rc) {
|
---|
1492 | Dos_Error(MB_CANCEL,
|
---|
1493 | rc,
|
---|
1494 | hwnd,
|
---|
1495 | pszSrcFile,
|
---|
1496 | __LINE__,
|
---|
1497 | GetPString(IDS_ERRORREADINGTEXT), ad->filename);
|
---|
1498 | free(ad->text);
|
---|
1499 | ad->text = NULL;
|
---|
1500 | ad->textsize = 0;
|
---|
1501 | }
|
---|
1502 | else {
|
---|
1503 | ad->text[ad->textsize] = 0;
|
---|
1504 | if (!ad->hex && !(ad->flags & (8 | 16)) && ad->textsize) {
|
---|
1505 | ULONG x;
|
---|
1506 |
|
---|
1507 | x = min(512, ad->textsize);
|
---|
1508 | if (fGuessType && IsBinary(ad->text, x))
|
---|
1509 | ad->hex = TRUE;
|
---|
1510 | }
|
---|
1511 | if (ad->textsize) {
|
---|
1512 | if (xbeginthread(ReLineThread,
|
---|
1513 | 524288,
|
---|
1514 | (PVOID)hwnd,
|
---|
1515 | pszSrcFile,
|
---|
1516 | __LINE__) != -1)
|
---|
1517 | {
|
---|
1518 | error = FALSE;
|
---|
1519 | }
|
---|
1520 | }
|
---|
1521 | }
|
---|
1522 | }
|
---|
1523 | }
|
---|
1524 | DosClose(handle);
|
---|
1525 | }
|
---|
1526 | }
|
---|
1527 | ad->busy--;
|
---|
1528 | DosReleaseMutexSem(ad->ScanSem);
|
---|
1529 | }
|
---|
1530 | }
|
---|
1531 | WinDestroyMsgQueue(hmq2);
|
---|
1532 | }
|
---|
1533 | DecrThreadUsage();
|
---|
1534 | WinTerminate(hab2);
|
---|
1535 | }
|
---|
1536 | # ifdef FORTIFY
|
---|
1537 | Fortify_LeaveScope();
|
---|
1538 | # endif
|
---|
1539 | if (error) //fixme
|
---|
1540 | PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
|
---|
1541 | DosPostEventSem(CompactSem);
|
---|
1542 | }
|
---|
1543 |
|
---|
1544 | MRESULT EXPENTRY ViewFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
1545 | MPARAM mp2)
|
---|
1546 | {
|
---|
1547 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
1548 |
|
---|
1549 | switch (msg) {
|
---|
1550 | case WM_CHAR:
|
---|
1551 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
1552 | break;
|
---|
1553 |
|
---|
1554 | case WM_CONTROL:
|
---|
1555 | switch (SHORT1FROMMP(mp1)) {
|
---|
1556 | case NEWVIEW_LISTBOX:
|
---|
1557 | return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL,
|
---|
1558 | mp1, mp2);
|
---|
1559 | }
|
---|
1560 | break;
|
---|
1561 |
|
---|
1562 | case WM_CALCFRAMERECT:
|
---|
1563 | {
|
---|
1564 | MRESULT mr;
|
---|
1565 | PRECTL prectl;
|
---|
1566 | SHORT sSelect;
|
---|
1567 |
|
---|
1568 | mr = oldproc(hwnd, msg, mp1, mp2);
|
---|
1569 |
|
---|
1570 | /*
|
---|
1571 | * Calculate the position of the client rectangle.
|
---|
1572 | * Otherwise, we'll see a lot of redraw when we move the
|
---|
1573 | * client during WM_FORMATFRAME.
|
---|
1574 | */
|
---|
1575 |
|
---|
1576 | if (mr && mp2) {
|
---|
1577 | prectl = (PRECTL) mp1;
|
---|
1578 | prectl->yBottom += 22;
|
---|
1579 | prectl->yTop -= 22;
|
---|
1580 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, NEWVIEW_LISTBOX,
|
---|
1581 | LM_QUERYITEMCOUNT,
|
---|
1582 | MPVOID, MPVOID);
|
---|
1583 | if (sSelect > 0)
|
---|
1584 | prectl->yTop -= 48;
|
---|
1585 | }
|
---|
1586 | return mr;
|
---|
1587 | }
|
---|
1588 |
|
---|
1589 | case WM_FORMATFRAME:
|
---|
1590 | {
|
---|
1591 | SHORT sCount, soldCount, sSelect;
|
---|
1592 | PSWP pswp, pswpClient, pswpNew1, pswpNew2, pswpNew3, pswpList,
|
---|
1593 | pswpScroll, pswpNew4, pswpUp, pswpDn;
|
---|
1594 |
|
---|
1595 | sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2);
|
---|
1596 | soldCount = sCount;
|
---|
1597 |
|
---|
1598 | /*
|
---|
1599 | * Reformat the frame to "squeeze" the client
|
---|
1600 | * and make room for status window sibling beneath
|
---|
1601 | */
|
---|
1602 |
|
---|
1603 | pswp = (PSWP) mp1;
|
---|
1604 | {
|
---|
1605 | SHORT x;
|
---|
1606 |
|
---|
1607 | for (x = 0; x < sCount; x++) {
|
---|
1608 | if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
|
---|
1609 | pswpClient = pswp;
|
---|
1610 | break;
|
---|
1611 | }
|
---|
1612 | pswp++;
|
---|
1613 | }
|
---|
1614 | }
|
---|
1615 | pswpNew1 = (PSWP) mp1 + soldCount;
|
---|
1616 | pswpNew2 = (PSWP) mp1 + (soldCount + 1);
|
---|
1617 | pswpNew3 = (PSWP) mp1 + (soldCount + 2);
|
---|
1618 | pswpNew4 = (PSWP) mp1 + (soldCount + 3);
|
---|
1619 | *pswpNew1 = *pswpClient;
|
---|
1620 | pswpNew1->hwnd = WinWindowFromID(hwnd, NEWVIEW_STATUS1);
|
---|
1621 | pswpNew1->x = pswpClient->x + 2;
|
---|
1622 | pswpNew1->y = pswpClient->y + 2;
|
---|
1623 | pswpNew1->cx = (pswpClient->cx / 3) - 3;
|
---|
1624 | pswpNew1->cy = 20;
|
---|
1625 | pswpClient->y = pswpNew1->y + pswpNew1->cy + 3;
|
---|
1626 | pswpClient->cy = (pswpClient->cy - pswpNew1->cy) - 5;
|
---|
1627 | *pswpNew2 = *pswpNew1;
|
---|
1628 | *pswpNew3 = *pswpNew1;
|
---|
1629 | *pswpNew4 = *pswpNew1;
|
---|
1630 | pswpNew2->hwnd = WinWindowFromID(hwnd, NEWVIEW_STATUS2);
|
---|
1631 | pswpNew3->hwnd = WinWindowFromID(hwnd, NEWVIEW_STATUS3);
|
---|
1632 | pswpNew4->hwnd = WinWindowFromID(hwnd, NEWVIEW_DRAG);
|
---|
1633 | pswpNew2->x = pswpNew1->x + pswpNew1->cx + 3;
|
---|
1634 | pswpNew3->x = pswpNew2->x + pswpNew2->cx + 3;
|
---|
1635 | pswpNew3->cx = ((pswpClient->x + pswpClient->cx) - pswpNew3->x) - 26;
|
---|
1636 | pswpNew4->x = pswpNew3->x + pswpNew3->cx + 3;
|
---|
1637 | pswpNew4->cx = 20;
|
---|
1638 | sCount += 4;
|
---|
1639 | pswpScroll = (PSWP) mp1;
|
---|
1640 | while (pswpScroll < pswpClient) {
|
---|
1641 | if (WinQueryWindowUShort(pswpScroll->hwnd, QWS_ID) == FID_VERTSCROLL)
|
---|
1642 | break;
|
---|
1643 | pswpScroll++;
|
---|
1644 | }
|
---|
1645 | if (pswpScroll == pswpClient)
|
---|
1646 | pswpScroll = NULL;
|
---|
1647 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, NEWVIEW_LISTBOX,
|
---|
1648 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
1649 | if (sSelect > 0) {
|
---|
1650 | pswpList = (PSWP) mp1 + (soldCount + 4);
|
---|
1651 | *pswpList = *pswpClient;
|
---|
1652 | pswpList->hwnd = WinWindowFromID(hwnd, NEWVIEW_LISTBOX);
|
---|
1653 | pswpList->x = pswpClient->x;
|
---|
1654 | pswpList->cx = pswpClient->cx;
|
---|
1655 | if (pswpScroll) {
|
---|
1656 | pswpList->cx += pswpScroll->cx;
|
---|
1657 | pswpScroll->cy -= 48;
|
---|
1658 | }
|
---|
1659 | pswpList->y = (pswpClient->y + pswpClient->cy) - 48;
|
---|
1660 | pswpList->cy = 48;
|
---|
1661 | pswpClient->cy -= 48;
|
---|
1662 | sCount++;
|
---|
1663 | }
|
---|
1664 | WinShowWindow(WinWindowFromID(hwnd, NEWVIEW_LISTBOX), (sSelect > 0));
|
---|
1665 |
|
---|
1666 | if (pswpScroll) {
|
---|
1667 | pswpUp = (PSWP) mp1 + (soldCount + 4 + (sSelect > 0));
|
---|
1668 | *pswpUp = *pswpClient;
|
---|
1669 | pswpUp->hwnd = WinWindowFromID(hwnd, IDM_PREVBLANKLINE);
|
---|
1670 | pswpUp->cx = pswpScroll->cx;
|
---|
1671 | pswpUp->x = pswpScroll->x;
|
---|
1672 | pswpUp->cy = WinQuerySysValue(HWND_DESKTOP, SV_CYVSCROLLARROW);
|
---|
1673 | pswpUp->y = (pswpScroll->y + pswpScroll->cy) - (pswpUp->cy + 1);
|
---|
1674 | pswpScroll->cy -= ((pswpUp->cy * 2) + 1);
|
---|
1675 | pswpDn = (PSWP) mp1 + (soldCount + 5 + (sSelect > 0));
|
---|
1676 | *pswpDn = *pswpUp;
|
---|
1677 | pswpDn->y = pswpScroll->y;
|
---|
1678 | pswpDn->hwnd = WinWindowFromID(hwnd, IDM_NEXTBLANKLINE);
|
---|
1679 | pswpScroll->y += pswpUp->cy;
|
---|
1680 | sCount += 2;
|
---|
1681 | }
|
---|
1682 | else {
|
---|
1683 | WinShowWindow(WinWindowFromID(hwnd, IDM_PREVBLANKLINE), FALSE);
|
---|
1684 | WinShowWindow(WinWindowFromID(hwnd, IDM_NEXTBLANKLINE), FALSE);
|
---|
1685 | }
|
---|
1686 | return MRFROMSHORT(sCount);
|
---|
1687 | }
|
---|
1688 |
|
---|
1689 | case WM_QUERYFRAMECTLCOUNT:
|
---|
1690 | {
|
---|
1691 | SHORT sCount, sSelect;
|
---|
1692 |
|
---|
1693 | sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2);
|
---|
1694 | sCount += 6;
|
---|
1695 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, NEWVIEW_LISTBOX,
|
---|
1696 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
1697 | if (sSelect > 0)
|
---|
1698 | sCount++;
|
---|
1699 | return MRFROMSHORT(sCount);
|
---|
1700 | }
|
---|
1701 | }
|
---|
1702 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
1703 | }
|
---|
1704 |
|
---|
1705 | MRESULT EXPENTRY FindStrDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
1706 | {
|
---|
1707 | VIEWDATA *ad;
|
---|
1708 |
|
---|
1709 | switch (msg) {
|
---|
1710 | case WM_INITDLG:
|
---|
1711 | if (!mp2)
|
---|
1712 | WinDismissDlg(hwnd, 0);
|
---|
1713 | else {
|
---|
1714 |
|
---|
1715 | HWND hwndClient = *(HWND *) mp2;
|
---|
1716 |
|
---|
1717 | WinSetWindowULong(hwnd, QWL_USER, (ULONG) hwndClient);
|
---|
1718 | ad = (VIEWDATA *) WinQueryWindowPtr(hwndClient, QWL_USER);
|
---|
1719 | MLEsetwrap(WinWindowFromID(hwnd, NEWFIND_MLE), FALSE);
|
---|
1720 | MLEsetlimit(WinWindowFromID(hwnd, NEWFIND_MLE), SEARCHSTRINGLEN);
|
---|
1721 | MLEsetformat(WinWindowFromID(hwnd, NEWFIND_MLE), MLFIE_NOTRANS);
|
---|
1722 | if (*ad->searchtext) {
|
---|
1723 |
|
---|
1724 | IPT here = 0;
|
---|
1725 | ULONG len = strlen(ad->searchtext);
|
---|
1726 |
|
---|
1727 | WinSendMsg(WinWindowFromID(hwnd, NEWFIND_MLE),
|
---|
1728 | MLM_SETIMPORTEXPORT,
|
---|
1729 | MPFROMP(ad->searchtext), MPFROMLONG(SEARCHSTRINGLEN));
|
---|
1730 | WinSendMsg(WinWindowFromID(hwnd, NEWFIND_MLE),
|
---|
1731 | MLM_IMPORT, MPFROMP(&here), MPFROMLONG(len));
|
---|
1732 | }
|
---|
1733 | WinCheckButton(hwnd, NEWFIND_ALSOSELECT, ad->alsoselect);
|
---|
1734 | WinCheckButton(hwnd, NEWFIND_SENSITIVE, ad->sensitive);
|
---|
1735 | WinCheckButton(hwnd, NEWFIND_LITERAL, ad->literalsearch);
|
---|
1736 | }
|
---|
1737 | break;
|
---|
1738 |
|
---|
1739 | case WM_COMMAND:
|
---|
1740 | switch (SHORT1FROMMP(mp1)) {
|
---|
1741 | case DID_OK:
|
---|
1742 | {
|
---|
1743 | CHAR s[SEARCHSTRINGLEN];
|
---|
1744 | IPT here = 0;
|
---|
1745 | ULONG len;
|
---|
1746 | HWND hwndClient = WinQueryWindowULong(hwnd, QWL_USER);
|
---|
1747 |
|
---|
1748 | ad = (VIEWDATA *) WinQueryWindowPtr(hwndClient, QWL_USER);
|
---|
1749 | memset(s, 0, SEARCHSTRINGLEN);
|
---|
1750 | WinSendMsg(WinWindowFromID(hwnd, NEWFIND_MLE),
|
---|
1751 | MLM_SETIMPORTEXPORT,
|
---|
1752 | MPFROMP(s), MPFROMLONG(SEARCHSTRINGLEN));
|
---|
1753 | len = SEARCHSTRINGLEN;
|
---|
1754 | WinSendMsg(WinWindowFromID(hwnd, NEWFIND_MLE),
|
---|
1755 | MLM_EXPORT, MPFROMP(&here), MPFROMLONG(&len));
|
---|
1756 | s[SEARCHSTRINGLEN - 1] = 0;
|
---|
1757 | if (!*s) {
|
---|
1758 | if (!fAlertBeepOff)
|
---|
1759 | DosBeep(250, 100); // Complain
|
---|
1760 | break;
|
---|
1761 | }
|
---|
1762 | strcpy(ad->searchtext, s);
|
---|
1763 | ad->sensitive = WinQueryButtonCheckstate(hwnd, NEWFIND_SENSITIVE);
|
---|
1764 | if (ad->sensitive != Sensitive) {
|
---|
1765 | Sensitive = ad->sensitive;
|
---|
1766 | PrfWriteProfileData(fmprof,
|
---|
1767 | appname,
|
---|
1768 | "Viewer.Sensitive",
|
---|
1769 | &ad->sensitive, sizeof(BOOL));
|
---|
1770 | }
|
---|
1771 | ad->literalsearch = WinQueryButtonCheckstate(hwnd, NEWFIND_LITERAL);
|
---|
1772 | if (ad->literalsearch != LiteralSearch) {
|
---|
1773 | LiteralSearch = ad->literalsearch;
|
---|
1774 | PrfWriteProfileData(fmprof,
|
---|
1775 | appname,
|
---|
1776 | "Viewer.LiteralSearch",
|
---|
1777 | &ad->literalsearch, sizeof(BOOL));
|
---|
1778 | }
|
---|
1779 | ad->alsoselect = WinQueryButtonCheckstate(hwnd, NEWFIND_ALSOSELECT);
|
---|
1780 | if (ad->alsoselect != AlsoSelect) {
|
---|
1781 | AlsoSelect = ad->alsoselect;
|
---|
1782 | PrfWriteProfileData(fmprof,
|
---|
1783 | appname,
|
---|
1784 | "Viewer.AlsoSelect",
|
---|
1785 | &ad->alsoselect, sizeof(BOOL));
|
---|
1786 | }
|
---|
1787 | }
|
---|
1788 | WinDismissDlg(hwnd, 1);
|
---|
1789 | break;
|
---|
1790 | case DID_CANCEL:
|
---|
1791 | WinDismissDlg(hwnd, 0);
|
---|
1792 | break;
|
---|
1793 | }
|
---|
1794 | return 0;
|
---|
1795 | }
|
---|
1796 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
1797 | }
|
---|
1798 |
|
---|
1799 | MRESULT EXPENTRY ViewWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
1800 | {
|
---|
1801 | VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
1802 |
|
---|
1803 | switch (msg) {
|
---|
1804 | case WM_CREATE:
|
---|
1805 | {
|
---|
1806 | HWND temphwnd;
|
---|
1807 | HWND hwndFrame = WinQueryWindow(hwnd, QW_PARENT);
|
---|
1808 |
|
---|
1809 | temphwnd = WinCreateWindow(hwndFrame,
|
---|
1810 | WC_BUTTON,
|
---|
1811 | "<",
|
---|
1812 | WS_VISIBLE |
|
---|
1813 | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
|
---|
1814 | 0,
|
---|
1815 | 0,
|
---|
1816 | 0,
|
---|
1817 | 0,
|
---|
1818 | hwndFrame,
|
---|
1819 | HWND_TOP, IDM_PREVBLANKLINE, NULL, NULL);
|
---|
1820 | if (!temphwnd)
|
---|
1821 | Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
|
---|
1822 | PCSZ_WINCREATEWINDOW);
|
---|
1823 | else {
|
---|
1824 | //fixme to allow user to change presparams 1-10-09 GKY
|
---|
1825 | WinSetPresParam(temphwnd,
|
---|
1826 | PP_FONTNAMESIZE,
|
---|
1827 | strlen(FNT_8HELVETICA) + 1,
|
---|
1828 | (PVOID) FNT_8HELVETICA);
|
---|
1829 | }
|
---|
1830 | temphwnd = WinCreateWindow(hwndFrame,
|
---|
1831 | WC_BUTTON,
|
---|
1832 | ">",
|
---|
1833 | WS_VISIBLE |
|
---|
1834 | BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
|
---|
1835 | 0,
|
---|
1836 | 0,
|
---|
1837 | 0,
|
---|
1838 | 0,
|
---|
1839 | hwndFrame,
|
---|
1840 | HWND_TOP, IDM_NEXTBLANKLINE, NULL, NULL);
|
---|
1841 | if (!temphwnd)
|
---|
1842 | Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
|
---|
1843 | PCSZ_WINCREATEWINDOW);
|
---|
1844 | else {
|
---|
1845 | //fixme to allow user to change presparams 1-10-09 GKY
|
---|
1846 | WinSetPresParam(temphwnd,
|
---|
1847 | PP_FONTNAMESIZE,
|
---|
1848 | strlen(FNT_8HELVETICA) + 1,
|
---|
1849 | (PVOID) FNT_8HELVETICA);
|
---|
1850 | }
|
---|
1851 | WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_NEWVIEW_TIMER, 1000L);
|
---|
1852 | }
|
---|
1853 | break;
|
---|
1854 |
|
---|
1855 | case WM_TIMER:
|
---|
1856 | if (ad &&
|
---|
1857 | ad->needrefreshing &&
|
---|
1858 | !ad->stopflag &&
|
---|
1859 | !ad->relining &&
|
---|
1860 | !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
1861 | ad->needrefreshing = FALSE;
|
---|
1862 | DosReleaseMutexSem(ad->ScanSem);
|
---|
1863 | WinInvalidateRect(hwnd, NULL, TRUE);
|
---|
1864 | }
|
---|
1865 | break;
|
---|
1866 |
|
---|
1867 | case UM_SETUP:
|
---|
1868 | if (!ad)
|
---|
1869 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
1870 | else {
|
---|
1871 | CHAR s[CCHMAXPATH + 8];
|
---|
1872 | APIRET rc;
|
---|
1873 |
|
---|
1874 | ad->hwndMenu = WinWindowFromID(ad->hwndFrame, FID_MENU);
|
---|
1875 | ad->hvscroll = WinWindowFromID(ad->hwndFrame, FID_VERTSCROLL);
|
---|
1876 | ad->hhscroll = WinWindowFromID(ad->hwndFrame, FID_HORZSCROLL);
|
---|
1877 | WinSendMsg(ad->hhscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1), MPVOID);
|
---|
1878 | WinSendMsg(ad->hvscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1), MPVOID);
|
---|
1879 | sprintf(s, "%s: %s", FM2Str, ad->filename);
|
---|
1880 | WinSetWindowText(ad->hwndFrame, s);
|
---|
1881 | rc = DosCreateMutexSem(NULL, &ad->ScanSem, 0L, FALSE);
|
---|
1882 | if (rc)
|
---|
1883 | Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
|
---|
1884 | PCSZ_DOSCREATEMUTEXSEM);
|
---|
1885 | else {
|
---|
1886 | PFNWP oldproc;
|
---|
1887 | HWND hwndFrame = ad->hwndFrame;
|
---|
1888 |
|
---|
1889 | WinSendMsg(ad->hvscroll,
|
---|
1890 | SBM_SETSCROLLBAR, MPFROMSHORT(1), MPFROM2SHORT(1, 1));
|
---|
1891 | WinSendMsg(ad->hhscroll, SBM_SETSCROLLBAR, MPFROMSHORT(1),
|
---|
1892 | MPFROM2SHORT(1, 1));
|
---|
1893 | ad->hwndStatus1 = WinCreateWindow(hwndFrame,
|
---|
1894 | WC_VIEWSTATUS,
|
---|
1895 | GetPString(IDS_LOADINGTEXT),
|
---|
1896 | WS_VISIBLE | SS_TEXT |
|
---|
1897 | DT_LEFT | DT_VCENTER,
|
---|
1898 | 0,
|
---|
1899 | 0,
|
---|
1900 | 0,
|
---|
1901 | 0,
|
---|
1902 | hwndFrame,
|
---|
1903 | HWND_TOP,
|
---|
1904 | NEWVIEW_STATUS1, NULL, NULL);
|
---|
1905 | if (!ad->hwndStatus1)
|
---|
1906 | Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
|
---|
1907 | PCSZ_WINCREATEWINDOW);
|
---|
1908 |
|
---|
1909 | ad->hwndStatus2 = WinCreateWindow(hwndFrame,
|
---|
1910 | WC_VIEWSTATUS,
|
---|
1911 | NULL,
|
---|
1912 | WS_VISIBLE | SS_TEXT |
|
---|
1913 | DT_LEFT | DT_VCENTER,
|
---|
1914 | 0,
|
---|
1915 | 0,
|
---|
1916 | 0,
|
---|
1917 | 0,
|
---|
1918 | hwndFrame,
|
---|
1919 | HWND_TOP,
|
---|
1920 | NEWVIEW_STATUS2, NULL, NULL);
|
---|
1921 | if (!ad->hwndStatus2)
|
---|
1922 | Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
|
---|
1923 | PCSZ_WINCREATEWINDOW);
|
---|
1924 |
|
---|
1925 | ad->hwndStatus3 = WinCreateWindow(hwndFrame,
|
---|
1926 | WC_VIEWSTATUS,
|
---|
1927 | NULL,
|
---|
1928 | WS_VISIBLE | SS_TEXT |
|
---|
1929 | DT_LEFT | DT_VCENTER,
|
---|
1930 | 0,
|
---|
1931 | 0,
|
---|
1932 | 0,
|
---|
1933 | 0,
|
---|
1934 | hwndFrame,
|
---|
1935 | HWND_TOP,
|
---|
1936 | NEWVIEW_STATUS3, NULL, NULL);
|
---|
1937 | if (!ad->hwndStatus3)
|
---|
1938 | Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
|
---|
1939 | PCSZ_WINCREATEWINDOW);
|
---|
1940 |
|
---|
1941 | ad->hwndListbox = WinCreateWindow(hwndFrame,
|
---|
1942 | WC_LISTBOX,
|
---|
1943 | NULL,
|
---|
1944 | LS_NOADJUSTPOS,
|
---|
1945 | 0,
|
---|
1946 | 0,
|
---|
1947 | 0,
|
---|
1948 | 0,
|
---|
1949 | hwndFrame,
|
---|
1950 | HWND_TOP,
|
---|
1951 | NEWVIEW_LISTBOX, NULL, NULL);
|
---|
1952 | if (!ad->hwndListbox)
|
---|
1953 | Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
|
---|
1954 | PCSZ_WINCREATEWINDOW);
|
---|
1955 |
|
---|
1956 | ad->hwndDrag = WinCreateWindow(hwndFrame,
|
---|
1957 | WC_VIEWSTATUS,
|
---|
1958 | "#100",
|
---|
1959 | WS_VISIBLE | SS_BITMAP,
|
---|
1960 | 0,
|
---|
1961 | 0,
|
---|
1962 | 0,
|
---|
1963 | 0,
|
---|
1964 | hwndFrame,
|
---|
1965 | HWND_TOP, NEWVIEW_DRAG, NULL, NULL);
|
---|
1966 | if (!ad->hwndDrag)
|
---|
1967 | Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
|
---|
1968 | PCSZ_WINCREATEWINDOW);
|
---|
1969 |
|
---|
1970 | oldproc = WinSubclassWindow(hwndFrame, ViewFrameWndProc);
|
---|
1971 | WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
|
---|
1972 | ad->hps = InitWindow(hwnd);
|
---|
1973 | if (xbeginthread(LoadFileThread,
|
---|
1974 | 524288,
|
---|
1975 | (PVOID)hwnd,
|
---|
1976 | pszSrcFile,
|
---|
1977 | __LINE__) != -1)
|
---|
1978 | {
|
---|
1979 | WinSendMsg(hwnd, UM_SETUP5, MPVOID, MPVOID);
|
---|
1980 | DosSleep(16); //05 Aug 07 GKY 32
|
---|
1981 | return (MRESULT) 1;
|
---|
1982 | }
|
---|
1983 | }
|
---|
1984 | }
|
---|
1985 | // Oops
|
---|
1986 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
|
---|
1987 | return 0;
|
---|
1988 |
|
---|
1989 | case UM_SETUP5:
|
---|
1990 | if (ad) {
|
---|
1991 | if (ad->hwndFrame ==
|
---|
1992 | WinQueryActiveWindow(WinQueryWindow(ad->hwndFrame,
|
---|
1993 | QW_PARENT)) &&
|
---|
1994 | !ParentIsDesktop(ad->hwndFrame, (HWND) 0)) {
|
---|
1995 | if (hwndStatus2)
|
---|
1996 | WinSetWindowText(hwndStatus2,
|
---|
1997 | (*ad->filename) ?
|
---|
1998 | ad->filename : GetPString(IDS_UNTITLEDTEXT));
|
---|
1999 | if (fMoreButtons) {
|
---|
2000 | WinSetWindowText(hwndName,
|
---|
2001 | (*ad->filename) ?
|
---|
2002 | ad->filename : GetPString(IDS_UNTITLEDTEXT));
|
---|
2003 | WinSetWindowText(hwndDate, NullStr);
|
---|
2004 | WinSetWindowText(hwndAttr, NullStr);
|
---|
2005 | }
|
---|
2006 | if (hwndStatus)
|
---|
2007 | WinSetWindowText(hwndStatus,
|
---|
2008 | GetPString(IDS_INTERNALVIEWERTITLETEXT));
|
---|
2009 | }
|
---|
2010 | }
|
---|
2011 | return 0;
|
---|
2012 |
|
---|
2013 | case DM_DISCARDOBJECT:
|
---|
2014 | case DM_PRINTOBJECT:
|
---|
2015 | return MRFROMLONG(DRR_TARGET);
|
---|
2016 |
|
---|
2017 | case UM_RESCAN:
|
---|
2018 | if (ad) {
|
---|
2019 | if (!ad->busy && !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
2020 | if (ad->numlines) {
|
---|
2021 |
|
---|
2022 | CHAR s[80], tb[34], tl[34];
|
---|
2023 |
|
---|
2024 | commafmt(tb, sizeof(tb), ad->textsize);
|
---|
2025 | commafmt(tl, sizeof(tl), ad->numlines);
|
---|
2026 | sprintf(s,
|
---|
2027 | " %s %s%s %s %s%s",
|
---|
2028 | tb,
|
---|
2029 | GetPString(IDS_BYTETEXT),
|
---|
2030 | &"s"[ad->textsize == 1],
|
---|
2031 | tl, GetPString(IDS_LINETEXT), &"s"[ad->numlines == 1]);
|
---|
2032 | WinSetWindowText(ad->hwndStatus1, s);
|
---|
2033 | }
|
---|
2034 | else
|
---|
2035 | WinSetWindowText(ad->hwndStatus1, GetPString(IDS_NVNOLINESTEXT));
|
---|
2036 | DosReleaseMutexSem(ad->ScanSem);
|
---|
2037 | }
|
---|
2038 | else
|
---|
2039 | WinSetWindowText(ad->hwndStatus1, GetPString(IDS_WORKINGTEXT));
|
---|
2040 | }
|
---|
2041 | return 0;
|
---|
2042 |
|
---|
2043 | case UM_SETUP2:
|
---|
2044 | /**
|
---|
2045 | * calculate width of client in characters, recalc lines if
|
---|
2046 | * oldwidth != newwidth, set ad->oldwidth for later comparison
|
---|
2047 | */
|
---|
2048 | if (ad) {
|
---|
2049 |
|
---|
2050 | BOOL invalidate = FALSE;
|
---|
2051 |
|
---|
2052 | if (ad->wrapon || ad->hex) { // GKY reverse case where hscroll bar is presnt
|
---|
2053 | if (WinQueryWindow(ad->hhscroll, QW_PARENT) == ad->hwndFrame) {
|
---|
2054 | invalidate = TRUE;
|
---|
2055 | WinSetOwner(ad->hhscroll, HWND_OBJECT);
|
---|
2056 | WinSetParent(ad->hhscroll, HWND_OBJECT, TRUE);
|
---|
2057 | ad->maxx = 0;
|
---|
2058 | ad->horzscroll = 0;
|
---|
2059 | }
|
---|
2060 | }
|
---|
2061 | else {
|
---|
2062 | if (WinQueryWindow(ad->hhscroll, QW_PARENT) != ad->hwndFrame) {
|
---|
2063 | invalidate = TRUE;
|
---|
2064 | WinSetOwner(ad->hhscroll, ad->hwndFrame);
|
---|
2065 | WinSetParent(ad->hhscroll, ad->hwndFrame, TRUE);
|
---|
2066 | }
|
---|
2067 | }
|
---|
2068 | if (invalidate) {
|
---|
2069 | WinSendMsg(ad->hwndFrame, WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER),
|
---|
2070 | MPVOID);
|
---|
2071 | WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
2072 | NEWVIEW_DRAG), NULL, FALSE);
|
---|
2073 | WinInvalidateRect(ad->hhscroll, NULL, FALSE);
|
---|
2074 | }
|
---|
2075 | }
|
---|
2076 |
|
---|
2077 | if (ad && !ad->busy &&
|
---|
2078 | !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
2079 |
|
---|
2080 | RECTL rcl;
|
---|
2081 | ULONG newwidth;
|
---|
2082 |
|
---|
2083 | WinQueryWindowRect(hwnd, &rcl);
|
---|
2084 | newwidth = (rcl.xRight - rcl.xLeft) / ad->fattrs.lAveCharWidth;
|
---|
2085 | if ((!ad->hex || ad->oldwidth == -1) &&
|
---|
2086 | newwidth != ad->oldwidth && ad->text && ad->textsize) {
|
---|
2087 | ad->oldwidth = newwidth;
|
---|
2088 | if (!ad->relining) {
|
---|
2089 | if (xbeginthread(ReLineThread,
|
---|
2090 | 524288,
|
---|
2091 | (PVOID)hwnd,
|
---|
2092 | pszSrcFile,
|
---|
2093 | __LINE__) == -1)
|
---|
2094 | {
|
---|
2095 | DosReleaseMutexSem(ad->ScanSem);
|
---|
2096 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
|
---|
2097 | return 0;
|
---|
2098 | }
|
---|
2099 | }
|
---|
2100 | }
|
---|
2101 | ad->oldwidth = newwidth;
|
---|
2102 | DosReleaseMutexSem(ad->ScanSem);
|
---|
2103 | }
|
---|
2104 | return MRFROMLONG(TRUE);
|
---|
2105 |
|
---|
2106 | case WM_CHAR:
|
---|
2107 | shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
2108 | if (ad && !ad->busy && !(SHORT1FROMMP(mp1) & KC_KEYUP) &&
|
---|
2109 | !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
2110 |
|
---|
2111 | ULONG numlines, wascursored = ad->cursored;
|
---|
2112 | RECTL rcl;
|
---|
2113 |
|
---|
2114 | WinQueryWindowRect(hwnd, &rcl);
|
---|
2115 | numlines = NumLines(&rcl, ad);
|
---|
2116 | if (numlines) {
|
---|
2117 | if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
|
---|
2118 | switch (SHORT2FROMMP(mp2)) {
|
---|
2119 | case VK_LEFT:
|
---|
2120 | WinSendMsg(hwnd, WM_HSCROLL, MPFROM2SHORT(FID_HORZSCROLL, 0),
|
---|
2121 | MPFROM2SHORT(0, SB_LINELEFT));
|
---|
2122 | break;
|
---|
2123 | case VK_RIGHT:
|
---|
2124 | WinSendMsg(hwnd, WM_HSCROLL, MPFROM2SHORT(FID_HORZSCROLL, 0),
|
---|
2125 | MPFROM2SHORT(0, SB_LINERIGHT));
|
---|
2126 | break;
|
---|
2127 | case VK_PAGEUP:
|
---|
2128 | PostMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
|
---|
2129 | MPFROM2SHORT(0, SB_PAGEUP));
|
---|
2130 | break;
|
---|
2131 | case VK_PAGEDOWN:
|
---|
2132 | PostMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
|
---|
2133 | MPFROM2SHORT(0, SB_PAGEDOWN));
|
---|
2134 | break;
|
---|
2135 | case VK_UP:
|
---|
2136 | if (ad->cursored > 1) {
|
---|
2137 | if (shiftstate & KC_SHIFT)
|
---|
2138 | WinSendMsg(hwnd, WM_BUTTON1CLICK,
|
---|
2139 | MPFROM2SHORT(ad->fattrs.lAveCharWidth + 2,
|
---|
2140 | ((rcl.yTop - (ad->lMaxHeight *
|
---|
2141 | ((ad->cursored) -
|
---|
2142 | ad->topline))) -
|
---|
2143 | ad->lMaxDescender) - 1),
|
---|
2144 | MPFROM2SHORT(TRUE, 0));
|
---|
2145 | ad->cursored--;
|
---|
2146 | if (ad->cursored < ad->topline) {
|
---|
2147 | PaintLine(hwnd, ad->hps, ad->cursored, ad->topline, &rcl);
|
---|
2148 | WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
|
---|
2149 | MPFROM2SHORT(0, SB_LINEUP));
|
---|
2150 | }
|
---|
2151 | else {
|
---|
2152 | PaintLine(hwnd, ad->hps, ad->cursored - 1, ad->topline, &rcl);
|
---|
2153 | PaintLine(hwnd, ad->hps, ad->cursored, ad->topline, &rcl);
|
---|
2154 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
2155 | }
|
---|
2156 | }
|
---|
2157 | break;
|
---|
2158 | case VK_DOWN:
|
---|
2159 | if (ad->cursored < ad->numlines &&
|
---|
2160 | ad->cursored < ad->topline + numlines) {
|
---|
2161 | if (shiftstate & KC_SHIFT)
|
---|
2162 | WinSendMsg(hwnd, WM_BUTTON1CLICK,
|
---|
2163 | MPFROM2SHORT(ad->fattrs.lAveCharWidth + 2,
|
---|
2164 | ((rcl.yTop - (ad->lMaxHeight *
|
---|
2165 | ((ad->cursored) -
|
---|
2166 | ad->topline))) -
|
---|
2167 | ad->lMaxDescender) - 1),
|
---|
2168 | MPFROM2SHORT(TRUE, 0));
|
---|
2169 | ad->cursored++;
|
---|
2170 | if (ad->cursored >= ad->topline + numlines) {
|
---|
2171 | PaintLine(hwnd, ad->hps, ad->cursored - 2, ad->topline, &rcl);
|
---|
2172 | WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
|
---|
2173 | MPFROM2SHORT(0, SB_LINEDOWN));
|
---|
2174 | }
|
---|
2175 | else {
|
---|
2176 | PaintLine(hwnd, ad->hps, ad->cursored - 1, ad->topline, &rcl);
|
---|
2177 | PaintLine(hwnd, ad->hps, ad->cursored - 2, ad->topline, &rcl);
|
---|
2178 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
2179 | }
|
---|
2180 | }
|
---|
2181 | break;
|
---|
2182 | case VK_END:
|
---|
2183 | if ((shiftstate & KC_CTRL) ||
|
---|
2184 | ad->cursored == (ad->topline - 1) + numlines) {
|
---|
2185 | ad->cursored = ad->numlines;
|
---|
2186 | ad->topline = (ad->numlines + 1) - numlines;
|
---|
2187 | if (ad->topline > ad->numlines)
|
---|
2188 | ad->topline = 1;
|
---|
2189 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
2190 | }
|
---|
2191 | else {
|
---|
2192 | ad->cursored = (ad->topline - 1) + numlines;
|
---|
2193 | if (ad->cursored > ad->numlines)
|
---|
2194 | ad->cursored = ad->numlines;
|
---|
2195 | PaintLine(hwnd, ad->hps, ad->cursored - 1, ad->topline, &rcl);
|
---|
2196 | PaintLine(hwnd, ad->hps, wascursored - 1, ad->topline, &rcl);
|
---|
2197 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
2198 | }
|
---|
2199 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
2200 | break;
|
---|
2201 | case VK_HOME:
|
---|
2202 | if ((shiftstate & KC_CTRL) || ad->cursored == ad->topline) {
|
---|
2203 | ad->topline = 1;
|
---|
2204 | ad->cursored = 1;
|
---|
2205 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
2206 | }
|
---|
2207 | else {
|
---|
2208 | ad->cursored = ad->topline;
|
---|
2209 | PaintLine(hwnd, ad->hps, ad->cursored - 1, ad->topline, &rcl);
|
---|
2210 | PaintLine(hwnd, ad->hps, wascursored - 1, ad->topline, &rcl);
|
---|
2211 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
2212 | }
|
---|
2213 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
2214 | break;
|
---|
2215 | case VK_SPACE:
|
---|
2216 | WinSendMsg(hwnd, WM_BUTTON1CLICK,
|
---|
2217 | MPFROM2SHORT(ad->fattrs.lAveCharWidth + 2,
|
---|
2218 | ((rcl.yTop - (ad->lMaxHeight *
|
---|
2219 | ((ad->cursored) -
|
---|
2220 | ad->topline))) -
|
---|
2221 | ad->lMaxDescender) - 1),
|
---|
2222 | MPFROM2SHORT(TRUE, 0));
|
---|
2223 | break;
|
---|
2224 | case VK_NEWLINE:
|
---|
2225 | case VK_ENTER:
|
---|
2226 | WinSendMsg(hwnd, WM_BUTTON1DBLCLK,
|
---|
2227 | MPFROM2SHORT(ad->fattrs.lAveCharWidth + 2,
|
---|
2228 | ((rcl.yTop - (ad->lMaxHeight *
|
---|
2229 | ((ad->cursored) -
|
---|
2230 | ad->topline))) -
|
---|
2231 | ad->lMaxDescender) - 1), MPFROM2SHORT(0,
|
---|
2232 | 0));
|
---|
2233 | break;
|
---|
2234 | }
|
---|
2235 | }
|
---|
2236 | else if (SHORT1FROMMP(mp1) & KC_CHAR) {
|
---|
2237 | switch (SHORT1FROMMP(mp2)) {
|
---|
2238 | case '\r':
|
---|
2239 | case '\n':
|
---|
2240 | WinSendMsg(hwnd, WM_BUTTON1DBLCLK,
|
---|
2241 | MPFROM2SHORT(ad->fattrs.lAveCharWidth + 2,
|
---|
2242 | (rcl.yTop - (ad->lMaxHeight *
|
---|
2243 | ((ad->cursored) -
|
---|
2244 | ad->topline))) - 1),
|
---|
2245 | MPFROM2SHORT(0, 0));
|
---|
2246 | break;
|
---|
2247 | default:
|
---|
2248 | break;
|
---|
2249 | }
|
---|
2250 | }
|
---|
2251 | if (wascursored != ad->cursored)
|
---|
2252 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
2253 | }
|
---|
2254 | DosReleaseMutexSem(ad->ScanSem);
|
---|
2255 | }
|
---|
2256 | break;
|
---|
2257 |
|
---|
2258 | case WM_BUTTON1MOTIONSTART:
|
---|
2259 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
2260 | if (ad && !ad->stopflag && !ad->busy &&
|
---|
2261 | !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
2262 | ad->mousecaptured = TRUE;
|
---|
2263 | ad->lastselected = ULONG_MAX;
|
---|
2264 | ad->lastdirection = 0;
|
---|
2265 | WinSetCapture(HWND_DESKTOP, hwnd);
|
---|
2266 | WinSendMsg(hwnd, WM_BUTTON1CLICK, mp1, MPFROM2SHORT(TRUE, 0));
|
---|
2267 | }
|
---|
2268 | break;
|
---|
2269 |
|
---|
2270 | case WM_MOUSEMOVE:
|
---|
2271 | shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
|
---|
2272 | if (ad && ad->mousecaptured) {
|
---|
2273 |
|
---|
2274 | ULONG numlines, whichline, x;
|
---|
2275 | LONG inc;
|
---|
2276 | RECTL Rectl;
|
---|
2277 | POINTS pts;
|
---|
2278 | BOOL outofwindow = FALSE;
|
---|
2279 |
|
---|
2280 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
2281 | numlines = NumLines(&Rectl, ad);
|
---|
2282 | if (numlines) {
|
---|
2283 | pts.x = SHORT1FROMMP(mp1);
|
---|
2284 | pts.y = SHORT2FROMMP(mp1);
|
---|
2285 | if (pts.y < 0) {
|
---|
2286 | WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
|
---|
2287 | MPFROM2SHORT(0, SB_LINEDOWN));
|
---|
2288 | pts.y = 1;
|
---|
2289 | outofwindow = TRUE;
|
---|
2290 | }
|
---|
2291 | else if (pts.y > Rectl.yTop - Rectl.yBottom) {
|
---|
2292 | WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
|
---|
2293 | MPFROM2SHORT(0, SB_LINEUP));
|
---|
2294 | pts.y = (Rectl.yTop - Rectl.yBottom) - 1;
|
---|
2295 | outofwindow = TRUE;
|
---|
2296 | }
|
---|
2297 | whichline = ((Rectl.yTop - Rectl.yBottom) -
|
---|
2298 | ((LONG) pts.y + ad->lMaxDescender)) / ad->lMaxHeight;
|
---|
2299 | if (whichline > numlines - 1)
|
---|
2300 | whichline = numlines - 1;
|
---|
2301 | whichline += (ad->topline - 1);
|
---|
2302 | if (whichline < ad->numlines && ad->lastselected != whichline) {
|
---|
2303 | if (ad->lastselected != ULONG_MAX) {
|
---|
2304 | inc = (ad->lastselected < whichline) ? 1 : -1;
|
---|
2305 | for (x = ad->lastselected + inc;
|
---|
2306 | x != whichline && x < ad->numlines;
|
---|
2307 | (ad->lastselected < whichline) ? x++ : x--) {
|
---|
2308 | if (ad->markedlines) {
|
---|
2309 | if (ad->markedlines[x] & VF_SELECTED) {
|
---|
2310 | ad->markedlines[x] &= (~VF_SELECTED);
|
---|
2311 | ad->selected--;
|
---|
2312 | }
|
---|
2313 | else {
|
---|
2314 | ad->markedlines[x] |= VF_SELECTED;
|
---|
2315 | ad->selected++;
|
---|
2316 | }
|
---|
2317 | }
|
---|
2318 | PaintLine(hwnd, ad->hps, x, ad->topline, &Rectl);
|
---|
2319 | }
|
---|
2320 | WinSendMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
2321 | }
|
---|
2322 | WinSendMsg(hwnd, WM_BUTTON1CLICK, MPFROM2SHORT(pts.x, pts.y),
|
---|
2323 | MPFROM2SHORT(TRUE, 0));
|
---|
2324 | }
|
---|
2325 | }
|
---|
2326 | if (outofwindow) {
|
---|
2327 |
|
---|
2328 | POINTL ptl;
|
---|
2329 |
|
---|
2330 | WinQueryPointerPos(HWND_DESKTOP, &ptl);
|
---|
2331 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1L);
|
---|
2332 | if ((SHORT) ptl.y == (SHORT) SHORT2FROMMP(mp1) &&
|
---|
2333 | (SHORT) ptl.x == (SHORT) SHORT1FROMMP(mp1) &&
|
---|
2334 | ((SHORT) ptl.y < 0 || ptl.y > (Rectl.yTop - Rectl.yBottom))) {
|
---|
2335 | PostMsg(hwnd, UM_MOUSEMOVE, mp1, MPVOID);
|
---|
2336 | DosSleep(1);
|
---|
2337 | }
|
---|
2338 | }
|
---|
2339 | }
|
---|
2340 | break;
|
---|
2341 |
|
---|
2342 | case UM_MOUSEMOVE:
|
---|
2343 | if (ad && ad->mousecaptured) {
|
---|
2344 |
|
---|
2345 | POINTL ptl;
|
---|
2346 | RECTL Rectl;
|
---|
2347 |
|
---|
2348 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
2349 | WinQueryPointerPos(HWND_DESKTOP, &ptl);
|
---|
2350 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
|
---|
2351 | if ((SHORT) ptl.y == (SHORT) SHORT2FROMMP(mp1) &&
|
---|
2352 | (SHORT) ptl.x == (SHORT) SHORT1FROMMP(mp1) &&
|
---|
2353 | ((SHORT) ptl.y < 0 || ptl.y > (Rectl.yTop - Rectl.yBottom))) {
|
---|
2354 | DosSleep(1);
|
---|
2355 | PostMsg(hwnd, WM_MOUSEMOVE, mp1, MPFROM2SHORT(TRUE, 0));
|
---|
2356 | }
|
---|
2357 | }
|
---|
2358 | return 0;
|
---|
2359 |
|
---|
2360 | case WM_BUTTON1UP:
|
---|
2361 | case WM_BUTTON1MOTIONEND:
|
---|
2362 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
2363 | if (ad && ad->mousecaptured) {
|
---|
2364 | ad->mousecaptured = FALSE;
|
---|
2365 | ad->lastselected = ULONG_MAX;
|
---|
2366 | ad->lastdirection = 0;
|
---|
2367 | DosReleaseMutexSem(ad->ScanSem);
|
---|
2368 | WinSetCapture(HWND_DESKTOP, NULLHANDLE);
|
---|
2369 | }
|
---|
2370 | break;
|
---|
2371 |
|
---|
2372 | case WM_BUTTON1DBLCLK:
|
---|
2373 | case WM_BUTTON1CLICK:
|
---|
2374 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
2375 | if (ad && !ad->stopflag && ad->numlines && ad->text && !ad->busy &&
|
---|
2376 | !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
2377 |
|
---|
2378 | ULONG numlines, whichline, wascursored, width;
|
---|
2379 | RECTL Rectl;
|
---|
2380 | POINTS pts;
|
---|
2381 |
|
---|
2382 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
2383 | numlines = NumLines(&Rectl, ad);
|
---|
2384 | if (!numlines)
|
---|
2385 | break;
|
---|
2386 | pts.x = SHORT1FROMMP(mp1);
|
---|
2387 | pts.y = SHORT2FROMMP(mp1);
|
---|
2388 | whichline = ((Rectl.yTop - Rectl.yBottom) -
|
---|
2389 | ((LONG) pts.y + ad->lMaxDescender)) / ad->lMaxHeight;
|
---|
2390 | if (whichline > numlines - 1)
|
---|
2391 | whichline = numlines - 1;
|
---|
2392 | whichline += (ad->topline - 1);
|
---|
2393 | if (whichline + 1 > ad->numlines)
|
---|
2394 | break;
|
---|
2395 | wascursored = ad->cursored;
|
---|
2396 | ad->cursored = whichline + 1;
|
---|
2397 | if (msg == WM_BUTTON1CLICK) {
|
---|
2398 | if (ad->lastselected != ULONG_MAX) {
|
---|
2399 | if (whichline > ad->lastselected)
|
---|
2400 | ad->lastdirection = 1;
|
---|
2401 | else
|
---|
2402 | ad->lastdirection = 2;
|
---|
2403 | }
|
---|
2404 | else
|
---|
2405 | ad->lastdirection = 0;
|
---|
2406 | ad->lastselected = whichline;
|
---|
2407 | if (whichline < ad->numlines) {
|
---|
2408 | if (ad->markedlines) {
|
---|
2409 | if (ad->markedlines[whichline] & VF_SELECTED) {
|
---|
2410 | ad->selected--;
|
---|
2411 | ad->markedlines[whichline] &= (~VF_SELECTED);
|
---|
2412 | }
|
---|
2413 | else {
|
---|
2414 | ad->selected++;
|
---|
2415 | ad->markedlines[whichline] |= VF_SELECTED;
|
---|
2416 | }
|
---|
2417 | }
|
---|
2418 | WinSendMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
2419 | }
|
---|
2420 | PaintLine(hwnd, ad->hps, whichline, ad->topline, &Rectl);
|
---|
2421 | if (ad->cursored != wascursored) {
|
---|
2422 | PaintLine(hwnd, ad->hps, wascursored - 1, ad->topline, &Rectl);
|
---|
2423 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
2424 | }
|
---|
2425 | }
|
---|
2426 | else {
|
---|
2427 |
|
---|
2428 | SHORT numsels, sSelect = 0, numinserted;
|
---|
2429 | ULONG linenum, size;
|
---|
2430 |
|
---|
2431 | if (!ad->hex && ad->lines) {
|
---|
2432 |
|
---|
2433 | CHAR *p, *e;
|
---|
2434 |
|
---|
2435 | width = (Rectl.xRight - Rectl.xLeft) / ad->fattrs.lAveCharWidth;
|
---|
2436 | e = p = ad->lines[whichline];
|
---|
2437 | while (*e != '\r' && *e != '\n' && e < ad->text + ad->textsize) {
|
---|
2438 | if (ad->wrapon && e - p == width)
|
---|
2439 | break;
|
---|
2440 | e++;
|
---|
2441 | }
|
---|
2442 | if ((*e == '\r' || *e == '\n') && e > p)
|
---|
2443 | e--;
|
---|
2444 | width = e - p;
|
---|
2445 | if (!width)
|
---|
2446 | goto NoAdd;
|
---|
2447 |
|
---|
2448 | if ((ad->httpin && (*httprun || fHttpRunWPSDefault) &&
|
---|
2449 | strnstr(ad->lines[whichline], "http://", width)) ||
|
---|
2450 | (ad->ftpin && (*ftprun || fFtpRunWPSDefault) &&
|
---|
2451 | strnstr(ad->lines[whichline], "ftp://", width)) ||
|
---|
2452 | (ad->mailin && *mailrun && mailstr(ad->lines[whichline], "@", width))) {
|
---|
2453 |
|
---|
2454 | USHORT ret;
|
---|
2455 | URLDATA *urld;
|
---|
2456 |
|
---|
2457 | urld = xmallocz(sizeof(URLDATA), pszSrcFile, __LINE__);
|
---|
2458 | if (urld) {
|
---|
2459 | urld->size = sizeof(URLDATA);
|
---|
2460 | urld->line = ad->lines[whichline];
|
---|
2461 | urld->len = width;
|
---|
2462 | ret = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, UrlDlgProc,
|
---|
2463 | FM3ModHandle, URL_FRAME, urld);
|
---|
2464 | switch (ret) {
|
---|
2465 | case 0:
|
---|
2466 | free(urld);
|
---|
2467 | goto NoAdd;
|
---|
2468 | case 1:
|
---|
2469 | if (*urld->url) {
|
---|
2470 | if (fHttpRunWPSDefault) {
|
---|
2471 | CHAR WPSDefaultHttpRun[CCHMAXPATH], WPSDefaultHttpRunDir[CCHMAXPATH];
|
---|
2472 |
|
---|
2473 | size = sizeof(WPSDefaultHttpRun);
|
---|
2474 | PrfQueryProfileData(HINI_USERPROFILE, PCSZ_WPURLDEFAULTSETTINGS,
|
---|
2475 | "DefaultBrowserExe", WPSDefaultHttpRun, &size);
|
---|
2476 | size = sizeof(WPSDefaultHttpRunDir);
|
---|
2477 | PrfQueryProfileData(HINI_USERPROFILE, PCSZ_WPURLDEFAULTSETTINGS,
|
---|
2478 | "DefaultWorkingDir", WPSDefaultHttpRunDir, &size);
|
---|
2479 | runemf2(SEPARATE | WINDOWED,
|
---|
2480 | hwnd, pszSrcFile, __LINE__,
|
---|
2481 | WPSDefaultHttpRunDir,
|
---|
2482 | fLibPathStrictHttpRun ? pLibPathStrict : NULL,
|
---|
2483 | "%s %s", WPSDefaultHttpRun, urld->url);
|
---|
2484 | }
|
---|
2485 | else
|
---|
2486 | runemf2(SEPARATE | WINDOWED,
|
---|
2487 | hwnd, pszSrcFile, __LINE__,
|
---|
2488 | httprundir,
|
---|
2489 | fLibPathStrictHttpRun ? pLibPathStrict : NULL,
|
---|
2490 | "%s %s", httprun, urld->url);
|
---|
2491 | }
|
---|
2492 | free(urld);
|
---|
2493 | goto NoAdd;
|
---|
2494 | case 2:
|
---|
2495 | if (*urld->url){
|
---|
2496 | if (fFtpRunWPSDefault) {
|
---|
2497 | CHAR WPSDefaultFtpRun[CCHMAXPATH], WPSDefaultFtpRunDir[CCHMAXPATH];
|
---|
2498 |
|
---|
2499 | size = sizeof(WPSDefaultFtpRun);
|
---|
2500 | PrfQueryProfileData(HINI_USERPROFILE, PCSZ_WPURLDEFAULTSETTINGS,
|
---|
2501 | "DefaultBrowserExe", WPSDefaultFtpRun, &size);
|
---|
2502 | size = sizeof(WPSDefaultFtpRunDir);
|
---|
2503 | PrfQueryProfileData(HINI_USERPROFILE, PCSZ_WPURLDEFAULTSETTINGS,
|
---|
2504 | "DefaultWorkingDir", WPSDefaultFtpRunDir, &size);
|
---|
2505 | runemf2(SEPARATE | WINDOWED,
|
---|
2506 | hwnd, pszSrcFile, __LINE__,
|
---|
2507 | WPSDefaultFtpRunDir,
|
---|
2508 | fLibPathStrictFtpRun ? pLibPathStrict : NULL,
|
---|
2509 | "%s %s", WPSDefaultFtpRun, urld->url);
|
---|
2510 | }
|
---|
2511 | else
|
---|
2512 | runemf2(SEPARATE | WINDOWED,
|
---|
2513 | hwnd, pszSrcFile, __LINE__,
|
---|
2514 | ftprundir,
|
---|
2515 | fLibPathStrictFtpRun ? pLibPathStrict : NULL,
|
---|
2516 | "%s %s", ftprun, urld->url);
|
---|
2517 | }
|
---|
2518 | free(urld);
|
---|
2519 | goto NoAdd;
|
---|
2520 | case 3:
|
---|
2521 | if (*urld->url){
|
---|
2522 | runemf2(SEPARATE | WINDOWED,
|
---|
2523 | hwnd, pszSrcFile, __LINE__,
|
---|
2524 | mailrundir,
|
---|
2525 | fLibPathStrictMailRun ? pLibPathStrict : NULL,
|
---|
2526 | "%s %s", mailrun, urld->url);
|
---|
2527 | }
|
---|
2528 | free(urld);
|
---|
2529 | goto NoAdd;
|
---|
2530 | default:
|
---|
2531 | break;
|
---|
2532 | }
|
---|
2533 | free(urld);
|
---|
2534 | }
|
---|
2535 | }
|
---|
2536 | }
|
---|
2537 | //Move line to selection box at top of viewer
|
---|
2538 | numsels = (SHORT) WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
|
---|
2539 | LM_QUERYITEMCOUNT, MPVOID,
|
---|
2540 | MPVOID);
|
---|
2541 | if (numsels > 0) {
|
---|
2542 | for (sSelect = 0; sSelect < numsels; sSelect++) {
|
---|
2543 | linenum =
|
---|
2544 | (ULONG) WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
|
---|
2545 | LM_QUERYITEMHANDLE,
|
---|
2546 | MPFROM2SHORT(sSelect, 0), MPVOID);
|
---|
2547 | if (linenum == whichline)
|
---|
2548 | goto NoAdd;
|
---|
2549 | }
|
---|
2550 | }
|
---|
2551 | {
|
---|
2552 | CHAR *s = NULL, *p;
|
---|
2553 |
|
---|
2554 | if (!ad->hex && ad->lines) {
|
---|
2555 | s = xmalloc(width + 2, pszSrcFile, __LINE__);
|
---|
2556 | if (!s)
|
---|
2557 | goto NoAdd;
|
---|
2558 | strncpy(s, ad->lines[whichline], width + 1);
|
---|
2559 | s[width + 1] = 0;
|
---|
2560 | p = s;
|
---|
2561 | while (*p) {
|
---|
2562 | if (*p == '\r' || *p == '\n') {
|
---|
2563 | *p = 0;
|
---|
2564 | break;
|
---|
2565 | }
|
---|
2566 | p++;
|
---|
2567 | }
|
---|
2568 | }
|
---|
2569 | else {
|
---|
2570 |
|
---|
2571 | register ULONG x;
|
---|
2572 |
|
---|
2573 | width = ad->textsize - (whichline * 16);
|
---|
2574 | width = min(width, 16); //standard hexx line length
|
---|
2575 | //use 80 as width * 5 gives inconsistent format on short lines
|
---|
2576 | s = xmalloc(80, pszSrcFile, __LINE__);
|
---|
2577 | if (!s)
|
---|
2578 | goto NoAdd;
|
---|
2579 | sprintf(s, "%08lx ", whichline * 16);
|
---|
2580 | p = s + 9;
|
---|
2581 | for (x = 0; x < width; x++) {
|
---|
2582 | sprintf(p, " %02x", (UCHAR)ad->text[(whichline * 16) + x]);
|
---|
2583 | p += 3;
|
---|
2584 | }
|
---|
2585 | *p = ' ';
|
---|
2586 | p++;
|
---|
2587 | *p = ' ';
|
---|
2588 | p++;
|
---|
2589 | for (x = 0; x < width; x++) {
|
---|
2590 | *p = ad->text[(whichline * 16) + x];
|
---|
2591 | p++;
|
---|
2592 | }
|
---|
2593 | *p = 0;
|
---|
2594 | }
|
---|
2595 | if (s) {
|
---|
2596 | if (*s) {
|
---|
2597 | ad->dummy = TRUE;
|
---|
2598 | numinserted = (SHORT) WinSendDlgItemMsg(ad->hwndFrame,
|
---|
2599 | NEWVIEW_LISTBOX,
|
---|
2600 | LM_INSERTITEM,
|
---|
2601 | MPFROM2SHORT(LIT_END,
|
---|
2602 | 0),
|
---|
2603 | MPFROMP(s));
|
---|
2604 | ad->dummy = FALSE;
|
---|
2605 | if (numinserted >= 0)
|
---|
2606 | WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
|
---|
2607 | LM_SETITEMHANDLE,
|
---|
2608 | MPFROM2SHORT(numinserted, 0),
|
---|
2609 | MPFROMLONG(whichline));
|
---|
2610 | }
|
---|
2611 | free(s);
|
---|
2612 | }
|
---|
2613 | }
|
---|
2614 | if (!numsels)
|
---|
2615 | WinSendMsg(ad->hwndFrame, WM_UPDATEFRAME,
|
---|
2616 | MPFROMLONG(FCF_SIZEBORDER), MPVOID);
|
---|
2617 | }
|
---|
2618 | NoAdd:
|
---|
2619 | DosReleaseMutexSem(ad->ScanSem);
|
---|
2620 | DosPostEventSem(CompactSem);
|
---|
2621 | }
|
---|
2622 | break;
|
---|
2623 |
|
---|
2624 | case WM_MENUEND:
|
---|
2625 | if (ad && ad->hwndPopup == (HWND) mp2) {
|
---|
2626 | WinDestroyWindow(ad->hwndPopup);
|
---|
2627 | ad->hwndPopup = (HWND) 0;
|
---|
2628 | }
|
---|
2629 | break;
|
---|
2630 |
|
---|
2631 | case UM_CONTEXTMENU:
|
---|
2632 | case WM_CONTEXTMENU:
|
---|
2633 | if (ad) {
|
---|
2634 | if (!ad->hwndPopup) {
|
---|
2635 | ad->hwndPopup =
|
---|
2636 | WinLoadMenu(HWND_DESKTOP, FM3ModHandle, NEWVIEW_POPUP);
|
---|
2637 | if (ad->hwndPopup)
|
---|
2638 | //fixme to allow user to change presparams 1-10-09 GKY
|
---|
2639 | WinSetPresParam(ad->hwndPopup,
|
---|
2640 | PP_FONTNAMESIZE,
|
---|
2641 | strlen(FNT_8HELVETICA) + 1,
|
---|
2642 | (PVOID) FNT_8HELVETICA);
|
---|
2643 | }
|
---|
2644 | if (ad->hwndPopup) {
|
---|
2645 |
|
---|
2646 | APIRET rc;
|
---|
2647 | SHORT sSelect;
|
---|
2648 |
|
---|
2649 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
2650 | WinEnableMenuItem(ad->hwndPopup, IDM_SAVETOCLIP, (rc == 0 &&
|
---|
2651 | ad->selected != 0));
|
---|
2652 | WinEnableMenuItem(ad->hwndPopup, IDM_APPENDTOCLIP, (rc == 0 &&
|
---|
2653 | ad->selected !=
|
---|
2654 | 0));
|
---|
2655 | WinEnableMenuItem(ad->hwndPopup, IDM_SAVETOLIST,
|
---|
2656 | (rc == 0 && ad->selected != 0));
|
---|
2657 | sSelect =
|
---|
2658 | (SHORT) WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
|
---|
2659 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
2660 | WinEnableMenuItem(ad->hwndPopup, IDM_SAVETOCLIP2,
|
---|
2661 | (rc == 0 && sSelect > 0));
|
---|
2662 | WinEnableMenuItem(ad->hwndPopup, IDM_APPENDTOCLIP2,
|
---|
2663 | (rc == 0 && sSelect > 0));
|
---|
2664 | WinEnableMenuItem(ad->hwndPopup, IDM_SAVETOLIST2,
|
---|
2665 | (rc == 0 && sSelect > 0));
|
---|
2666 | WinEnableMenuItem(ad->hwndPopup, IDM_SELECTALL,
|
---|
2667 | (rc == 0 && ad->numlines != 0 && ad->markedlines));
|
---|
2668 | WinEnableMenuItem(ad->hwndPopup, IDM_DESELECTALL,
|
---|
2669 | (rc == 0 && ad->numlines != 0 && ad->markedlines
|
---|
2670 | && ad->selected != 0));
|
---|
2671 | WinEnableMenuItem(ad->hwndPopup, IDM_PREVSELECTED,
|
---|
2672 | (rc == 0 && ad->numlines != 0 && ad->markedlines
|
---|
2673 | && ad->selected != 0));
|
---|
2674 | WinEnableMenuItem(ad->hwndPopup, IDM_NEXTSELECTED,
|
---|
2675 | (rc == 0 && ad->numlines != 0 && ad->markedlines
|
---|
2676 | && ad->selected != 0));
|
---|
2677 | WinEnableMenuItem(ad->hwndPopup, IDM_SELECTFOUND,
|
---|
2678 | (rc == 0 && ad->numlines != 0 && ad->markedlines
|
---|
2679 | && ad->found != 0));
|
---|
2680 | WinEnableMenuItem(ad->hwndPopup, IDM_DESELECTFOUND,
|
---|
2681 | (rc == 0 && ad->numlines != 0 && ad->markedlines
|
---|
2682 | && ad->selected != 0 && ad->found != 0));
|
---|
2683 | WinEnableMenuItem(ad->hwndPopup, IDM_INVERT,
|
---|
2684 | (rc == 0 && ad->numlines != 0 && ad->markedlines));
|
---|
2685 | WinEnableMenuItem(ad->hwndPopup, IDM_FINDFIRST,
|
---|
2686 | (rc == 0 && ad->numlines != 0 && ad->markedlines));
|
---|
2687 | WinEnableMenuItem(ad->hwndPopup, IDM_FINDNEXT,
|
---|
2688 | (rc == 0 && ad->numlines != 0 && ad->markedlines
|
---|
2689 | && ad->found));
|
---|
2690 | WinEnableMenuItem(ad->hwndPopup, IDM_FINDPREV,
|
---|
2691 | (rc == 0 && ad->numlines != 0 && ad->markedlines
|
---|
2692 | && ad->found));
|
---|
2693 | WinEnableMenuItem(ad->hwndPopup, IDM_GOTOLINE,
|
---|
2694 | (rc == 0 && ad->numlines != 0));
|
---|
2695 | WinEnableMenuItem(ad->hwndPopup, IDM_GOTOOFFSET,
|
---|
2696 | (rc == 0 && ad->textsize != 0));
|
---|
2697 | if (!rc)
|
---|
2698 | DosReleaseMutexSem(ad->ScanSem);
|
---|
2699 | PopupMenu(hwnd, hwnd, ad->hwndPopup);
|
---|
2700 | }
|
---|
2701 | }
|
---|
2702 | break;
|
---|
2703 |
|
---|
2704 | case UM_SETUP3:
|
---|
2705 | if (ad && !ad->busy &&
|
---|
2706 | !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
2707 | ad->multiplier = ad->numlines / 32767;
|
---|
2708 | if (ad->multiplier * 32767 != ad->numlines)
|
---|
2709 | ad->multiplier++;
|
---|
2710 | if (!ad->multiplier)
|
---|
2711 | ad->multiplier++;
|
---|
2712 | {
|
---|
2713 | RECTL Rectl;
|
---|
2714 | ULONG numlines;
|
---|
2715 |
|
---|
2716 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
2717 | numlines = NumLines(&Rectl, ad);
|
---|
2718 | if (numlines) {
|
---|
2719 | WinSendMsg(ad->hhscroll, SBM_SETTHUMBSIZE,
|
---|
2720 | MPFROM2SHORT((SHORT) Rectl.xRight, (SHORT) ad->maxx),
|
---|
2721 | MPVOID);
|
---|
2722 | WinSendMsg(ad->hvscroll, SBM_SETTHUMBSIZE,
|
---|
2723 | MPFROM2SHORT((SHORT) numlines,
|
---|
2724 | (SHORT) min(ad->numlines, 32767)), MPVOID);
|
---|
2725 | if (ad->multiplier)
|
---|
2726 | WinSendMsg(ad->hvscroll, SBM_SETSCROLLBAR,
|
---|
2727 | MPFROMSHORT((SHORT) (ad->topline / ad->multiplier)),
|
---|
2728 | MPFROM2SHORT(1, (SHORT) ((ad->numlines + 1) /
|
---|
2729 | ad->multiplier) - numlines));
|
---|
2730 | WinSendMsg(ad->hhscroll, SBM_SETSCROLLBAR,
|
---|
2731 | MPFROMSHORT((SHORT) abs(ad->horzscroll)),
|
---|
2732 | MPFROM2SHORT(0, (SHORT) (ad->maxx - Rectl.xRight)));
|
---|
2733 | if (ad->numlines - ad->topline < numlines) {
|
---|
2734 | ad->topline = ((ad->numlines - ad->topline) - numlines);
|
---|
2735 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
2736 | }
|
---|
2737 | }
|
---|
2738 | }
|
---|
2739 | DosReleaseMutexSem(ad->ScanSem);
|
---|
2740 | }
|
---|
2741 | return 0;
|
---|
2742 |
|
---|
2743 | case UM_SETUP4:
|
---|
2744 | if (ad && !ad->busy &&
|
---|
2745 | !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
2746 |
|
---|
2747 | CHAR s[140], t[34];
|
---|
2748 | ULONG numlines;
|
---|
2749 | RECTL Rectl;
|
---|
2750 |
|
---|
2751 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
2752 | numlines = NumLines(&Rectl, ad);
|
---|
2753 | commafmt(t, sizeof(t), ad->cursored);
|
---|
2754 | strcpy(s, GetPString(IDS_LINECOLONTEXT));
|
---|
2755 | strcat(s, t);
|
---|
2756 | if (ad->selected) {
|
---|
2757 | if (ad->selected > ad->numlines)
|
---|
2758 | ad->selected = 0;
|
---|
2759 | else {
|
---|
2760 | commafmt(t, sizeof(t), ad->selected);
|
---|
2761 | strcat(s, " (");
|
---|
2762 | strcat(s, t);
|
---|
2763 | strcat(s, GetPString(IDS_SELECTEDPARENTEXT));
|
---|
2764 | }
|
---|
2765 | }
|
---|
2766 | if (ad->found) {
|
---|
2767 | if (ad->found > ad->numlines)
|
---|
2768 | ad->found = 0;
|
---|
2769 | else {
|
---|
2770 | commafmt(t, sizeof(t), ad->found);
|
---|
2771 | strcat(s, " (");
|
---|
2772 | strcat(s, t);
|
---|
2773 | strcat(s, GetPString(IDS_FOUNDPARENTEXT));
|
---|
2774 | }
|
---|
2775 | }
|
---|
2776 | WinSetWindowText(ad->hwndStatus2, s);
|
---|
2777 | if (!ad->hex && ad->lines)
|
---|
2778 | commafmt(t, sizeof(t), ad->lines[ad->cursored - 1] - ad->text);
|
---|
2779 | else
|
---|
2780 | commafmt(t, sizeof(t), (ad->cursored - 1) * 16);
|
---|
2781 | strcpy(s, GetPString(IDS_OFFSETCOLONTEXT));
|
---|
2782 | strcat(s, t);
|
---|
2783 | WinSetWindowText(ad->hwndStatus3, s);
|
---|
2784 | if (ad->multiplier)
|
---|
2785 | WinSendMsg(ad->hvscroll, SBM_SETSCROLLBAR,
|
---|
2786 | MPFROMSHORT((SHORT) (ad->topline / ad->multiplier)),
|
---|
2787 | MPFROM2SHORT(1, (SHORT) ((ad->numlines + 1) /
|
---|
2788 | ad->multiplier) - numlines));
|
---|
2789 | WinSendMsg(ad->hhscroll, SBM_SETSCROLLBAR,
|
---|
2790 | MPFROMSHORT((SHORT) abs(ad->horzscroll)),
|
---|
2791 | MPFROM2SHORT(0, (SHORT) (ad->maxx - Rectl.xRight)));
|
---|
2792 | DosReleaseMutexSem(ad->ScanSem);
|
---|
2793 | }
|
---|
2794 | return 0;
|
---|
2795 |
|
---|
2796 | case UM_CONTAINER_FILLED:
|
---|
2797 | if (ad && !ad->busy &&
|
---|
2798 | !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
2799 | ad->stopflag = 0;
|
---|
2800 | ad->topline = 1;
|
---|
2801 | ad->cursored = 1;
|
---|
2802 | ad->multiplier = 1;
|
---|
2803 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
2804 | WinEnableWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
2805 | IDM_NEXTBLANKLINE), !ad->hex);
|
---|
2806 | WinEnableWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
2807 | IDM_PREVBLANKLINE), !ad->hex);
|
---|
2808 | if (ad->numlines)
|
---|
2809 | {
|
---|
2810 | if (mp1 && (ULONG) mp1 < ad->numlines + 1) {
|
---|
2811 |
|
---|
2812 | RECTL Rectl;
|
---|
2813 | ULONG numlines;
|
---|
2814 |
|
---|
2815 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
2816 | numlines = NumLines(&Rectl, ad);
|
---|
2817 | if (numlines) {
|
---|
2818 | ad->topline = (ULONG) mp1;
|
---|
2819 | if (ad->numlines - ad->topline < numlines)
|
---|
2820 | ad->topline = ad->numlines - numlines;
|
---|
2821 | ad->cursored = (ULONG) mp1;
|
---|
2822 | if (mp2) {
|
---|
2823 | ad->cursored = (ULONG) mp2;
|
---|
2824 | if (ad->cursored > (ad->topline - 1) + numlines)
|
---|
2825 | ad->cursored = (ad->topline - 1) + numlines;
|
---|
2826 | }
|
---|
2827 | }
|
---|
2828 | }
|
---|
2829 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
---|
2830 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
2831 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
2832 | }
|
---|
2833 | DosReleaseMutexSem(ad->ScanSem);
|
---|
2834 | }
|
---|
2835 | else if (ad)
|
---|
2836 | ad->needrefreshing = TRUE;
|
---|
2837 | return 0;
|
---|
2838 |
|
---|
2839 | case WM_ERASEBACKGROUND:
|
---|
2840 | WinFillRect((HPS) mp1, (PRECTL) mp2,
|
---|
2841 | standardcolors[ad->colors[COLORS_NORMALBACK]]);
|
---|
2842 | return 0;
|
---|
2843 |
|
---|
2844 | case WM_PAINT:
|
---|
2845 | if (ad) {
|
---|
2846 |
|
---|
2847 | HPS hpsp;
|
---|
2848 | RECTL Rectl;
|
---|
2849 | register ULONG x;
|
---|
2850 | ULONG numlines, wascursored = ad->cursored;
|
---|
2851 |
|
---|
2852 | hpsp = WinBeginPaint(hwnd, ad->hps, &Rectl);
|
---|
2853 | WinFillRect(hpsp, &Rectl,
|
---|
2854 | standardcolors[ad->colors[COLORS_NORMALBACK]]);
|
---|
2855 | if (!ad->stopflag && !ad->busy &&
|
---|
2856 | !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
2857 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
2858 | numlines = NumLines(&Rectl, ad);
|
---|
2859 | if (numlines) {
|
---|
2860 | if (ad->numlines && (ad->lines || ad->hex)) {
|
---|
2861 | if (ad->topline > (ad->numlines + 1) - numlines)
|
---|
2862 | ad->topline = (ad->numlines + 1) - numlines;
|
---|
2863 | if (ad->topline > ad->numlines)
|
---|
2864 | ad->topline = 1;
|
---|
2865 | if (!ad->topline)
|
---|
2866 | ad->topline = 1;
|
---|
2867 | if (ad->cursored < ad->topline)
|
---|
2868 | ad->cursored = ad->topline;
|
---|
2869 | else if (ad->cursored > (ad->topline + numlines) - 1)
|
---|
2870 | ad->cursored = (ad->topline + numlines) - 1;
|
---|
2871 | if (ad->cursored > ad->numlines)
|
---|
2872 | ad->cursored = ad->numlines;
|
---|
2873 | if (wascursored != ad->cursored)
|
---|
2874 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
2875 | }
|
---|
2876 | else
|
---|
2877 | ad->topline = ad->cursored = 1;
|
---|
2878 | if (ad->numlines && (ad->lines || ad->hex)) {
|
---|
2879 | for (x = ad->topline - 1; x < ad->numlines; x++) {
|
---|
2880 | if (((LONG) (Rectl.yTop -
|
---|
2881 | (ad->lMaxHeight *
|
---|
2882 | (((x + 1) - ad->topline) + 1))) -
|
---|
2883 | ad->lMaxDescender) <= 0)
|
---|
2884 | break;
|
---|
2885 | PaintLine(hwnd, hpsp, x, ad->topline, &Rectl);
|
---|
2886 | }
|
---|
2887 | }
|
---|
2888 | }
|
---|
2889 | if (ad->multiplier)
|
---|
2890 | WinSendMsg(ad->hvscroll, SBM_SETSCROLLBAR,
|
---|
2891 | MPFROMSHORT((SHORT) (ad->topline / ad->multiplier)),
|
---|
2892 | MPFROM2SHORT(1, (SHORT) ((ad->numlines + 1) /
|
---|
2893 | ad->multiplier) - numlines));
|
---|
2894 | WinSendMsg(ad->hhscroll, SBM_SETSCROLLBAR,
|
---|
2895 | MPFROMSHORT((SHORT) abs(ad->horzscroll)),
|
---|
2896 | MPFROM2SHORT(0, (SHORT) (ad->maxx - Rectl.xRight)));
|
---|
2897 | WinSendMsg(ad->hhscroll, SBM_SETTHUMBSIZE,
|
---|
2898 | MPFROM2SHORT((SHORT) Rectl.xRight, (SHORT) ad->maxx),
|
---|
2899 | MPVOID);
|
---|
2900 | DosReleaseMutexSem(ad->ScanSem);
|
---|
2901 | ad->needrefreshing = FALSE;
|
---|
2902 | }
|
---|
2903 | else
|
---|
2904 | ad->needrefreshing = TRUE;
|
---|
2905 | WinEndPaint(hpsp);
|
---|
2906 | }
|
---|
2907 | else {
|
---|
2908 |
|
---|
2909 | HPS hpsp;
|
---|
2910 |
|
---|
2911 | hpsp = WinBeginPaint(hwnd, (HPS) 0, NULL);
|
---|
2912 | WinEndPaint(hpsp);
|
---|
2913 | }
|
---|
2914 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
2915 | break;
|
---|
2916 |
|
---|
2917 | case WM_HSCROLL:
|
---|
2918 | {
|
---|
2919 | RECTL rectl;
|
---|
2920 | BOOL invalidate = TRUE;
|
---|
2921 |
|
---|
2922 | WinQueryWindowRect(hwnd, &rectl);
|
---|
2923 | switch (SHORT2FROMMP(mp2)) {
|
---|
2924 | case SB_PAGERIGHT:
|
---|
2925 | if (abs(ad->horzscroll) <= ad->maxx - rectl.xRight) {
|
---|
2926 | ad->horzscroll -= rectl.xRight;
|
---|
2927 | if (abs(ad->horzscroll) > ad->maxx - rectl.xRight)
|
---|
2928 | ad->horzscroll = -((ad->maxx - rectl.xRight) +
|
---|
2929 | ad->fattrs.lAveCharWidth);
|
---|
2930 | }
|
---|
2931 | else
|
---|
2932 | invalidate = FALSE;
|
---|
2933 | break;
|
---|
2934 |
|
---|
2935 | case SB_PAGELEFT:
|
---|
2936 | if (ad->horzscroll < 0) {
|
---|
2937 | ad->horzscroll += rectl.xRight;
|
---|
2938 | if (ad->horzscroll > 0)
|
---|
2939 | ad->horzscroll = 0;
|
---|
2940 | }
|
---|
2941 | else
|
---|
2942 | invalidate = FALSE;
|
---|
2943 | break;
|
---|
2944 |
|
---|
2945 | case SB_LINERIGHT:
|
---|
2946 | if (abs(ad->horzscroll) <= ad->maxx - rectl.xRight)
|
---|
2947 | ad->horzscroll -= ad->fattrs.lAveCharWidth;
|
---|
2948 | else
|
---|
2949 | invalidate = FALSE;
|
---|
2950 | break;
|
---|
2951 |
|
---|
2952 | case SB_LINELEFT:
|
---|
2953 | if (ad->horzscroll < 0)
|
---|
2954 | ad->horzscroll += ad->fattrs.lAveCharWidth;
|
---|
2955 | else
|
---|
2956 | invalidate = FALSE;
|
---|
2957 | break;
|
---|
2958 |
|
---|
2959 | case SB_SLIDERTRACK:
|
---|
2960 | ad->horzscroll = (SHORT1FROMMP(mp2) / ad->fattrs.lAveCharWidth) *
|
---|
2961 | ad->fattrs.lAveCharWidth;
|
---|
2962 | ad->horzscroll = -(ad->horzscroll);
|
---|
2963 | if (ad->horzscroll > 0)
|
---|
2964 | ad->horzscroll = 0;
|
---|
2965 | if (abs(ad->horzscroll) > (ad->maxx - rectl.xRight) +
|
---|
2966 | ad->fattrs.lAveCharWidth)
|
---|
2967 | ad->horzscroll = -(ad->maxx - rectl.xRight);
|
---|
2968 | break;
|
---|
2969 |
|
---|
2970 | default:
|
---|
2971 | invalidate = FALSE;
|
---|
2972 | break;
|
---|
2973 | }
|
---|
2974 | if (invalidate)
|
---|
2975 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
2976 | }
|
---|
2977 | break;
|
---|
2978 |
|
---|
2979 | case WM_VSCROLL:
|
---|
2980 | if (ad && !ad->stopflag && ad->text && ad->numlines && !ad->busy &&
|
---|
2981 | !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
2982 |
|
---|
2983 | ULONG numlines, wascursored;
|
---|
2984 | RECTL rcl;
|
---|
2985 |
|
---|
2986 | WinQueryWindowRect(hwnd, &rcl);
|
---|
2987 | numlines = NumLines(&rcl, ad);
|
---|
2988 | if (numlines) {
|
---|
2989 | wascursored = ad->cursored;
|
---|
2990 | switch (SHORT2FROMMP(mp2)) {
|
---|
2991 | case SB_PAGEUP:
|
---|
2992 | if (ad->topline > 1) {
|
---|
2993 | ad->topline -= numlines;
|
---|
2994 | if (ad->topline > ad->numlines ||
|
---|
2995 | ad->topline + numlines > (ad->numlines + 1))
|
---|
2996 | ad->topline = 1;
|
---|
2997 | if (ad->cursored > ad->topline + numlines)
|
---|
2998 | ad->cursored = ad->topline + numlines;
|
---|
2999 | if (ad->cursored > ad->numlines)
|
---|
3000 | ad->cursored = ad->numlines;
|
---|
3001 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3002 | }
|
---|
3003 | break;
|
---|
3004 | case SB_PAGEDOWN:
|
---|
3005 | if (ad->topline + numlines <= ad->numlines) {
|
---|
3006 | ad->topline += numlines;
|
---|
3007 | if (ad->topline + numlines > ad->numlines + 1)
|
---|
3008 | ad->topline = (ad->numlines + 1) - numlines;
|
---|
3009 | if (ad->cursored < ad->topline)
|
---|
3010 | ad->cursored = ad->topline;
|
---|
3011 | if (ad->cursored + 1 > ad->topline + numlines)
|
---|
3012 | ad->cursored = (ad->topline + numlines) - 1;
|
---|
3013 | if (ad->cursored > ad->numlines)
|
---|
3014 | ad->cursored = ad->numlines;
|
---|
3015 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3016 | }
|
---|
3017 | break;
|
---|
3018 | case SB_LINEDOWN:
|
---|
3019 | if (ad->topline + numlines <= ad->numlines) {
|
---|
3020 |
|
---|
3021 | RECTL Rectl, iRectl;
|
---|
3022 |
|
---|
3023 | ad->topline++;
|
---|
3024 | if (ad->cursored < ad->topline)
|
---|
3025 | ad->cursored = ad->topline;
|
---|
3026 | else if (ad->cursored + 1 > ad->topline + numlines)
|
---|
3027 | ad->cursored = (ad->topline + numlines) - 1;
|
---|
3028 | if (ad->cursored > ad->numlines)
|
---|
3029 | ad->cursored = ad->numlines;
|
---|
3030 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
3031 | WinScrollWindow(hwnd, 0, ad->lMaxHeight,
|
---|
3032 | NULL, NULL, NULLHANDLE, &iRectl, 0);
|
---|
3033 | WinFillRect(ad->hps, &iRectl,
|
---|
3034 | standardcolors[ad->colors[COLORS_NORMALBACK]]);
|
---|
3035 | PaintLine(hwnd, ad->hps, (ad->topline + numlines) - 2,
|
---|
3036 | ad->topline, &Rectl);
|
---|
3037 | if (ad->cursored != ad->topline + numlines)
|
---|
3038 | PaintLine(hwnd, ad->hps, ad->cursored - 1, ad->topline, &Rectl);
|
---|
3039 | if (wascursored != ad->cursored &&
|
---|
3040 | wascursored < ad->topline + numlines &&
|
---|
3041 | wascursored >= ad->topline)
|
---|
3042 | PaintLine(hwnd, ad->hps, wascursored - 1, ad->topline, &Rectl);
|
---|
3043 | if (numlines >= ad->numlines)
|
---|
3044 | numlines = 0;
|
---|
3045 | if (ad->multiplier)
|
---|
3046 | WinSendMsg(ad->hvscroll, SBM_SETSCROLLBAR,
|
---|
3047 | MPFROMSHORT((SHORT) (ad->topline / ad->multiplier)),
|
---|
3048 | MPFROM2SHORT(1, (SHORT) ((ad->numlines + 1) /
|
---|
3049 | ad->multiplier) -
|
---|
3050 | numlines));
|
---|
3051 | WinSendMsg(ad->hhscroll, SBM_SETSCROLLBAR,
|
---|
3052 | MPFROMSHORT((SHORT) abs(ad->horzscroll)),
|
---|
3053 | MPFROM2SHORT(0, (SHORT) (ad->maxx - Rectl.xRight)));
|
---|
3054 | }
|
---|
3055 | break;
|
---|
3056 | case SB_LINEUP:
|
---|
3057 | if (ad->topline > 1) {
|
---|
3058 |
|
---|
3059 | RECTL Rectl, iRectl;
|
---|
3060 |
|
---|
3061 | ad->topline--;
|
---|
3062 | if (ad->cursored < ad->topline)
|
---|
3063 | ad->cursored = ad->topline;
|
---|
3064 | else if (ad->cursored + 1 > ad->topline + numlines)
|
---|
3065 | ad->cursored = (ad->topline + numlines) - 1;
|
---|
3066 | if (ad->cursored > ad->numlines)
|
---|
3067 | ad->cursored = ad->numlines;
|
---|
3068 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
3069 | WinScrollWindow(hwnd, 0, -ad->lMaxHeight,
|
---|
3070 | NULL, NULL, NULLHANDLE, &iRectl, 0);
|
---|
3071 | WinFillRect(ad->hps, &iRectl,
|
---|
3072 | standardcolors[ad->colors[COLORS_NORMALBACK]]);
|
---|
3073 | iRectl = Rectl;
|
---|
3074 | iRectl.yTop -= ((numlines * ad->lMaxHeight) + ad->lMaxDescender);
|
---|
3075 | WinFillRect(ad->hps, &iRectl,
|
---|
3076 | standardcolors[ad->colors[COLORS_NORMALBACK]]);
|
---|
3077 | PaintLine(hwnd, ad->hps, ad->topline - 1, ad->topline, &Rectl);
|
---|
3078 | if (ad->cursored != ad->topline)
|
---|
3079 | PaintLine(hwnd, ad->hps, ad->cursored - 1, ad->topline, &Rectl);
|
---|
3080 | if (ad->cursored != wascursored &&
|
---|
3081 | wascursored >= ad->topline &&
|
---|
3082 | wascursored < ad->topline + numlines)
|
---|
3083 | PaintLine(hwnd, ad->hps, wascursored - 1, ad->topline, &Rectl);
|
---|
3084 | if (numlines >= ad->numlines)
|
---|
3085 | numlines = 0;
|
---|
3086 | if (ad->multiplier)
|
---|
3087 | WinSendMsg(ad->hvscroll, SBM_SETSCROLLBAR,
|
---|
3088 | MPFROMSHORT((SHORT) (ad->topline / ad->multiplier)),
|
---|
3089 | MPFROM2SHORT(1, (SHORT) ((ad->numlines + 1) /
|
---|
3090 | ad->multiplier) -
|
---|
3091 | numlines));
|
---|
3092 | WinSendMsg(ad->hhscroll, SBM_SETSCROLLBAR,
|
---|
3093 | MPFROMSHORT((SHORT) abs(ad->horzscroll)),
|
---|
3094 | MPFROM2SHORT(0, (SHORT) (ad->maxx - Rectl.xRight)));
|
---|
3095 | }
|
---|
3096 | break;
|
---|
3097 | case SB_SLIDERTRACK:
|
---|
3098 | if ((SHORT1FROMMP(mp2) >= 1) || (SHORT1FROMMP(mp2)) <= ad->numlines) {
|
---|
3099 | ad->topline = (ULONG) SHORT1FROMMP(mp2) * ad->multiplier;
|
---|
3100 | if (ad->topline + numlines > ad->numlines + 1)
|
---|
3101 | ad->topline = (ad->numlines + 1) - numlines;
|
---|
3102 | if (!ad->topline)
|
---|
3103 | ad->topline = 1;
|
---|
3104 | if (ad->cursored < ad->topline)
|
---|
3105 | ad->cursored = ad->topline;
|
---|
3106 | else if (ad->cursored > ad->topline + numlines)
|
---|
3107 | ad->cursored = ad->topline + numlines;
|
---|
3108 | if (ad->cursored > ad->numlines)
|
---|
3109 | ad->cursored = ad->numlines;
|
---|
3110 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3111 | }
|
---|
3112 | else
|
---|
3113 | WinAlarm(HWND_DESKTOP, WA_NOTE);
|
---|
3114 | break;
|
---|
3115 | }
|
---|
3116 | if (ad->cursored != wascursored)
|
---|
3117 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
3118 | }
|
---|
3119 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3120 | }
|
---|
3121 | break;
|
---|
3122 |
|
---|
3123 | case WM_INITMENU:
|
---|
3124 | switch (SHORT1FROMMP(mp1)) {
|
---|
3125 | case IDM_FILESMENU:
|
---|
3126 | {
|
---|
3127 | APIRET rc;
|
---|
3128 | SHORT sSelect;
|
---|
3129 |
|
---|
3130 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3131 | WinEnableMenuItem((HWND) mp2, IDM_SAVETOCLIP, (rc == 0 &&
|
---|
3132 | ad->selected != 0));
|
---|
3133 | WinEnableMenuItem((HWND) mp2, IDM_APPENDTOCLIP, (rc == 0 &&
|
---|
3134 | ad->selected != 0));
|
---|
3135 | WinEnableMenuItem((HWND) mp2, IDM_SAVETOLIST, (rc == 0 &&
|
---|
3136 | ad->selected != 0));
|
---|
3137 | sSelect = (SHORT) WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
|
---|
3138 | LM_QUERYITEMCOUNT, MPVOID,
|
---|
3139 | MPVOID);
|
---|
3140 | WinEnableMenuItem((HWND) mp2, IDM_SAVETOCLIP2,
|
---|
3141 | (rc == 0 && sSelect > 0));
|
---|
3142 | WinEnableMenuItem((HWND) mp2, IDM_APPENDTOCLIP2,
|
---|
3143 | (rc == 0 && sSelect > 0));
|
---|
3144 | WinEnableMenuItem((HWND) mp2, IDM_SAVETOLIST2,
|
---|
3145 | (rc == 0 && sSelect > 0));
|
---|
3146 | if (!rc)
|
---|
3147 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3148 | }
|
---|
3149 | break;
|
---|
3150 |
|
---|
3151 | case IDM_VIEWSMENU:
|
---|
3152 | {
|
---|
3153 | APIRET rc;
|
---|
3154 |
|
---|
3155 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3156 | WinEnableMenuItem((HWND) mp2, IDM_FONTPALETTE, (rc == 0));
|
---|
3157 | WinEnableMenuItem((HWND) mp2, IDM_HEXMODE, (rc == 0));
|
---|
3158 | WinEnableMenuItem((HWND) mp2, IDM_WRAP, (rc == 0));
|
---|
3159 | WinEnableMenuItem((HWND) mp2, IDM_CODEPAGE, (rc == 0));
|
---|
3160 | if (!rc)
|
---|
3161 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3162 | }
|
---|
3163 | WinCheckMenuItem((HWND) mp2, IDM_HEXMODE, ad->hex);
|
---|
3164 | WinCheckMenuItem((HWND) mp2, IDM_WRAP, ad->wrapon);
|
---|
3165 | WinCheckMenuItem((HWND) mp2, IDM_IGNOREFTP, ad->ignoreftp);
|
---|
3166 | WinCheckMenuItem((HWND) mp2, IDM_IGNOREHTTP, ad->ignorehttp);
|
---|
3167 | WinCheckMenuItem((HWND) mp2, IDM_IGNOREMAIL, ad->ignoremail);
|
---|
3168 | break;
|
---|
3169 |
|
---|
3170 | case IDM_SEARCHMENU:
|
---|
3171 | {
|
---|
3172 | APIRET rc;
|
---|
3173 |
|
---|
3174 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3175 | WinEnableMenuItem((HWND) mp2, IDM_FINDFIRST, (rc == 0 &&
|
---|
3176 | ad->numlines != 0 &&
|
---|
3177 | ad->markedlines));
|
---|
3178 | WinEnableMenuItem((HWND) mp2, IDM_FINDNEXT, (rc == 0 &&
|
---|
3179 | ad->numlines != 0 &&
|
---|
3180 | ad->markedlines &&
|
---|
3181 | ad->found != 0));
|
---|
3182 | WinEnableMenuItem((HWND) mp2, IDM_FINDPREV, (rc == 0 &&
|
---|
3183 | ad->numlines != 0 &&
|
---|
3184 | ad->markedlines &&
|
---|
3185 | ad->found != 0));
|
---|
3186 | WinEnableMenuItem((HWND) mp2, IDM_NEXTBLANKLINE, (rc == 0 &&
|
---|
3187 | ad->numlines != 0 &&
|
---|
3188 | !ad->hex));
|
---|
3189 | WinEnableMenuItem((HWND) mp2, IDM_PREVBLANKLINE, (rc == 0 &&
|
---|
3190 | ad->numlines != 0 &&
|
---|
3191 | !ad->hex));
|
---|
3192 | WinEnableMenuItem((HWND) mp2, IDM_GOTOLINE, (rc == 0 &&
|
---|
3193 | ad->numlines != 0));
|
---|
3194 | WinEnableMenuItem((HWND) mp2, IDM_GOTOOFFSET, (rc == 0 &&
|
---|
3195 | ad->textsize != 0));
|
---|
3196 | if (!rc)
|
---|
3197 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3198 | }
|
---|
3199 | break;
|
---|
3200 |
|
---|
3201 | case IDM_SELECTSUBMENU:
|
---|
3202 | {
|
---|
3203 | APIRET rc;
|
---|
3204 |
|
---|
3205 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3206 | WinEnableMenuItem((HWND) mp2, IDM_SELECTALL, (rc == 0 &&
|
---|
3207 | ad->numlines != 0 &&
|
---|
3208 | ad->markedlines &&
|
---|
3209 | (ad->selected !=
|
---|
3210 | ad->numlines ||
|
---|
3211 | !ad->selected)));
|
---|
3212 | WinEnableMenuItem((HWND) mp2, IDM_DESELECTALL, (rc == 0 &&
|
---|
3213 | ad->numlines != 0 &&
|
---|
3214 | ad->markedlines &&
|
---|
3215 | ad->selected != 0));
|
---|
3216 | WinEnableMenuItem((HWND) mp2, IDM_DESELECTFOUND, (rc == 0 &&
|
---|
3217 | ad->numlines != 0 &&
|
---|
3218 | ad->markedlines &&
|
---|
3219 | ad->selected != 0 &&
|
---|
3220 | ad->found != 0));
|
---|
3221 | WinEnableMenuItem((HWND) mp2, IDM_SELECTFOUND, (rc == 0 &&
|
---|
3222 | ad->numlines != 0 &&
|
---|
3223 | ad->markedlines &&
|
---|
3224 | ad->found != 0 &&
|
---|
3225 | (ad->numlines !=
|
---|
3226 | ad->selected ||
|
---|
3227 | !ad->selected)));
|
---|
3228 | WinEnableMenuItem((HWND) mp2, IDM_NEXTSELECTED, (rc == 0 &&
|
---|
3229 | ad->numlines != 0 &&
|
---|
3230 | ad->markedlines &&
|
---|
3231 | ad->selected != 0));
|
---|
3232 | WinEnableMenuItem((HWND) mp2, IDM_PREVSELECTED, (rc == 0 &&
|
---|
3233 | ad->numlines != 0 &&
|
---|
3234 | ad->markedlines &&
|
---|
3235 | ad->selected != 0));
|
---|
3236 | WinEnableMenuItem((HWND) mp2, IDM_INVERT, (rc == 0 &&
|
---|
3237 | ad->numlines != 0 &&
|
---|
3238 | ad->markedlines));
|
---|
3239 | if (!rc)
|
---|
3240 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3241 | }
|
---|
3242 | break;
|
---|
3243 | }
|
---|
3244 | break;
|
---|
3245 |
|
---|
3246 | case UM_CONTROL:
|
---|
3247 | switch (SHORT1FROMMP(mp1)) {
|
---|
3248 | case NEWVIEW_LISTBOX:
|
---|
3249 | switch (SHORT2FROMMP(mp1)) {
|
---|
3250 | case LN_SETFOCUS:
|
---|
3251 | if (ad) {
|
---|
3252 | if (!ad->clientfocused) {
|
---|
3253 | PostMsg(hwnd,
|
---|
3254 | WM_COMMAND, MPFROM2SHORT(IDM_NEXTWINDOW, 0), MPVOID);
|
---|
3255 | break;
|
---|
3256 | }
|
---|
3257 | ad->clientfocused = FALSE;
|
---|
3258 | }
|
---|
3259 | PostMsg(hwnd,
|
---|
3260 | UM_CONTROL, MPFROM2SHORT(NEWVIEW_LISTBOX, LN_SELECT), MPVOID);
|
---|
3261 | break;
|
---|
3262 | case LN_KILLFOCUS:
|
---|
3263 | if (ad) {
|
---|
3264 | ad->clientfocused = TRUE;
|
---|
3265 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
3266 | }
|
---|
3267 | break;
|
---|
3268 | case LN_SELECT:
|
---|
3269 | if (ad && !ad->dummy) {
|
---|
3270 |
|
---|
3271 | ULONG linenum, numlines;
|
---|
3272 | SHORT sSelect;
|
---|
3273 | HWND hwndUL = WinWindowFromID(ad->hwndFrame,
|
---|
3274 | SHORT1FROMMP(mp1));
|
---|
3275 | RECTL Rectl;
|
---|
3276 |
|
---|
3277 | sSelect = (SHORT) WinSendMsg(hwndUL,
|
---|
3278 | LM_QUERYSELECTION,
|
---|
3279 | MPFROM2SHORT(LIT_FIRST, 0), MPVOID);
|
---|
3280 | if (sSelect >= 0) {
|
---|
3281 | linenum = (ULONG) WinSendMsg(hwndUL,
|
---|
3282 | LM_QUERYITEMHANDLE,
|
---|
3283 | MPFROM2SHORT(sSelect, 0), MPVOID);
|
---|
3284 | if (ad->topline != linenum + 1 && linenum < ad->numlines) {
|
---|
3285 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
3286 | numlines = NumLines(&Rectl, ad);
|
---|
3287 | ad->topline = linenum + 1;
|
---|
3288 | if (ad->numlines - ad->topline < numlines)
|
---|
3289 | ad->topline = ad->numlines - numlines;
|
---|
3290 | ad->cursored = linenum + 1;
|
---|
3291 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3292 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
3293 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
3294 | }
|
---|
3295 | }
|
---|
3296 | else
|
---|
3297 | PostMsg(hwndUL, LM_SELECTITEM, MPFROM2SHORT(0, 0),
|
---|
3298 | MPFROM2SHORT(TRUE, 0));
|
---|
3299 | }
|
---|
3300 | break;
|
---|
3301 |
|
---|
3302 | case LN_ENTER:
|
---|
3303 | if (ad) {
|
---|
3304 |
|
---|
3305 | SHORT sSelect;
|
---|
3306 | HWND hwndUL = WinWindowFromID(ad->hwndFrame,
|
---|
3307 | SHORT1FROMMP(mp1));
|
---|
3308 |
|
---|
3309 | sSelect = (SHORT) WinSendMsg(hwndUL,
|
---|
3310 | LM_QUERYSELECTION,
|
---|
3311 | MPFROM2SHORT(LIT_FIRST, 0), MPVOID);
|
---|
3312 | if (sSelect >= 0) {
|
---|
3313 | ad->dummy = TRUE;
|
---|
3314 | WinSendMsg(hwndUL, LM_DELETEITEM,
|
---|
3315 | MPFROM2SHORT(sSelect, 0), MPVOID);
|
---|
3316 | ad->dummy = FALSE;
|
---|
3317 | sSelect = (SHORT) WinSendMsg(hwndUL,
|
---|
3318 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
3319 | if (sSelect <= 0) {
|
---|
3320 | PostMsg(ad->hwndFrame, WM_UPDATEFRAME,
|
---|
3321 | MPFROMLONG(FCF_SIZEBORDER), MPVOID);
|
---|
3322 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
3323 | }
|
---|
3324 | }
|
---|
3325 | }
|
---|
3326 | break;
|
---|
3327 |
|
---|
3328 | default:
|
---|
3329 | break;
|
---|
3330 | }
|
---|
3331 | break;
|
---|
3332 |
|
---|
3333 | default:
|
---|
3334 | break;
|
---|
3335 | }
|
---|
3336 | return 0;
|
---|
3337 |
|
---|
3338 | case WM_COMMAND:
|
---|
3339 | switch (SHORT1FROMMP(mp1)) {
|
---|
3340 | case IDM_EDIT:
|
---|
3341 | if (*editor) {
|
---|
3342 |
|
---|
3343 | CHAR *dummy[2];
|
---|
3344 |
|
---|
3345 | dummy[0] = ad->filename;
|
---|
3346 | dummy[1] = NULL;
|
---|
3347 | ExecOnList(hwnd, editor, WINDOWED | SEPARATE, NULL, NULL, dummy, NULL,
|
---|
3348 | pszSrcFile, __LINE__);
|
---|
3349 | }
|
---|
3350 | else
|
---|
3351 | StartMLEEditor(ad->hwndParent, 4, ad->filename, ad->hwndFrame);
|
---|
3352 | ad->hwndRestore = (HWND) 0;
|
---|
3353 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
3354 | break;
|
---|
3355 |
|
---|
3356 | case IDM_IGNOREFTP:
|
---|
3357 | ad->ignoreftp = (ad->ignoreftp) ? FALSE : TRUE;
|
---|
3358 | ad->ftpin = FALSE;
|
---|
3359 | if (ad->text && (*ftprun || fFtpRunWPSDefault) &&
|
---|
3360 | !ad->ignoreftp && strstr(ad->text, "ftp://"))
|
---|
3361 | ad->ftpin = TRUE;
|
---|
3362 | IgnoreFTP = ad->ignoreftp;
|
---|
3363 | PrfWriteProfileData(fmprof, appname, "Viewer.IgnoreFTP",
|
---|
3364 | &ad->ignoreftp, sizeof(BOOL));
|
---|
3365 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3366 | break;
|
---|
3367 |
|
---|
3368 | case IDM_IGNOREHTTP:
|
---|
3369 | ad->ignorehttp = (ad->ignorehttp) ? FALSE : TRUE;
|
---|
3370 | ad->httpin = FALSE;
|
---|
3371 | if (ad->text && (*httprun || fHttpRunWPSDefault) && !ad->ignorehttp &&
|
---|
3372 | strstr(ad->text, "http://"))
|
---|
3373 | ad->httpin = TRUE;
|
---|
3374 | IgnoreHTTP = ad->ignorehttp;
|
---|
3375 | PrfWriteProfileData(fmprof, appname, "Viewer.IgnoreHTTP",
|
---|
3376 | &ad->ignorehttp, sizeof(BOOL));
|
---|
3377 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3378 | break;
|
---|
3379 |
|
---|
3380 | case IDM_IGNOREMAIL:
|
---|
3381 | ad->ignoremail = (ad->ignoremail) ? FALSE : TRUE;
|
---|
3382 | ad->mailin = FALSE;
|
---|
3383 | if (ad->text && *mailrun && !ad->ignoremail &&
|
---|
3384 | strstr(ad->text, "@"))
|
---|
3385 | ad->mailin = TRUE;
|
---|
3386 | IgnoreMail = ad->ignoremail;
|
---|
3387 | PrfWriteProfileData(fmprof, appname, "Viewer.IgnoreMail",
|
---|
3388 | &ad->ignoremail, sizeof(BOOL));
|
---|
3389 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3390 | break;
|
---|
3391 |
|
---|
3392 | case IDM_PREVBLANKLINE:
|
---|
3393 | if (!ad->hex && ad->lines) {
|
---|
3394 |
|
---|
3395 | ULONG x;
|
---|
3396 |
|
---|
3397 | x = ad->cursored - 2;
|
---|
3398 | if (x >= ad->numlines)
|
---|
3399 | x = 0;
|
---|
3400 | while (x < ad->numlines &&
|
---|
3401 | (*ad->lines[x] == '\r' || *ad->lines[x] == '\n'))
|
---|
3402 | x--;
|
---|
3403 | if (x >= ad->numlines)
|
---|
3404 | x = 0;
|
---|
3405 | for (; x < ad->numlines; x--) {
|
---|
3406 | if (*ad->lines[x] == '\r' || *ad->lines[x] == '\n') {
|
---|
3407 | if (x < ad->numlines - 1)
|
---|
3408 | x++;
|
---|
3409 | break;
|
---|
3410 | }
|
---|
3411 | }
|
---|
3412 | if (x < ad->numlines) {
|
---|
3413 | ad->topline = ad->cursored = x;
|
---|
3414 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3415 | }
|
---|
3416 | }
|
---|
3417 | break;
|
---|
3418 |
|
---|
3419 | case IDM_NEXTBLANKLINE:
|
---|
3420 | if (!ad->hex && ad->lines) {
|
---|
3421 |
|
---|
3422 | ULONG x;
|
---|
3423 |
|
---|
3424 | x = ad->cursored;
|
---|
3425 | while (x < ad->numlines &&
|
---|
3426 | (*ad->lines[x] == '\r' || *ad->lines[x] == '\n'))
|
---|
3427 | x++;
|
---|
3428 | for (; x < ad->numlines; x++) {
|
---|
3429 | if (*ad->lines[x] == '\r' || *ad->lines[x] == '\n') {
|
---|
3430 | if (x < ad->numlines - 1)
|
---|
3431 | x++;
|
---|
3432 | break;
|
---|
3433 | }
|
---|
3434 | }
|
---|
3435 | if (x < ad->numlines) {
|
---|
3436 | while (x < ad->numlines &&
|
---|
3437 | (*ad->lines[x] == '\r' || *ad->lines[x] == '\n'))
|
---|
3438 | x++;
|
---|
3439 | if (x < ad->numlines) {
|
---|
3440 | ad->topline = ad->cursored = x;
|
---|
3441 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3442 | }
|
---|
3443 | }
|
---|
3444 | }
|
---|
3445 | break;
|
---|
3446 |
|
---|
3447 | case IDM_VIEW:
|
---|
3448 | case IDM_OBJECT:
|
---|
3449 | if (!ad->hex && ad->lines) {
|
---|
3450 |
|
---|
3451 | CHAR line[CCHMAXPATH], filename[CCHMAXPATH], *p;
|
---|
3452 |
|
---|
3453 | strncpy(line, ad->lines[ad->cursored - 1], CCHMAXPATH);
|
---|
3454 | line[CCHMAXPATH - 1] = 0;
|
---|
3455 | chop_at_crnl(line);
|
---|
3456 | if (*line == '\"') {
|
---|
3457 | memmove(line, line + 1, strlen(line));
|
---|
3458 | p = strchr(line, '\"');
|
---|
3459 | lstrip(line);
|
---|
3460 | if (p)
|
---|
3461 | *p = 0;
|
---|
3462 | rstrip(line);
|
---|
3463 | }
|
---|
3464 | else {
|
---|
3465 | lstrip(line);
|
---|
3466 | p = strchr(line, ' ');
|
---|
3467 | if (p)
|
---|
3468 | *p = 0;
|
---|
3469 | rstrip(line);
|
---|
3470 | }
|
---|
3471 | if (!strchr(line, '\\') && !strchr(line, '/') && !strchr(line, ':')) {
|
---|
3472 | strcpy(filename, ad->filename);
|
---|
3473 | p = strrchr(filename, '\\');
|
---|
3474 | if (p)
|
---|
3475 | p++;
|
---|
3476 | else
|
---|
3477 | p = filename;
|
---|
3478 | strcpy(p, line);
|
---|
3479 | }
|
---|
3480 | else
|
---|
3481 | strcpy(filename, line);
|
---|
3482 | MakeFullName(filename);
|
---|
3483 | if (*filename && IsFile(filename) == 1) {
|
---|
3484 | if (SHORT1FROMMP(mp1) == IDM_OBJECT)
|
---|
3485 | OpenObject(filename, Default, ad->hwndFrame);
|
---|
3486 | else
|
---|
3487 | DefaultView(hwnd, ad->hwndFrame, HWND_DESKTOP, NULL, 0, filename);
|
---|
3488 | }
|
---|
3489 | }
|
---|
3490 | break;
|
---|
3491 |
|
---|
3492 | case IDM_COLORPALETTE:
|
---|
3493 | {
|
---|
3494 | COLORS co;
|
---|
3495 | LONG temp[COLORS_MAX];
|
---|
3496 |
|
---|
3497 | memset(&co, 0, sizeof(co));
|
---|
3498 | co.size = sizeof(co);
|
---|
3499 | co.numcolors = COLORS_MAX;
|
---|
3500 | co.colors = ad->colors;
|
---|
3501 | co.descriptions = IDS_NVCOLORS1TEXT;
|
---|
3502 | co.origs = temp;
|
---|
3503 | co.prompt = IDS_NVCOLORSPROMPTTEXT;
|
---|
3504 | memcpy(temp, ad->colors, sizeof(LONG) * COLORS_MAX);
|
---|
3505 | if (WinDlgBox(HWND_DESKTOP,
|
---|
3506 | hwnd,
|
---|
3507 | ColorDlgProc,
|
---|
3508 | FM3ModHandle, COLOR_FRAME, (PVOID) & co)) {
|
---|
3509 | memcpy(Colors, ad->colors, sizeof(LONG) * COLORS_MAX);
|
---|
3510 | PrfWriteProfileData(fmprof,
|
---|
3511 | appname,
|
---|
3512 | "Viewer.Colors",
|
---|
3513 | &ad->colors, sizeof(LONG) * COLORS_MAX);
|
---|
3514 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3515 | WinInvalidateRect(ad->hwndStatus1, NULL, FALSE);
|
---|
3516 | WinInvalidateRect(ad->hwndStatus2, NULL, FALSE);
|
---|
3517 | WinInvalidateRect(ad->hwndStatus3, NULL, FALSE);
|
---|
3518 | }
|
---|
3519 | }
|
---|
3520 | break;
|
---|
3521 |
|
---|
3522 | case IDM_NEXTWINDOW:
|
---|
3523 | case IDM_PREVWINDOW:
|
---|
3524 | {
|
---|
3525 | SHORT sSelect;
|
---|
3526 |
|
---|
3527 | sSelect = (SHORT) WinSendDlgItemMsg(ad->hwndFrame,
|
---|
3528 | NEWVIEW_LISTBOX,
|
---|
3529 | LM_QUERYITEMCOUNT,
|
---|
3530 | MPVOID, MPVOID);
|
---|
3531 | if (sSelect) {
|
---|
3532 | if (!ad->clientfocused)
|
---|
3533 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
3534 | else
|
---|
3535 | WinSetFocus(HWND_DESKTOP,
|
---|
3536 | WinWindowFromID(ad->hwndFrame, NEWVIEW_LISTBOX));
|
---|
3537 | }
|
---|
3538 | else
|
---|
3539 | WinSetFocus(HWND_DESKTOP, hwnd);
|
---|
3540 | }
|
---|
3541 | break;
|
---|
3542 |
|
---|
3543 | case IDM_FINDFIRST:
|
---|
3544 | {
|
---|
3545 | APIRET rc;
|
---|
3546 |
|
---|
3547 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3548 | if (!rc) {
|
---|
3549 | if (!ad->busy && ad->text && ad->numlines && ad->markedlines) {
|
---|
3550 |
|
---|
3551 | ULONG numlines;
|
---|
3552 | RECTL Rectl;
|
---|
3553 | static char test[SEARCHSTRINGLEN];
|
---|
3554 |
|
---|
3555 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
3556 | numlines = NumLines(&Rectl, ad);
|
---|
3557 | if (!numlines)
|
---|
3558 | break;
|
---|
3559 | strcpy(test, ad->searchtext);
|
---|
3560 | if (WinDlgBox(HWND_DESKTOP, hwnd, FindStrDlgProc, FM3ModHandle,
|
---|
3561 | NEWFIND_FRAME, (PVOID) & hwnd)) {
|
---|
3562 | if (*ad->searchtext && strcmp(test, ad->searchtext))
|
---|
3563 | PrfWriteProfileString(fmprof,
|
---|
3564 | appname,
|
---|
3565 | "Viewer.Searchtext",
|
---|
3566 | (PVOID) ad->searchtext);
|
---|
3567 | xbeginthread(SearchThread,
|
---|
3568 | 524288,
|
---|
3569 | (PVOID)hwnd,
|
---|
3570 | pszSrcFile,
|
---|
3571 | __LINE__);
|
---|
3572 | }
|
---|
3573 | }
|
---|
3574 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3575 | }
|
---|
3576 | }
|
---|
3577 | break;
|
---|
3578 |
|
---|
3579 | case IDM_PREVSELECTED:
|
---|
3580 | case IDM_NEXTSELECTED:
|
---|
3581 | case IDM_FINDPREV:
|
---|
3582 | case IDM_FINDNEXT:
|
---|
3583 | {
|
---|
3584 | APIRET rc;
|
---|
3585 |
|
---|
3586 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3587 | if (!rc) {
|
---|
3588 | if (!ad->busy && ad->text && ad->markedlines) {
|
---|
3589 |
|
---|
3590 | RECTL Rectl;
|
---|
3591 | register ULONG x;
|
---|
3592 | ULONG numlines;
|
---|
3593 | CHAR markedwith;
|
---|
3594 |
|
---|
3595 | markedwith = (SHORT1FROMMP(mp1) == IDM_FINDNEXT ||
|
---|
3596 | SHORT1FROMMP(mp1) == IDM_FINDPREV) ?
|
---|
3597 | VF_FOUND : VF_SELECTED;
|
---|
3598 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
3599 | numlines = NumLines(&Rectl, ad);
|
---|
3600 | if (!numlines)
|
---|
3601 | break;
|
---|
3602 | WinSetPointer(HWND_DESKTOP, hptrBusy);
|
---|
3603 | if (SHORT1FROMMP(mp1) == IDM_PREVSELECTED ||
|
---|
3604 | SHORT1FROMMP(mp1) == IDM_FINDPREV) {
|
---|
3605 | for (x = ad->cursored - 2; x < ULONG_MAX - 1; x--) {
|
---|
3606 | if (ad->markedlines[x] & markedwith) {
|
---|
3607 | ad->topline = x + 1;
|
---|
3608 | if (ad->numlines - ad->topline < numlines)
|
---|
3609 | ad->topline = ad->numlines - numlines;
|
---|
3610 | ad->cursored = x + 1;
|
---|
3611 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3612 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
3613 | break;
|
---|
3614 | }
|
---|
3615 | }
|
---|
3616 | }
|
---|
3617 | else {
|
---|
3618 | for (x = ad->cursored; x < ad->numlines; x++) {
|
---|
3619 | if (ad->markedlines[x] & markedwith) {
|
---|
3620 | ad->topline = x + 1;
|
---|
3621 | if (ad->numlines - ad->topline < numlines)
|
---|
3622 | ad->topline = ad->numlines - numlines;
|
---|
3623 | ad->cursored = x + 1;
|
---|
3624 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3625 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
3626 | break;
|
---|
3627 | }
|
---|
3628 | }
|
---|
3629 | }
|
---|
3630 | WinSetPointer(HWND_DESKTOP, hptrArrow);
|
---|
3631 | if (x >= ad->numlines && !fAlertBeepOff)
|
---|
3632 | DosBeep(50, 100);
|
---|
3633 | }
|
---|
3634 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3635 | }
|
---|
3636 | }
|
---|
3637 | break;
|
---|
3638 |
|
---|
3639 | case IDM_SELECTFOUND:
|
---|
3640 | case IDM_DESELECTFOUND:
|
---|
3641 | {
|
---|
3642 | APIRET rc;
|
---|
3643 |
|
---|
3644 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3645 | if (!rc) {
|
---|
3646 | if (!ad->busy && ad->text && ad->markedlines) {
|
---|
3647 |
|
---|
3648 | RECTL Rectl;
|
---|
3649 | register ULONG x;
|
---|
3650 | ULONG numlines;
|
---|
3651 |
|
---|
3652 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
3653 | numlines = NumLines(&Rectl, ad);
|
---|
3654 | if (!numlines)
|
---|
3655 | break;
|
---|
3656 | WinSetPointer(HWND_DESKTOP, hptrBusy);
|
---|
3657 | for (x = 0; x < ad->numlines; x++) {
|
---|
3658 | if (SHORT1FROMMP(mp1) == IDM_SELECTFOUND) {
|
---|
3659 | if ((ad->markedlines[x] & VF_FOUND) &&
|
---|
3660 | !(ad->markedlines[x] & VF_SELECTED)) {
|
---|
3661 | ad->markedlines[x] |= VF_SELECTED;
|
---|
3662 | ad->selected++;
|
---|
3663 | }
|
---|
3664 | }
|
---|
3665 | else {
|
---|
3666 | if ((ad->markedlines[x] & VF_FOUND) &&
|
---|
3667 | (ad->markedlines[x] & VF_SELECTED)) {
|
---|
3668 | ad->markedlines[x] &= (~VF_SELECTED);
|
---|
3669 | ad->selected--;
|
---|
3670 | }
|
---|
3671 | }
|
---|
3672 | }
|
---|
3673 | WinSendMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
3674 | WinSetPointer(HWND_DESKTOP, hptrArrow);
|
---|
3675 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3676 | }
|
---|
3677 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3678 | }
|
---|
3679 | }
|
---|
3680 | break;
|
---|
3681 |
|
---|
3682 | case IDM_GOTOLINE:
|
---|
3683 | case IDM_GOTOOFFSET:
|
---|
3684 | {
|
---|
3685 | APIRET rc;
|
---|
3686 |
|
---|
3687 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3688 | if (!rc) {
|
---|
3689 | if (!ad->busy && ad->numlines) {
|
---|
3690 |
|
---|
3691 | ULONG numlines, linenum;
|
---|
3692 | CHAR s[34], ss[134];
|
---|
3693 | STRINGINPARMS sip;
|
---|
3694 | RECTL Rectl;
|
---|
3695 | register ULONG x;
|
---|
3696 |
|
---|
3697 | WinQueryWindowRect(hwnd, &Rectl);
|
---|
3698 | numlines = NumLines(&Rectl, ad);
|
---|
3699 | if (!numlines)
|
---|
3700 | break;
|
---|
3701 | if (ad->numlines <= numlines) {
|
---|
3702 | if (!fAlertBeepOff)
|
---|
3703 | DosBeep(500, 100);
|
---|
3704 | break;
|
---|
3705 | }
|
---|
3706 | sip.help = (SHORT1FROMMP(mp1) == IDM_GOTOLINE) ?
|
---|
3707 | GetPString(IDS_NVLINEJUMPTEXT) : GetPString(IDS_NVBYTEJUMPTEXT);
|
---|
3708 | sip.ret = s;
|
---|
3709 | *s = 0;
|
---|
3710 | sip.inputlen = 34;
|
---|
3711 | sip.title = (SHORT1FROMMP(mp1) == IDM_GOTOLINE) ?
|
---|
3712 | GetPString(IDS_NVLINEJUMPTITLETEXT) :
|
---|
3713 | GetPString(IDS_NVBYTEJUMPTITLETEXT);
|
---|
3714 | sprintf(ss,
|
---|
3715 | GetPString(IDS_NVJUMPTEXT),
|
---|
3716 | (SHORT1FROMMP(mp1) == IDM_GOTOLINE) ?
|
---|
3717 | GetPString(IDS_LINETEXT) :
|
---|
3718 | GetPString(IDS_OFFSETTEXT),
|
---|
3719 | (SHORT1FROMMP(mp1) == IDM_GOTOLINE) ?
|
---|
3720 | 1 :
|
---|
3721 | 0,
|
---|
3722 | (SHORT1FROMMP(mp1) == IDM_GOTOLINE) ?
|
---|
3723 | ad->numlines : ad->textsize - 1);
|
---|
3724 | sip.prompt = ss;
|
---|
3725 | WinDlgBox(HWND_DESKTOP,
|
---|
3726 | hwnd, InputDlgProc, FM3ModHandle, STR_FRAME, &sip);
|
---|
3727 | if (*s) {
|
---|
3728 | s[33] = 0;
|
---|
3729 | linenum = atol(s);
|
---|
3730 | switch (SHORT1FROMMP(mp1)) {
|
---|
3731 | case IDM_GOTOLINE:
|
---|
3732 | if (linenum > 0 && linenum <= ad->numlines) {
|
---|
3733 | ad->topline = linenum;
|
---|
3734 | ad->cursored = ad->topline;
|
---|
3735 | if (ad->numlines - ad->topline < numlines)
|
---|
3736 | ad->topline = (ad->numlines - numlines) + 1;
|
---|
3737 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3738 | }
|
---|
3739 | break;
|
---|
3740 | case IDM_GOTOOFFSET:
|
---|
3741 | if (linenum < ad->textsize) {
|
---|
3742 | if (ad->hex)
|
---|
3743 | ad->topline = (linenum / 16) + 1;
|
---|
3744 | else if (ad->lines) {
|
---|
3745 | ad->topline = (ULONG) - 1;
|
---|
3746 | for (x = 0; x < ad->numlines; x++) {
|
---|
3747 | if (ad->lines[x] > ad->text + linenum) {
|
---|
3748 | ad->topline = x + 1;
|
---|
3749 | break;
|
---|
3750 | }
|
---|
3751 | }
|
---|
3752 | if (ad->topline == (ULONG) - 1)
|
---|
3753 | ad->topline = ad->numlines;
|
---|
3754 | }
|
---|
3755 | ad->cursored = ad->topline;
|
---|
3756 | if (ad->numlines - ad->topline < numlines)
|
---|
3757 | ad->topline = (ad->numlines - numlines) + 1;
|
---|
3758 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3759 | }
|
---|
3760 | break;
|
---|
3761 | }
|
---|
3762 | }
|
---|
3763 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
3764 | }
|
---|
3765 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3766 | }
|
---|
3767 | }
|
---|
3768 | break;
|
---|
3769 |
|
---|
3770 | case IDM_CODEPAGE:
|
---|
3771 | {
|
---|
3772 | INT cp;
|
---|
3773 |
|
---|
3774 | cp = PickCodepage(hwnd);
|
---|
3775 | if (cp != -1) {
|
---|
3776 | ad->fattrs.usCodePage = (USHORT) cp;
|
---|
3777 | Codepage = ad->fattrs.usCodePage;
|
---|
3778 | PrfWriteProfileData(fmprof,
|
---|
3779 | appname,
|
---|
3780 | "Viewer.Codepage",
|
---|
3781 | &ad->fattrs.usCodePage, sizeof(USHORT));
|
---|
3782 | GpiDeleteSetId(ad->hps, NEWVIEWMLE_FONT_LCID);
|
---|
3783 | GpiAssociate(ad->hps, 0);
|
---|
3784 | GpiDestroyPS(ad->hps);
|
---|
3785 | ad->hps = InitWindow(hwnd);
|
---|
3786 | WinSendMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
---|
3787 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
3788 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3789 | }
|
---|
3790 | }
|
---|
3791 | break;
|
---|
3792 |
|
---|
3793 | case IDM_SAVETOLIST2:
|
---|
3794 | case IDM_SAVETOCLIP2:
|
---|
3795 | case IDM_APPENDTOCLIP2:
|
---|
3796 | case IDM_SAVETOLIST:
|
---|
3797 | case IDM_SAVETOCLIP:
|
---|
3798 | case IDM_APPENDTOCLIP:
|
---|
3799 | {
|
---|
3800 | APIRET rc;
|
---|
3801 |
|
---|
3802 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3803 | if (!rc) {
|
---|
3804 | if (!ad->busy) {
|
---|
3805 | ad->cliptype = SHORT1FROMMP(mp1);
|
---|
3806 | xbeginthread(ClipboardThread,
|
---|
3807 | 524288,
|
---|
3808 | (PVOID)hwnd,
|
---|
3809 | pszSrcFile,
|
---|
3810 | __LINE__);
|
---|
3811 | }
|
---|
3812 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3813 | }
|
---|
3814 | }
|
---|
3815 | break;
|
---|
3816 |
|
---|
3817 | case IDM_SELECTALL:
|
---|
3818 | case IDM_DESELECTALL:
|
---|
3819 | case IDM_INVERT:
|
---|
3820 | {
|
---|
3821 | APIRET rc;
|
---|
3822 |
|
---|
3823 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3824 | if (!rc) {
|
---|
3825 | if (!ad->busy && ad->markedlines) {
|
---|
3826 |
|
---|
3827 | register ULONG x;
|
---|
3828 |
|
---|
3829 | for (x = 0; x < ad->numlines; x++) {
|
---|
3830 | switch (SHORT1FROMMP(mp1)) {
|
---|
3831 | case IDM_SELECTALL:
|
---|
3832 | if (!(ad->markedlines[x] & VF_SELECTED)) {
|
---|
3833 | ad->markedlines[x] |= VF_SELECTED;
|
---|
3834 | ad->selected++;
|
---|
3835 | }
|
---|
3836 | break;
|
---|
3837 | case IDM_DESELECTALL:
|
---|
3838 | if (ad->markedlines[x] & VF_SELECTED) {
|
---|
3839 | ad->markedlines[x] &= (~VF_SELECTED);
|
---|
3840 | ad->selected--;
|
---|
3841 | }
|
---|
3842 | break;
|
---|
3843 | case IDM_INVERT:
|
---|
3844 | if (ad->markedlines[x] & VF_SELECTED) {
|
---|
3845 | ad->markedlines[x] &= (~VF_SELECTED);
|
---|
3846 | ad->selected--;
|
---|
3847 | }
|
---|
3848 | else {
|
---|
3849 | ad->markedlines[x] |= VF_SELECTED;
|
---|
3850 | ad->selected++;
|
---|
3851 | }
|
---|
3852 | break;
|
---|
3853 | }
|
---|
3854 | }
|
---|
3855 | WinSendMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
3856 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3857 | }
|
---|
3858 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3859 | }
|
---|
3860 | }
|
---|
3861 | break;
|
---|
3862 |
|
---|
3863 | case IDM_WRAP:
|
---|
3864 | {
|
---|
3865 | APIRET rc;
|
---|
3866 |
|
---|
3867 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3868 | if (!rc) {
|
---|
3869 | if (!ad->busy) {
|
---|
3870 | ad->wrapon = ad->wrapon ? FALSE : TRUE;
|
---|
3871 | WrapOn = ad->wrapon;
|
---|
3872 | PrfWriteProfileData(fmprof, appname, "Viewer.WrapOn",
|
---|
3873 | &ad->wrapon, sizeof(BOOL));
|
---|
3874 | PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
3875 | PostMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
---|
3876 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
3877 | if (WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
|
---|
3878 | LM_QUERYITEMCOUNT, MPVOID, MPVOID))
|
---|
3879 | WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX, LM_DELETEALL,
|
---|
3880 | MPVOID, MPVOID);
|
---|
3881 | ad->oldwidth = -1;
|
---|
3882 | WinSendMsg(ad->hvscroll, SBM_SETTHUMBSIZE,
|
---|
3883 | MPFROM2SHORT(1, 1), MPVOID);
|
---|
3884 | WinSendMsg(ad->hvscroll, SBM_SETSCROLLBAR,
|
---|
3885 | MPFROMSHORT(1), MPFROM2SHORT(1, 1));
|
---|
3886 | WinSendMsg(ad->hhscroll, SBM_SETTHUMBSIZE,
|
---|
3887 | MPFROM2SHORT(1, 1), MPVOID);
|
---|
3888 | WinSendMsg(ad->hhscroll, SBM_SETSCROLLBAR,
|
---|
3889 | MPFROMSHORT(1), MPFROM2SHORT(1, 1));
|
---|
3890 | WinSendMsg(ad->hwndFrame, WM_UPDATEFRAME,
|
---|
3891 | MPFROMLONG(FCF_SIZEBORDER), MPVOID);
|
---|
3892 | WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
3893 | NEWVIEW_DRAG), NULL, FALSE);
|
---|
3894 | //WinInvalidateRect(ad->hhscroll, NULL, FALSE);
|
---|
3895 | }
|
---|
3896 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3897 | }
|
---|
3898 | }
|
---|
3899 | break;
|
---|
3900 |
|
---|
3901 | case IDM_HEXMODE:
|
---|
3902 | {
|
---|
3903 | APIRET rc;
|
---|
3904 |
|
---|
3905 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3906 | if (!rc) {
|
---|
3907 | if (!ad->busy) {
|
---|
3908 | ad->hex = (ad->hex) ? FALSE : TRUE;
|
---|
3909 | WinEnableWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
3910 | IDM_NEXTBLANKLINE), !ad->hex);
|
---|
3911 | WinEnableWindow(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
3912 | IDM_PREVBLANKLINE), !ad->hex);
|
---|
3913 | PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
3914 | PostMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
---|
3915 | PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
|
---|
3916 | if (WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
|
---|
3917 | LM_QUERYITEMCOUNT, MPVOID, MPVOID))
|
---|
3918 | WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX, LM_DELETEALL,
|
---|
3919 | MPVOID, MPVOID);
|
---|
3920 | ad->oldwidth = -1;
|
---|
3921 | WinSendMsg(ad->hvscroll, SBM_SETTHUMBSIZE,
|
---|
3922 | MPFROM2SHORT(1, 1), MPVOID);
|
---|
3923 | WinSendMsg(ad->hvscroll, SBM_SETSCROLLBAR,
|
---|
3924 | MPFROMSHORT(1), MPFROM2SHORT(1, 1));
|
---|
3925 | WinSendMsg(ad->hhscroll, SBM_SETTHUMBSIZE,
|
---|
3926 | MPFROM2SHORT(1, 1), MPVOID);
|
---|
3927 | WinSendMsg(ad->hhscroll, SBM_SETSCROLLBAR,
|
---|
3928 | MPFROMSHORT(1), MPFROM2SHORT(1, 1));
|
---|
3929 | WinSendMsg(ad->hwndFrame, WM_UPDATEFRAME,
|
---|
3930 | MPFROMLONG(FCF_SIZEBORDER), MPVOID);
|
---|
3931 | WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
3932 | NEWVIEW_DRAG), NULL, FALSE);
|
---|
3933 | //WinInvalidateRect(ad->hhscroll, NULL, FALSE);
|
---|
3934 | }
|
---|
3935 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3936 | }
|
---|
3937 | }
|
---|
3938 | break;
|
---|
3939 |
|
---|
3940 | case IDM_FONTPALETTE:
|
---|
3941 | {
|
---|
3942 | APIRET rc;
|
---|
3943 |
|
---|
3944 | rc = DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN);
|
---|
3945 | if (!rc) {
|
---|
3946 | SetMLEFont(hwnd, &ad->fattrs, 11);
|
---|
3947 | PrfWriteProfileData(fmprof, appname, "Viewer.Fattrs",
|
---|
3948 | &ad->fattrs, sizeof(FATTRS));
|
---|
3949 | Fattrs = ad->fattrs;
|
---|
3950 | GpiDeleteSetId(ad->hps, NEWVIEWMLE_FONT_LCID);
|
---|
3951 | GpiAssociate(ad->hps, 0);
|
---|
3952 | GpiDestroyPS(ad->hps);
|
---|
3953 | ad->hps = InitWindow(hwnd);
|
---|
3954 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3955 | WinSendMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
3956 | WinInvalidateRect(hwnd, NULL, FALSE);
|
---|
3957 | }
|
---|
3958 | }
|
---|
3959 | break;
|
---|
3960 |
|
---|
3961 | case IDM_HELP:
|
---|
3962 | if (hwndHelp)
|
---|
3963 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
3964 | MPFROM2SHORT(HELP_NEWVIEW, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
3965 | break;
|
---|
3966 | }
|
---|
3967 | return 0;
|
---|
3968 |
|
---|
3969 | case WM_SETFOCUS:
|
---|
3970 | if (mp2)
|
---|
3971 | WinSendMsg(hwnd, UM_SETUP5, MPVOID, MPVOID);
|
---|
3972 | if (mp2 && ad && ad->needrefreshing && !ad->stopflag &&
|
---|
3973 | !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
|
---|
3974 | ad->needrefreshing = FALSE;
|
---|
3975 | DosReleaseMutexSem(ad->ScanSem);
|
---|
3976 | WinInvalidateRect(hwnd, NULL, TRUE);
|
---|
3977 | }
|
---|
3978 | break;
|
---|
3979 |
|
---|
3980 | case WM_SIZE:
|
---|
3981 | if (SHORT1FROMMP(mp2) && SHORT2FROMMP(mp2)) {
|
---|
3982 | PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
|
---|
3983 | PostMsg(hwnd, UM_SETUP3, MPVOID, MPVOID);
|
---|
3984 | }
|
---|
3985 | break;
|
---|
3986 |
|
---|
3987 | case WM_SAVEAPPLICATION:
|
---|
3988 | if (ad && ParentIsDesktop(hwnd, ad->hwndParent)) {
|
---|
3989 |
|
---|
3990 | SWP swp;
|
---|
3991 |
|
---|
3992 | WinQueryWindowPos(ad->hwndFrame, &swp);
|
---|
3993 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
|
---|
3994 | PrfWriteProfileData(fmprof,
|
---|
3995 | appname, "NewViewSizePos", &swp, sizeof(swp));
|
---|
3996 | }
|
---|
3997 | break;
|
---|
3998 |
|
---|
3999 | case WM_CLOSE:
|
---|
4000 | if (ad)
|
---|
4001 | ad->stopflag = 1;
|
---|
4002 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
|
---|
4003 | return 0;
|
---|
4004 |
|
---|
4005 | case WM_DESTROY:
|
---|
4006 | {
|
---|
4007 | BOOL dontclose = FALSE;
|
---|
4008 | HWND hwndRestore = (HWND) 0;
|
---|
4009 |
|
---|
4010 | WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_NEWVIEW_TIMER);
|
---|
4011 | if (ad) {
|
---|
4012 | ad->stopflag = 1;
|
---|
4013 | if (ad->ScanSem) {
|
---|
4014 | DosRequestMutexSem(ad->ScanSem, 15000);
|
---|
4015 | DosCloseMutexSem(ad->ScanSem);
|
---|
4016 | }
|
---|
4017 | if (ad->busy)
|
---|
4018 | DosSleep(100); //05 Aug 07 GKY 128
|
---|
4019 | if (ad->hps) {
|
---|
4020 | GpiDeleteSetId(ad->hps, NEWVIEWMLE_FONT_LCID);
|
---|
4021 | GpiAssociate(ad->hps, 0);
|
---|
4022 | GpiDestroyPS(ad->hps);
|
---|
4023 | }
|
---|
4024 | hwndRestore = ad->hwndRestore;
|
---|
4025 | dontclose = ((ad->flags & 4) != 0) ? TRUE : FALSE;
|
---|
4026 | FreeViewerMem(hwnd);
|
---|
4027 | WinSetWindowPtr(hwnd, QWL_USER, NULL);
|
---|
4028 | free(ad);
|
---|
4029 | }
|
---|
4030 | if (hwndRestore && hwndRestore != HWND_DESKTOP) {
|
---|
4031 |
|
---|
4032 | ULONG fl = SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER;
|
---|
4033 | SWP swp;
|
---|
4034 |
|
---|
4035 | if (WinQueryWindowPos(hwndRestore, &swp)) {
|
---|
4036 | if (!(swp.fl & SWP_MAXIMIZE))
|
---|
4037 | fl |= SWP_RESTORE;
|
---|
4038 | WinSetWindowPos(hwndRestore, HWND_TOP, 0, 0, 0, 0, fl);
|
---|
4039 | }
|
---|
4040 | }
|
---|
4041 | if (!dontclose &&
|
---|
4042 | ParentIsDesktop(hwnd, WinQueryWindow(WinQueryWindow(hwnd,
|
---|
4043 | QW_PARENT),
|
---|
4044 | QW_PARENT))) {
|
---|
4045 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
4046 | DosExit(EXIT_PROCESS, 1);
|
---|
4047 | }
|
---|
4048 | }
|
---|
4049 | break;
|
---|
4050 | }
|
---|
4051 |
|
---|
4052 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
4053 | }
|
---|
4054 |
|
---|
4055 | HWND StartViewer(HWND hwndParent, USHORT flags, CHAR * filename,
|
---|
4056 | HWND hwndRestore)
|
---|
4057 | {
|
---|
4058 | HWND hwndFrame = (HWND) 0, hwndClient;
|
---|
4059 | VIEWDATA *ad;
|
---|
4060 | ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
|
---|
4061 | FCF_SIZEBORDER | FCF_MINMAX |
|
---|
4062 | FCF_NOBYTEALIGN | FCF_VERTSCROLL |
|
---|
4063 | FCF_MENU | FCF_ICON | FCF_ACCELTABLE | FCF_HORZSCROLL;
|
---|
4064 |
|
---|
4065 | if (strcmp(realappname, FM3Str))
|
---|
4066 | hwndParent = HWND_DESKTOP;
|
---|
4067 | if (ParentIsDesktop(hwndParent, hwndParent))
|
---|
4068 | FrameFlags |= FCF_TASKLIST;
|
---|
4069 | hwndFrame = WinCreateStdWindow(hwndParent,
|
---|
4070 | 0,
|
---|
4071 | &FrameFlags,
|
---|
4072 | WC_NEWVIEW,
|
---|
4073 | GetPString(IDS_FM2VIEWERTITLETEXT),
|
---|
4074 | fwsAnimate,
|
---|
4075 | FM3ModHandle, NEWVIEW_FRAME, &hwndClient);
|
---|
4076 | if (hwndFrame) {
|
---|
4077 |
|
---|
4078 | HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
|
---|
4079 |
|
---|
4080 | if (!fToolbar && hwndMenu) {
|
---|
4081 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
4082 | MPFROM2SHORT(IDM_FINDFIRST, FALSE), MPVOID);
|
---|
4083 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
4084 | MPFROM2SHORT(IDM_FINDNEXT, FALSE), MPVOID);
|
---|
4085 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
4086 | MPFROM2SHORT(IDM_FINDPREV, FALSE), MPVOID);
|
---|
4087 | WinSendMsg(hwndMenu, MM_DELETEITEM,
|
---|
4088 | MPFROM2SHORT(IDM_SAVETOCLIP, FALSE), MPVOID);
|
---|
4089 | }
|
---|
4090 | ad = xmallocz(sizeof(VIEWDATA), pszSrcFile, __LINE__);
|
---|
4091 | if (!ad) {
|
---|
4092 | WinDestroyWindow(hwndFrame);
|
---|
4093 | hwndFrame = (HWND)0;
|
---|
4094 | }
|
---|
4095 | else {
|
---|
4096 | ad->size = sizeof(VIEWDATA);
|
---|
4097 | ad->stopflag = 0;
|
---|
4098 | ad->multiplier = 1;
|
---|
4099 | ad->hwndRestore = hwndRestore;
|
---|
4100 | ad->hwndFrame = hwndFrame;
|
---|
4101 | ad->hwndParent = hwndParent;
|
---|
4102 | ad->clientfocused = TRUE;
|
---|
4103 | ad->oldwidth = -1;
|
---|
4104 | strcpy(ad->filename, filename);
|
---|
4105 | ad->flags = flags;
|
---|
4106 | if (ad->flags & 16)
|
---|
4107 | ad->hex = TRUE;
|
---|
4108 | WinSetWindowPtr(hwndClient, QWL_USER, (PVOID) ad);
|
---|
4109 | if (Firsttime) {
|
---|
4110 |
|
---|
4111 | ULONG size;
|
---|
4112 |
|
---|
4113 | size = sizeof(BOOL);
|
---|
4114 | PrfQueryProfileData(fmprof, appname, "Viewer.Sensitive",
|
---|
4115 | (PVOID) & Sensitive, &size);
|
---|
4116 | size = sizeof(USHORT);
|
---|
4117 | PrfQueryProfileData(fmprof, appname, "Viewer.Codepage",
|
---|
4118 | (PVOID) & Codepage, &size);
|
---|
4119 | size = sizeof(BOOL);
|
---|
4120 | PrfQueryProfileData(fmprof, appname, "Viewer.LiteralSearch",
|
---|
4121 | (PVOID) & LiteralSearch, &size);
|
---|
4122 | size = sizeof(BOOL);
|
---|
4123 | PrfQueryProfileData(fmprof, appname, "Viewer.AlsoSelect",
|
---|
4124 | (PVOID) & AlsoSelect, &size);
|
---|
4125 | size = sizeof(BOOL);
|
---|
4126 | PrfQueryProfileData(fmprof, appname, "Viewer.WrapOn",
|
---|
4127 | (PVOID) & WrapOn, &size);
|
---|
4128 | size = sizeof(BOOL);
|
---|
4129 | PrfQueryProfileData(fmprof, appname, "Viewer.IgnoreFTP",
|
---|
4130 | (PVOID) & IgnoreFTP, &size);
|
---|
4131 | size = sizeof(BOOL);
|
---|
4132 | PrfQueryProfileData(fmprof, appname, "Viewer.IgnoreHTTP",
|
---|
4133 | (PVOID) & IgnoreHTTP, &size);
|
---|
4134 | size = sizeof(BOOL);
|
---|
4135 | PrfQueryProfileData(fmprof, appname, "Viewer.IgnoreMail",
|
---|
4136 | (PVOID) & IgnoreMail, &size);
|
---|
4137 | memset(&Fattrs, 0, sizeof(FATTRS));
|
---|
4138 | size = sizeof(FATTRS);
|
---|
4139 | Fattrs.usRecordLength = sizeof(FATTRS);
|
---|
4140 | Fattrs.lMaxBaselineExt = 16;
|
---|
4141 | Fattrs.lAveCharWidth = 8;
|
---|
4142 | Fattrs.usCodePage = Codepage;
|
---|
4143 | strcpy(Fattrs.szFacename, GetPString(IDS_SYSMONOTEXT));
|
---|
4144 | PrfQueryProfileData(fmprof, appname, "Viewer.Fattrs",
|
---|
4145 | (PVOID) & Fattrs, &size);
|
---|
4146 | size = sizeof(LONG) * COLORS_MAX;
|
---|
4147 | PrfQueryProfileData(fmprof, appname, "Viewer.Colors",
|
---|
4148 | (PVOID) Colors, &size);
|
---|
4149 | Firsttime = FALSE;
|
---|
4150 | }
|
---|
4151 | {
|
---|
4152 | ULONG size = sizeof(ad->searchtext);
|
---|
4153 |
|
---|
4154 | PrfQueryProfileData(fmprof, appname, "Viewer.Searchtext",
|
---|
4155 | (PVOID) ad->searchtext, &size);
|
---|
4156 | ad->searchtext[sizeof(ad->searchtext) - 1] = 0;
|
---|
4157 | }
|
---|
4158 | ad->sensitive = Sensitive;
|
---|
4159 | ad->literalsearch = LiteralSearch;
|
---|
4160 | ad->fattrs = Fattrs;
|
---|
4161 | ad->alsoselect = AlsoSelect;
|
---|
4162 | ad->fattrs.usCodePage = Codepage;
|
---|
4163 | ad->wrapon = WrapOn;
|
---|
4164 | ad->ignorehttp = IgnoreHTTP;
|
---|
4165 | ad->ignoreftp = IgnoreFTP;
|
---|
4166 | ad->ignoremail = IgnoreMail;
|
---|
4167 | memcpy(ad->colors, Colors, sizeof(LONG) * COLORS_MAX);
|
---|
4168 | WinSetWindowPtr(hwndClient, QWL_USER, (PVOID) ad);
|
---|
4169 | if (!WinSendMsg(hwndClient, UM_SETUP, MPVOID, MPVOID))
|
---|
4170 | hwndFrame = (HWND) 0;
|
---|
4171 | else {
|
---|
4172 | //DosSleep(32);
|
---|
4173 | if (!(FrameFlags & FCF_TASKLIST) && !(flags & 2)) {
|
---|
4174 | SWP swp;
|
---|
4175 |
|
---|
4176 | FillClient(hwndParent, &swp, NULL, FALSE);
|
---|
4177 | WinSetWindowPos(hwndFrame, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
|
---|
4178 | SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_RESTORE |
|
---|
4179 | SWP_ZORDER | SWP_ACTIVATE);
|
---|
4180 | }
|
---|
4181 | else if (FrameFlags & FCF_TASKLIST) {
|
---|
4182 |
|
---|
4183 | SWP swp, swpD;
|
---|
4184 | ULONG size = sizeof(swp);
|
---|
4185 | LONG cxScreen, cyScreen;
|
---|
4186 |
|
---|
4187 | WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
|
---|
4188 | if (PrfQueryProfileData(fmprof,
|
---|
4189 | appname, "NewViewSizePos", &swpD, &size)) {
|
---|
4190 | cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
|
---|
4191 | cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
|
---|
4192 | if (swp.x + swpD.cx > cxScreen)
|
---|
4193 | swp.x = cxScreen - swpD.cx;
|
---|
4194 | if (swp.y + swpD.cy > cyScreen)
|
---|
4195 | swp.y = cyScreen - swpD.cy;
|
---|
4196 | swp.cx = swpD.cx;
|
---|
4197 | swp.cy = swpD.cy;
|
---|
4198 | }
|
---|
4199 | WinSetWindowPos(hwndFrame, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
|
---|
4200 | SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
|
---|
4201 | SWP_ACTIVATE);
|
---|
4202 | }
|
---|
4203 | }
|
---|
4204 | }
|
---|
4205 | }
|
---|
4206 | return hwndFrame;
|
---|
4207 | }
|
---|
4208 |
|
---|
4209 | #pragma alloc_text(NEWVIEW,ViewStatusProc,FreeViewerMem,LoadFileThread)
|
---|
4210 | #pragma alloc_text(NEWVIEW,InitWindow,PaintLine,ViewWndProc)
|
---|
4211 | #pragma alloc_text(NEWVIEW,ViewFrameWndProc,StartViewer,ReLineThread)
|
---|
4212 | #pragma alloc_text(NEWVIEW,BuildAList,SearchThread,ClipboardThread,FindStrDlgProc)
|
---|
4213 | #pragma alloc_text(NEWVIEW,BuildAList2,UrlDlgProc)
|
---|