source: trunk/dll/newview.c@ 1395

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

Allow user to turn off alert and/or error beeps in settings notebook. Ticket 341 Move repeated strings to PCSZs. Ticket 6 Add *DateFormat functions to format dates based on locale Ticket 28 Eliminate Win_Error2 by moving function names to PCSZs used in Win_Error Ticket 6

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