source: trunk/dll/newview.c@ 1392

Last change on this file since 1392 was 1391, checked in by Gregg Young, 17 years ago

Move nontranslated strings to init.c and codepage.c; use those strings in place of GetPString calls. Move other strings to a StringTable; minor cleanup and code changes to codepage.c to use a string array instead of GetPString calls. Ticket 340

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