source: trunk/dll/newview.c@ 1673

Last change on this file since 1673 was 1673, checked in by Gregg Young, 13 years ago

Update to Doxygen comment style Ticket 55. Also some minor code cleanup.

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