source: trunk/dll/newview.c@ 1402

Last change on this file since 1402 was 1402, checked in by Gregg Young, 16 years ago

Remove variable aurgs from docopy & unlinkf (not used); Move more strings to PCSZs and string table; Move PCSZs to compile time initialization; Fix hang on startup caused by a drive scan and a dircnr scan trying to update a drive in the tree at the same time (related to the "treeswitch options); Code cleanup mainly removal of old printfs, SayMsgs, DbgMsg and unneeded %s.

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