Changeset 1471 for trunk/dll/grep2.c
- Timestamp:
- Oct 14, 2009, 1:43:04 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dll/grep2.c
r1438 r1471 26 26 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook. 27 27 08 Mar 09 GKY Additional strings move to PCSZs in init.c 28 07 Oct 09 SHL Remember last search mask across runs 28 29 29 30 fixme for more excess locals to be gone … … 36 37 #include <share.h> 37 38 #include <time.h> 38 // #include <process.h> // _beginthread39 39 40 40 #define INCL_DOS 41 41 #define INCL_WIN 42 #define INCL_LONGLONG 43 #define INCL_WINSTDCNR 42 #define INCL_LONGLONG // dircnrs.h 43 #define INCL_WINSTDCNR // makelist.h 44 44 45 45 #include "fm3dll.h" … … 54 54 #include "mle.h" 55 55 #include "grep.h" 56 #include "errutil.h" 57 #include "strutil.h" 58 #include "pathutil.h" 59 #include "walkem.h" 56 #include "errutil.h" // Dos_Error... 57 #include "strutil.h" // GetPString 58 #include "pathutil.h" // BldFullPathName 59 #include "walkem.h" // FillPathListBox 60 60 #include "grep2.h" 61 61 #include "wrappers.h" // xfgets 62 #include "misc.h" 62 #include "misc.h" // LoadLibPath 63 63 #include "strips.h" // bstrip 64 64 #include "dirs.h" // save_dir2 65 65 #include "fortify.h" 66 66 #include "excputil.h" // xbeginthread 67 #include "valid.h" 67 #include "valid.h" // IsFile 68 68 69 69 #pragma data_seg(DATA1) 70 70 71 71 static PSZ pszSrcFile = __FILE__; 72 73 static PCSZ PSCZ_GREP_LASTMASK_SELECT = "Grep_LastMaskSelect"; 72 74 73 75 MRESULT EXPENTRY EnvDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) … … 159 161 bstrip(p); 160 162 if (!*p) { 161 163 if (!fAlertBeepOff) 162 164 DosBeep(50, 100); 163 165 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, ENV_NAME)); … … 190 192 SHORT sSelect; 191 193 CHAR *p; 192 CHAR s[8192 + 14]; 194 GREPINFO *GrepInfo; 195 ULONG size; 193 196 CHAR simple[8192]; 194 197 CHAR path[CCHMAXPATH]; 195 GREPINFO *GrepInfo; 196 197 static CHAR lastmask[8192] = "*"; 198 static CHAR lasttext[4096] = ""; 198 CHAR s[8192 + 14]; 199 200 // 07 Oct 09 SHL fixme to not be static and save to profile? 201 static CHAR lastmask[8192]; 202 static CHAR lasttext[4096]; 199 203 static BOOL recurse = TRUE; 200 static BOOL sensitive = FALSE;201 static BOOL absolute = FALSE;202 static BOOL sayfiles = TRUE;204 static BOOL sensitive; 205 static BOOL absolute; 206 static BOOL sayfiles; 203 207 static BOOL searchEAs = TRUE; 204 208 static BOOL searchFiles = TRUE; 205 static BOOL changed = FALSE; 209 static BOOL changed; 210 static BOOL fInitDone; // First time init done 206 211 static BOOL findifany = TRUE; 207 static BOOL gRemember = FALSE; 208 ULONG size; 212 static BOOL gRemember; 209 213 static UINT newer = 0; 210 214 static UINT older = 0; 211 215 static ULONG greater = 0; 212 216 static ULONG lesser = 0; 217 static SHORT sLastMaskSelect = LIT_NONE; 213 218 214 219 switch (msg) { … … 220 225 GrepInfo = mp2; 221 226 if (GrepInfo->szGrepPath && IsFile(GrepInfo->szGrepPath) == 0) { 222 BldFullPathName(lastmask, GrepInfo->szGrepPath, "*"); 223 } 227 BldFullPathName(lastmask, GrepInfo->szGrepPath, "*"); // Directory passed 228 sLastMaskSelect = LIT_NONE; 229 fInitDone = TRUE; 230 } 231 else if (sLastMaskSelect == LIT_NONE) { 232 size = sizeof(sLastMaskSelect); 233 PrfQueryProfileData(fmprof, appname, PSCZ_GREP_LASTMASK_SELECT, &sLastMaskSelect, &size); 234 if (sLastMaskSelect >= 0) 235 fInitDone = TRUE; 236 } 237 if (!fInitDone) { 238 lastmask[0] = '*'; 239 lastmask[1] = 0; 240 } 241 224 242 WinSetWindowULong(hwnd, QWL_USER, *(HWND *) GrepInfo->hwnd); 225 243 WinSendDlgItemMsg(hwnd, … … 303 321 WinEnableWindow(WinWindowFromID(hwnd, GREP_NOSIZEDUPES), FALSE); 304 322 323 // Fill mask listbox 305 324 BldFullPathName(s, pFM2SaveDirectory, PCSZ_GREPMASKDAT); 306 325 fp = _fsopen(s, "r", SH_DENYWR); … … 318 337 fclose(fp); 319 338 } 339 // 25 Sep 09 SHL Reselect last last used item 340 if (sLastMaskSelect >= 0) 341 WinSendDlgItemMsg(hwnd, GREP_LISTBOX, LM_SELECTITEM, 342 MPFROMSHORT(sLastMaskSelect), MPFROMSHORT(TRUE)); 320 343 321 344 FillPathListBox(hwnd, 322 345 WinWindowFromID(hwnd, GREP_DRIVELIST), 323 346 (HWND) 0, NULL, FALSE); 347 // 25 Sep 09 SHL fixme select drive matching current container? 324 348 break; 325 349 … … 334 358 335 359 case UM_FOCUSME: 336 / * set focus to window hwnd in mp1 */360 // set focus to window hwnd in mp1 337 361 if (mp1) 338 362 WinSetFocus(HWND_DESKTOP, (HWND) mp1); … … 409 433 } 410 434 } 411 break; 412 } 435 break; // LN_ENTER 436 } // switch 413 437 break; 414 438 … … 435 459 MPFROMSHORT(LIT_FIRST), MPVOID); 436 460 if (sSelect >= 0) { 461 sLastMaskSelect = sSelect; 437 462 *s = 0; 438 463 if (WinQueryButtonCheckstate(hwnd, GREP_APPEND)) { … … 650 675 } 651 676 rstrip(s); 677 // 25 Sep 09 SHL fixme to honor append 652 678 if (*s) { 653 679 strcat(s, simple); … … 692 718 GREP_LISTBOX, 693 719 LM_DELETEITEM, MPFROM2SHORT(sSelect, 0), MPVOID); 720 if (sSelect >= sLastMaskSelect) 721 sLastMaskSelect--; 694 722 changed = TRUE; 695 723 } … … 812 840 else { 813 841 // 07 Feb 08 SHL - fixme to malloc and free in thread 814 static GREP g; // Passed to thread 815 842 static GREP g; // Passed to thread 816 843 p = xmalloc(8192 + 512, pszSrcFile, __LINE__); 817 844 if (!p) … … 841 868 (PVOID) & searchEAs, sizeof(BOOL)); 842 869 } 870 PrfWriteProfileData(fmprof, appname, 871 PSCZ_GREP_LASTMASK_SELECT, &sLastMaskSelect, sizeof(sLastMaskSelect)); 843 872 g.finddupes = WinQueryButtonCheckstate(hwnd, GREP_FINDDUPES) != 0; 844 873 if (g.finddupes) { … … 854 883 bstrip(p); 855 884 if (!*p) { 856 885 if (!fAlertBeepOff) 857 886 DosBeep(50, 100); 858 887 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, GREP_MASK)); … … 976 1005 } 977 1006 if (changed) { 978 // Grep mask list changed1007 // Save modified mask list 979 1008 SHORT x; 980 1009 … … 983 1012 LM_QUERYITEMCOUNT, 984 1013 MPVOID, MPVOID); 985 if (sSelect > 0) { 1014 // 07 Oct 09 SHL Rewrite if list empty 1015 if (sSelect >= 0) { 986 1016 BldFullPathName(s, pFM2SaveDirectory, PCSZ_GREPMASKDAT); 987 1017 if (CheckDriveSpaceAvail(s, ullDATFileSpaceNeeded, 1) == 2)
Note:
See TracChangeset
for help on using the changeset viewer.