Changeset 1471 for trunk/dll/grep2.c


Ignore:
Timestamp:
Oct 14, 2009, 1:43:04 AM (16 years ago)
Author:
Steven Levine
Message:

Remember last filter mask selection
Use Ctrl-click to select state or commonly used directory quicklist entry without activating.
Use Ctrl-click to select walk dialog user list entry without activating.
Avoid drivebar MB2 exception
Remember last seek and scan mask selection across runs
Avoid traps when changing tree container display style
Restore missing drives to drive list dropdown
Minor documentation updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/grep2.c

    r1438 r1471  
    2626  07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
    2727  08 Mar 09 GKY Additional strings move to PCSZs in init.c
     28  07 Oct 09 SHL Remember last search mask across runs
    2829
    2930  fixme for more excess locals to be gone
     
    3637#include <share.h>
    3738#include <time.h>
    38 // #include <process.h>                    // _beginthread
    3939
    4040#define INCL_DOS
    4141#define INCL_WIN
    42 #define INCL_LONGLONG                   // dircnrs.h
    43 #define INCL_WINSTDCNR                  // makelist.h
     42#define INCL_LONGLONG                   // dircnrs.h
     43#define INCL_WINSTDCNR                  // makelist.h
    4444
    4545#include "fm3dll.h"
     
    5454#include "mle.h"
    5555#include "grep.h"
    56 #include "errutil.h"                    // Dos_Error...
    57 #include "strutil.h"                    // GetPString
    58 #include "pathutil.h"                   // BldFullPathName
    59 #include "walkem.h"                     // FillPathListBox
     56#include "errutil.h"                    // Dos_Error...
     57#include "strutil.h"                    // GetPString
     58#include "pathutil.h"                   // BldFullPathName
     59#include "walkem.h"                     // FillPathListBox
    6060#include "grep2.h"
    6161#include "wrappers.h"                   // xfgets
    62 #include "misc.h"                       // LoadLibPath
     62#include "misc.h"                       // LoadLibPath
    6363#include "strips.h"                     // bstrip
    6464#include "dirs.h"                       // save_dir2
    6565#include "fortify.h"
    6666#include "excputil.h"                   // xbeginthread
    67 #include "valid.h"                      // IsFile
     67#include "valid.h"                      // IsFile
    6868
    6969#pragma data_seg(DATA1)
    7070
    7171static PSZ pszSrcFile = __FILE__;
     72
     73static PCSZ PSCZ_GREP_LASTMASK_SELECT = "Grep_LastMaskSelect";
    7274
    7375MRESULT EXPENTRY EnvDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     
    159161        bstrip(p);
    160162        if (!*p) {
    161           if (!fAlertBeepOff)
     163          if (!fAlertBeepOff)
    162164            DosBeep(50, 100);
    163165          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, ENV_NAME));
     
    190192  SHORT sSelect;
    191193  CHAR *p;
    192   CHAR s[8192 + 14];
     194  GREPINFO *GrepInfo;
     195  ULONG size;
    193196  CHAR simple[8192];
    194197  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];
    199203  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;
    203207  static BOOL searchEAs = TRUE;
    204208  static BOOL searchFiles = TRUE;
    205   static BOOL changed = FALSE;
     209  static BOOL changed;
     210  static BOOL fInitDone;                // First time init done
    206211  static BOOL findifany = TRUE;
    207   static BOOL gRemember = FALSE;
    208   ULONG size;
     212  static BOOL gRemember;
    209213  static UINT newer = 0;
    210214  static UINT older = 0;
    211215  static ULONG greater = 0;
    212216  static ULONG lesser = 0;
     217  static SHORT sLastMaskSelect = LIT_NONE;
    213218
    214219  switch (msg) {
     
    220225    GrepInfo = mp2;
    221226    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
    224242    WinSetWindowULong(hwnd, QWL_USER, *(HWND *) GrepInfo->hwnd);
    225243    WinSendDlgItemMsg(hwnd,
     
    303321    WinEnableWindow(WinWindowFromID(hwnd, GREP_NOSIZEDUPES), FALSE);
    304322
     323    // Fill mask listbox
    305324    BldFullPathName(s, pFM2SaveDirectory, PCSZ_GREPMASKDAT);
    306325    fp = _fsopen(s, "r", SH_DENYWR);
     
    318337      fclose(fp);
    319338    }
     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));
    320343
    321344    FillPathListBox(hwnd,
    322345                    WinWindowFromID(hwnd, GREP_DRIVELIST),
    323346                    (HWND) 0, NULL, FALSE);
     347    // 25 Sep 09 SHL fixme select drive matching current container?
    324348    break;
    325349
     
    334358
    335359  case UM_FOCUSME:
    336     /* set focus to window hwnd in mp1 */
     360    // set focus to window hwnd in mp1
    337361    if (mp1)
    338362      WinSetFocus(HWND_DESKTOP, (HWND) mp1);
     
    409433          }
    410434        }
    411         break;                          // LN_ENTER
    412       }                                 // switch
     435        break; // LN_ENTER
     436      } // switch
    413437      break;
    414438
     
    435459                                              MPFROMSHORT(LIT_FIRST), MPVOID);
    436460          if (sSelect >= 0) {
     461            sLastMaskSelect = sSelect;
    437462            *s = 0;
    438463            if (WinQueryButtonCheckstate(hwnd, GREP_APPEND)) {
     
    650675          }
    651676          rstrip(s);
     677          // 25 Sep 09 SHL fixme to honor append
    652678          if (*s) {
    653679            strcat(s, simple);
     
    692718                          GREP_LISTBOX,
    693719                          LM_DELETEITEM, MPFROM2SHORT(sSelect, 0), MPVOID);
     720        if (sSelect >= sLastMaskSelect)
     721          sLastMaskSelect--;
    694722        changed = TRUE;
    695723      }
     
    812840      else {
    813841        // 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
    816843        p = xmalloc(8192 + 512, pszSrcFile, __LINE__);
    817844        if (!p)
     
    841868                              (PVOID) & searchEAs, sizeof(BOOL));
    842869        }
     870        PrfWriteProfileData(fmprof, appname,
     871                            PSCZ_GREP_LASTMASK_SELECT, &sLastMaskSelect, sizeof(sLastMaskSelect));
    843872        g.finddupes = WinQueryButtonCheckstate(hwnd, GREP_FINDDUPES) != 0;
    844873        if (g.finddupes) {
     
    854883        bstrip(p);
    855884        if (!*p) {
    856           if (!fAlertBeepOff)
     885          if (!fAlertBeepOff)
    857886            DosBeep(50, 100);
    858887          WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, GREP_MASK));
     
    9761005      }
    9771006      if (changed) {
    978         // Grep mask list changed
     1007        // Save modified mask list
    9791008        SHORT x;
    9801009
     
    9831012                                            LM_QUERYITEMCOUNT,
    9841013                                            MPVOID, MPVOID);
    985         if (sSelect > 0) {
     1014        // 07 Oct 09 SHL Rewrite if list empty
     1015        if (sSelect >= 0) {
    9861016          BldFullPathName(s, pFM2SaveDirectory, PCSZ_GREPMASKDAT);
    9871017          if (CheckDriveSpaceAvail(s, ullDATFileSpaceNeeded, 1) == 2)
Note: See TracChangeset for help on using the changeset viewer.