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