source: trunk/dll/newview.c@ 1572

Last change on this file since 1572 was 1544, checked in by Gregg Young, 15 years ago

Changes to fopen and _fsopen to allow FM2 to be loaded in high memory

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