source: trunk/dll/newview.c@ 1786

Last change on this file since 1786 was 1781, checked in by Gregg Young, 11 years ago

Fix conditional trap caused by changes in CS [1780]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 117.5 KB
RevLine 
[83]1
2/***********************************************************************
3
4 $Id: newview.c 1781 2014-06-28 21:25:34Z 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 *.
[1781]42 28 Jun 14 GKY Fix errors identified with CPPCheck Fix "mailto" failure to drop trailing >
[83]43
44***********************************************************************/
45
[2]46#include <stdlib.h>
47#include <string.h>
[1335]48// #include <process.h> // 10 Dec 08 SHL
[2]49#include <limits.h>
50#include <share.h>
[350]51
[907]52#define INCL_DOS
53#define INCL_WIN
54#define INCL_GPI
55#define INCL_LONGLONG
56
[1186]57#include "fm3dll.h"
[1225]58#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
[1210]59#include "mainwnd2.h" // Data declaration(s)
60#include "collect.h" // Data declaration(s)
61#include "grep.h" // Data declaration(s)
62#include "dircnrs.h" // Data declaration(s)
63#include "init.h" // Data declaration(s)
[2]64#include "fm3dlg.h"
65#include "fm3str.h"
66#include "mle.h"
[907]67#include "makelist.h" // AddToList
68#include "errutil.h" // Dos_Error...
69#include "strutil.h" // GetPString
[985]70#include "notebook.h" // httprun etc
[1162]71#include "colors.h" // ColorDlgProc
72#include "defview.h" // DefaultView
73#include "draglist.h" // DragOne
74#include "mainwnd.h" // FillClient, MakeBubble
75#include "valid.h" // IsBinary
76#include "saveclip.h" // ListToClipboardHab
77#include "codepage.h" // PickCodepage
78#include "fonts.h" // SetPresParamFromFattrs
79#include "newview.h"
80#include "strips.h" // chop_at_crnl, convert_nl_to_nul
[1335]81 // remove_first_occurence_of_character
82 // strip_lead_char, strip_trail_char
[1186]83#include "common.h" // CommonTextButton, CommonTextProc, DecrThreadUsage
[1335]84 // IncrThreadUsage
[1186]85#include "systemf.h" // ExecOnList
86#include "input.h" // InputDlgProc
87#include "shadow.h" // OpenObject
88#include "chklist.h" // PopupMenu
89#include "viewer.h" // StartMLEEditor
[1400]90#include "i18nutil.h" // commafmt
[1186]91#include "getnames.h" // export_filename
92#include "literal.h" // literal
93#include "wrappers.h" // xrealloc
94#include "stristr.h" // findstring
95#include "misc.h" // PaintRecessedWindow
[1029]96#include "fortify.h"
[1335]97#include "excputil.h" // xbeginthread
[2]98
[1210]99// Data definitions
100#pragma data_seg(GLOBAL1)
101HEV CompactSem;
102BOOL fFtpRunWPSDefault;
103BOOL fHttpRunWPSDefault;
104
105#pragma data_seg(GLOBAL2)
106CHAR *httprun;
107CHAR *mailrun;
108
109#pragma data_seg(GLOBAL3)
110LONG standardcolors[16];
111
[2]112#pragma data_seg(DATA2)
[350]113static PSZ pszSrcFile = __FILE__;
114
[2]115#define VF_SELECTED 0x01
116#define VF_FOUND 0x02
117#define VF_HTTP 0x04
118#define VF_FTP 0x08
119
[1433]120#define NEWVIEWMLE_FONT_LCID 5
[2]121
[890]122#define COLORS_MAX 14
[2]123
124#define COLORS_CURSOREDNORMALBACK 0
125#define COLORS_CURSOREDSELECTEDBACK 1
126#define COLORS_NORMALBACK 2
127#define COLORS_SELECTEDBACK 3
128#define COLORS_NORMALFORE 4
129#define COLORS_FOUNDFORE 5
130#define COLORS_SELECTEDFORE 6
131#define COLORS_SELECTEDFOUNDFORE 7
132#define COLORS_HTTPBACK 8
133#define COLORS_HTTPFORE 9
134#define COLORS_FTPBACK 10
135#define COLORS_FTPFORE 11
[890]136#define COLORS_MAILBACK 12
137#define COLORS_MAILFORE 13
[2]138
[895]139static LONG Colors[COLORS_MAX] = {
140 COLR_WHITE, COLR_DARKGRAY,
[551]141 COLR_PALEGRAY, COLR_BLACK,
142 COLR_BLACK, COLR_RED,
143 COLR_WHITE, COLR_YELLOW,
144 COLR_PALEGRAY, COLR_DARKBLUE,
[890]145 COLR_PALEGRAY, COLR_DARKGREEN,
146 COLR_PALEGRAY, COLR_DARKRED
[551]147};
[2]148
149#define SEARCHSTRINGLEN 1024
150
[191]151typedef struct
152{
[895]153 FATTRS fattrs;
154 LONG colors[COLORS_MAX];
[191]155 CHAR *text;
156 CHAR **lines, *markedlines;
157 CHAR searchtext[SEARCHSTRINGLEN], *lastpos, szFacename[FACESIZE];
158 ULONG textsize, numlines, topline, cursored, selected, numalloc, multiplier,
[551]159 lastselected, found;
[191]160 LONG oldwidth, lastdirection, lMaxAscender, lMaxDescender, lMaxHeight,
[551]161 maxx, horzscroll;
[191]162 HMTX ScanSem;
163 HWND hvscroll, hwndMenu, hwndStatus1, hwndStatus2, hwndStatus3, hwndRestore,
[551]164 hwndPopup, hwndListbox, hwndFrame, hwndDrag, hwndParent, hhscroll;
[191]165 HPS hps;
[895]166 USHORT size;
167 USHORT flags;
168 USHORT cliptype;
169 CHAR filename[CCHMAXPATH];
170 CHAR stopflag, busy;
171 BOOL hex, mousecaptured, sensitive, dummy, literalsearch, clientfocused,
172 alsoselect, wrapon, relining, httpin, ftpin, mailin, ignorehttp, ignoreftp,
173 ignoremail, needrefreshing;
[191]174}
175VIEWDATA;
[2]176
[191]177typedef struct
178{
[895]179 ULONG len;
180 CHAR *line;
[2]181 USHORT size;
182 USHORT dummy;
[191]183 CHAR url[SEARCHSTRINGLEN];
184}
185URLDATA;
[2]186
[191]187static BOOL Sensitive = FALSE;
188static USHORT Codepage = 0;
189static BOOL Firsttime = TRUE;
190static BOOL LiteralSearch = FALSE;
191static BOOL AlsoSelect = FALSE;
192static BOOL WrapOn = FALSE;
193static BOOL IgnoreFTP = FALSE;
194static BOOL IgnoreHTTP = FALSE;
[890]195static BOOL IgnoreMail = FALSE;
[2]196static FATTRS Fattrs;
197
[890]198// mailstr checks for a designated character in a string then cuts the string
[895]199//to the first word that contains the character then prepends <mailto: and appends >
[890]200
[1780]201PSZ mailstr(CHAR *pszSrc, CHAR *pszFindChar, LONG StrLens)
[890]202{
[895]203 CHAR *pszCharCounter;
204 CHAR *pszTestStr = pszSrc;
[1780]205 CHAR szMailTo[SEARCHSTRINGLEN] = "mailto:";
[906]206 //CHAR szMailEnd[] = ">";
[890]207
[895]208 if (!strnstr(pszTestStr, pszFindChar, StrLens))
[890]209 return NULL;
[895]210 bstripcr(pszSrc);
211 remove_first_occurence_of_character("\r", pszSrc);
212 remove_first_occurence_of_character("\n", pszSrc);
213 if (!strstr(pszSrc, " ")){
[898]214 if (!stristr(pszSrc, "<mailto:") && !fNoMailtoMailRun) {
[895]215 strip_lead_char("<", pszSrc);
216 strip_trail_char(">", pszSrc);
217 strcat(szMailTo, pszSrc);
[906]218 // strcat(szMailTo, szMailEnd);
[1780]219 strcpy(pszSrc, szMailTo);
[895]220 return pszSrc;
[890]221 }
[895]222 else {
[898]223 strip_lead_char("<", pszSrc);
224 strip_trail_char(">", pszSrc);
[895]225 return pszSrc;
226 }
[890]227 }
[895]228 while (strchr(pszSrc, ' ') < strchr(pszSrc, *pszFindChar)){
229 pszCharCounter = pszSrc;
230 while (*pszCharCounter && *pszCharCounter != ' '){
231 *pszCharCounter = ' ';
232 pszCharCounter++;
233 }
234 lstrip(pszSrc);
235 }
236 pszCharCounter = pszSrc;
237 while (*pszCharCounter && *pszCharCounter != ' ' && *pszCharCounter != '\r' &&
[1335]238 *pszCharCounter != '\n' && *pszCharCounter != '\"')
[895]239 pszCharCounter++;
240 *pszCharCounter = 0;
[898]241 if (!stristr(pszSrc, "<mailto:") && !fNoMailtoMailRun) {
[895]242 strip_lead_char("<", pszSrc);
243 strip_trail_char(">", pszSrc);
244 strcat(szMailTo, pszSrc);
[906]245 //strcat(szMailTo, szMailEnd);
[1780]246 strcpy(pszSrc, szMailTo);
[895]247 return pszSrc;
248 }
249 else {
[898]250 strip_lead_char("<", pszSrc);
251 strip_trail_char(">", pszSrc);
[895]252 return pszSrc;
253 }
[890]254}
255
[191]256MRESULT EXPENTRY UrlDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[83]257{
[2]258 URLDATA *urld;
259
[551]260 switch (msg) {
[191]261 case WM_INITDLG:
[551]262 if (mp2) {
[191]263 CHAR *p, *e, *pp;
264 SHORT count;
[1780]265 CHAR szUrlString[SEARCHSTRINGLEN];
[2]266
[191]267 WinSetWindowPtr(hwnd, QWL_USER, mp2);
268 urld = mp2;
[551]269 e = urld->line + urld->len + 1;
270 p = urld->line;
271 do {
[191]272 p = strnstr(p, "http://", e - p);
[551]273 if (p) {
274 strncpy(urld->url, p, min(e - p, SEARCHSTRINGLEN - 1));
275 urld->url[min(e - p, SEARCHSTRINGLEN - 1)] = 0;
276 pp = urld->url;
[191]277 while (*pp && *pp != ' ' && *pp != '\r' && *pp != '\n' &&
278 *pp != '\"')
279 pp++;
280 *pp = 0;
281 WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_INSERTITEM,
[551]282 MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url));
[191]283 p++;
284 }
[2]285 }
[191]286 while (p && *p && p < e);
[551]287 p = urld->line;
288 do {
[191]289 p = strnstr(p, "ftp://", e - p);
[551]290 if (p) {
291 strncpy(urld->url, p, min(e - p, SEARCHSTRINGLEN - 1));
292 urld->url[min(e - p, SEARCHSTRINGLEN - 1)] = 0;
293 pp = urld->url;
[191]294 while (*pp && *pp != ' ' && *pp != '\r' && *pp != '\n' &&
295 *pp != '\"')
296 pp++;
297 *pp = 0;
298 WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_INSERTITEM,
[551]299 MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url));
[191]300 p++;
[1335]301 }
[191]302 }
303 while (p && *p && p < e);
[890]304 p = urld->line;
[1780]305 if (strchr(p, '@')) {
306 strcpy(szUrlString, urld->line);
307 mailstr(szUrlString, "@", e - p);
308 strcpy(urld->url, szUrlString);
309 if (pp = strchr(urld->url, '>'))
310 *pp = 0;
[1335]311 WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_INSERTITEM,
312 MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url));
[890]313 }
[551]314 *urld->url = 0;
[191]315 count = (SHORT) WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_QUERYITEMCOUNT,
316 MPVOID, MPVOID);
[551]317 if (count) {
[191]318 WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_SELECTITEM,
319 MPFROMSHORT(0), MPFROMSHORT(TRUE));
320 if (count == 1)
321 WinSendMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
322 else
323 PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
324 break;
325 }
326 }
327 WinDismissDlg(hwnd, 0);
328 break;
[2]329
[191]330 case UM_SETUP:
331 WinShowWindow(hwnd, TRUE);
332 return 0;
[2]333
[191]334 case WM_CONTROL:
[551]335 switch (SHORT1FROMMP(mp1)) {
[191]336 case URL_LISTBOX:
[551]337 switch (SHORT2FROMMP(mp1)) {
[191]338 case LN_ENTER:
339 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
340 break;
[2]341 }
[191]342 break;
343 }
344 return 0;
[2]345
[191]346 case WM_COMMAND:
[551]347 switch (SHORT1FROMMP(mp1)) {
[191]348 case URL_BOOKMARK:
349 WinDismissDlg(hwnd, 3);
350 break;
[2]351
[191]352 case DID_OK:
353 {
354 SHORT select;
[2]355
[191]356 urld = WinQueryWindowPtr(hwnd, QWL_USER);
[551]357 if (urld) {
[191]358 select = (SHORT) WinSendDlgItemMsg(hwnd, URL_LISTBOX,
359 LM_QUERYSELECTION,
[551]360 MPFROMSHORT(LIT_FIRST), MPVOID);
361 if (select >= 0) {
362 *urld->url = 0;
[191]363 WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_QUERYITEMTEXT,
[551]364 MPFROM2SHORT(select, sizeof(urld->url)),
365 MPFROMP(urld->url));
366 if (*urld->url) {
367 if (!strncmp(urld->url, "http://", 7)) {
[191]368 WinDismissDlg(hwnd, 1);
369 break;
370 }
[551]371 else if (!strncmp(urld->url, "ftp://", 6)) {
372 memmove(urld->url, urld->url + 6, strlen(urld->url) + 1);
373 if (*urld->url) {
[191]374 WinDismissDlg(hwnd, 2);
375 break;
376 }
[1335]377 }
378 else if (strchr(urld->url, '@')) {
[890]379 WinDismissDlg(hwnd, 3);
380 break;
[1335]381 }
[191]382 }
383 }
384 }
385 }
[1398]386 Runtime_Error(pszSrcFile, __LINE__, NULL);
[191]387 break;
[2]388
[191]389 case DID_CANCEL:
390 WinDismissDlg(hwnd, 0);
391 break;
[2]392
[191]393 case IDM_HELP:
394 break;
395 }
396 return 0;
[2]397 }
[191]398 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]399}
400
[191]401static ULONG NumLines(RECTL * rcl, VIEWDATA * ad)
[83]402{
[2]403 ULONG numlines;
404
[551]405 numlines = (rcl->yTop - rcl->yBottom) / ad->lMaxHeight;
406 if (ad->lMaxDescender && numlines &&
407 ((rcl->yTop - rcl->yBottom) -
408 (numlines * ad->lMaxHeight) <= ad->lMaxDescender))
[2]409 numlines--;
410 return numlines;
411}
412
[191]413static CHAR **BuildAList(HWND hwnd)
[83]414{
[191]415 VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
416 register ULONG x, y, z = 0;
417 ULONG width;
418 RECTL Rectl;
419 CHAR **list = NULL, s[SEARCHSTRINGLEN], a;
420 register CHAR *p, *e;
[907]421 UINT numlines = 0, numalloc = 0;
[2]422
[551]423 if (ad && ad->selected) {
[191]424 WinQueryWindowRect(hwnd, &Rectl);
[551]425 width = (Rectl.xRight - Rectl.xLeft) / ad->fattrs.lAveCharWidth;
426 if (!width && !ad->hex)
[2]427 return list;
[551]428 for (x = 0; x < ad->numlines; x++) {
429 if (ad->stopflag)
[191]430 break;
[551]431 if (ad->markedlines[x] & VF_SELECTED) {
432 if (ad->hex) {
433 width = ad->textsize - (x * 16);
[191]434 width = min(width, 16);
435 sprintf(s, "%08lx ", x * 16);
436 p = s + 9;
[551]437 for (y = 0; y < width; y++) {
[870]438 sprintf(p, " %02x", (UCHAR)ad->text[(x * 16) + y]);
[191]439 p += 3;
440 }
441 *p = ' ';
442 p++;
443 *p = ' ';
444 p++;
[551]445 for (y = 0; y < width; y++) {
446 a = ad->text[(x * 16) + y];
[191]447 if (a && a != '\n' && a != '\r' && a != '\t' && a != '\x1a')
[551]448 *p = ad->text[(x * 16) + y];
[191]449 else
450 *p = '.';
451 p++;
452 }
453 *p = 0;
454 }
[551]455 else {
456 if (!ad->wrapon) {
457 e = p = ad->lines[x];
458 while (*e != '\r' && *e != '\n' && e < ad->text + ad->textsize)
[191]459 e++;
460 width = e - p;
461 }
[551]462 else {
463 p = ad->lines[x];
[191]464 e = p + (width - 1);
[551]465 if (e - ad->text > ad->textsize)
466 e = ad->text + ad->textsize;
467 while (p < e) {
468 if (*p == '\r' || *p == '\n') {
[191]469 e = p;
470 break;
471 }
472 p++;
473 }
474 }
[551]475 strncpy(s, ad->lines[x], e - ad->lines[x]);
476 s[e - ad->lines[x]] = 0;
[191]477 }
478 if (AddToList(s, &list, &numlines, &numalloc))
479 break;
480 z++;
[551]481 if (z >= ad->selected)
[191]482 break;
[2]483 }
484 }
485 }
486 return list;
487}
488
[191]489static CHAR **BuildAList2(HWND hwnd)
[83]490{
[191]491 VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
492 CHAR **list = NULL, s[SEARCHSTRINGLEN];
493 SHORT x, z;
[907]494 UINT numlines = 0, numalloc = 0;
[2]495
[551]496 if (ad) {
497 z = (SHORT) WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
[191]498 LM_QUERYITEMCOUNT, MPVOID, MPVOID);
499 z = max(z, 0);
[551]500 for (x = 0; x < z; x++) {
501 if (ad->stopflag)
[191]502 break;
[2]503 *s = 0;
[551]504 WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX, LM_QUERYITEMTEXT,
[191]505 MPFROM2SHORT(x, SEARCHSTRINGLEN), MPFROMP(s));
506 if (*s)
507 if (AddToList(s, &list, &numlines, &numalloc))
508 break;
[2]509 }
510 }
511 return list;
512}
513
[191]514MRESULT EXPENTRY ViewStatusProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[83]515{
[551]516 switch (msg) {
[191]517 case WM_CREATE:
518 return CommonTextProc(hwnd, msg, mp1, mp2);
[2]519
[191]520 case WM_MOUSEMOVE:
521 {
522 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
523
[551]524 if (fOtherHelp) {
525 if ((!hwndBubble || WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd)
526 && !WinQueryCapture(HWND_DESKTOP)) {
[2]527
[1394]528 PCSZ s = NULL;
[2]529
[551]530 switch (id) {
[191]531 case NEWVIEW_STATUS2:
532 s = GetPString(IDS_NVSTATUS2HELPTEXT);
533 break;
534 case NEWVIEW_STATUS3:
535 s = GetPString(IDS_NVSTATUS3HELPTEXT);
536 break;
537 case NEWVIEW_DRAG:
538 s = GetPString(IDS_NVDRAGHELPTEXT);
539 break;
540 }
541 if (s && *s)
542 MakeBubble(hwnd, TRUE, s);
543 else if (hwndBubble)
544 WinDestroyWindow(hwndBubble);
545 }
[2]546 }
[551]547 switch (id) {
[191]548 case NEWVIEW_STATUS1:
549 break;
550 default:
551 return CommonTextButton(hwnd, msg, mp1, mp2);
552 }
553 }
554 break;
[2]555
[191]556 case WM_BUTTON3UP:
557 case WM_BUTTON1UP:
558 case WM_BUTTON1DOWN:
559 case WM_BUTTON3DOWN:
560 {
561 USHORT id;
562
563 id = WinQueryWindowUShort(hwnd, QWS_ID);
[551]564 switch (id) {
[191]565 case NEWVIEW_STATUS1:
566 break;
567 default:
568 return CommonTextButton(hwnd, msg, mp1, mp2);
[2]569 }
[191]570 }
571 break;
[2]572
[191]573 case UM_CLICKED:
574 case UM_CLICKED3:
575 {
576 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID), cmd = 0;
577
[551]578 switch (id) {
[191]579 case NEWVIEW_DRAG:
580 if (msg == UM_CLICKED)
581 cmd = (msg == UM_CLICKED) ? IDM_HEXMODE : IDM_DESELECTALL;
582 break;
583 case NEWVIEW_STATUS2:
584 cmd = (msg == UM_CLICKED) ? IDM_GOTOLINE : IDM_FINDFIRST;
585 break;
586 case NEWVIEW_STATUS3:
587 cmd = (msg == UM_CLICKED) ? IDM_GOTOOFFSET : IDM_FINDNEXT;
588 break;
589 default:
590 break;
[2]591 }
[191]592 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
593 FID_CLIENT),
[551]594 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
[191]595 }
596 return 0;
[2]597
[191]598 case WM_BEGINDRAG:
599 {
600 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
601
[551]602 switch (id) {
[191]603 case NEWVIEW_STATUS1:
604 case NEWVIEW_DRAG:
605 {
[551]606 VIEWDATA *ad =
607 WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
608 QW_PARENT),
[574]609 FID_CLIENT), QWL_USER);
[2]610
[191]611 if (ad)
612 DragOne(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]613 FID_CLIENT), (HWND) 0, ad->filename,
614 FALSE);
[191]615 }
616 break;
617 default:
618 break;
[2]619 }
[191]620 }
621 break;
[2]622
[191]623 case WM_CONTEXTMENU:
624 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
[551]625 FID_CLIENT), UM_CONTEXTMENU, MPVOID, MPVOID);
[191]626 break;
[2]627
[191]628 case WM_SETFOCUS:
629 if (mp2)
630 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
631 break;
[2]632
[191]633 case WM_PAINT:
634 {
635 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
636 ULONG color;
637 VIEWDATA *ad = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
[551]638 QW_PARENT),
[574]639 FID_CLIENT), QWL_USER);
[191]640 SWP swp;
641 POINTL ptl;
642 HPS hps;
643
[551]644 switch (id) {
[191]645 case NEWVIEW_STATUS1:
646 PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
647 break;
648 default:
649 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
650 break;
[2]651 }
[191]652 hps = WinGetPS(WinQueryWindow(hwnd, QW_PARENT));
[551]653 if (hps) {
[191]654 WinQueryWindowPos(hwnd, &swp);
655 ptl.x = swp.x - 1;
656 ptl.y = swp.y + swp.cy + 2;
657 GpiMove(hps, &ptl);
[551]658 switch (id) {
[191]659 case NEWVIEW_STATUS1:
660 if (ad)
[551]661 color =
662 (standardcolors[ad->colors[COLORS_NORMALBACK]] ==
663 CLR_WHITE) ? CLR_PALEGRAY : CLR_WHITE;
[191]664 else
665 color = CLR_WHITE;
666 break;
667 default:
668 if (ad)
[551]669 color =
670 (standardcolors[ad->colors[COLORS_NORMALBACK]] ==
671 CLR_PALEGRAY) ? CLR_DARKGRAY : CLR_PALEGRAY;
[191]672 else
673 color = CLR_PALEGRAY;
674 break;
675 }
676 GpiSetColor(hps, color);
677 ptl.x = swp.x + swp.cx;
678 GpiLine(hps, &ptl);
679 WinReleasePS(hps);
680 }
681 }
682 break;
[2]683
[191]684 case UM_FOCUSME:
685 WinSetFocus(HWND_DESKTOP,
[551]686 WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT), FID_CLIENT));
[191]687 return 0;
[2]688 }
[191]689 return PFNWPStatic(hwnd, msg, mp1, mp2);
[2]690}
691
[191]692static VOID FreeViewerMem(HWND hwnd)
[83]693{
[191]694 VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
[2]695
[551]696 if (ad) {
697 ad->selected = ad->textsize = ad->numlines = ad->numalloc = 0;
[1009]698 xfree(ad->text, pszSrcFile, __LINE__);
699 xfree(ad->lines, pszSrcFile, __LINE__);
700 xfree(ad->markedlines, pszSrcFile, __LINE__);
[551]701 ad->text = NULL;
702 ad->lines = NULL;
703 ad->markedlines = NULL;
[2]704 DosPostEventSem(CompactSem);
705 }
706}
707
[191]708static HPS InitWindow(HWND hwnd)
[83]709{
[191]710 VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
711 HPS hps = (HPS) 0;
712 SIZEL sizel;
713 FONTMETRICS FontMetrics;
[2]714
[551]715 if (ad) {
[2]716 sizel.cx = sizel.cy = 0;
[191]717 hps = GpiCreatePS(WinQueryAnchorBlock(hwnd), WinOpenWindowDC(hwnd),
718 (PSIZEL) & sizel, PU_PELS | GPIF_DEFAULT | GPIT_MICRO |
719 GPIA_ASSOC);
[551]720 if (hps) {
721 GpiSetCp(hps, (ULONG) ad->fattrs.usCodePage);
[1433]722 GpiCreateLogFont(hps, NULL, NEWVIEWMLE_FONT_LCID, &ad->fattrs);
723 GpiSetCharSet(hps, NEWVIEWMLE_FONT_LCID);
[551]724 GpiQueryFontMetrics(hps, (long)sizeof(FONTMETRICS), &FontMetrics);
725 ad->fattrs.lAveCharWidth = FontMetrics.lAveCharWidth;
726 ad->fattrs.lMaxBaselineExt = FontMetrics.lMaxBaselineExt;
727 ad->lMaxAscender = max(FontMetrics.lMaxAscender, 0);
728 ad->lMaxDescender = max(FontMetrics.lMaxDescender, 0);
729 ad->lMaxHeight = ad->lMaxAscender + ad->lMaxDescender;
730 if (ad->fattrs.usCodePage != FontMetrics.usCodePage) {
731 ad->fattrs.usCodePage = FontMetrics.usCodePage;
732 Codepage = ad->fattrs.usCodePage;
[191]733 PrfWriteProfileData(fmprof,
734 appname,
735 "Viewer.Codepage",
[551]736 &ad->fattrs.usCodePage, sizeof(USHORT));
[2]737 }
[551]738 else if (ad->fattrs.usCodePage) {
[2]739
[191]740 HMQ hmq;
741 ULONG cps[50], len, x;
[2]742
[551]743 if (!DosQueryCp(sizeof(cps), cps, &len)) {
744 for (x = 0; x < len / sizeof(ULONG); x++) {
745 if (cps[x] == (ULONG) ad->fattrs.usCodePage) {
[191]746 hmq = WinQueryWindowULong(hwnd, QWL_HMQ);
[551]747 WinSetCp(hmq, ad->fattrs.usCodePage);
[191]748 break;
749 }
750 }
751 }
[551]752 DosSetProcessCp((ULONG) ad->fattrs.usCodePage);
[2]753 }
[191]754 GpiSetBackMix(hps, BM_OVERPAINT);
[551]755 SetPresParamFromFattrs(WinWindowFromID(ad->hwndFrame, NEWVIEW_LISTBOX),
756 &ad->fattrs, FontMetrics.sNominalPointSize,
757 MAKEFIXED(FontMetrics.sNominalPointSize / 10,
758 0));
[2]759 }
760 }
761 return (hps);
762}
763
[191]764static VOID PaintLine(HWND hwnd, HPS hps, ULONG whichline, ULONG topline,
765 RECTL * Rectl)
[83]766{
[191]767 VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
768 POINTL ptl;
769 ULONG width;
770 register CHAR *p, *e;
771 CHAR marker[] = " >";
772 RECTL rcl2;
[2]773
[551]774 if (ad && (ad->hex || ad->lines)) {
775 ptl.y = (Rectl->yTop - (ad->lMaxHeight *
776 (((whichline + 1) - topline) + 1)));
[2]777 ptl.x = 0;
[191]778 GpiMove(hps, &ptl);
779 GpiSetBackMix(hps, BM_OVERPAINT);
[551]780 if (ad->markedlines) {
781 if (ad->markedlines[whichline] & VF_SELECTED) {
782 GpiSetColor(hps, ((ad->markedlines[whichline] & VF_FOUND) != 0) ?
783 standardcolors[ad->colors[COLORS_SELECTEDFOUNDFORE]] :
784 standardcolors[ad->colors[COLORS_SELECTEDFORE]]);
785 GpiSetBackColor(hps, (whichline == ad->cursored - 1) ?
786 standardcolors[ad->
787 colors[COLORS_CURSOREDSELECTEDBACK]] :
788 standardcolors[ad->colors[COLORS_SELECTEDBACK]]);
[2]789 }
[551]790 else if (ad->markedlines[whichline] & VF_FOUND) {
791 GpiSetColor(hps, standardcolors[ad->colors[COLORS_FOUNDFORE]]);
792 GpiSetBackColor(hps, (whichline == ad->cursored - 1) ?
793 standardcolors[ad->
794 colors[COLORS_CURSOREDNORMALBACK]] :
795 standardcolors[ad->colors[COLORS_NORMALBACK]]);
[2]796 }
[551]797 else {
798 GpiSetColor(hps, standardcolors[ad->colors[COLORS_NORMALFORE]]);
799 GpiSetBackColor(hps, (whichline == ad->cursored - 1) ?
800 standardcolors[ad->
801 colors[COLORS_CURSOREDNORMALBACK]] :
802 standardcolors[ad->colors[COLORS_NORMALBACK]]);
[2]803 }
804 }
[551]805 else {
806 GpiSetColor(hps, standardcolors[ad->colors[COLORS_NORMALFORE]]);
807 GpiSetBackColor(hps, (whichline == ad->cursored - 1) ?
808 standardcolors[ad->colors[COLORS_CURSOREDNORMALBACK]] :
809 standardcolors[ad->colors[COLORS_NORMALBACK]]);
[2]810 }
[551]811 if (!ad->hex) {
812 if (ad->wrapon) {
813 width = (Rectl->xRight - Rectl->xLeft) / ad->fattrs.lAveCharWidth;
814 if (width) {
815 GpiCharString(hps, 1, marker + (whichline == ad->cursored - 1));
816 p = ad->lines[whichline];
[191]817 e = p + (width - 1);
[551]818 if (e - ad->text > ad->textsize)
819 e = ad->text + ad->textsize;
820 while (p < e) {
821 if (*p == '\r' || *p == '\n') {
[191]822 e = p;
823 break;
824 }
825 p++;
826 }
[551]827 if (ad->ftpin && whichline != ad->cursored - 1
828 && (!ad->markedlines
829 || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
830 && strnstr(ad->lines[whichline], "ftp://",
831 e - ad->lines[whichline])) {
832 GpiSetColor(hps, standardcolors[ad->colors[COLORS_FTPFORE]]);
833 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_FTPBACK]]);
[191]834 }
[551]835 if (ad->httpin && whichline != ad->cursored - 1
836 && (!ad->markedlines
837 || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
838 && strnstr(ad->lines[whichline], "http://",
839 e - ad->lines[whichline])) {
840 GpiSetColor(hps, standardcolors[ad->colors[COLORS_HTTPFORE]]);
841 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_HTTPBACK]]);
[1335]842 }
[890]843
[1335]844 if (ad->mailin && whichline != ad->cursored - 1
[890]845 && (!ad->markedlines
846 || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
847 && strnstr(ad->lines[whichline], "@",e - ad->lines[whichline])) {
848 GpiSetColor(hps, standardcolors[ad->colors[COLORS_MAILFORE]]);
849 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_MAILBACK]]);
[191]850 }
851 rcl2 = *Rectl;
[551]852 rcl2.yTop = ptl.y + ad->lMaxAscender;
853 rcl2.yBottom = ptl.y - ad->lMaxDescender;
854 GpiCharString(hps, e - ad->lines[whichline], ad->lines[whichline]);
[191]855 GpiQueryCurrentPosition(hps, &ptl);
856 rcl2.xLeft = ptl.x;
857 WinFillRect(hps, &rcl2,
[551]858 standardcolors[ad->colors[COLORS_NORMALBACK]]);
[191]859 }
[2]860 }
[551]861 else {
862 width = (Rectl->xRight - Rectl->xLeft) / ad->fattrs.lAveCharWidth;
863 if (width) {
864 GpiCharString(hps, 1, marker + (whichline == ad->cursored - 1));
865 p = ad->lines[whichline];
866 e = p + (abs(ad->horzscroll) / ad->fattrs.lAveCharWidth);
867 if (e - ad->text > ad->textsize)
868 e = ad->text + ad->textsize;
869 while (p < e) {
[191]870 if (*p == '\r' || *p == '\n')
871 break;
872 p++;
873 }
[551]874 if (*p != '\r' && *p != '\n') {
[2]875
[191]876 CHAR *pp;
[2]877
[191]878 e = p + (width - 1);
[551]879 if (e - ad->text > ad->textsize)
880 e = ad->text + ad->textsize;
[191]881 pp = p;
[551]882 while (pp < e) {
883 if (*pp == '\r' || *pp == '\n') {
[191]884 e = pp;
885 break;
886 }
887 pp++;
888 }
889 }
890 else
891 e = p;
[551]892 if (ad->ftpin && whichline != ad->cursored - 1
893 && (!ad->markedlines
894 || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
895 && strnstr(ad->lines[whichline], "ftp://",
896 e - ad->lines[whichline])) {
897 GpiSetColor(hps, standardcolors[ad->colors[COLORS_FTPFORE]]);
898 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_FTPBACK]]);
[191]899 }
[551]900 if (ad->httpin && whichline != ad->cursored - 1
901 && (!ad->markedlines
902 || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
[890]903 && strnstr(ad->lines[whichline], "http://",e - ad->lines[whichline])) {
[551]904 GpiSetColor(hps, standardcolors[ad->colors[COLORS_HTTPFORE]]);
905 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_HTTPBACK]]);
[1335]906 }
[890]907
[1335]908 if (ad->mailin && whichline != ad->cursored - 1
[890]909 && (!ad->markedlines
910 || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND)))
911 && strnstr(ad->lines[whichline], "@",e - ad->lines[whichline])) {
912 GpiSetColor(hps, standardcolors[ad->colors[COLORS_MAILFORE]]);
913 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_MAILBACK]]);
[191]914 }
915 rcl2 = *Rectl;
[551]916 rcl2.yTop = ptl.y + ad->lMaxAscender;
917 rcl2.yBottom = ptl.y - ad->lMaxDescender;
[191]918 GpiCharString(hps, e - p, p);
919 GpiQueryCurrentPosition(hps, &ptl);
920 rcl2.xLeft = ptl.x;
921 WinFillRect(hps, &rcl2,
[551]922 standardcolors[ad->colors[COLORS_NORMALBACK]]);
[191]923 }
[2]924 }
925 }
[551]926 else {
[2]927
[191]928 CHAR s[80];
929 register ULONG x;
[2]930
931 rcl2 = *Rectl;
[551]932 rcl2.yTop = ptl.y + ad->lMaxAscender;
933 rcl2.yBottom = ptl.y - ad->lMaxDescender;
934 GpiCharString(hps, 1, marker + (whichline == ad->cursored - 1));
935 width = ad->textsize - (whichline * 16);
[191]936 width = min(width, 16);
[551]937 sprintf(s, "%08lx ", whichline * 16);
[2]938 p = s + 9;
[551]939 for (x = 0; x < width; x++) {
[870]940 sprintf(p, " %02x", (UCHAR)ad->text[(whichline * 16) + x]);
[191]941 p += 3;
[2]942 }
[551]943 for (; x < 16; x++) {
[191]944 *p = ' ';
945 p++;
946 *p = ' ';
947 p++;
948 *p = ' ';
949 p++;
[2]950 }
951 *p = ' ';
952 p++;
953 *p = ' ';
954 p++;
[551]955 for (x = 0; x < width; x++) {
956 *p = ad->text[(whichline * 16) + x];
[191]957 p++;
[2]958 }
959 *p = 0;
[551]960 GpiCharString(hps, (p - s) - (abs(ad->horzscroll) /
961 ad->fattrs.lAveCharWidth),
962 s + (abs(ad->horzscroll) / ad->fattrs.lAveCharWidth));
[191]963 GpiQueryCurrentPosition(hps, &ptl);
[551]964 if (ptl.x + abs(ad->horzscroll) + ad->fattrs.lAveCharWidth + 1 >
965 ad->maxx) {
966 ad->maxx = ptl.x + abs(ad->horzscroll) + ad->fattrs.lAveCharWidth + 1;
967 WinSendMsg(ad->hhscroll, SBM_SETTHUMBSIZE,
968 MPFROM2SHORT((SHORT) Rectl->xRight, (SHORT) ad->maxx),
[191]969 MPVOID);
[2]970 }
971 rcl2.xLeft = ptl.x;
[551]972 WinFillRect(hps, &rcl2, standardcolors[ad->colors[COLORS_NORMALBACK]]);
[2]973 }
974 }
975}
976
[533]977static VOID SearchThread(VOID * args)
[83]978{
[551]979 HWND hwnd = (HWND) args;
[191]980 HAB hab2;
981 HMQ hmq2;
982 VIEWDATA *ad;
[2]983 register CHAR *p;
[191]984 RECTL Rectl;
985 ULONG width, numlines, lastline, whichline, firstline = ULONG_MAX;
[2]986 register ULONG x;
[191]987 CHAR s[SEARCHSTRINGLEN], s2[SEARCHSTRINGLEN], *t, *n, markwith;
[2]988
989 priority_normal();
[1063]990# ifdef FORTIFY
991 Fortify_EnterScope();
992# endif
[2]993 hab2 = WinInitialize(0);
[551]994 if (hab2) {
[191]995 hmq2 = WinCreateMsgQueue(hab2, 0);
[533]996 if (hmq2) {
[191]997 WinCancelShutdown(hmq2, TRUE);
[533]998 IncrThreadUsage();
[191]999 ad = WinQueryWindowPtr(hwnd, QWL_USER);
[551]1000 if (ad) {
1001 if (!DosRequestMutexSem(ad->ScanSem, SEM_INDEFINITE_WAIT)) {
1002 markwith = VF_FOUND | ((ad->alsoselect) ? VF_SELECTED : 0);
1003 strcpy(s, ad->searchtext);
1004 if (*s) {
[191]1005 WinQueryWindowRect(hwnd, &Rectl);
[551]1006 width = (Rectl.xRight - Rectl.xLeft) / ad->fattrs.lAveCharWidth;
[191]1007 numlines = NumLines(&Rectl, ad);
[551]1008 WinSetWindowText(WinWindowFromID(ad->hwndFrame,
[191]1009 NEWVIEW_STATUS1),
[1498]1010 (CHAR *) GetPString(IDS_SEARCHINGTEXT));
[551]1011 if (numlines && width && ad->markedlines && ad->numlines &&
1012 ad->text && ad->textsize) {
1013 for (x = 0; x < ad->numlines && !ad->stopflag; x++)
1014 ad->markedlines[x] &= (~VF_FOUND);
1015 ad->found = 0;
[191]1016 t = s;
[551]1017 while (t && !ad->stopflag) {
[191]1018 lastline = 1;
[368]1019 n = convert_nl_to_nul(t);
[551]1020 if (*t) {
[191]1021 strcpy(s2, t);
[551]1022 if (ad->literalsearch)
[191]1023 literal(s2);
[551]1024 p = ad->text;
1025 while (p && !ad->stopflag) {
[191]1026 p = findstring(s2, strlen(s2), p,
[551]1027 ad->textsize - (p - ad->text),
1028 ad->sensitive);
1029 if (p) {
1030 if (ad->hex) {
1031 whichline = (p - ad->text) / 16;
[191]1032 if (whichline < firstline)
1033 firstline = whichline;
[551]1034 if (!(ad->markedlines[whichline] & VF_FOUND))
1035 ad->found++;
1036 if (markwith & VF_SELECTED) {
1037 if (!(ad->markedlines[whichline] & VF_SELECTED))
1038 ad->selected++;
[191]1039 }
[551]1040 ad->markedlines[whichline] |= markwith;
1041 if ((p - ad->text) + strlen(s2) >
1042 (whichline + 1) * 16) {
[191]1043 whichline++;
[551]1044 if (!(ad->markedlines[whichline] & VF_FOUND))
1045 ad->found++;
1046 if (markwith & VF_SELECTED) {
1047 if (!(ad->markedlines[whichline] & VF_SELECTED))
1048 ad->selected++;
[191]1049 }
[551]1050 ad->markedlines[whichline] |= markwith;
[191]1051 }
[551]1052 p = ad->text + ((whichline + 1) * 16);
1053 if (p >= ad->text + ad->textsize)
[191]1054 break;
1055 }
[551]1056 else {
1057 for (x = lastline; x < ad->numlines; x++) {
1058 if (ad->lines[x] > p) {
[191]1059 if (x - 1 < firstline)
1060 firstline = x - 1;
[551]1061 if (!(ad->markedlines[x - 1] & VF_FOUND))
1062 ad->found++;
1063 if (markwith & VF_SELECTED) {
1064 if (!(ad->markedlines[x - 1] & VF_SELECTED))
1065 ad->selected++;
[191]1066 }
[551]1067 ad->markedlines[x - 1] |= markwith;
1068 if (x + 1 < ad->numlines &&
1069 p + strlen(s2) > ad->lines[x]) {
[191]1070 x++;
[551]1071 if (!(ad->markedlines[x - 1] & VF_FOUND))
1072 ad->found++;
1073 if (markwith & VF_SELECTED) {
1074 if (!(ad->markedlines[x - 1] & VF_SELECTED))
1075 ad->selected++;
[191]1076 }
[551]1077 ad->markedlines[x - 1] |= markwith;
[191]1078 }
1079 lastline = x;
[551]1080 p = ad->lines[x];
[191]1081 break;
1082 }
1083 }
[551]1084 if (x >= ad->numlines) {
1085 if (markwith & VF_SELECTED) {
1086 if (!
1087 (ad->markedlines[numlines - 1] & VF_SELECTED))
1088 ad->selected++;
1089 if (!(ad->markedlines[numlines - 1] & VF_FOUND))
1090 ad->found++;
[191]1091 }
[551]1092 ad->markedlines[ad->numlines - 1] |= markwith;
[191]1093 break;
1094 }
1095 }
1096 }
1097 }
1098 }
1099 t = n;
1100 }
1101 }
[551]1102 DosReleaseMutexSem(ad->ScanSem);
1103 if (!ad->stopflag && firstline == ULONG_MAX) {
[1395]1104 if (!fAlertBeepOff)
1105 DosBeep(50, 50);
[551]1106 WinSetWindowText(WinWindowFromID(ad->hwndFrame,
[191]1107 NEWVIEW_STATUS1),
[1498]1108 (CHAR *) GetPString(IDS_NOMATCHINGTEXT));
[771]1109 DosSleep(150);//05 Aug 07 GKY 1500
[191]1110 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1111 PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
1112 }
[551]1113 else if (!ad->stopflag) {
[191]1114 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1115 PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
1116 PostMsg(hwnd, UM_CONTAINER_FILLED,
[551]1117 MPFROMLONG(firstline + 1), MPFROMLONG(firstline + 1));
[191]1118 }
1119 }
1120 else
[551]1121 DosReleaseMutexSem(ad->ScanSem);
[191]1122 }
[2]1123 }
1124 WinDestroyMsgQueue(hmq2);
1125 }
[533]1126 DecrThreadUsage();
[2]1127 WinTerminate(hab2);
1128 }
[1063]1129
1130# ifdef FORTIFY
1131 Fortify_LeaveScope();
1132# endif
[2]1133 DosPostEventSem(CompactSem);
1134}
1135
[533]1136static VOID ClipboardThread(VOID * args)
[83]1137{
[551]1138 HWND hwnd = (HWND) args;
[191]1139 HAB hab2;
1140 HMQ hmq2;
[2]1141 VIEWDATA *ad;
[191]1142 CHAR **list;
1143 USHORT cmd;
[2]1144 register ULONG x;
[191]1145 BOOL released = FALSE;
[2]1146
1147 priority_normal();
[1063]1148# ifdef FORTIFY
1149 Fortify_EnterScope();
1150# endif
[2]1151 hab2 = WinInitialize(0);
[551]1152 if (hab2) {
[191]1153 hmq2 = WinCreateMsgQueue(hab2, 0);
[533]1154 if (hmq2) {
[191]1155 WinCancelShutdown(hmq2, TRUE);
[533]1156 IncrThreadUsage();
[191]1157 ad = WinQueryWindowPtr(hwnd, QWL_USER);
[551]1158 if (ad) {
1159 if (!DosRequestMutexSem(ad->ScanSem, SEM_INDEFINITE_WAIT)) {
1160 cmd = ad->cliptype;
1161 if (ad->numlines && ad->text && ad->textsize && ad->markedlines &&
1162 !ad->stopflag) {
1163 WinSetWindowText(WinWindowFromID(ad->hwndFrame,
[191]1164 NEWVIEW_STATUS1),
[1498]1165 (CHAR *) GetPString(IDS_BUILDINGLINELISTTEXT));
[191]1166 if (cmd == IDM_SAVETOCLIP || cmd == IDM_APPENDTOCLIP ||
1167 cmd == IDM_SAVETOLIST)
1168 list = BuildAList(hwnd);
1169 else
1170 list = BuildAList2(hwnd);
[551]1171 if (list) {
1172 if (!ad->stopflag) {
1173 WinSetWindowText(WinWindowFromID(ad->hwndFrame,
[191]1174 NEWVIEW_STATUS1),
1175 (cmd == IDM_SAVETOCLIP ||
1176 cmd == IDM_SAVETOCLIP2) ?
[1498]1177 (CHAR *) GetPString(IDS_SAVETOCLIPTEXT) :
[191]1178 (cmd == IDM_APPENDTOCLIP ||
1179 cmd == IDM_APPENDTOCLIP2) ?
[1498]1180 (CHAR *) GetPString(IDS_APPENDTOCLIPTEXT) :
1181 (CHAR *) GetPString(IDS_WRITETOFILETEXT));
[551]1182 DosReleaseMutexSem(ad->ScanSem);
[191]1183 released = TRUE;
1184 if (cmd == IDM_SAVETOCLIP || cmd == IDM_APPENDTOCLIP ||
1185 cmd == IDM_SAVETOCLIP2 || cmd == IDM_APPENDTOCLIP2)
[1084]1186 ListToClipboardHab(hab2, list, cmd);
[551]1187 else {
[2]1188
[191]1189 FILE *fp;
[1544]1190 CHAR filename[CCHMAXPATH];
1191 CHAR *modea = "a+";
[2]1192
[191]1193 *filename = 0;
[551]1194 if (export_filename(hwnd, filename, FALSE)) {
[1544]1195 fp = xfsopen(filename, modea, SH_DENYWR, pszSrcFile, __LINE__, TRUE);
[350]1196 if (!fp) {
1197 saymsg(MB_CANCEL,
1198 hwnd,
1199 GetPString(IDS_ERRORTEXT),
[551]1200 GetPString(IDS_CANTOPENFORWRITETEXT), filename);
[350]1201 }
1202 else {
[191]1203 fseek(fp, 0L, SEEK_END);
1204 for (x = 0; list[x]; x++)
[551]1205 fprintf(fp, "%s\n", list[x]);
[191]1206 fclose(fp);
1207 }
1208 }
1209 }
1210 }
1211 FreeList(list);
1212 }
[551]1213 else {
1214 DosReleaseMutexSem(ad->ScanSem);
[191]1215 released = TRUE;
[1395]1216 if (!fAlertBeepOff)
1217 DosBeep(50, 100);
[551]1218 WinSetWindowText(WinWindowFromID(ad->hwndFrame,
[191]1219 NEWVIEW_STATUS1),
[1498]1220 (CHAR *) GetPString(IDS_NVNOLINESSELTEXT));
[771]1221 DosSleep(150);//05 Aug 07 GKY 1500
[191]1222 }
1223 }
1224 if (!released)
[551]1225 DosReleaseMutexSem(ad->ScanSem);
[191]1226 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1227 }
[2]1228 }
1229 WinDestroyMsgQueue(hmq2);
1230 }
[533]1231 DecrThreadUsage();
[2]1232 WinTerminate(hab2);
1233 }
[1063]1234# ifdef FORTIFY
1235 Fortify_LeaveScope();
1236# endif
[2]1237 DosPostEventSem(CompactSem);
1238}
1239
[533]1240static VOID ReLineThread(VOID * args)
[83]1241{
[551]1242 HWND hwnd = (HWND) args;
[191]1243 HAB hab2;
1244 HMQ hmq2;
[2]1245 VIEWDATA *ad;
[191]1246 CHAR *p, *pp, *e, *whereiam = NULL;
1247 RECTL Rectl;
1248 ULONG width, numlines, firstline = 1, cursored = 1;
[2]1249
1250 priority_normal();
[1063]1251# ifdef FORTIFY
1252 Fortify_EnterScope();
1253# endif
[2]1254 hab2 = WinInitialize(0);
[533]1255 if (hab2) {
[191]1256 hmq2 = WinCreateMsgQueue(hab2, 0);
[533]1257 if (hmq2) {
[191]1258 WinCancelShutdown(hmq2, TRUE);
[533]1259 IncrThreadUsage();
[191]1260 ad = WinQueryWindowPtr(hwnd, QWL_USER);
[855]1261 if (!ad)
[1398]1262 Runtime_Error(pszSrcFile, __LINE__, NULL);
[850]1263 else {
[551]1264 if (!DosRequestMutexSem(ad->ScanSem, SEM_INDEFINITE_WAIT)) {
[850]1265 ad->relining = TRUE;
[551]1266 ad->busy++;
1267 ad->maxx = 0;
1268 if (ad->text && ad->textsize) {
1269 if (ad->hex) {
1270 firstline = ad->topline;
1271 cursored = ad->cursored;
[191]1272 }
[551]1273 else if (ad->lines)
1274 whereiam = ad->lines[ad->cursored - 1];
1275 ad->found = 0;
1276 ad->selected = ad->numlines = ad->numalloc = 0;
[1009]1277 xfree(ad->lines, pszSrcFile, __LINE__);
1278 xfree(ad->markedlines, pszSrcFile, __LINE__);
[551]1279 ad->lines = NULL;
1280 ad->markedlines = NULL;
1281 WinSetWindowText(WinWindowFromID(ad->hwndFrame,
[191]1282 NEWVIEW_STATUS1),
[1498]1283 (CHAR *) GetPString(IDS_FORMATTINGTEXT));
[551]1284 if (!ad->hex) {
1285 if (WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
1286 LM_QUERYITEMCOUNT, MPVOID, MPVOID)) {
1287 WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
1288 LM_DELETEALL, MPVOID, MPVOID);
1289 PostMsg(ad->hwndFrame, WM_UPDATEFRAME,
[191]1290 MPFROMLONG(FCF_SIZEBORDER), MPVOID);
1291 }
1292 }
1293 WinSetFocus(HWND_DESKTOP, hwnd);
[551]1294 if (!ad->hex) {
[191]1295 WinQueryWindowRect(hwnd, &Rectl);
[551]1296 width = (Rectl.xRight - Rectl.xLeft) / ad->fattrs.lAveCharWidth;
[191]1297 numlines = NumLines(&Rectl, ad);
[551]1298 ad->oldwidth = width;
1299 p = ad->text;
1300 if (width) {
1301 while (p - ad->text < ad->textsize && !ad->stopflag) {
1302 if (ad->wrapon) {
[191]1303 e = p + (width - 1);
[551]1304 if (e - ad->text > ad->textsize)
1305 e = ad->text + ad->textsize;
[191]1306 pp = p;
[551]1307 while (pp < e) {
1308 if (*pp == '\r' || *pp == '\n') {
[191]1309 e = pp;
1310 break;
1311 }
1312 pp++;
1313 }
1314 }
[551]1315 else {
[191]1316 pp = p;
[551]1317 while (pp - ad->text < ad->textsize &&
[191]1318 *pp != '\r' && *pp != '\n')
1319 pp++;
1320 e = pp;
[551]1321 if (ad->maxx <
1322 (((e - p) + 1) * ad->fattrs.lAveCharWidth) + 1)
1323 ad->maxx = (((e - p) + 1) *
1324 ad->fattrs.lAveCharWidth) + 1;
[191]1325 }
[551]1326 if (whereiam && p >= whereiam && e <= whereiam) {
1327 cursored = firstline = ad->numlines + 1;
[191]1328 whereiam = NULL;
1329 }
[1673]1330 // assign ad->lines[ad->numlines]
[551]1331 if (ad->numlines + 1 > ad->numalloc) {
[2]1332
[191]1333 CHAR **temp;
[2]1334
[551]1335 temp = xrealloc(ad->lines, sizeof(CHAR *) *
1336 (ad->numalloc + 256), pszSrcFile,
1337 __LINE__);
[350]1338 if (!temp)
[191]1339 break;
[551]1340 ad->lines = temp;
1341 ad->numalloc += 256;
[191]1342 }
[551]1343 ad->lines[ad->numlines] = p;
1344 ad->numlines++;
1345 if (ad->numlines == numlines) {
[1673]1346 // display first page
[191]1347 register INT x;
[2]1348
[551]1349 for (x = 0; x < ad->numlines; x++) {
[191]1350 if ((LONG) (Rectl.yTop -
[850]1351 (ad->lMaxHeight * (((x + 1) -
1352 ad->topline) + 1))) < 0)
1353 break;
[551]1354 PaintLine(hwnd, ad->hps, x, 1, &Rectl);
[191]1355 }
1356 }
1357 p = e;
[551]1358 if (p - ad->text < ad->textsize) {
[191]1359 if (*p == '\r')
1360 p++;
1361 }
[551]1362 if (p - ad->text < ad->textsize) {
[191]1363 if (*p == '\n')
1364 p++;
1365 }
1366 }
1367 }
[551]1368 if (ad->numalloc != ad->numlines) {
[2]1369
[191]1370 CHAR **temp;
[2]1371
[551]1372 temp =
1373 xrealloc(ad->lines, sizeof(CHAR *) * ad->numlines,
1374 pszSrcFile, __LINE__);
1375 if (temp) {
1376 ad->lines = temp;
1377 ad->numalloc = ad->numlines;
[191]1378 }
1379 }
1380 }
[551]1381 else {
1382 ad->numlines = ad->textsize / 16;
1383 if (ad->numlines * 16 < ad->textsize)
1384 ad->numlines++;
[191]1385 }
[551]1386 if (ad->numlines) {
[985]1387 ad->markedlines = xmallocz(ad->numlines, pszSrcFile, __LINE__);
[551]1388 if (ad->markedlines) {
1389 ad->selected = 0;
[191]1390 }
[1335]1391 if ((*ftprun || fFtpRunWPSDefault) && !ad->ignoreftp &&
1392 strstr(ad->text, "ftp://"))
[551]1393 ad->ftpin = TRUE;
[1335]1394 if ((*httprun || fHttpRunWPSDefault) && !ad->ignorehttp &&
1395 strstr(ad->text, "http://"))
1396 ad->httpin = TRUE;
1397 if (*mailrun && !ad->ignoremail && strstr(ad->text, "@"))
1398 ad->mailin = TRUE;
[191]1399 }
1400 }
[551]1401 DosReleaseMutexSem(ad->ScanSem);
[191]1402 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1403 PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
[551]1404 ad->busy--;
[850]1405 } // if got sim
1406 } // if got VIEWDATA
[1780]1407 if (ad && !ad->stopflag) {
1408 PostMsg(hwnd, UM_CONTAINER_FILLED, MPFROMLONG(firstline),
1409 MPFROMLONG(cursored));
1410 ad->relining = FALSE;
1411 }
[2]1412 WinDestroyMsgQueue(hmq2);
1413 }
[533]1414 DecrThreadUsage();
[2]1415 WinTerminate(hab2);
[1063]1416 }
[1036]1417# ifdef FORTIFY
[1063]1418 Fortify_LeaveScope();
1419# endif
[2]1420 DosPostEventSem(CompactSem);
1421}
1422
[533]1423static VOID LoadFileThread(VOID * args)
[83]1424{
[551]1425 HWND hwnd = (HWND) args;
[191]1426 HAB hab2;
1427 HMQ hmq2;
[2]1428 VIEWDATA *ad;
[191]1429 HFILE handle;
[841]1430 ULONG action;
1431 ULONG len;
[191]1432 APIRET rc;
1433 BOOL error = TRUE;
[2]1434
[1063]1435# ifdef FORTIFY
1436 Fortify_EnterScope();
1437# endif
[2]1438 hab2 = WinInitialize(0);
[551]1439 if (hab2) {
[191]1440 hmq2 = WinCreateMsgQueue(hab2, 0);
[551]1441 if (hmq2) {
[191]1442 WinCancelShutdown(hmq2, TRUE);
[533]1443 IncrThreadUsage();
[191]1444 ad = WinQueryWindowPtr(hwnd, QWL_USER);
[551]1445 if (ad) {
1446 if (!DosRequestMutexSem(ad->ScanSem, SEM_INDEFINITE_WAIT)) {
1447 ad->busy++;
[191]1448 priority_normal();
[551]1449 if (*ad->filename) {
[1009]1450 xfree(ad->text, pszSrcFile, __LINE__);
1451 xfree(ad->lines, pszSrcFile, __LINE__);
1452 xfree(ad->markedlines, pszSrcFile, __LINE__);
[551]1453 ad->text = NULL;
1454 ad->lines = NULL;
1455 ad->markedlines = NULL;
[890]1456 ad->ftpin = ad->httpin = ad->mailin = FALSE;
[551]1457 ad->selected = ad->numlines = ad->textsize = ad->numalloc = 0;
1458 WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX, LM_DELETEALL,
[191]1459 MPVOID, MPVOID);
[551]1460 PostMsg(ad->hwndFrame, WM_UPDATEFRAME,
[191]1461 MPFROMLONG(FCF_SIZEBORDER), MPVOID);
1462 WinSetFocus(HWND_DESKTOP, hwnd);
[844]1463 rc = DosOpen(ad->filename, &handle, &action, 0, 0,
1464 OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
1465 OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT |
1466 OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE |
1467 OPEN_ACCESS_READONLY, 0);
[350]1468 if (rc) {
1469 Dos_Error(MB_CANCEL,
1470 rc,
1471 hwnd,
1472 pszSrcFile,
1473 __LINE__,
[551]1474 GetPString(IDS_COMPCANTOPENTEXT), ad->filename);
[350]1475 }
1476 else {
[841]1477 DosChgFilePtr(handle, 0, FILE_END, &len);
1478 DosChgFilePtr(handle, 0, FILE_BEGIN, &action);
[350]1479 if (!len) {
1480 saymsg(MB_CANCEL,
1481 hwnd,
1482 GetPString(IDS_ERRORTEXT),
[551]1483 GetPString(IDS_ZEROLENGTHTEXT), ad->filename);
[350]1484 }
1485 else {
[850]1486 // 06 Oct 07 SHL Protect against 4096 NFTS driver small buffer defect
[858]1487 ad->text = xmalloc(max(len + 2, 4096), // 05 Nov 07 SHL
[850]1488 pszSrcFile,
1489 __LINE__);
[551]1490 if (ad->text) {
1491 *ad->text = 0;
1492 ad->text[len] = 0;
1493 rc = DosRead(handle, ad->text, len, &ad->textsize);
[350]1494 if (rc) {
[191]1495 Dos_Error(MB_CANCEL,
1496 rc,
1497 hwnd,
[350]1498 pszSrcFile,
[191]1499 __LINE__,
[551]1500 GetPString(IDS_ERRORREADINGTEXT), ad->filename);
[1039]1501 free(ad->text);
[551]1502 ad->text = NULL;
1503 ad->textsize = 0;
[191]1504 }
[350]1505 else {
[551]1506 ad->text[ad->textsize] = 0;
1507 if (!ad->hex && !(ad->flags & (8 | 16)) && ad->textsize) {
[350]1508 ULONG x;
[551]1509
1510 x = min(512, ad->textsize);
1511 if (fGuessType && IsBinary(ad->text, x))
1512 ad->hex = TRUE;
[350]1513 }
[551]1514 if (ad->textsize) {
[1335]1515 if (xbeginthread(ReLineThread,
1516 524288,
1517 (PVOID)hwnd,
1518 pszSrcFile,
1519 __LINE__) != -1)
1520 {
[551]1521 error = FALSE;
[1335]1522 }
[350]1523 }
1524 }
[191]1525 }
1526 }
1527 DosClose(handle);
1528 }
1529 }
[551]1530 ad->busy--;
1531 DosReleaseMutexSem(ad->ScanSem);
[191]1532 }
[2]1533 }
1534 WinDestroyMsgQueue(hmq2);
1535 }
[533]1536 DecrThreadUsage();
[2]1537 WinTerminate(hab2);
[1063]1538 }
[1034]1539# ifdef FORTIFY
[1063]1540 Fortify_LeaveScope();
1541# endif
1542 if (error) //fixme
[191]1543 PostMsg(hwnd, UM_CONTAINER_FILLED, MPVOID, MPVOID);
[2]1544 DosPostEventSem(CompactSem);
1545}
1546
[551]1547MRESULT EXPENTRY ViewFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
1548 MPARAM mp2)
[83]1549{
[191]1550 PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
[2]1551
[551]1552 switch (msg) {
[191]1553 case WM_CHAR:
1554 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
1555 break;
[2]1556
[191]1557 case WM_CONTROL:
[551]1558 switch (SHORT1FROMMP(mp1)) {
[191]1559 case NEWVIEW_LISTBOX:
1560 return WinSendMsg(WinWindowFromID(hwnd, FID_CLIENT), UM_CONTROL,
1561 mp1, mp2);
1562 }
1563 break;
[2]1564
[191]1565 case WM_CALCFRAMERECT:
1566 {
1567 MRESULT mr;
1568 PRECTL prectl;
1569 SHORT sSelect;
[2]1570
[191]1571 mr = oldproc(hwnd, msg, mp1, mp2);
[2]1572
[1673]1573 /**
[191]1574 * Calculate the position of the client rectangle.
1575 * Otherwise, we'll see a lot of redraw when we move the
1576 * client during WM_FORMATFRAME.
1577 */
[2]1578
[551]1579 if (mr && mp2) {
[191]1580 prectl = (PRECTL) mp1;
[551]1581 prectl->yBottom += 22;
1582 prectl->yTop -= 22;
[191]1583 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, NEWVIEW_LISTBOX,
1584 LM_QUERYITEMCOUNT,
1585 MPVOID, MPVOID);
1586 if (sSelect > 0)
[551]1587 prectl->yTop -= 48;
[2]1588 }
[191]1589 return mr;
1590 }
[2]1591
[191]1592 case WM_FORMATFRAME:
1593 {
1594 SHORT sCount, soldCount, sSelect;
[551]1595 PSWP pswp, pswpClient, pswpNew1, pswpNew2, pswpNew3, pswpList,
1596 pswpScroll, pswpNew4, pswpUp, pswpDn;
[2]1597
[191]1598 sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2);
1599 soldCount = sCount;
[2]1600
[1673]1601 /**
[191]1602 * Reformat the frame to "squeeze" the client
1603 * and make room for status window sibling beneath
1604 */
[2]1605
[191]1606 pswp = (PSWP) mp1;
1607 {
1608 SHORT x;
[2]1609
[551]1610 for (x = 0; x < sCount; x++) {
1611 if (WinQueryWindowUShort(pswp->hwnd, QWS_ID) == FID_CLIENT) {
[191]1612 pswpClient = pswp;
1613 break;
1614 }
1615 pswp++;
1616 }
[2]1617 }
[191]1618 pswpNew1 = (PSWP) mp1 + soldCount;
1619 pswpNew2 = (PSWP) mp1 + (soldCount + 1);
1620 pswpNew3 = (PSWP) mp1 + (soldCount + 2);
1621 pswpNew4 = (PSWP) mp1 + (soldCount + 3);
1622 *pswpNew1 = *pswpClient;
[551]1623 pswpNew1->hwnd = WinWindowFromID(hwnd, NEWVIEW_STATUS1);
1624 pswpNew1->x = pswpClient->x + 2;
1625 pswpNew1->y = pswpClient->y + 2;
1626 pswpNew1->cx = (pswpClient->cx / 3) - 3;
1627 pswpNew1->cy = 20;
1628 pswpClient->y = pswpNew1->y + pswpNew1->cy + 3;
1629 pswpClient->cy = (pswpClient->cy - pswpNew1->cy) - 5;
[191]1630 *pswpNew2 = *pswpNew1;
1631 *pswpNew3 = *pswpNew1;
1632 *pswpNew4 = *pswpNew1;
[551]1633 pswpNew2->hwnd = WinWindowFromID(hwnd, NEWVIEW_STATUS2);
1634 pswpNew3->hwnd = WinWindowFromID(hwnd, NEWVIEW_STATUS3);
1635 pswpNew4->hwnd = WinWindowFromID(hwnd, NEWVIEW_DRAG);
1636 pswpNew2->x = pswpNew1->x + pswpNew1->cx + 3;
1637 pswpNew3->x = pswpNew2->x + pswpNew2->cx + 3;
1638 pswpNew3->cx = ((pswpClient->x + pswpClient->cx) - pswpNew3->x) - 26;
1639 pswpNew4->x = pswpNew3->x + pswpNew3->cx + 3;
1640 pswpNew4->cx = 20;
[191]1641 sCount += 4;
1642 pswpScroll = (PSWP) mp1;
[551]1643 while (pswpScroll < pswpClient) {
1644 if (WinQueryWindowUShort(pswpScroll->hwnd, QWS_ID) == FID_VERTSCROLL)
[191]1645 break;
1646 pswpScroll++;
1647 }
1648 if (pswpScroll == pswpClient)
1649 pswpScroll = NULL;
1650 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, NEWVIEW_LISTBOX,
[551]1651 LM_QUERYITEMCOUNT, MPVOID, MPVOID);
1652 if (sSelect > 0) {
[191]1653 pswpList = (PSWP) mp1 + (soldCount + 4);
1654 *pswpList = *pswpClient;
[551]1655 pswpList->hwnd = WinWindowFromID(hwnd, NEWVIEW_LISTBOX);
1656 pswpList->x = pswpClient->x;
1657 pswpList->cx = pswpClient->cx;
1658 if (pswpScroll) {
1659 pswpList->cx += pswpScroll->cx;
1660 pswpScroll->cy -= 48;
[191]1661 }
[551]1662 pswpList->y = (pswpClient->y + pswpClient->cy) - 48;
1663 pswpList->cy = 48;
1664 pswpClient->cy -= 48;
[191]1665 sCount++;
1666 }
1667 WinShowWindow(WinWindowFromID(hwnd, NEWVIEW_LISTBOX), (sSelect > 0));
[2]1668
[551]1669 if (pswpScroll) {
[191]1670 pswpUp = (PSWP) mp1 + (soldCount + 4 + (sSelect > 0));
1671 *pswpUp = *pswpClient;
[551]1672 pswpUp->hwnd = WinWindowFromID(hwnd, IDM_PREVBLANKLINE);
1673 pswpUp->cx = pswpScroll->cx;
1674 pswpUp->x = pswpScroll->x;
1675 pswpUp->cy = WinQuerySysValue(HWND_DESKTOP, SV_CYVSCROLLARROW);
1676 pswpUp->y = (pswpScroll->y + pswpScroll->cy) - (pswpUp->cy + 1);
1677 pswpScroll->cy -= ((pswpUp->cy * 2) + 1);
[191]1678 pswpDn = (PSWP) mp1 + (soldCount + 5 + (sSelect > 0));
1679 *pswpDn = *pswpUp;
[551]1680 pswpDn->y = pswpScroll->y;
1681 pswpDn->hwnd = WinWindowFromID(hwnd, IDM_NEXTBLANKLINE);
1682 pswpScroll->y += pswpUp->cy;
[191]1683 sCount += 2;
1684 }
[551]1685 else {
[191]1686 WinShowWindow(WinWindowFromID(hwnd, IDM_PREVBLANKLINE), FALSE);
1687 WinShowWindow(WinWindowFromID(hwnd, IDM_NEXTBLANKLINE), FALSE);
1688 }
1689 return MRFROMSHORT(sCount);
1690 }
[2]1691
[191]1692 case WM_QUERYFRAMECTLCOUNT:
1693 {
1694 SHORT sCount, sSelect;
1695
1696 sCount = (SHORT) oldproc(hwnd, msg, mp1, mp2);
1697 sCount += 6;
1698 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, NEWVIEW_LISTBOX,
[551]1699 LM_QUERYITEMCOUNT, MPVOID, MPVOID);
[191]1700 if (sSelect > 0)
1701 sCount++;
1702 return MRFROMSHORT(sCount);
1703 }
[2]1704 }
[191]1705 return oldproc(hwnd, msg, mp1, mp2);
[2]1706}
1707
[191]1708MRESULT EXPENTRY FindStrDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[83]1709{
[2]1710 VIEWDATA *ad;
1711
[551]1712 switch (msg) {
[191]1713 case WM_INITDLG:
1714 if (!mp2)
1715 WinDismissDlg(hwnd, 0);
[551]1716 else {
[2]1717
[191]1718 HWND hwndClient = *(HWND *) mp2;
[2]1719
[191]1720 WinSetWindowULong(hwnd, QWL_USER, (ULONG) hwndClient);
1721 ad = (VIEWDATA *) WinQueryWindowPtr(hwndClient, QWL_USER);
1722 MLEsetwrap(WinWindowFromID(hwnd, NEWFIND_MLE), FALSE);
1723 MLEsetlimit(WinWindowFromID(hwnd, NEWFIND_MLE), SEARCHSTRINGLEN);
1724 MLEsetformat(WinWindowFromID(hwnd, NEWFIND_MLE), MLFIE_NOTRANS);
[551]1725 if (*ad->searchtext) {
[2]1726
[191]1727 IPT here = 0;
[551]1728 ULONG len = strlen(ad->searchtext);
[2]1729
[191]1730 WinSendMsg(WinWindowFromID(hwnd, NEWFIND_MLE),
1731 MLM_SETIMPORTEXPORT,
[551]1732 MPFROMP(ad->searchtext), MPFROMLONG(SEARCHSTRINGLEN));
[191]1733 WinSendMsg(WinWindowFromID(hwnd, NEWFIND_MLE),
[551]1734 MLM_IMPORT, MPFROMP(&here), MPFROMLONG(len));
[2]1735 }
[551]1736 WinCheckButton(hwnd, NEWFIND_ALSOSELECT, ad->alsoselect);
1737 WinCheckButton(hwnd, NEWFIND_SENSITIVE, ad->sensitive);
1738 WinCheckButton(hwnd, NEWFIND_LITERAL, ad->literalsearch);
[191]1739 }
1740 break;
[2]1741
[191]1742 case WM_COMMAND:
[551]1743 switch (SHORT1FROMMP(mp1)) {
[191]1744 case DID_OK:
1745 {
1746 CHAR s[SEARCHSTRINGLEN];
1747 IPT here = 0;
1748 ULONG len;
1749 HWND hwndClient = WinQueryWindowULong(hwnd, QWL_USER);
[2]1750
[191]1751 ad = (VIEWDATA *) WinQueryWindowPtr(hwndClient, QWL_USER);
1752 memset(s, 0, SEARCHSTRINGLEN);
1753 WinSendMsg(WinWindowFromID(hwnd, NEWFIND_MLE),
1754 MLM_SETIMPORTEXPORT,
[551]1755 MPFROMP(s), MPFROMLONG(SEARCHSTRINGLEN));
[191]1756 len = SEARCHSTRINGLEN;
1757 WinSendMsg(WinWindowFromID(hwnd, NEWFIND_MLE),
[551]1758 MLM_EXPORT, MPFROMP(&here), MPFROMLONG(&len));
[191]1759 s[SEARCHSTRINGLEN - 1] = 0;
[551]1760 if (!*s) {
[1395]1761 if (!fAlertBeepOff)
1762 DosBeep(250, 100); // Complain
[191]1763 break;
1764 }
[551]1765 strcpy(ad->searchtext, s);
1766 ad->sensitive = WinQueryButtonCheckstate(hwnd, NEWFIND_SENSITIVE);
1767 if (ad->sensitive != Sensitive) {
1768 Sensitive = ad->sensitive;
[191]1769 PrfWriteProfileData(fmprof,
1770 appname,
1771 "Viewer.Sensitive",
[551]1772 &ad->sensitive, sizeof(BOOL));
[191]1773 }
[551]1774 ad->literalsearch = WinQueryButtonCheckstate(hwnd, NEWFIND_LITERAL);
1775 if (ad->literalsearch != LiteralSearch) {
1776 LiteralSearch = ad->literalsearch;
[191]1777 PrfWriteProfileData(fmprof,
1778 appname,
1779 "Viewer.LiteralSearch",
[551]1780 &ad->literalsearch, sizeof(BOOL));
[191]1781 }
[551]1782 ad->alsoselect = WinQueryButtonCheckstate(hwnd, NEWFIND_ALSOSELECT);
1783 if (ad->alsoselect != AlsoSelect) {
1784 AlsoSelect = ad->alsoselect;
[191]1785 PrfWriteProfileData(fmprof,
1786 appname,
1787 "Viewer.AlsoSelect",
[551]1788 &ad->alsoselect, sizeof(BOOL));
[191]1789 }
[2]1790 }
[191]1791 WinDismissDlg(hwnd, 1);
1792 break;
1793 case DID_CANCEL:
1794 WinDismissDlg(hwnd, 0);
1795 break;
1796 }
1797 return 0;
[2]1798 }
[191]1799 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]1800}
1801
[191]1802MRESULT EXPENTRY ViewWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[83]1803{
[191]1804 VIEWDATA *ad = WinQueryWindowPtr(hwnd, QWL_USER);
[2]1805
[551]1806 switch (msg) {
[191]1807 case WM_CREATE:
1808 {
1809 HWND temphwnd;
[377]1810 HWND hwndFrame = WinQueryWindow(hwnd, QW_PARENT);
[2]1811
[377]1812 temphwnd = WinCreateWindow(hwndFrame,
[191]1813 WC_BUTTON,
1814 "<",
1815 WS_VISIBLE |
1816 BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
1817 0,
1818 0,
1819 0,
1820 0,
[377]1821 hwndFrame,
[551]1822 HWND_TOP, IDM_PREVBLANKLINE, NULL, NULL);
[377]1823 if (!temphwnd)
[1395]1824 Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
1825 PCSZ_WINCREATEWINDOW);
[377]1826 else {
[1394]1827 //fixme to allow user to change presparams 1-10-09 GKY
[551]1828 WinSetPresParam(temphwnd,
1829 PP_FONTNAMESIZE,
[1391]1830 strlen(FNT_8HELVETICA) + 1,
[1400]1831 (PVOID) FNT_8HELVETICA);
[377]1832 }
1833 temphwnd = WinCreateWindow(hwndFrame,
[191]1834 WC_BUTTON,
1835 ">",
1836 WS_VISIBLE |
1837 BS_PUSHBUTTON | BS_NOPOINTERFOCUS,
1838 0,
1839 0,
1840 0,
1841 0,
[377]1842 hwndFrame,
[551]1843 HWND_TOP, IDM_NEXTBLANKLINE, NULL, NULL);
[377]1844 if (!temphwnd)
[1395]1845 Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
1846 PCSZ_WINCREATEWINDOW);
[377]1847 else {
[1394]1848 //fixme to allow user to change presparams 1-10-09 GKY
[551]1849 WinSetPresParam(temphwnd,
1850 PP_FONTNAMESIZE,
[1391]1851 strlen(FNT_8HELVETICA) + 1,
[1400]1852 (PVOID) FNT_8HELVETICA);
[377]1853 }
[1444]1854 WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, ID_NEWVIEW_TIMER, 1000L);
[191]1855 }
1856 break;
[2]1857
[191]1858 case WM_TIMER:
1859 if (ad &&
[551]1860 ad->needrefreshing &&
1861 !ad->stopflag &&
1862 !ad->relining &&
1863 !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
1864 ad->needrefreshing = FALSE;
1865 DosReleaseMutexSem(ad->ScanSem);
[191]1866 WinInvalidateRect(hwnd, NULL, TRUE);
1867 }
1868 break;
[2]1869
[191]1870 case UM_SETUP:
[377]1871 if (!ad)
[1398]1872 Runtime_Error(pszSrcFile, __LINE__, NULL);
[350]1873 else {
1874 CHAR s[CCHMAXPATH + 8];
1875 APIRET rc;
[551]1876
1877 ad->hwndMenu = WinWindowFromID(ad->hwndFrame, FID_MENU);
1878 ad->hvscroll = WinWindowFromID(ad->hwndFrame, FID_VERTSCROLL);
1879 ad->hhscroll = WinWindowFromID(ad->hwndFrame, FID_HORZSCROLL);
1880 WinSendMsg(ad->hhscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1), MPVOID);
1881 WinSendMsg(ad->hvscroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(1, 1), MPVOID);
1882 sprintf(s, "%s: %s", FM2Str, ad->filename);
1883 WinSetWindowText(ad->hwndFrame, s);
1884 rc = DosCreateMutexSem(NULL, &ad->ScanSem, 0L, FALSE);
[350]1885 if (rc)
[551]1886 Dos_Error(MB_CANCEL, rc, hwnd, pszSrcFile, __LINE__,
[1398]1887 PCSZ_DOSCREATEMUTEXSEM);
[350]1888 else {
1889 PFNWP oldproc;
[551]1890 HWND hwndFrame = ad->hwndFrame;
1891
1892 WinSendMsg(ad->hvscroll,
1893 SBM_SETSCROLLBAR, MPFROMSHORT(1), MPFROM2SHORT(1, 1));
1894 WinSendMsg(ad->hhscroll, SBM_SETSCROLLBAR, MPFROMSHORT(1),
[191]1895 MPFROM2SHORT(1, 1));
[551]1896 ad->hwndStatus1 = WinCreateWindow(hwndFrame,
[1498]1897 (CHAR *) WC_VIEWSTATUS,
1898 (CHAR *) GetPString(IDS_LOADINGTEXT),
[551]1899 WS_VISIBLE | SS_TEXT |
1900 DT_LEFT | DT_VCENTER,
1901 0,
1902 0,
1903 0,
1904 0,
1905 hwndFrame,
1906 HWND_TOP,
1907 NEWVIEW_STATUS1, NULL, NULL);
1908 if (!ad->hwndStatus1)
[1395]1909 Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
1910 PCSZ_WINCREATEWINDOW);
[377]1911
[551]1912 ad->hwndStatus2 = WinCreateWindow(hwndFrame,
[1498]1913 (CHAR *) WC_VIEWSTATUS,
[551]1914 NULL,
1915 WS_VISIBLE | SS_TEXT |
1916 DT_LEFT | DT_VCENTER,
1917 0,
1918 0,
1919 0,
1920 0,
1921 hwndFrame,
1922 HWND_TOP,
1923 NEWVIEW_STATUS2, NULL, NULL);
1924 if (!ad->hwndStatus2)
[1395]1925 Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
1926 PCSZ_WINCREATEWINDOW);
[377]1927
[551]1928 ad->hwndStatus3 = WinCreateWindow(hwndFrame,
[1498]1929 (CHAR *) WC_VIEWSTATUS,
[551]1930 NULL,
1931 WS_VISIBLE | SS_TEXT |
1932 DT_LEFT | DT_VCENTER,
1933 0,
1934 0,
1935 0,
1936 0,
1937 hwndFrame,
1938 HWND_TOP,
1939 NEWVIEW_STATUS3, NULL, NULL);
1940 if (!ad->hwndStatus3)
[1395]1941 Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
1942 PCSZ_WINCREATEWINDOW);
[377]1943
[551]1944 ad->hwndListbox = WinCreateWindow(hwndFrame,
[1498]1945 (CHAR *) WC_LISTBOX,
[551]1946 NULL,
1947 LS_NOADJUSTPOS,
1948 0,
1949 0,
1950 0,
1951 0,
1952 hwndFrame,
1953 HWND_TOP,
1954 NEWVIEW_LISTBOX, NULL, NULL);
1955 if (!ad->hwndListbox)
[1395]1956 Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
1957 PCSZ_WINCREATEWINDOW);
[377]1958
[551]1959 ad->hwndDrag = WinCreateWindow(hwndFrame,
[1498]1960 (CHAR *) WC_VIEWSTATUS,
[551]1961 "#100",
1962 WS_VISIBLE | SS_BITMAP,
1963 0,
1964 0,
1965 0,
1966 0,
1967 hwndFrame,
1968 HWND_TOP, NEWVIEW_DRAG, NULL, NULL);
1969 if (!ad->hwndDrag)
[1395]1970 Win_Error(hwndFrame, hwnd, pszSrcFile, __LINE__,
1971 PCSZ_WINCREATEWINDOW);
[377]1972
1973 oldproc = WinSubclassWindow(hwndFrame, ViewFrameWndProc);
[551]1974 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
1975 ad->hps = InitWindow(hwnd);
[1335]1976 if (xbeginthread(LoadFileThread,
1977 524288,
1978 (PVOID)hwnd,
1979 pszSrcFile,
1980 __LINE__) != -1)
1981 {
[350]1982 WinSendMsg(hwnd, UM_SETUP5, MPVOID, MPVOID);
[818]1983 DosSleep(16); //05 Aug 07 GKY 32
[551]1984 return (MRESULT) 1;
[191]1985 }
[2]1986 }
[191]1987 }
[350]1988 // Oops
[191]1989 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
1990 return 0;
[2]1991
[191]1992 case UM_SETUP5:
[551]1993 if (ad) {
1994 if (ad->hwndFrame ==
1995 WinQueryActiveWindow(WinQueryWindow(ad->hwndFrame,
[191]1996 QW_PARENT)) &&
[551]1997 !ParentIsDesktop(ad->hwndFrame, (HWND) 0)) {
[191]1998 if (hwndStatus2)
1999 WinSetWindowText(hwndStatus2,
[551]2000 (*ad->filename) ?
[1498]2001 ad->filename : (CHAR *) GetPString(IDS_UNTITLEDTEXT));
[551]2002 if (fMoreButtons) {
[191]2003 WinSetWindowText(hwndName,
[551]2004 (*ad->filename) ?
[1498]2005 ad->filename : (CHAR *) GetPString(IDS_UNTITLEDTEXT));
[191]2006 WinSetWindowText(hwndDate, NullStr);
2007 WinSetWindowText(hwndAttr, NullStr);
2008 }
2009 if (hwndStatus)
2010 WinSetWindowText(hwndStatus,
[1498]2011 (CHAR *) GetPString(IDS_INTERNALVIEWERTITLETEXT));
[2]2012 }
[191]2013 }
2014 return 0;
[2]2015
[191]2016 case DM_DISCARDOBJECT:
2017 case DM_PRINTOBJECT:
2018 return MRFROMLONG(DRR_TARGET);
[2]2019
[191]2020 case UM_RESCAN:
[551]2021 if (ad) {
2022 if (!ad->busy && !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
2023 if (ad->numlines) {
[2]2024
[191]2025 CHAR s[80], tb[34], tl[34];
[2]2026
[551]2027 commafmt(tb, sizeof(tb), ad->textsize);
2028 commafmt(tl, sizeof(tl), ad->numlines);
[191]2029 sprintf(s,
2030 " %s %s%s %s %s%s",
2031 tb,
2032 GetPString(IDS_BYTETEXT),
[551]2033 &"s"[ad->textsize == 1],
2034 tl, GetPString(IDS_LINETEXT), &"s"[ad->numlines == 1]);
2035 WinSetWindowText(ad->hwndStatus1, s);
[191]2036 }
2037 else
[1498]2038 WinSetWindowText(ad->hwndStatus1, (CHAR *) GetPString(IDS_NVNOLINESTEXT));
[551]2039 DosReleaseMutexSem(ad->ScanSem);
[2]2040 }
[191]2041 else
[1498]2042 WinSetWindowText(ad->hwndStatus1, (CHAR *) GetPString(IDS_WORKINGTEXT));
[191]2043 }
2044 return 0;
[2]2045
[191]2046 case UM_SETUP2:
[920]2047 /**
[191]2048 * calculate width of client in characters, recalc lines if
2049 * oldwidth != newwidth, set ad->oldwidth for later comparison
2050 */
[551]2051 if (ad) {
[2]2052
[191]2053 BOOL invalidate = FALSE;
[2]2054
[819]2055 if (ad->wrapon || ad->hex) { // GKY reverse case where hscroll bar is presnt
[850]2056 if (WinQueryWindow(ad->hhscroll, QW_PARENT) == ad->hwndFrame) {
2057 invalidate = TRUE;
2058 WinSetOwner(ad->hhscroll, HWND_OBJECT);
2059 WinSetParent(ad->hhscroll, HWND_OBJECT, TRUE);
2060 ad->maxx = 0;
2061 ad->horzscroll = 0;
2062 }
[2]2063 }
[551]2064 else {
2065 if (WinQueryWindow(ad->hhscroll, QW_PARENT) != ad->hwndFrame) {
[191]2066 invalidate = TRUE;
[551]2067 WinSetOwner(ad->hhscroll, ad->hwndFrame);
2068 WinSetParent(ad->hhscroll, ad->hwndFrame, TRUE);
[191]2069 }
2070 }
[551]2071 if (invalidate) {
2072 WinSendMsg(ad->hwndFrame, WM_UPDATEFRAME, MPFROMLONG(FCF_SIZEBORDER),
[191]2073 MPVOID);
2074 WinInvalidateRect(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2075 NEWVIEW_DRAG), NULL, FALSE);
[551]2076 WinInvalidateRect(ad->hhscroll, NULL, FALSE);
[191]2077 }
2078 }
[2]2079
[551]2080 if (ad && !ad->busy &&
2081 !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
[2]2082
[191]2083 RECTL rcl;
2084 ULONG newwidth;
[2]2085
[191]2086 WinQueryWindowRect(hwnd, &rcl);
[551]2087 newwidth = (rcl.xRight - rcl.xLeft) / ad->fattrs.lAveCharWidth;
2088 if ((!ad->hex || ad->oldwidth == -1) &&
2089 newwidth != ad->oldwidth && ad->text && ad->textsize) {
2090 ad->oldwidth = newwidth;
2091 if (!ad->relining) {
[1335]2092 if (xbeginthread(ReLineThread,
2093 524288,
2094 (PVOID)hwnd,
2095 pszSrcFile,
2096 __LINE__) == -1)
2097 {
[551]2098 DosReleaseMutexSem(ad->ScanSem);
[191]2099 WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
2100 return 0;
2101 }
2102 }
[2]2103 }
[551]2104 ad->oldwidth = newwidth;
2105 DosReleaseMutexSem(ad->ScanSem);
[191]2106 }
2107 return MRFROMLONG(TRUE);
[2]2108
[191]2109 case WM_CHAR:
2110 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
[551]2111 if (ad && !ad->busy && !(SHORT1FROMMP(mp1) & KC_KEYUP) &&
2112 !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
[2]2113
[551]2114 ULONG numlines, wascursored = ad->cursored;
[191]2115 RECTL rcl;
[2]2116
[191]2117 WinQueryWindowRect(hwnd, &rcl);
2118 numlines = NumLines(&rcl, ad);
[551]2119 if (numlines) {
2120 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
2121 switch (SHORT2FROMMP(mp2)) {
[191]2122 case VK_LEFT:
2123 WinSendMsg(hwnd, WM_HSCROLL, MPFROM2SHORT(FID_HORZSCROLL, 0),
2124 MPFROM2SHORT(0, SB_LINELEFT));
2125 break;
2126 case VK_RIGHT:
2127 WinSendMsg(hwnd, WM_HSCROLL, MPFROM2SHORT(FID_HORZSCROLL, 0),
2128 MPFROM2SHORT(0, SB_LINERIGHT));
2129 break;
2130 case VK_PAGEUP:
2131 PostMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
2132 MPFROM2SHORT(0, SB_PAGEUP));
2133 break;
2134 case VK_PAGEDOWN:
2135 PostMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
2136 MPFROM2SHORT(0, SB_PAGEDOWN));
2137 break;
2138 case VK_UP:
[551]2139 if (ad->cursored > 1) {
[191]2140 if (shiftstate & KC_SHIFT)
2141 WinSendMsg(hwnd, WM_BUTTON1CLICK,
[551]2142 MPFROM2SHORT(ad->fattrs.lAveCharWidth + 2,
2143 ((rcl.yTop - (ad->lMaxHeight *
2144 ((ad->cursored) -
2145 ad->topline))) -
2146 ad->lMaxDescender) - 1),
[191]2147 MPFROM2SHORT(TRUE, 0));
[551]2148 ad->cursored--;
2149 if (ad->cursored < ad->topline) {
2150 PaintLine(hwnd, ad->hps, ad->cursored, ad->topline, &rcl);
[191]2151 WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
2152 MPFROM2SHORT(0, SB_LINEUP));
2153 }
[551]2154 else {
2155 PaintLine(hwnd, ad->hps, ad->cursored - 1, ad->topline, &rcl);
2156 PaintLine(hwnd, ad->hps, ad->cursored, ad->topline, &rcl);
[191]2157 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2158 }
2159 }
2160 break;
2161 case VK_DOWN:
[551]2162 if (ad->cursored < ad->numlines &&
2163 ad->cursored < ad->topline + numlines) {
[191]2164 if (shiftstate & KC_SHIFT)
2165 WinSendMsg(hwnd, WM_BUTTON1CLICK,
[551]2166 MPFROM2SHORT(ad->fattrs.lAveCharWidth + 2,
2167 ((rcl.yTop - (ad->lMaxHeight *
2168 ((ad->cursored) -
2169 ad->topline))) -
2170 ad->lMaxDescender) - 1),
[191]2171 MPFROM2SHORT(TRUE, 0));
[551]2172 ad->cursored++;
2173 if (ad->cursored >= ad->topline + numlines) {
2174 PaintLine(hwnd, ad->hps, ad->cursored - 2, ad->topline, &rcl);
[191]2175 WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
2176 MPFROM2SHORT(0, SB_LINEDOWN));
2177 }
[551]2178 else {
2179 PaintLine(hwnd, ad->hps, ad->cursored - 1, ad->topline, &rcl);
2180 PaintLine(hwnd, ad->hps, ad->cursored - 2, ad->topline, &rcl);
[191]2181 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2182 }
2183 }
2184 break;
2185 case VK_END:
2186 if ((shiftstate & KC_CTRL) ||
[551]2187 ad->cursored == (ad->topline - 1) + numlines) {
2188 ad->cursored = ad->numlines;
2189 ad->topline = (ad->numlines + 1) - numlines;
2190 if (ad->topline > ad->numlines)
2191 ad->topline = 1;
[191]2192 WinInvalidateRect(hwnd, NULL, FALSE);
2193 }
[551]2194 else {
2195 ad->cursored = (ad->topline - 1) + numlines;
2196 if (ad->cursored > ad->numlines)
2197 ad->cursored = ad->numlines;
2198 PaintLine(hwnd, ad->hps, ad->cursored - 1, ad->topline, &rcl);
2199 PaintLine(hwnd, ad->hps, wascursored - 1, ad->topline, &rcl);
[191]2200 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2201 }
2202 PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
2203 break;
2204 case VK_HOME:
[551]2205 if ((shiftstate & KC_CTRL) || ad->cursored == ad->topline) {
2206 ad->topline = 1;
2207 ad->cursored = 1;
[191]2208 WinInvalidateRect(hwnd, NULL, FALSE);
2209 }
[551]2210 else {
2211 ad->cursored = ad->topline;
2212 PaintLine(hwnd, ad->hps, ad->cursored - 1, ad->topline, &rcl);
2213 PaintLine(hwnd, ad->hps, wascursored - 1, ad->topline, &rcl);
[191]2214 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2215 }
2216 PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
2217 break;
2218 case VK_SPACE:
2219 WinSendMsg(hwnd, WM_BUTTON1CLICK,
[551]2220 MPFROM2SHORT(ad->fattrs.lAveCharWidth + 2,
2221 ((rcl.yTop - (ad->lMaxHeight *
2222 ((ad->cursored) -
2223 ad->topline))) -
2224 ad->lMaxDescender) - 1),
[191]2225 MPFROM2SHORT(TRUE, 0));
2226 break;
2227 case VK_NEWLINE:
2228 case VK_ENTER:
2229 WinSendMsg(hwnd, WM_BUTTON1DBLCLK,
[551]2230 MPFROM2SHORT(ad->fattrs.lAveCharWidth + 2,
2231 ((rcl.yTop - (ad->lMaxHeight *
2232 ((ad->cursored) -
2233 ad->topline))) -
2234 ad->lMaxDescender) - 1), MPFROM2SHORT(0,
2235 0));
[191]2236 break;
2237 }
2238 }
[551]2239 else if (SHORT1FROMMP(mp1) & KC_CHAR) {
2240 switch (SHORT1FROMMP(mp2)) {
[191]2241 case '\r':
2242 case '\n':
2243 WinSendMsg(hwnd, WM_BUTTON1DBLCLK,
[551]2244 MPFROM2SHORT(ad->fattrs.lAveCharWidth + 2,
2245 (rcl.yTop - (ad->lMaxHeight *
2246 ((ad->cursored) -
2247 ad->topline))) - 1),
[191]2248 MPFROM2SHORT(0, 0));
2249 break;
2250 default:
2251 break;
2252 }
2253 }
[551]2254 if (wascursored != ad->cursored)
[191]2255 PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
[2]2256 }
[551]2257 DosReleaseMutexSem(ad->ScanSem);
[191]2258 }
2259 break;
[2]2260
[191]2261 case WM_BUTTON1MOTIONSTART:
2262 WinSetFocus(HWND_DESKTOP, hwnd);
[551]2263 if (ad && !ad->stopflag && !ad->busy &&
2264 !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
2265 ad->mousecaptured = TRUE;
2266 ad->lastselected = ULONG_MAX;
2267 ad->lastdirection = 0;
[191]2268 WinSetCapture(HWND_DESKTOP, hwnd);
2269 WinSendMsg(hwnd, WM_BUTTON1CLICK, mp1, MPFROM2SHORT(TRUE, 0));
2270 }
2271 break;
[2]2272
[191]2273 case WM_MOUSEMOVE:
2274 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
[551]2275 if (ad && ad->mousecaptured) {
[2]2276
[191]2277 ULONG numlines, whichline, x;
2278 LONG inc;
2279 RECTL Rectl;
2280 POINTS pts;
2281 BOOL outofwindow = FALSE;
[2]2282
[191]2283 WinQueryWindowRect(hwnd, &Rectl);
2284 numlines = NumLines(&Rectl, ad);
[551]2285 if (numlines) {
[191]2286 pts.x = SHORT1FROMMP(mp1);
2287 pts.y = SHORT2FROMMP(mp1);
[551]2288 if (pts.y < 0) {
[191]2289 WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
2290 MPFROM2SHORT(0, SB_LINEDOWN));
2291 pts.y = 1;
2292 outofwindow = TRUE;
2293 }
[551]2294 else if (pts.y > Rectl.yTop - Rectl.yBottom) {
[191]2295 WinSendMsg(hwnd, WM_VSCROLL, MPFROM2SHORT(FID_VERTSCROLL, 0),
2296 MPFROM2SHORT(0, SB_LINEUP));
[1533]2297 pts.y = (SHORT) (Rectl.yTop - Rectl.yBottom) - 1;
[191]2298 outofwindow = TRUE;
2299 }
2300 whichline = ((Rectl.yTop - Rectl.yBottom) -
[551]2301 ((LONG) pts.y + ad->lMaxDescender)) / ad->lMaxHeight;
[191]2302 if (whichline > numlines - 1)
2303 whichline = numlines - 1;
[551]2304 whichline += (ad->topline - 1);
2305 if (whichline < ad->numlines && ad->lastselected != whichline) {
2306 if (ad->lastselected != ULONG_MAX) {
2307 inc = (ad->lastselected < whichline) ? 1 : -1;
2308 for (x = ad->lastselected + inc;
2309 x != whichline && x < ad->numlines;
2310 (ad->lastselected < whichline) ? x++ : x--) {
2311 if (ad->markedlines) {
2312 if (ad->markedlines[x] & VF_SELECTED) {
2313 ad->markedlines[x] &= (~VF_SELECTED);
2314 ad->selected--;
[191]2315 }
[551]2316 else {
2317 ad->markedlines[x] |= VF_SELECTED;
2318 ad->selected++;
[191]2319 }
2320 }
[551]2321 PaintLine(hwnd, ad->hps, x, ad->topline, &Rectl);
[191]2322 }
2323 WinSendMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
2324 }
2325 WinSendMsg(hwnd, WM_BUTTON1CLICK, MPFROM2SHORT(pts.x, pts.y),
2326 MPFROM2SHORT(TRUE, 0));
2327 }
2328 }
[551]2329 if (outofwindow) {
[2]2330
[191]2331 POINTL ptl;
[2]2332
[191]2333 WinQueryPointerPos(HWND_DESKTOP, &ptl);
2334 WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1L);
2335 if ((SHORT) ptl.y == (SHORT) SHORT2FROMMP(mp1) &&
2336 (SHORT) ptl.x == (SHORT) SHORT1FROMMP(mp1) &&
[551]2337 ((SHORT) ptl.y < 0 || ptl.y > (Rectl.yTop - Rectl.yBottom))) {
[191]2338 PostMsg(hwnd, UM_MOUSEMOVE, mp1, MPVOID);
[771]2339 DosSleep(1);
[191]2340 }
[2]2341 }
[191]2342 }
2343 break;
[2]2344
[191]2345 case UM_MOUSEMOVE:
[551]2346 if (ad && ad->mousecaptured) {
[2]2347
[191]2348 POINTL ptl;
2349 RECTL Rectl;
[2]2350
[191]2351 WinQueryWindowRect(hwnd, &Rectl);
2352 WinQueryPointerPos(HWND_DESKTOP, &ptl);
[771]2353 WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1);
[191]2354 if ((SHORT) ptl.y == (SHORT) SHORT2FROMMP(mp1) &&
2355 (SHORT) ptl.x == (SHORT) SHORT1FROMMP(mp1) &&
[551]2356 ((SHORT) ptl.y < 0 || ptl.y > (Rectl.yTop - Rectl.yBottom))) {
[771]2357 DosSleep(1);
[191]2358 PostMsg(hwnd, WM_MOUSEMOVE, mp1, MPFROM2SHORT(TRUE, 0));
[2]2359 }
[191]2360 }
2361 return 0;
[2]2362
[191]2363 case WM_BUTTON1UP:
2364 case WM_BUTTON1MOTIONEND:
2365 WinSetFocus(HWND_DESKTOP, hwnd);
[551]2366 if (ad && ad->mousecaptured) {
2367 ad->mousecaptured = FALSE;
2368 ad->lastselected = ULONG_MAX;
2369 ad->lastdirection = 0;
2370 DosReleaseMutexSem(ad->ScanSem);
[191]2371 WinSetCapture(HWND_DESKTOP, NULLHANDLE);
2372 }
2373 break;
[2]2374
[191]2375 case WM_BUTTON1DBLCLK:
2376 case WM_BUTTON1CLICK:
2377 WinSetFocus(HWND_DESKTOP, hwnd);
[551]2378 if (ad && !ad->stopflag && ad->numlines && ad->text && !ad->busy &&
2379 !DosRequestMutexSem(ad->ScanSem, SEM_IMMEDIATE_RETURN)) {
[2]2380
[191]2381 ULONG numlines, whichline, wascursored, width;
2382 RECTL Rectl;
2383 POINTS pts;
[2]2384
[191]2385 WinQueryWindowRect(hwnd, &Rectl);
2386 numlines = NumLines(&Rectl, ad);
2387 if (!numlines)
2388 break;
2389 pts.x = SHORT1FROMMP(mp1);
2390 pts.y = SHORT2FROMMP(mp1);
2391 whichline = ((Rectl.yTop - Rectl.yBottom) -
[551]2392 ((LONG) pts.y + ad->lMaxDescender)) / ad->lMaxHeight;
[191]2393 if (whichline > numlines - 1)
2394 whichline = numlines - 1;
[551]2395 whichline += (ad->topline - 1);
2396 if (whichline + 1 > ad->numlines)
[191]2397 break;
[551]2398 wascursored = ad->cursored;
2399 ad->cursored = whichline + 1;
2400 if (msg == WM_BUTTON1CLICK) {
2401 if (ad->lastselected != ULONG_MAX) {
2402 if (whichline > ad->lastselected)
2403 ad->lastdirection = 1;
[191]2404 else
[551]2405 ad->lastdirection = 2;
[191]2406 }
2407 else
[551]2408 ad->lastdirection = 0;
2409 ad->lastselected = whichline;
2410 if (whichline < ad->numlines) {
2411 if (ad->markedlines) {
2412 if (ad->markedlines[whichline] & VF_SELECTED) {
2413 ad->selected--;
2414 ad->markedlines[whichline] &= (~VF_SELECTED);
[191]2415 }
[551]2416 else {
2417 ad->selected++;
2418 ad->markedlines[whichline] |= VF_SELECTED;
[191]2419 }
2420 }
2421 WinSendMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
2422 }
[551]2423 PaintLine(hwnd, ad->hps, whichline, ad->topline, &Rectl);
2424 if (ad->cursored != wascursored) {
2425 PaintLine(hwnd, ad->hps, wascursored - 1, ad->topline, &Rectl);
[191]2426 PostMsg(hwnd, UM_SETUP4, MPVOID, MPVOID);
2427 }
2428 }
[551]2429 else {
[2]2430
[191]2431 SHORT numsels, sSelect = 0, numinserted;
[890]2432 ULONG linenum, size;
[1780]2433 CHAR *s = NULL, *p;
[2]2434
[551]2435 if (!ad->hex && ad->lines) {
[2]2436
[1780]2437 CHAR *e;
[2]2438
[551]2439 width = (Rectl.xRight - Rectl.xLeft) / ad->fattrs.lAveCharWidth;
2440 e = p = ad->lines[whichline];
2441 while (*e != '\r' && *e != '\n' && e < ad->text + ad->textsize) {
2442 if (ad->wrapon && e - p == width)
[191]2443 break;
2444 e++;
2445 }
2446 if ((*e == '\r' || *e == '\n') && e > p)
2447 e--;
2448 width = e - p;
2449 if (!width)
[1780]2450 goto NoAdd;
[2]2451
[890]2452 if ((ad->httpin && (*httprun || fHttpRunWPSDefault) &&
[1781]2453 strnstr(ad->lines[whichline], "http://", width)) ||
[890]2454 (ad->ftpin && (*ftprun || fFtpRunWPSDefault) &&
[1781]2455 strnstr(ad->lines[whichline], "ftp://", width)) ||
2456 (ad->mailin && *mailrun && strchr(ad->lines[whichline], '@'))) {
[2]2457
[191]2458 USHORT ret;
2459 URLDATA *urld;
[2]2460
[551]2461 urld = xmallocz(sizeof(URLDATA), pszSrcFile, __LINE__);
[350]2462 if (urld) {
[551]2463 urld->size = sizeof(URLDATA);
[1781]2464 urld->line = ad->lines[whichline];
[551]2465 urld->len = width;
[191]2466 ret = (USHORT) WinDlgBox(HWND_DESKTOP, hwnd, UrlDlgProc,
2467 FM3ModHandle, URL_FRAME, urld);
[350]2468 switch (ret) {
[191]2469 case 0:
[1335]2470 free(urld);
[191]2471 goto NoAdd;
2472 case 1:
[1335]2473 if (*urld->url) {
2474 if (fHttpRunWPSDefault) {
2475 CHAR WPSDefaultHttpRun[CCHMAXPATH], WPSDefaultHttpRunDir[CCHMAXPATH];
[890]2476
[1335]2477 size = sizeof(WPSDefaultHttpRun);
[1498]2478 PrfQueryProfileData(HINI_USERPROFILE, (CHAR *) PCSZ_WPURLDEFAULTSETTINGS,
[1335]2479 "DefaultBrowserExe", WPSDefaultHttpRun, &size);
2480 size = sizeof(WPSDefaultHttpRunDir);
[1498]2481 PrfQueryProfileData(HINI_USERPROFILE, (CHAR *) PCSZ_WPURLDEFAULTSETTINGS,
[1335]2482 "DefaultWorkingDir", WPSDefaultHttpRunDir, &size);
2483 runemf2(SEPARATE | WINDOWED,
2484 hwnd, pszSrcFile, __LINE__,
2485 WPSDefaultHttpRunDir,
[1400]2486 fLibPathStrictHttpRun ? pLibPathStrict : NULL,
[1335]2487 "%s %s", WPSDefaultHttpRun, urld->url);
2488 }
2489 else
2490 runemf2(SEPARATE | WINDOWED,
2491 hwnd, pszSrcFile, __LINE__,
2492 httprundir,
[1400]2493 fLibPathStrictHttpRun ? pLibPathStrict : NULL,
[1335]2494 "%s %s", httprun, urld->url);
2495 }
[1039]2496 free(urld);
[191]2497 goto NoAdd;
2498 case 2:
[1335]2499 if (*urld->url){
2500 if (fFtpRunWPSDefault) {
2501 CHAR WPSDefaultFtpRun[CCHMAXPATH], WPSDefaultFtpRunDir[CCHMAXPATH];
[890]2502
[1335]2503 size = sizeof(WPSDefaultFtpRun);
[1498]2504 PrfQueryProfileData(HINI_USERPROFILE, (CHAR *) PCSZ_WPURLDEFAULTSETTINGS,
[1335]2505 "DefaultBrowserExe", WPSDefaultFtpRun, &size);
2506 size = sizeof(WPSDefaultFtpRunDir);
[1498]2507 PrfQueryProfileData(HINI_USERPROFILE, (CHAR *) PCSZ_WPURLDEFAULTSETTINGS,
[1335]2508 "DefaultWorkingDir", WPSDefaultFtpRunDir, &size);
2509 runemf2(SEPARATE | WINDOWED,
2510 hwnd, pszSrcFile, __LINE__,
2511 WPSDefaultFtpRunDir,
[1400]2512 fLibPathStrictFtpRun ? pLibPathStrict : NULL,
[1335]2513 "%s %s", WPSDefaultFtpRun, urld->url);
2514 }
2515 else
2516 runemf2(SEPARATE | WINDOWED,
2517 hwnd, pszSrcFile, __LINE__,
2518 ftprundir,
[1400]2519 fLibPathStrictFtpRun ? pLibPathStrict : NULL,
[1335]2520 "%s %s", ftprun, urld->url);
2521 }
2522 free(urld);
[1780]2523 goto NoAdd;
2524 case 3:
[1335]2525 if (*urld->url){
2526 runemf2(SEPARATE | WINDOWED,
2527 hwnd, pszSrcFile, __LINE__,
2528 mailrundir,
[1400]2529 fLibPathStrictMailRun ? pLibPathStrict : NULL,
[1335]2530 "%s %s", mailrun, urld->url);
2531 }
2532 free(urld);
2533 goto NoAdd;
[191]2534 default:
2535 break;
2536 }
[1335]2537 free(urld);
[191]2538 }
2539 }
[1780]2540 }
2541 //Move line to selection box at top of viewer
2542 numsels = (SHORT) WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
2543 LM_QUERYITEMCOUNT, MPVOID,
2544 MPVOID);
2545 if (numsels > 0) {
2546 for (sSelect = 0; sSelect < numsels; sSelect++) {
2547 linenum =
2548 (ULONG) WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
2549 LM_QUERYITEMHANDLE,
2550 MPFROM2SHORT(sSelect, 0), MPVOID);
2551 if (linenum == whichline)
2552 goto NoAdd;
2553 }
2554 }
2555 //{
2556 if (!ad->hex && ad->lines) {
2557 s = xmalloc(width + 2, pszSrcFile, __LINE__);
2558 if (!s)
2559 goto NoAdd;
2560 strncpy(s, ad->lines[whichline], width + 1);
2561 s[width + 1] = 0;
2562 p = s;
2563 while (*p) {
2564 if (*p == '\r' || *p == '\n') {
2565 *p = 0;
2566 break;
2567 }
2568 p++;
2569 }
2570 }
2571 else {
[2]2572
[1780]2573 register ULONG x;
[2]2574
[1780]2575 width = ad->textsize - (whichline * 16);
2576 width = min(width, 16); //standard hexx line length
2577 //use 80 as width * 5 gives inconsistent format on short lines
2578 s = xmalloc(80, pszSrcFile, __LINE__);
2579 if (!s)
2580 goto NoAdd;
2581 sprintf(s, "%08lx ", whichline * 16);
2582 p = s + 9;
2583 for (x = 0; x < width; x++) {
2584 sprintf(p, " %02x", (UCHAR)ad->text[(whichline * 16) + x]);
2585 p += 3;
2586 }
2587 *p = ' ';
2588 p++;
2589 *p = ' ';
2590 p++;
2591 for (x = 0; x < width; x++) {
2592 *p = ad->text[(whichline * 16) + x];
2593 p++;
2594 }
2595 *p = 0;
2596 }
2597 if (s) {
2598 if (*s) {
2599 ad->dummy = TRUE;
2600 numinserted = (SHORT) WinSendDlgItemMsg(ad->hwndFrame,
2601 NEWVIEW_LISTBOX,
2602 LM_INSERTITEM,
2603 MPFROM2SHORT(LIT_END,
2604 0),
2605 MPFROMP(s));
2606 ad->dummy = FALSE;
2607 if (numinserted >= 0)
2608 WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX,
2609 LM_SETITEMHANDLE,
2610 MPFROM2SHORT(numinserted, 0),
2611 MPFROMLONG(whichline));
2612 }
2613 free(s);
2614 }
2615 //}
[191]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.