Changeset 890 for trunk/dll/newview.c
- Timestamp:
- Dec 28, 2007, 7:44:08 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/newview.c
r888 r890 27 27 10 Oct 07 SHL Correct ReLineThread typo 28 28 17 Dec 07 GKY Make WPURLDEFAULTSETTINGS the fall back for ftp/httprun 29 28 Dec 07 GKY Add mailrun to allow mailto by clicking on an email address in the viewer 29 30 30 31 ***********************************************************************/ … … 60 61 #define FIXED_FONT_LCID 5 61 62 62 #define COLORS_MAX 1 263 #define COLORS_MAX 14 63 64 64 65 #define COLORS_CURSOREDNORMALBACK 0 … … 74 75 #define COLORS_FTPBACK 10 75 76 #define COLORS_FTPFORE 11 77 #define COLORS_MAILBACK 12 78 #define COLORS_MAILFORE 13 76 79 77 80 static LONG Colors[COLORS_MAX] = { COLR_WHITE, COLR_DARKGRAY, … … 80 83 COLR_WHITE, COLR_YELLOW, 81 84 COLR_PALEGRAY, COLR_DARKBLUE, 82 COLR_PALEGRAY, COLR_DARKGREEN 85 COLR_PALEGRAY, COLR_DARKGREEN, 86 COLR_PALEGRAY, COLR_DARKRED 83 87 }; 84 88 … … 100 104 maxx, horzscroll; 101 105 BOOL hex, mousecaptured, sensitive, dummy, literalsearch, clientfocused, 102 alsoselect, wrapon, relining, httpin, ftpin, ignorehttp, ignoreftp,103 needrefreshing;106 alsoselect, wrapon, relining, httpin, ftpin, mailin, ignorehttp, ignoreftp, 107 ignoremail, needrefreshing; 104 108 HMTX ScanSem; 105 109 HWND hvscroll, hwndMenu, hwndStatus1, hwndStatus2, hwndStatus3, hwndRestore, … … 129 133 static BOOL IgnoreFTP = FALSE; 130 134 static BOOL IgnoreHTTP = FALSE; 135 static BOOL IgnoreMail = FALSE; 131 136 static FATTRS Fattrs; 137 138 // mailstr checks for a designated character in a string then cuts the string 139 //to the first word that contains the character 140 141 CHAR *mailstr(CHAR *t, CHAR *s, LONG lens) 142 { 143 CHAR *pp; 144 CHAR *test = t; 145 146 if (!strnstr(test, s, lens)) 147 return NULL; 148 bstripcr(t); 149 if (!strstr(t, " ")) 150 return t; 151 while (strchr(t, ' ') < strchr(t, (CHAR) s)){ 152 pp = t; 153 while (*pp && *pp != ' '){ 154 *pp = ' '; 155 pp++; 156 } 157 lstrip(t); 158 } 159 pp = t; 160 while (*pp && *pp != ' ' && *pp != '\r' && *pp != '\n' && 161 *pp != '\"') 162 pp++; 163 *pp = 0; 164 printf("%s", t); fflush(stdout); 165 strip_lead_char(t, "<"); 166 strip_trail_char(t, ">"); 167 return t; 168 } 132 169 133 170 MRESULT EXPENTRY UrlDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) … … 175 212 MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url)); 176 213 p++; 177 214 } 178 215 } 179 216 while (p && *p && p < e); 217 p = urld->line; 218 if (mailstr(p, "@", e - p)) { 219 strcpy(urld->url, p); 220 WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_INSERTITEM, 221 MPFROM2SHORT(LIT_END, 0), MPFROMP(urld->url)); 222 } 180 223 *urld->url = 0; 181 224 count = (SHORT) WinSendDlgItemMsg(hwnd, URL_LISTBOX, LM_QUERYITEMCOUNT, … … 241 284 break; 242 285 } 243 } 286 } 287 else if (!strncmp(urld->url, "@", 1)) { 288 memmove(urld->url, urld->url + 6, strlen(urld->url) + 1); 289 if (*urld->url) { 290 WinDismissDlg(hwnd, 3); 291 break; 292 } 293 } 244 294 } 245 295 } … … 709 759 GpiSetColor(hps, standardcolors[ad->colors[COLORS_HTTPFORE]]); 710 760 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_HTTPBACK]]); 761 } 762 763 if (ad->mailin && whichline != ad->cursored - 1 764 && (!ad->markedlines 765 || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND))) 766 && strnstr(ad->lines[whichline], "@",e - ad->lines[whichline])) { 767 GpiSetColor(hps, standardcolors[ad->colors[COLORS_MAILFORE]]); 768 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_MAILBACK]]); 711 769 } 712 770 rcl2 = *Rectl; … … 762 820 && (!ad->markedlines 763 821 || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND))) 764 && strnstr(ad->lines[whichline], "http://", 765 e - ad->lines[whichline])) { 822 && strnstr(ad->lines[whichline], "http://",e - ad->lines[whichline])) { 766 823 GpiSetColor(hps, standardcolors[ad->colors[COLORS_HTTPFORE]]); 767 824 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_HTTPBACK]]); 825 } 826 827 if (ad->mailin && whichline != ad->cursored - 1 828 && (!ad->markedlines 829 || !(ad->markedlines[whichline] & (VF_SELECTED | VF_FOUND))) 830 && strnstr(ad->lines[whichline], "@",e - ad->lines[whichline])) { 831 GpiSetColor(hps, standardcolors[ad->colors[COLORS_MAILFORE]]); 832 GpiSetBackColor(hps, standardcolors[ad->colors[COLORS_MAILBACK]]); 768 833 } 769 834 rcl2 = *Rectl; … … 1228 1293 ad->selected = 0; 1229 1294 } 1230 if (*ftprun && !ad->ignoreftp && strstr(ad->text, "ftp://")) 1295 if ((*ftprun || fFtpRunWPSDefault) && !ad->ignoreftp && 1296 strstr(ad->text, "ftp://")) 1231 1297 ad->ftpin = TRUE; 1232 if (*httprun && !ad->ignorehttp && strstr(ad->text, "http://")) 1233 ad->httpin = TRUE; 1298 if ((*httprun || fHttpRunWPSDefault) && !ad->ignorehttp && 1299 strstr(ad->text, "http://")) 1300 ad->httpin = TRUE; 1301 if (*mailrun && !ad->ignoremail && strstr(ad->text, "@")) 1302 ad->mailin = TRUE; 1234 1303 } 1235 1304 } … … 1286 1355 ad->lines = NULL; 1287 1356 ad->markedlines = NULL; 1288 ad->ftpin = ad->httpin = FALSE;1357 ad->ftpin = ad->httpin = ad->mailin = FALSE; 1289 1358 ad->selected = ad->numlines = ad->textsize = ad->numalloc = 0; 1290 1359 WinSendDlgItemMsg(ad->hwndFrame, NEWVIEW_LISTBOX, LM_DELETEALL, … … 2201 2270 RECTL Rectl; 2202 2271 POINTS pts; 2272 //CHAR *mailstring; 2203 2273 2204 2274 WinQueryWindowRect(hwnd, &Rectl); … … 2249 2319 2250 2320 SHORT numsels, sSelect = 0, numinserted; 2251 ULONG linenum ;2321 ULONG linenum, size; 2252 2322 2253 2323 if (!ad->hex && ad->lines) { … … 2266 2336 width = e - p; 2267 2337 if (!width) 2268 2269 2270 if ((ad->httpin && *httprun&&2338 goto NoAdd; 2339 2340 if ((ad->httpin && (*httprun || fHttpRunWPSDefault) && 2271 2341 strnstr(ad->lines[whichline], "http://", width)) || 2272 (ad->ftpin && *ftprun && 2273 strnstr(ad->lines[whichline], "ftp://", width))) { 2342 (ad->ftpin && (*ftprun || fFtpRunWPSDefault) && 2343 strnstr(ad->lines[whichline], "ftp://", width)) || 2344 (ad->mailin && *mailrun && mailstr(ad->lines[whichline], "@", width))) { 2274 2345 2275 2346 USHORT ret; … … 2285 2356 switch (ret) { 2286 2357 case 0: 2287 2358 free(urld); 2288 2359 goto NoAdd; 2289 2360 case 1: 2290 if (*urld->url) 2291 runemf2(SEPARATE | WINDOWED, 2292 hwnd, pszSrcFile, __LINE__, 2293 httprund, NULL, "%s %s", httprun, urld->url); 2361 if (*urld->url) { 2362 if (fHttpRunWPSDefault) { 2363 CHAR WPSDefaultHttpRun[CCHMAXPATH], WPSDefaultHttpRunDir[CCHMAXPATH]; 2364 2365 size = sizeof(WPSDefaultHttpRun); 2366 PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", 2367 "DefaultBrowserExe", WPSDefaultHttpRun, &size); 2368 size = sizeof(WPSDefaultHttpRunDir); 2369 PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", 2370 "DefaultWorkingDir", WPSDefaultHttpRunDir, &size); 2371 runemf2(SEPARATE | WINDOWED, 2372 hwnd, pszSrcFile, __LINE__, 2373 WPSDefaultHttpRunDir, 2374 fLibPathStrictHttpRun ? "SET LIBPATHSTRICT=TRUE" : NULL, 2375 "%s %s", WPSDefaultHttpRun, urld->url); 2376 } 2377 else 2378 runemf2(SEPARATE | WINDOWED, 2379 hwnd, pszSrcFile, __LINE__, 2380 httprundir, NULL, "%s %s", httprun, urld->url); 2381 } 2294 2382 free(urld); 2295 2383 goto NoAdd; 2296 2384 case 2: 2297 if (*urld->url) 2298 runemf2(SEPARATE | WINDOWED, 2385 if (*urld->url){ 2386 if (fFtpRunWPSDefault) { 2387 CHAR WPSDefaultFtpRun[CCHMAXPATH], WPSDefaultFtpRunDir[CCHMAXPATH]; 2388 2389 size = sizeof(WPSDefaultFtpRun); 2390 PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", 2391 "DefaultBrowserExe", WPSDefaultFtpRun, &size); 2392 size = sizeof(WPSDefaultFtpRunDir); 2393 PrfQueryProfileData(HINI_USERPROFILE, "WPURLDEFAULTSETTINGS", 2394 "DefaultWorkingDir", WPSDefaultFtpRunDir, &size); 2395 runemf2(SEPARATE | WINDOWED, 2396 hwnd, pszSrcFile, __LINE__, 2397 WPSDefaultFtpRunDir, 2398 fLibPathStrictFtpRun ? "SET LIBPATHSTRICT=TRUE" : NULL, 2399 "%s %s", WPSDefaultFtpRun, urld->url); 2400 } 2401 else 2402 runemf2(SEPARATE | WINDOWED, 2403 hwnd, pszSrcFile, __LINE__, 2404 ftprundir, NULL, "%s %s", ftprun, urld->url); 2405 } 2406 case 3: 2407 if (*urld->url){ 2408 runemf2(SEPARATE | WINDOWED, 2299 2409 hwnd, pszSrcFile, __LINE__, 2300 ftprund, NULL, "%s %s", ftprun, urld->url); 2301 free(urld); 2302 goto NoAdd; 2410 mailrundir, NULL, "%s %s", mailrun, urld->url); 2411 } 2412 free(urld); 2413 goto NoAdd; 2303 2414 default: 2304 2415 break; 2305 2416 } 2306 2417 free(urld); 2307 2418 } 2308 2419 } … … 2577 2688 IDM_PREVBLANKLINE), !ad->hex); 2578 2689 if (ad->numlines) 2579 //{ // 27 Aug 07 GKY This creates a duplicate error for a zero byte file2580 // if (!ad->text)2581 // Runtime_Error(pszSrcFile, __LINE__, "no data");2582 // PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);2583 // }2584 // else2585 2690 { 2586 2691 if (mp1 && (ULONG) mp1 < ad->numlines + 1) { … … 2941 3046 WinCheckMenuItem((HWND) mp2, IDM_IGNOREFTP, ad->ignoreftp); 2942 3047 WinCheckMenuItem((HWND) mp2, IDM_IGNOREHTTP, ad->ignorehttp); 3048 WinCheckMenuItem((HWND) mp2, IDM_IGNOREMAIL, ad->ignoremail); 2943 3049 break; 2944 3050 … … 3132 3238 ad->ignoreftp = (ad->ignoreftp) ? FALSE : TRUE; 3133 3239 ad->ftpin = FALSE; 3134 if (ad->text && *ftprun && !ad->ignoreftp && strstr(ad->text, "ftp://")) 3240 if (ad->text && (*ftprun || fFtpRunWPSDefault) && 3241 !ad->ignoreftp && strstr(ad->text, "ftp://")) 3135 3242 ad->ftpin = TRUE; 3136 3243 IgnoreFTP = ad->ignoreftp; … … 3143 3250 ad->ignorehttp = (ad->ignorehttp) ? FALSE : TRUE; 3144 3251 ad->httpin = FALSE; 3145 if (ad->text && *httprun&& !ad->ignorehttp &&3252 if (ad->text && (*httprun || fHttpRunWPSDefault) && !ad->ignorehttp && 3146 3253 strstr(ad->text, "http://")) 3147 3254 ad->httpin = TRUE; … … 3149 3256 PrfWriteProfileData(fmprof, appname, "Viewer.IgnoreHTTP", 3150 3257 &ad->ignorehttp, sizeof(BOOL)); 3258 WinInvalidateRect(hwnd, NULL, FALSE); 3259 break; 3260 3261 case IDM_IGNOREMAIL: 3262 ad->ignoremail = (ad->ignoremail) ? FALSE : TRUE; 3263 ad->mailin = FALSE; 3264 if (ad->text && *mailrun && !ad->ignoremail && 3265 strstr(ad->text, "@")) 3266 ad->mailin = TRUE; 3267 IgnoreMail = ad->ignoremail; 3268 PrfWriteProfileData(fmprof, appname, "Viewer.IgnoreMail", 3269 &ad->ignoremail, sizeof(BOOL)); 3151 3270 WinInvalidateRect(hwnd, NULL, FALSE); 3152 3271 break; … … 3891 4010 size = sizeof(BOOL); 3892 4011 PrfQueryProfileData(fmprof, appname, "Viewer.IgnoreHTTP", 3893 (PVOID) & IgnoreHTTP, &size); 4012 (PVOID) & IgnoreHTTP, &size); 4013 size = sizeof(BOOL); 4014 PrfQueryProfileData(fmprof, appname, "Viewer.IgnoreMail", 4015 (PVOID) & IgnoreMail, &size); 3894 4016 memset(&Fattrs, 0, sizeof(FATTRS)); 3895 4017 size = sizeof(FATTRS); … … 3921 4043 ad->ignorehttp = IgnoreHTTP; 3922 4044 ad->ignoreftp = IgnoreFTP; 4045 ad->ignoremail = IgnoreMail; 3923 4046 memcpy(ad->colors, Colors, sizeof(LONG) * COLORS_MAX); 3924 4047 WinSetWindowPtr(hwndClient, QWL_USER, (PVOID) ad);
Note:
See TracChangeset
for help on using the changeset viewer.